mirror of
https://github.com/subsurface/subsurface.git
synced 2024-12-11 03:21:29 +00:00
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>
This commit is contained in:
parent
4296ca11a6
commit
f8a200dbce
1 changed files with 5 additions and 3 deletions
|
@ -203,6 +203,7 @@ MainWindow::MainWindow() : QMainWindow(),
|
||||||
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), TankInfoModel::instance(), SLOT(update()));
|
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), TankInfoModel::instance(), SLOT(update()));
|
||||||
for (int i = 0; i < NUM_RECENT_FILES; i++) {
|
for (int i = 0; i < NUM_RECENT_FILES; i++) {
|
||||||
actionsRecent[i] = new QAction(this);
|
actionsRecent[i] = new QAction(this);
|
||||||
|
actionsRecent[i]->setData(i);
|
||||||
ui.menuFile->insertAction(ui.actionQuit, actionsRecent[i]);
|
ui.menuFile->insertAction(ui.actionQuit, actionsRecent[i]);
|
||||||
connect(actionsRecent[i], SIGNAL(triggered(bool)), this, SLOT(recentFileTriggered(bool)));
|
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.")))
|
if (!okToClose(tr("Please save or cancel the current dive edit before opening a new file.")))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QAction *actionRecent = (QAction *)sender();
|
int filenr = ((QAction *)sender())->data().toInt();
|
||||||
|
if (filenr >= recentFiles.count())
|
||||||
const QString &filename = actionRecent->toolTip();
|
return;
|
||||||
|
const QString &filename = recentFiles[filenr];
|
||||||
|
|
||||||
updateLastUsedDir(QFileInfo(filename).dir().path());
|
updateLastUsedDir(QFileInfo(filename).dir().path());
|
||||||
closeCurrentFile();
|
closeCurrentFile();
|
||||||
|
|
Loading…
Reference in a new issue