2023-04-11 10:19:35 +08:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Copyright (C) 2023, 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 <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* Authors: iaom <zhangpengfei@kylinos.cn>
|
|
|
|
*/
|
2021-06-17 14:08:55 +08:00
|
|
|
#ifndef APPSEARCHPLUGIN_H
|
|
|
|
#define APPSEARCHPLUGIN_H
|
|
|
|
|
|
|
|
#include <QObject>
|
2021-07-31 16:12:04 +08:00
|
|
|
#include <QWidget>
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include <QFrame>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QAction>
|
2022-06-13 13:38:47 +08:00
|
|
|
#include <QDBusInterface>
|
|
|
|
#include <QDBusReply>
|
|
|
|
#include <QtDBus>
|
2021-06-17 14:08:55 +08:00
|
|
|
#include "search-plugin-iface.h"
|
2021-07-31 16:12:04 +08:00
|
|
|
#include "action-label.h"
|
2021-12-09 13:57:19 +08:00
|
|
|
#include "separation-line.h"
|
2021-06-17 14:08:55 +08:00
|
|
|
#include "libsearch_global.h"
|
2022-06-13 13:38:47 +08:00
|
|
|
#include "ukui-search-task.h"
|
2023-09-01 17:30:21 +08:00
|
|
|
#include "icon-loader.h"
|
|
|
|
|
2021-12-14 14:43:35 +08:00
|
|
|
namespace UkuiSearch {
|
2022-06-23 10:13:58 +08:00
|
|
|
class LIBSEARCH_EXPORT AppSearchPlugin : public QThread, public SearchPluginIface
|
2021-06-17 14:08:55 +08:00
|
|
|
{
|
|
|
|
friend class AppSearch;
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
AppSearchPlugin(QObject *parent = nullptr);
|
2022-11-22 10:17:36 +08:00
|
|
|
~AppSearchPlugin();
|
2021-06-17 14:08:55 +08:00
|
|
|
PluginType pluginType() {return PluginType::SearchPlugin;}
|
|
|
|
const QString name();
|
|
|
|
const QString description();
|
2023-09-01 17:30:21 +08:00
|
|
|
const QIcon icon() {return IconLoader::loadIconQt("appsearch");}
|
2021-06-17 14:08:55 +08:00
|
|
|
void setEnable(bool enable) {m_enable = enable;}
|
|
|
|
bool isEnable() {return m_enable;}
|
|
|
|
QString getPluginName();
|
|
|
|
|
|
|
|
void KeywordSearch(QString keyword,DataQueue<ResultInfo> *searchResult);
|
2022-02-12 14:20:55 +08:00
|
|
|
void stopSearch();
|
2021-06-17 14:08:55 +08:00
|
|
|
QList<SearchPluginIface::Actioninfo> getActioninfo(int type);
|
|
|
|
void openAction(int actionkey, QString key, int type);
|
2021-07-31 16:12:04 +08:00
|
|
|
// bool isPreviewEnable(QString key, int type);
|
|
|
|
// QWidget *previewPage(QString key, int type, QWidget *parent);
|
|
|
|
QWidget *detailPage(const ResultInfo &ri);
|
2023-05-06 15:41:56 +08:00
|
|
|
void run();
|
2021-06-17 14:08:55 +08:00
|
|
|
private:
|
2021-07-31 16:12:04 +08:00
|
|
|
void initDetailPage();
|
2021-06-17 14:08:55 +08:00
|
|
|
bool launch(const QString &path);
|
|
|
|
bool addPanelShortcut(const QString &path);
|
|
|
|
bool addDesktopShortcut(const QString &path);
|
|
|
|
bool installAppAction(const QString &name);
|
|
|
|
bool m_enable = true;
|
|
|
|
QList<SearchPluginIface::Actioninfo> m_actionInfo_installed;
|
|
|
|
QList<SearchPluginIface::Actioninfo> m_actionInfo_not_installed;
|
2021-07-31 16:12:04 +08:00
|
|
|
|
2022-06-13 13:38:47 +08:00
|
|
|
UkuiSearchTask *m_appSearchTask = nullptr;
|
|
|
|
DataQueue<ResultItem>* m_appSearchResults = nullptr;
|
2022-06-23 10:13:58 +08:00
|
|
|
DataQueue<SearchPluginIface::ResultInfo> *m_searchResult = nullptr;
|
2022-06-13 13:38:47 +08:00
|
|
|
|
2021-07-31 16:12:04 +08:00
|
|
|
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;
|
2021-12-09 13:57:19 +08:00
|
|
|
SeparationLine *m_line_1 = nullptr;
|
2021-07-31 16:12:04 +08:00
|
|
|
QLabel *m_descLabel = nullptr;
|
2021-12-09 13:57:19 +08:00
|
|
|
SeparationLine *m_line_2 = nullptr;
|
2021-07-31 16:12:04 +08:00
|
|
|
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;
|
2021-06-17 14:08:55 +08:00
|
|
|
};
|
|
|
|
|
2022-06-23 10:13:58 +08:00
|
|
|
//class AppSearch : public QObject, public QRunnable {
|
|
|
|
// Q_OBJECT
|
|
|
|
//public:
|
|
|
|
// AppSearch(DataQueue<SearchPluginIface::ResultInfo> *searchResult, DataQueue<ResultItem>* appSearchResults, UkuiSearchTask *appSearchTask, QString keyword, size_t uniqueSymbol);
|
|
|
|
// ~AppSearch();
|
|
|
|
//protected:
|
|
|
|
// void run() override;
|
|
|
|
//private:
|
2022-06-13 13:38:47 +08:00
|
|
|
|
2022-06-23 10:13:58 +08:00
|
|
|
// bool isUniqueSymbolChanged();
|
2022-06-13 13:38:47 +08:00
|
|
|
|
2022-06-23 10:13:58 +08:00
|
|
|
// size_t m_uniqueSymbol;
|
|
|
|
// UkuiSearchTask *m_appSearchTask = nullptr;
|
|
|
|
// DataQueue<ResultItem>* m_appSearchResults = nullptr;
|
|
|
|
// DataQueue<SearchPluginIface::ResultInfo> *m_search_result = nullptr;
|
2022-06-13 13:38:47 +08:00
|
|
|
|
2022-06-23 10:13:58 +08:00
|
|
|
//};
|
2021-06-17 14:08:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // APPSEARCHPLUGIN_H
|