diff --git a/debian/changelog b/debian/changelog index d9c057b..99cfc76 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +ukui-search (1.0.0+0731) v101; urgency=medium + + * test. + + -- zhangpengfei Sat, 31 Jul 2021 14:43:21 +0800 + ukui-search (0.4.0+0720) v101; urgency=medium * Bug 无 diff --git a/debian/libukui-search0.install b/debian/libukui-search0.install index c6bfa96..cda173e 100644 --- a/debian/libukui-search0.install +++ b/debian/libukui-search0.install @@ -1 +1,2 @@ usr/lib/*/libukui-search.so.* +libsearch/.qm/*.qm usr/share/ukui-search/translations diff --git a/debian/ukui-search.install b/debian/ukui-search.install index d7f1780..877acce 100644 --- a/debian/ukui-search.install +++ b/debian/ukui-search.install @@ -1,5 +1,5 @@ usr/bin/ukui-search etc/xdg/autostart/*.desktop usr/share/applications/*.desktop -src/.qm/*.qm usr/share/ukui-search/translations +frontend/.qm/*.qm usr/share/ukui-search/translations usr/share/glib-2.0/schemas/*.xml diff --git a/frontend/control/search-line-edit.cpp b/frontend/control/search-line-edit.cpp index 821991d..9e83b05 100644 --- a/frontend/control/search-line-edit.cpp +++ b/frontend/control/search-line-edit.cpp @@ -189,5 +189,8 @@ void LineEditStyle::drawPrimitive(QStyle::PrimitiveElement element, const QStyle } break; } + default: + return; +// return QProxyStyle::drawPrimitive(element, option, painter, widget); } } diff --git a/frontend/control/stack-pages/search-page-section.cpp b/frontend/control/stack-pages/search-page-section.cpp index fa85342..6bf7d28 100644 --- a/frontend/control/stack-pages/search-page-section.cpp +++ b/frontend/control/stack-pages/search-page-section.cpp @@ -20,6 +20,7 @@ */ #include "search-page-section.h" #include +#include using namespace Zeeker; #define RESULT_LAYOUT_MARGINS 0,0,0,0 @@ -80,6 +81,7 @@ void ResultArea::onWidgetSizeChanged() void ResultArea::initUi() { +// this->verticalScrollBar()->setProperty("drawScrollBarGroove", false); QPalette pal = palette(); pal.setColor(QPalette::Base, RESULT_BACKGROUND_COLOR); pal.setColor(QPalette::Window, RESULT_BACKGROUND_COLOR); @@ -107,7 +109,8 @@ void ResultArea::setupConnectionsForWidget(ResultWidget *widget) DetailArea::DetailArea(QWidget *parent) : QScrollArea(parent) { initUi(); - connect(this, &DetailArea::setWidgetInfo, m_detailWidget, &DetailWidget::setWidgetInfo); + connect(this, &DetailArea::setWidgetInfo, m_detailWidget, &DetailWidget::updateDetailPage); + connect(this, &DetailArea::setWidgetInfo, this, &DetailArea::show); } void DetailArea::initUi() @@ -120,6 +123,7 @@ void DetailArea::initUi() this->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); this->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); this->setWidgetResizable(true); + this->setFixedSize(368, 516); m_detailWidget = new DetailWidget(this); this->setWidget(m_detailWidget); this->hide(); @@ -127,8 +131,14 @@ void DetailArea::initUi() DetailWidget::DetailWidget(QWidget *parent) : QWidget(parent) { - initUi(); - clear(); +// initUi(); +// clear(); + this->setFixedWidth(368); + m_mainLyt = new QVBoxLayout(this); + this->setLayout(m_mainLyt); + m_mainLyt->setContentsMargins(DETAIL_WIDGET_MARGINS); + m_mainLyt->setAlignment(Qt::AlignHCenter); +// m_mainLyt->addStretch(); } QString escapeHtml(const QString & str) { @@ -140,121 +150,143 @@ QString escapeHtml(const QString & str) { void DetailWidget::setWidgetInfo(const QString &plugin_name, const SearchPluginIface::ResultInfo &info) { - clearLayout(m_descFrameLyt); - clearLayout(m_previewFrameLyt); - if(SearchPluginManager::getInstance()->getPlugin(plugin_name)->isPreviewEnable(info.actionKey,info.type)) { - m_iconLabel->hide(); - m_previewFrameLyt->addWidget(SearchPluginManager::getInstance()->getPlugin(plugin_name)->previewPage(info.actionKey,info.type, m_previewFrame), 0 , Qt::AlignHCenter); - m_previewFrameLyt->setContentsMargins(0,0,0,0); - m_previewFrame->show(); - } else { - m_previewFrame->hide(); - m_iconLabel->setPixmap(info.icon.pixmap(info.icon.actualSize(ICON_SIZE))); - m_iconLabel->show(); - } - QFontMetrics fontMetrics = m_nameLabel->fontMetrics(); - QString name = fontMetrics.elidedText(info.name, Qt::ElideRight, NAME_LABEL_WIDTH - 8); - m_nameLabel->setText(QString("

%1

").arg(escapeHtml(name))); - m_nameLabel->setToolTip(info.name); - m_pluginLabel->setText(plugin_name); - m_nameFrame->show(); - m_line_1->show(); +// clearLayout(m_descFrameLyt); +// clearLayout(m_previewFrameLyt); +// if(SearchPluginManager::getInstance()->getPlugin(plugin_name)->isPreviewEnable(info.actionKey,info.type)) { +// m_iconLabel->hide(); +// m_previewFrameLyt->addWidget(SearchPluginManager::getInstance()->getPlugin(plugin_name)->previewPage(info.actionKey,info.type, m_previewFrame), 0 , Qt::AlignHCenter); +// m_previewFrameLyt->setContentsMargins(0,0,0,0); +// m_previewFrame->show(); +// } else { +// m_previewFrame->hide(); +// m_iconLabel->setPixmap(info.icon.pixmap(info.icon.actualSize(ICON_SIZE))); +// m_iconLabel->show(); +// } +// QFontMetrics fontMetrics = m_nameLabel->fontMetrics(); +// QString name = fontMetrics.elidedText(info.name, Qt::ElideRight, NAME_LABEL_WIDTH - 8); +// m_nameLabel->setText(QString("

%1

").arg(escapeHtml(name))); +// m_nameLabel->setToolTip(info.name); +// m_pluginLabel->setText(plugin_name); +// m_nameFrame->show(); +// m_line_1->show(); - if (info.description.length() > 0) { - //NEW_TODO 样式待优化 - clearLayout(m_descFrameLyt); - Q_FOREACH (SearchPluginIface::DescriptionInfo desc, info.description) { - QLabel * descLabel = new QLabel(m_descFrame); - descLabel->setTextFormat(Qt::PlainText); - descLabel->setWordWrap(true); - QString show_desc = desc.key + " " + desc.value; - descLabel->setText(show_desc); - m_descFrameLyt->addWidget(descLabel); +// if (info.description.length() > 0) { +// //NEW_TODO 样式待优化 +// clearLayout(m_descFrameLyt); +// Q_FOREACH (SearchPluginIface::DescriptionInfo desc, info.description) { +// QLabel * descLabel = new QLabel(m_descFrame); +// descLabel->setTextFormat(Qt::PlainText); +// descLabel->setWordWrap(true); +// QString show_desc = desc.key + " " + desc.value; +// descLabel->setText(show_desc); +// m_descFrameLyt->addWidget(descLabel); +// } +// m_descFrame->show(); +// m_line_2->show(); +// } +// clearLayout(m_actionFrameLyt); +// Q_FOREACH (SearchPluginIface::Actioninfo actioninfo, SearchPluginManager::getInstance()->getPlugin(plugin_name)->getActioninfo(info.type)) { +// ActionLabel * actionLabel = new ActionLabel(actioninfo.displayName, info.actionKey, actioninfo.actionkey, plugin_name, info.type, m_actionFrame); +// m_actionFrameLyt->addWidget(actionLabel); +// } +// m_actionFrame->show(); +} + +void DetailWidget::updateDetailPage(const QString &plugin_name, const SearchPluginIface::ResultInfo &info) +{ + if(m_detailPage) { + if(m_currentPluginId == plugin_name) { + SearchPluginManager::getInstance()->getPlugin(plugin_name)->detailPage(info); + } else { + m_mainLyt->removeWidget(m_detailPage); + m_detailPage->hide(); + m_detailPage = SearchPluginManager::getInstance()->getPlugin(plugin_name)->detailPage(info); + m_detailPage->setParent(this); + m_mainLyt->addWidget(m_detailPage); + m_detailPage->show(); +// m_mainLyt->insertWidget(0, m_detailPage, 0); } - m_descFrame->show(); - m_line_2->show(); + } else { + m_detailPage = SearchPluginManager::getInstance()->getPlugin(plugin_name)->detailPage(info); + m_detailPage->setParent(this); + m_mainLyt->addWidget(m_detailPage); +// m_mainLyt->insertWidget(0, m_detailPage, 0); } - clearLayout(m_actionFrameLyt); - Q_FOREACH (SearchPluginIface::Actioninfo actioninfo, SearchPluginManager::getInstance()->getPlugin(plugin_name)->getActioninfo(info.type)) { - ActionLabel * actionLabel = new ActionLabel(actioninfo.displayName, info.actionKey, actioninfo.actionkey, plugin_name, info.type, m_actionFrame); - m_actionFrameLyt->addWidget(actionLabel); - } - m_actionFrame->show(); } void DetailWidget::clear() { - m_iconLabel->hide(); - m_nameFrame->hide(); - m_line_1->hide(); - m_descFrame->hide(); - m_line_2->hide(); - m_actionFrame->hide(); +// m_iconLabel->hide(); +// m_nameFrame->hide(); +// m_line_1->hide(); +// m_descFrame->hide(); +// m_line_2->hide(); +// m_actionFrame->hide(); } void DetailWidget::initUi() { - this->setFixedSize(368, 516); - m_mainLyt = new QVBoxLayout(this); - this->setLayout(m_mainLyt); - m_mainLyt->setContentsMargins(DETAIL_WIDGET_MARGINS); - m_mainLyt->setAlignment(Qt::AlignHCenter); +// this->setFixedSize(368, 516); +// m_mainLyt = new QVBoxLayout(this); +// this->setLayout(m_mainLyt); +// m_mainLyt->setContentsMargins(DETAIL_WIDGET_MARGINS); +// m_mainLyt->setAlignment(Qt::AlignHCenter); - m_iconLabel = new QLabel(this); - m_iconLabel->setFixedHeight(DETAIL_ICON_HEIGHT); - m_iconLabel->setAlignment(Qt::AlignCenter); - m_previewFrame = new QFrame(this); - m_previewFrameLyt = new QHBoxLayout(m_previewFrame); +// m_iconLabel = new QLabel(this); +// m_iconLabel->setFixedHeight(DETAIL_ICON_HEIGHT); +// m_iconLabel->setAlignment(Qt::AlignCenter); +// m_previewFrame = new QFrame(this); +// m_previewFrameLyt = new QHBoxLayout(m_previewFrame); - m_nameFrame = new QFrame(this); - m_nameFrameLyt = new QHBoxLayout(m_nameFrame); - m_nameFrame->setLayout(m_nameFrameLyt); - m_nameFrameLyt->setContentsMargins(DETAIL_FRAME_MARGINS); - m_nameLabel = new QLabel(m_nameFrame); - m_nameLabel->setMaximumWidth(NAME_LABEL_WIDTH); - m_pluginLabel = new QLabel(m_nameFrame); - m_pluginLabel->setEnabled(false); - m_nameFrameLyt->addWidget(m_nameLabel); - m_nameFrameLyt->addStretch(); - m_nameFrameLyt->addWidget(m_pluginLabel); +// m_nameFrame = new QFrame(this); +// m_nameFrameLyt = new QHBoxLayout(m_nameFrame); +// m_nameFrame->setLayout(m_nameFrameLyt); +// m_nameFrameLyt->setContentsMargins(DETAIL_FRAME_MARGINS); +// m_nameLabel = new QLabel(m_nameFrame); +// m_nameLabel->setMaximumWidth(NAME_LABEL_WIDTH); +// m_pluginLabel = new QLabel(m_nameFrame); +// m_pluginLabel->setEnabled(false); +// m_nameFrameLyt->addWidget(m_nameLabel); +// m_nameFrameLyt->addStretch(); +// m_nameFrameLyt->addWidget(m_pluginLabel); - m_line_1 = new QFrame(this); - m_line_1->setFixedHeight(1); - m_line_1->setLineWidth(0); - m_line_1->setStyleSheet(LINE_STYLE); - m_line_2 = new QFrame(this); - m_line_2->setFixedHeight(1); - m_line_2->setLineWidth(0); - m_line_2->setStyleSheet(LINE_STYLE); +// m_line_1 = new QFrame(this); +// m_line_1->setFixedHeight(1); +// m_line_1->setLineWidth(0); +// m_line_1->setStyleSheet(LINE_STYLE); +// m_line_2 = new QFrame(this); +// m_line_2->setFixedHeight(1); +// m_line_2->setLineWidth(0); +// m_line_2->setStyleSheet(LINE_STYLE); - m_descFrame = new QFrame(this); - m_descFrameLyt = new QVBoxLayout(m_descFrame); - m_descFrame->setLayout(m_descFrameLyt); - m_descFrameLyt->setContentsMargins(DETAIL_FRAME_MARGINS); +// m_descFrame = new QFrame(this); +// m_descFrameLyt = new QVBoxLayout(m_descFrame); +// m_descFrame->setLayout(m_descFrameLyt); +// m_descFrameLyt->setContentsMargins(DETAIL_FRAME_MARGINS); - m_actionFrame = new QFrame(this); - m_actionFrameLyt = new QVBoxLayout(m_actionFrame); - m_actionFrame->setLayout(m_actionFrameLyt); - m_actionFrameLyt->setContentsMargins(DETAIL_FRAME_MARGINS); +// m_actionFrame = new QFrame(this); +// m_actionFrameLyt = new QVBoxLayout(m_actionFrame); +// m_actionFrame->setLayout(m_actionFrameLyt); +// m_actionFrameLyt->setContentsMargins(DETAIL_FRAME_MARGINS); - m_mainLyt->addWidget(m_iconLabel); - m_mainLyt->addWidget(m_previewFrame, 0, Qt::AlignHCenter); - m_mainLyt->addWidget(m_nameFrame); - m_mainLyt->addWidget(m_line_1); - m_mainLyt->addWidget(m_descFrame); - m_mainLyt->addWidget(m_line_2); - m_mainLyt->addWidget(m_actionFrame); - m_mainLyt->addStretch(); +// m_mainLyt->addWidget(m_iconLabel); +// m_mainLyt->addWidget(m_previewFrame, 0, Qt::AlignHCenter); +// m_mainLyt->addWidget(m_nameFrame); +// m_mainLyt->addWidget(m_line_1); +// m_mainLyt->addWidget(m_descFrame); +// m_mainLyt->addWidget(m_line_2); +// m_mainLyt->addWidget(m_actionFrame); +// m_mainLyt->addStretch(); } -void DetailWidget::paintEvent(QPaintEvent * event) +void DetailWidget::paintEvent(QPaintEvent *event) { QStyleOption opt; opt.init(this); QPainter p(this); style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); - QRect rect = this->rect(); + QRect rect = this->rect().adjusted(0, 0, -8, 0); p.setRenderHint(QPainter::Antialiasing); // 反锯齿; p.setBrush(opt.palette.color(QPalette::Text)); p.setOpacity(DETAIL_WIDGET_TRANSPARENT); @@ -276,49 +308,49 @@ void DetailWidget::clearLayout(QLayout *layout) child = NULL; } -ActionLabel::ActionLabel(const QString &action, const QString &key, const int &ActionKey, const QString &pluginId, const int type, QWidget *parent) : QLabel(parent) -{ - m_action = action; - m_key = key; - m_actionKey = ActionKey; - m_type = type; - m_pluginId = pluginId; - this->initUi(); - this->installEventFilter(this); -} +//ActionLabel::ActionLabel(const QString &action, const QString &key, const int &ActionKey, const QString &pluginId, const int type, QWidget *parent) : QLabel(parent) +//{ +// m_action = action; +// m_key = key; +// m_actionKey = ActionKey; +// m_type = type; +// m_pluginId = pluginId; +// this->initUi(); +// this->installEventFilter(this); +//} -void ActionLabel::initUi() -{ - this->setText(m_action); - QPalette pal = palette(); - pal.setColor(QPalette::WindowText, ACTION_NORMAL_COLOR); - pal.setColor(QPalette::Light, ACTION_HOVER_COLOR); - pal.setColor(QPalette::Dark, ACTION_PRESS_COLOR); - this->setPalette(pal); - this->setForegroundRole(QPalette::WindowText); - this->setCursor(QCursor(Qt::PointingHandCursor)); -} +//void ActionLabel::initUi() +//{ +// this->setText(m_action); +// QPalette pal = palette(); +// pal.setColor(QPalette::WindowText, ACTION_NORMAL_COLOR); +// pal.setColor(QPalette::Light, ACTION_HOVER_COLOR); +// pal.setColor(QPalette::Dark, ACTION_PRESS_COLOR); +// this->setPalette(pal); +// this->setForegroundRole(QPalette::WindowText); +// this->setCursor(QCursor(Qt::PointingHandCursor)); +//} -bool ActionLabel::eventFilter(QObject *watched, QEvent *event) -{ - if (watched == this) { - if(event->type() == QEvent::MouseButtonPress) { - this->setForegroundRole(QPalette::Dark); - return true; - } else if(event->type() == QEvent::MouseButtonRelease) { - SearchPluginIface *plugin = SearchPluginManager::getInstance()->getPlugin(m_pluginId); - if (plugin) - plugin->openAction(m_actionKey, m_key, m_type); - else - qWarning()<<"Get plugin failed!"; - this->setForegroundRole(QPalette::Light); - return true; - } else if(event->type() == QEvent::Enter) { - this->setForegroundRole(QPalette::Light); - return true; - } else if(event->type() == QEvent::Leave) { - this->setForegroundRole(QPalette::WindowText); - return true; - } - } -} +//bool ActionLabel::eventFilter(QObject *watched, QEvent *event) +//{ +// if (watched == this) { +// if(event->type() == QEvent::MouseButtonPress) { +// this->setForegroundRole(QPalette::Dark); +// return true; +// } else if(event->type() == QEvent::MouseButtonRelease) { +// SearchPluginIface *plugin = SearchPluginManager::getInstance()->getPlugin(m_pluginId); +// if (plugin) +// plugin->openAction(m_actionKey, m_key, m_type); +// else +// qWarning()<<"Get plugin failed!"; +// this->setForegroundRole(QPalette::Light); +// return true; +// } else if(event->type() == QEvent::Enter) { +// this->setForegroundRole(QPalette::Light); +// return true; +// } else if(event->type() == QEvent::Leave) { +// this->setForegroundRole(QPalette::WindowText); +// return true; +// } +// } +//} diff --git a/frontend/control/stack-pages/search-page-section.h b/frontend/control/stack-pages/search-page-section.h index 2c615be..9f51ca7 100644 --- a/frontend/control/stack-pages/search-page-section.h +++ b/frontend/control/stack-pages/search-page-section.h @@ -62,26 +62,29 @@ public: void clear(); public Q_SLOTS: - void setWidgetInfo(const QString&, const SearchPluginIface::ResultInfo&); - + void setWidgetInfo(const QString &plugin_name, const SearchPluginIface::ResultInfo &info); + void updateDetailPage(const QString &plugin_name, const SearchPluginIface::ResultInfo &info); +protected: + void paintEvent(QPaintEvent *event); private: void initUi(); - void paintEvent(QPaintEvent *); void clearLayout(QLayout *); QVBoxLayout * m_mainLyt = nullptr; - QLabel * m_iconLabel = nullptr; - QFrame *m_previewFrame = nullptr; - QHBoxLayout *m_previewFrameLyt = nullptr; - QFrame * m_nameFrame = nullptr; - QHBoxLayout * m_nameFrameLyt = nullptr; - QLabel * m_nameLabel = nullptr; - QLabel * m_pluginLabel = nullptr; - QFrame * m_line_1 = nullptr; - QFrame * m_descFrame = nullptr; - QVBoxLayout * m_descFrameLyt = nullptr; - QFrame * m_line_2 = nullptr; - QFrame * m_actionFrame = nullptr; - QVBoxLayout * m_actionFrameLyt = nullptr; + QString m_currentPluginId; + QWidget *m_detailPage = nullptr; +// QLabel * m_iconLabel = nullptr; +// QFrame *m_previewFrame = nullptr; +// QHBoxLayout *m_previewFrameLyt = nullptr; +// QFrame * m_nameFrame = nullptr; +// QHBoxLayout * m_nameFrameLyt = nullptr; +// QLabel * m_nameLabel = nullptr; +// QLabel * m_pluginLabel = nullptr; +// QFrame * m_line_1 = nullptr; +// QFrame * m_descFrame = nullptr; +// QVBoxLayout * m_descFrameLyt = nullptr; +// QFrame * m_line_2 = nullptr; +// QFrame * m_actionFrame = nullptr; +// QVBoxLayout * m_actionFrameLyt = nullptr; }; class DetailArea : public QScrollArea @@ -98,23 +101,23 @@ Q_SIGNALS: void setWidgetInfo(const QString&, const SearchPluginIface::ResultInfo&); }; -class ActionLabel : public QLabel -{ - Q_OBJECT -public: - ActionLabel(const QString &action, const QString &key, const int &ActionKey, const QString &pluginId, const int type = 0, QWidget *parent = nullptr); - ~ActionLabel() = default; -private: - void initUi(); - QString m_action; - QString m_key; - int m_actionKey; - int m_type = 0; - QString m_pluginId; +//class ActionLabel : public QLabel +//{ +// Q_OBJECT +//public: +// ActionLabel(const QString &action, const QString &key, const int &ActionKey, const QString &pluginId, const int type = 0, QWidget *parent = nullptr); +// ~ActionLabel() = default; +//private: +// void initUi(); +// QString m_action; +// QString m_key; +// int m_actionKey; +// int m_type = 0; +// QString m_pluginId; -protected: - bool eventFilter(QObject *, QEvent *); -}; +//protected: +// bool eventFilter(QObject *, QEvent *); +//}; } diff --git a/frontend/control/stack-pages/search-result-page.cpp b/frontend/control/stack-pages/search-result-page.cpp index a09ce68..9146c6c 100644 --- a/frontend/control/stack-pages/search-result-page.cpp +++ b/frontend/control/stack-pages/search-result-page.cpp @@ -129,6 +129,8 @@ void SearchResultPage::initConnections() { connect(this, &SearchResultPage::startSearch, m_resultArea, &ResultArea::startSearch); connect(this, &SearchResultPage::stopSearch, m_resultArea, &ResultArea::stopSearch); + connect(this, &SearchResultPage::startSearch, m_detailArea, &DetailArea::hide); + connect(this, &SearchResultPage::stopSearch, m_detailArea, &DetailArea::hide); } void SearchResultPage::setupConnectionsForWidget(ResultWidget *widget) diff --git a/frontend/view/result-view.cpp b/frontend/view/result-view.cpp index c2ec8bb..d8b109f 100644 --- a/frontend/view/result-view.cpp +++ b/frontend/view/result-view.cpp @@ -142,6 +142,8 @@ void ResultView::clearSelectedRow() this->blockSignals(true); this->clearSelection(); this->blockSignals(false); + } else { + m_is_selected = false; } } @@ -178,7 +180,7 @@ void ResultView::onRowSelectedSlot(const QItemSelection &selected, const QItemSe //NEW_TODO m_is_selected = true; Q_EMIT this->currentRowChanged(m_plugin_id, m_model->getInfo(this->currentIndex())); - m_is_selected = false; + if(!selected.isEmpty()) { QRegion region = visualRegionForSelection(selected); QRect rect = region.boundingRect(); @@ -240,7 +242,6 @@ void ResultView::initConnections() { // connect(this, &ResultView::startSearch, m_model, &SearchResultModel::startSearch); connect(this, &ResultView::startSearch, [ = ](const QString &keyword) { - qDebug() << "==========start search!"; m_style_delegate->setSearchKeyword(keyword); m_model->startSearch(keyword); }); diff --git a/libsearch/appsearch/app-search-plugin.cpp b/libsearch/appsearch/app-search-plugin.cpp index b2ec215..a1d9ffa 100644 --- a/libsearch/appsearch/app-search-plugin.cpp +++ b/libsearch/appsearch/app-search-plugin.cpp @@ -2,6 +2,7 @@ #include #include #include +#include "file-utils.h" using namespace Zeeker; size_t AppSearchPlugin::uniqueSymbol = 0; QMutex AppSearchPlugin::m_mutex; @@ -16,6 +17,7 @@ AppSearchPlugin::AppSearchPlugin(QObject *parent) : QObject(parent) AppMatch::getAppMatch()->start(); m_pool.setMaxThreadCount(2); m_pool.setExpiryTimeout(1000); + initDetailPage(); } const QString AppSearchPlugin::name() @@ -91,16 +93,126 @@ void AppSearchPlugin::openAction(int actionkey, QString key, int type) } } -bool AppSearchPlugin::isPreviewEnable(QString key, int type) +QWidget *AppSearchPlugin::detailPage(const ResultInfo &ri) { - return false; + m_currentActionKey = ri.actionKey; + m_iconLabel->setPixmap(ri.icon.pixmap(120, 120)); + QFontMetrics fontMetrics = m_nameLabel->fontMetrics(); + QString showname = fontMetrics.elidedText(ri.name, Qt::ElideRight, 274); //当字体长度超过215时显示为省略号 + m_nameLabel->setText(QString("

%1

").arg(FileUtils::escapeHtml(showname))); + if(QString::compare(showname, ri.name)) { + m_nameLabel->setToolTip(ri.name); + } + m_pluginLabel->setText(tr("Application")); + if(ri.type == 1) { + m_actionLabel1->hide(); + m_actionLabel2->hide(); + m_actionLabel3->hide(); + m_actionLabel4->show(); + QString showDesc = fontMetrics.elidedText(ri.description.at(0).key + " " + ri.description.at(0).value, Qt::ElideRight, 3114); //当字体长度超过215时显示为省略号 + m_descLabel->setText(FileUtils::escapeHtml(showDesc)); + m_descFrame->show(); + m_line_2->show(); + + } else { + m_descFrame->hide(); + m_line_2->hide(); + m_actionLabel1->show(); + m_actionLabel2->show(); + m_actionLabel3->show(); + m_actionLabel4->hide(); + } + return m_detailPage; } -QWidget *AppSearchPlugin::previewPage(QString key, int type, QWidget *parent = nullptr) +void AppSearchPlugin::initDetailPage() { - return nullptr; + m_detailPage = new QWidget(); + m_detailPage->setFixedWidth(360); + m_detailPage->setAttribute(Qt::WA_TranslucentBackground); + m_detailLyt = new QVBoxLayout(m_detailPage); + m_detailLyt->setContentsMargins(8, 0, 16, 0); + m_iconLabel = new QLabel(m_detailPage); + m_iconLabel->setAlignment(Qt::AlignCenter); + m_iconLabel->setFixedHeight(128); + + m_nameFrame = new QFrame(m_detailPage); + m_nameFrameLyt = new QHBoxLayout(m_nameFrame); + m_nameFrame->setLayout(m_nameFrameLyt); + m_nameFrameLyt->setContentsMargins(8, 0, 0, 0); + m_nameLabel = new QLabel(m_nameFrame); + m_nameLabel->setMaximumWidth(280); + m_pluginLabel = new QLabel(m_nameFrame); + m_pluginLabel->setEnabled(false); + m_nameFrameLyt->addWidget(m_nameLabel); + 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_descFrame = new QFrame(m_detailPage); + m_descFrameLyt = new QVBoxLayout(m_descFrame); + m_descLabel = new QLabel(m_descFrame); + m_descLabel->setTextFormat(Qt::PlainText); + m_descLabel->setWordWrap(true); + 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_actionFrame = new QFrame(m_detailPage); + m_actionFrameLyt = new QVBoxLayout(m_actionFrame); + m_actionFrameLyt->setContentsMargins(8, 0, 0, 0); + m_actionLabel1 = new ActionLabel(tr("Open"), m_currentActionKey, m_actionFrame); + m_actionLabel2 = new ActionLabel(tr("Add Shortcut to Desktop"), m_currentActionKey, m_actionFrame); + m_actionLabel3 = new ActionLabel(tr("Add Shortcut to Panel"), m_currentActionKey, m_actionFrame); + m_actionLabel4 = new ActionLabel(tr("Install"), m_currentActionKey, m_actionFrame); + + m_actionFrameLyt->addWidget(m_actionLabel1); + m_actionFrameLyt->addWidget(m_actionLabel2); + m_actionFrameLyt->addWidget(m_actionLabel3); + m_actionFrameLyt->addWidget(m_actionLabel4); + m_actionFrame->setLayout(m_actionFrameLyt); + + m_detailLyt->addSpacing(50); + m_detailLyt->addWidget(m_iconLabel); + m_detailLyt->addWidget(m_nameFrame); + m_detailLyt->addWidget(m_line_1); + m_detailLyt->addWidget(m_descFrame); + m_detailLyt->addWidget(m_line_2); + m_detailLyt->addWidget(m_actionFrame); + m_detailPage->setLayout(m_detailLyt); + m_detailLyt->addStretch(); + + connect(m_actionLabel1, &ActionLabel::actionTriggered, [ & ](){ + launch(m_currentActionKey); + }); + connect(m_actionLabel2, &ActionLabel::actionTriggered, [ & ](){ + addDesktopShortcut(m_currentActionKey); + }); + connect(m_actionLabel3, &ActionLabel::actionTriggered, [ & ](){ + addPanelShortcut(m_currentActionKey); + }); + connect(m_actionLabel4, &ActionLabel::actionTriggered, [ & ](){ + installAppAction(m_currentActionKey); + }); } +//bool AppSearchPlugin::isPreviewEnable(QString key, int type) +//{ +// return false; +//} + +//QWidget *AppSearchPlugin::previewPage(QString key, int type, QWidget *parent = nullptr) +//{ +// return nullptr; +//} + bool AppSearchPlugin::launch(const QString &path) { GDesktopAppInfo * desktopAppInfo = g_desktop_app_info_new_from_filename(path.toLocal8Bit().data()); diff --git a/libsearch/appsearch/app-search-plugin.h b/libsearch/appsearch/app-search-plugin.h index 01cf4e1..f5ea35f 100644 --- a/libsearch/appsearch/app-search-plugin.h +++ b/libsearch/appsearch/app-search-plugin.h @@ -2,8 +2,15 @@ #define APPSEARCHPLUGIN_H #include +#include +#include +#include +#include +#include +#include #include "search-plugin-iface.h" #include "app-match.h" +#include "action-label.h" #include "libsearch_global.h" namespace Zeeker { class LIBSEARCH_EXPORT AppSearchPlugin : public QObject, public SearchPluginIface @@ -23,9 +30,11 @@ public: void KeywordSearch(QString keyword,DataQueue *searchResult); QList getActioninfo(int type); void openAction(int actionkey, QString key, int type); - bool isPreviewEnable(QString key, int type); - QWidget *previewPage(QString key, int type, QWidget *parent); +// bool isPreviewEnable(QString key, int type); +// QWidget *previewPage(QString key, int type, QWidget *parent); + QWidget *detailPage(const ResultInfo &ri); private: + void initDetailPage(); bool launch(const QString &path); bool addPanelShortcut(const QString &path); bool addDesktopShortcut(const QString &path); @@ -36,6 +45,28 @@ private: QThreadPool m_pool; static size_t uniqueSymbol; static QMutex m_mutex; + + QString m_currentActionKey; + QWidget *m_detailPage; + QVBoxLayout *m_detailLyt = nullptr; + QLabel *m_iconLabel = nullptr; + QFrame *m_nameFrame = nullptr; + QHBoxLayout *m_nameFrameLyt = nullptr; + QLabel *m_nameLabel = nullptr; + QLabel *m_pluginLabel = nullptr; + QFrame *m_line_1 = nullptr; + QFrame *m_descFrame = nullptr; + QLabel *m_descLabel = nullptr; + QVBoxLayout *m_descFrameLyt = nullptr; + QFrame *m_line_2 = nullptr; + QFrame *m_actionFrame = nullptr; + QVBoxLayout *m_actionFrameLyt = nullptr; + ActionLabel *m_actionLabel1 = nullptr; + ActionLabel *m_actionLabel2 = nullptr; + ActionLabel *m_actionLabel3 = nullptr; + ActionLabel *m_actionLabel4 = nullptr; + + QVBoxLayout * m_actionLyt = nullptr; }; class AppSearch : public QObject, public QRunnable { diff --git a/libsearch/file-utils.cpp b/libsearch/file-utils.cpp index d640a79..9a054c6 100644 --- a/libsearch/file-utils.cpp +++ b/libsearch/file-utils.cpp @@ -788,3 +788,11 @@ bool FileUtils::copyPath(QString &path) QApplication::clipboard()->setText(path); return true; } + +QString FileUtils::escapeHtml(const QString &str) +{ + QString temp = str; + temp.replace("<", "<"); + temp.replace(">", ">"); + return temp; +} diff --git a/libsearch/file-utils.h b/libsearch/file-utils.h index c718f53..e3319eb 100644 --- a/libsearch/file-utils.h +++ b/libsearch/file-utils.h @@ -89,6 +89,7 @@ public: static bool openFile(QString &path, bool openInDir = false); static bool copyPath(QString &path); + static QString escapeHtml(const QString & str); static size_t _max_index_count; static size_t _current_index_count; //this one has been Abandoned,do not use it. static unsigned short _index_status; diff --git a/libsearch/index/file-search-plugin.cpp b/libsearch/index/file-search-plugin.cpp index 3b42d88..2e29131 100644 --- a/libsearch/index/file-search-plugin.cpp +++ b/libsearch/index/file-search-plugin.cpp @@ -13,6 +13,7 @@ FileSearchPlugin::FileSearchPlugin(QObject *parent) : QObject(parent) m_actionInfo << open << Openpath << CopyPath; m_pool.setMaxThreadCount(2); m_pool.setExpiryTimeout(1000); + initDetailPage(); } const QString FileSearchPlugin::name() @@ -68,25 +69,131 @@ void FileSearchPlugin::openAction(int actionkey, QString key, int type) } } -bool FileSearchPlugin::isPreviewEnable(QString key, int type) +QWidget *FileSearchPlugin::detailPage(const ResultInfo &ri) { - return true; + m_currentActionKey = ri.actionKey; + m_iconLabel->setPixmap(ri.icon.pixmap(120, 120)); + QFontMetrics fontMetrics = m_nameLabel->fontMetrics(); + QString showname = fontMetrics.elidedText(ri.name, Qt::ElideRight, 274); //当字体长度超过215时显示为省略号 + m_nameLabel->setText(QString("

%1

").arg(FileUtils::escapeHtml(showname))); + if(QString::compare(showname, ri.name)) { + m_nameLabel->setToolTip(ri.name); + } + m_pluginLabel->setText(tr("File")); + + m_pathLabel2->setText(m_pathLabel2->fontMetrics().elidedText(m_currentActionKey, Qt::ElideRight, m_pathLabel2->width())); + m_pathLabel2->setToolTip(m_currentActionKey); + m_timeLabel2->setText(ri.description.at(1).value); + return m_detailPage; } -QWidget *FileSearchPlugin::previewPage(QString key, int type, QWidget *parent) +void FileSearchPlugin::initDetailPage() { - QWidget *previewPage = new QWidget(parent); - QHBoxLayout * previewLyt = new QHBoxLayout(previewPage); - previewLyt->setContentsMargins(0, 0, 0, 0); - QLabel *label = new QLabel(previewPage); - previewLyt->addWidget(label); - label->setFixedHeight(120); - previewPage->setFixedSize(120,120); - previewLyt->setAlignment(Qt::AlignCenter); - label->setPixmap(FileUtils::getFileIcon(QUrl::fromLocalFile(key).toString()).pixmap(120,120)); - return previewPage; + m_detailPage = new QWidget(); + m_detailPage->setFixedWidth(360); + m_detailPage->setAttribute(Qt::WA_TranslucentBackground); + m_detailLyt = new QVBoxLayout(m_detailPage); + m_detailLyt->setContentsMargins(8, 0, 16, 0); + m_iconLabel = new QLabel(m_detailPage); + m_iconLabel->setAlignment(Qt::AlignCenter); + m_iconLabel->setFixedHeight(128); + + m_nameFrame = new QFrame(m_detailPage); + m_nameFrameLyt = new QHBoxLayout(m_nameFrame); + m_nameFrame->setLayout(m_nameFrameLyt); + m_nameFrameLyt->setContentsMargins(8, 0, 0, 0); + m_nameLabel = new QLabel(m_nameFrame); + m_nameLabel->setMaximumWidth(280); + m_pluginLabel = new QLabel(m_nameFrame); + m_pluginLabel->setEnabled(false); + m_nameFrameLyt->addWidget(m_nameLabel); + 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_pathFrame = new QFrame(m_detailPage); + m_pathFrameLyt = new QHBoxLayout(m_pathFrame); + m_pathLabel1 = new QLabel(m_pathFrame); + m_pathLabel2 = new QLabel(m_pathFrame); + m_pathLabel1->setText(tr("Path")); + m_pathLabel2->setFixedWidth(240); + m_pathLabel2->setAlignment(Qt::AlignRight); + m_pathFrameLyt->addWidget(m_pathLabel1); + m_pathFrameLyt->addStretch(); + m_pathFrameLyt->addWidget(m_pathLabel2); + + m_timeFrame = new QFrame(m_detailPage); + m_timeFrameLyt = new QHBoxLayout(m_timeFrame); + m_timeLabel1 = new QLabel(m_timeFrame); + m_timeLabel2 = new QLabel(m_timeFrame); + m_timeLabel2->setAlignment(Qt::AlignRight); + m_timeLabel1->setText(tr("Last time modified")); + m_timeFrameLyt->addWidget(m_timeLabel1); + 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_actionFrame = new QFrame(m_detailPage); + m_actionFrameLyt = new QVBoxLayout(m_actionFrame); + m_actionFrameLyt->setContentsMargins(8, 0, 0, 0); + m_actionLabel1 = new ActionLabel(tr("Open"), m_currentActionKey, m_actionFrame); + m_actionLabel2 = new ActionLabel(tr("Open path"), m_currentActionKey, m_actionFrame); + m_actionLabel3 = new ActionLabel(tr("Copy path"), m_currentActionKey, m_actionFrame); + + m_actionFrameLyt->addWidget(m_actionLabel1); + m_actionFrameLyt->addWidget(m_actionLabel2); + m_actionFrameLyt->addWidget(m_actionLabel3); + m_actionFrame->setLayout(m_actionFrameLyt); + + m_detailLyt->addSpacing(50); + m_detailLyt->addWidget(m_iconLabel); + m_detailLyt->addWidget(m_nameFrame); + m_detailLyt->addWidget(m_line_1); + m_detailLyt->addWidget(m_pathFrame); + m_detailLyt->addWidget(m_timeFrame); + m_detailLyt->addWidget(m_line_2); + m_detailLyt->addWidget(m_actionFrame); + m_detailPage->setLayout(m_detailLyt); + m_detailLyt->addStretch(); + + connect(m_actionLabel1, &ActionLabel::actionTriggered, [ & ](){ + FileUtils::openFile(m_currentActionKey); + }); + connect(m_actionLabel2, &ActionLabel::actionTriggered, [ & ](){ + FileUtils::openFile(m_currentActionKey, true); + }); + connect(m_actionLabel3, &ActionLabel::actionTriggered, [ & ](){ + FileUtils::copyPath(m_currentActionKey); + }); } +//bool FileSearchPlugin::isPreviewEnable(QString key, int type) +//{ +// return true; +//} + +//QWidget *FileSearchPlugin::previewPage(QString key, int type, QWidget *parent) +//{ +// QWidget *previewPage = new QWidget(parent); +// QHBoxLayout * previewLyt = new QHBoxLayout(previewPage); +// previewLyt->setContentsMargins(0, 0, 0, 0); +// QLabel *label = new QLabel(previewPage); +// previewLyt->addWidget(label); +// label->setFixedHeight(120); +// previewPage->setFixedSize(120,120); +// previewLyt->setAlignment(Qt::AlignCenter); +// label->setPixmap(FileUtils::getFileIcon(QUrl::fromLocalFile(key).toString()).pixmap(120,120)); +// return previewPage; +//} + DirSearchPlugin::DirSearchPlugin(QObject *parent) : QObject(parent) { SearchPluginIface::Actioninfo open { 0, tr("Open")}; @@ -95,6 +202,7 @@ DirSearchPlugin::DirSearchPlugin(QObject *parent) : QObject(parent) m_actionInfo << open << Openpath << CopyPath; m_pool.setMaxThreadCount(2); m_pool.setExpiryTimeout(1000); + initDetailPage(); } const QString DirSearchPlugin::name() @@ -150,16 +258,122 @@ void DirSearchPlugin::openAction(int actionkey, QString key, int type) } } -bool DirSearchPlugin::isPreviewEnable(QString key, int type) +QWidget *DirSearchPlugin::detailPage(const ResultInfo &ri) { - return false; + m_currentActionKey = ri.actionKey; + m_iconLabel->setPixmap(ri.icon.pixmap(120, 120)); + QFontMetrics fontMetrics = m_nameLabel->fontMetrics(); + QString showname = fontMetrics.elidedText(ri.name, Qt::ElideRight, 274); //当字体长度超过215时显示为省略号 + m_nameLabel->setText(QString("

%1

").arg(FileUtils::escapeHtml(showname))); + if(QString::compare(showname, ri.name)) { + m_nameLabel->setToolTip(ri.name); + } + m_pluginLabel->setText(tr("directory")); + + m_pathLabel2->setText(m_pathLabel2->fontMetrics().elidedText(m_currentActionKey, Qt::ElideRight, m_pathLabel2->width())); + m_pathLabel2->setToolTip(m_currentActionKey); + m_timeLabel2->setText(ri.description.at(1).value); + return m_detailPage; } -QWidget *DirSearchPlugin::previewPage(QString key, int type, QWidget *parent) +void DirSearchPlugin::initDetailPage() { - return nullptr; + m_detailPage = new QWidget(); + m_detailPage->setFixedWidth(360); + m_detailPage->setAttribute(Qt::WA_TranslucentBackground); + m_detailLyt = new QVBoxLayout(m_detailPage); + m_detailLyt->setContentsMargins(8, 0, 16, 0); + m_iconLabel = new QLabel(m_detailPage); + m_iconLabel->setAlignment(Qt::AlignCenter); + m_iconLabel->setFixedHeight(128); + + m_nameFrame = new QFrame(m_detailPage); + m_nameFrameLyt = new QHBoxLayout(m_nameFrame); + m_nameFrame->setLayout(m_nameFrameLyt); + m_nameFrameLyt->setContentsMargins(8, 0, 0, 0); + m_nameLabel = new QLabel(m_nameFrame); + m_nameLabel->setMaximumWidth(280); + m_pluginLabel = new QLabel(m_nameFrame); + m_pluginLabel->setEnabled(false); + m_nameFrameLyt->addWidget(m_nameLabel); + 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_pathFrame = new QFrame(m_detailPage); + m_pathFrameLyt = new QHBoxLayout(m_pathFrame); + m_pathLabel1 = new QLabel(m_pathFrame); + m_pathLabel2 = new QLabel(m_pathFrame); + m_pathLabel1->setText(tr("Path")); + m_pathLabel2->setFixedWidth(240); + m_pathLabel2->setAlignment(Qt::AlignRight); + m_pathFrameLyt->addWidget(m_pathLabel1); + m_pathFrameLyt->addStretch(); + m_pathFrameLyt->addWidget(m_pathLabel2); + + m_timeFrame = new QFrame(m_detailPage); + m_timeFrameLyt = new QHBoxLayout(m_timeFrame); + m_timeLabel1 = new QLabel(m_timeFrame); + m_timeLabel2 = new QLabel(m_timeFrame); + m_timeLabel2->setAlignment(Qt::AlignRight); + m_timeLabel1->setText(tr("Last time modified")); + m_timeFrameLyt->addWidget(m_timeLabel1); + 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_actionFrame = new QFrame(m_detailPage); + m_actionFrameLyt = new QVBoxLayout(m_actionFrame); + m_actionFrameLyt->setContentsMargins(8, 0, 0, 0); + m_actionLabel1 = new ActionLabel(tr("Open"), m_currentActionKey, m_actionFrame); + m_actionLabel2 = new ActionLabel(tr("Open path"), m_currentActionKey, m_actionFrame); + m_actionLabel3 = new ActionLabel(tr("Copy path"), m_currentActionKey, m_actionFrame); + + m_actionFrameLyt->addWidget(m_actionLabel1); + m_actionFrameLyt->addWidget(m_actionLabel2); + m_actionFrameLyt->addWidget(m_actionLabel3); + m_actionFrame->setLayout(m_actionFrameLyt); + + m_detailLyt->addSpacing(50); + m_detailLyt->addWidget(m_iconLabel); + m_detailLyt->addWidget(m_nameFrame); + m_detailLyt->addWidget(m_line_1); + m_detailLyt->addWidget(m_pathFrame); + m_detailLyt->addWidget(m_timeFrame); + m_detailLyt->addWidget(m_line_2); + m_detailLyt->addWidget(m_actionFrame); + m_detailPage->setLayout(m_detailLyt); + m_detailLyt->addStretch(); + + connect(m_actionLabel1, &ActionLabel::actionTriggered, [ & ](){ + FileUtils::openFile(m_currentActionKey); + }); + connect(m_actionLabel2, &ActionLabel::actionTriggered, [ & ](){ + FileUtils::openFile(m_currentActionKey, true); + }); + connect(m_actionLabel3, &ActionLabel::actionTriggered, [ & ](){ + FileUtils::copyPath(m_currentActionKey); + }); } +//bool DirSearchPlugin::isPreviewEnable(QString key, int type) +//{ +// return false; +//} + +//QWidget *DirSearchPlugin::previewPage(QString key, int type, QWidget *parent) +//{ +// return nullptr; +//} + FileContengSearchPlugin::FileContengSearchPlugin(QObject *parent) : QObject(parent) { SearchPluginIface::Actioninfo open { 0, tr("Open")}; @@ -168,6 +382,7 @@ FileContengSearchPlugin::FileContengSearchPlugin(QObject *parent) : QObject(pare m_actionInfo << open << Openpath << CopyPath; m_pool.setMaxThreadCount(2); m_pool.setExpiryTimeout(1000); + initDetailPage(); } const QString FileContengSearchPlugin::name() @@ -191,6 +406,7 @@ void Zeeker::FileContengSearchPlugin::KeywordSearch(QString keyword, DataQueuesetPixmap(ri.icon.pixmap(120, 120)); + + m_pluginLabel->setText(tr("File")); + QFontMetrics fontMetrics = m_nameLabel->fontMetrics(); + QString showname = fontMetrics.elidedText(ri.name, Qt::ElideRight, 215); //当字体长度超过215时显示为省略号 + m_nameLabel->setText(QString("

%1

").arg(FileUtils::escapeHtml(showname))); + if(QString::compare(showname, ri.name)) { + m_nameLabel->setToolTip(ri.name); + } + + m_snippetLabel->setText(getHtmlText(ri.description.at(0).value, m_keyWord)); + m_pathLabel2->setText(m_pathLabel2->fontMetrics().elidedText(m_currentActionKey, Qt::ElideRight, m_pathLabel2->width())); + m_pathLabel2->setToolTip(m_currentActionKey); + m_timeLabel2->setText(ri.description.at(2).value); + return m_detailPage; } -QWidget *FileContengSearchPlugin::previewPage(QString key, int type, QWidget *parent) +QString FileContengSearchPlugin::getHtmlText(const QString &text, const QString &keyword) { - return nullptr; + QString htmlString; + bool boldOpenned = false; + for(int i = 0; i < text.length(); i++) { + if((keyword.toUpper()).contains(QString(text.at(i)).toUpper())) { + if(! boldOpenned) { + boldOpenned = true; + htmlString.append(QString("")); + } + htmlString.append(FileUtils::escapeHtml(QString(text.at(i)))); + } else { + if(boldOpenned) { + boldOpenned = false; + htmlString.append(QString("")); + } + htmlString.append(FileUtils::escapeHtml(QString(text.at(i)))); + } + } + htmlString.replace("\n", "
");//替换换行符 + return htmlString; } + +void FileContengSearchPlugin::initDetailPage() +{ + m_detailPage = new QWidget(); + m_detailPage->setFixedWidth(360); + m_detailPage->setAttribute(Qt::WA_TranslucentBackground); + m_detailLyt = new QVBoxLayout(m_detailPage); + m_detailLyt->setContentsMargins(8, 0, 16, 0); + m_iconLabel = new QLabel(m_detailPage); + m_iconLabel->setAlignment(Qt::AlignCenter); + m_iconLabel->setFixedHeight(128); + + m_nameFrame = new QFrame(m_detailPage); + m_nameFrameLyt = new QHBoxLayout(m_nameFrame); + m_nameFrame->setLayout(m_nameFrameLyt); + m_nameFrameLyt->setContentsMargins(8, 0, 0, 0); + m_nameLabel = new QLabel(m_nameFrame); + m_nameLabel->setMaximumWidth(280); + m_pluginLabel = new QLabel(m_nameFrame); + m_pluginLabel->setEnabled(false); + m_nameFrameLyt->addWidget(m_nameLabel); + 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_snippetLabel = new QLabel(m_detailPage); + m_snippetLabel->setWordWrap(true); + m_snippetLabel->setContentsMargins(8, 0, 8, 0); + + m_pathFrame = new QFrame(m_detailPage); + m_pathFrameLyt = new QHBoxLayout(m_pathFrame); + m_pathLabel1 = new QLabel(m_pathFrame); + m_pathLabel2 = new QLabel(m_pathFrame); + m_pathLabel1->setText(tr("Path")); + m_pathLabel2->setFixedWidth(240); + m_pathLabel2->setAlignment(Qt::AlignRight); + m_pathFrameLyt->addWidget(m_pathLabel1); + m_pathFrameLyt->addStretch(); + m_pathFrameLyt->addWidget(m_pathLabel2); + + m_timeFrame = new QFrame(m_detailPage); + m_timeFrameLyt = new QHBoxLayout(m_timeFrame); + m_timeLabel1 = new QLabel(m_timeFrame); + m_timeLabel2 = new QLabel(m_timeFrame); + m_timeLabel2->setAlignment(Qt::AlignRight); + m_timeLabel1->setText(tr("Last time modified")); + m_timeFrameLyt->addWidget(m_timeLabel1); + 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_actionFrame = new QFrame(m_detailPage); + m_actionFrameLyt = new QVBoxLayout(m_actionFrame); + m_actionFrameLyt->setContentsMargins(8, 0, 0, 0); + m_actionLabel1 = new ActionLabel(tr("Open"), m_currentActionKey, m_actionFrame); + m_actionLabel2 = new ActionLabel(tr("Open path"), m_currentActionKey, m_actionFrame); + m_actionLabel3 = new ActionLabel(tr("Copy path"), m_currentActionKey, m_actionFrame); + + m_actionFrameLyt->addWidget(m_actionLabel1); + m_actionFrameLyt->addWidget(m_actionLabel2); + m_actionFrameLyt->addWidget(m_actionLabel3); + m_actionFrame->setLayout(m_actionFrameLyt); + + m_detailLyt->addSpacing(50); + m_detailLyt->addWidget(m_iconLabel); + m_detailLyt->addWidget(m_nameFrame); + m_detailLyt->addWidget(m_line_1); + m_detailLyt->addWidget(m_snippetLabel); + m_detailLyt->addWidget(m_pathFrame); + m_detailLyt->addWidget(m_timeFrame); + m_detailLyt->addWidget(m_line_2); + m_detailLyt->addWidget(m_actionFrame); + m_detailPage->setLayout(m_detailLyt); + m_detailLyt->addStretch(); + + connect(m_actionLabel1, &ActionLabel::actionTriggered, [ & ](){ + FileUtils::openFile(m_currentActionKey); + }); + connect(m_actionLabel2, &ActionLabel::actionTriggered, [ & ](){ + FileUtils::openFile(m_currentActionKey, true); + }); + connect(m_actionLabel3, &ActionLabel::actionTriggered, [ & ](){ + FileUtils::copyPath(m_currentActionKey); + }); +} + +//bool FileContengSearchPlugin::isPreviewEnable(QString key, int type) +//{ +// return false; +//} + +//QWidget *FileContengSearchPlugin::previewPage(QString key, int type, QWidget *parent) +//{ +// return nullptr; +//} diff --git a/libsearch/index/file-search-plugin.h b/libsearch/index/file-search-plugin.h index 7ebc137..82a7bc4 100644 --- a/libsearch/index/file-search-plugin.h +++ b/libsearch/index/file-search-plugin.h @@ -3,10 +3,17 @@ #include #include +#include +#include +#include +#include +#include +#include #include "libsearch_global.h" #include "search-plugin-iface.h" #include "common.h" +#include "action-label.h" namespace Zeeker { //internal plugin class LIBSEARCH_EXPORT FileSearchPlugin : public QObject, public SearchPluginIface @@ -25,10 +32,39 @@ public: void KeywordSearch(QString keyword,DataQueue *searchResult); QList getActioninfo(int type); void openAction(int actionkey, QString key, int type = 0); - bool isPreviewEnable(QString key, int type); - QWidget *previewPage(QString key, int type, QWidget *parent = nullptr); +// bool isPreviewEnable(QString key, int type); +// QWidget *previewPage(QString key, int type, QWidget *parent = nullptr); + QWidget *detailPage(const ResultInfo &ri); private: + void initDetailPage(); + QString m_currentActionKey; + QWidget *m_detailPage; + QVBoxLayout *m_detailLyt = nullptr; + QLabel *m_iconLabel = nullptr; + QFrame *m_nameFrame = nullptr; + QHBoxLayout *m_nameFrameLyt = nullptr; + QLabel *m_nameLabel = nullptr; + QLabel *m_pluginLabel = nullptr; + QFrame *m_line_1 = nullptr; + QFrame *m_pathFrame = nullptr; + QLabel *m_pathLabel1 = nullptr; + QLabel *m_pathLabel2 = nullptr; + QHBoxLayout *m_pathFrameLyt = nullptr; + QFrame *m_timeFrame = nullptr; + QLabel *m_timeLabel1 = nullptr; + QLabel *m_timeLabel2 = nullptr; + QHBoxLayout *m_timeFrameLyt = nullptr; + + QFrame *m_line_2 = nullptr; + QFrame *m_actionFrame = nullptr; + QVBoxLayout *m_actionFrameLyt = nullptr; + ActionLabel *m_actionLabel1 = nullptr; + ActionLabel *m_actionLabel2 = nullptr; + ActionLabel *m_actionLabel3 = nullptr; + + QVBoxLayout * m_actionLyt = nullptr; + bool m_enable = true; QList m_actionInfo; QThreadPool m_pool; @@ -50,9 +86,38 @@ public: void KeywordSearch(QString keyword,DataQueue *searchResult); QList getActioninfo(int type); void openAction(int actionkey, QString key, int type = 0); - bool isPreviewEnable(QString key, int type); - QWidget *previewPage(QString key, int type, QWidget *parent = nullptr); +// bool isPreviewEnable(QString key, int type); +// QWidget *previewPage(QString key, int type, QWidget *parent = nullptr); + QWidget *detailPage(const ResultInfo &ri); private: + void initDetailPage(); + QWidget *m_detailPage = nullptr; + QString m_currentActionKey; + QVBoxLayout *m_detailLyt = nullptr; + QLabel *m_iconLabel = nullptr; + QFrame *m_nameFrame = nullptr; + QHBoxLayout *m_nameFrameLyt = nullptr; + QLabel *m_nameLabel = nullptr; + QLabel *m_pluginLabel = nullptr; + QFrame *m_line_1 = nullptr; + QFrame *m_pathFrame = nullptr; + QLabel *m_pathLabel1 = nullptr; + QLabel *m_pathLabel2 = nullptr; + QHBoxLayout *m_pathFrameLyt = nullptr; + QFrame *m_timeFrame = nullptr; + QLabel *m_timeLabel1 = nullptr; + QLabel *m_timeLabel2 = nullptr; + QHBoxLayout *m_timeFrameLyt = nullptr; + + QFrame *m_line_2 = nullptr; + QFrame *m_actionFrame = nullptr; + QVBoxLayout *m_actionFrameLyt = nullptr; + ActionLabel *m_actionLabel1 = nullptr; + ActionLabel *m_actionLabel2 = nullptr; + ActionLabel *m_actionLabel3 = nullptr; + + QVBoxLayout * m_actionLyt = nullptr; + bool m_enable = true; QList m_actionInfo; QThreadPool m_pool; @@ -74,9 +139,40 @@ public: void KeywordSearch(QString keyword,DataQueue *searchResult); QList getActioninfo(int type); void openAction(int actionkey, QString key, int type = 0); - bool isPreviewEnable(QString key, int type); - QWidget *previewPage(QString key, int type, QWidget *parent = nullptr); +// bool isPreviewEnable(QString key, int type); +// QWidget *previewPage(QString key, int type, QWidget *parent = nullptr); + QWidget *detailPage(const ResultInfo &ri); + QString getHtmlText(const QString & text, const QString & keyword); private: + void initDetailPage(); + QWidget *m_detailPage = nullptr; + QString m_currentActionKey; + QVBoxLayout *m_detailLyt = nullptr; + QLabel *m_iconLabel = nullptr; + QFrame *m_nameFrame = nullptr; + QHBoxLayout *m_nameFrameLyt = nullptr; + QLabel *m_nameLabel = nullptr; + QLabel *m_pluginLabel = nullptr; + QFrame *m_line_1 = nullptr; + QLabel *m_snippetLabel = nullptr; + QFrame *m_pathFrame = nullptr; + QLabel *m_pathLabel1 = nullptr; + QLabel *m_pathLabel2 = nullptr; + QHBoxLayout *m_pathFrameLyt = nullptr; + QFrame *m_timeFrame = nullptr; + QLabel *m_timeLabel1 = nullptr; + QLabel *m_timeLabel2 = nullptr; + QHBoxLayout *m_timeFrameLyt = nullptr; + + QFrame *m_line_2 = nullptr; + QFrame *m_actionFrame = nullptr; + QVBoxLayout *m_actionFrameLyt = nullptr; + ActionLabel *m_actionLabel1 = nullptr; + ActionLabel *m_actionLabel2 = nullptr; + ActionLabel *m_actionLabel3 = nullptr; + + QVBoxLayout * m_actionLyt = nullptr; + QString m_keyWord; bool m_enable = true; QList m_actionInfo; QThreadPool m_pool; diff --git a/libsearch/index/search-manager.cpp b/libsearch/index/search-manager.cpp index 78f2bb3..cc44097 100644 --- a/libsearch/index/search-manager.cpp +++ b/libsearch/index/search-manager.cpp @@ -347,21 +347,35 @@ int FileContentSearch::getResult(Xapian::MSet &result, std::string &keyWord) { std::string wordTobeFound = QString::fromStdString(keyWord).section(" ", 0, 0).toStdString(); int size = wordTobeFound.length(); term.skip_to(wordTobeFound); - int count = 0; - for(auto pos = term.positionlist_begin(); pos != term.positionlist_end() && count < 6; ++pos) { - std::string s = data.substr((*pos < 60) ? 0 : (*pos - 60), size + 120); - QString snippet = QString::fromStdString(s); - if(snippet.size() > 6 + QString::fromStdString(keyWord).size()) { - snippet.replace(0, 3, "...").replace(snippet.size() - 3, 3, "..."); - } else { - snippet.append("...").prepend("..."); - } - ri.description.prepend(SearchPluginIface::DescriptionInfo{"",snippet}); -// snippets.append(snippet); - QString().swap(snippet); - std::string().swap(s); - ++count; +// int count = 0; +// for(auto pos = term.positionlist_begin(); pos != term.positionlist_end() && count < 6; ++pos) { +// std::string s = data.substr((*pos < 60) ? 0 : (*pos - 60), size + 120); +// QString snippet = QString::fromStdString(s); +// if(snippet.size() > 6 + QString::fromStdString(keyWord).size()) { +// snippet.replace(0, 3, "...").replace(snippet.size() - 3, 3, "..."); +// } else { +// snippet.append("...").prepend("..."); +// } +// ri.description.prepend(SearchPluginIface::DescriptionInfo{"",snippet}); +//// snippets.append(snippet); +// QString().swap(snippet); +// std::string().swap(s); +// ++count; +// } + //fix me: make a snippet without cut cjk char. + auto pos = term.positionlist_begin(); + QString snippet; + if(data.length() - *pos < 120) { + std::string s = data.substr((data.length() < 120) ? 0 : (data.length() - 120), 120); + snippet = QString::fromStdString(s); + } else { + std::string s = data.substr(*pos, 120); + snippet = QString::fromStdString(s); } + + ri.description.prepend(SearchPluginIface::DescriptionInfo{"",snippet}); + QString().swap(snippet); +// std::string().swap(s); std::string().swap(data); diff --git a/libsearch/plugininterface/action-label.cpp b/libsearch/plugininterface/action-label.cpp new file mode 100644 index 0000000..5cbbbff --- /dev/null +++ b/libsearch/plugininterface/action-label.cpp @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2021, KylinSoft Co., Ltd. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Authors: zhangpengfei + * + */ +#include "action-label.h" +#define ACTION_NORMAL_COLOR QColor(55, 144, 250, 255) +#define ACTION_HOVER_COLOR QColor(64, 169, 251, 255) +#define ACTION_PRESS_COLOR QColor(41, 108, 217, 255) +using namespace Zeeker; +ActionLabel::ActionLabel(const QString &action, const QString &key, QWidget *parent) : QLabel(parent) +{ + m_action = action; + m_key = key; + this->initUi(); + this->installEventFilter(this); +} + +void ActionLabel::initUi() +{ + this->setText(m_action); + QPalette pal = palette(); + pal.setColor(QPalette::WindowText, ACTION_NORMAL_COLOR); + pal.setColor(QPalette::Light, ACTION_HOVER_COLOR); + pal.setColor(QPalette::Dark, ACTION_PRESS_COLOR); + this->setPalette(pal); + this->setForegroundRole(QPalette::WindowText); + this->setCursor(QCursor(Qt::PointingHandCursor)); +} + +bool ActionLabel::eventFilter(QObject *watched, QEvent *event) +{ + if (watched == this) { + if(event->type() == QEvent::MouseButtonPress) { + this->setForegroundRole(QPalette::Dark); + return true; + } else if(event->type() == QEvent::MouseButtonRelease) { + Q_EMIT this->actionTriggered(m_action); + this->setForegroundRole(QPalette::Light); + return true; + } else if(event->type() == QEvent::Enter) { + this->setForegroundRole(QPalette::Light); + return true; + } else if(event->type() == QEvent::Leave) { + this->setForegroundRole(QPalette::WindowText); + return true; + } + } + return false; +} diff --git a/libsearch/plugininterface/action-label.h b/libsearch/plugininterface/action-label.h new file mode 100644 index 0000000..11ec07c --- /dev/null +++ b/libsearch/plugininterface/action-label.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2021, KylinSoft Co., Ltd. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Authors: zhangpengfei + * + */ +#ifndef ACTIONLABEL_H +#define ACTIONLABEL_H + +#include +#include +#include +namespace Zeeker { +class ActionLabel : public QLabel +{ + Q_OBJECT +public: + ActionLabel(const QString &action, const QString &key, QWidget *parent = nullptr); + ~ActionLabel() = default; + +Q_SIGNALS: + void actionTriggered(QString &action); + +protected: + bool eventFilter(QObject *, QEvent *); + +private: + void initUi(); + QString m_action; + QString m_key; + + +}; +} + +#endif // ACTIONLABEL_H diff --git a/libsearch/plugininterface/plugin-interface.pri b/libsearch/plugininterface/plugin-interface.pri index 6dd0f4b..ea4d345 100644 --- a/libsearch/plugininterface/plugin-interface.pri +++ b/libsearch/plugininterface/plugin-interface.pri @@ -1,9 +1,11 @@ INCLUDEPATH += $$PWD \ HEADERS += \ + $$PWD/action-label.h \ $$PWD/plugin-iface.h \ $$PWD/search-plugin-iface.h \ $$PWD/data-queue.h -SOURCES += +SOURCES += \ + $$PWD/action-label.cpp diff --git a/libsearch/plugininterface/search-plugin-iface.h b/libsearch/plugininterface/search-plugin-iface.h index 5714a8d..3363407 100644 --- a/libsearch/plugininterface/search-plugin-iface.h +++ b/libsearch/plugininterface/search-plugin-iface.h @@ -41,8 +41,9 @@ public: virtual void KeywordSearch(QString keyword,DataQueue *searchResult) = 0; virtual QList getActioninfo(int type) = 0; virtual void openAction(int actionkey, QString key, int type) = 0; - virtual bool isPreviewEnable(QString key, int type) = 0; - virtual QWidget *previewPage(QString key, int type, QWidget *parent = nullptr) = 0; +// virtual bool isPreviewEnable(QString key, int type) = 0; +// virtual QWidget *previewPage(QString key, int type, QWidget *parent = nullptr) = 0; + virtual QWidget *detailPage(const ResultInfo &ri) = 0; }; } diff --git a/libsearch/settingsearch/settings-search-plugin.cpp b/libsearch/settingsearch/settings-search-plugin.cpp index da168a5..88549b2 100644 --- a/libsearch/settingsearch/settings-search-plugin.cpp +++ b/libsearch/settingsearch/settings-search-plugin.cpp @@ -13,6 +13,7 @@ SettingsSearchPlugin::SettingsSearchPlugin(QObject *parent) : QObject(parent) m_pool.setMaxThreadCount(1); m_pool.setExpiryTimeout(1000); xmlElement(); + initDetailPage(); } const QString SettingsSearchPlugin::name() @@ -123,15 +124,28 @@ void SettingsSearchPlugin::openAction(int actionkey, QString key, int type) } } -bool SettingsSearchPlugin::isPreviewEnable(QString key, int type) +QWidget *SettingsSearchPlugin::detailPage(const ResultInfo &ri) { - return false; + m_currentActionKey = ri.actionKey; + m_iconLabel->setPixmap(ri.icon.pixmap(120, 120)); + QFontMetrics fontMetrics = m_nameLabel->fontMetrics(); + QString showname = fontMetrics.elidedText(ri.name, Qt::ElideRight, 274); //当字体长度超过215时显示为省略号 + m_nameLabel->setText(QString("

%1

").arg(FileUtils::escapeHtml(showname))); + if(QString::compare(showname, ri.name)) { + m_nameLabel->setToolTip(ri.name); + } + return m_detailPage; } -QWidget *SettingsSearchPlugin::previewPage(QString key, int type, QWidget *parent = nullptr) -{ - return nullptr; -} +//bool SettingsSearchPlugin::isPreviewEnable(QString key, int type) +//{ +// return false; +//} + +//QWidget *SettingsSearchPlugin::previewPage(QString key, int type, QWidget *parent = nullptr) +//{ +// return nullptr; +//} /** * @brief SettingsSearchPlugin::xmlElement @@ -201,3 +215,53 @@ void SettingsSearchPlugin::xmlElement() { } file.close(); } + +void SettingsSearchPlugin::initDetailPage() +{ + m_detailPage = new QWidget(); + m_detailPage->setFixedWidth(360); + m_detailPage->setAttribute(Qt::WA_TranslucentBackground); + m_detailLyt = new QVBoxLayout(m_detailPage); + m_detailLyt->setContentsMargins(8, 0, 16, 0); + m_iconLabel = new QLabel(m_detailPage); + m_iconLabel->setAlignment(Qt::AlignCenter); + m_iconLabel->setFixedHeight(128); + + m_nameFrame = new QFrame(m_detailPage); + m_nameFrameLyt = new QHBoxLayout(m_nameFrame); + m_nameFrame->setLayout(m_nameFrameLyt); + m_nameFrameLyt->setContentsMargins(8, 0, 0, 0); + m_nameLabel = new QLabel(m_nameFrame); + m_nameLabel->setMaximumWidth(280); + m_pluginLabel = new QLabel(m_nameFrame); + m_pluginLabel->setText(tr("Settings")); + m_pluginLabel->setEnabled(false); + m_nameFrameLyt->addWidget(m_nameLabel); + 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_actionFrame = new QFrame(m_detailPage); + m_actionFrameLyt = new QVBoxLayout(m_actionFrame); + m_actionFrameLyt->setContentsMargins(8, 0, 0, 0); + m_actionLabel1 = new ActionLabel(tr("Open"), m_currentActionKey, m_actionFrame); + + m_actionFrameLyt->addWidget(m_actionLabel1);; + m_actionFrame->setLayout(m_actionFrameLyt); + + m_detailLyt->addSpacing(50); + m_detailLyt->addWidget(m_iconLabel); + m_detailLyt->addWidget(m_nameFrame); + m_detailLyt->addWidget(m_line_1); + m_detailLyt->addWidget(m_actionFrame); + m_detailPage->setLayout(m_detailLyt); + m_detailLyt->addStretch(); + + connect(m_actionLabel1, &ActionLabel::actionTriggered, [ & ](){ + openAction(0, m_currentActionKey, 0); + }); +} diff --git a/libsearch/settingsearch/settings-search-plugin.h b/libsearch/settingsearch/settings-search-plugin.h index 948ae81..41cb6c5 100644 --- a/libsearch/settingsearch/settings-search-plugin.h +++ b/libsearch/settingsearch/settings-search-plugin.h @@ -3,6 +3,13 @@ #include #include +#include +#include +#include +#include +#include +#include +#include "action-label.h" #include "search-plugin-iface.h" namespace Zeeker { @@ -22,11 +29,28 @@ public: void KeywordSearch(QString keyword,DataQueue *searchResult); QList getActioninfo(int type); void openAction(int actionkey, QString key, int type); - bool isPreviewEnable(QString key, int type); - QWidget *previewPage(QString key, int type, QWidget *parent); +// bool isPreviewEnable(QString key, int type); +// QWidget *previewPage(QString key, int type, QWidget *parent); + QWidget *detailPage(const ResultInfo &ri); private: void xmlElement(); + void initDetailPage(); + QString m_currentActionKey; + QWidget *m_detailPage = nullptr; + QVBoxLayout *m_detailLyt = nullptr; + QLabel *m_iconLabel = nullptr; + QFrame *m_nameFrame = nullptr; + QHBoxLayout *m_nameFrameLyt = nullptr; + QLabel *m_nameLabel = nullptr; + QLabel *m_pluginLabel = nullptr; + QFrame *m_line_1 = nullptr; + QFrame *m_actionFrame = nullptr; + QVBoxLayout *m_actionFrameLyt = nullptr; + ActionLabel *m_actionLabel1 = nullptr; + + QVBoxLayout * m_actionLyt = nullptr; + QMap m_chineseSearchList; QMap m_englishSearchList; diff --git a/translations/libukui-search/libukui-search_zh_CN.ts b/translations/libukui-search/libukui-search_zh_CN.ts index e4e88fb..c018ca7 100644 --- a/translations/libukui-search/libukui-search_zh_CN.ts +++ b/translations/libukui-search/libukui-search_zh_CN.ts @@ -4,7 +4,7 @@ Zeeker::AppSearch - + Application Description: 应用描述: @@ -12,32 +12,41 @@ Zeeker::AppSearchPlugin - + + Open 打开 - + + Add Shortcut to Desktop 添加到桌面快捷方式 - + + Add Shortcut to Panel 添加到任务栏快捷方式 - + + Install 安装 - - - + + + Applications Search 应用搜索 + + + Application + 应用 + Application Description: 应用描述: @@ -46,74 +55,120 @@ Zeeker::DirSearchPlugin - + + Open 打开 - + + Open path 打开文件所在路径 - + Copy Path 复制文件路径 - - + + Dir Search 目录搜索 - + Dir search. 目录搜索。 + + + directory + 目录 + + + + Path + 路径 + + + + Last time modified + 上次修改时间 + + + + Copy path + 复制路径 + Zeeker::FileContengSearchPlugin - + + Open 打开 - + + Open path 打开文件所在路径 - + Copy Path 复制文件路径 - + File Content Search 文本内容搜索 - + File content search. 文本内容搜索。 - + File content search 文本内容搜索 + + + File + 文件 + + + + Path + 路径 + + + + Last time modified + 上次修改时间 + + + + Copy path + 复制路径 + Zeeker::FileSearchPlugin + Open 打开 + Open path 打开文件所在路径 @@ -123,16 +178,36 @@ 复制文件路径 - - + + File Search 文件搜索 - + File search. 文件搜索。 + + + File + 文件 + + + + Path + 路径 + + + + Last time modified + 上次修改时间 + + + + Copy path + 复制路径 + Zeeker::SearchManager @@ -151,19 +226,25 @@ Zeeker::SettingsSearchPlugin + Open 打开 - - + + Settings Search 设置 - + Settings search. 设置。 + + + Settings + 设置项 + diff --git a/ukui-search.pro b/ukui-search.pro index d2a9e6a..ea7a3e1 100644 --- a/ukui-search.pro +++ b/ukui-search.pro @@ -1,7 +1,7 @@ TEMPLATE = subdirs SUBDIRS += $$PWD/libchinese-segmentation \ $$PWD/libsearch \ - $$PWD/src \ +# $$PWD/src \ $$PWD/frontend \ $$PWD/ukuisearch-systemdbus # The following define makes your compiler emit warnings if you use @@ -16,7 +16,7 @@ DEFINES += QT_DEPRECATED_WARNINGS #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 libsearch.depends += libchinese-segmentation -src.depends = libsearch +#src.depends = libsearch frontend.depends = libsearch CONFIG += ordered \