Skip to content
Permalink
Browse files

Add optional combobox for transmit mode selection in the MainWindow's…

… toolbar.

Implements feature request SF-1119
  • Loading branch information...
askreet authored and mkrautz committed Feb 8, 2015
1 parent 3515479 commit 44dc94e928c59901bbf839377efcd9d7d73cff2a
Showing with 96 additions and 11 deletions.
  1. +2 −0 src/mumble/LookConfig.cpp
  2. +18 −11 src/mumble/LookConfig.ui
  3. +62 −0 src/mumble/MainWindow.cpp
  4. +8 −0 src/mumble/MainWindow.h
  5. +4 −0 src/mumble/Settings.cpp
  6. +2 −0 src/mumble/Settings.h
@@ -144,6 +144,7 @@ void LookConfig::load(const Settings &r) {
loadCheckBox(qcbStateInTray, r.bStateInTray);
loadCheckBox(qcbShowUserCount, r.bShowUserCount);
loadCheckBox(qcbShowContextMenuInMenuBar, r.bShowContextMenuInMenuBar);
loadCheckBox(qcbShowTransmitModeComboBox, r.bShowTransmitModeComboBox);
loadCheckBox(qcbHighContrast, r.bHighContrast);
loadCheckBox(qcbChatBarUseSelection, r.bChatBarUseSelection);
loadCheckBox(qcbFilterHidesEmptyChannels, r.bFilterHidesEmptyChannels);
@@ -186,6 +187,7 @@ void LookConfig::save() const {
s.bStateInTray = qcbStateInTray->isChecked();
s.bShowUserCount = qcbShowUserCount->isChecked();
s.bShowContextMenuInMenuBar = qcbShowContextMenuInMenuBar->isChecked();
s.bShowTransmitModeComboBox = qcbShowTransmitModeComboBox->isChecked();
s.bHighContrast = qcbHighContrast->isChecked();
s.bChatBarUseSelection = qcbChatBarUseSelection->isChecked();
s.bFilterHidesEmptyChannels = qcbFilterHidesEmptyChannels->isChecked();
@@ -81,17 +81,7 @@
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="qcbHighContrast">
<property name="toolTip">
<string>Apply some high contrast optimizations for visually impaired users</string>
</property>
<property name="text">
<string>Optimize for high contrast</string>
</property>
</widget>
</item>
<item row="7" column="0">
<item row="8" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
@@ -104,6 +94,23 @@
</property>
</spacer>
</item>
<item row="6" column="0" colspan="2">
<widget class="QCheckBox" name="qcbHighContrast">
<property name="toolTip">
<string>Apply some high contrast optimizations for visually impaired users</string>
</property>
<property name="text">
<string>Optimize for high contrast</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="2">
<widget class="QCheckBox" name="qcbShowTransmitModeComboBox">
<property name="text">
<string>Show transmit mode dropdown in toolbar</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@@ -325,6 +325,22 @@ void MainWindow::setupGui() {
SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)),
SLOT(qtvUserCurrentChanged(const QModelIndex &, const QModelIndex &)));

// QtCreator and uic.exe do not allow adding arbitrary widgets
// such as a QComboBox to a QToolbar, even though they are supported.
qcbTransmitMode = new QComboBox(qtIconToolbar);
qcbTransmitMode->setObjectName(QLatin1String("qcbTransmitMode"));
qcbTransmitMode->addItem(tr("Continuous"));
qcbTransmitMode->addItem(tr("Voice Activity"));
qcbTransmitMode->addItem(tr("Push-to-Talk"));

qaTransmitModeSeparator = qtIconToolbar->insertSeparator(qaConfigDialog);
qaTransmitMode = qtIconToolbar->insertWidget(qaTransmitModeSeparator, qcbTransmitMode);

connect(qcbTransmitMode, SIGNAL(activated(int)),
this, SLOT(qcbTransmitMode_activated(int)));

updateTransmitModeComboBox();

#ifndef Q_OS_MAC
setupView(false);
#endif
@@ -510,6 +526,20 @@ void MainWindow::updateTrayIcon() {
}
}

void MainWindow::updateTransmitModeComboBox() {
switch (g.s.atTransmit) {
case Settings::Continous:
qcbTransmitMode->setCurrentIndex(0);
return;
case Settings::VAD:
qcbTransmitMode->setCurrentIndex(1);
return;
case Settings::PushToTalk:
qcbTransmitMode->setCurrentIndex(2);
return;
}
}

Channel *MainWindow::getContextMenuChannel() {
if (cContextChannel)
return cContextChannel.data();
@@ -896,6 +926,16 @@ void MainWindow::setupView(bool toggle_minimize) {
move(geom.x(), geom.y());
}

// Display the Transmit Mode Dropdown, if configured to do so, otherwise
// hide it.
if (g.s.bShowTransmitModeComboBox) {
qaTransmitMode->setVisible(true);
qaTransmitModeSeparator->setVisible(true);
} else {
qaTransmitMode->setVisible(false);
qaTransmitModeSeparator->setVisible(false);
}

show();
activateWindow();

@@ -1011,6 +1051,25 @@ void MainWindow::on_qaSelfRegister_triggered() {
g.sh->registerUser(p->uiSession);
}

void MainWindow::qcbTransmitMode_activated(int index) {
switch(index) {
case 0: // Continuous
g.s.atTransmit = Settings::Continous;
g.l->log(Log::Information, tr("Transmit Mode set to Continous"));
return;

case 1: // Voice Activity
g.s.atTransmit = Settings::VAD;
g.l->log(Log::Information, tr("Transmit Mode set to Voice Activity"));
return;

case 2: // Push-to-Talk
g.s.atTransmit = Settings::PushToTalk;
g.l->log(Log::Information, tr("Transmit Mode set to Push-to-Talk"));
return;
}
}

void MainWindow::on_qmServer_aboutToShow() {
qmServer->clear();
qmServer->addAction(qaServerConnect);
@@ -2083,6 +2142,7 @@ void MainWindow::on_qaConfigDialog_triggered() {

if (dlg->exec() == QDialog::Accepted) {
setupView(false);
updateTransmitModeComboBox();
updateTrayIcon();

UserModel *um = static_cast<UserModel *>(qtvUsers->model());
@@ -2405,6 +2465,8 @@ void MainWindow::on_gsCycleTransmitMode_triggered(bool down, QVariant scdata)

g.l->log(Log::Information, tr("Cycled Transmit Mode to %1").arg(qsNewMode));
}

updateTransmitModeComboBox();
}

void MainWindow::whisperReleased(QVariant scdata) {
@@ -37,10 +37,12 @@
# include <QtCore/QPointer>
# include <QtWidgets/QMainWindow>
# include <QtWidgets/QSystemTrayIcon>
# include <QtWidgets/QComboBox>
#else
# include <QtCore/QWeakPointer>
# include <QtGui/QMainWindow>
# include <QtGui/QSystemTrayIcon>
# include <QtGui/QComboBox>
#endif

#include <QtNetwork/QAbstractSocket>
@@ -131,6 +133,7 @@ class MainWindow : public QMainWindow, public MessageHandler, public Ui::MainWin
void setOnTop(bool top);
void setShowDockTitleBars(bool doShow);
void updateTrayIcon();
void updateTransmitModeComboBox();
QPair<QByteArray, QImage> openImageFile();
static const QString defaultStyleSheet;

@@ -162,6 +165,10 @@ class MainWindow : public QMainWindow, public MessageHandler, public Ui::MainWin

PTTButtonWidget *qwPTTButtonWidget;

QComboBox *qcbTransmitMode;
QAction *qaTransmitMode;
QAction *qaTransmitModeSeparator;

void createActions();
void setupGui();
void customEvent(QEvent *evt) Q_DECL_OVERRIDE;
@@ -189,6 +196,7 @@ class MainWindow : public QMainWindow, public MessageHandler, public Ui::MainWin
void on_qmSelf_aboutToShow();
void on_qaSelfComment_triggered();
void on_qaSelfRegister_triggered();
void qcbTransmitMode_activated(int index);
void qmUser_aboutToShow();
void on_qaUserCommentReset_triggered();
void on_qaUserTextureReset_triggered();
@@ -364,6 +364,8 @@ Settings::Settings() {
iMaxImageHeight = 1024;
bSuppressIdentity = false;

bShowTransmitModeComboBox = false;

// Accessibility
bHighContrast = false;

@@ -675,6 +677,7 @@ void Settings::load(QSettings* settings_ptr) {
SAVELOAD(bShowContextMenuInMenuBar, "ui/showcontextmenuinmenubar");
SAVELOAD(qbaConnectDialogGeometry, "ui/connect/geometry");
SAVELOAD(qbaConnectDialogHeader, "ui/connect/header");
SAVELOAD(bShowTransmitModeComboBox, "ui/transmitmodecombobox");
SAVELOAD(bHighContrast, "ui/HighContrast");
SAVELOAD(iMaxLogBlocks, "ui/MaxLogBlocks");

@@ -966,6 +969,7 @@ void Settings::save() {
SAVELOAD(bShowContextMenuInMenuBar, "ui/showcontextmenuinmenubar");
SAVELOAD(qbaConnectDialogGeometry, "ui/connect/geometry");
SAVELOAD(qbaConnectDialogHeader, "ui/connect/header");
SAVELOAD(bShowTransmitModeComboBox, "ui/transmitmodecombobox");
SAVELOAD(bHighContrast, "ui/HighContrast");
SAVELOAD(iMaxLogBlocks, "ui/MaxLogBlocks");

@@ -298,6 +298,8 @@ struct Settings {
KeyPair kpCertificate;
bool bSuppressIdentity;

bool bShowTransmitModeComboBox;

// Accessibility
bool bHighContrast;

0 comments on commit 44dc94e

Please sign in to comment.
You can’t perform that action at this time.