diff --git a/src/gui_impl/commands/adapt_channel_view_gui_command.cpp b/src/gui_impl/commands/adapt_channel_view_gui_command.cpp index 58b90c9a..cc199e90 100644 --- a/src/gui_impl/commands/adapt_channel_view_gui_command.cpp +++ b/src/gui_impl/commands/adapt_channel_view_gui_command.cpp @@ -25,6 +25,7 @@ QString const AdaptChannelViewGuiCommand::SET_AUTO_SCALE_MAX_TO_MAX_ = "Zero Lin QString const AdaptChannelViewGuiCommand::SET_AUTO_SCALE_MIN_TO_MAX_ = "Zero Line Fitted"; QString const AdaptChannelViewGuiCommand::ANIMATIONS_ = "Animations"; QString const AdaptChannelViewGuiCommand::SET_ANIMATION_DURATION_ = "Set Animation Duration"; +QString const AdaptChannelViewGuiCommand::HOTKEYS_ = "Keyboard and Mouse Shortcuts"; QStringList const AdaptChannelViewGuiCommand::ACTIONS_ = QStringList() << AdaptChannelViewGuiCommand::CHANNELS_ << AdaptChannelViewGuiCommand::SCALE_ALL_ << @@ -34,7 +35,8 @@ QStringList const AdaptChannelViewGuiCommand::ACTIONS_ = QStringList() << AdaptChannelViewGuiCommand::SCALE_ << AdaptChannelViewGuiCommand::HIDE_ << AdaptChannelViewGuiCommand::ANIMATIONS_ << - AdaptChannelViewGuiCommand::SET_ANIMATION_DURATION_; + AdaptChannelViewGuiCommand::SET_ANIMATION_DURATION_ << + AdaptChannelViewGuiCommand::HOTKEYS_; //----------------------------------------------------------------------------- GuiActionFactoryRegistrator registrator_ ("Adapt Channel View", @@ -52,13 +54,17 @@ void AdaptChannelViewGuiCommand::init () { setIcon (CHANNELS_, QIcon(":/images/ic_reorder_black_24dp.png")); setIcon (SCALE_ALL_, QIcon(":/images/ic_autoscale_black_24dp.png")); + setIcon (HOTKEYS_, QIcon(":/images/ic_help_outline_black_24dp.png")); resetActionTriggerSlot (CHANNELS_, SLOT(selectShownChannels())); resetActionTriggerSlot (SCALE_ALL_, SLOT(scaleAll())); resetActionTriggerSlot (CHANGE_COLOR_, SLOT(changeColor())); resetActionTriggerSlot (SCALE_, SLOT(scale())); resetActionTriggerSlot (HIDE_, SLOT(hide())); + resetActionTriggerSlot (HOTKEYS_, SLOT(showHotkeyDialog())); + setShortcut (CHANNELS_, tr("Ctrl+C")); - //setShortcut (SCALE_ALL_, tr("Ctrl+A")); + setShortcut (SCALE_ALL_, tr("Ctrl+A")); + setShortcut (HOTKEYS_, tr("Ctrl+H")); QActionGroup* scale_mode_action_group = new QActionGroup (this); scale_mode_action_group->setExclusive(true); @@ -99,6 +105,7 @@ void AdaptChannelViewGuiCommand::evaluateEnabledness () QStringList disabled_actions_if_no_file = ACTIONS_; disabled_actions_if_no_file.removeAll(ANIMATIONS_); disabled_actions_if_no_file.removeAll(SET_ANIMATION_DURATION_); + disabled_actions_if_no_file.removeAll(HOTKEYS_); disableIfNoFileIsOpened (disabled_actions_if_no_file); disableIfNoSignalIsVisualised (disabled_actions_if_no_file); @@ -229,4 +236,11 @@ void AdaptChannelViewGuiCommand::setAnimationDuration () settings.endGroup (); } +//------------------------------------------------------------------------- +void AdaptChannelViewGuiCommand::showHotkeyDialog() +{ + hotkey_dialog_ = new HotkeyDialog(); + hotkey_dialog_->show(); +} + } diff --git a/src/gui_impl/commands/adapt_channel_view_gui_command.h b/src/gui_impl/commands/adapt_channel_view_gui_command.h index 5f87effd..e1e7ebc0 100644 --- a/src/gui_impl/commands/adapt_channel_view_gui_command.h +++ b/src/gui_impl/commands/adapt_channel_view_gui_command.h @@ -8,6 +8,7 @@ #include "gui/gui_action_command.h" #include "gui/gui_action_factory_registrator.h" +#include "gui_impl/dialogs/hotkey_dialog.h" namespace sigviewer { @@ -61,6 +62,9 @@ private slots: //------------------------------------------------------------------------- void setAnimationDuration (); + //------------------------------------------------------------------------- + void showHotkeyDialog (); + private: static QString const CHANNELS_; static QString const CHANGE_COLOR_; @@ -73,8 +77,11 @@ private slots: static QString const ANIMATIONS_; static QString const SET_ANIMATION_DURATION_; static QStringList const ACTIONS_; + static QString const HOTKEYS_; static GuiActionFactoryRegistrator registrator_; + + HotkeyDialog* hotkey_dialog_; }; } diff --git a/src/gui_impl/dialogs/dialogs.pri b/src/gui_impl/dialogs/dialogs.pri index 0b27ba5e..dbc6d9d2 100644 --- a/src/gui_impl/dialogs/dialogs.pri +++ b/src/gui_impl/dialogs/dialogs.pri @@ -4,7 +4,8 @@ HEADERS += \ $$PWD/event_time_selection_dialog.h \ $$PWD/event_types_selection_dialog.h \ $$PWD/scale_channel_dialog.h \ - $$PWD/resampling_dialog.h + $$PWD/resampling_dialog.h \ + $$PWD/hotkey_dialog.h SOURCES += \ $$PWD/basic_header_info_dialog.cpp \ @@ -12,7 +13,8 @@ SOURCES += \ $$PWD/event_time_selection_dialog.cpp \ $$PWD/event_types_selection_dialog.cpp \ $$PWD/scale_channel_dialog.cpp \ - $$PWD/resampling_dialog.cpp + $$PWD/resampling_dialog.cpp \ + $$PWD/hotkey_dialog.cpp FORMS += \ $$PWD/about_dialog.ui \ @@ -20,4 +22,5 @@ FORMS += \ $$PWD/event_time_selection_dialog.ui \ $$PWD/event_type_selection_dialog.ui \ $$PWD/scale_channel_dialog.ui \ - $$PWD/resampling_dialog.ui + $$PWD/resampling_dialog.ui \ + $$PWD/hotkey_dialog.ui diff --git a/src/gui_impl/dialogs/hotkey_dialog.cpp b/src/gui_impl/dialogs/hotkey_dialog.cpp new file mode 100644 index 00000000..9b6f8f07 --- /dev/null +++ b/src/gui_impl/dialogs/hotkey_dialog.cpp @@ -0,0 +1,111 @@ +// Copyright (c) 2016 The SigViewer Development Team +// Licensed under the GNU General Public License (GPL) +// https://www.gnu.org/licenses/gpl + + +#include "hotkey_dialog.h" +#include "ui_hotkey_dialog.h" + +#include + +HotkeyDialog::HotkeyDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::HotkeyDialog) +{ + ui->setupUi(this); + + QDesktopWidget dw; + int x=dw.width()*0.35; + int y=dw.height()*0.78; + resize(x,y); + + this->setWindowTitle(tr("Keyboard and Mouse Shortcuts")); + +#if defined(Q_OS_MACOS) + QString ctrl = "Cmd"; + QString alt = "Option"; + QString quit = "+Q" +#else + QString ctrl = "Ctrl"; + QString alt = "Alt"; + QString quit = "+F4"; +#endif + + QStringList actionDescriptions; + QStringList hotkeys; + + actionDescriptions << "Scale Individual Channel Up" + << "Scale Individual Channel Down" + << "Scale All Channels Up" + << "Scale All Channels Down" + << "Info Dialog" + << "Channel Dialog" + << "Event Dialog" + << "Open File" + << "Scale All" + << "Zoom In Horizontal" + << "Zoom Out Horizontal" + << "Zoom In Vertical" + << "Zoom Out Vertical" + << "New Event Mode" + << "Edit Event Mode" + << "Scroll Mode" + << "View Options Mode" + << "Undo" + << "Redo" + << "Close File" + << "Exit"; + + hotkeys << ctrl + "+Mousewheel Up" + << ctrl + "+Mousewheel Down" + << "Shift + Mousewheel Up" + << "Shift + Mousewheel Down" + << ctrl + "+I" + << ctrl + "+C" + << ctrl + "+E" + << ctrl + "+O" + << ctrl + "+A" + << alt + "++" + << alt + "+-" + << ctrl + "++" + << ctrl + "+-" + << ctrl + "+1" + << ctrl + "+2" + << ctrl + "+3" + << ctrl + "+4" + << ctrl + "+Z" + << ctrl + "+Y" + << ctrl + "+W" + << ctrl + quit; + + ui->tableWidget->setRowCount(actionDescriptions.size()); + ui->tableWidget->setColumnCount(2); + ui->tableWidget->horizontalHeader()->hide(); + ui->tableWidget->verticalHeader()->hide(); + ui->tableWidget->setShowGrid(false); + ui->tableWidget->setFocusPolicy(Qt::NoFocus); + ui->tableWidget->setColumnWidth(0, width() * 0.47); + ui->tableWidget->setColumnWidth(1, width() * 0.45); + ui->tableWidget->setSelectionMode(QAbstractItemView::NoSelection); + + for (int row = 0; row < ui->tableWidget->rowCount(); row++) + { + QTableWidgetItem *newItem = new QTableWidgetItem(tr("%1").arg(actionDescriptions[row])); + newItem->setFlags(newItem->flags()^Qt::ItemIsEditable); + ui->tableWidget->setItem(row, 0, newItem); + newItem = new QTableWidgetItem(tr("%1").arg(hotkeys[row])); + newItem->setTextAlignment( Qt::AlignRight | Qt::AlignVCenter ); + newItem->setFlags(newItem->flags()^Qt::ItemIsEditable); + ui->tableWidget->setItem(row, 1, newItem); + } +} + +HotkeyDialog::~HotkeyDialog() +{ + delete ui; +} + +void HotkeyDialog::on_pushButton_clicked() +{ + close(); +} diff --git a/src/gui_impl/dialogs/hotkey_dialog.h b/src/gui_impl/dialogs/hotkey_dialog.h new file mode 100644 index 00000000..e7d5b611 --- /dev/null +++ b/src/gui_impl/dialogs/hotkey_dialog.h @@ -0,0 +1,30 @@ +// Copyright (c) 2016 The SigViewer Development Team +// Licensed under the GNU General Public License (GPL) +// https://www.gnu.org/licenses/gpl + + +#ifndef HOTKEY_DIALOG_H +#define HOTKEY_DIALOG_H + +#include + +namespace Ui { +class HotkeyDialog; +} + +class HotkeyDialog : public QDialog +{ + Q_OBJECT + +public: + explicit HotkeyDialog(QWidget *parent = 0); + ~HotkeyDialog(); + +private slots: + void on_pushButton_clicked(); + +private: + Ui::HotkeyDialog *ui; +}; + +#endif // HOTKEY_DIALOG_H diff --git a/src/gui_impl/dialogs/hotkey_dialog.ui b/src/gui_impl/dialogs/hotkey_dialog.ui new file mode 100644 index 00000000..86f76af0 --- /dev/null +++ b/src/gui_impl/dialogs/hotkey_dialog.ui @@ -0,0 +1,57 @@ + + + HotkeyDialog + + + + 0 + 0 + 400 + 300 + + + + Dialog + + + + + + + + + Qt::Horizontal + + + + 133 + 20 + + + + + + + + OK + + + + + + + Qt::Horizontal + + + + 132 + 20 + + + + + + + + + diff --git a/src/gui_impl/main_window.cpp b/src/gui_impl/main_window.cpp index 62b5e816..a1422f89 100644 --- a/src/gui_impl/main_window.cpp +++ b/src/gui_impl/main_window.cpp @@ -105,6 +105,7 @@ void MainWindow::initToolBars() view_toolbar_->addAction(action("Zoom Out Vertical")); view_toolbar_->addAction(action("Zoom In Horizontal")); view_toolbar_->addAction(action("Zoom Out Horizontal")); + view_toolbar_->addAction(action("Keyboard and Mouse Shortcuts")); view_toolbar_views_menu_->addSeparator (); toggle_all_toolbars_ = new QAction (tr("Hide all Toolbars"), this); @@ -262,6 +263,7 @@ void MainWindow::initMenus (QSharedPointer application_conte help_menu_->addSeparator(); } help_menu_->addAction (action("About")); + help_menu_->addAction (action("Keyboard and Mouse Shortcuts")); } //-----------------------------------------------------------------------------