summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--desktop-widgets/mainwindow.h8
-rw-r--r--profile-widget/profilewidget2.cpp9
-rw-r--r--profile-widget/profilewidget2.h2
-rw-r--r--subsurface-desktop-main.cpp2
4 files changed, 11 insertions, 10 deletions
diff --git a/desktop-widgets/mainwindow.h b/desktop-widgets/mainwindow.h
index 05844fbd6..0d431b8b5 100644
--- a/desktop-widgets/mainwindow.h
+++ b/desktop-widgets/mainwindow.h
@@ -77,10 +77,6 @@ public:
LocationInformationWidget *locationInformationWidget();
void setTitle(enum MainWindowTitleFormat format = MWTF_FILENAME);
- // Some shortcuts like "change DC" or "copy/paste dive components"
- // should only be enabled when the profile's visible.
- void disableShortcuts(bool disablePaste = true);
- void enableShortcuts();
void loadFiles(const QStringList files);
void importFiles(const QStringList importFiles);
void importTxtFiles(const QStringList fileNames);
@@ -194,6 +190,10 @@ slots:
void planCreated();
void setEnabledToolbar(bool arg1);
void setPlanNotes();
+ // Some shortcuts like "change DC" or "copy/paste dive components"
+ // should only be enabled when the profile's visible.
+ void disableShortcuts(bool disablePaste = true);
+ void enableShortcuts();
private:
Ui::MainWindow ui;
diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp
index 178183d2e..046095465 100644
--- a/profile-widget/profilewidget2.cpp
+++ b/profile-widget/profilewidget2.cpp
@@ -976,8 +976,7 @@ void ProfileWidget2::setProfileState()
connect(DivePictureModel::instance(), SIGNAL(rowsRemoved(const QModelIndex &, int, int)), this, SLOT(plotPictures()));
/* show the same stuff that the profile shows. */
- //TODO: Move the DC handling to another method.
- MainWindow::instance()->enableShortcuts();
+ emit enableShortcuts();
currentState = PROFILE;
emit enableToolbar(true);
@@ -1124,8 +1123,7 @@ void ProfileWidget2::setAddState()
mouseFollowerHorizontal->setLine(timeAxis->line());
mouseFollowerVertical->setLine(QLineF(0, profileYAxis->pos().y(), 0, timeAxis->pos().y()));
disconnectTemporaryConnections();
- //TODO: Move this method to another place, shouldn't be on mainwindow.
- MainWindow::instance()->disableShortcuts(false);
+ emit disableShortcuts(false);
actionsForKeys[Qt::Key_Left]->setShortcut(Qt::Key_Left);
actionsForKeys[Qt::Key_Right]->setShortcut(Qt::Key_Right);
actionsForKeys[Qt::Key_Up]->setShortcut(Qt::Key_Up);
@@ -1158,8 +1156,7 @@ void ProfileWidget2::setPlanState()
mouseFollowerHorizontal->setLine(timeAxis->line());
mouseFollowerVertical->setLine(QLineF(0, profileYAxis->pos().y(), 0, timeAxis->pos().y()));
disconnectTemporaryConnections();
- //TODO: Move this method to another place, shouldn't be on mainwindow.
- MainWindow::instance()->disableShortcuts();
+ emit disableShortcuts(true);
actionsForKeys[Qt::Key_Left]->setShortcut(Qt::Key_Left);
actionsForKeys[Qt::Key_Right]->setShortcut(Qt::Key_Right);
actionsForKeys[Qt::Key_Up]->setShortcut(Qt::Key_Up);
diff --git a/profile-widget/profilewidget2.h b/profile-widget/profilewidget2.h
index 8ac34f625..c102bbcf3 100644
--- a/profile-widget/profilewidget2.h
+++ b/profile-widget/profilewidget2.h
@@ -90,6 +90,8 @@ signals:
void fontPrintScaleChanged(double scale);
void enableToolbar(bool enable);
void showError();
+ void enableShortcuts();
+ void disableShortcuts(bool paste);
public
slots: // Necessary to call from QAction's signals.
diff --git a/subsurface-desktop-main.cpp b/subsurface-desktop-main.cpp
index 23be242b6..bbe602848 100644
--- a/subsurface-desktop-main.cpp
+++ b/subsurface-desktop-main.cpp
@@ -88,6 +88,8 @@ int main(int argc, char **argv)
// now let's set up some connections
QObject::connect(m->graphics(), &ProfileWidget2::enableToolbar ,m, &MainWindow::setEnabledToolbar, Qt::AutoConnection);
QObject::connect(m->graphics(), &ProfileWidget2::showError, m, &MainWindow::showError, Qt::AutoConnection);
+ QObject::connect(m->graphics(), &ProfileWidget2::disableShortcuts, m, &MainWindow::disableShortcuts, Qt::AutoConnection);
+ QObject::connect(m->graphics(), &ProfileWidget2::enableShortcuts, m, &MainWindow::enableShortcuts, Qt::AutoConnection);
if (verbose > 0)
print_files();
if (!quit)