summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorisanae <14251494+isanae@users.noreply.github.com>2019-06-03 18:30:23 -0400
committerisanae <14251494+isanae@users.noreply.github.com>2019-06-03 18:30:23 -0400
commit97026b4da03dbb9dda460c6046aaa09a23a927bf (patch)
tree04b8450cdf3c8dd63d37ef4940d5802f2d6b6ef5
parent355a2fbbee568723a05283f9a63ad9aa30040394 (diff)
added menubar toggle in the context menu
removed two unused actions: actionToolbar_Size and actionToolbar_style added ways to make the menu reappear if you hide everything: - show the toolbar popup when right-clicking around the border of the main window - intercept the Alt key and make the main menu visible
-rw-r--r--src/mainwindow.cpp40
-rw-r--r--src/mainwindow.h4
-rw-r--r--src/mainwindow.ui24
3 files changed, 56 insertions, 12 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 01bb4fc1..1098b529 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -653,6 +653,7 @@ void MainWindow::toolbarMenu_aboutToShow()
// to avoid deleting the menu, the attribute is removed here
ui->menuToolbars->setAttribute(Qt::WA_DeleteOnClose, false);
+ ui->actionMainMenuToggle->setChecked(ui->menuBar->isVisible());
ui->actionToolBarMainToggle->setChecked(ui->toolBar->isVisible());
ui->actionToolBarLinksToggle->setChecked(ui->linksToolBar->isVisible());
@@ -670,6 +671,11 @@ QMenu* MainWindow::createPopupMenu()
return ui->menuToolbars;
}
+void MainWindow::on_actionMainMenuToggle_triggered()
+{
+ ui->menuBar->setVisible(!ui->menuBar->isVisible());
+}
+
void MainWindow::on_actionToolBarMainToggle_triggered()
{
ui->toolBar->setVisible(!ui->toolBar->isVisible());
@@ -724,6 +730,23 @@ void MainWindow::setToolbarButtonStyle(Qt::ToolButtonStyle s)
}
}
+void MainWindow::on_centralWidget_customContextMenuRequested(const QPoint &pos)
+{
+ // the custom context menu event bubbles up to here if widgets don't actually
+ // process this, which would show the menu when right-clicking button, labels,
+ // etc.
+ //
+ // only show the context menu when right-clicking on the central widget
+ // itself, which is basically just the outer edges of the main window
+ auto* w = childAt(pos);
+ if (w != ui->centralWidget) {
+ return;
+ }
+
+ auto* m = createPopupMenu();
+ m->exec(ui->centralWidget->mapToGlobal(pos));
+}
+
void MainWindow::scheduleUpdateButton()
{
if (!m_UpdateProblemsTimer.isActive()) {
@@ -1928,6 +1951,10 @@ void MainWindow::readSettings()
settings.value("toolbar_button_style").toInt()));
}
+ if (settings.contains("menubar_visible")) {
+ ui->menuBar->setVisible(settings.value("menubar_visible").toBool());
+ }
+
if (settings.contains("window_split")) {
ui->splitter->restoreState(settings.value("window_split").toByteArray());
}
@@ -2007,6 +2034,7 @@ void MainWindow::storeSettings(QSettings &settings) {
settings.remove("window_state");
settings.remove("toolbar_size");
settings.remove("toolbar_button_style");
+ settings.remove("menubar_visible");
settings.remove("window_split");
settings.remove("window_monitor");
settings.remove("log_split");
@@ -2019,6 +2047,7 @@ void MainWindow::storeSettings(QSettings &settings) {
settings.setValue("window_state", saveState());
settings.setValue("toolbar_size", ui->toolBar->iconSize());
settings.setValue("toolbar_button_style", static_cast<int>(ui->toolBar->toolButtonStyle()));
+ settings.setValue("menubar_visible", ui->menuBar->isVisible());
settings.setValue("window_split", ui->splitter->saveState());
settings.setValue("window_monitor", QApplication::desktop()->screenNumber(this));
settings.setValue("log_split", ui->topLevelSplitter->saveState());
@@ -6815,6 +6844,17 @@ void MainWindow::dropEvent(QDropEvent *event)
event->accept();
}
+void MainWindow::keyPressEvent(QKeyEvent *event)
+{
+ // if the menubar is hidden, pressing Alt will make it visible
+ if (event->key() == Qt::Key_Alt) {
+ if (!ui->menuBar->isVisible()) {
+ ui->menuBar->setVisible(true);
+ }
+ }
+
+ QMainWindow::keyPressEvent(event);
+}
void MainWindow::on_clickBlankButton_clicked()
{
diff --git a/src/mainwindow.h b/src/mainwindow.h
index a0cce858..09aeb044 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -195,6 +195,7 @@ protected:
virtual void resizeEvent(QResizeEvent *event);
virtual void dragEnterEvent(QDragEnterEvent *event);
virtual void dropEvent(QDropEvent *event);
+ void keyPressEvent(QKeyEvent *event) override;
private slots:
void on_actionChange_Game_triggered();
@@ -633,6 +634,7 @@ private slots: // ui slots
void on_actionSettings_triggered();
void on_actionUpdate_triggered();
void on_actionExit_triggered();
+ void on_actionMainMenuToggle_triggered();
void on_actionToolBarMainToggle_triggered();
void on_actionToolBarLinksToggle_triggered();
void on_actionToolBarSmallIcons_triggered();
@@ -642,7 +644,7 @@ private slots: // ui slots
void on_actionToolBarTextOnly_triggered();
void on_actionToolBarIconsAndText_triggered();
-
+ void on_centralWidget_customContextMenuRequested(const QPoint &pos);
void on_bsaList_customContextMenuRequested(const QPoint &pos);
void on_clearFiltersButton_clicked();
void on_btnRefreshData_clicked();
diff --git a/src/mainwindow.ui b/src/mainwindow.ui
index 9656cbf2..e25111e1 100644
--- a/src/mainwindow.ui
+++ b/src/mainwindow.ui
@@ -30,6 +30,9 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
+ <property name="contextMenuPolicy">
+ <enum>Qt::CustomContextMenu</enum>
+ </property>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<property name="leftMargin">
<number>6</number>
@@ -1432,6 +1435,7 @@ p, li { white-space: pre-wrap; }
<property name="title">
<string>&amp;Toolbars</string>
</property>
+ <addaction name="actionMainMenuToggle"/>
<addaction name="actionToolBarMainToggle"/>
<addaction name="actionToolBarLinksToggle"/>
<addaction name="separator"/>
@@ -1719,22 +1723,12 @@ p, li { white-space: pre-wrap; }
<string>Exits Mod Organizer</string>
</property>
</action>
- <action name="actionToolbar_Size">
- <property name="text">
- <string>Toolbar Size</string>
- </property>
- </action>
- <action name="actionToolbar_style">
- <property name="text">
- <string>Toolbar Buttons</string>
- </property>
- </action>
<action name="actionToolBarMainToggle">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
- <string>&amp;Main</string>
+ <string>M&amp;ain</string>
</property>
</action>
<action name="actionToolBarLinksToggle">
@@ -1793,6 +1787,14 @@ p, li { white-space: pre-wrap; }
<string>M&amp;edium Icons</string>
</property>
</action>
+ <action name="actionMainMenuToggle">
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>&amp;Menu</string>
+ </property>
+ </action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>