aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mainwindow.cpp28
-rw-r--r--src/mainwindow.h5
-rw-r--r--src/messageview.cpp43
-rw-r--r--src/messageview.h11
4 files changed, 78 insertions, 9 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 9a94a2e..fd59f47 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -555,6 +555,9 @@ MainWindow::MainWindow(const Config &config, QWidget *parent)
}
buildMenus();
+ // After buildMenus(), which registers the toolbar and menu entries these
+ // actions already carry: the bar shows the same objects a second time.
+ populateMessageBar();
// After buildMenus(): QMainWindow::restoreState() matches toolbars by
// object name, so they must already exist or their position is dropped.
restoreUiState();
@@ -1967,15 +1970,10 @@ void MainWindow::buildMenus()
const int iconSize = m_config.toolbarIconSize();
toolBar->setIconSize(QSize(iconSize, iconSize));
- // First, because composing and replying are what a user reaches for most
- // (item 123). These TWO only: the other four are menu-and-key, which is
- // what keeps the no-duplicate-icons rule satisfiable, since reply_no_quote
- // shares reply's icon and an icon-only toolbar would make the two buttons
- // indistinguishable.
- toolBar->addAction(m_actions.value(QStringLiteral("compose")));
- toolBar->addAction(m_actions.value(QStringLiteral("reply")));
- toolBar->addSeparator();
-
+ // Compose, Reply and Forward are NOT here (item 140). They act on a
+ // message, where everything below acts on the list or on the selection,
+ // and mixing the two is what made this toolbar read as the place for
+ // everything. They live on the message pane's own bar instead.
QAction *syncAction = m_actions.value(QStringLiteral("sync"));
// Carried over from the QPushButton this replaced: with no command
// configured the control is disabled, and the tooltip is the only thing
@@ -1994,6 +1992,18 @@ void MainWindow::buildMenus()
toolBar->addAction(m_actions.value(QStringLiteral("undo")));
}
+void MainWindow::populateMessageBar()
+{
+ // The window's own QActions, shown a second time rather than copied: a
+ // duplicate QAction would need its own enablement and would drift from the
+ // menu entry that updateComposeActions() keeps in step.
+ m_messageView->setBarActions(
+ { m_actions.value(QStringLiteral("compose")),
+ m_actions.value(QStringLiteral("reply")),
+ m_actions.value(QStringLiteral("forward")) },
+ { m_actions.value(QStringLiteral("toggle_html")) });
+}
+
void MainWindow::showShortcutReference()
{
// Generated from the actions, so it cannot disagree with what the keys
diff --git a/src/mainwindow.h b/src/mainwindow.h
index ea3ba61..909b04b 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -637,6 +637,11 @@ private:
void registerActions();
void buildMenus();
+
+ /// Fills the message pane's own bar with the three message actions and
+ /// toggle_html (items 139 to 141). Called after buildMenus(), which is
+ /// what creates the actions it hands over.
+ void populateMessageBar();
void wireWorker();
/// Asks the worker to re-enumerate the database tags for the completer.
diff --git a/src/messageview.cpp b/src/messageview.cpp
index 22df6ce..c8395f1 100644
--- a/src/messageview.cpp
+++ b/src/messageview.cpp
@@ -37,6 +37,9 @@
#include <QTimer>
#include <QTreeWidget>
#include <QVBoxLayout>
+#include <QStyle>
+#include <QSizePolicy>
+#include <QToolBar>
#include <QWheelEvent>
#include <QWebEnginePage>
#include <QWebEngineProfile>
@@ -456,7 +459,20 @@ MessageView::MessageView(QWidget *parent)
menu.exec(globalPos);
});
+ // The pane's own action bar (items 139 to 141). Empty until MainWindow
+ // fills it: the actions belong to the window, and MessageView deliberately
+ // knows nothing about the action map.
+ m_messageBar = new QToolBar(this);
+ m_messageBar->setObjectName(QStringLiteral("message_toolbar"));
+ // The desktop's own button style, for the reason the main toolbar records:
+ // a hardcoded setToolButtonStyle() overrides the user's "Icon only".
+ m_messageBar->setToolButtonStyle(static_cast<Qt::ToolButtonStyle>(
+ style()->styleHint(QStyle::SH_ToolButtonStyle, nullptr, m_messageBar)));
+ m_messageBar->setMovable(false);
+ m_messageBar->hide();
+
auto *layout = new QVBoxLayout(this);
+ layout->addWidget(m_messageBar);
layout->addLayout(headerRow);
layout->addWidget(m_blockedBar);
layout->addWidget(m_receiveOnlyRibbon);
@@ -566,6 +582,33 @@ void MessageView::applyNoticeBarStyles()
}
}
+void MessageView::setBarActions(const QList<QAction *> &messageActions,
+ const QList<QAction *> &viewControls)
+{
+ m_messageBar->clear();
+
+ for (QAction *action : messageActions) {
+ if (action)
+ m_messageBar->addAction(action);
+ }
+
+ // The stretch is what separates the two scopes, so the view controls end
+ // up at the right edge. A QToolBar has no addStretch(), so it takes an
+ // expanding spacer widget.
+ if (!viewControls.isEmpty()) {
+ auto *spacer = new QWidget(m_messageBar);
+ spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
+ m_messageBar->addWidget(spacer);
+
+ for (QAction *action : viewControls) {
+ if (action)
+ m_messageBar->addAction(action);
+ }
+ }
+
+ m_messageBar->setVisible(!m_messageBar->actions().isEmpty());
+}
+
void MessageView::clear()
{
m_items.clear();
diff --git a/src/messageview.h b/src/messageview.h
index 29101d6..b28dcdc 100644
--- a/src/messageview.h
+++ b/src/messageview.h
@@ -32,6 +32,7 @@
class QLabel;
class QMenu;
+class QToolBar;
class QWebEnginePage;
class QPushButton;
class QWebEngineView;
@@ -245,6 +246,15 @@ public:
/// after three wrong theories. Keep the two questions separate.
static void addPaneActions(QMenu *menu, QWebEnginePage *page);
+ /// Fills the pane's own action bar (items 139 to 141). The actions are
+ /// MainWindow's own, shown a second time rather than duplicated, so they
+ /// keep one enablement state and one menu entry. \p viewControls are
+ /// separated from \p messageActions by a stretch: acting on the message
+ /// and changing how it is displayed are different scopes, which is the
+ /// confusion the bar exists to remove one level up.
+ void setBarActions(const QList<QAction *> &messageActions,
+ const QList<QAction *> &viewControls);
+
/// Tells the pane whether the query bar currently holds anything.
///
/// The menus need it to grey out "Exclude from search": excluding from an
@@ -405,6 +415,7 @@ private:
CidSchemeHandler *m_cidHandler = nullptr;
QLabel *m_headerLabel = nullptr;
+ QToolBar *m_messageBar = nullptr;
QWidget *m_blockedBar = nullptr;
QLabel *m_blockedLabel = nullptr;
QLabel *m_receiveOnlyRibbon = nullptr;