diff --git a/src/lib/app/browserwindow.cpp b/src/lib/app/browserwindow.cpp index ed3ce3d2d..267820202 100644 --- a/src/lib/app/browserwindow.cpp +++ b/src/lib/app/browserwindow.cpp @@ -98,6 +98,17 @@ const QString BrowserWindow::WEBKITVERSION = qWebKitVersion(); +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) @@ -413,6 +424,15 @@ void BrowserWindow::loadSettings() m_useSingleKeyShortcuts = settings.value("useSingleKeyShortcuts", false).toBool(); settings.endGroup(); + 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")))); + } else { + quitAction->setShortcut(QKeySequence()); + } + settings.endGroup(); + m_adblockIcon->setEnabled(settings.value("AdBlock/enabled", true).toBool()); statusBar()->setVisible(!isFullScreen() && showStatusBar); diff --git a/src/lib/app/mainmenu.cpp b/src/lib/app/mainmenu.cpp index 65eef1590..0bc9c50c0 100644 --- a/src/lib/app/mainmenu.cpp +++ b/src/lib/app/mainmenu.cpp @@ -39,16 +39,6 @@ #include #include -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); - } -} - MainMenu::MainMenu(BrowserWindow* window, QWidget* parent) : QMenu(parent) , m_window(window) @@ -516,7 +506,7 @@ void MainMenu::init() action = new QAction(QIcon::fromTheme(QSL("application-exit")), tr("Quit"), this); action->setMenuRole(QAction::QuitRole); - action->setShortcut(actionShortcut(QKeySequence::Quit, QKeySequence(QSL("Ctrl+Q")))); + // shortcut set from browserwindow connect(action, SIGNAL(triggered()), this, SLOT(quitApplication())); m_actions[QSL("Standard/Quit")] = action; diff --git a/src/lib/preferences/preferences.cpp b/src/lib/preferences/preferences.cpp index b5b2ae1b9..c431fb7ab 100644 --- a/src/lib/preferences/preferences.cpp +++ b/src/lib/preferences/preferences.cpp @@ -295,6 +295,7 @@ Preferences::Preferences(BrowserWindow* window, QWidget* parent) ui->defaultZoomLevel->addItem(QString("%1%").arg(level)); } ui->defaultZoomLevel->setCurrentIndex(settings.value("DefaultZoomLevel", WebView::zoomLevels().indexOf(100)).toInt()); + ui->closeAppWithCtrlQ->setChecked(settings.value("closeAppWithCtrlQ", true).toBool()); //Cache ui->pagesInCache->setValue(settings.value("maximumCachedPages", 3).toInt()); @@ -995,6 +996,7 @@ void Preferences::saveSettings() settings.setValue("DefaultZoomLevel", ui->defaultZoomLevel->currentIndex()); settings.setValue("XSSAuditing", ui->xssAuditing->isChecked()); settings.setValue("enableFormsUndoRedo", ui->formsUndoRedo->isChecked()); + settings.setValue("closeAppWithCtrlQ", ui->closeAppWithCtrlQ->isChecked()); #ifdef Q_OS_WIN settings.setValue("CheckDefaultBrowser", ui->checkDefaultBrowser->isChecked()); #endif diff --git a/src/lib/preferences/preferences.ui b/src/lib/preferences/preferences.ui index 8a5aa2b19..8ebdfdae9 100644 --- a/src/lib/preferences/preferences.ui +++ b/src/lib/preferences/preferences.ui @@ -1997,7 +1997,17 @@ - + + + + If unchecked, prevents accidental exit from the application if the Ctrl-W shortcut was intended. + + + Close application with Ctrl-Q + + + + Qt::Vertical