forked from openkylin/ukui-search
搜索插件接口增加一个反向调用接口,应用搜索增加截图打开时隐藏主页面动作。
This commit is contained in:
parent
4a413c6287
commit
ac81ac7af2
|
@ -38,6 +38,7 @@
|
|||
#include "ukuistylehelper/ukuistylehelper.h"
|
||||
#include "windowmanager/windowmanager.h"
|
||||
#include "global-settings.h"
|
||||
#include "action-transmiter.h"
|
||||
|
||||
#define MAIN_MARGINS 0, 0, 0, 0
|
||||
#define TITLE_MARGINS 0,0,0,0
|
||||
|
@ -95,6 +96,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
this->bootOptionsFilter("-s");
|
||||
this->setText(keyword);
|
||||
});
|
||||
connect(ActionTransmiter::getInstance(), &ActionTransmiter::hideUIAction, this, &MainWindow::tryHideMainwindow);
|
||||
//NEW_TODO, register plugins
|
||||
// SearchPluginManager::getInstance()->registerPlugin(\\);
|
||||
// m_stackedWidget->setPlugins(SearchPluginManager::getInstance()->getPluginIds());
|
||||
|
|
|
@ -265,6 +265,9 @@ void AppSearchPlugin::initDetailPage()
|
|||
|
||||
bool AppSearchPlugin::launch(const QString &path)
|
||||
{
|
||||
if(QFileInfo(path).fileName() == "kylin-screenshot.desktop") {
|
||||
invokeActions(InvokableAction::HideUI);
|
||||
}
|
||||
bool res(false);
|
||||
QDBusInterface * appLaunchInterface = new QDBusInterface("com.kylin.AppManager",
|
||||
"/com/kylin/AppManager",
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
#include "action-transmiter.h"
|
||||
#include <mutex>
|
||||
using namespace UkuiSearch;
|
||||
|
||||
static std::once_flag flag;
|
||||
static ActionTransmiter *global_intance = nullptr;
|
||||
ActionTransmiter::ActionTransmiter(QObject *parent) : QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
ActionTransmiter *ActionTransmiter::getInstance()
|
||||
{
|
||||
std::call_once(flag, [ & ] {
|
||||
global_intance = new ActionTransmiter();
|
||||
});
|
||||
return global_intance;
|
||||
}
|
||||
|
||||
void ActionTransmiter::invokeActions(SearchPluginIface::InvokableActions actions)
|
||||
{
|
||||
if(SearchPluginIface::InvokableAction::HideUI == actions) {
|
||||
Q_EMIT hideUIAction();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
#ifndef ACTIONTRANSMITER_H
|
||||
#define ACTIONTRANSMITER_H
|
||||
|
||||
#include <QObject>
|
||||
#include "search-plugin-iface.h"
|
||||
namespace UkuiSearch {
|
||||
/**
|
||||
* @brief The ActionTransmiter class
|
||||
* 转发搜索插件的action调用信号
|
||||
*/
|
||||
class ActionTransmiter : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static ActionTransmiter *getInstance();
|
||||
Q_INVOKABLE void invokeActions(SearchPluginIface::InvokableActions actions);
|
||||
|
||||
Q_SIGNALS:
|
||||
void hideUIAction();
|
||||
|
||||
private:
|
||||
ActionTransmiter(QObject *parent = nullptr);
|
||||
};
|
||||
|
||||
}
|
||||
#endif // ACTIONTRANSMITER_H
|
|
@ -1,6 +1,7 @@
|
|||
INCLUDEPATH += $$PWD
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/action-transmiter.h \
|
||||
$$PWD/action-label.h \
|
||||
$$PWD/common-defines.h \
|
||||
$$PWD/plugin-iface.h \
|
||||
|
@ -10,6 +11,8 @@ HEADERS += \
|
|||
$$PWD/separation-line.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/action-transmiter.cpp \
|
||||
$$PWD/action-label.cpp \
|
||||
$$PWD/separation-line.cpp
|
||||
$$PWD/separation-line.cpp \
|
||||
$$PWD/search-plugin-iface.cpp
|
||||
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
#include "action-transmiter.h"
|
||||
#include "search-plugin-iface.h"
|
||||
|
||||
using namespace UkuiSearch;
|
||||
|
||||
void SearchPluginIface::invokeActions(InvokableActions actions)
|
||||
{
|
||||
ActionTransmiter::getInstance()->invokeActions(actions);
|
||||
}
|
|
@ -15,6 +15,13 @@ namespace UkuiSearch {
|
|||
class SearchPluginIface : public PluginInterface
|
||||
{
|
||||
public:
|
||||
enum InvokableAction
|
||||
{
|
||||
None = 1u << 0,
|
||||
HideUI = 1u << 1
|
||||
};
|
||||
Q_DECLARE_FLAGS(InvokableActions, InvokableAction)
|
||||
|
||||
struct DescriptionInfo
|
||||
{
|
||||
QString key;
|
||||
|
@ -46,9 +53,10 @@ public:
|
|||
// 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;
|
||||
|
||||
void invokeActions(InvokableActions actions);
|
||||
};
|
||||
}
|
||||
|
||||
Q_DECLARE_INTERFACE(UkuiSearch::SearchPluginIface, SearchPluginIface_iid)
|
||||
|
||||
#endif // SEARCHPLUGINIFACE_H
|
||||
|
|
Loading…
Reference in New Issue