Mercurial > hg > sonic-visualiser
comparison main/MainWindow.cpp @ 1253:cc434d37a126 3.0-integration
Patch from Fab Nicol to fix a problem with Recent Files menu:
"Patch corrects a linux version bug already there in recent tags (at least 2.5, including in official Linux distros) and apparently remaining unnotices wrt open Recent Files submenu: an offending ampersand in paths (perhaps a Qt bug) makes the menu useless."
author | Chris Cannam |
---|---|
date | Mon, 15 Aug 2016 16:45:17 +0100 |
parents | 2ebb6b52388a |
children | 65b8c009a9f2 |
comparison
equal
deleted
inserted
replaced
1252:8b89cefa8409 | 1253:cc434d37a126 |
---|---|
1762 MainWindow::setupRecentFilesMenu() | 1762 MainWindow::setupRecentFilesMenu() |
1763 { | 1763 { |
1764 m_recentFilesMenu->clear(); | 1764 m_recentFilesMenu->clear(); |
1765 vector<QString> files = m_recentFiles.getRecent(); | 1765 vector<QString> files = m_recentFiles.getRecent(); |
1766 for (size_t i = 0; i < files.size(); ++i) { | 1766 for (size_t i = 0; i < files.size(); ++i) { |
1767 QAction *action = new QAction(files[i], this); | 1767 /* F. Nicol patch 13 Aug. 2016 */ |
1768 connect(action, SIGNAL(triggered()), this, SLOT(openRecentFile())); | 1768 const QString& path = files[i]; |
1769 QAction *action = new QAction(path, this); | |
1770 connect(action, &QAction::triggered, [this, path] { openRecentFile(path);}); | |
1771 /* end of patch */ | |
1769 if (i == 0) { | 1772 if (i == 0) { |
1770 action->setShortcut(tr("Ctrl+R")); | 1773 action->setShortcut(tr("Ctrl+R")); |
1771 m_keyReference->registerShortcut | 1774 m_keyReference->registerShortcut |
1772 (tr("Re-open"), | 1775 (tr("Re-open"), |
1773 action->shortcut().toString(), | 1776 action->shortcut().toString(), |
3071 tr("<b>Audio required</b><p>Unable to load layer data from \"%1\" without an audio file.<br>Please load at least one audio file before importing annotations.").arg(text)); | 3074 tr("<b>Audio required</b><p>Unable to load layer data from \"%1\" without an audio file.<br>Please load at least one audio file before importing annotations.").arg(text)); |
3072 } | 3075 } |
3073 } | 3076 } |
3074 | 3077 |
3075 void | 3078 void |
3076 MainWindow::openRecentFile() | 3079 MainWindow::openRecentFile(const QString& path) |
3077 { | 3080 { |
3081 /* F. Nicol patch 13 Aug. 2016 */ | |
3082 #if 0 | |
3078 QObject *obj = sender(); | 3083 QObject *obj = sender(); |
3079 QAction *action = dynamic_cast<QAction *>(obj); | 3084 QAction *action = dynamic_cast<QAction *>(obj); |
3080 | 3085 |
3081 if (!action) { | 3086 if (!action) { |
3082 cerr << "WARNING: MainWindow::openRecentFile: sender is not an action" | 3087 cerr << "WARNING: MainWindow::openRecentFile: sender is not an action" |
3083 << endl; | 3088 << endl; |
3084 return; | 3089 return; |
3085 } | 3090 } |
3086 | 3091 |
3087 QString path = action->text(); | 3092 QString path = action->text(); |
3093 #endif | |
3094 /* End of F. Nicol patch 13 Aug. 2016 */ | |
3095 | |
3088 if (path == "") return; | 3096 if (path == "") return; |
3089 | 3097 |
3090 FileOpenStatus status = openPath(path, ReplaceSession); | 3098 FileOpenStatus status = openPath(path, ReplaceSession); |
3091 | 3099 |
3092 if (status == FileOpenFailed) { | 3100 if (status == FileOpenFailed) { |