From 441d06f6d1ae7f0b03fd86dafb99084d2c0b52ab Mon Sep 17 00:00:00 2001 From: Benjamin Jemlich Date: Thu, 31 May 2012 12:48:39 +0200 Subject: [PATCH] ChatBar: Always use the current channel by default --- src/mumble/CustomElements.cpp | 2 +- src/mumble/LookConfig.cpp | 2 + src/mumble/LookConfig.ui | 131 ++++++++++++++++++---------------- src/mumble/MainWindow.cpp | 12 ++-- src/mumble/MainWindow.h | 1 + src/mumble/Messages.cpp | 4 ++ src/mumble/Settings.cpp | 3 + src/mumble/Settings.h | 1 + 8 files changed, 89 insertions(+), 67 deletions(-) diff --git a/src/mumble/CustomElements.cpp b/src/mumble/CustomElements.cpp index 115a5eecc..6b5cdcffa 100644 --- a/src/mumble/CustomElements.cpp +++ b/src/mumble/CustomElements.cpp @@ -105,7 +105,7 @@ void ChatbarTextEdit::inFocus(bool focus) { void ChatbarTextEdit::contextMenuEvent(QContextMenuEvent *qcme) { QMenu *menu = createStandardContextMenu(); - QAction *action = new QAction(tr("Paste and send") + QLatin1Char('\t'), menu); + QAction *action = new QAction(tr("Paste and &Send") + QLatin1Char('\t'), menu); action->setEnabled(!QApplication::clipboard()->text().isEmpty()); connect(action, SIGNAL(triggered()), this, SLOT(pasteAndSend_triggered())); if (menu->actions().count() > 6) diff --git a/src/mumble/LookConfig.cpp b/src/mumble/LookConfig.cpp index a7b85b5d3..fe48f4129 100644 --- a/src/mumble/LookConfig.cpp +++ b/src/mumble/LookConfig.cpp @@ -133,6 +133,7 @@ void LookConfig::load(const Settings &r) { loadCheckBox(qcbShowUserCount, r.bShowUserCount); loadCheckBox(qcbShowContextMenuInMenuBar, r.bShowContextMenuInMenuBar); loadCheckBox(qcbHighContrast, r.bHighContrast); + loadCheckBox(qcbChatBarUseSelection, r.bChatBarUseSelection); } void LookConfig::save() const { @@ -172,6 +173,7 @@ void LookConfig::save() const { s.bShowUserCount = qcbShowUserCount->isChecked(); s.bShowContextMenuInMenuBar = qcbShowContextMenuInMenuBar->isChecked(); s.bHighContrast = qcbHighContrast->isChecked(); + s.bChatBarUseSelection = qcbChatBarUseSelection->isChecked(); } void LookConfig::accept() const { diff --git a/src/mumble/LookConfig.ui b/src/mumble/LookConfig.ui index bc2d6d451..ec91829b9 100644 --- a/src/mumble/LookConfig.ui +++ b/src/mumble/LookConfig.ui @@ -244,6 +244,67 @@ + + + + Tray Icon + + + + + + Hide the main Mumble window in the tray when it is minimized. + + + <b>If set, minimizing the Mumble main window will cause it to be hidden and accessible only from the tray. Otherwise, it will be minimized as a window normally would.</b> + + + Hide in tray when minimized + + + + + + + Displays talking status in system tray + + + + + + Show talking status in tray icon + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + @@ -313,47 +374,12 @@ - - - - Tray Icon - - - - - - Hide the main Mumble window in the tray when it is minimized. - - - <b>If set, minimizing the Mumble main window will cause it to be hidden and accessible only from the tray. Otherwise, it will be minimized as a window normally would.</b> - - - Hide in tray when minimized - - - - - - - Displays talking status in system tray - - - - - - Show talking status in tray icon - - - - - - Channel Tree - + @@ -411,35 +437,16 @@ + + + + Use selected item as the chat bar target + + + - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - diff --git a/src/mumble/MainWindow.cpp b/src/mumble/MainWindow.cpp index b6b9b63d7..147868266 100644 --- a/src/mumble/MainWindow.cpp +++ b/src/mumble/MainWindow.cpp @@ -1504,9 +1504,9 @@ void MainWindow::sendChatbarMessage(QString qsText) { qsText = Qt::escape(qsText); qsText = TextMessage::autoFormat(qsText); - if (p == NULL || p->uiSession == g.uiSession) { + if (!g.s.bChatBarUseSelection || p == NULL || p->uiSession == g.uiSession) { // Channel message - if (c == NULL) // If no channel selected fallback to current one + if (!g.s.bChatBarUseSelection || c == NULL) // If no channel selected fallback to current one c = ClientUser::get(g.uiSession)->cChannel; g.sh->sendChannelTextMessage(c->iId, qsText, false); @@ -2569,14 +2569,18 @@ void MainWindow::on_Icon_activated(QSystemTrayIcon::ActivationReason reason) { } void MainWindow::qtvUserCurrentChanged(const QModelIndex &, const QModelIndex &) { + updateChatBar(); +} + +void MainWindow::updateChatBar() { User *p = pmModel->getUser(qtvUsers->currentIndex()); Channel *c = pmModel->getChannel(qtvUsers->currentIndex()); if (g.uiSession == 0) { qteChat->setDefaultText(tr("
Not connected
"), true); - } else if (p == NULL || p->uiSession == g.uiSession) { + } else if (!g.s.bChatBarUseSelection || p == NULL || p->uiSession == g.uiSession) { // Channel tree target - if (c == NULL) // If no channel selected fallback to current one + if (!g.s.bChatBarUseSelection || c == NULL) // If no channel selected fallback to current one c = ClientUser::get(g.uiSession)->cChannel; qteChat->setDefaultText(tr("
Type message to channel '%1' here
").arg(c->qsName)); diff --git a/src/mumble/MainWindow.h b/src/mumble/MainWindow.h index b131475ad..965a887da 100644 --- a/src/mumble/MainWindow.h +++ b/src/mumble/MainWindow.h @@ -116,6 +116,7 @@ class MainWindow : public QMainWindow, public MessageHandler, public Ui::MainWin QPair openImageFile(); static const QString defaultStyleSheet; + void updateChatBar(); void openTextMessageDialog(ClientUser *p); #ifdef Q_OS_WIN diff --git a/src/mumble/Messages.cpp b/src/mumble/Messages.cpp index 8806c0d3b..17ec5575f 100644 --- a/src/mumble/Messages.cpp +++ b/src/mumble/Messages.cpp @@ -433,6 +433,10 @@ void MainWindow::msgUserState(const MumbleProto::UserState &msg) { pmModel->moveUser(pDst, c); + if (pDst == pSelf) { + g.mw->updateChatBar(); + } + if (log && (pDst != pSelf) && (pDst->cChannel == pSelf->cChannel)) { if (pDst == pSrc) g.l->log(Log::ChannelJoin, tr("%1 entered channel.").arg(Log::formatClientUser(pDst, Log::Target))); diff --git a/src/mumble/Settings.cpp b/src/mumble/Settings.cpp index cec514482..64eb204a7 100644 --- a/src/mumble/Settings.cpp +++ b/src/mumble/Settings.cpp @@ -309,6 +309,7 @@ Settings::Settings() { bStateInTray = true; bUsage = true; bShowUserCount = false; + bChatBarUseSelection = false; wlWindowLayout = LayoutClassic; bShowContextMenuInMenuBar = false; @@ -638,6 +639,7 @@ void Settings::load(QSettings* settings_ptr) { SAVELOAD(bStateInTray, "ui/stateintray"); SAVELOAD(bUsage, "ui/usage"); SAVELOAD(bShowUserCount, "ui/showusercount"); + SAVELOAD(bChatBarUseSelection, "ui/chatbaruseselection"); SAVELOAD(qsImagePath, "ui/imagepath"); SAVELOAD(bShowContextMenuInMenuBar, "ui/showcontextmenuinmenubar"); SAVELOAD(qbaConnectDialogGeometry, "ui/connect/geometry"); @@ -911,6 +913,7 @@ void Settings::save() { SAVELOAD(bStateInTray, "ui/stateintray"); SAVELOAD(bUsage, "ui/usage"); SAVELOAD(bShowUserCount, "ui/showusercount"); + SAVELOAD(bChatBarUseSelection, "ui/chatbaruseselection"); SAVELOAD(qsImagePath, "ui/imagepath"); SAVELOAD(bShowContextMenuInMenuBar, "ui/showcontextmenuinmenubar"); SAVELOAD(qbaConnectDialogGeometry, "ui/connect/geometry"); diff --git a/src/mumble/Settings.h b/src/mumble/Settings.h index 3bec4bd03..d6680933c 100644 --- a/src/mumble/Settings.h +++ b/src/mumble/Settings.h @@ -248,6 +248,7 @@ struct Settings { bool bStateInTray; bool bUsage; bool bShowUserCount; + bool bChatBarUseSelection; QByteArray qbaConnectDialogHeader, qbaConnectDialogGeometry; bool bShowContextMenuInMenuBar;