mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 05:49:53 +08:00
add global shortcut wakeup (#2097)
* add global shortcut wakeup * del useless * add ann * upgrade git mod * add short text * update * Simplify logic and add QKeySequence non-null judgment. * Simplify logic. * Simplify logic.
This commit is contained in:
parent
18080d174c
commit
cf0146050e
@ -1 +1 @@
|
||||
Subproject commit 7999052006382afbb8708bf73f877240ed8ad1e5
|
||||
Subproject commit 18ac011008d3ae55abc19233ba94fad1ea9801d8
|
@ -72,6 +72,7 @@ namespace vnotex
|
||||
Copy,
|
||||
Paste,
|
||||
Properties,
|
||||
Global_WakeUp,
|
||||
MaxShortcut
|
||||
};
|
||||
Q_ENUM(Shortcut)
|
||||
|
@ -63,7 +63,8 @@
|
||||
"UnitedEntry" : "Ctrl+G, G",
|
||||
"Copy" : "Ctrl+C",
|
||||
"Paste" : "Ctrl+V",
|
||||
"Properties" : "F2"
|
||||
"Properties" : "F2",
|
||||
"Global_WakeUp" : "Ctrl+Alt+U"
|
||||
},
|
||||
"file_type_suffixes" : [
|
||||
{
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include <QWindowStateChangeEvent>
|
||||
#include <QTimer>
|
||||
#include <QProgressDialog>
|
||||
#include <QHotkey>
|
||||
|
||||
#include "toolbox.h"
|
||||
#include "notebookexplorer.h"
|
||||
@ -595,6 +596,14 @@ void MainWindow::closeOnQuit()
|
||||
|
||||
void MainWindow::setupShortcuts()
|
||||
{
|
||||
const auto &coreConfig = ConfigMgr::getInst().getCoreConfig();
|
||||
|
||||
// For cross-platform global shortcuts, the external library QHotkey is used.
|
||||
QKeySequence wakeUp(coreConfig.getShortcut(CoreConfig::Global_WakeUp));
|
||||
if (!wakeUp.isEmpty()) {
|
||||
auto qHotkey = new QHotkey(wakeUp, true, this);
|
||||
connect(qHotkey , &QHotkey::activated, this, &MainWindow::showMainWindow);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::setStayOnTop(bool p_enabled)
|
||||
|
@ -5,6 +5,9 @@
|
||||
#include <QSystemTrayIcon>
|
||||
#include <QApplication>
|
||||
|
||||
#include <utils/widgetutils.h>
|
||||
#include <core/configmgr.h>
|
||||
#include <core/coreconfig.h>
|
||||
#include "mainwindow.h"
|
||||
#include "widgetsfactory.h"
|
||||
|
||||
@ -35,11 +38,19 @@ QSystemTrayIcon *SystemTrayHelper::setupSystemTray(MainWindow *p_win)
|
||||
auto menu = WidgetsFactory::createMenu(p_win);
|
||||
trayIcon->setContextMenu(menu);
|
||||
|
||||
menu->addAction(MainWindow::tr("Show Main Window"),
|
||||
menu,
|
||||
[p_win]() {
|
||||
p_win->showMainWindow();
|
||||
});
|
||||
const auto &coreConfig = ConfigMgr::getInst().getCoreConfig();
|
||||
|
||||
{
|
||||
auto act = menu->addAction(MainWindow::tr("Show Main Window"),
|
||||
menu,
|
||||
[p_win]() {
|
||||
p_win->showMainWindow();
|
||||
});
|
||||
|
||||
WidgetUtils::addActionShortcutText(act, coreConfig.getShortcut(CoreConfig::Global_WakeUp));
|
||||
}
|
||||
|
||||
menu->addSeparator();
|
||||
|
||||
menu->addAction(MainWindow::tr("Quit"),
|
||||
menu,
|
||||
|
Loading…
x
Reference in New Issue
Block a user