mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Starting client activates existing instance if such exists
This commit is contained in:
parent
1ec67cb100
commit
beae534d66
@ -110,6 +110,7 @@ int main(int argc, char *argv[])
|
|||||||
IPC ipc;
|
IPC ipc;
|
||||||
ipc.registerEventHandler(&toxURIEventHandler);
|
ipc.registerEventHandler(&toxURIEventHandler);
|
||||||
ipc.registerEventHandler(&toxSaveEventHandler);
|
ipc.registerEventHandler(&toxSaveEventHandler);
|
||||||
|
ipc.registerEventHandler(&toxActivateEventHandler);
|
||||||
|
|
||||||
if (parser.positionalArguments().size() > 0)
|
if (parser.positionalArguments().size() > 0)
|
||||||
{
|
{
|
||||||
@ -152,6 +153,13 @@ int main(int argc, char *argv[])
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(!ipc.isCurrentOwner())
|
||||||
|
{
|
||||||
|
time_t event = ipc.postEvent("$activate");
|
||||||
|
ipc.waitUntilProcessed(event);
|
||||||
|
if (!ipc.isCurrentOwner())
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
// Run
|
// Run
|
||||||
Widget* w = Widget::getInstance();
|
Widget* w = Widget::getInstance();
|
||||||
|
@ -51,6 +51,14 @@
|
|||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
#include <tox/tox.h>
|
#include <tox/tox.h>
|
||||||
|
|
||||||
|
void toxActivateEventHandler(const QByteArray& data)
|
||||||
|
{
|
||||||
|
if(data != "$activate")
|
||||||
|
return;
|
||||||
|
Widget::getInstance()->show();
|
||||||
|
Widget::getInstance()->activateWindow();
|
||||||
|
}
|
||||||
|
|
||||||
Widget *Widget::instance{nullptr};
|
Widget *Widget::instance{nullptr};
|
||||||
|
|
||||||
Widget::Widget(QWidget *parent)
|
Widget::Widget(QWidget *parent)
|
||||||
@ -563,7 +571,10 @@ void Widget::onIconClick(QSystemTrayIcon::ActivationReason reason)
|
|||||||
switch (reason) {
|
switch (reason) {
|
||||||
case QSystemTrayIcon::Trigger:
|
case QSystemTrayIcon::Trigger:
|
||||||
if(this->isHidden() == true)
|
if(this->isHidden() == true)
|
||||||
|
{
|
||||||
this->show();
|
this->show();
|
||||||
|
this->activateWindow();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
this->hide();
|
this->hide();
|
||||||
case QSystemTrayIcon::DoubleClick:
|
case QSystemTrayIcon::DoubleClick:
|
||||||
|
@ -168,4 +168,6 @@ private:
|
|||||||
QTranslator* translator;
|
QTranslator* translator;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void toxActivateEventHandler(const QByteArray& data);
|
||||||
|
|
||||||
#endif // WIDGET_H
|
#endif // WIDGET_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user