Skip to content

Commit

Permalink
MainWindow: only allow layout to be changed via settings.
Browse files Browse the repository at this point in the history
This simplifies our handling of our UI layout setting in
MainWindow.

Previously, we had slots that detected visibility and position
changes for dock elements. And if any of them fired, we would
revert back to the 'custom' layout.

However, changing the layout behind the user's back meant we
had to keep track of the original layout setting when we
performed a re-layout of the MainWindow, such as when we apply
new settings from the ConfigDialog.

In Qt 5 (we think!), things changed, and the slots are called
more frequently.

Currently, that means that Mumble *always* resets to the 'custom'
layout when applying settings. That's no good.

This commit removes the slots that listen for layout and visibility
changes for dock elements. It also removes MainWindow's 'dock widget'
context menu when not in the 'custom' layout. The result is that you
are now locked into the layout that you choose in the ConfigDialog.

We already have code in Mumble that I wrote a while back that disables
dragging of dock elements when you are not in the 'custom' layout.

This is a natural extension of that: you can no longer modify the
layout of the UI unless you choose 'custom'.

Fixes #2003
  • Loading branch information
mkrautz committed Dec 26, 2015
1 parent 173b68a commit 25ceebb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 27 deletions.
32 changes: 9 additions & 23 deletions src/mumble/MainWindow.cpp
Expand Up @@ -364,12 +364,10 @@ void MainWindow::setupGui() {
else if (! g.s.bMinimalView && ! g.s.qbaMainWindowGeometry.isNull()) else if (! g.s.bMinimalView && ! g.s.qbaMainWindowGeometry.isNull())
restoreGeometry(g.s.qbaMainWindowGeometry); restoreGeometry(g.s.qbaMainWindowGeometry);


Settings::WindowLayout wlTmp = g.s.wlWindowLayout;
if (g.s.bMinimalView && ! g.s.qbaMinimalViewState.isNull()) if (g.s.bMinimalView && ! g.s.qbaMinimalViewState.isNull())
restoreState(g.s.qbaMinimalViewState); restoreState(g.s.qbaMinimalViewState);
else if (! g.s.bMinimalView && ! g.s.qbaMainWindowState.isNull()) else if (! g.s.bMinimalView && ! g.s.qbaMainWindowState.isNull())
restoreState(g.s.qbaMainWindowState); restoreState(g.s.qbaMainWindowState);
g.s.wlWindowLayout = wlTmp;


setupView(false); setupView(false);


Expand Down Expand Up @@ -564,6 +562,14 @@ void MainWindow::updateTransmitModeComboBox() {
} }
} }


QMenu *MainWindow::createPopupMenu() {
if (g.s.wlWindowLayout == Settings::LayoutCustom) {
return QMainWindow::createPopupMenu();
}

return NULL;
}

Channel *MainWindow::getContextMenuChannel() { Channel *MainWindow::getContextMenuChannel() {
if (cContextChannel) if (cContextChannel)
return cContextChannel.data(); return cContextChannel.data();
Expand Down Expand Up @@ -882,9 +888,7 @@ void MainWindow::setOnTop(bool top) {
void MainWindow::setupView(bool toggle_minimize) { void MainWindow::setupView(bool toggle_minimize) {
bool showit = ! g.s.bMinimalView; bool showit = ! g.s.bMinimalView;


// Update window layout switch (g.s.wlWindowLayout) {
Settings::WindowLayout wlTmp = g.s.wlWindowLayout;
switch (wlTmp) {
case Settings::LayoutClassic: case Settings::LayoutClassic:
removeDockWidget(qdwLog); removeDockWidget(qdwLog);
addDockWidget(Qt::LeftDockWidgetArea, qdwLog); addDockWidget(Qt::LeftDockWidgetArea, qdwLog);
Expand All @@ -908,11 +912,9 @@ void MainWindow::setupView(bool toggle_minimize) {
qdwChat->show(); qdwChat->show();
break; break;
default: default:
wlTmp = Settings::LayoutCustom;
break; break;
} }
qteChat->updateGeometry(); qteChat->updateGeometry();
g.s.wlWindowLayout = wlTmp;


QRect geom = frameGeometry(); QRect geom = frameGeometry();


Expand Down Expand Up @@ -3032,22 +3034,6 @@ void MainWindow::on_qteLog_highlighted(const QUrl &url) {
} }
} }


void MainWindow::on_qdwChat_dockLocationChanged(Qt::DockWidgetArea) {
g.s.wlWindowLayout = Settings::LayoutCustom;
}

void MainWindow::on_qdwLog_dockLocationChanged(Qt::DockWidgetArea) {
g.s.wlWindowLayout = Settings::LayoutCustom;
}

void MainWindow::on_qdwChat_visibilityChanged(bool) {
g.s.wlWindowLayout = Settings::LayoutCustom;
}

void MainWindow::on_qdwLog_visibilityChanged(bool) {
g.s.wlWindowLayout = Settings::LayoutCustom;
}

void MainWindow::context_triggered() { void MainWindow::context_triggered() {
QAction *a = qobject_cast<QAction *>(sender()); QAction *a = qobject_cast<QAction *>(sender());


Expand Down
6 changes: 2 additions & 4 deletions src/mumble/MainWindow.h
Expand Up @@ -187,6 +187,8 @@ class MainWindow : public QMainWindow, public MessageHandler, public Ui::MainWin
void showEvent(QShowEvent *e) Q_DECL_OVERRIDE; void showEvent(QShowEvent *e) Q_DECL_OVERRIDE;
void changeEvent(QEvent* e) Q_DECL_OVERRIDE; void changeEvent(QEvent* e) Q_DECL_OVERRIDE;


QMenu *createPopupMenu() Q_DECL_OVERRIDE;

bool handleSpecialContextMenu(const QUrl &url, const QPoint &pos_, bool focus = false); bool handleSpecialContextMenu(const QUrl &url, const QPoint &pos_, bool focus = false);
Channel* getContextMenuChannel(); Channel* getContextMenuChannel();
ClientUser* getContextMenuUser(); ClientUser* getContextMenuUser();
Expand Down Expand Up @@ -259,10 +261,6 @@ class MainWindow : public QMainWindow, public MessageHandler, public Ui::MainWin
void on_qteLog_customContextMenuRequested(const QPoint &pos); void on_qteLog_customContextMenuRequested(const QPoint &pos);
void on_qteLog_anchorClicked(const QUrl &); void on_qteLog_anchorClicked(const QUrl &);
void on_qteLog_highlighted(const QUrl & link); void on_qteLog_highlighted(const QUrl & link);
void on_qdwChat_dockLocationChanged(Qt::DockWidgetArea);
void on_qdwLog_dockLocationChanged(Qt::DockWidgetArea);
void on_qdwChat_visibilityChanged(bool);
void on_qdwLog_visibilityChanged(bool);
void on_PushToTalk_triggered(bool, QVariant); void on_PushToTalk_triggered(bool, QVariant);
void on_PushToMute_triggered(bool, QVariant); void on_PushToMute_triggered(bool, QVariant);
void on_VolumeUp_triggered(bool, QVariant); void on_VolumeUp_triggered(bool, QVariant);
Expand Down

0 comments on commit 25ceebb

Please sign in to comment.