mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
Untangle Profile from MainWindow: shortcuts
This, too, should be done with signals. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
000c9cc21c
commit
1013ba39c5
4 changed files with 11 additions and 10 deletions
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue