From 81ca828b95ca1e72b45c35d97fe5c9664f8cfbdd Mon Sep 17 00:00:00 2001 From: Dan Dennedy Date: Wed, 10 Jan 2024 15:46:50 -0800 Subject: [PATCH] fix Other Versions submenu on macOS --- src/mainwindow.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 3986731c08..3f5cc08f21 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -102,7 +102,6 @@ #include #include #include -#include #include #define SHOTCUT_THEME @@ -688,9 +687,13 @@ void MainWindow::setupAndConnectDocks() void MainWindow::setupMenuFile() { +#ifdef Q_OS_MAC + static auto sep = " "; +#else + static auto sep = "\t"; +#endif connect(ui->menuOtherVersions, &QMenu::aboutToShow, this, [&] { - for (auto a : ui->menuOtherVersions->actions()) - delete a; + ui->menuOtherVersions->clear(); QDir dir(QFileInfo(m_currentFile).absolutePath()); auto name = Util::baseName(m_currentFile, true); auto match = kBackupFileRegex.match(name); @@ -705,11 +708,11 @@ void MainWindow::setupMenuFile() if (filename != name) { auto text = filename; if (!kBackupFileRegex.match(filename).hasMatch()) - text += QString::fromLatin1("\t(%1)").arg(fileInfo.lastModified().toString(Qt::ISODate)); + text += QString::fromLatin1("%1(%2)").arg(sep, fileInfo.lastModified().toString(Qt::ISODate)); ui->menuOtherVersions->addAction(text)->setData(dir.filePath(filename)); } } - ui->menuOtherVersions->show(); + QCoreApplication::processEvents(); }); connect(ui->menuOtherVersions, &QMenu::triggered, this, [&](QAction * action) { open(action->data().toString());