ukui-search/libsearch/searchinterface/searchtasks/app-search-task.h

80 lines
2.3 KiB
C
Raw Normal View History

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>
*/
#ifndef APPSEARCHTASK_H
#define APPSEARCHTASK_H
#include <QIcon>
#include <QThreadPool>
#include <QRunnable>
#include <QDBusInterface>
#include <QtDBus>
#include "search-task-plugin-iface.h"
#include "search-controller.h"
#include "result-item.h"
#include "application-info.h"
#include "search-result-property.h"
namespace UkuiSearch {
class AppSearchTask : public SearchTaskPluginIface
{
friend class AppSearchWorker;
Q_OBJECT
public:
explicit AppSearchTask(QObject *parent);
~AppSearchTask();
PluginType pluginType() {return PluginType::SearchTaskPlugin;}
const QString name();
const QString description();
const QIcon icon() {return QIcon::fromTheme("appsearch");}
void setEnable(bool enable) {}
bool isEnable() { return true;}
SearchProperty::SearchType getSearchType() {return SearchProperty::SearchType::Application;}
QString getCustomSearchType();
void startSearch(std::shared_ptr<SearchController> searchController);
void stop();
Q_INVOKABLE void sendFinishSignal(size_t searchId);
private:
ApplicationInfo m_appinfo;
std::shared_ptr<SearchController> m_searchController;
QThreadPool *m_pool = nullptr;
};
class AppSearchWorker : public QRunnable
{
public:
explicit AppSearchWorker(AppSearchTask *AppSarchTask);
protected:
void run();
private:
~AppSearchWorker();
void sendErrorMsg(const QString &msg);
private:
AppSearchTask *m_appSearchTask = nullptr;
QDBusInterface *m_interFace = nullptr;
size_t m_currentSearchId = 0;
};
}
#endif // APPSEARCHTASK_H