From 3c7b232361d01f79a1d48ae3d8200cb6a68bbf32 Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Sun, 2 Jun 2019 11:55:13 -0400 Subject: - always show statusbar, used by the menu and toolbar to display status tips - reduced margins around central widgets to align it with status bar text, removed bottom margins completely because the statusbar is enough - notifications: now always enabled, dialog shows a special item when empty, just change the tooltip and leave the text alone - added all toolbar actions to menu - non functional in menu for now: tools, help and endorse because they're menus - changed some of the action strings to be the same on both toolbar and menu, added missing status tips --- src/mainwindow.cpp | 46 ++++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 24 deletions(-) (limited to 'src/mainwindow.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 0ef9bc80..ff62e05e 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -242,7 +242,6 @@ MainWindow::MainWindow(QSettings &initSettings m_RefreshProgress->setVisible(false); statusBar()->addWidget(m_RefreshProgress, 1000); statusBar()->clearMessage(); - statusBar()->hide(); updateProblemsButton(); @@ -674,8 +673,6 @@ void MainWindow::updateProblemsButton() { size_t numProblems = checkForProblems(); if (numProblems > 0) { - ui->actionNotifications->setEnabled(true); - ui->actionNotifications->setIconText(tr("Notifications")); ui->actionNotifications->setToolTip(tr("There are notifications to read")); QPixmap mergedIcon = QPixmap(":/MO/gui/warning").scaled(64, 64); @@ -686,8 +683,6 @@ void MainWindow::updateProblemsButton() } ui->actionNotifications->setIcon(QIcon(mergedIcon)); } else { - ui->actionNotifications->setEnabled(false); - ui->actionNotifications->setIconText(tr("No Notifications")); ui->actionNotifications->setToolTip(tr("There are no notifications")); ui->actionNotifications->setIcon(QIcon(":/MO/gui/warning")); } @@ -975,6 +970,13 @@ void MainWindow::showEvent(QShowEvent *event) void MainWindow::closeEvent(QCloseEvent* event) +{ + if (!exit()) { + event->ignore(); + } +} + +bool MainWindow::exit() { m_closing = true; @@ -982,8 +984,7 @@ void MainWindow::closeEvent(QCloseEvent* event) if (QMessageBox::question(this, tr("Downloads in progress"), tr("There are still downloads in progress, do you really want to quit?"), QMessageBox::Yes | QMessageBox::Cancel) == QMessageBox::Cancel) { - event->ignore(); - return; + return false; } else { m_OrganizerCore.downloadManager()->pauseAll(); } @@ -996,12 +997,12 @@ void MainWindow::closeEvent(QCloseEvent* event) { m_OrganizerCore.waitForApplication(injected_process_still_running); if (!m_closing) { // if operation cancelled - event->ignore(); - return; + return false; } } setCursor(Qt::WaitCursor); + return true; } void MainWindow::cleanup() @@ -2292,11 +2293,9 @@ void MainWindow::refresher_progress(int percent) { if (percent == 100) { m_RefreshProgress->setVisible(false); - statusBar()->hide(); this->setEnabled(true); } else if (!m_RefreshProgress->isVisible()) { this->setEnabled(false); - statusBar()->show(); m_RefreshProgress->setVisible(true); m_RefreshProgress->setRange(0, 100); m_RefreshProgress->setValue(percent); @@ -2309,7 +2308,6 @@ void MainWindow::directory_refreshed() // now refreshDataTreeKeepExpandedNodes(); updateProblemsButton(); - statusBar()->hide(); } void MainWindow::esplist_changed() @@ -2930,7 +2928,6 @@ void MainWindow::untrack_clicked() void MainWindow::validationFailed(const QString &error) { qDebug("Nexus API validation failed: %s", qUtf8Printable(error)); - statusBar()->hide(); } void MainWindow::windowTutorialFinished(const QString &windowName) @@ -4115,7 +4112,6 @@ void MainWindow::checkModsForUpdates() QString apiKey; if (m_OrganizerCore.settings().getNexusApiKey(apiKey)) { m_OrganizerCore.doAfterLogin([this] () { this->checkModsForUpdates(); }); - statusBar()->show(); NexusInterface::instance(&m_PluginContainer)->getAccessManager()->apiCheck(apiKey); } else { qWarning("You are not currently authenticated with Nexus. Please do so under Settings -> Nexus."); @@ -5391,12 +5387,15 @@ void MainWindow::on_conflictsCheckBox_toggled(bool) refreshDataTreeKeepExpandedNodes(); } - void MainWindow::on_actionUpdate_triggered() { m_OrganizerCore.startMOUpdate(); } +void MainWindow::on_actionExit_triggered() +{ + exit(); +} void MainWindow::actionEndorseMO() { @@ -5974,16 +5973,15 @@ void MainWindow::on_actionNotifications_triggered() { updateProblemsButton(); ProblemsDialog problems(m_PluginContainer.plugins(), this); - if (problems.hasProblems()) { - QSettings &settings = m_OrganizerCore.settings().directInterface(); - QString key = QString("geometry/%1").arg(problems.objectName()); - if (settings.contains(key)) { - problems.restoreGeometry(settings.value(key).toByteArray()); - } - problems.exec(); - settings.setValue(key, problems.saveGeometry()); - updateProblemsButton(); + + QSettings &settings = m_OrganizerCore.settings().directInterface(); + QString key = QString("geometry/%1").arg(problems.objectName()); + if (settings.contains(key)) { + problems.restoreGeometry(settings.value(key).toByteArray()); } + problems.exec(); + settings.setValue(key, problems.saveGeometry()); + updateProblemsButton(); } void MainWindow::on_actionChange_Game_triggered() -- cgit v1.3.1 From 860eb49b45703d939196e92ba6e6d99f54ed3088 Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Sun, 2 Jun 2019 13:14:21 -0400 Subject: removed actionToToolButton(), which was replacing QAction's in the toolbar with QToolButton's, making it very difficult to have an equivalent in the main menu. QAction's can have a menu, so use that instead. the only place this doesn't work is with the nexus button, which can be replaced by a menu if there are IPluginModPage plugins adding items to it; registerModPage() works fine with the toolbar, but doesn't handle the main menu yet --- src/mainwindow.cpp | 117 ++++++++++++++++++++++------------------------------- src/mainwindow.h | 9 +++-- src/mainwindow.ui | 29 +++---------- 3 files changed, 59 insertions(+), 96 deletions(-) (limited to 'src/mainwindow.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index ff62e05e..462eb5e0 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -206,6 +206,7 @@ MainWindow::MainWindow(QSettings &initSettings , m_ContextItem(nullptr) , m_ContextAction(nullptr) , m_ContextRow(-1) + , m_browseModPage(nullptr) , m_CurrentSaveView(nullptr) , m_OrganizerCore(organizerCore) , m_PluginContainer(pluginContainer) @@ -248,17 +249,12 @@ MainWindow::MainWindow(QSettings &initSettings // Setup toolbar QWidget *spacer = new QWidget(ui->toolBar); spacer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred); - QWidget *widget = ui->toolBar->widgetForAction(ui->actionTool); - QToolButton *toolBtn = qobject_cast(widget); - if (toolBtn->menu() == nullptr) { - actionToToolButton(ui->actionTool); - } - - actionToToolButton(ui->actionHelp); - createHelpWidget(); + setupActionMenu(ui->actionTool); + setupActionMenu(ui->actionHelp); + setupActionMenu(ui->actionEndorseMO); - actionToToolButton(ui->actionEndorseMO); + createHelpMenu(); createEndorseWidget(); toggleMO2EndorseState(); @@ -611,28 +607,13 @@ static QModelIndex mapToModel(const QAbstractItemModel *targetModel, QModelIndex return result; } - -void MainWindow::actionToToolButton(QAction *&sourceAction) +void MainWindow::setupActionMenu(QAction* a) { - QToolButton *button = new QToolButton(ui->toolBar); - button->setObjectName(sourceAction->objectName()); - button->setIcon(sourceAction->icon()); - button->setText(sourceAction->text()); - button->setPopupMode(QToolButton::InstantPopup); - button->setToolButtonStyle(ui->toolBar->toolButtonStyle()); - button->setToolTip(sourceAction->toolTip()); - button->setShortcut(sourceAction->shortcut()); - QMenu *buttonMenu = new QMenu(sourceAction->text(), button); - button->setMenu(buttonMenu); - QAction *newAction = ui->toolBar->insertWidget(sourceAction, button); - newAction->setObjectName(sourceAction->objectName()); - newAction->setIcon(sourceAction->icon()); - newAction->setText(sourceAction->text()); - newAction->setToolTip(sourceAction->toolTip()); - newAction->setShortcut(sourceAction->shortcut()); - ui->toolBar->removeAction(sourceAction); - sourceAction->deleteLater(); - sourceAction = newAction; + a->setMenu(new QMenu(this)); + + auto* w = ui->toolBar->widgetForAction(a); + if (auto* tb=dynamic_cast(w)) + tb->setPopupMode(QToolButton::InstantPopup); } void MainWindow::updateToolBar() @@ -760,32 +741,34 @@ void MainWindow::createEndorseWidget() } -void MainWindow::createHelpWidget() +void MainWindow::createHelpMenu() { - QToolButton *toolBtn = qobject_cast(ui->toolBar->widgetForAction(ui->actionHelp)); - QMenu *buttonMenu = toolBtn->menu(); - if (buttonMenu == nullptr) { + auto* menu = ui->actionHelp->menu(); + if (!menu) { + // this happens on startup because languageChanged() (which calls this) is + // called before the menus are actually created return; } - buttonMenu->clear(); - QAction *helpAction = new QAction(tr("Help on UI"), buttonMenu); + menu->clear(); + + QAction *helpAction = new QAction(tr("Help on UI"), menu); connect(helpAction, SIGNAL(triggered()), this, SLOT(helpTriggered())); - buttonMenu->addAction(helpAction); + menu->addAction(helpAction); - QAction *wikiAction = new QAction(tr("Documentation"), buttonMenu); + QAction *wikiAction = new QAction(tr("Documentation"), menu); connect(wikiAction, SIGNAL(triggered()), this, SLOT(wikiTriggered())); - buttonMenu->addAction(wikiAction); + menu->addAction(wikiAction); - QAction *discordAction = new QAction(tr("Chat on Discord"), buttonMenu); + QAction *discordAction = new QAction(tr("Chat on Discord"), menu); connect(discordAction, SIGNAL(triggered()), this, SLOT(discordTriggered())); - buttonMenu->addAction(discordAction); + menu->addAction(discordAction); - QAction *issueAction = new QAction(tr("Report Issue"), buttonMenu); + QAction *issueAction = new QAction(tr("Report Issue"), menu); connect(issueAction, SIGNAL(triggered()), this, SLOT(issueTriggered())); - buttonMenu->addAction(issueAction); + menu->addAction(issueAction); - QMenu *tutorialMenu = new QMenu(tr("Tutorials"), buttonMenu); + QMenu *tutorialMenu = new QMenu(tr("Tutorials"), menu); typedef std::vector > ActionList; @@ -823,9 +806,9 @@ void MainWindow::createHelpWidget() tutorialMenu->addAction(iter->second); } - buttonMenu->addMenu(tutorialMenu); - buttonMenu->addAction(tr("About"), this, SLOT(about())); - buttonMenu->addAction(tr("About Qt"), qApp, SLOT(aboutQt())); + menu->addMenu(tutorialMenu); + menu->addAction(tr("About"), this, SLOT(about())); + menu->addAction(tr("About Qt"), qApp, SLOT(aboutQt())); } void MainWindow::modFilterActive(bool filterActive) @@ -1128,21 +1111,20 @@ void MainWindow::modPagePluginInvoke() void MainWindow::registerPluginTool(IPluginTool *tool, QString name, QMenu *menu) { + if (!menu) { + menu = ui->actionTool->menu(); + } + if (name.isEmpty()) name = tool->displayName(); - QAction *action = new QAction(tool->icon(), name, ui->toolBar); + QAction *action = new QAction(tool->icon(), name, menu); action->setToolTip(tool->tooltip()); tool->setParentWidget(this); action->setData(qVariantFromValue((QObject*)tool)); connect(action, SIGNAL(triggered()), this, SLOT(toolPluginInvoke()), Qt::QueuedConnection); - if (menu == nullptr) { - QToolButton *toolBtn = qobject_cast(ui->toolBar->widgetForAction(ui->actionTool)); - toolBtn->menu()->addAction(action); - } else { - menu->addAction(action); - } + menu->addAction(action); } void MainWindow::registerPluginTools(std::vector toolPlugins) @@ -1176,8 +1158,7 @@ void MainWindow::registerPluginTools(std::vector toolPlugins) for (auto info : submenuMap[submenuKey]) { registerPluginTool(info.second, info.first, submenu); } - QToolButton *toolBtn = qobject_cast(ui->toolBar->widgetForAction(ui->actionTool)); - toolBtn->menu()->addMenu(submenu); + ui->actionTool->menu()->addMenu(submenu); } else { registerPluginTool(submenuMap[submenuKey].front().second); @@ -1188,25 +1169,23 @@ void MainWindow::registerPluginTools(std::vector toolPlugins) void MainWindow::registerModPage(IPluginModPage *modPage) { // turn the browser action into a drop-down menu if necessary - if (ui->actionNexus->menu() == nullptr) { - QAction *nexusAction = ui->actionNexus; - // TODO: use a different icon for nexus! - ui->actionNexus = new QAction(nexusAction->icon(), tr("Browse Mod Page"), ui->toolBar); - ui->toolBar->insertAction(nexusAction, ui->actionNexus); - ui->toolBar->removeAction(nexusAction); - actionToToolButton(ui->actionNexus); + if (!m_browseModPage) { + m_browseModPage = new QAction(ui->actionNexus->icon(), tr("Browse Mod Page"), this); + setupActionMenu(m_browseModPage); - QToolButton *browserBtn = qobject_cast(ui->toolBar->widgetForAction(ui->actionNexus)); - browserBtn->menu()->addAction(nexusAction); + m_browseModPage->menu()->addAction(ui->actionNexus); + + ui->toolBar->insertAction(ui->actionNexus, m_browseModPage); + ui->toolBar->removeAction(ui->actionNexus); } - QAction *action = new QAction(modPage->icon(), modPage->displayName(), ui->toolBar); + QAction *action = new QAction(modPage->icon(), modPage->displayName(), this); modPage->setParentWidget(this); action->setData(qVariantFromValue(reinterpret_cast(modPage))); connect(action, SIGNAL(triggered()), this, SLOT(modPagePluginInvoke()), Qt::QueuedConnection); - QToolButton *toolBtn = qobject_cast(ui->toolBar->widgetForAction(ui->actionNexus)); - toolBtn->menu()->addAction(action); + + m_browseModPage->menu()->addAction(action); } @@ -5096,7 +5075,7 @@ void MainWindow::languageChange(const QString &newLanguage) ui->profileBox->setItemText(0, QObject::tr("")); - createHelpWidget(); + createHelpMenu(); updateDownloadView(); updateProblemsButton(); diff --git a/src/mainwindow.h b/src/mainwindow.h index 1f0dd5ff..7281aab7 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -206,7 +206,9 @@ private: void cleanup(); - void actionToToolButton(QAction *&sourceAction); + void setupActionMenu(QAction* a); + void createHelpMenu(); + void createEndorseWidget(); void updateToolBar(); void activateSelectedProfile(); @@ -255,9 +257,6 @@ private: // remove invalid category-references from mods void fixCategories(); - void createEndorseWidget(); - void createHelpWidget(); - bool extractProgress(QProgressDialog &extractProgress, int percentage, std::string fileName); size_t checkForProblems(); @@ -343,6 +342,8 @@ private: QTreeWidgetItem *m_ContextItem; QAction *m_ContextAction; + QAction* m_browseModPage; + CategoryFactory &m_CategoryFactory; bool m_LoginAttempted; diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 84d3c9e4..a3eb8504 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -1418,14 +1418,14 @@ p, li { white-space: pre-wrap; } - + &Help - + @@ -1621,7 +1621,10 @@ p, li { white-space: pre-wrap; } &Help - Help + Show help options + + + Show help options Ctrl+H @@ -1691,26 +1694,6 @@ p, li { white-space: pre-wrap; } Exits Mod Organizer - - - false - - - - :/MO/gui/plugins:/MO/gui/plugins - - - &Tools - - - - - false - - - &Help menu - - false -- cgit v1.3.1 From 746e9c08e68ed7e44e6ef4e29b250c73b9c21440 Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Sun, 2 Jun 2019 14:22:24 -0400 Subject: moved notification menu item to tools, was the only thing in view fixed endorse action to also work with the menu fixed changing endorsement integration setting not changing visibility of actions --- src/mainwindow.cpp | 32 +++++++++++++++++--------------- src/mainwindow.h | 2 +- src/mainwindow.ui | 20 ++++---------------- 3 files changed, 22 insertions(+), 32 deletions(-) (limited to 'src/mainwindow.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 462eb5e0..8e0d2624 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -255,7 +255,7 @@ MainWindow::MainWindow(QSettings &initSettings setupActionMenu(ui->actionEndorseMO); createHelpMenu(); - createEndorseWidget(); + createEndorseMenu(); toggleMO2EndorseState(); @@ -722,22 +722,23 @@ void MainWindow::about() } -void MainWindow::createEndorseWidget() +void MainWindow::createEndorseMenu() { - QToolButton *toolBtn = qobject_cast(ui->toolBar->widgetForAction(ui->actionEndorseMO)); - QMenu *buttonMenu = toolBtn->menu(); - if (buttonMenu == nullptr) { + auto* menu = ui->actionEndorseMO->menu(); + if (!menu) { + // shouldn't happen return; } - buttonMenu->clear(); - QAction *endorseAction = new QAction(tr("Endorse"), buttonMenu); + menu->clear(); + + QAction *endorseAction = new QAction(tr("Endorse"), menu); connect(endorseAction, SIGNAL(triggered()), this, SLOT(actionEndorseMO())); - buttonMenu->addAction(endorseAction); + menu->addAction(endorseAction); - QAction *wontEndorseAction = new QAction(tr("Won't Endorse"), buttonMenu); + QAction *wontEndorseAction = new QAction(tr("Won't Endorse"), menu); connect(wontEndorseAction, SIGNAL(triggered()), this, SLOT(actionWontEndorseMO())); - buttonMenu->addAction(wontEndorseAction); + menu->addAction(wontEndorseAction); } @@ -5021,6 +5022,8 @@ void MainWindow::on_actionSettings_triggered() m_OrganizerCore.updateVFSParams(settings.logLevel(), settings.crashDumpsType(), settings.executablesBlacklist()); m_OrganizerCore.cycleDiagnostics(); + + toggleMO2EndorseState(); } @@ -5473,20 +5476,19 @@ void MainWindow::modUpdateCheck(std::multimap IDs) void MainWindow::toggleMO2EndorseState() { - QToolButton *toolBtn = qobject_cast(ui->toolBar->widgetForAction(ui->actionEndorseMO)); if (Settings::instance().endorsementIntegration()) { ui->actionEndorseMO->setVisible(true); if (Settings::instance().directInterface().contains("endorse_state")) { - ui->actionEndorseMO->setEnabled(false); + ui->actionEndorseMO->menu()->setEnabled(false); if (Settings::instance().directInterface().value("endorse_state").toString() == "Endorsed") { ui->actionEndorseMO->setToolTip(tr("Thank you for endorsing MO2! :)")); - toolBtn->setToolTip(tr("Thank you for endorsing MO2! :)")); + ui->actionEndorseMO->setStatusTip(tr("Thank you for endorsing MO2! :)")); } else if (Settings::instance().directInterface().value("endorse_state").toString() == "Abstained") { ui->actionEndorseMO->setToolTip(tr("Please reconsider endorsing MO2 on Nexus!")); - toolBtn->setToolTip(tr("Please reconsider endorsing MO2 on Nexus!")); + ui->actionEndorseMO->setStatusTip(tr("Please reconsider endorsing MO2 on Nexus!")); } } else { - ui->actionEndorseMO->setEnabled(true); + ui->actionEndorseMO->menu()->setEnabled(true); } } else ui->actionEndorseMO->setVisible(false); diff --git a/src/mainwindow.h b/src/mainwindow.h index 7281aab7..96660aeb 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -208,7 +208,7 @@ private: void setupActionMenu(QAction* a); void createHelpMenu(); - void createEndorseWidget(); + void createEndorseMenu(); void updateToolBar(); void activateSelectedProfile(); diff --git a/src/mainwindow.ui b/src/mainwindow.ui index a3eb8504..03cb9ab7 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -1417,8 +1417,11 @@ p, li { white-space: pre-wrap; } &Tools + + + @@ -1427,13 +1430,7 @@ p, li { white-space: pre-wrap; } - - - - - &View - - + @@ -1443,7 +1440,6 @@ p, li { white-space: pre-wrap; } - @@ -1694,14 +1690,6 @@ p, li { white-space: pre-wrap; } Exits Mod Organizer - - - false - - - Endorse Mod Organizer - - -- cgit v1.3.1 From 41ef9813dd7b3b7587afe8dfe3a16f2711200edb Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Sun, 2 Jun 2019 15:22:11 -0400 Subject: moved links to a new dedicated toolbar --- src/mainwindow.cpp | 56 ++++++++++++++++++++++++++++++------------------------ src/mainwindow.h | 4 +--- src/mainwindow.ui | 43 +++++++++++++++++++++++------------------ 3 files changed, 57 insertions(+), 46 deletions(-) (limited to 'src/mainwindow.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 8e0d2624..09ecc3f9 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -247,8 +247,6 @@ MainWindow::MainWindow(QSettings &initSettings updateProblemsButton(); // Setup toolbar - QWidget *spacer = new QWidget(ui->toolBar); - spacer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred); setupActionMenu(ui->actionTool); setupActionMenu(ui->actionHelp); @@ -259,16 +257,6 @@ MainWindow::MainWindow(QSettings &initSettings toggleMO2EndorseState(); - for (QAction *action : ui->toolBar->actions()) { - if (action->isSeparator()) { - // insert spacers - ui->toolBar->insertWidget(action, spacer); - m_Sep = action; - // m_Sep would only use the last separator anyway, and we only have the one anyway? - break; - } - } - TaskProgressManager::instance().tryCreateTaskbar(); // set up mod list @@ -407,7 +395,7 @@ MainWindow::MainWindow(QSettings &initSettings connect(&TutorialManager::instance(), SIGNAL(windowTutorialFinished(QString)), this, SLOT(windowTutorialFinished(QString))); connect(ui->tabWidget, SIGNAL(currentChanged(int)), &TutorialManager::instance(), SIGNAL(tabChanged(int))); connect(ui->modList->header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(modListSortIndicatorChanged(int,Qt::SortOrder))); - connect(ui->toolBar, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(toolBar_customContextMenuRequested(QPoint))); + connect(ui->linksToolBar, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(linksToolBar_customContextMenuRequested(QPoint))); connect(&m_OrganizerCore, &OrganizerCore::modInstalled, this, &MainWindow::modInstalled); connect(&m_OrganizerCore, &OrganizerCore::close, this, &QMainWindow::close); @@ -618,29 +606,36 @@ void MainWindow::setupActionMenu(QAction* a) void MainWindow::updateToolBar() { - for (QAction *action : ui->toolBar->actions()) { - if (action->objectName().startsWith("custom__")) { - ui->toolBar->removeAction(action); - action->deleteLater(); - } + for (auto* a : ui->linksToolBar->actions()) { + ui->linksToolBar->removeAction(a); + a->deleteLater(); } + bool hasLinks = false; + std::vector::iterator begin, end; m_OrganizerCore.executablesList()->getExecutables(begin, end); + for (auto iter = begin; iter != end; ++iter) { if (iter->isShownOnToolbar()) { + hasLinks = true; + QAction *exeAction = new QAction(iconForExecutable(iter->m_BinaryInfo.filePath()), iter->m_Title, ui->toolBar); + exeAction->setObjectName(QString("custom__") + iter->m_Title); if (!connect(exeAction, SIGNAL(triggered()), this, SLOT(startExeAction()))) { qDebug("failed to connect trigger?"); } - ui->toolBar->insertAction(m_Sep, exeAction); + + ui->linksToolBar->addAction(exeAction); } } -} + // don't show the toolbar if there are no links + ui->linksToolBar->setVisible(hasLinks); +} void MainWindow::scheduleUpdateButton() { @@ -649,7 +644,6 @@ void MainWindow::scheduleUpdateButton() } } - void MainWindow::updateProblemsButton() { size_t numProblems = checkForProblems(); @@ -1834,6 +1828,10 @@ void MainWindow::readSettings() restoreGeometry(settings.value("window_geometry").toByteArray()); } + if (settings.contains("window_state")) { + restoreState(settings.value("window_state").toByteArray()); + } + if (settings.contains("window_split")) { ui->splitter->restoreState(settings.value("window_split").toByteArray()); } @@ -1910,6 +1908,7 @@ void MainWindow::storeSettings(QSettings &settings) { if (settings.value("reset_geometry", false).toBool()) { settings.remove("window_geometry"); + settings.remove("window_state"); settings.remove("window_split"); settings.remove("log_split"); settings.remove("filters_visible"); @@ -1918,6 +1917,7 @@ void MainWindow::storeSettings(QSettings &settings) { settings.remove("reset_geometry"); } else { settings.setValue("window_geometry", saveGeometry()); + settings.setValue("window_state", saveState()); settings.setValue("window_split", ui->splitter->saveState()); settings.setValue("log_split", ui->topLevelSplitter->saveState()); settings.setValue("browser_geometry", m_IntegratedBrowser.saveGeometry()); @@ -6062,17 +6062,23 @@ void MainWindow::removeFromToolbar() } -void MainWindow::toolBar_customContextMenuRequested(const QPoint &point) +void MainWindow::linksToolBar_customContextMenuRequested(const QPoint &point) { - QAction *action = ui->toolBar->actionAt(point); + QAction *action = ui->linksToolBar->actionAt(point); + if (action != nullptr) { if (action->objectName().startsWith("custom_")) { m_ContextAction = action; QMenu menu; - menu.addAction(tr("Remove"), this, SLOT(removeFromToolbar())); - menu.exec(ui->toolBar->mapToGlobal(point)); + menu.addAction(tr("Remove '%1' from the toolbar").arg(action->text()), this, SLOT(removeFromToolbar())); + menu.exec(ui->linksToolBar->mapToGlobal(point)); + return; } } + + // did not click a link button, show the default context menu + auto* m = createPopupMenu(); + m->exec(ui->linksToolBar->mapToGlobal(point)); } void MainWindow::on_espList_customContextMenuRequested(const QPoint &pos) diff --git a/src/mainwindow.h b/src/mainwindow.h index 96660aeb..8e50fa2e 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -316,8 +316,6 @@ private: Ui::MainWindow *ui; - QAction *m_Sep; // Executable Shortcuts are added after this. Non owning. - bool m_WasVisible; MOBase::TutorialControl m_Tutorial; @@ -594,7 +592,7 @@ private slots: */ void allowListResize(); - void toolBar_customContextMenuRequested(const QPoint &point); + void linksToolBar_customContextMenuRequested(const QPoint &point); void removeFromToolbar(); void overwriteClosed(int); diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 03cb9ab7..59d30a09 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -1349,17 +1349,8 @@ p, li { white-space: pre-wrap; } - - true - - - Qt::CustomContextMenu - - Tool Bar - - - false + Main ToolBar @@ -1367,12 +1358,6 @@ p, li { white-space: pre-wrap; } 36 - - Qt::ToolButtonIconOnly - - - false - TopToolBarArea @@ -1380,9 +1365,11 @@ p, li { white-space: pre-wrap; } false - - + + + + @@ -1443,6 +1430,26 @@ p, li { white-space: pre-wrap; } + + + Qt::CustomContextMenu + + + Links ToolBar + + + + 42 + 36 + + + + TopToolBarArea + + + false + + -- cgit v1.3.1 From fab357ef4d1b65e2737fa2db93a42ede38653a59 Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Sun, 2 Jun 2019 15:57:52 -0400 Subject: toolbar size and button style are now configurable and remembered --- src/mainwindow.cpp | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/mainwindow.h | 3 +++ 2 files changed, 74 insertions(+) (limited to 'src/mainwindow.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 09ecc3f9..642b0c99 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -189,6 +189,9 @@ along with Mod Organizer. If not, see . using namespace MOBase; using namespace MOShared; +const QSize SmallToolbarSize(24, 24); +const QSize LargeToolbarSize(42, 36); + MainWindow::MainWindow(QSettings &initSettings , OrganizerCore &organizerCore @@ -637,6 +640,61 @@ void MainWindow::updateToolBar() ui->linksToolBar->setVisible(hasLinks); } +QMenu* MainWindow::createPopupMenu() +{ + auto* m = QMainWindow::createPopupMenu(); + + m->addSeparator(); + + auto* a = new QAction(tr("Small Icons"), m); + connect(a, &QAction::triggered, [&]{ setToolbarSize(SmallToolbarSize); }); + a->setCheckable(true); + a->setChecked(ui->toolBar->iconSize() == SmallToolbarSize); + m->addAction(a); + + a = new QAction(tr("Large Icons"), m); + connect(a, &QAction::triggered, [&]{ setToolbarSize(LargeToolbarSize); }); + a->setCheckable(true); + a->setChecked(ui->toolBar->iconSize() == LargeToolbarSize); + m->addAction(a); + + m->addSeparator(); + + a = new QAction(tr("Icons only"), m); + connect(a, &QAction::triggered, [&]{ setToolbarButtonStyle(Qt::ToolButtonIconOnly); }); + a->setCheckable(true); + a->setChecked(ui->toolBar->toolButtonStyle() == Qt::ToolButtonIconOnly); + m->addAction(a); + + a = new QAction(tr("Text only"), m); + connect(a, &QAction::triggered, [&]{ setToolbarButtonStyle(Qt::ToolButtonTextOnly); }); + a->setCheckable(true); + a->setChecked(ui->toolBar->toolButtonStyle() == Qt::ToolButtonTextOnly); + m->addAction(a); + + a = new QAction(tr("Text and Icons"), m); + connect(a, &QAction::triggered, [&]{ setToolbarButtonStyle(Qt::ToolButtonTextUnderIcon); }); + a->setCheckable(true); + a->setChecked(ui->toolBar->toolButtonStyle() == Qt::ToolButtonTextUnderIcon); + m->addAction(a); + + return m; +} + +void MainWindow::setToolbarSize(const QSize& s) +{ + for (auto* tb : findChildren()) { + tb->setIconSize(s); + } +} + +void MainWindow::setToolbarButtonStyle(Qt::ToolButtonStyle s) +{ + for (auto* tb : findChildren()) { + tb->setToolButtonStyle(s); + } +} + void MainWindow::scheduleUpdateButton() { if (!m_UpdateProblemsTimer.isActive()) { @@ -1832,6 +1890,15 @@ void MainWindow::readSettings() restoreState(settings.value("window_state").toByteArray()); } + if (settings.contains("toolbar_size")) { + setToolbarSize(settings.value("toolbar_size").toSize()); + } + + if (settings.contains("toolbar_button_style")) { + setToolbarButtonStyle(static_cast( + settings.value("toolbar_button_style").toInt())); + } + if (settings.contains("window_split")) { ui->splitter->restoreState(settings.value("window_split").toByteArray()); } @@ -1909,6 +1976,8 @@ void MainWindow::storeSettings(QSettings &settings) { if (settings.value("reset_geometry", false).toBool()) { settings.remove("window_geometry"); settings.remove("window_state"); + settings.remove("toolbar_size"); + settings.remove("toolbar_button_style"); settings.remove("window_split"); settings.remove("log_split"); settings.remove("filters_visible"); @@ -1918,6 +1987,8 @@ void MainWindow::storeSettings(QSettings &settings) { } else { settings.setValue("window_geometry", saveGeometry()); settings.setValue("window_state", saveState()); + settings.setValue("toolbar_size", ui->toolBar->iconSize()); + settings.setValue("toolbar_button_style", static_cast(ui->toolBar->toolButtonStyle())); settings.setValue("window_split", ui->splitter->saveState()); settings.setValue("log_split", ui->topLevelSplitter->saveState()); settings.setValue("browser_geometry", m_IntegratedBrowser.saveGeometry()); diff --git a/src/mainwindow.h b/src/mainwindow.h index 8e50fa2e..fa5912b8 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -211,6 +211,9 @@ private: void createEndorseMenu(); void updateToolBar(); + void setToolbarSize(const QSize& s); + void setToolbarButtonStyle(Qt::ToolButtonStyle s); + QMenu* createPopupMenu() override; void activateSelectedProfile(); void setExecutableIndex(int index); -- cgit v1.3.1 From e6706c7a5b82e68443de6ca262c77e1543986b1e Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Sun, 2 Jun 2019 16:28:09 -0400 Subject: the toolbar menu is now in the ui file instead of being created by hand it's also shared between the main menu and the context menu --- src/mainwindow.cpp | 82 +++++++++++++++++++++++++++++------------------ src/mainwindow.h | 10 ++++++ src/mainwindow.ui | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 153 insertions(+), 32 deletions(-) (limited to 'src/mainwindow.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 642b0c99..3da571f9 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -399,6 +399,7 @@ MainWindow::MainWindow(QSettings &initSettings connect(ui->tabWidget, SIGNAL(currentChanged(int)), &TutorialManager::instance(), SIGNAL(tabChanged(int))); connect(ui->modList->header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(modListSortIndicatorChanged(int,Qt::SortOrder))); connect(ui->linksToolBar, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(linksToolBar_customContextMenuRequested(QPoint))); + connect(ui->menuToolbars, &QMenu::aboutToShow, [&]{ toolbarMenu_aboutToShow(); }); connect(&m_OrganizerCore, &OrganizerCore::modInstalled, this, &MainWindow::modInstalled); connect(&m_OrganizerCore, &OrganizerCore::close, this, &QMainWindow::close); @@ -640,45 +641,66 @@ void MainWindow::updateToolBar() ui->linksToolBar->setVisible(hasLinks); } -QMenu* MainWindow::createPopupMenu() +void MainWindow::toolbarMenu_aboutToShow() { - auto* m = QMainWindow::createPopupMenu(); + // well, this is a bit of a hack to allow the same toolbar menu to be shown + // in both the main menu and the context menu + // + // the toolbar menu is returned by createPopupMenu(), but Qt takes ownership + // of it and deletes it by setting the WA_DeleteOnClose attribute on it + // + // to avoid deleting the menu, the attribute is removed here + ui->menuToolbars->setAttribute(Qt::WA_DeleteOnClose, false); - m->addSeparator(); + ui->actionToolBarMainToggle->setChecked(ui->toolBar->isVisible()); + ui->actionToolBarLinksToggle->setChecked(ui->linksToolBar->isVisible()); - auto* a = new QAction(tr("Small Icons"), m); - connect(a, &QAction::triggered, [&]{ setToolbarSize(SmallToolbarSize); }); - a->setCheckable(true); - a->setChecked(ui->toolBar->iconSize() == SmallToolbarSize); - m->addAction(a); + ui->actionToolBarLargeIcons->setChecked(ui->toolBar->iconSize() == LargeToolbarSize); + ui->actionToolBarSmallIcons->setChecked(ui->toolBar->iconSize() == SmallToolbarSize); - a = new QAction(tr("Large Icons"), m); - connect(a, &QAction::triggered, [&]{ setToolbarSize(LargeToolbarSize); }); - a->setCheckable(true); - a->setChecked(ui->toolBar->iconSize() == LargeToolbarSize); - m->addAction(a); + ui->actionToolBarIconsOnly->setChecked(ui->toolBar->toolButtonStyle() == Qt::ToolButtonIconOnly); + ui->actionToolBarTextOnly->setChecked(ui->toolBar->toolButtonStyle() == Qt::ToolButtonTextOnly); + ui->actionToolBarIconsAndText->setChecked(ui->toolBar->toolButtonStyle() == Qt::ToolButtonTextUnderIcon); +} - m->addSeparator(); +QMenu* MainWindow::createPopupMenu() +{ + return ui->menuToolbars; +} - a = new QAction(tr("Icons only"), m); - connect(a, &QAction::triggered, [&]{ setToolbarButtonStyle(Qt::ToolButtonIconOnly); }); - a->setCheckable(true); - a->setChecked(ui->toolBar->toolButtonStyle() == Qt::ToolButtonIconOnly); - m->addAction(a); +void MainWindow::on_actionToolBarMainToggle_triggered() +{ + ui->toolBar->setVisible(!ui->toolBar->isVisible()); +} - a = new QAction(tr("Text only"), m); - connect(a, &QAction::triggered, [&]{ setToolbarButtonStyle(Qt::ToolButtonTextOnly); }); - a->setCheckable(true); - a->setChecked(ui->toolBar->toolButtonStyle() == Qt::ToolButtonTextOnly); - m->addAction(a); +void MainWindow::on_actionToolBarLinksToggle_triggered() +{ + ui->linksToolBar->setVisible(!ui->linksToolBar->isVisible()); +} - a = new QAction(tr("Text and Icons"), m); - connect(a, &QAction::triggered, [&]{ setToolbarButtonStyle(Qt::ToolButtonTextUnderIcon); }); - a->setCheckable(true); - a->setChecked(ui->toolBar->toolButtonStyle() == Qt::ToolButtonTextUnderIcon); - m->addAction(a); +void MainWindow::on_actionToolBarLargeIcons_triggered() +{ + setToolbarSize(LargeToolbarSize); +} + +void MainWindow::on_actionToolBarSmallIcons_triggered() +{ + setToolbarSize(SmallToolbarSize); +} - return m; +void MainWindow::on_actionToolBarIconsOnly_triggered() +{ + setToolbarButtonStyle(Qt::ToolButtonIconOnly); +} + +void MainWindow::on_actionToolBarTextOnly_triggered() +{ + setToolbarButtonStyle(Qt::ToolButtonTextOnly); +} + +void MainWindow::on_actionToolBarIconsAndText_triggered() +{ + setToolbarButtonStyle(Qt::ToolButtonTextUnderIcon); } void MainWindow::setToolbarSize(const QSize& s) diff --git a/src/mainwindow.h b/src/mainwindow.h index fa5912b8..18aa525e 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -213,6 +213,8 @@ private: void updateToolBar(); void setToolbarSize(const QSize& s); void setToolbarButtonStyle(Qt::ToolButtonStyle s); + void toolbarMenu_aboutToShow(); + QMenu* createPopupMenu() override; void activateSelectedProfile(); @@ -631,6 +633,14 @@ private slots: // ui slots void on_actionSettings_triggered(); void on_actionUpdate_triggered(); void on_actionExit_triggered(); + void on_actionToolBarMainToggle_triggered(); + void on_actionToolBarLinksToggle_triggered(); + void on_actionToolBarLargeIcons_triggered(); + void on_actionToolBarSmallIcons_triggered(); + void on_actionToolBarIconsOnly_triggered(); + void on_actionToolBarTextOnly_triggered(); + void on_actionToolBarIconsAndText_triggered(); + void on_bsaList_customContextMenuRequested(const QPoint &pos); void on_clearFiltersButton_clicked(); diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 59d30a09..a4bd2888 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -1358,6 +1358,9 @@ p, li { white-space: pre-wrap; } 36 + + Qt::ToolButtonTextUnderIcon + TopToolBarArea @@ -1405,10 +1408,8 @@ p, li { white-space: pre-wrap; } - - @@ -1425,8 +1426,30 @@ p, li { white-space: pre-wrap; } + + + View + + + + Toolbars + + + + + + + + + + + + + + + @@ -1697,6 +1720,72 @@ p, li { white-space: pre-wrap; } Exits Mod Organizer + + + Toolbar Size + + + + + Toolbar Buttons + + + + + true + + + &Main + + + + + true + + + &Links + + + + + true + + + &Small Icons + + + + + true + + + Lar&ge Icons + + + + + true + + + &Icons Only + + + + + true + + + &Text Only + + + + + true + + + I&cons and Text + + -- cgit v1.3.1 From 71a9f085138bf8f9dc75a27abd9b54cdb89a0876 Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Sun, 2 Jun 2019 16:45:58 -0400 Subject: added medium toolbar icon size --- src/mainwindow.cpp | 17 ++++++++++++----- src/mainwindow.h | 3 ++- src/mainwindow.ui | 9 ++++++--- 3 files changed, 20 insertions(+), 9 deletions(-) (limited to 'src/mainwindow.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 3da571f9..753b6a5d 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -190,6 +190,7 @@ using namespace MOBase; using namespace MOShared; const QSize SmallToolbarSize(24, 24); +const QSize MediumToolbarSize(32, 32); const QSize LargeToolbarSize(42, 36); @@ -655,8 +656,9 @@ void MainWindow::toolbarMenu_aboutToShow() ui->actionToolBarMainToggle->setChecked(ui->toolBar->isVisible()); ui->actionToolBarLinksToggle->setChecked(ui->linksToolBar->isVisible()); - ui->actionToolBarLargeIcons->setChecked(ui->toolBar->iconSize() == LargeToolbarSize); ui->actionToolBarSmallIcons->setChecked(ui->toolBar->iconSize() == SmallToolbarSize); + ui->actionToolBarMediumIcons->setChecked(ui->toolBar->iconSize() == MediumToolbarSize); + ui->actionToolBarLargeIcons->setChecked(ui->toolBar->iconSize() == LargeToolbarSize); ui->actionToolBarIconsOnly->setChecked(ui->toolBar->toolButtonStyle() == Qt::ToolButtonIconOnly); ui->actionToolBarTextOnly->setChecked(ui->toolBar->toolButtonStyle() == Qt::ToolButtonTextOnly); @@ -678,14 +680,19 @@ void MainWindow::on_actionToolBarLinksToggle_triggered() ui->linksToolBar->setVisible(!ui->linksToolBar->isVisible()); } -void MainWindow::on_actionToolBarLargeIcons_triggered() +void MainWindow::on_actionToolBarSmallIcons_triggered() { - setToolbarSize(LargeToolbarSize); + setToolbarSize(SmallToolbarSize); } -void MainWindow::on_actionToolBarSmallIcons_triggered() +void MainWindow::on_actionToolBarMediumIcons_triggered() { - setToolbarSize(SmallToolbarSize); + setToolbarSize(MediumToolbarSize); +} + +void MainWindow::on_actionToolBarLargeIcons_triggered() +{ + setToolbarSize(LargeToolbarSize); } void MainWindow::on_actionToolBarIconsOnly_triggered() diff --git a/src/mainwindow.h b/src/mainwindow.h index 18aa525e..a0cce858 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -635,8 +635,9 @@ private slots: // ui slots void on_actionExit_triggered(); void on_actionToolBarMainToggle_triggered(); void on_actionToolBarLinksToggle_triggered(); - void on_actionToolBarLargeIcons_triggered(); void on_actionToolBarSmallIcons_triggered(); + void on_actionToolBarMediumIcons_triggered(); + void on_actionToolBarLargeIcons_triggered(); void on_actionToolBarIconsOnly_triggered(); void on_actionToolBarTextOnly_triggered(); void on_actionToolBarIconsAndText_triggered(); diff --git a/src/mainwindow.ui b/src/mainwindow.ui index a4bd2888..29a8ac76 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -1358,9 +1358,6 @@ p, li { white-space: pre-wrap; } 36 - - Qt::ToolButtonTextUnderIcon - TopToolBarArea @@ -1438,6 +1435,7 @@ p, li { white-space: pre-wrap; } + @@ -1786,6 +1784,11 @@ p, li { white-space: pre-wrap; } I&cons and Text + + + M&edium Icons + + -- cgit v1.3.1