From 763945bb95fb3f5871d8b8241c8d9db2f0f66d4c Mon Sep 17 00:00:00 2001 From: Piotr Esden-Tempski Date: Thu, 2 Mar 2017 23:31:04 -0800 Subject: [PATCH] Added Ctrl-Q and Ctrl-W shortcuts. Ctrl-Q is commonly used to close the application, and Ctrl-W usually is used to close the current tab. According to the Qt::Modifier documentation this setup should work seamlessly on Mac OS where Meta is usually used in place of Ctrl. This fixes bug #899. --- pv/mainwindow.cpp | 12 ++++++++++++ pv/mainwindow.hpp | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/pv/mainwindow.cpp b/pv/mainwindow.cpp index ddc2c8f0..662d68af 100644 --- a/pv/mainwindow.cpp +++ b/pv/mainwindow.cpp @@ -401,6 +401,11 @@ void MainWindow::setup_ui() session_selector_.setCornerWidget(static_tab_widget_, Qt::TopLeftCorner); session_selector_.setTabsClosable(true); + close_application_shortcut_ = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), this, SLOT(close())); + close_application_shortcut_->setAutoRepeat(false); + + close_current_tab_shortcut_ = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), this, SLOT(on_close_current_tab())); + connect(new_session_button_, SIGNAL(clicked(bool)), this, SLOT(on_new_session_clicked())); connect(run_stop_button_, SIGNAL(clicked(bool)), @@ -742,4 +747,11 @@ void MainWindow::on_actionAbout_triggered() dlg.exec(); } +void MainWindow::on_close_current_tab() +{ + int tab = session_selector_.currentIndex(); + + on_tab_close_requested(tab); +} + } // namespace pv diff --git a/pv/mainwindow.hpp b/pv/mainwindow.hpp index 9ba532bf..d2653d26 100644 --- a/pv/mainwindow.hpp +++ b/pv/mainwindow.hpp @@ -130,6 +130,8 @@ private Q_SLOTS: void on_actionAbout_triggered(); + void on_close_current_tab(); + private: DeviceManager &device_manager_; @@ -154,6 +156,8 @@ private: QIcon icon_grey_; QShortcut *run_stop_shortcut_; + QShortcut *close_application_shortcut_; + QShortcut *close_current_tab_shortcut_; }; } // namespace pv -- 2.30.2