From 8ab1780501a984136cfdbf862ca359b4e66abdaf Mon Sep 17 00:00:00 2001 From: baydam Date: Wed, 15 Apr 2020 20:36:01 +0000 Subject: [PATCH] Improve loading speed of the keyboard shortcut --- src/gui/MainWindow.cpp | 9 ++++++--- src/gui/MainWindow.h | 2 ++ src/gui/ShortcutWindow.cpp | 5 ++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 7cf0adb..c2793f6 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -1598,6 +1598,9 @@ void MainWindow::createLayout() // Create console logging output consoleWindow = ConsoleWindow::console(); consoleWindow->setVisible(false); + // Create shortcut window + _shortcutWindow = new ShortcutWindow; + _shortcutWindow->setVisible(false); // Create layout. paintSplitter = new QSplitter(Qt::Vertical); @@ -2202,6 +2205,7 @@ void MainWindow::createActions() connect(feedbackAction, SIGNAL(triggered()), this, SLOT(sendFeedback())); // Keyboard shortcuts shortcutAction = new QAction(tr("&Keyboard shortcuts"), this); + shortcutAction->setShortcut(Qt::CTRL + Qt::Key_K); connect(shortcutAction, SIGNAL(triggered()), this, SLOT(openShortcutWindow())); // All available screen as action @@ -3745,9 +3749,8 @@ void MainWindow::exitFullScreen() void MainWindow::openShortcutWindow() { - ShortcutWindow *shortcutWindow = new ShortcutWindow; - setAttribute(Qt::WA_DeleteOnClose); - shortcutWindow->show(); + _shortcutWindow->reload(); // Important for speed + _shortcutWindow->setVisible(true); } void MainWindow::updateSettings() diff --git a/src/gui/MainWindow.h b/src/gui/MainWindow.h index fa4b278..a59f78f 100644 --- a/src/gui/MainWindow.h +++ b/src/gui/MainWindow.h @@ -560,6 +560,8 @@ private: PreferenceDialog* _preferenceDialog; // About dialog AboutDialog *_aboutDialog; + // Shortcut Windows + ShortcutWindow *_shortcutWindow; // UndoStack QUndoStack *undoStack; diff --git a/src/gui/ShortcutWindow.cpp b/src/gui/ShortcutWindow.cpp index 8769d54..f645906 100644 --- a/src/gui/ShortcutWindow.cpp +++ b/src/gui/ShortcutWindow.cpp @@ -64,13 +64,12 @@ ShortcutWindow::ShortcutWindow() // Create and customize font int sansSerif = QFontDatabase::addApplicationFont(":/base-font"); int serif = QFontDatabase::addApplicationFont(":/console-font"); - QFont sansSerifFont(QFont(QFontDatabase::applicationFontFamilies(sansSerif).at(0), 9, QFont::Normal)); - QFont serifFont(QFont(QFontDatabase::applicationFontFamilies(serif).at(0), 9, QFont::Normal)); + QFont sansSerifFont(QFont(QFontDatabase::applicationFontFamilies(sansSerif).at(0), 11, QFont::Normal)); + QFont serifFont(QFont(QFontDatabase::applicationFontFamilies(serif).at(0), 10, QFont::Normal)); // Apply font to the document settings()->setFontFamily(QWebEngineSettings::SansSerifFont, sansSerifFont.family()); settings()->setFontFamily(QWebEngineSettings::SerifFont, serifFont.family()); - } }