ChatBar: Always use the current channel by default

This commit is contained in:
Benjamin Jemlich 2012-05-31 12:48:39 +02:00
parent d7f03aba62
commit 441d06f6d1
8 changed files with 89 additions and 67 deletions

View File

@ -105,7 +105,7 @@ void ChatbarTextEdit::inFocus(bool focus) {
void ChatbarTextEdit::contextMenuEvent(QContextMenuEvent *qcme) { void ChatbarTextEdit::contextMenuEvent(QContextMenuEvent *qcme) {
QMenu *menu = createStandardContextMenu(); 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()); action->setEnabled(!QApplication::clipboard()->text().isEmpty());
connect(action, SIGNAL(triggered()), this, SLOT(pasteAndSend_triggered())); connect(action, SIGNAL(triggered()), this, SLOT(pasteAndSend_triggered()));
if (menu->actions().count() > 6) if (menu->actions().count() > 6)

View File

@ -133,6 +133,7 @@ void LookConfig::load(const Settings &r) {
loadCheckBox(qcbShowUserCount, r.bShowUserCount); loadCheckBox(qcbShowUserCount, r.bShowUserCount);
loadCheckBox(qcbShowContextMenuInMenuBar, r.bShowContextMenuInMenuBar); loadCheckBox(qcbShowContextMenuInMenuBar, r.bShowContextMenuInMenuBar);
loadCheckBox(qcbHighContrast, r.bHighContrast); loadCheckBox(qcbHighContrast, r.bHighContrast);
loadCheckBox(qcbChatBarUseSelection, r.bChatBarUseSelection);
} }
void LookConfig::save() const { void LookConfig::save() const {
@ -172,6 +173,7 @@ void LookConfig::save() const {
s.bShowUserCount = qcbShowUserCount->isChecked(); s.bShowUserCount = qcbShowUserCount->isChecked();
s.bShowContextMenuInMenuBar = qcbShowContextMenuInMenuBar->isChecked(); s.bShowContextMenuInMenuBar = qcbShowContextMenuInMenuBar->isChecked();
s.bHighContrast = qcbHighContrast->isChecked(); s.bHighContrast = qcbHighContrast->isChecked();
s.bChatBarUseSelection = qcbChatBarUseSelection->isChecked();
} }
void LookConfig::accept() const { void LookConfig::accept() const {

View File

@ -244,6 +244,67 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="2" column="1">
<widget class="QGroupBox" name="qgbTray">
<property name="title">
<string>Tray Icon</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="qcbHideTray">
<property name="toolTip">
<string>Hide the main Mumble window in the tray when it is minimized.</string>
</property>
<property name="whatsThis">
<string>&lt;b&gt;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.&lt;/b&gt;</string>
</property>
<property name="text">
<string>Hide in tray when minimized</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="qcbStateInTray">
<property name="toolTip">
<string>Displays talking status in system tray</string>
</property>
<property name="whatsThis">
<string/>
</property>
<property name="text">
<string>Show talking status in tray icon</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="5" column="1">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QGroupBox" name="qgbApplication"> <widget class="QGroupBox" name="qgbApplication">
<property name="title"> <property name="title">
@ -313,47 +374,12 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="2" column="1">
<widget class="QGroupBox" name="qgbTray">
<property name="title">
<string>Tray Icon</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="qcbHideTray">
<property name="toolTip">
<string>Hide the main Mumble window in the tray when it is minimized.</string>
</property>
<property name="whatsThis">
<string>&lt;b&gt;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.&lt;/b&gt;</string>
</property>
<property name="text">
<string>Hide in tray when minimized</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="qcbStateInTray">
<property name="toolTip">
<string>Displays talking status in system tray</string>
</property>
<property name="whatsThis">
<string/>
</property>
<property name="text">
<string>Show talking status in tray icon</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="3" column="1"> <item row="3" column="1">
<widget class="QGroupBox" name="qgbChannel"> <widget class="QGroupBox" name="qgbChannel">
<property name="title"> <property name="title">
<string>Channel Tree</string> <string>Channel Tree</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_2" columnstretch="0,1"> <layout class="QGridLayout" name="gridLayout_2" columnstretch="0,0">
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="qliChannelDrag"> <widget class="QLabel" name="qliChannelDrag">
<property name="text"> <property name="text">
@ -411,35 +437,16 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="0" colspan="2">
<widget class="QCheckBox" name="qcbChatBarUseSelection">
<property name="text">
<string>Use selected item as the chat bar target</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="5" column="1">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout> </layout>
</widget> </widget>
<resources/> <resources/>

View File

@ -1504,9 +1504,9 @@ void MainWindow::sendChatbarMessage(QString qsText) {
qsText = Qt::escape(qsText); qsText = Qt::escape(qsText);
qsText = TextMessage::autoFormat(qsText); qsText = TextMessage::autoFormat(qsText);
if (p == NULL || p->uiSession == g.uiSession) { if (!g.s.bChatBarUseSelection || p == NULL || p->uiSession == g.uiSession) {
// Channel message // 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; c = ClientUser::get(g.uiSession)->cChannel;
g.sh->sendChannelTextMessage(c->iId, qsText, false); 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 &) { void MainWindow::qtvUserCurrentChanged(const QModelIndex &, const QModelIndex &) {
updateChatBar();
}
void MainWindow::updateChatBar() {
User *p = pmModel->getUser(qtvUsers->currentIndex()); User *p = pmModel->getUser(qtvUsers->currentIndex());
Channel *c = pmModel->getChannel(qtvUsers->currentIndex()); Channel *c = pmModel->getChannel(qtvUsers->currentIndex());
if (g.uiSession == 0) { if (g.uiSession == 0) {
qteChat->setDefaultText(tr("<center>Not connected</center>"), true); qteChat->setDefaultText(tr("<center>Not connected</center>"), true);
} else if (p == NULL || p->uiSession == g.uiSession) { } else if (!g.s.bChatBarUseSelection || p == NULL || p->uiSession == g.uiSession) {
// Channel tree target // 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; c = ClientUser::get(g.uiSession)->cChannel;
qteChat->setDefaultText(tr("<center>Type message to channel '%1' here</center>").arg(c->qsName)); qteChat->setDefaultText(tr("<center>Type message to channel '%1' here</center>").arg(c->qsName));

View File

@ -116,6 +116,7 @@ class MainWindow : public QMainWindow, public MessageHandler, public Ui::MainWin
QPair<QByteArray, QImage> openImageFile(); QPair<QByteArray, QImage> openImageFile();
static const QString defaultStyleSheet; static const QString defaultStyleSheet;
void updateChatBar();
void openTextMessageDialog(ClientUser *p); void openTextMessageDialog(ClientUser *p);
#ifdef Q_OS_WIN #ifdef Q_OS_WIN

View File

@ -433,6 +433,10 @@ void MainWindow::msgUserState(const MumbleProto::UserState &msg) {
pmModel->moveUser(pDst, c); pmModel->moveUser(pDst, c);
if (pDst == pSelf) {
g.mw->updateChatBar();
}
if (log && (pDst != pSelf) && (pDst->cChannel == pSelf->cChannel)) { if (log && (pDst != pSelf) && (pDst->cChannel == pSelf->cChannel)) {
if (pDst == pSrc) if (pDst == pSrc)
g.l->log(Log::ChannelJoin, tr("%1 entered channel.").arg(Log::formatClientUser(pDst, Log::Target))); g.l->log(Log::ChannelJoin, tr("%1 entered channel.").arg(Log::formatClientUser(pDst, Log::Target)));

View File

@ -309,6 +309,7 @@ Settings::Settings() {
bStateInTray = true; bStateInTray = true;
bUsage = true; bUsage = true;
bShowUserCount = false; bShowUserCount = false;
bChatBarUseSelection = false;
wlWindowLayout = LayoutClassic; wlWindowLayout = LayoutClassic;
bShowContextMenuInMenuBar = false; bShowContextMenuInMenuBar = false;
@ -638,6 +639,7 @@ void Settings::load(QSettings* settings_ptr) {
SAVELOAD(bStateInTray, "ui/stateintray"); SAVELOAD(bStateInTray, "ui/stateintray");
SAVELOAD(bUsage, "ui/usage"); SAVELOAD(bUsage, "ui/usage");
SAVELOAD(bShowUserCount, "ui/showusercount"); SAVELOAD(bShowUserCount, "ui/showusercount");
SAVELOAD(bChatBarUseSelection, "ui/chatbaruseselection");
SAVELOAD(qsImagePath, "ui/imagepath"); SAVELOAD(qsImagePath, "ui/imagepath");
SAVELOAD(bShowContextMenuInMenuBar, "ui/showcontextmenuinmenubar"); SAVELOAD(bShowContextMenuInMenuBar, "ui/showcontextmenuinmenubar");
SAVELOAD(qbaConnectDialogGeometry, "ui/connect/geometry"); SAVELOAD(qbaConnectDialogGeometry, "ui/connect/geometry");
@ -911,6 +913,7 @@ void Settings::save() {
SAVELOAD(bStateInTray, "ui/stateintray"); SAVELOAD(bStateInTray, "ui/stateintray");
SAVELOAD(bUsage, "ui/usage"); SAVELOAD(bUsage, "ui/usage");
SAVELOAD(bShowUserCount, "ui/showusercount"); SAVELOAD(bShowUserCount, "ui/showusercount");
SAVELOAD(bChatBarUseSelection, "ui/chatbaruseselection");
SAVELOAD(qsImagePath, "ui/imagepath"); SAVELOAD(qsImagePath, "ui/imagepath");
SAVELOAD(bShowContextMenuInMenuBar, "ui/showcontextmenuinmenubar"); SAVELOAD(bShowContextMenuInMenuBar, "ui/showcontextmenuinmenubar");
SAVELOAD(qbaConnectDialogGeometry, "ui/connect/geometry"); SAVELOAD(qbaConnectDialogGeometry, "ui/connect/geometry");

View File

@ -248,6 +248,7 @@ struct Settings {
bool bStateInTray; bool bStateInTray;
bool bUsage; bool bUsage;
bool bShowUserCount; bool bShowUserCount;
bool bChatBarUseSelection;
QByteArray qbaConnectDialogHeader, qbaConnectDialogGeometry; QByteArray qbaConnectDialogHeader, qbaConnectDialogGeometry;
bool bShowContextMenuInMenuBar; bool bShowContextMenuInMenuBar;