From 75868a323b5c06c779d4808ed5ab15c21ae2f4a7 Mon Sep 17 00:00:00 2001 From: Stefan Hacker Date: Wed, 18 Mar 2009 03:06:03 +0100 Subject: [PATCH] Added Chatbar dock widget to MainWindow --- src/mumble/LookConfig.cpp | 2 + src/mumble/LookConfig.ui | 25 +- src/mumble/MainWindow.cpp | 50 +++- src/mumble/MainWindow.h | 9 +- src/mumble/MainWindow.ui | 483 ++++++++++++++++++++------------------ src/mumble/Settings.cpp | 3 + src/mumble/Settings.h | 1 + 7 files changed, 332 insertions(+), 241 deletions(-) diff --git a/src/mumble/LookConfig.cpp b/src/mumble/LookConfig.cpp index d26af2bdc..8c993f71d 100644 --- a/src/mumble/LookConfig.cpp +++ b/src/mumble/LookConfig.cpp @@ -96,6 +96,7 @@ void LookConfig::load(const Settings &r) { qleCSS->setText(r.qsSkin); loadComboBox(qcbExpand, r.ceExpand); loadComboBox(qcbChannelDrag, r.ceChannelDrag); + loadCheckBox(qcbShowChatbar, r.bShowChatbar); loadCheckBox(qcbPlayersTop, r.bPlayerTop); loadCheckBox(qcbAlwaysOnTop, r.bAlwaysOnTop); loadCheckBox(qcbAskOnQuit, r.bAskOnQuit); @@ -120,6 +121,7 @@ void LookConfig::save() const { s.qsSkin = qleCSS->text(); s.ceExpand=static_cast(qcbExpand->currentIndex()); s.ceChannelDrag=static_cast(qcbChannelDrag->currentIndex()); + s.bShowChatbar = qcbShowChatbar->isChecked(); s.bPlayerTop=qcbPlayersTop->isChecked(); s.bAlwaysOnTop = qcbAlwaysOnTop->isChecked(); s.bAskOnQuit = qcbAskOnQuit->isChecked(); diff --git a/src/mumble/LookConfig.ui b/src/mumble/LookConfig.ui index 449112b2e..9e34b8ad8 100644 --- a/src/mumble/LookConfig.ui +++ b/src/mumble/LookConfig.ui @@ -6,7 +6,7 @@ 0 0 311 - 353 + 374 @@ -123,7 +123,7 @@ - + List players above subchannels (requires restart). @@ -136,7 +136,7 @@ - + Ask whether to close or minimize when quitting Mumble. @@ -149,7 +149,7 @@ - + Hide the main Mumble window in the tray when it is minimized. @@ -162,7 +162,7 @@ - + Make the Mumble window appear on top of other windows. @@ -175,7 +175,7 @@ - + Show all configuration items @@ -188,6 +188,19 @@ + + + + Check to show chat bar + + + <b>If checked the chat bar is shown</b><br />Uncheck to hide it + + + Show chatbar + + + diff --git a/src/mumble/MainWindow.cpp b/src/mumble/MainWindow.cpp index efc5f3ef9..3c7ae7ae9 100644 --- a/src/mumble/MainWindow.cpp +++ b/src/mumble/MainWindow.cpp @@ -56,22 +56,22 @@ MessageBoxEvent::MessageBoxEvent(QString m) : QEvent(static_cast(M msg = m; } -LogTitleBar::LogTitleBar() { +DockTitleBar::DockTitleBar() { qtTick = new QTimer(this); qtTick->setSingleShot(true); connect(qtTick, SIGNAL(timeout()), this, SLOT(tick())); size = newsize = 0; } -QSize LogTitleBar::sizeHint() const { +QSize DockTitleBar::sizeHint() const { return minimumSizeHint(); } -QSize LogTitleBar::minimumSizeHint() const { +QSize DockTitleBar::minimumSizeHint() const { return QSize(size,size); } -bool LogTitleBar::eventFilter(QObject *, QEvent *evt) { +bool DockTitleBar::eventFilter(QObject *, QEvent *evt) { QDockWidget *qdw = qobject_cast(parentWidget()); switch (evt->type()) { @@ -97,7 +97,7 @@ bool LogTitleBar::eventFilter(QObject *, QEvent *evt) { return false; } -void LogTitleBar::tick() { +void DockTitleBar::tick() { QDockWidget *qdw = qobject_cast(parentWidget()); if (newsize == size) @@ -270,14 +270,18 @@ void MainWindow::setupGui() { connect(gsUnlink, SIGNAL(down()), qaAudioUnlink, SLOT(trigger())); connect(gsMinimal, SIGNAL(down()), qaConfigMinimal, SLOT(trigger())); - ltbDockTitle = new LogTitleBar(); - qdwLog->setTitleBarWidget(ltbDockTitle); + dtbLogDockTitle = new DockTitleBar(); + qdwLog->setTitleBarWidget(dtbLogDockTitle); foreach(QWidget *w, qdwLog->findChildren()) { - w->installEventFilter(ltbDockTitle); + w->installEventFilter(dtbLogDockTitle); w->setMouseTracking(true); } + dtbChatDockTitle = new DockTitleBar(); + qdwChat->setTitleBarWidget(dtbChatDockTitle); + qdwChat->installEventFilter(dtbChatDockTitle); + if (g.s.bMinimalView && ! g.s.qbaMinimalViewGeometry.isNull()) restoreGeometry(g.s.qbaMinimalViewGeometry); else if (! g.s.bMinimalView && ! g.s.qbaMainWindowGeometry.isNull()) @@ -519,6 +523,7 @@ void MainWindow::setupView(bool toggle_minimize) { setWindowFlags(f); qdwLog->setVisible(showit); + qdwChat->setVisible(showit && g.s.bShowChatbar); qtvPlayers->header()->setVisible(showit); menuBar()->setVisible(showit); @@ -802,6 +807,33 @@ void MainWindow::on_qaQuit_triggered() { this->close(); } +void MainWindow::on_qleChat_returnPressed() { + if (qleChat->text().isEmpty() || !g.sh || !g.sh->isRunning()) return; // Check if text & connection is available + + Player *p = pmModel->getPlayer(qtvPlayers->currentIndex()); + Channel *c = pmModel->getChannel(qtvPlayers->currentIndex()); + + MumbleProto::TextMessage mptm; + mptm.set_message(u8(qleChat->text())); + + if (p == NULL || p->uiSession == g.uiSession) { + // Channel tree message + if (c == NULL) // If no channel selected fallback to current one + c = ClientPlayer::get(g.uiSession)->cChannel; + + mptm.add_channel_id(c->iId); + g.l->log(Log::TextMessage, tr("To %1: %2").arg(c->qsName).arg(qleChat->text()), tr("Message to %1").arg(c->qsName)); + } + else { + // Player message + mptm.add_session(p->uiSession); + g.l->log(Log::TextMessage, tr("To %1: %2").arg(p->qsName).arg(qleChat->text()), tr("Message to %1").arg(p->qsName)); + } + + g.sh->sendMessage(mptm); + qleChat->setText(QString()); +} + void MainWindow::on_qmConfig_aboutToShow() { // Don't remove the config, as that messes up OSX. foreach(QAction *a, qmConfig->actions()) @@ -1141,7 +1173,7 @@ void MainWindow::on_qaAudioUnlink_triggered() { void MainWindow::on_qaConfigDialog_triggered() { ConfigDialog *dlg= new ConfigDialog(this); if (dlg->exec() == QDialog::Accepted) - setOnTop(g.s.bAlwaysOnTop); + setupView(false); delete dlg; } diff --git a/src/mumble/MainWindow.h b/src/mumble/MainWindow.h index 0c2d95da9..d02809c3b 100644 --- a/src/mumble/MainWindow.h +++ b/src/mumble/MainWindow.h @@ -53,16 +53,16 @@ class MessageBoxEvent : public QEvent { MessageBoxEvent(QString msg); }; -class LogTitleBar : public QWidget { +class DockTitleBar : public QWidget { private: Q_OBJECT - Q_DISABLE_COPY(LogTitleBar) + Q_DISABLE_COPY(DockTitleBar) protected: QTimer *qtTick; int size; int newsize; public: - LogTitleBar(); + DockTitleBar(); QSize sizeHint() const; QSize minimumSizeHint() const; public slots: @@ -85,7 +85,7 @@ class MainWindow : public QMainWindow, public MessageHandler, public Ui::MainWin GlobalShortcut *gsPushTalk, *gsResetAudio, *gsMuteSelf, *gsDeafSelf; GlobalShortcut *gsUnlink, *gsCenterPos, *gsPushMute, *gsMetaChannel, *gsToggleOverlay; GlobalShortcut *gsAltTalk, *gsMinimal, *gsVolumeUp, *gsVolumeDown; - LogTitleBar *ltbDockTitle; + DockTitleBar *dtbLogDockTitle, *dtbChatDockTitle; ACLEditor *aclEdit; BanEditor *banEdit; @@ -156,6 +156,7 @@ class MainWindow : public QMainWindow, public MessageHandler, public Ui::MainWin void on_qaHelpAboutQt_triggered(); void on_qaHelpVersionCheck_triggered(); void on_qaQuit_triggered(); + void on_qleChat_returnPressed(); void on_qteLog_customContextMenuRequested(const QPoint &pos); void on_qteLog_anchorClicked(const QUrl &); void on_qteLog_highlighted(const QUrl & link); diff --git a/src/mumble/MainWindow.ui b/src/mumble/MainWindow.ui index 2d329e2a5..0417b921f 100644 --- a/src/mumble/MainWindow.ui +++ b/src/mumble/MainWindow.ui @@ -1,8 +1,7 @@ - - + MainWindow - - + + 0 0 @@ -10,555 +9,595 @@ 435 - + Mumble - - + + QMainWindow::AllowNestedDocks|QMainWindow::AnimatedDocks + + + Qt::CustomContextMenu - + true - + true - + 10 - + false - + true - - + + 0 0 671 - 22 + 19 - - + + &Server - - + + &Player - - + + &Channel - - + + &Audio - - - - - - - - - + + + + + + + + + - - + + C&onfigure - + - - + + &Help - - - - - - - + + + + + + + - - - - - - + + + + + + - - + + QDockWidget::DockWidgetMovable - + Log - + 1 - - + + Qt::CustomContextMenu - - This shows all recent activity. Connecting to servers, errors and information messages all show up here.<br />To configure exactly which messages show up here, use the <b>Settings</b> command from the menu. + + This shows all recent activity. Connecting to servers, errors and information messages all show up here.<br />To configure exactly which messages show up here, use the <b>Settings</b> command from the menu. - + false - - + + + + 0 + 0 + + + + + + + This is the chatbar<br />If you enter text here and then press enter the text is sent to the player or channel that was selected. If nothing is selected the message is sent to your current channel. + + + QDockWidget::DockWidgetMovable + + + Chatbar + + + 1 + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + + &Quit Mumble - + Closes the program - + Exits the application. - + Ctrl+Q - - + + &Connect - + Open the server connection dialog - + Shows a dialog of registered servers, and also allows quick connect. - - + + false - + &Disconnect - + Disconnect from server - + Disconnects you from the server. - - + + false - + &Ban lists - + Edit ban lists on server - + This lets you edit the server-side IP ban lists. - - + + false - + &Information - + Show information about the server connection - + This will show extended information about the connection to the server. - - + + &Kick - + Kick player (with reason) - + Kick selected player off server. You'll be asked to specify a reason. - - + + true - + &Mute - + Mute player - + Mute or unmute player on server. Unmuting a deafened player will also undeafen them. - - + + &Ban - + Kick and ban player (with reason) - + Kick and ban selected player from server. You'll be asked to specify a reason. - - + + true - + &Deafen - + Deafen player - + Deafen or undeafen player on server. Deafening a player will also mute them. - - + + true - + &Local Mute - + Mute player locally - + Mute or unmute player locally. Use this on other players in the same room. - - + + Send Messa&ge - + Send a Text Message - + Sends a text message to another user. - - + + &Add - + Add new channel - + This adds a new sub-channel to the currently selected channel. - - + + &Remove - + Remove channel - + This removes a channel and all sub-channels. - - + + &Edit ACL - + Edit Groups and ACL for channel - + This opens the Group and ACL dialog for the channel, to control permissions. - - + + &Rename - + Renames the channel - + This renames a channel. - - + + &Change Description - + Changes the channel description - + This changes the description of a channel. - - + + &Link - + Link your channel to another channel - + This links your current channel to the selected channel. If they have permission to speak in the other channel, players can now hear each other. This is a permanent link, and will last until manually unlinked or the server is restarted. Please see the shortcuts for push-to-link. - - - &Unlink + + + &Unlink - + Unlink your channel from another channel - + This unlinks your current channel from the selected channel. - - + + Unlink &All - + Unlinks your channel from all linked channels. - + This unlinks your current channel (not the selected one) from all linked channels. - - + + &Reset - + Reset audio preprocessor - + This will reset the audio preprocessor, including noise cancellation, automatic gain and voice activity detection. If something suddenly worsens the audio environment (like dropping the microphone) and it was temporary, use this to avoid having to wait for the preprocessor to readjust. - - + + true - + &Mute Self - + Mute yourself - + Mute or unmute yourself. When muted, you will not send any data to the server. Unmuting while deafened will also undeafen. - - + + true - + &Deafen Self - + Deafen yourself - + Deafen or undeafen yourself. When deafened, you will not hear anything. Deafening yourself will also mute. - - + + true - + &Text-To-Speech - + Toggle Text-To-Speech - + Enable or disable the text-to-speech engine. Only messages enabled for TTS in the Configuration dialog will actually be spoken. - - + + S&tatistics - + Display audio statistics - + Pops up a small dialog with information about your current audio input. - - - &Unlink + + + &Unlink - + Forcibly unlink plugin - + This forces the current plugin to unlink, which is handy if it is reading completely wrong data. - - + + &Settings - + Configure Mumble - + Allows you to change most settings for Mumble. - + QAction::PreferencesRole - - + + &Audio Wizard - + Start the audio configuration wizard - + This will guide you through the process of configuring your audio hardware. - - + + &What's This? - + Enter What's This? mode - - Click this to enter "What's This?" mode. Your cursor will turn into a question mark. Click on any button, menu choice or area to show a description of what it is. + + Click this to enter "What's This?" mode. Your cursor will turn into a question mark. Click on any button, menu choice or area to show a description of what it is. - - + + &About - + Information about Mumble - + Shows a small dialog with information and license for Mumble. - + QAction::AboutRole - - + + About &Speex - + Information about Speex - + Shows a small dialog with information about Speex. - + QAction::ApplicationSpecificRole - - + + About &Qt - + Information about Qt - + Shows a small dialog with information about Qt. - + QAction::AboutQtRole - - + + Check for &Updates - + Check for new version of Mumble - + Connects to the Mumble webpage to check if a new version is available, and notifies you with an appropriate download URL if this is the case. - - + + Send Messa&ge - + Send a Text Message - + Sends a text message to all users in a channel. - - + + Send &Tree Message - + Send message to channel tree. - + This sends a text message to a channel and it's subchannels. - - + + true - + &Minimal View - + Toggle minimal window modes - + This will toggle minimal mode, where the log window and menu is hidden. - - + + true - + Hide Frame - + Toggle showing frame on minimal window - + This will toggle whether the minimal window should have a frame for moving and resizing. diff --git a/src/mumble/Settings.cpp b/src/mumble/Settings.cpp index fd6dd4da5..7fb37929a 100644 --- a/src/mumble/Settings.cpp +++ b/src/mumble/Settings.cpp @@ -72,6 +72,7 @@ Settings::Settings() { bFirstTime = true; ceExpand = ChannelsWithPlayers; ceChannelDrag = Ask; + bShowChatbar = true; bMinimalView = false; bHideFrame = false; bAlwaysOnTop = false; @@ -278,6 +279,7 @@ void Settings::load() { LOADENUM(ceChannelDrag, "ui/drag"); SAVELOAD(bAlwaysOnTop, "ui/alwaysontop"); SAVELOAD(bAskOnQuit, "ui/askonquit"); + SAVELOAD(bShowChatbar, "ui/shotchatbar"); SAVELOAD(bMinimalView, "ui/minimalview"); SAVELOAD(bHideFrame, "ui/hideframe"); SAVELOAD(bPlayerTop, "ui/playertop"); @@ -429,6 +431,7 @@ void Settings::save() { SAVELOAD(ceChannelDrag, "ui/drag"); SAVELOAD(bAlwaysOnTop, "ui/alwaysontop"); SAVELOAD(bAskOnQuit, "ui/askonquit"); + SAVELOAD(bShowChatbar, "ui/showchatbar"); SAVELOAD(bMinimalView, "ui/minimalview"); SAVELOAD(bHideFrame, "ui/hideframe"); SAVELOAD(bPlayerTop, "ui/playertop"); diff --git a/src/mumble/Settings.h b/src/mumble/Settings.h index 2f5a96cb8..e6dbf2cb4 100644 --- a/src/mumble/Settings.h +++ b/src/mumble/Settings.h @@ -126,6 +126,7 @@ struct Settings { QByteArray qbaConfigGeometry; ChannelExpand ceExpand; ChannelDrag ceChannelDrag; + bool bShowChatbar; bool bMinimalView; bool bHideFrame; bool bAlwaysOnTop;