diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2017-11-30 17:56:16 +0100 |
---|---|---|
committer | Lubomir I. Ivanov <neolit123@gmail.com> | 2017-12-01 03:39:10 +0100 |
commit | f8a200dbcef6e86db159ae844e18fd438a87b7fb (patch) | |
tree | a57168a065ac11b648c6e82f7bc9c242a3014755 /desktop-widgets/mainwindow.cpp | |
parent | 4296ca11a6a663dd61ec917efd6f50016709b25a (diff) | |
download | subsurface-f8a200dbcef6e86db159ae844e18fd438a87b7fb.tar.gz |
Don't use action tooltip to access recently used file
Currently, the path to the recently used file is stored in the tooltip
of the corresponding recent file action. Instead, store the number
of the recent file in the action. This allows for more flexibility
concerning formating of the tooltips (think git repositories, etc.).
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/mainwindow.cpp')
-rw-r--r-- | desktop-widgets/mainwindow.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index 01b09e04c..9dddba434 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -203,6 +203,7 @@ MainWindow::MainWindow() : QMainWindow(), connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), TankInfoModel::instance(), SLOT(update())); for (int i = 0; i < NUM_RECENT_FILES; i++) { actionsRecent[i] = new QAction(this); + actionsRecent[i]->setData(i); ui.menuFile->insertAction(ui.actionQuit, actionsRecent[i]); connect(actionsRecent[i], SIGNAL(triggered(bool)), this, SLOT(recentFileTriggered(bool))); } @@ -1592,9 +1593,10 @@ void MainWindow::recentFileTriggered(bool checked) if (!okToClose(tr("Please save or cancel the current dive edit before opening a new file."))) return; - QAction *actionRecent = (QAction *)sender(); - - const QString &filename = actionRecent->toolTip(); + int filenr = ((QAction *)sender())->data().toInt(); + if (filenr >= recentFiles.count()) + return; + const QString &filename = recentFiles[filenr]; updateLastUsedDir(QFileInfo(filename).dir().path()); closeCurrentFile(); |