-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin_general.cpp
56 lines (49 loc) · 1.85 KB
/
plugin_general.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include "plugins.h"
#include <QTimer>
void GeneralPlugin::initDefaultConfiguration(AbstractConfig*abstractConfig) {
GeneralConfiguration*generalConfig= (GeneralConfiguration*)abstractConfig;
generalConfig->toggleLauncherHotkey="Ctrl+SPACE";
}
void setToggleLauncherHotkey(AppGlobals*appGlobals) {
QString toggleHotkeyKeySequence=appGlobals->configuration->generalConfiguration.toggleLauncherHotkey;
if(toggleHotkeyKeySequence!=NULL) {
appGlobals->hotkeyManager->registerHotkey("_toggleLauncherHotkey", QKeySequence(toggleHotkeyKeySequence));
}
}
void GeneralPlugin::init(AppGlobals*appGlobals) {
this->appGlobals=appGlobals;
this->appGlobals->inputDialog=new InputDialog(appGlobals);
appGlobals->hotkeyManager->registerAction("_toggleLauncherHotkey",[this]() {
toggleMainLauncherWindow();
});
setToggleLauncherHotkey(appGlobals);
}
void GeneralPlugin::refresh() {
appGlobals->trayManager->updateIcon();
setToggleLauncherHotkey(appGlobals);
}
QList<AbstractMatcher*>getDefaultMatchers(AppGlobals*appGlobals) {
QList<AbstractMatcher*>result;
for(int i=0;i<appGlobals->matchers.size();i++) {
AbstractMatcher*matcher=appGlobals->matchers[i];
if(matcher->getMatchingTags().contains("default")) {
result.append(matcher);
}
}
return result;
}
void GeneralPlugin::toggleMainLauncherWindow() {
InputDialog*dialog=appGlobals->inputDialog;
if(dialog->isDialogVisible()) {
dialog->hideDialog();
} else {
compoundMatcher.setMatchers(getDefaultMatchers(appGlobals));
dialog->select(&compoundMatcher,[](InputItem*item) {
InputItem _item=*item;
QTimer::singleShot(1, [_item]() {
QApplication::processEvents();
_item.ownerMatcher->execute((InputItem*)&_item);
});
});
}
}