diff --git a/src/lib/app/browserwindow.cpp b/src/lib/app/browserwindow.cpp index 5fc91eb1d..6549fcf89 100644 --- a/src/lib/app/browserwindow.cpp +++ b/src/lib/app/browserwindow.cpp @@ -88,23 +88,6 @@ #include #endif -#ifdef Q_OS_WIN -#include -#ifndef WM_DWMCOMPOSITIONCHANGED -#define WM_DWMCOMPOSITIONCHANGED 0x031E -#endif -#endif /* Q_OS_WIN */ - -static QKeySequence actionShortcut(QKeySequence shortcut, QKeySequence fallBack, QKeySequence shortcutRTL = QKeySequence(), QKeySequence fallbackRTL = QKeySequence()) -{ - if (QApplication::isRightToLeft() && (!shortcutRTL.isEmpty() || !fallbackRTL.isEmpty())) { - return (shortcutRTL.isEmpty() ? fallbackRTL : shortcutRTL); - } - else { - return (shortcut.isEmpty() ? fallBack : shortcut); - } -} - BrowserWindow::BrowserWindow(Qz::BrowserWindowType type, const QUrl &startUrl) : QMainWindow(0) , m_startUrl(startUrl) @@ -463,7 +446,7 @@ void BrowserWindow::loadSettings() settings.beginGroup("Web-Browser-Settings"); QAction *quitAction = m_mainMenu->action(QSL("Standard/Quit")); if (settings.value("closeAppWithCtrlQ", true).toBool()) { - quitAction->setShortcut(actionShortcut(QKeySequence::Quit, QKeySequence(QSL("Ctrl+Q")))); + quitAction->setShortcut(QzTools::actionShortcut(QKeySequence::Quit, QKeySequence(QSL("Ctrl+Q")))); } else { quitAction->setShortcut(QKeySequence()); } diff --git a/src/lib/history/historymenu.cpp b/src/lib/history/historymenu.cpp index bc5de035f..2db671544 100644 --- a/src/lib/history/historymenu.cpp +++ b/src/lib/history/historymenu.cpp @@ -30,15 +30,6 @@ #include #include -static QKeySequence actionShortcut(QKeySequence shortcut, QKeySequence fallback, QKeySequence shortcutRTL, QKeySequence fallbackRTL) -{ - if (QApplication::isRightToLeft() && (!shortcutRTL.isEmpty() || !fallbackRTL.isEmpty())) { - return (shortcutRTL.isEmpty() ? fallbackRTL : shortcutRTL); - } - - return (shortcut.isEmpty() ? fallback : shortcut); -} - HistoryMenu::HistoryMenu(QWidget* parent) : Menu(parent) { @@ -216,10 +207,10 @@ void HistoryMenu::init() setTitle(tr("Hi&story")); QAction* act = addAction(IconProvider::standardIcon(QStyle::SP_ArrowBack), tr("&Back"), this, SLOT(goBack())); - act->setShortcut(actionShortcut(QKeySequence::Back, Qt::ALT + Qt::Key_Left, QKeySequence::Forward, Qt::ALT + Qt::Key_Right)); + act->setShortcut(QzTools::actionShortcut(QKeySequence::Back, Qt::ALT + Qt::Key_Left, QKeySequence::Forward, Qt::ALT + Qt::Key_Right)); act = addAction(IconProvider::standardIcon(QStyle::SP_ArrowForward), tr("&Forward"), this, SLOT(goForward())); - act->setShortcut(actionShortcut(QKeySequence::Forward, Qt::ALT + Qt::Key_Right, QKeySequence::Back, Qt::ALT + Qt::Key_Left)); + act->setShortcut(QzTools::actionShortcut(QKeySequence::Forward, Qt::ALT + Qt::Key_Right, QKeySequence::Back, Qt::ALT + Qt::Key_Left)); act = addAction(QIcon::fromTheme("go-home"), tr("&Home"), this, SLOT(goHome())); act->setShortcut(QKeySequence(Qt::ALT + Qt::Key_Home)); diff --git a/src/lib/tools/qztools.cpp b/src/lib/tools/qztools.cpp index 3fbfb8fce..7dc9c2c9d 100644 --- a/src/lib/tools/qztools.cpp +++ b/src/lib/tools/qztools.cpp @@ -695,6 +695,14 @@ bool QzTools::matchDomain(const QString &pattern, const QString &domain) return index > 0 && domain[index - 1] == QLatin1Char('.'); } +QKeySequence QzTools::actionShortcut(QKeySequence shortcut, QKeySequence fallBack, QKeySequence shortcutRtl, QKeySequence fallbackRtl) +{ + if (QApplication::isRightToLeft() && (!shortcutRtl.isEmpty() || !fallbackRtl.isEmpty())) + return shortcutRtl.isEmpty() ? fallbackRtl : shortcutRtl; + + return shortcut.isEmpty() ? fallBack : shortcut; +} + static inline bool isQuote(const QChar &c) { return (c == QLatin1Char('"') || c == QLatin1Char('\'')); diff --git a/src/lib/tools/qztools.h b/src/lib/tools/qztools.h index 199df5c36..57ed1d7a9 100644 --- a/src/lib/tools/qztools.h +++ b/src/lib/tools/qztools.h @@ -81,6 +81,7 @@ public: static QString getSaveFileName(const QString &name, QWidget* parent = 0, const QString &caption = QString(), const QString &dir = QString(), const QString &filter = QString(), QString* selectedFilter = 0, QFileDialog::Options options = 0); static bool matchDomain(const QString &pattern, const QString &domain); + static QKeySequence actionShortcut(QKeySequence shortcut, QKeySequence fallBack, QKeySequence shortcutRtl = QKeySequence(), QKeySequence fallbackRtl = QKeySequence()); static QString operatingSystem();