1
0
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:
novist 2014-11-25 19:11:05 +02:00
parent 1ec67cb100
commit beae534d66
3 changed files with 22 additions and 1 deletions

View File

@ -110,6 +110,7 @@ int main(int argc, char *argv[])
IPC ipc;
ipc.registerEventHandler(&toxURIEventHandler);
ipc.registerEventHandler(&toxSaveEventHandler);
ipc.registerEventHandler(&toxActivateEventHandler);
if (parser.positionalArguments().size() > 0)
{
@ -152,6 +153,13 @@ int main(int argc, char *argv[])
return EXIT_FAILURE;
}
}
else if(!ipc.isCurrentOwner())
{
time_t event = ipc.postEvent("$activate");
ipc.waitUntilProcessed(event);
if (!ipc.isCurrentOwner())
return EXIT_SUCCESS;
}
// Run
Widget* w = Widget::getInstance();

View File

@ -51,6 +51,14 @@
#include <QTranslator>
#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(QWidget *parent)
@ -563,7 +571,10 @@ void Widget::onIconClick(QSystemTrayIcon::ActivationReason reason)
switch (reason) {
case QSystemTrayIcon::Trigger:
if(this->isHidden() == true)
{
this->show();
this->activateWindow();
}
else
this->hide();
case QSystemTrayIcon::DoubleClick:

View File

@ -168,4 +168,6 @@ private:
QTranslator* translator;
};
void toxActivateEventHandler(const QByteArray& data);
#endif // WIDGET_H