]> sigrok.org Git - pulseview.git/commitdiff
Added Ctrl-Q and Ctrl-W shortcuts.
authorPiotr Esden-Tempski <redacted>
Fri, 3 Mar 2017 07:31:04 +0000 (23:31 -0800)
committerUwe Hermann <redacted>
Fri, 3 Mar 2017 20:46:10 +0000 (21:46 +0100)
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
pv/mainwindow.hpp

index ddc2c8f0435c798039ab369830a3368c148a23dc..662d68af2f29bdba5ceff5f68931855d18708026 100644 (file)
@@ -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
index 9ba532bf6cc8fc3e15a23efd826d36515ebd6383..d2653d26952c51f5078a18a17695deab5cfb01fe 100644 (file)
@@ -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