mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Fixed showing window when clicking tray icon / shortcut and window is minimized
Double-clicking tray icon shows window Middle-clicking tray icon hides window
This commit is contained in:
parent
fcd58b2c63
commit
3a5a94c666
|
@ -56,8 +56,7 @@ void toxActivateEventHandler(const QByteArray& data)
|
||||||
{
|
{
|
||||||
if (data != "$activate")
|
if (data != "$activate")
|
||||||
return;
|
return;
|
||||||
Widget::getInstance()->show();
|
Widget::getInstance()->forceShow();
|
||||||
Widget::getInstance()->activateWindow();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget *Widget::instance{nullptr};
|
Widget *Widget::instance{nullptr};
|
||||||
|
@ -113,7 +112,8 @@ void Widget::init()
|
||||||
this,
|
this,
|
||||||
SLOT(onIconClick(QSystemTrayIcon::ActivationReason)));
|
SLOT(onIconClick(QSystemTrayIcon::ActivationReason)));
|
||||||
|
|
||||||
if (Settings::getInstance().getShowSystemTray()){
|
if (Settings::getInstance().getShowSystemTray())
|
||||||
|
{
|
||||||
icon->show();
|
icon->show();
|
||||||
if (Settings::getInstance().getAutostartInTray() == false)
|
if (Settings::getInstance().getAutostartInTray() == false)
|
||||||
this->show();
|
this->show();
|
||||||
|
@ -570,6 +570,13 @@ void Widget::setWindowTitle(const QString& title)
|
||||||
QMainWindow::setWindowTitle("qTox - " + title);
|
QMainWindow::setWindowTitle("qTox - " + title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Widget::forceShow()
|
||||||
|
{
|
||||||
|
hide(); // Workaround to force minimized window to be restored
|
||||||
|
show();
|
||||||
|
activateWindow();
|
||||||
|
}
|
||||||
|
|
||||||
void Widget::onAddClicked()
|
void Widget::onAddClicked()
|
||||||
{
|
{
|
||||||
hideMainForms();
|
hideMainForms();
|
||||||
|
@ -592,21 +599,30 @@ void Widget::onTransferClicked()
|
||||||
|
|
||||||
void Widget::onIconClick(QSystemTrayIcon::ActivationReason reason)
|
void Widget::onIconClick(QSystemTrayIcon::ActivationReason reason)
|
||||||
{
|
{
|
||||||
switch (reason) {
|
switch (reason)
|
||||||
|
{
|
||||||
case QSystemTrayIcon::Trigger:
|
case QSystemTrayIcon::Trigger:
|
||||||
if (this->isHidden() == true)
|
|
||||||
{
|
{
|
||||||
this->show();
|
if (isHidden())
|
||||||
this->activateWindow();
|
{
|
||||||
|
show();
|
||||||
|
activateWindow();
|
||||||
|
}
|
||||||
|
else if (isMinimized() || !isActiveWindow())
|
||||||
|
forceShow();
|
||||||
|
else
|
||||||
|
hide();
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else
|
case QSystemTrayIcon::DoubleClick:
|
||||||
this->hide();
|
forceShow();
|
||||||
case QSystemTrayIcon::DoubleClick:
|
|
||||||
break;
|
break;
|
||||||
case QSystemTrayIcon::MiddleClick:
|
case QSystemTrayIcon::MiddleClick:
|
||||||
|
hide();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,6 +81,7 @@ public:
|
||||||
public slots:
|
public slots:
|
||||||
void onSettingsClicked();
|
void onSettingsClicked();
|
||||||
void setWindowTitle(const QString& title);
|
void setWindowTitle(const QString& title);
|
||||||
|
void forceShow();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void friendRequestAccepted(const QString& userId);
|
void friendRequestAccepted(const QString& userId);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user