Remove some compilation warnings.

This commit is contained in:
JunjieBai 2023-04-23 16:27:45 +08:00
parent 12d5e76cc5
commit c5304dfe94
16 changed files with 43 additions and 115 deletions

View File

@ -266,59 +266,6 @@ void MainWindow::ScreenGeometryChanged(QRect rect) {
} }
} }
/**
* @brief MainWindow::moveToPanel
*/
void MainWindow::moveToPanel() {
QRect availableGeometry = qApp->primaryScreen()->availableGeometry();
QRect screenGeometry = qApp->primaryScreen()->geometry();
QDBusInterface primaryScreenInterface("org.ukui.SettingsDaemon",
"/org/ukui/SettingsDaemon/wayland",
"org.ukui.SettingsDaemon.wayland",
QDBusConnection::sessionBus());
if(QDBusReply<int>(primaryScreenInterface.call("x")).isValid()) {
QDBusReply<int> x = primaryScreenInterface.call("x");
QDBusReply<int> y = primaryScreenInterface.call("y");
QDBusReply<int> width = primaryScreenInterface.call("width");
QDBusReply<int> height = primaryScreenInterface.call("height");
screenGeometry.setX(x);
screenGeometry.setY(y);
screenGeometry.setWidth(width);
screenGeometry.setHeight(height);
availableGeometry.setX(x);
availableGeometry.setY(y);
availableGeometry.setWidth(width);
availableGeometry.setHeight(height);
}
QDesktopWidget * desktopWidget = QApplication::desktop();
QRect screenMainRect = desktopWidget->screenGeometry(0);//获取设备屏幕大小
QDBusInterface interface("com.ukui.panel.desktop",
"/",
"com.ukui.panel.desktop",
QDBusConnection::sessionBus());
int position = QDBusReply<int>(interface.call("GetPanelPosition", "position"));
int height = QDBusReply<int>(interface.call("GetPanelSize", "height"));
int d = 8; //窗口边沿到任务栏距离
if(position == 0) {
//任务栏在下侧
this->move(availableGeometry.x() + availableGeometry.width() - this->width() - d, screenGeometry.y() + screenGeometry.height() - this->height() - height - d);
} else if(position == 1) {
//任务栏在上侧
this->move(availableGeometry.x() + availableGeometry.width() - this->width() - d, screenGeometry.y() + height + d);
} else if(position == 2) {
//任务栏在左侧
this->move(screenGeometry.x() + height + d, screenGeometry.y() + screenGeometry.height() - this->height() - d);
} else if(position == 3) {
//任务栏在右侧
this->move(screenGeometry.x() + screenGeometry.width() - this->width() - height - d, screenGeometry.y() + screenGeometry.height() - this->height() - d);
}
}
/** /**
* @brief MainWindow::centerToScreen 使 * @brief MainWindow::centerToScreen 使
* @param widget * @param widget

View File

@ -67,11 +67,6 @@ class MainWindow : public QMainWindow {
public: public:
explicit MainWindow(QWidget *parent = nullptr); explicit MainWindow(QWidget *parent = nullptr);
~MainWindow(); ~MainWindow();
/**
* @brief Load the main window
* The position which mainwindow shows follow the ukui-panel.
*/
void moveToPanel();
// The position which mainwindow shows in the center of screen where the cursor in. // The position which mainwindow shows in the center of screen where the cursor in.
void centerToScreen(QWidget* widget); void centerToScreen(QWidget* widget);

View File

@ -135,25 +135,6 @@ const bool &SearchResultModel::isExpanded()
return m_isExpanded; return m_isExpanded;
} }
/**
* @brief SearchResultModel::getActions
* @param index
* @return
*/
QStringList SearchResultModel::getActions(const QModelIndex &index)
{
if (m_item->m_result_info_list.length() > index.row() && index.row() >= 0)
// return m_item->m_result_info_list.at(index.row()).actionList;
return QStringList();
}
QString SearchResultModel::getKey(const QModelIndex &index)
{
if (m_item->m_result_info_list.length() > index.row() && index.row() >= 0)
// return m_item->m_result_info_list.at(index.row()).key;
return NULL;
}
void SearchResultModel::refresh() void SearchResultModel::refresh()
{ {
this->beginResetModel(); this->beginResetModel();

View File

@ -54,8 +54,6 @@ public:
const SearchPluginIface::ResultInfo & getInfo(const QModelIndex&); const SearchPluginIface::ResultInfo & getInfo(const QModelIndex&);
void setExpanded(const bool&); void setExpanded(const bool&);
const bool &isExpanded(); const bool &isExpanded();
QStringList getActions(const QModelIndex &);
QString getKey(const QModelIndex &);
void refresh(); void refresh();
public Q_SLOTS: public Q_SLOTS:

View File

@ -109,6 +109,9 @@ ApplicationPropertyHelper::ApplicationPropertyHelper(ApplicationProperty::Proper
case ApplicationProperty::AutoStart: case ApplicationProperty::AutoStart:
d->m_databaseField = "AUTO_START"; d->m_databaseField = "AUTO_START";
d->m_valueType = QMetaType::Int; d->m_valueType = QMetaType::Int;
break;
default:
break;
} }
} }

View File

@ -781,14 +781,9 @@ QString FileUtils::escapeHtml(const QString &str)
return temp; return temp;
} }
QString FileUtils::chineseSubString(const std::string &myStr, int start, int length) QString FileUtils::chineseSubString(const std::string &myStr, uint start, uint length)
{ {
std::string afterSub = ""; std::string afterSub = "";
//越界保护
if(start < 0 || length < 0){
return " ";
}
QString sub = QString::fromStdString(myStr); QString sub = QString::fromStdString(myStr);
QFont ft(QApplication::font().family(),QApplication::font().pointSize()); QFont ft(QApplication::font().family(),QApplication::font().pointSize());
QFontMetrics fm (ft); QFontMetrics fm (ft);
@ -813,7 +808,7 @@ QString FileUtils::chineseSubString(const std::string &myStr, int start, int len
} }
sub = fm.elidedText(sub, Qt::ElideRight, 2*LABEL_MAX_WIDTH); //超过两行则省略 sub = fm.elidedText(sub, Qt::ElideRight, 2*LABEL_MAX_WIDTH); //超过两行则省略
} else { } else {
int newStart = myStr.length()-length; //更新截取位置 uint newStart = myStr.length()-length; //更新截取位置
afterSub = myStr.substr(newStart, length); afterSub = myStr.substr(newStart, length);
sub=QString::fromStdString(afterSub); sub=QString::fromStdString(afterSub);
@ -850,7 +845,7 @@ bool FileUtils::isOpenXMLFileEncrypted(const QString &path)
return true; return true;
} }
//比较前四位是否为对应值来判断OpenXML类型文件是否加密 //比较前四位是否为对应值来判断OpenXML类型文件是否加密
if (encrypt[0] == 0x50 && encrypt[1] == 0x4b && encrypt[2] == 0x03 && encrypt[3] == 0x04) { if ((encrypt[0] & 0x50) && (encrypt[1] & 0x4b) && (encrypt[2] & 0x03) && (encrypt[3] & 0x04)) {
return false; return false;
} else { } else {
qDebug() << "Encrypt!" << path; qDebug() << "Encrypt!" << path;

View File

@ -62,7 +62,7 @@ public:
static int openFile(QString &path, bool openInDir = false); static int openFile(QString &path, bool openInDir = false);
static bool copyPath(QString &path); static bool copyPath(QString &path);
static QString escapeHtml(const QString &str); static QString escapeHtml(const QString &str);
static QString chineseSubString(const std::string &myStr,int start,int length); static QString chineseSubString(const std::string &myStr, uint start, uint length);
static QIcon iconFromTheme(const QString &name, const QIcon &iconDefault); static QIcon iconFromTheme(const QString &name, const QIcon &iconDefault);
static bool isOpenXMLFileEncrypted(const QString &path); static bool isOpenXMLFileEncrypted(const QString &path);
/** /**

View File

@ -300,6 +300,7 @@ void DirSearchPlugin::openAction(int actionkey, QString key, int type)
break; break;
case 1: case 1:
FileUtils::openFile(key, true); FileUtils::openFile(key, true);
break;
case 2: case 2:
FileUtils::copyPath(key); FileUtils::copyPath(key);
default: default:
@ -480,6 +481,7 @@ void FileContengSearchPlugin::openAction(int actionkey, QString key, int type)
break; break;
case 1: case 1:
FileUtils::openFile(key, true); FileUtils::openFile(key, true);
break;
case 2: case 2:
FileUtils::copyPath(key); FileUtils::copyPath(key);
default: default:

View File

@ -417,11 +417,11 @@ int OcrSearch::keywordSearchOcr() {
std::vector<KeyWord> sKeyWord = ChineseSegmentation::getInstance()->callSegment(m_keyword); std::vector<KeyWord> sKeyWord = ChineseSegmentation::getInstance()->callSegment(m_keyword);
//Creat a query //Creat a query
std::string words; std::string words;
for(int i = 0; i < sKeyWord.size(); i++) { for(size_t i = 0; i < sKeyWord.size(); i++) {
words.append(sKeyWord.at(i).word).append(" "); words.append(sKeyWord.at(i).word).append(" ");
} }
std::vector<Xapian::Query> v; std::vector<Xapian::Query> v;
for(int i=0; i<sKeyWord.size(); i++) { for(size_t i = 0; i < sKeyWord.size(); i++) {
v.push_back(Xapian::Query(sKeyWord.at(i).word)); v.push_back(Xapian::Query(sKeyWord.at(i).word));
qDebug() << QString::fromStdString(sKeyWord.at(i).word); qDebug() << QString::fromStdString(sKeyWord.at(i).word);
} }

View File

@ -44,11 +44,11 @@ public:
private: private:
QString m_name; QString m_name;
QString m_path;
int m_order;
bool m_enable; bool m_enable;
bool m_isExternal; int m_order;
bool m_isFixed; bool m_isFixed;
bool m_isExternal;
QString m_path;
}; };
} }

View File

@ -80,6 +80,8 @@ SearchResultPropertyInfo::SearchResultPropertyInfo(SearchProperty::SearchResultP
d->m_displayName = tr("application package name"); d->m_displayName = tr("application package name");
d->m_valueType = QMetaType::QString; d->m_valueType = QMetaType::QString;
break; break;
default:
break;
} }
} }

View File

@ -149,7 +149,7 @@ QWidget *Search::pluginUi()
} }
} }
}); });
connect(m_webEngineFrame->mCombox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [=](int index) { connect(m_webEngineFrame->mCombox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [=] {
if (m_gsettings && m_gsettings->keys().contains(WEB_ENGINE_KEY)) { if (m_gsettings && m_gsettings->keys().contains(WEB_ENGINE_KEY)) {
m_gsettings->set(WEB_ENGINE_KEY, m_webEngineFrame->mCombox->currentData().toString()); m_gsettings->set(WEB_ENGINE_KEY, m_webEngineFrame->mCombox->currentData().toString());
} }

View File

@ -170,7 +170,7 @@ AppDBManager::AppDBManager(QObject *parent) : QThread(parent), m_database(QSqlDa
//监控应用进程开启 //监控应用进程开启
connect(KWindowSystem::self(), &KWindowSystem::windowAdded, [ = ](WId id) { connect(KWindowSystem::self(), &KWindowSystem::windowAdded, [ = ](WId id) {
KWindowInfo info = KWindowSystem::windowInfo(id, 0, NET::WM2AllProperties); KWindowInfo info(id, NET::Properties(), NET::WM2AllProperties);
if (info.valid()) { if (info.valid()) {
QString desktopfp; QString desktopfp;
desktopfp = this->tranPidToDesktopFp(info.pid()); desktopfp = this->tranPidToDesktopFp(info.pid());
@ -863,13 +863,15 @@ bool AppDBManager::handleFavoritesStateUpdate(const QString &desktopFilePath, co
ApplicationInfoMap infos; ApplicationInfoMap infos;
//获取应用在数据库中的favorites标志位 //获取应用在数据库中的favorites标志位
int previousPos = -1; uint previousPos = 0;
bool getPrevious(false);
cmd = "SELECT FAVORITES FROM APPINFO WHERE DESKTOP_FILE_PATH =:desktopFilePath"; cmd = "SELECT FAVORITES FROM APPINFO WHERE DESKTOP_FILE_PATH =:desktopFilePath";
query.prepare(cmd); query.prepare(cmd);
query.bindValue(":desktopFilePath", desktopFilePath); query.bindValue(":desktopFilePath", desktopFilePath);
if (query.exec()) { if (query.exec()) {
if (query.next()) { if (query.next()) {
previousPos = query.value("FAVORITES").toInt(); previousPos = query.value("FAVORITES").toUInt();
getPrevious = true;
} else { } else {
qWarning() << query.lastQuery() << query.lastError(); qWarning() << query.lastQuery() << query.lastError();
} }
@ -878,18 +880,18 @@ bool AppDBManager::handleFavoritesStateUpdate(const QString &desktopFilePath, co
} }
//收藏位未改变 //收藏位未改变
if (previousPos == num) { if (getPrevious && previousPos == num) {
res = false; res = false;
qWarning() << "favorites state has no changes, I quit!"; qWarning() << "favorites state has no changes, I quit!";
return res; return res;
} }
//查询目前favorites最大值 //查询目前favorites最大值
int maxFavorite = -1; uint maxFavorite = 0;
query.prepare("SELECT max(FAVORITES) as max FROM APPINFO"); query.prepare("SELECT max(FAVORITES) as max FROM APPINFO");
if (query.exec()) { if (query.exec()) {
if (query.next()) { if (query.next()) {
maxFavorite = query.value("max").toInt(); maxFavorite = query.value("max").toUInt();
if (maxFavorite + 1 < num) { if (maxFavorite + 1 < num) {
qWarning() << QString("Max favorites pos is %0.To be moved to a invalid pos, I quit!!").arg(query.value("max").toInt()); qWarning() << QString("Max favorites pos is %0.To be moved to a invalid pos, I quit!!").arg(query.value("max").toInt());
res = false; res = false;
@ -934,7 +936,7 @@ bool AppDBManager::handleFavoritesStateUpdate(const QString &desktopFilePath, co
} }
} else { } else {
//直接设置时(要设置的应用未被收藏查询要设置的favorites标志位是否被占用占用则将该应用及其之后的应用的favorites标志位后移 //直接设置时(要设置的应用未被收藏查询要设置的favorites标志位是否被占用占用则将该应用及其之后的应用的favorites标志位后移
if (!previousPos) { if (getPrevious && !previousPos) {
cmd = QString("SELECT DESKTOP_FILE_PATH FROM APPINFO WHERE FAVORITES = %1").arg(num); cmd = QString("SELECT DESKTOP_FILE_PATH FROM APPINFO WHERE FAVORITES = %1").arg(num);
if (!query.exec(cmd)) { if (!query.exec(cmd)) {
qWarning() << "Fail to exec:" << cmd << "because:" << query.lastError(); qWarning() << "Fail to exec:" << cmd << "because:" << query.lastError();
@ -999,7 +1001,7 @@ bool AppDBManager::handleFavoritesStateUpdate(const QString &desktopFilePath, co
return res; return res;
} }
bool AppDBManager::handleChangeFavoritesPos(const QString &desktopFilePath, const uint pos, const int previousPos, ApplicationInfoMap &updatedInfo) bool AppDBManager::handleChangeFavoritesPos(const QString &desktopFilePath, const uint pos, const uint previousPos, ApplicationInfoMap &updatedInfo)
{ {
if (pos < 1) { if (pos < 1) {
qWarning() << "To be moved to a invalid favorites pos , I quit!!"; qWarning() << "To be moved to a invalid favorites pos , I quit!!";
@ -1059,13 +1061,15 @@ bool AppDBManager::handleTopStateUpdate(const QString &desktopFilePath, const ui
ApplicationInfoMap infos; ApplicationInfoMap infos;
//获取应用在数据库中的top标志位 //获取应用在数据库中的top标志位
int previousPos = -1; uint previousPos = 0;
bool getPrevious(false);
cmd = "SELECT TOP FROM APPINFO WHERE DESKTOP_FILE_PATH =:desktopFilePath"; cmd = "SELECT TOP FROM APPINFO WHERE DESKTOP_FILE_PATH =:desktopFilePath";
query.prepare(cmd); query.prepare(cmd);
query.bindValue(":desktopFilePath", desktopFilePath); query.bindValue(":desktopFilePath", desktopFilePath);
if (query.exec()) { if (query.exec()) {
if (query.next()) { if (query.next()) {
previousPos = query.value("TOP").toInt(); previousPos = query.value("TOP").toUInt();
getPrevious = true;
} else { } else {
qWarning() << query.lastQuery() << query.lastError(); qWarning() << query.lastQuery() << query.lastError();
} }
@ -1074,18 +1078,18 @@ bool AppDBManager::handleTopStateUpdate(const QString &desktopFilePath, const ui
} }
//top位未改变 //top位未改变
if (previousPos == num) { if (getPrevious && previousPos == num) {
res = false; res = false;
qWarning() << "Top state has no changes, I quit!"; qWarning() << "Top state has no changes, I quit!";
return res; return res;
} }
//查询目前top最大值 //查询目前top最大值
int maxTop = -1; uint maxTop = 0;
query.prepare("SELECT max(TOP) as max FROM APPINFO"); query.prepare("SELECT max(TOP) as max FROM APPINFO");
if (query.exec()) { if (query.exec()) {
if (query.next()) { if (query.next()) {
maxTop = query.value("max").toInt(); maxTop = query.value("max").toUInt();
if (maxTop + 1 < num) { if (maxTop + 1 < num) {
qWarning() << QString("Max top pos is %0.To be moved to a invalid pos, I quit!!").arg(query.value("max").toInt()); qWarning() << QString("Max top pos is %0.To be moved to a invalid pos, I quit!!").arg(query.value("max").toInt());
res = false; res = false;
@ -1132,7 +1136,7 @@ bool AppDBManager::handleTopStateUpdate(const QString &desktopFilePath, const ui
} }
} else { } else {
//直接设置时查询要设置的top标志位是否被占用占用则将该应用及其之后的应用的top标志位后移 //直接设置时查询要设置的top标志位是否被占用占用则将该应用及其之后的应用的top标志位后移
if (!previousPos) { if (getPrevious && !previousPos) {
cmd = QString("SELECT DESKTOP_FILE_PATH FROM APPINFO WHERE TOP = %1").arg(num); cmd = QString("SELECT DESKTOP_FILE_PATH FROM APPINFO WHERE TOP = %1").arg(num);
if (!query.exec(cmd)) { if (!query.exec(cmd)) {
qWarning() << "Fail to exec:" << cmd << "because:" << query.lastError(); qWarning() << "Fail to exec:" << cmd << "because:" << query.lastError();
@ -1196,7 +1200,7 @@ bool AppDBManager::handleTopStateUpdate(const QString &desktopFilePath, const ui
return res; return res;
} }
bool AppDBManager::handleChangeTopPos(const QString &desktopFilePath, uint pos, const int previousPos, ApplicationInfoMap &updatedInfo) bool AppDBManager::handleChangeTopPos(const QString &desktopFilePath, uint pos, const uint previousPos, ApplicationInfoMap &updatedInfo)
{ {
if (pos < 1) { if (pos < 1) {
qWarning() << "To be moved to a invalid top pos , I quit!!"; qWarning() << "To be moved to a invalid top pos , I quit!!";

View File

@ -127,8 +127,8 @@ private:
void initFileSystemWatcher(); void initFileSystemWatcher();
//处理置顶收藏移动位置 //处理置顶收藏移动位置
bool handleChangeFavoritesPos(const QString &desktopFilePath, const uint pos, const int previousPos, ApplicationInfoMap &updatedInfo); bool handleChangeFavoritesPos(const QString &desktopFilePath, const uint pos, const uint previousPos, ApplicationInfoMap &updatedInfo);
bool handleChangeTopPos(const QString &desktopFilePath, uint pos, const int previousPos, ApplicationInfoMap &updatedInfo); bool handleChangeTopPos(const QString &desktopFilePath, uint pos, const uint previousPos, ApplicationInfoMap &updatedInfo);
private: private:
static QMutex s_mutex; static QMutex s_mutex;

View File

@ -22,6 +22,8 @@
#include <QDir> #include <QDir>
#include "convert-winid-to-desktop.h" #include "convert-winid-to-desktop.h"
static const char* GET_DESKTOP_EXEC_NAME_MAIN = "cat %s | awk '{if($1~\"Exec=\")if($2~\"\%\"){print $1} else print}' | cut -d '=' -f 2";
ConvertWinidToDesktop::ConvertWinidToDesktop(QObject *parent) : QObject(parent) ConvertWinidToDesktop::ConvertWinidToDesktop(QObject *parent) : QObject(parent)
{ {
} }
@ -176,7 +178,7 @@ QString ConvertWinidToDesktop::compareCmdExec(QFileInfoList list)
if (!fileInfo.filePath().endsWith(".desktop")) { if (!fileInfo.filePath().endsWith(".desktop")) {
continue; continue;
} }
cmd.sprintf(GET_DESKTOP_EXEC_NAME_MAIN, fileInfo.filePath().toStdString().data()); cmd.asprintf(GET_DESKTOP_EXEC_NAME_MAIN, fileInfo.filePath().toStdString().data());
QString desktopFileExeName = getDesktopFileName(cmd).remove("\n"); QString desktopFileExeName = getDesktopFileName(cmd).remove("\n");
if (desktopFileExeName.isEmpty()) { if (desktopFileExeName.isEmpty()) {
@ -219,7 +221,7 @@ QString ConvertWinidToDesktop::compareCmdName(QFileInfoList list)
if (!fileInfo.filePath().endsWith(".desktop")) { if (!fileInfo.filePath().endsWith(".desktop")) {
continue; continue;
} }
cmd.sprintf(GET_DESKTOP_EXEC_NAME_MAIN, fileInfo.filePath().toStdString().data()); cmd.asprintf(GET_DESKTOP_EXEC_NAME_MAIN, fileInfo.filePath().toStdString().data());
QString desktopFileExeName = getDesktopFileName(cmd).remove("\n"); QString desktopFileExeName = getDesktopFileName(cmd).remove("\n");
if (desktopFileExeName.isEmpty()) { if (desktopFileExeName.isEmpty()) {
@ -265,7 +267,7 @@ QString ConvertWinidToDesktop::containsName(QFileInfoList list)
continue; continue;
} }
cmd.sprintf(GET_DESKTOP_EXEC_NAME_MAIN, fileInfo.filePath().toStdString().data()); cmd.asprintf(GET_DESKTOP_EXEC_NAME_MAIN, fileInfo.filePath().toStdString().data());
QString desktopFileExeName = getDesktopFileName(cmd).remove("\n"); QString desktopFileExeName = getDesktopFileName(cmd).remove("\n");
pathDesktopName = pathDesktopName.mid(pathDesktopName.lastIndexOf("/") + 1); pathDesktopName = pathDesktopName.mid(pathDesktopName.lastIndexOf("/") + 1);

View File

@ -31,7 +31,6 @@
#define PEONY_HOME "/usr/share/applications/peony-home.desktop" #define PEONY_HOME "/usr/share/applications/peony-home.desktop"
#define PEONY_MAIN "/usr/share/applications/peony.desktop" #define PEONY_MAIN "/usr/share/applications/peony.desktop"
#define GET_DESKTOP_EXEC_NAME_MAIN "cat %s | awk '{if($1~\"Exec=\")if($2~\"\%\"){print $1} else print}' | cut -d '=' -f 2"
#define ANDROID_FILE_PATH "/.local/share/applications/" #define ANDROID_FILE_PATH "/.local/share/applications/"
#define ANDROID_APP_CURRENT "/.local/share/applications/." #define ANDROID_APP_CURRENT "/.local/share/applications/."
#define ANDROID_APP_UPER "/.local/share/applications/.." #define ANDROID_APP_UPER "/.local/share/applications/.."