Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotkeydialog #99

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
18 changes: 16 additions & 2 deletions src/gui_impl/commands/adapt_channel_view_gui_command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_ <<
Expand 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",
Expand All @@ -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);
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -229,4 +236,11 @@ void AdaptChannelViewGuiCommand::setAnimationDuration ()
settings.endGroup ();
}

//-------------------------------------------------------------------------
void AdaptChannelViewGuiCommand::showHotkeyDialog()
{
hotkey_dialog_ = new HotkeyDialog();
hotkey_dialog_->show();
}

}
7 changes: 7 additions & 0 deletions src/gui_impl/commands/adapt_channel_view_gui_command.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -61,6 +62,9 @@ private slots:
//-------------------------------------------------------------------------
void setAnimationDuration ();

//-------------------------------------------------------------------------
void showHotkeyDialog ();

private:
static QString const CHANNELS_;
static QString const CHANGE_COLOR_;
Expand All @@ -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_;
};

}
Expand Down
9 changes: 6 additions & 3 deletions src/gui_impl/dialogs/dialogs.pri
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,23 @@ 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 \
$$PWD/channel_selection_dialog.cpp \
$$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 \
$$PWD/channel_dialog.ui \
$$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
111 changes: 111 additions & 0 deletions src/gui_impl/dialogs/hotkey_dialog.cpp
Original file line number Diff line number Diff line change
@@ -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 <QDesktopWidget>

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();
}
30 changes: 30 additions & 0 deletions src/gui_impl/dialogs/hotkey_dialog.h
Original file line number Diff line number Diff line change
@@ -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 <QDialog>

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
57 changes: 57 additions & 0 deletions src/gui_impl/dialogs/hotkey_dialog.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>HotkeyDialog</class>
<widget class="QDialog" name="HotkeyDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="3">
<widget class="QTableWidget" name="tableWidget"/>
</item>
<item row="1" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>133</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>OK</string>
</property>
</widget>
</item>
<item row="1" column="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>132</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
2 changes: 2 additions & 0 deletions src/gui_impl/main_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -262,6 +263,7 @@ void MainWindow::initMenus (QSharedPointer<ApplicationContext> application_conte
help_menu_->addSeparator();
}
help_menu_->addAction (action("About"));
help_menu_->addAction (action("Keyboard and Mouse Shortcuts"));
}

//-----------------------------------------------------------------------------
Expand Down