From: Piotr Esden-Tempski Date: Fri, 3 Mar 2017 07:31:04 +0000 (-0800) Subject: Added Ctrl-Q and Ctrl-W shortcuts. X-Git-Tag: pulseview-0.4.0~180 X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=commitdiff_plain;h=763945bb95fb3f5871d8b8241c8d9db2f0f66d4c;hp=45cb64fff7ebf16381bb567e33c22a9ff6f78cd8 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. --- 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