diff --git a/libsearch/appsearch/app-search-plugin.cpp b/libsearch/appsearch/app-search-plugin.cpp index a6fc80d..505587b 100644 --- a/libsearch/appsearch/app-search-plugin.cpp +++ b/libsearch/appsearch/app-search-plugin.cpp @@ -148,10 +148,7 @@ void AppSearchPlugin::initDetailPage() m_nameFrameLyt->addStretch(); m_nameFrameLyt->addWidget(m_pluginLabel); - m_line_1 = new QFrame(m_detailPage); - m_line_1->setLineWidth(0); - m_line_1->setFixedHeight(1); - m_line_1->setStyleSheet("QFrame{background: rgba(0,0,0,0.2);}"); + m_line_1 = new SeparationLine(m_detailPage); m_descFrame = new QFrame(m_detailPage); m_descFrameLyt = new QVBoxLayout(m_descFrame); m_descLabel = new QLabel(m_descFrame); @@ -160,10 +157,7 @@ void AppSearchPlugin::initDetailPage() m_descFrameLyt->addWidget(m_descLabel); m_descFrame->setLayout(m_descFrameLyt); m_descFrameLyt->setContentsMargins(8, 0, 0, 0); - m_line_2 = new QFrame(m_detailPage); - m_line_2->setLineWidth(0); - m_line_2->setFixedHeight(1); - m_line_2->setStyleSheet("QFrame{background: rgba(0,0,0,0.2);}"); + m_line_2 = new SeparationLine(m_detailPage); m_actionFrame = new QFrame(m_detailPage); m_actionFrameLyt = new QVBoxLayout(m_actionFrame); diff --git a/libsearch/appsearch/app-search-plugin.h b/libsearch/appsearch/app-search-plugin.h index 94e728f..8d98243 100644 --- a/libsearch/appsearch/app-search-plugin.h +++ b/libsearch/appsearch/app-search-plugin.h @@ -11,6 +11,7 @@ #include "search-plugin-iface.h" #include "app-match.h" #include "action-label.h" +#include "separation-line.h" #include "libsearch_global.h" namespace UkuiSearch { class LIBSEARCH_EXPORT AppSearchPlugin : public QObject, public SearchPluginIface @@ -55,11 +56,11 @@ private: QHBoxLayout *m_nameFrameLyt = nullptr; QLabel *m_nameLabel = nullptr; QLabel *m_pluginLabel = nullptr; - QFrame *m_line_1 = nullptr; + SeparationLine *m_line_1 = nullptr; QFrame *m_descFrame = nullptr; QLabel *m_descLabel = nullptr; QVBoxLayout *m_descFrameLyt = nullptr; - QFrame *m_line_2 = nullptr; + SeparationLine *m_line_2 = nullptr; QFrame *m_actionFrame = nullptr; QVBoxLayout *m_actionFrameLyt = nullptr; ActionLabel *m_actionLabel1 = nullptr; diff --git a/libsearch/index/file-search-plugin.cpp b/libsearch/index/file-search-plugin.cpp index 6371a23..ed08bb0 100644 --- a/libsearch/index/file-search-plugin.cpp +++ b/libsearch/index/file-search-plugin.cpp @@ -121,10 +121,7 @@ void FileSearchPlugin::initDetailPage() m_nameFrameLyt->addStretch(); m_nameFrameLyt->addWidget(m_pluginLabel); - m_line_1 = new QFrame(m_detailPage); - m_line_1->setLineWidth(0); - m_line_1->setFixedHeight(1); - m_line_1->setStyleSheet("QFrame{background: rgba(0,0,0,0.2);}"); + m_line_1 = new SeparationLine(m_detailPage); m_pathFrame = new QFrame(m_detailPage); m_pathFrameLyt = new QHBoxLayout(m_pathFrame); @@ -147,10 +144,7 @@ void FileSearchPlugin::initDetailPage() m_timeFrameLyt->addStretch(); m_timeFrameLyt->addWidget(m_timeLabel2); - m_line_2 = new QFrame(m_detailPage); - m_line_2->setLineWidth(0); - m_line_2->setFixedHeight(1); - m_line_2->setStyleSheet("QFrame{background: rgba(0,0,0,0.2);}"); + m_line_2 = new SeparationLine(m_detailPage); m_actionFrame = new QFrame(m_detailPage); m_actionFrameLyt = new QVBoxLayout(m_actionFrame); @@ -318,10 +312,7 @@ void DirSearchPlugin::initDetailPage() m_nameFrameLyt->addStretch(); m_nameFrameLyt->addWidget(m_pluginLabel); - m_line_1 = new QFrame(m_detailPage); - m_line_1->setLineWidth(0); - m_line_1->setFixedHeight(1); - m_line_1->setStyleSheet("QFrame{background: rgba(0,0,0,0.2);}"); + m_line_1 = new SeparationLine(m_detailPage); m_pathFrame = new QFrame(m_detailPage); m_pathFrameLyt = new QHBoxLayout(m_pathFrame); @@ -344,10 +335,7 @@ void DirSearchPlugin::initDetailPage() m_timeFrameLyt->addStretch(); m_timeFrameLyt->addWidget(m_timeLabel2); - m_line_2 = new QFrame(m_detailPage); - m_line_2->setLineWidth(0); - m_line_2->setFixedHeight(1); - m_line_2->setStyleSheet("QFrame{background: rgba(0,0,0,0.2);}"); + m_line_2 = new SeparationLine(m_detailPage); m_actionFrame = new QFrame(m_detailPage); m_actionFrameLyt = new QVBoxLayout(m_actionFrame); @@ -555,10 +543,7 @@ void FileContengSearchPlugin::initDetailPage() m_nameFrameLyt->addStretch(); m_nameFrameLyt->addWidget(m_pluginLabel); - m_line_1 = new QFrame(m_detailPage); - m_line_1->setLineWidth(0); - m_line_1->setFixedHeight(1); - m_line_1->setStyleSheet("QFrame{background: rgba(0,0,0,0.2);}"); + m_line_1 = new SeparationLine(m_detailPage); m_snippetLabel = new QLabel(m_detailPage); // m_snippetLabel->setWordWrap(true); @@ -585,10 +570,7 @@ void FileContengSearchPlugin::initDetailPage() m_timeFrameLyt->addStretch(); m_timeFrameLyt->addWidget(m_timeLabel2); - m_line_2 = new QFrame(m_detailPage); - m_line_2->setLineWidth(0); - m_line_2->setFixedHeight(1); - m_line_2->setStyleSheet("QFrame{background: rgba(0,0,0,0.2);}"); + m_line_2 = new SeparationLine(m_detailPage); m_actionFrame = new QFrame(m_detailPage); m_actionFrameLyt = new QVBoxLayout(m_actionFrame); diff --git a/libsearch/index/file-search-plugin.h b/libsearch/index/file-search-plugin.h index ff94c34..6c37f1b 100644 --- a/libsearch/index/file-search-plugin.h +++ b/libsearch/index/file-search-plugin.h @@ -14,6 +14,7 @@ #include "search-plugin-iface.h" #include "common.h" #include "action-label.h" +#include "separation-line.h" namespace UkuiSearch { //internal plugin class LIBSEARCH_EXPORT FileSearchPlugin : public QObject, public SearchPluginIface @@ -46,7 +47,7 @@ private: QHBoxLayout *m_nameFrameLyt = nullptr; QLabel *m_nameLabel = nullptr; QLabel *m_pluginLabel = nullptr; - QFrame *m_line_1 = nullptr; + SeparationLine *m_line_1 = nullptr; QFrame *m_pathFrame = nullptr; QLabel *m_pathLabel1 = nullptr; QLabel *m_pathLabel2 = nullptr; @@ -56,7 +57,7 @@ private: QLabel *m_timeLabel2 = nullptr; QHBoxLayout *m_timeFrameLyt = nullptr; - QFrame *m_line_2 = nullptr; + SeparationLine *m_line_2 = nullptr; QFrame *m_actionFrame = nullptr; QVBoxLayout *m_actionFrameLyt = nullptr; ActionLabel *m_actionLabel1 = nullptr; @@ -99,7 +100,7 @@ private: QHBoxLayout *m_nameFrameLyt = nullptr; QLabel *m_nameLabel = nullptr; QLabel *m_pluginLabel = nullptr; - QFrame *m_line_1 = nullptr; + SeparationLine *m_line_1 = nullptr; QFrame *m_pathFrame = nullptr; QLabel *m_pathLabel1 = nullptr; QLabel *m_pathLabel2 = nullptr; @@ -109,7 +110,7 @@ private: QLabel *m_timeLabel2 = nullptr; QHBoxLayout *m_timeFrameLyt = nullptr; - QFrame *m_line_2 = nullptr; + SeparationLine *m_line_2 = nullptr; QFrame *m_actionFrame = nullptr; QVBoxLayout *m_actionFrameLyt = nullptr; ActionLabel *m_actionLabel1 = nullptr; @@ -154,7 +155,7 @@ private: QHBoxLayout *m_nameFrameLyt = nullptr; QLabel *m_nameLabel = nullptr; QLabel *m_pluginLabel = nullptr; - QFrame *m_line_1 = nullptr; + SeparationLine *m_line_1 = nullptr; QLabel *m_snippetLabel = nullptr; QFrame *m_pathFrame = nullptr; QLabel *m_pathLabel1 = nullptr; @@ -165,7 +166,7 @@ private: QLabel *m_timeLabel2 = nullptr; QHBoxLayout *m_timeFrameLyt = nullptr; - QFrame *m_line_2 = nullptr; + SeparationLine *m_line_2 = nullptr; QFrame *m_actionFrame = nullptr; QVBoxLayout *m_actionFrameLyt = nullptr; ActionLabel *m_actionLabel1 = nullptr; diff --git a/libsearch/mailsearch/mail-search-plugin.cpp b/libsearch/mailsearch/mail-search-plugin.cpp index bc3f60a..cd3e661 100644 --- a/libsearch/mailsearch/mail-search-plugin.cpp +++ b/libsearch/mailsearch/mail-search-plugin.cpp @@ -9,7 +9,6 @@ using namespace UkuiSearch; #define DETAIL_ICON_HEIGHT 128 #define NAME_LABEL_MARGINS 8, 0, 0, 0 #define NAME_LABEL_WIDTH 282 -#define LINE_STYLE "QFrame{background: rgba(0, 0, 0, 0.2);}" #define DETAIL_ACTION_MARGINS 8, 0, 0, 0 #define DESC_PAGE_WIDTH 316 #define DESC_LABEL_MARGINS 0, 0, 0, 0 @@ -142,10 +141,7 @@ void MailSearchPlugin::initDetailPage() m_nameFrameLyt->addStretch(); m_nameFrameLyt->addWidget(m_pluginLabel); - m_line_1 = new QFrame(m_detailPage); - m_line_1->setLineWidth(0); - m_line_1->setFixedHeight(1); - m_line_1->setStyleSheet(LINE_STYLE); + m_line_1 = new SeparationLine(m_detailPage); m_descListArea = new MailDescArea(m_detailPage); QPalette scroll_bar_pal = m_descListArea->verticalScrollBar()->palette(); @@ -218,10 +214,7 @@ void MailSearchPlugin::initDetailPage() m_descPageLyt->addRow(m_ccLabel, m_ccFieldsLabel); // m_descPageLyt->addRow(m_attachmentLabel, m_attachmentFieldsLabel); - m_line_2 = new QFrame(m_detailPage); - m_line_2->setLineWidth(0); - m_line_2->setFixedHeight(1); - m_line_2->setStyleSheet(LINE_STYLE); + m_line_2 = new SeparationLine(m_detailPage); m_actionFrame = new QFrame(m_detailPage); m_actionFrameLyt = new QVBoxLayout(m_actionFrame); diff --git a/libsearch/mailsearch/mail-search-plugin.h b/libsearch/mailsearch/mail-search-plugin.h index 43e2ee6..9a65bea 100644 --- a/libsearch/mailsearch/mail-search-plugin.h +++ b/libsearch/mailsearch/mail-search-plugin.h @@ -22,6 +22,7 @@ #include #include "search-plugin-iface.h" #include "action-label.h" +#include "separation-line.h" #include "libsearch_global.h" namespace UkuiSearch { @@ -71,7 +72,7 @@ private: QHBoxLayout *m_nameFrameLyt = nullptr; QLabel *m_nameLabel = nullptr; QLabel *m_pluginLabel = nullptr; - QFrame *m_line_1 = nullptr; + SeparationLine *m_line_1 = nullptr; MailDescArea *m_descListArea = nullptr; QWidget *m_descPage = nullptr; @@ -91,7 +92,7 @@ private: QTextBrowser *m_ccFieldsLabel = nullptr; QLabel *m_attachmentFieldsLabel = nullptr; - QFrame *m_line_2 = nullptr; + SeparationLine *m_line_2 = nullptr; QFrame *m_actionFrame = nullptr; QVBoxLayout *m_actionFrameLyt = nullptr; ActionLabel *m_actionLabel1 = nullptr; diff --git a/libsearch/notesearch/note-search-plugin.cpp b/libsearch/notesearch/note-search-plugin.cpp index 764e7cb..17bf611 100644 --- a/libsearch/notesearch/note-search-plugin.cpp +++ b/libsearch/notesearch/note-search-plugin.cpp @@ -100,10 +100,8 @@ void NoteSearchPlugin::initDetailPage() m_nameFrameLyt->addStretch(); m_nameFrameLyt->addWidget(m_pluginLabel); - m_line_1 = new QFrame(m_detailPage); - m_line_1->setLineWidth(0); - m_line_1->setFixedHeight(1); - m_line_1->setStyleSheet("QFrame{background: rgba(0,0,0,0.2);}"); + m_line_1 = new SeparationLine(m_detailPage); + m_descFrame = new QFrame(m_detailPage); m_descFrameLyt = new QVBoxLayout(m_descFrame); m_descLabel = new QLabel(m_descFrame); @@ -112,15 +110,8 @@ void NoteSearchPlugin::initDetailPage() m_descFrameLyt->addWidget(m_descLabel); m_descFrame->setLayout(m_descFrameLyt); m_descFrameLyt->setContentsMargins(8, 0, 0, 0); - m_line_2 = new QFrame(m_detailPage); - m_line_2->setLineWidth(0); - m_line_2->setFixedHeight(1); - m_line_2->setStyleSheet("QFrame{background: rgba(0,0,0,0.2);}"); - m_line_1 = new QFrame(m_detailPage); - m_line_1->setLineWidth(0); - m_line_1->setFixedHeight(1); - m_line_1->setStyleSheet("QFrame{background: rgba(0,0,0,0.2);}"); + m_line_2 = new SeparationLine(m_detailPage); m_actionFrame = new QFrame(m_detailPage); m_actionFrameLyt = new QVBoxLayout(m_actionFrame); diff --git a/libsearch/notesearch/note-search-plugin.h b/libsearch/notesearch/note-search-plugin.h index 07efa18..2f3f413 100644 --- a/libsearch/notesearch/note-search-plugin.h +++ b/libsearch/notesearch/note-search-plugin.h @@ -15,6 +15,7 @@ #include #include "search-plugin-iface.h" #include "action-label.h" +#include "separation-line.h" #include "libsearch_global.h" namespace UkuiSearch { @@ -55,11 +56,11 @@ private: QHBoxLayout *m_nameFrameLyt = nullptr; QLabel *m_nameLabel = nullptr; QLabel *m_pluginLabel = nullptr; - QFrame *m_line_1 = nullptr; + SeparationLine *m_line_1 = nullptr; QFrame *m_descFrame = nullptr; QLabel *m_descLabel = nullptr; QVBoxLayout *m_descFrameLyt = nullptr; - QFrame *m_line_2 = nullptr; + SeparationLine *m_line_2 = nullptr; QFrame *m_actionFrame = nullptr; QVBoxLayout *m_actionFrameLyt = nullptr; ActionLabel *m_actionLabel1 = nullptr; diff --git a/libsearch/plugininterface/plugin-interface.pri b/libsearch/plugininterface/plugin-interface.pri index 6d65027..e4aec47 100644 --- a/libsearch/plugininterface/plugin-interface.pri +++ b/libsearch/plugininterface/plugin-interface.pri @@ -5,9 +5,11 @@ HEADERS += \ $$PWD/common-defines.h \ $$PWD/plugin-iface.h \ $$PWD/search-plugin-iface.h \ + $$PWD/search-task-plugin-iface.h \ $$PWD/data-queue.h \ - $$PWD/search-task-plugin-iface.h + $$PWD/separation-line.h SOURCES += \ - $$PWD/action-label.cpp + $$PWD/action-label.cpp \ + $$PWD/separation-line.cpp diff --git a/libsearch/plugininterface/separation-line.cpp b/libsearch/plugininterface/separation-line.cpp new file mode 100644 index 0000000..9514b26 --- /dev/null +++ b/libsearch/plugininterface/separation-line.cpp @@ -0,0 +1,24 @@ +#include "separation-line.h" +#include "global-settings.h" + +#define NOMORL_LINE_STYLE "QFrame{background: rgba(0,0,0,0.1);}" +#define DARK_LINE_STYLE "QFrame{background: rgba(255, 255, 255, 0.16);}" + +using namespace Zeeker; +SeparationLine::SeparationLine(QWidget *parent) : QFrame(parent) +{ + this->setLineWidth(0); + this->setFixedHeight(1); + setLineStyle(); + connect(qApp, &QApplication::paletteChanged, this, &SeparationLine::setLineStyle); +} + +void SeparationLine::setLineStyle() +{ + QString type = GlobalSettings::getInstance()->getValue(STYLE_NAME_KEY).toString(); + if (type == "ukui-dark") { + this->setStyleSheet(DARK_LINE_STYLE); + } else { + this->setStyleSheet(NOMORL_LINE_STYLE); + } +} diff --git a/libsearch/plugininterface/separation-line.h b/libsearch/plugininterface/separation-line.h new file mode 100644 index 0000000..97c0f1d --- /dev/null +++ b/libsearch/plugininterface/separation-line.h @@ -0,0 +1,17 @@ +#ifndef SEPARATIONLINE_H +#define SEPARATIONLINE_H + +#include +#include + +class SeparationLine : public QFrame +{ + Q_OBJECT +public: + SeparationLine(QWidget *parent = nullptr); + ~SeparationLine() = default; +public Q_SLOTS: + void setLineStyle(); +}; + +#endif // SEPARATIONLINE_H diff --git a/libsearch/settingsearch/settings-search-plugin.cpp b/libsearch/settingsearch/settings-search-plugin.cpp index 00d9277..ab7a3c6 100644 --- a/libsearch/settingsearch/settings-search-plugin.cpp +++ b/libsearch/settingsearch/settings-search-plugin.cpp @@ -111,10 +111,7 @@ void SettingsSearchPlugin::initDetailPage() m_nameFrameLyt->addStretch(); m_nameFrameLyt->addWidget(m_pluginLabel); - m_line_1 = new QFrame(m_detailPage); - m_line_1->setLineWidth(0); - m_line_1->setFixedHeight(1); - m_line_1->setStyleSheet("QFrame{background: rgba(0,0,0,0.2);}"); + m_line_1 = new SeparationLine(m_detailPage); m_actionFrame = new QFrame(m_detailPage); m_actionFrameLyt = new QVBoxLayout(m_actionFrame); diff --git a/libsearch/settingsearch/settings-search-plugin.h b/libsearch/settingsearch/settings-search-plugin.h index de68002..dd3eaa0 100644 --- a/libsearch/settingsearch/settings-search-plugin.h +++ b/libsearch/settingsearch/settings-search-plugin.h @@ -11,6 +11,7 @@ #include #include #include "action-label.h" +#include "separation-line.h" #include "search-plugin-iface.h" namespace UkuiSearch { @@ -52,7 +53,7 @@ private: QHBoxLayout *m_nameFrameLyt = nullptr; QLabel *m_nameLabel = nullptr; QLabel *m_pluginLabel = nullptr; - QFrame *m_line_1 = nullptr; + SeparationLine *m_line_1 = nullptr; QFrame *m_actionFrame = nullptr; QVBoxLayout *m_actionFrameLyt = nullptr; ActionLabel *m_actionLabel1 = nullptr;