parent
d94ea704cd
commit
16e7a0523a
|
@ -65,7 +65,7 @@ QVector<SKeyWord> ChineseSegmentation::callSegement(QString str) {
|
||||||
convert(keywordres, vecNeeds);
|
convert(keywordres, vecNeeds);
|
||||||
|
|
||||||
keywordres.clear();
|
keywordres.clear();
|
||||||
keywordres.shrink_to_fit();
|
// keywordres.shrink_to_fit();
|
||||||
|
|
||||||
|
|
||||||
return vecNeeds;
|
return vecNeeds;
|
||||||
|
|
|
@ -11,19 +11,24 @@ namespace Zeeker {
|
||||||
class SearchPluginIface : public PluginInterface
|
class SearchPluginIface : public PluginInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
struct DescriptionInfo
|
||||||
|
{
|
||||||
|
QString key;
|
||||||
|
QString value;
|
||||||
|
};
|
||||||
/**
|
/**
|
||||||
* @brief The resultInfo struct
|
* @brief The ResultInfo struct
|
||||||
*/
|
*/
|
||||||
struct resultInfo
|
struct ResultInfo
|
||||||
{
|
{
|
||||||
QIcon icon;
|
QIcon icon;
|
||||||
QString name;
|
QString name;
|
||||||
QString description;
|
QVector<DescriptionInfo> description;
|
||||||
QMap<QString,QString> actionMap;//action name and action key
|
QMap<QString,QString> actionMap;//action name and action key
|
||||||
};
|
};
|
||||||
virtual ~SearchPluginIface() {}
|
virtual ~SearchPluginIface() {}
|
||||||
virtual QString getPluginName() = 0;
|
virtual QString getPluginName() = 0;
|
||||||
virtual void KeywordSearch(QString keyword,QQueue<resultInfo> *searchResult) = 0;
|
virtual void KeywordSearch(QString keyword,QQueue<ResultInfo> *searchResult) = 0;
|
||||||
virtual void openAction(QString name, QString key) = 0;
|
virtual void openAction(QString name, QString key) = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -116,6 +116,10 @@ void CreateIndexAskDialog::initUi() {
|
||||||
m_contentLyt->addWidget(m_btnFrame);
|
m_contentLyt->addWidget(m_btnFrame);
|
||||||
|
|
||||||
m_mainLyt->addWidget(m_contentFrame);
|
m_mainLyt->addWidget(m_contentFrame);
|
||||||
|
#if (QT_VERSION < QT_VERSION_CHECK(5, 12, 0))
|
||||||
|
m_titleFrame->hide();
|
||||||
|
this->setFixedSize(380, 162);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
14
src/main.cpp
14
src/main.cpp
|
@ -29,7 +29,9 @@
|
||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
|
||||||
#include <ukui-log4qt.h>
|
#include <ukui-log4qt.h>
|
||||||
|
#endif
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include "qt-single-application.h"
|
#include "qt-single-application.h"
|
||||||
|
@ -145,8 +147,11 @@ void searchMethod(FileUtils::SearchMethod sm){
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
int main(int argc, char *argv[]) {
|
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");
|
// initUkuiLog4qt("ukui-search");
|
||||||
|
//#endif
|
||||||
|
|
||||||
// Determine whether the home directory has been created, and if not, keep waiting.
|
// Determine whether the home directory has been created, and if not, keep waiting.
|
||||||
char *p_home = NULL;
|
char *p_home = NULL;
|
||||||
|
@ -172,6 +177,11 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
// Output log to file
|
// Output log to file
|
||||||
qInstallMessageHandler(messageOutput);
|
qInstallMessageHandler(messageOutput);
|
||||||
|
//若使用v101日志模块,可以解放如下判断条件
|
||||||
|
//#if (QT_VERSION < QT_VERSION_CHECK(5, 12, 0))
|
||||||
|
// // Output log to file
|
||||||
|
// qInstallMessageHandler(messageOutput);
|
||||||
|
//#endif
|
||||||
|
|
||||||
// Register meta type
|
// Register meta type
|
||||||
qDebug() << "ukui-search main start";
|
qDebug() << "ukui-search main start";
|
||||||
|
@ -291,7 +301,9 @@ int main(int argc, char *argv[]) {
|
||||||
if(QString::compare(QString("-s"), QString(QLatin1String(argv[1]))) == 0) {
|
if(QString::compare(QString("-s"), QString(QLatin1String(argv[1]))) == 0) {
|
||||||
// w->moveToPanel();
|
// w->moveToPanel();
|
||||||
centerToScreen(w);
|
centerToScreen(w);
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
|
||||||
XAtomHelper::getInstance()->setWindowMotifHint(w->winId(), w->m_hints);
|
XAtomHelper::getInstance()->setWindowMotifHint(w->winId(), w->m_hints);
|
||||||
|
#endif
|
||||||
w->show();
|
w->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,9 +29,11 @@
|
||||||
#include <QPalette>
|
#include <QPalette>
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
#include <QStyleOption>
|
#include <QStyleOption>
|
||||||
#include <KWindowEffects>
|
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
|
||||||
|
#include <KWindowEffects>
|
||||||
#include "kwindowsystem.h"
|
#include "kwindowsystem.h"
|
||||||
|
#endif
|
||||||
#include "qt-single-application.h"
|
#include "qt-single-application.h"
|
||||||
|
|
||||||
//#include "inotify-manager.h"
|
//#include "inotify-manager.h"
|
||||||
|
@ -67,6 +69,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||||
initUi();
|
initUi();
|
||||||
initTimer();
|
initTimer();
|
||||||
|
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
|
||||||
// setProperty("useStyleWindowManager", false); //禁止拖动
|
// setProperty("useStyleWindowManager", false); //禁止拖动
|
||||||
m_hints.flags = MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS;
|
m_hints.flags = MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS;
|
||||||
m_hints.functions = MWM_FUNC_ALL;
|
m_hints.functions = MWM_FUNC_ALL;
|
||||||
|
@ -80,6 +83,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||||
path.addRect(rect);
|
path.addRect(rect);
|
||||||
setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon()));
|
setProperty("blurRegion", QRegion(path.toFillPolygon().toPolygon()));
|
||||||
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
|
KWindowEffects::enableBlurBehind(this->winId(), true, QRegion(path.toFillPolygon().toPolygon()));
|
||||||
|
#endif
|
||||||
|
|
||||||
connect(qApp, &QApplication::paletteChanged, this, [ = ](const QPalette & pal) {
|
connect(qApp, &QApplication::paletteChanged, this, [ = ](const QPalette & pal) {
|
||||||
this->setPalette(pal);
|
this->setPalette(pal);
|
||||||
|
@ -125,7 +129,9 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||||
clearSearchResult();
|
clearSearchResult();
|
||||||
// this->moveToPanel();
|
// this->moveToPanel();
|
||||||
centerToScreen(this);
|
centerToScreen(this);
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
|
||||||
XAtomHelper::getInstance()->setWindowMotifHint(winId(), m_hints);
|
XAtomHelper::getInstance()->setWindowMotifHint(winId(), m_hints);
|
||||||
|
#endif
|
||||||
this->show();
|
this->show();
|
||||||
this->m_searchLayout->focusIn(); //打开主界面时输入框夺焦,可直接输入
|
this->m_searchLayout->focusIn(); //打开主界面时输入框夺焦,可直接输入
|
||||||
this->raise();
|
this->raise();
|
||||||
|
@ -150,10 +156,12 @@ MainWindow::~MainWindow() {
|
||||||
delete m_searchLayout;
|
delete m_searchLayout;
|
||||||
m_searchLayout = NULL;
|
m_searchLayout = NULL;
|
||||||
}
|
}
|
||||||
// if(m_settingsWidget) {
|
#if (QT_VERSION < QT_VERSION_CHECK(5, 12, 0))
|
||||||
// delete m_settingsWidget;
|
if(m_settingsWidget) {
|
||||||
// m_settingsWidget = NULL;
|
delete m_settingsWidget;
|
||||||
// }
|
m_settingsWidget = NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if(m_askDialog) {
|
if(m_askDialog) {
|
||||||
delete m_askDialog;
|
delete m_askDialog;
|
||||||
m_askDialog = NULL;
|
m_askDialog = NULL;
|
||||||
|
@ -203,38 +211,42 @@ void MainWindow::initUi() {
|
||||||
m_menuBtn->setProperty("isWindowButton", 0x01);
|
m_menuBtn->setProperty("isWindowButton", 0x01);
|
||||||
m_menuBtn->setFlat(true);
|
m_menuBtn->setFlat(true);
|
||||||
connect(m_menuBtn, &QPushButton::clicked, this, [ = ]() {
|
connect(m_menuBtn, &QPushButton::clicked, this, [ = ]() {
|
||||||
// if(m_settingsWidget) { //当此窗口已存在时,仅需置顶
|
#if (QT_VERSION < QT_VERSION_CHECK(5, 12, 0))
|
||||||
// if(!m_settingsWidget->isVisible()) {
|
if(m_settingsWidget) { //当此窗口已存在时,仅需置顶
|
||||||
// centerToScreen(m_settingsWidget);
|
if(!m_settingsWidget->isVisible()) {
|
||||||
// }
|
centerToScreen(m_settingsWidget);
|
||||||
// m_settingsWidget->showWidget();
|
}
|
||||||
// return;
|
m_settingsWidget->showWidget();
|
||||||
// }
|
return;
|
||||||
// m_settingsWidget = new SettingsWidget();
|
}
|
||||||
// connect(this, &MainWindow::webEngineChanged, m_settingsWidget, [ = ]() {
|
m_settingsWidget = new SettingsWidget();
|
||||||
// m_settingsWidget->resetWebEngine();
|
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)) {
|
connect(m_settingsWidget, &SettingsWidget::webEngineChanged, this, [ = ](const QString & engine) {
|
||||||
// m_search_gsettings->set(WEB_ENGINE_KEY, engine);
|
if(m_search_gsettings && m_search_gsettings->keys().contains(WEB_ENGINE_KEY)) {
|
||||||
// } else {
|
m_search_gsettings->set(WEB_ENGINE_KEY, engine);
|
||||||
// GlobalSettings::getInstance()->setValue(WEB_ENGINE, engine);
|
} else {
|
||||||
// }
|
GlobalSettings::getInstance()->setValue(WEB_ENGINE, engine);
|
||||||
// });
|
}
|
||||||
// centerToScreen(m_settingsWidget);
|
});
|
||||||
// m_settingsWidget->show();
|
centerToScreen(m_settingsWidget);
|
||||||
// connect(m_settingsWidget, &SettingsWidget::settingWidgetClosed, this, [ = ]() {
|
m_settingsWidget->show();
|
||||||
// QTimer::singleShot(100, this, [ = ] {
|
connect(m_settingsWidget, &SettingsWidget::settingWidgetClosed, this, [ = ]() {
|
||||||
//// clearSearchResult(); //现暂定从设置页返回主页面不清空搜索结果
|
QTimer::singleShot(100, this, [ = ] {
|
||||||
// this->setWindowState(this->windowState() & ~Qt::WindowMinimized);
|
// clearSearchResult(); //现暂定从设置页返回主页面不清空搜索结果
|
||||||
// this->raise();
|
this->setWindowState(this->windowState() & ~Qt::WindowMinimized);
|
||||||
// this->showNormal();
|
this->raise();
|
||||||
// this->activateWindow();
|
this->showNormal();
|
||||||
// });
|
this->activateWindow();
|
||||||
// });
|
});
|
||||||
|
});
|
||||||
|
#endif
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
|
||||||
//打开控制面板的设置页
|
//打开控制面板的设置页
|
||||||
QProcess process;
|
QProcess process;
|
||||||
process.startDetached("ukui-control-center --search");
|
process.startDetached("ukui-control-center --search");
|
||||||
|
#endif
|
||||||
});
|
});
|
||||||
m_titleLyt->addWidget(m_iconLabel);
|
m_titleLyt->addWidget(m_iconLabel);
|
||||||
m_titleLyt->addWidget(m_titleLabel);
|
m_titleLyt->addWidget(m_titleLabel);
|
||||||
|
@ -290,11 +302,13 @@ void MainWindow::initUi() {
|
||||||
|
|
||||||
//创建索引询问弹窗
|
//创建索引询问弹窗
|
||||||
m_askDialog = new CreateIndexAskDialog(this);
|
m_askDialog = new CreateIndexAskDialog(this);
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
|
||||||
MotifWmHints ask_dialog_hints;
|
MotifWmHints ask_dialog_hints;
|
||||||
ask_dialog_hints.flags = MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS;
|
ask_dialog_hints.flags = MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS;
|
||||||
ask_dialog_hints.functions = MWM_FUNC_ALL;
|
ask_dialog_hints.functions = MWM_FUNC_ALL;
|
||||||
ask_dialog_hints.decorations = MWM_DECOR_BORDER;
|
ask_dialog_hints.decorations = MWM_DECOR_BORDER;
|
||||||
XAtomHelper::getInstance()->setWindowMotifHint(m_askDialog->winId(), ask_dialog_hints);
|
XAtomHelper::getInstance()->setWindowMotifHint(m_askDialog->winId(), ask_dialog_hints);
|
||||||
|
#endif
|
||||||
connect(m_askDialog, &CreateIndexAskDialog::closed, this, [ = ]() {
|
connect(m_askDialog, &CreateIndexAskDialog::closed, this, [ = ]() {
|
||||||
m_isAskDialogVisible = false;
|
m_isAskDialogVisible = false;
|
||||||
});
|
});
|
||||||
|
@ -327,7 +341,9 @@ void MainWindow::bootOptionsFilter(QString opt) {
|
||||||
clearSearchResult();
|
clearSearchResult();
|
||||||
// this->moveToPanel();
|
// this->moveToPanel();
|
||||||
centerToScreen(this);
|
centerToScreen(this);
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
|
||||||
XAtomHelper::getInstance()->setWindowMotifHint(winId(), m_hints);
|
XAtomHelper::getInstance()->setWindowMotifHint(winId(), m_hints);
|
||||||
|
#endif
|
||||||
this->show();
|
this->show();
|
||||||
this->m_searchLayout->focusIn();
|
this->m_searchLayout->focusIn();
|
||||||
this->raise();
|
this->raise();
|
||||||
|
|
|
@ -49,10 +49,14 @@
|
||||||
#include "content-widget.h"
|
#include "content-widget.h"
|
||||||
#include "input-box.h"
|
#include "input-box.h"
|
||||||
#include "index/index-generator.h"
|
#include "index/index-generator.h"
|
||||||
//#include "settings-widget.h"
|
|
||||||
#include "libsearch.h"
|
#include "libsearch.h"
|
||||||
#include "search-app-thread.h"
|
#include "search-app-thread.h"
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
|
||||||
#include "xatom-helper.h"
|
#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"
|
#include "create-index-ask-dialog.h"
|
||||||
|
|
||||||
#define UKUI_SEARCH_SCHEMAS "org.ukui.search.settings"
|
#define UKUI_SEARCH_SCHEMAS "org.ukui.search.settings"
|
||||||
|
@ -82,7 +86,9 @@ public:
|
||||||
void centerToScreen(QWidget* widget);
|
void centerToScreen(QWidget* widget);
|
||||||
void initGsettings();
|
void initGsettings();
|
||||||
|
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
|
||||||
MotifWmHints m_hints;
|
MotifWmHints m_hints;
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -95,7 +101,9 @@ private:
|
||||||
QLabel * m_iconLabel = nullptr; // Icon lable
|
QLabel * m_iconLabel = nullptr; // Icon lable
|
||||||
QLabel * m_titleLabel = nullptr; // Title lable
|
QLabel * m_titleLabel = nullptr; // Title lable
|
||||||
QPushButton * m_menuBtn = nullptr; // Menu button
|
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
|
ContentWidget * m_contentFrame = nullptr; // Content frame
|
||||||
SearchBarHLayout * m_searchLayout = nullptr; // Search bar layout
|
SearchBarHLayout * m_searchLayout = nullptr; // Search bar layout
|
||||||
SeachBarWidget * m_searchWidget = nullptr; // Search bar
|
SeachBarWidget * m_searchWidget = nullptr; // Search bar
|
||||||
|
|
|
@ -37,10 +37,12 @@ SettingsWidget::SettingsWidget(QWidget *parent) : QWidget(parent) {
|
||||||
// this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
|
// this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
|
||||||
// this->setAttribute(Qt::WA_TranslucentBackground);
|
// 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.flags = MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS;
|
||||||
m_hints.functions = MWM_FUNC_ALL;
|
m_hints.functions = MWM_FUNC_ALL;
|
||||||
m_hints.decorations = MWM_DECOR_BORDER;
|
m_hints.decorations = MWM_DECOR_BORDER;
|
||||||
XAtomHelper::getInstance()->setWindowMotifHint(winId(), m_hints);
|
XAtomHelper::getInstance()->setWindowMotifHint(winId(), m_hints);
|
||||||
|
#endif
|
||||||
|
|
||||||
initUi();
|
initUi();
|
||||||
refreshIndexState();
|
refreshIndexState();
|
||||||
|
@ -224,6 +226,11 @@ void SettingsWidget::initUi() {
|
||||||
// m_mainLyt->addWidget(m_bottomBtnFrame);
|
// m_mainLyt->addWidget(m_bottomBtnFrame);
|
||||||
|
|
||||||
m_contentLyt->addStretch();
|
m_contentLyt->addStretch();
|
||||||
|
|
||||||
|
#if (QT_VERSION < QT_VERSION_CHECK(5, 12, 0))
|
||||||
|
this->m_titleFrame->hide();
|
||||||
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -374,7 +381,9 @@ void SettingsWidget::showWidget() {
|
||||||
flags &= ~Qt::WindowStaysOnTopHint;
|
flags &= ~Qt::WindowStaysOnTopHint;
|
||||||
this->setWindowFlags(flags);
|
this->setWindowFlags(flags);
|
||||||
m_timer->start();
|
m_timer->start();
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
|
||||||
XAtomHelper::getInstance()->setWindowMotifHint(winId(), m_hints);
|
XAtomHelper::getInstance()->setWindowMotifHint(winId(), m_hints);
|
||||||
|
#endif
|
||||||
this->show();
|
this->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,9 @@
|
||||||
#include <QScrollArea>
|
#include <QScrollArea>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <libsearch.h>
|
#include <libsearch.h>
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
|
||||||
#include "xatom-helper.h"
|
#include "xatom-helper.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Zeeker {
|
namespace Zeeker {
|
||||||
class SettingsWidget : public QWidget {
|
class SettingsWidget : public QWidget {
|
||||||
|
@ -56,7 +58,9 @@ private:
|
||||||
void resize();
|
void resize();
|
||||||
void showWarningDialog(const int&);
|
void showWarningDialog(const int&);
|
||||||
|
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
|
||||||
MotifWmHints m_hints;
|
MotifWmHints m_hints;
|
||||||
|
#endif
|
||||||
|
|
||||||
//标题栏
|
//标题栏
|
||||||
QVBoxLayout * m_mainLyt = nullptr;
|
QVBoxLayout * m_mainLyt = nullptr;
|
||||||
|
|
Loading…
Reference in New Issue