1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

add logout action to tray menu

This commit is contained in:
agilob 2015-08-30 12:25:46 +01:00 committed by tux3
parent d6d5fd1c33
commit 7d579faf47
4 changed files with 22 additions and 9 deletions

View File

@ -251,7 +251,7 @@ void ProfileForm::onAvatarClicked()
return bytes;
};
QString filename = QFileDialog::getOpenFileName(0,
QString filename = QFileDialog::getOpenFileName(this,
tr("Choose a profile picture"),
QDir::homePath(),
Nexus::getSupportedImageFilter());
@ -291,8 +291,9 @@ void ProfileForm::onAvatarClicked()
// If this happens, you're really doing it on purpose.
if (bytes.size() > 65535)
{
QMessageBox::critical(this, tr("Error"),
tr("The supplied image is too large.\nPlease use another image."));
QMessageBox::critical(this,
tr("Error"),
tr("The supplied image is too large.\nPlease use another image."));
return;
}
@ -327,7 +328,8 @@ void ProfileForm::onRenameClicked()
void ProfileForm::onExportClicked()
{
QString current = Nexus::getProfile()->getName() + Core::TOX_EXT;
QString path = QFileDialog::getSaveFileName(0, tr("Export profile", "save dialog title"),
QString path = QFileDialog::getSaveFileName(this,
tr("Export profile", "save dialog title"),
QDir::home().filePath(current),
tr("Tox save file (*.tox)", "save dialog filter"));
if (!path.isEmpty())
@ -344,8 +346,9 @@ void ProfileForm::onExportClicked()
void ProfileForm::onDeleteClicked()
{
if (GUI::askQuestion(tr("Really delete profile?","deletion confirmation title"),
tr("Are you sure you want to delete this profile?","deletion confirmation text")))
if (GUI::askQuestion(
tr("Really delete profile?", "deletion confirmation title"),
tr("Are you sure you want to delete this profile?", "deletion confirmation text")))
{
Nexus& nexus = Nexus::getInstance();
nexus.getProfile()->remove();
@ -368,7 +371,8 @@ void ProfileForm::onCopyQrClicked()
void ProfileForm::onSaveQrClicked()
{
QString current = Nexus::getProfile()->getName() + ".png";
QString path = QFileDialog::getSaveFileName(0, tr("Save", "save qr image"),
QString path = QFileDialog::getSaveFileName(this,
tr("Save", "save qr image"),
QDir::home().filePath(current),
tr("Save QrCode (*.png)", "save dialog filter"));
if (!path.isEmpty())
@ -413,7 +417,7 @@ void ProfileForm::onChangePassClicked()
void ProfileForm::retranslateUi()
{
bodyUI->retranslateUi(this);
nameLabel->setText(QObject::tr("User Profile"));
nameLabel->setText(tr("User Profile"));
// We have to add the toxId tooltip here and not in the .ui or Qt won't know how to translate it dynamically
toxId->setToolTip(tr("This bunch of characters tells other Tox clients how to contact you.\nShare it with your friends to communicate."));
}

View File

@ -43,6 +43,7 @@ public:
signals:
void clicked();
protected:
virtual void mouseReleaseEvent(QMouseEvent*) final override {emit clicked();}
};
@ -63,6 +64,7 @@ signals:
public slots:
void onSelfAvatarLoaded(const QPixmap &pic);
void onLogoutClicked();
private slots:
void setToxId(const QString& id);
@ -72,7 +74,6 @@ private slots:
void onRenameClicked();
void onExportClicked();
void onDeleteClicked();
void onLogoutClicked();
void onCopyQrClicked();
void onSaveQrClicked();
void onDeletePassClicked();

View File

@ -1697,7 +1697,13 @@ void Widget::onTryCreateTrayIcon()
icon = new SystemTrayIcon();
updateIcons();
trayMenu = new QMenu(this);
QStyle *style = qApp->style();
actionLogout = new QAction(tr("&Logout"), this);
actionLogout->setIcon(style->standardIcon(QStyle::SP_BrowserStop));
connect(actionLogout, &QAction::triggered, profileForm, &ProfileForm::onLogoutClicked);
actionQuit = new QAction(tr("&Exit"), this);
actionQuit->setMenuRole(QAction::QuitRole);
actionQuit->setShortcut(QKeySequence::Quit); // system default quit shorcut
@ -1708,6 +1714,7 @@ void Widget::onTryCreateTrayIcon()
trayMenu->addAction(statusAway);
trayMenu->addAction(statusBusy);
trayMenu->addSeparator();
trayMenu->addAction(actionLogout);
trayMenu->addAction(actionQuit);
icon->setContextMenu(trayMenu);

View File

@ -228,6 +228,7 @@ private:
QAction *statusOnline;
QAction *statusAway;
QAction *statusBusy;
QAction *actionLogout;
QAction *actionQuit;
QMenu* filterMenu;