diff --git a/libchinese-segmentation/chinese-segmentation.cpp b/libchinese-segmentation/chinese-segmentation.cpp index 095d6a7..ea80a67 100644 --- a/libchinese-segmentation/chinese-segmentation.cpp +++ b/libchinese-segmentation/chinese-segmentation.cpp @@ -65,7 +65,7 @@ QVector ChineseSegmentation::callSegement(QString str) { convert(keywordres, vecNeeds); keywordres.clear(); - keywordres.shrink_to_fit(); +// keywordres.shrink_to_fit(); return vecNeeds; diff --git a/libsearch/global-settings.cpp b/libsearch/global-settings.cpp index 36d3ba6..838ac79 100644 --- a/libsearch/global-settings.cpp +++ b/libsearch/global-settings.cpp @@ -19,7 +19,6 @@ * */ #include -#include #include #include "global-settings.h" @@ -83,6 +82,8 @@ GlobalSettings::GlobalSettings(QObject *parent) : QObject(parent) { qApp->paletteChanged(qApp->palette()); m_cache.remove(FONT_SIZE_KEY); m_cache.insert(FONT_SIZE_KEY, m_theme_gsettings->get(FONT_SIZE_KEY).toDouble()); + } else if (key == ICON_THEME_KEY) { + qApp->paletteChanged(qApp->palette()); } }); m_cache.remove(STYLE_NAME_KEY); diff --git a/libsearch/global-settings.h b/libsearch/global-settings.h index 7815eb2..3de9ded 100644 --- a/libsearch/global-settings.h +++ b/libsearch/global-settings.h @@ -33,6 +33,7 @@ #include #include #include +#include #include "libsearch_global.h" #define CONTROL_CENTER_PERSONALISE_GSETTINGS_ID "org.ukui.control-center.personalise" @@ -40,6 +41,7 @@ #define THEME_GSETTINGS_ID "org.ukui.style" #define STYLE_NAME_KEY "styleName" #define FONT_SIZE_KEY "systemFontSize" +#define ICON_THEME_KEY "iconThemeName" #define ENABLE_CREATE_INDEX_ASK_DIALOG "enable_create_index_ask_dialog" #define WEB_ENGINE "web_engine" diff --git a/libsearch/plugininterface/search-plugin-iface.h b/libsearch/plugininterface/search-plugin-iface.h index d4ccdb9..a2cb769 100644 --- a/libsearch/plugininterface/search-plugin-iface.h +++ b/libsearch/plugininterface/search-plugin-iface.h @@ -11,19 +11,24 @@ namespace Zeeker { class SearchPluginIface : public PluginInterface { public: + struct DescriptionInfo + { + QString key; + QString value; + }; /** - * @brief The resultInfo struct + * @brief The ResultInfo struct */ - struct resultInfo + struct ResultInfo { QIcon icon; QString name; - QString description; + QVector description; QMap actionMap;//action name and action key }; virtual ~SearchPluginIface() {} virtual QString getPluginName() = 0; - virtual void KeywordSearch(QString keyword,QQueue *searchResult) = 0; + virtual void KeywordSearch(QString keyword,QQueue *searchResult) = 0; virtual void openAction(QString name, QString key) = 0; }; diff --git a/src/content-widget.cpp b/src/content-widget.cpp index 7d9f335..532c6c6 100644 --- a/src/content-widget.cpp +++ b/src/content-widget.cpp @@ -22,7 +22,6 @@ #include #include #include -#include #include "config-file.h" using namespace Zeeker; diff --git a/src/control/highlight-item-delegate.cpp b/src/control/highlight-item-delegate.cpp index a11d3c3..c57e1e3 100644 --- a/src/control/highlight-item-delegate.cpp +++ b/src/control/highlight-item-delegate.cpp @@ -20,12 +20,10 @@ */ #include "highlight-item-delegate.h" #include -#include #include #include #include #include -#include "global-settings.h" using namespace Zeeker; HighlightItemDelegate::HighlightItemDelegate(QObject *parent) : QStyledItemDelegate(parent) { diff --git a/src/control/highlight-item-delegate.h b/src/control/highlight-item-delegate.h index 81a0527..cc71b72 100644 --- a/src/control/highlight-item-delegate.h +++ b/src/control/highlight-item-delegate.h @@ -22,6 +22,7 @@ #define HIGHLIGHTITEMDELEGATE_H #include +#include "global-settings.h" namespace Zeeker { class HighlightItemDelegate : public QStyledItemDelegate { diff --git a/src/control/home-page-item.cpp b/src/control/home-page-item.cpp index 5177a6d..5fe596d 100644 --- a/src/control/home-page-item.cpp +++ b/src/control/home-page-item.cpp @@ -26,7 +26,6 @@ #include #include #include -#include using namespace Zeeker; HomePageItem::HomePageItem(QWidget *parent, const int& type, const QString& path) : QWidget(parent) { diff --git a/src/control/search-detail-view.cpp b/src/control/search-detail-view.cpp index 6f16695..319cbeb 100644 --- a/src/control/search-detail-view.cpp +++ b/src/control/search-detail-view.cpp @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -40,6 +39,7 @@ using namespace Zeeker; SearchDetailView::SearchDetailView(QWidget *parent) : QWidget(parent) { initUI(); + connect(qApp, &QApplication::paletteChanged, this, &SearchDetailView::refreshIcon); } SearchDetailView::~SearchDetailView() { @@ -200,9 +200,7 @@ void SearchDetailView::setAppWidget(const QString &appname, const QString &path, m_typeLabel->show(); m_hLine->show(); - QIcon icon; if(path.isEmpty() || path == "") { - icon = QIcon(iconpath); m_optionView->setupOptions(m_type, false); //未安装应用有一个label显示软件描述 if(description != "" && !description.isEmpty()) { @@ -210,17 +208,13 @@ void SearchDetailView::setAppWidget(const QString &appname, const QString &path, m_contentLabel->show(); m_contentLabel->setText(QString(tr("Introduction: %1")).arg(description)); } + setIcon(iconpath, false); } else { m_optionView->setupOptions(m_type, true); - if(QIcon::fromTheme(iconpath).isNull()) { - icon = QIcon(":/res/icons/desktop.png"); - } else { - icon = QIcon::fromTheme(iconpath); - } + setIcon(iconpath, true); } m_optionView->show(); - m_iconLabel->setPixmap(icon.pixmap(icon.actualSize(QSize(96, 96)))); QFontMetrics fontMetrics = m_nameLabel->fontMetrics(); QString showname = fontMetrics.elidedText(m_name, Qt::ElideRight, 274); //当字体长度超过215时显示为省略号 m_nameLabel->setText(showname); @@ -352,8 +346,7 @@ void SearchDetailView::setupWidget(const int& type, const QString& path) { case SearchListView::ResType::Content: case SearchListView::ResType::Dir : case SearchListView::ResType::File : { - QIcon icon = FileUtils::getFileIcon(QUrl::fromLocalFile(path).toString()); - m_iconLabel->setPixmap(icon.pixmap(icon.actualSize(QSize(96, 96)))); + setIcon(path); QFontMetrics fontMetrics = m_nameLabel->fontMetrics(); QString wholeName = FileUtils::getFileName(path); QString name = fontMetrics.elidedText(wholeName, Qt::ElideRight, 274); @@ -366,8 +359,7 @@ void SearchDetailView::setupWidget(const int& type, const QString& path) { break; } case SearchListView::ResType::Setting : { - QIcon icon = FileUtils::getSettingIcon(path, true); - m_iconLabel->setPixmap(icon.pixmap(icon.actualSize(QSize(96, 96)))); + setIcon(path); QString settingType = path.mid(path.indexOf("/") + 1, path.lastIndexOf("/") - path.indexOf("/") - 1); //配置项所属控制面板插件名 m_nameLabel->setText(settingType); m_typeLabel->setText(FileUtils::getSettingName(path)); @@ -567,6 +559,42 @@ void SearchDetailView::initUI() { this->clearLayout(); //初始化时隐藏所有控件 } +/** + * @brief SearchDetailView::refreshIcon 图标主题变更时,刷新图标的槽函数 + */ +void SearchDetailView::refreshIcon() { + this->setIcon(m_iconPath); +} + +/** + * @brief SearchDetailView::setIcon 设置图标区域 + * @param path 图标路径或图标名 + * @param installed 如果是应用,是否已安装 + */ +void SearchDetailView::setIcon(const QString &path, const bool &installed) +{ + m_iconPath = path; + if (m_type == SearchListView::ResType::App) { + QIcon icon; + if(!installed) { + icon = QIcon(path); + } else { + if(QIcon::fromTheme(path).isNull()) { + icon = QIcon(":/res/icons/desktop.png"); + } else { + icon = QIcon::fromTheme(path); + } + } + m_iconLabel->setPixmap(icon.pixmap(icon.actualSize(QSize(96, 96)))); + } else if (m_type == SearchListView::ResType::Setting) { + QIcon icon = FileUtils::getSettingIcon(path, true); + m_iconLabel->setPixmap(icon.pixmap(icon.actualSize(QSize(96, 96)))); + } else { + QIcon icon = FileUtils::getFileIcon(QUrl::fromLocalFile(path).toString()); + m_iconLabel->setPixmap(icon.pixmap(icon.actualSize(QSize(96, 96)))); + } +} + /** * @brief SearchDetailView::addDesktopShortcut 添加到桌面快捷方式 * @return diff --git a/src/control/search-detail-view.h b/src/control/search-detail-view.h index 96551da..a06cf87 100644 --- a/src/control/search-detail-view.h +++ b/src/control/search-detail-view.h @@ -71,6 +71,8 @@ private: QString m_pkgname = 0; //目前只有未安装应用在打开软件商店时需要此参数 void initUI(); + void setIcon(const QString& path, const bool &installed = true); + QString m_iconPath; QLabel * m_iconLabel = nullptr; QFrame * m_nameFrame = nullptr; QHBoxLayout * m_nameLayout = nullptr; @@ -105,6 +107,7 @@ Q_SIGNALS: void configFileChanged(); private Q_SLOTS: void execActions(const int&, const int&, const QString&); + void refreshIcon(); }; //此类用于url拦截 diff --git a/src/control/search-list-view.cpp b/src/control/search-list-view.cpp index 2cbb308..e4611e7 100644 --- a/src/control/search-list-view.cpp +++ b/src/control/search-list-view.cpp @@ -128,7 +128,13 @@ void SearchListView::clear() { */ void SearchListView::refresh() { + QModelIndex index = this->currentIndex(); m_model->refresh(); + if(index.row() >= 0 && index.row() < m_model->length() && m_isSelected) { + this->blockSignals(true); + this->setCurrentIndex(index); + this->blockSignals(false); + } rowheight = this->rowHeight(this->model()->index(0, 0, QModelIndex())) + 1; this->setFixedHeight(m_item->getCurrentSize() * rowheight + 4); } diff --git a/src/create-index-ask-dialog.cpp b/src/create-index-ask-dialog.cpp index 1fc2e76..0d1fc1e 100644 --- a/src/create-index-ask-dialog.cpp +++ b/src/create-index-ask-dialog.cpp @@ -20,11 +20,10 @@ */ #include "create-index-ask-dialog.h" -#include using namespace Zeeker; CreateIndexAskDialog::CreateIndexAskDialog(QWidget *parent) : QDialog(parent) { - this->setWindowIcon(QIcon::fromTheme("kylin-search")); +// this->setWindowIcon(QIcon::fromTheme("kylin-search")); this->setWindowTitle(tr("ukui-search")); initUi(); @@ -46,6 +45,10 @@ void CreateIndexAskDialog::initUi() { m_iconLabel = new QLabel(m_titleFrame); m_iconLabel->setFixedSize(24, 24); m_iconLabel->setPixmap(QIcon::fromTheme("kylin-search").pixmap(QSize(24, 24))); + //主题改变时,更新自定义标题栏的图标 + connect(qApp, &QApplication::paletteChanged, this, [ = ]() { + m_iconLabel->setPixmap(QIcon::fromTheme("kylin-search").pixmap(QSize(24, 24))); + }); m_titleLabel = new QLabel(m_titleFrame); m_titleLabel->setText(tr("Search")); m_closeBtn = new QPushButton(m_titleFrame); @@ -113,6 +116,10 @@ void CreateIndexAskDialog::initUi() { m_contentLyt->addWidget(m_btnFrame); m_mainLyt->addWidget(m_contentFrame); +#if (QT_VERSION < QT_VERSION_CHECK(5, 12, 0)) + m_titleFrame->hide(); + this->setFixedSize(380, 162); +#endif } /** diff --git a/src/create-index-ask-dialog.h b/src/create-index-ask-dialog.h index bf360fc..4719181 100644 --- a/src/create-index-ask-dialog.h +++ b/src/create-index-ask-dialog.h @@ -30,6 +30,8 @@ #include #include #include +#include +#include namespace Zeeker { class CreateIndexAskDialog : public QDialog { diff --git a/src/main.cpp b/src/main.cpp index cca0d2a..54dbe8b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -29,8 +29,11 @@ #include #include #include +#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)) #include +#endif #include +#include #include "qt-single-application.h" #include "qt-local-peer.h" //#include "inotify-manager.h" @@ -144,8 +147,11 @@ void searchMethod(FileUtils::SearchMethod sm){ } */ int main(int argc, char *argv[]) { - //Init log module +//v101日志模块 +//#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)) +// //Init log module // initUkuiLog4qt("ukui-search"); +//#endif // Determine whether the home directory has been created, and if not, keep waiting. char *p_home = NULL; @@ -171,6 +177,11 @@ int main(int argc, char *argv[]) { // Output log to file qInstallMessageHandler(messageOutput); +//若使用v101日志模块,可以解放如下判断条件 +//#if (QT_VERSION < QT_VERSION_CHECK(5, 12, 0)) +// // Output log to file +// qInstallMessageHandler(messageOutput); +//#endif // Register meta type qDebug() << "ukui-search main start"; @@ -268,6 +279,7 @@ int main(int argc, char *argv[]) { //set main window to the center of screen MainWindow *w = new MainWindow; + qApp->setWindowIcon(QIcon::fromTheme("kylin-search")); // centerToScreen(w); // w->moveToPanel(); centerToScreen(w); @@ -289,7 +301,9 @@ int main(int argc, char *argv[]) { if(QString::compare(QString("-s"), QString(QLatin1String(argv[1]))) == 0) { // w->moveToPanel(); centerToScreen(w); +#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)) XAtomHelper::getInstance()->setWindowMotifHint(w->winId(), w->m_hints); +#endif w->show(); } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index bca3a05..4cd016c 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -29,9 +29,11 @@ #include #include #include -#include #include +#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)) +#include #include "kwindowsystem.h" +#endif #include "qt-single-application.h" //#include "inotify-manager.h" @@ -58,7 +60,7 @@ MainWindow::MainWindow(QWidget *parent) : // this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint); // this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); - this->setWindowIcon(QIcon::fromTheme("kylin-search")); +// this->setWindowIcon(QIcon::fromTheme("kylin-search")); this->setAttribute(Qt::WA_TranslucentBackground, true); this->setAutoFillBackground(false); this->setFocusPolicy(Qt::StrongFocus); @@ -67,6 +69,7 @@ MainWindow::MainWindow(QWidget *parent) : initUi(); initTimer(); +#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)) // setProperty("useStyleWindowManager", false); //禁止拖动 m_hints.flags = MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS; m_hints.functions = MWM_FUNC_ALL; @@ -80,6 +83,7 @@ MainWindow::MainWindow(QWidget *parent) : path.addRect(rect); setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon())); KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon())); +#endif connect(qApp, &QApplication::paletteChanged, this, [ = ](const QPalette & pal) { this->setPalette(pal); @@ -125,7 +129,9 @@ MainWindow::MainWindow(QWidget *parent) : clearSearchResult(); // this->moveToPanel(); centerToScreen(this); +#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)) XAtomHelper::getInstance()->setWindowMotifHint(winId(), m_hints); +#endif this->show(); this->m_searchLayout->focusIn(); //打开主界面时输入框夺焦,可直接输入 this->raise(); @@ -150,10 +156,12 @@ MainWindow::~MainWindow() { delete m_searchLayout; m_searchLayout = NULL; } -// if(m_settingsWidget) { -// delete m_settingsWidget; -// m_settingsWidget = NULL; -// } +#if (QT_VERSION < QT_VERSION_CHECK(5, 12, 0)) + if(m_settingsWidget) { + delete m_settingsWidget; + m_settingsWidget = NULL; + } +#endif if(m_askDialog) { delete m_askDialog; m_askDialog = NULL; @@ -189,6 +197,10 @@ void MainWindow::initUi() { m_iconLabel = new QLabel(m_titleFrame); m_iconLabel->setFixedSize(24, 24); m_iconLabel->setPixmap(QIcon::fromTheme("kylin-search").pixmap(QSize(24, 24))); + //主题改变时,更新自定义标题栏的图标 + connect(qApp, &QApplication::paletteChanged, this, [ = ]() { + m_iconLabel->setPixmap(QIcon::fromTheme("kylin-search").pixmap(QSize(24, 24))); + }); m_titleLabel = new QLabel(m_titleFrame); m_titleLabel->setText(tr("Search")); m_menuBtn = new QPushButton(m_titleFrame); @@ -199,38 +211,42 @@ void MainWindow::initUi() { m_menuBtn->setProperty("isWindowButton", 0x01); m_menuBtn->setFlat(true); connect(m_menuBtn, &QPushButton::clicked, this, [ = ]() { -// if(m_settingsWidget) { //当此窗口已存在时,仅需置顶 -// if(!m_settingsWidget->isVisible()) { -// centerToScreen(m_settingsWidget); -// } -// m_settingsWidget->showWidget(); -// return; -// } -// m_settingsWidget = new SettingsWidget(); -// connect(this, &MainWindow::webEngineChanged, m_settingsWidget, [ = ]() { -// m_settingsWidget->resetWebEngine(); -// }); -// connect(m_settingsWidget, &SettingsWidget::webEngineChanged, this, [ = ](const QString & engine) { -// if(m_search_gsettings && m_search_gsettings->keys().contains(WEB_ENGINE_KEY)) { -// m_search_gsettings->set(WEB_ENGINE_KEY, engine); -// } else { -// GlobalSettings::getInstance()->setValue(WEB_ENGINE, engine); -// } -// }); -// centerToScreen(m_settingsWidget); -// m_settingsWidget->show(); -// connect(m_settingsWidget, &SettingsWidget::settingWidgetClosed, this, [ = ]() { -// QTimer::singleShot(100, this, [ = ] { -//// clearSearchResult(); //现暂定从设置页返回主页面不清空搜索结果 -// this->setWindowState(this->windowState() & ~Qt::WindowMinimized); -// this->raise(); -// this->showNormal(); -// this->activateWindow(); -// }); -// }); +#if (QT_VERSION < QT_VERSION_CHECK(5, 12, 0)) + if(m_settingsWidget) { //当此窗口已存在时,仅需置顶 + if(!m_settingsWidget->isVisible()) { + centerToScreen(m_settingsWidget); + } + m_settingsWidget->showWidget(); + return; + } + m_settingsWidget = new SettingsWidget(); + connect(this, &MainWindow::webEngineChanged, m_settingsWidget, [ = ]() { + m_settingsWidget->resetWebEngine(); + }); + connect(m_settingsWidget, &SettingsWidget::webEngineChanged, this, [ = ](const QString & engine) { + if(m_search_gsettings && m_search_gsettings->keys().contains(WEB_ENGINE_KEY)) { + m_search_gsettings->set(WEB_ENGINE_KEY, engine); + } else { + GlobalSettings::getInstance()->setValue(WEB_ENGINE, engine); + } + }); + centerToScreen(m_settingsWidget); + m_settingsWidget->show(); + connect(m_settingsWidget, &SettingsWidget::settingWidgetClosed, this, [ = ]() { + QTimer::singleShot(100, this, [ = ] { +// clearSearchResult(); //现暂定从设置页返回主页面不清空搜索结果 + this->setWindowState(this->windowState() & ~Qt::WindowMinimized); + this->raise(); + this->showNormal(); + this->activateWindow(); + }); + }); +#endif +#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)) //打开控制面板的设置页 QProcess process; process.startDetached("ukui-control-center --search"); +#endif }); m_titleLyt->addWidget(m_iconLabel); m_titleLyt->addWidget(m_titleLabel); @@ -286,11 +302,13 @@ void MainWindow::initUi() { //创建索引询问弹窗 m_askDialog = new CreateIndexAskDialog(this); +#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)) MotifWmHints ask_dialog_hints; ask_dialog_hints.flags = MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS; ask_dialog_hints.functions = MWM_FUNC_ALL; ask_dialog_hints.decorations = MWM_DECOR_BORDER; XAtomHelper::getInstance()->setWindowMotifHint(m_askDialog->winId(), ask_dialog_hints); +#endif connect(m_askDialog, &CreateIndexAskDialog::closed, this, [ = ]() { m_isAskDialogVisible = false; }); @@ -323,7 +341,9 @@ void MainWindow::bootOptionsFilter(QString opt) { clearSearchResult(); // this->moveToPanel(); centerToScreen(this); +#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)) XAtomHelper::getInstance()->setWindowMotifHint(winId(), m_hints); +#endif this->show(); this->m_searchLayout->focusIn(); this->raise(); diff --git a/src/mainwindow.h b/src/mainwindow.h index 8de33fe..7a5a153 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -49,10 +49,14 @@ #include "content-widget.h" #include "input-box.h" #include "index/index-generator.h" -//#include "settings-widget.h" #include "libsearch.h" #include "search-app-thread.h" +#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)) #include "xatom-helper.h" +#endif +#if (QT_VERSION < QT_VERSION_CHECK(5, 12, 0)) +#include "settings-widget.h" +#endif #include "create-index-ask-dialog.h" #define UKUI_SEARCH_SCHEMAS "org.ukui.search.settings" @@ -82,7 +86,9 @@ public: void centerToScreen(QWidget* widget); void initGsettings(); +#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)) MotifWmHints m_hints; +#endif private: @@ -95,7 +101,9 @@ private: QLabel * m_iconLabel = nullptr; // Icon lable QLabel * m_titleLabel = nullptr; // Title lable QPushButton * m_menuBtn = nullptr; // Menu button -// SettingsWidget * m_settingsWidget = nullptr; // Settings Widget +#if (QT_VERSION < QT_VERSION_CHECK(5, 12, 0)) + SettingsWidget * m_settingsWidget = nullptr; // Settings Widget +#endif ContentWidget * m_contentFrame = nullptr; // Content frame SearchBarHLayout * m_searchLayout = nullptr; // Search bar layout SeachBarWidget * m_searchWidget = nullptr; // Search bar diff --git a/src/model/search-item-model.cpp b/src/model/search-item-model.cpp index 264fe74..66e2cee 100644 --- a/src/model/search-item-model.cpp +++ b/src/model/search-item-model.cpp @@ -186,3 +186,8 @@ void SearchItemModel::refresh() this->beginResetModel(); this->endResetModel(); } + +int SearchItemModel::length() +{ + return m_item->m_pathlist.length(); +} diff --git a/src/model/search-item-model.h b/src/model/search-item-model.h index 8104566..396c77e 100644 --- a/src/model/search-item-model.h +++ b/src/model/search-item-model.h @@ -60,6 +60,7 @@ public: void clear(); void setBestAppIcon(const QString &, const bool &); void refresh(); + int length(); private : SearchItem * m_item = nullptr; diff --git a/src/settings-widget.cpp b/src/settings-widget.cpp index b9b47f8..afca905 100644 --- a/src/settings-widget.cpp +++ b/src/settings-widget.cpp @@ -32,15 +32,17 @@ using namespace Zeeker; extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed); SettingsWidget::SettingsWidget(QWidget *parent) : QWidget(parent) { - this->setWindowIcon(QIcon::fromTheme("kylin-search")); +// this->setWindowIcon(QIcon::fromTheme("kylin-search")); this->setWindowTitle(tr("ukui-search-settings")); // this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint); // this->setAttribute(Qt::WA_TranslucentBackground); +#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)) m_hints.flags = MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS; m_hints.functions = MWM_FUNC_ALL; m_hints.decorations = MWM_DECOR_BORDER; XAtomHelper::getInstance()->setWindowMotifHint(winId(), m_hints); +#endif initUi(); refreshIndexState(); @@ -70,6 +72,10 @@ void SettingsWidget::initUi() { m_titleFrame->setLayout(m_titleLyt); m_titleIcon = new QLabel(m_titleFrame); m_titleIcon->setPixmap(QIcon::fromTheme("kylin-search").pixmap(QSize(24, 24))); + //主题改变时,更新自定义标题栏的图标 + connect(qApp, &QApplication::paletteChanged, this, [ = ]() { + m_titleIcon->setPixmap(QIcon::fromTheme("kylin-search").pixmap(QSize(24, 24))); + }); m_titleLabel = new QLabel(m_titleFrame); m_titleLabel->setText(tr("Search")); m_closeBtn = new QPushButton(m_titleFrame); @@ -220,6 +226,11 @@ void SettingsWidget::initUi() { // m_mainLyt->addWidget(m_bottomBtnFrame); m_contentLyt->addStretch(); + +#if (QT_VERSION < QT_VERSION_CHECK(5, 12, 0)) + this->m_titleFrame->hide(); + setAttribute(Qt::WA_DeleteOnClose); +#endif } /** @@ -370,7 +381,9 @@ void SettingsWidget::showWidget() { flags &= ~Qt::WindowStaysOnTopHint; this->setWindowFlags(flags); m_timer->start(); +#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)) XAtomHelper::getInstance()->setWindowMotifHint(winId(), m_hints); +#endif this->show(); } diff --git a/src/settings-widget.h b/src/settings-widget.h index 56143ed..421a099 100644 --- a/src/settings-widget.h +++ b/src/settings-widget.h @@ -33,7 +33,9 @@ #include #include #include +#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)) #include "xatom-helper.h" +#endif namespace Zeeker { class SettingsWidget : public QWidget { @@ -56,7 +58,9 @@ private: void resize(); void showWarningDialog(const int&); +#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)) MotifWmHints m_hints; +#endif //标题栏 QVBoxLayout * m_mainLyt = nullptr;