Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEAT(client): Move back to previous channel(s) #6674

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/updatetranslations.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def Update(lupdatebin, tsfile: str, debuglupdate: bool, applyHeuristics = True)
logging.error('lupdate failed with error code %d', res.returncode)
logging.debug('stdout: ' + res.stdout)
exit(1)
p = re.compile('Found (?P<nsrc>[0-9]+) source text\(s\) \((?P<nnew>[0-9]+) new and (?P<nsame>[0-9]+) already existing\)')
p = re.compile(r'Found (?P<nsrc>[0-9]+) source text\(s\) \((?P<nnew>[0-9]+) new and (?P<nsame>[0-9]+) already existing\)')
m = p.search(res.stdout.decode('ascii'))
logging.debug('Found %s texts where %s new and %s same', m.group('nsrc'), m.group('nnew'), m.group('nsame'))
return (m.group('nsrc'), m.group('nnew'), m.group('nsame'))
Expand Down
3 changes: 2 additions & 1 deletion src/mumble/GlobalShortcutTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ enum Type {
HelpAboutQt,
HelpVersionCheck,
TogglePositionalAudio,
MoveBack,
};

// A few assertions meant to catch, if anyone inserts a new value in-between instead of appending
Expand All @@ -66,7 +67,7 @@ static_assert(PushToTalk == 1, "You may only append to the end of the enum!");
static_assert(ToggleMinimalView == 9, "You may only append to the end of the enum!");
static_assert(ToggleSearch == 22, "You may only append to the end of the enum!");
static_assert(HelpVersionCheck == 43, "You may only append to the end of the enum!");
static_assert(TogglePositionalAudio == 44, "You may only append to the end of the enum!");
static_assert(MoveBack == 45, "You may only append to the end of the enum!");
} // namespace GlobalShortcutType

#endif // MUMBLE_MUMBLE_GLOBALSHORTCUTTYPES_H_
70 changes: 70 additions & 0 deletions src/mumble/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
#endif

#include <algorithm>
#include <optional>

MessageBoxEvent::MessageBoxEvent(QString m) : QEvent(static_cast< QEvent::Type >(MB_QEVENT)) {
msg = m;
Expand Down Expand Up @@ -424,6 +425,10 @@ void MainWindow::createActions() {
gsTogglePositionalAudio->setObjectName("gsTogglePositionalAudio");
gsTogglePositionalAudio->qsWhatsThis = tr("This will toggle positional audio on/off");

gsMoveBack = new GlobalShortcut(this, GlobalShortcutType::MoveBack, tr("Move back", "Global shortcut"));
gsMoveBack->setObjectName("gsMoveBack");
gsMoveBack->qsWhatsThis = tr("This will move you back into your previous channel");

#ifndef Q_OS_MAC
qstiIcon->show();
#endif
Expand Down Expand Up @@ -466,6 +471,7 @@ void MainWindow::setupGui() {
static_cast< void (UserModel::*)(const ClientUser *, const Channel *) >(&UserModel::removeChannelListener));
QObject::connect(Global::get().channelListenerManager.get(), &ChannelListenerManager::localVolumeAdjustmentsChanged,
pmModel, &UserModel::on_channelListenerLocalVolumeAdjustmentChanged);
QObject::connect(pmModel, &UserModel::userMoved, this, &MainWindow::on_user_moved);

// connect slots to PluginManager
QObject::connect(pmModel, &UserModel::userAdded, Global::get().pluginManager, &PluginManager::on_userAdded);
Expand Down Expand Up @@ -1174,6 +1180,57 @@ void MainWindow::enableRecording(bool recordingAllowed) {
}
}

void MainWindow::on_user_moved(unsigned int sessionID, const std::optional< unsigned int > &prevChannelID,
unsigned int newChannelID) {
if (sessionID == Global::get().uiSession && prevChannelID.has_value()) {
if (prevChannelID != m_movedBackFromChannel) {
// Add to stack of previous channels
m_previousChannels.push(prevChannelID.value());
qaMoveBack->setEnabled(true);
} else {
m_movedBackFromChannel.reset();
}
}

(void) newChannelID;
}

void MainWindow::on_qaMoveBack_triggered() {
if (m_previousChannels.empty()) {
return;
}

Channel *prevChannel = Channel::get(m_previousChannels.top());
m_previousChannels.pop();

if (!prevChannel) {
Global::get().l->log(Log::Warning,
tr("The channel you have been in previously no longer exists on this server."));
qaMoveBack->setEnabled(false);
return;
}

ClientUser *self = ClientUser::get(Global::get().uiSession);
if (!self) {
qaMoveBack->setEnabled(false);
return;
}

ServerHandlerPtr handler = Global::get().sh;
if (!handler) {
qaMoveBack->setEnabled(false);
return;
}

// Setting this prevents the user's current channel to be added to the stack
// of last visited channels. If it was added, the user could only ever cycle
// between the last channel and the current one.
m_movedBackFromChannel = self->cChannel->iId;
handler->joinChannel(Global::get().uiSession, prevChannel->iId);

qaMoveBack->setEnabled(!m_previousChannels.empty());
}

static void recreateServerHandler() {
ServerHandlerPtr sh = Global::get().sh;
if (sh && sh->isRunning()) {
Expand Down Expand Up @@ -3398,6 +3455,14 @@ void MainWindow::on_gsTogglePositionalAudio_triggered(bool down, QVariant) {
enablePositionalAudio(!Global::get().s.bPositionalAudio);
}

void MainWindow::on_gsMoveBack_triggered(bool down, QVariant) {
if (!down) {
return;
}

on_qaMoveBack_triggered();
}


void MainWindow::whisperReleased(QVariant scdata) {
if (Global::get().iPushToTalk <= 0)
Expand Down Expand Up @@ -3483,6 +3548,11 @@ void MainWindow::serverDisconnected(QAbstractSocket::SocketError err, QString re
// clear ChannelListener
Global::get().channelListenerManager->clear();

// Reset move-back history
qaMoveBack->setEnabled(false);
m_previousChannels = {};
m_movedBackFromChannel.reset();

Global::get().uiSession = 0;
Global::get().pPermissions = ChanACL::None;
Global::get().bAttenuateOthers = false;
Expand Down
11 changes: 11 additions & 0 deletions src/mumble/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
#include "Usage.h"
#include "UserLocalNicknameDialog.h"

#include <optional>
#include <stack>

#include "ui_MainWindow.h"

#define MB_QEVENT (QEvent::User + 939)
Expand Down Expand Up @@ -109,6 +112,7 @@ class MainWindow : public QMainWindow, public Ui::MainWindow {
GlobalShortcut *gsAudioTTS;
GlobalShortcut *gsHelpAbout, *gsHelpAboutQt, *gsHelpVersionCheck;
GlobalShortcut *gsTogglePositionalAudio;
GlobalShortcut *gsMoveBack;

DockTitleBar *dtbLogDockTitle, *dtbChatDockTitle;

Expand Down Expand Up @@ -197,6 +201,9 @@ class MainWindow : public QMainWindow, public Ui::MainWindow {
qt_unique_ptr< UserLocalVolumeSlider > m_userLocalVolumeSlider;
qt_unique_ptr< ListenerVolumeSlider > m_listenerVolumeSlider;

std::stack< unsigned int > m_previousChannels;
std::optional< unsigned int > m_movedBackFromChannel;

static constexpr int stateVersion();

void createActions();
Expand Down Expand Up @@ -345,6 +352,7 @@ public slots:
void on_gsHelpAboutQt_triggered(bool, QVariant);
void on_gsHelpVersionCheck_triggered(bool, QVariant);
void on_gsTogglePositionalAudio_triggered(bool, QVariant);
void on_gsMoveBack_triggered(bool, QVariant);

void on_Reconnect_timeout();
void on_Icon_activated(QSystemTrayIcon::ActivationReason);
Expand Down Expand Up @@ -394,6 +402,9 @@ public slots:
void toggleSearchDialogVisibility();
/// Enables or disables the recording feature
void enableRecording(bool recordingAllowed);
void on_user_moved(unsigned int sessionID, const std::optional< unsigned int > &prevChannelID,
unsigned int newChannelID);
void on_qaMoveBack_triggered();
signals:
/// Signal emitted when the server and the client have finished
/// synchronizing (after a new connection).
Expand Down
17 changes: 17 additions & 0 deletions src/mumble/MainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@
<addaction name="qaServerConnect"/>
<addaction name="qaServerInformation"/>
<addaction name="separator"/>
<addaction name="qaMoveBack"/>
<addaction name="separator"/>
<addaction name="qaAudioMute"/>
<addaction name="qaAudioDeaf"/>
<addaction name="qaRecording"/>
Expand Down Expand Up @@ -1071,6 +1073,21 @@ the channel's context menu.</string>
<string>Ctrl+F</string>
</property>
</action>
<action name="qaMoveBack">
<property name="enabled">
<bool>false</bool>
</property>
<property name="icon">
<iconset>
<normaloff>skin:arrow_left.svg</normaloff>skin:arrow_left.svg</iconset>
</property>
<property name="text">
<string>M&amp;ove back</string>
</property>
<property name="toolTip">
<string>Moves you back to the previous channel</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
Expand Down
2 changes: 2 additions & 0 deletions src/mumble/UserModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1128,6 +1128,8 @@ void UserModel::moveUser(ClientUser *p, Channel *np) {
ModelItem *pi = ModelItem::c_qhChannels.value(np);
ModelItem *item = ModelItem::c_qhUsers.value(p);

emit userMoved(p->uiSession, p->cChannel ? std::optional< unsigned int >(p->cChannel->iId) : std::nullopt, np->iId);

item = moveItem(opi, pi, item);

if (p->uiSession == Global::get().uiSession) {
Expand Down
8 changes: 8 additions & 0 deletions src/mumble/UserModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include <QtCore/QSet>
#include <QtGui/QIcon>

#include <optional>

class User;
class ClientUser;
class Channel;
Expand Down Expand Up @@ -218,6 +220,12 @@ public slots:
///
/// @param userSessionID The ID of that user's session
void userAdded(unsigned int userSessionID);
/// A signal emitted whenever a user has moved to a given channel
///
/// @param userSessionID The session ID of the moved user
/// @param prevChannelID The ID of the channel the user is moving from (if any)
/// @param newChannelID The ID of the channel the user has moved into
void userMoved(unsigned int userSessionID, std::optional< unsigned int > prevChannelID, unsigned int newChannelID);
/// A signal emitted whenever a user is removed from the model.
///
/// @param userSessionID The ID of that user's session
Expand Down
21 changes: 21 additions & 0 deletions src/mumble/mumble_ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7015,6 +7015,27 @@ Valid options are:
<source>This could be caused by one of the following scenarios:&lt;ul&gt;&lt;li&gt;Your client and the server use different encryption standards. This could be because you are using a very old client or the server you are connecting to is very old. In the first case, you should update your client and in the second case you should contact the server administrator so that they can update their server.&lt;/li&gt;&lt;li&gt;Either your client or the server is using an old operating system that doesn&apos;t provide up-to-date encryption methods. In this case you should consider updating your OS or contacting the server admin so that they can update theirs.&lt;/li&gt;&lt;li&gt;The server you are connecting to isn&apos;t actually a Mumble server. Please ensure that the used server address really belongs to a Mumble server and not e.g. to a game server.&lt;/li&gt;&lt;li&gt;The port you are connecting to does not belong to a Mumble server but instead is bound to a completely unrelated process on the server-side. Please double-check you have used the correct port.&lt;/li&gt;&lt;/ul&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>M&amp;ove back</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Moves you back to the previous channel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move back</source>
<comment>Global shortcut</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>This will move you back into your previous channel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The channel you have been in previously no longer exists on this server.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Manual</name>
Expand Down
21 changes: 21 additions & 0 deletions src/mumble/mumble_bg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7012,6 +7012,27 @@ Valid options are:
<source>This could be caused by one of the following scenarios:&lt;ul&gt;&lt;li&gt;Your client and the server use different encryption standards. This could be because you are using a very old client or the server you are connecting to is very old. In the first case, you should update your client and in the second case you should contact the server administrator so that they can update their server.&lt;/li&gt;&lt;li&gt;Either your client or the server is using an old operating system that doesn&apos;t provide up-to-date encryption methods. In this case you should consider updating your OS or contacting the server admin so that they can update theirs.&lt;/li&gt;&lt;li&gt;The server you are connecting to isn&apos;t actually a Mumble server. Please ensure that the used server address really belongs to a Mumble server and not e.g. to a game server.&lt;/li&gt;&lt;li&gt;The port you are connecting to does not belong to a Mumble server but instead is bound to a completely unrelated process on the server-side. Please double-check you have used the correct port.&lt;/li&gt;&lt;/ul&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>M&amp;ove back</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Moves you back to the previous channel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move back</source>
<comment>Global shortcut</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>This will move you back into your previous channel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The channel you have been in previously no longer exists on this server.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Manual</name>
Expand Down
21 changes: 21 additions & 0 deletions src/mumble/mumble_br.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7011,6 +7011,27 @@ Valid options are:
<source>This could be caused by one of the following scenarios:&lt;ul&gt;&lt;li&gt;Your client and the server use different encryption standards. This could be because you are using a very old client or the server you are connecting to is very old. In the first case, you should update your client and in the second case you should contact the server administrator so that they can update their server.&lt;/li&gt;&lt;li&gt;Either your client or the server is using an old operating system that doesn&apos;t provide up-to-date encryption methods. In this case you should consider updating your OS or contacting the server admin so that they can update theirs.&lt;/li&gt;&lt;li&gt;The server you are connecting to isn&apos;t actually a Mumble server. Please ensure that the used server address really belongs to a Mumble server and not e.g. to a game server.&lt;/li&gt;&lt;li&gt;The port you are connecting to does not belong to a Mumble server but instead is bound to a completely unrelated process on the server-side. Please double-check you have used the correct port.&lt;/li&gt;&lt;/ul&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>M&amp;ove back</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Moves you back to the previous channel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move back</source>
<comment>Global shortcut</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>This will move you back into your previous channel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The channel you have been in previously no longer exists on this server.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Manual</name>
Expand Down
21 changes: 21 additions & 0 deletions src/mumble/mumble_ca.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7165,6 +7165,27 @@ Les opcions vàlides són:
<source>This could be caused by one of the following scenarios:&lt;ul&gt;&lt;li&gt;Your client and the server use different encryption standards. This could be because you are using a very old client or the server you are connecting to is very old. In the first case, you should update your client and in the second case you should contact the server administrator so that they can update their server.&lt;/li&gt;&lt;li&gt;Either your client or the server is using an old operating system that doesn&apos;t provide up-to-date encryption methods. In this case you should consider updating your OS or contacting the server admin so that they can update theirs.&lt;/li&gt;&lt;li&gt;The server you are connecting to isn&apos;t actually a Mumble server. Please ensure that the used server address really belongs to a Mumble server and not e.g. to a game server.&lt;/li&gt;&lt;li&gt;The port you are connecting to does not belong to a Mumble server but instead is bound to a completely unrelated process on the server-side. Please double-check you have used the correct port.&lt;/li&gt;&lt;/ul&gt;</source>
<translation>La causa pot ser una de les següents:&lt;ul&gt;&lt;li&gt;El vostre client i el servidor fan servir estàndards d&apos;encriptació diferents. Potser el vostre client o el servidor són molt antics. En el primer cas, hauríeu d&apos;actualitzar el vostre client i en el segon cas hauríeu de contactar l&apos;administrador del servidor per que l&apos;actualitzi.&lt;/li&gt;&lt;li&gt;O bé el vostre client o el servidor estan utilitzant un sistema operatiu antic que no proporciona mètodes d&apos;encriptació actuals. En aquest cas hauríeu de considerar actualitzar el vostre sistema o contactar l&apos;administrador del servidor per que actualitzi el seu.&lt;/li&gt;&lt;li&gt;El servidor al que esteu connectat a no és de fet un Mumble servidor. Si us plau assegureu-vos que l&apos;adreça del servidor que utilitzeu correspon realment a un servidor Mumble, i no, per exemple, a un servidor de joc.&lt;/li&gt;&lt;li&gt;El port al que esteu connectat no pertany a un servidor Mumble servidor si no que està lligat a un procés sense cap relació amb el servidor lateral. Comproveu si us plau que utilitzeu el port correcte.&lt;/li&gt;&lt;/ul&gt;</translation>
</message>
<message>
<source>M&amp;ove back</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Moves you back to the previous channel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Move back</source>
<comment>Global shortcut</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>This will move you back into your previous channel</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The channel you have been in previously no longer exists on this server.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Manual</name>
Expand Down
Loading
Loading