mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Merge pull request #409 from agilob/trayicon
support for hiding in tray
This commit is contained in:
commit
f8057c8046
20
main.cpp
20
main.cpp
|
@ -19,6 +19,7 @@
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QFontDatabase>
|
#include <QFontDatabase>
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
|
#include <QSystemTrayIcon>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
|
@ -47,7 +48,24 @@ int main(int argc, char *argv[])
|
||||||
QFontDatabase::addApplicationFont("://DejaVuSans.ttf");
|
QFontDatabase::addApplicationFont("://DejaVuSans.ttf");
|
||||||
|
|
||||||
Widget* w = Widget::getInstance();
|
Widget* w = Widget::getInstance();
|
||||||
w->show();
|
if (QSystemTrayIcon::isSystemTrayAvailable() == false)
|
||||||
|
{
|
||||||
|
qWarning() << "No system tray detected!";
|
||||||
|
w->show();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QSystemTrayIcon *icon = new QSystemTrayIcon(w);
|
||||||
|
QObject::connect(icon,
|
||||||
|
SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
|
||||||
|
w,
|
||||||
|
SLOT(onIconClick()));
|
||||||
|
icon->setIcon(w->windowIcon());
|
||||||
|
icon->show();
|
||||||
|
if(Settings::getInstance().getAutostartInTray() == false)
|
||||||
|
w->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int errorcode = a.exec();
|
int errorcode = a.exec();
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/*
|
/*
|
||||||
Copyright (C) 2013 by Maxim Biro <nurupo.contributions@gmail.com>
|
Copyright (C) 2013 by Maxim Biro <nurupo.contributions@gmail.com>
|
||||||
|
|
||||||
This file is part of Tox Qt GUI.
|
This file is part of Tox Qt GUI.
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
@ -10,7 +10,7 @@
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
See the COPYING file for more details.
|
See the COPYING file for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -110,6 +110,7 @@ void Settings::load()
|
||||||
enableIPv6 = s.value("enableIPv6", true).toBool();
|
enableIPv6 = s.value("enableIPv6", true).toBool();
|
||||||
useTranslations = s.value("useTranslations", true).toBool();
|
useTranslations = s.value("useTranslations", true).toBool();
|
||||||
makeToxPortable = s.value("makeToxPortable", false).toBool();
|
makeToxPortable = s.value("makeToxPortable", false).toBool();
|
||||||
|
autostartInTray = s.value("autostartInTray", false).toBool();
|
||||||
forceTCP = s.value("forceTCP", false).toBool();
|
forceTCP = s.value("forceTCP", false).toBool();
|
||||||
useProxy = s.value("useProxy", false).toBool();
|
useProxy = s.value("useProxy", false).toBool();
|
||||||
proxyAddr = s.value("proxyAddr", "").toString();
|
proxyAddr = s.value("proxyAddr", "").toString();
|
||||||
|
@ -213,6 +214,7 @@ void Settings::save(QString path)
|
||||||
s.setValue("enableIPv6", enableIPv6);
|
s.setValue("enableIPv6", enableIPv6);
|
||||||
s.setValue("useTranslations",useTranslations);
|
s.setValue("useTranslations",useTranslations);
|
||||||
s.setValue("makeToxPortable",makeToxPortable);
|
s.setValue("makeToxPortable",makeToxPortable);
|
||||||
|
s.setValue("autostartInTray",autostartInTray);
|
||||||
s.setValue("useProxy", useProxy);
|
s.setValue("useProxy", useProxy);
|
||||||
s.setValue("forceTCP", forceTCP);
|
s.setValue("forceTCP", forceTCP);
|
||||||
s.setValue("proxyAddr", proxyAddr);
|
s.setValue("proxyAddr", proxyAddr);
|
||||||
|
@ -349,6 +351,16 @@ void Settings::setMakeToxPortable(bool newValue)
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Settings::getAutostartInTray() const
|
||||||
|
{
|
||||||
|
return autostartInTray;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::setAutostartInTray(bool newValue)
|
||||||
|
{
|
||||||
|
autostartInTray = newValue;
|
||||||
|
}
|
||||||
|
|
||||||
bool Settings::getUseTranslations() const
|
bool Settings::getUseTranslations() const
|
||||||
{
|
{
|
||||||
return useTranslations;
|
return useTranslations;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/*
|
/*
|
||||||
Copyright (C) 2013 by Maxim Biro <nurupo.contributions@gmail.com>
|
Copyright (C) 2013 by Maxim Biro <nurupo.contributions@gmail.com>
|
||||||
|
|
||||||
This file is part of Tox Qt GUI.
|
This file is part of Tox Qt GUI.
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
@ -10,7 +10,7 @@
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
See the COPYING file for more details.
|
See the COPYING file for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -49,12 +49,15 @@ public:
|
||||||
bool getMakeToxPortable() const;
|
bool getMakeToxPortable() const;
|
||||||
void setMakeToxPortable(bool newValue);
|
void setMakeToxPortable(bool newValue);
|
||||||
|
|
||||||
|
bool getAutostartInTray() const;
|
||||||
|
void setAutostartInTray(bool newValue);
|
||||||
|
|
||||||
bool getUseTranslations() const;
|
bool getUseTranslations() const;
|
||||||
void setUseTranslations(bool newValue);
|
void setUseTranslations(bool newValue);
|
||||||
|
|
||||||
bool getForceTCP() const;
|
bool getForceTCP() const;
|
||||||
void setForceTCP(bool newValue);
|
void setForceTCP(bool newValue);
|
||||||
|
|
||||||
QString getProxyAddr() const;
|
QString getProxyAddr() const;
|
||||||
void setProxyAddr(const QString& newValue);
|
void setProxyAddr(const QString& newValue);
|
||||||
|
|
||||||
|
@ -165,7 +168,8 @@ private:
|
||||||
bool enableIPv6;
|
bool enableIPv6;
|
||||||
bool useTranslations;
|
bool useTranslations;
|
||||||
static bool makeToxPortable;
|
static bool makeToxPortable;
|
||||||
|
bool autostartInTray;
|
||||||
|
|
||||||
bool forceTCP;
|
bool forceTCP;
|
||||||
|
|
||||||
bool useProxy;
|
bool useProxy;
|
||||||
|
|
|
@ -31,13 +31,14 @@ GeneralForm::GeneralForm() :
|
||||||
bodyUI->cbEnableIPv6->setChecked(Settings::getInstance().getEnableIPv6());
|
bodyUI->cbEnableIPv6->setChecked(Settings::getInstance().getEnableIPv6());
|
||||||
bodyUI->cbUseTranslations->setChecked(Settings::getInstance().getUseTranslations());
|
bodyUI->cbUseTranslations->setChecked(Settings::getInstance().getUseTranslations());
|
||||||
bodyUI->cbMakeToxPortable->setChecked(Settings::getInstance().getMakeToxPortable());
|
bodyUI->cbMakeToxPortable->setChecked(Settings::getInstance().getMakeToxPortable());
|
||||||
|
bodyUI->startInTray->setChecked(Settings::getInstance().getAutostartInTray());
|
||||||
|
|
||||||
for (auto entry : SmileyPack::listSmileyPacks())
|
for (auto entry : SmileyPack::listSmileyPacks())
|
||||||
{
|
{
|
||||||
bodyUI->smileyPackBrowser->addItem(entry.first, entry.second);
|
bodyUI->smileyPackBrowser->addItem(entry.first, entry.second);
|
||||||
}
|
}
|
||||||
bodyUI->smileyPackBrowser->setCurrentIndex(bodyUI->smileyPackBrowser->findData(Settings::getInstance().getSmileyPack()));
|
bodyUI->smileyPackBrowser->setCurrentIndex(bodyUI->smileyPackBrowser->findData(Settings::getInstance().getSmileyPack()));
|
||||||
|
|
||||||
bodyUI->cbUDPDisabled->setChecked(Settings::getInstance().getForceTCP());
|
bodyUI->cbUDPDisabled->setChecked(Settings::getInstance().getForceTCP());
|
||||||
bodyUI->proxyAddr->setText(Settings::getInstance().getProxyAddr());
|
bodyUI->proxyAddr->setText(Settings::getInstance().getProxyAddr());
|
||||||
int port = Settings::getInstance().getProxyPort();
|
int port = Settings::getInstance().getProxyPort();
|
||||||
|
@ -46,10 +47,11 @@ GeneralForm::GeneralForm() :
|
||||||
|
|
||||||
bodyUI->cbUseProxy->setChecked(Settings::getInstance().getUseProxy());
|
bodyUI->cbUseProxy->setChecked(Settings::getInstance().getUseProxy());
|
||||||
onUseProxyUpdated();
|
onUseProxyUpdated();
|
||||||
|
|
||||||
connect(bodyUI->cbEnableIPv6, &QCheckBox::stateChanged, this, &GeneralForm::onEnableIPv6Updated);
|
connect(bodyUI->cbEnableIPv6, &QCheckBox::stateChanged, this, &GeneralForm::onEnableIPv6Updated);
|
||||||
connect(bodyUI->cbUseTranslations, &QCheckBox::stateChanged, this, &GeneralForm::onUseTranslationUpdated);
|
connect(bodyUI->cbUseTranslations, &QCheckBox::stateChanged, this, &GeneralForm::onUseTranslationUpdated);
|
||||||
connect(bodyUI->cbMakeToxPortable, &QCheckBox::stateChanged, this, &GeneralForm::onMakeToxPortableUpdated);
|
connect(bodyUI->cbMakeToxPortable, &QCheckBox::stateChanged, this, &GeneralForm::onMakeToxPortableUpdated);
|
||||||
|
connect(bodyUI->startInTray, &QCheckBox::stateChanged, this, &GeneralForm::onSetAutostartInTray);
|
||||||
connect(bodyUI->smileyPackBrowser, SIGNAL(currentIndexChanged(int)), this, SLOT(onSmileyBrowserIndexChanged(int)));
|
connect(bodyUI->smileyPackBrowser, SIGNAL(currentIndexChanged(int)), this, SLOT(onSmileyBrowserIndexChanged(int)));
|
||||||
// new syntax can't handle overloaded signals... (at least not in a pretty way)
|
// new syntax can't handle overloaded signals... (at least not in a pretty way)
|
||||||
connect(bodyUI->cbUDPDisabled, &QCheckBox::stateChanged, this, &GeneralForm::onUDPUpdated);
|
connect(bodyUI->cbUDPDisabled, &QCheckBox::stateChanged, this, &GeneralForm::onUDPUpdated);
|
||||||
|
@ -78,6 +80,11 @@ void GeneralForm::onMakeToxPortableUpdated()
|
||||||
Settings::getInstance().setMakeToxPortable(bodyUI->cbMakeToxPortable->isChecked());
|
Settings::getInstance().setMakeToxPortable(bodyUI->cbMakeToxPortable->isChecked());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GeneralForm::onSetAutostartInTray()
|
||||||
|
{
|
||||||
|
Settings::getInstance().setAutostartInTray(bodyUI->startInTray->isChecked());
|
||||||
|
}
|
||||||
|
|
||||||
void GeneralForm::onSmileyBrowserIndexChanged(int index)
|
void GeneralForm::onSmileyBrowserIndexChanged(int index)
|
||||||
{
|
{
|
||||||
QString filename = bodyUI->smileyPackBrowser->itemData(index).toString();
|
QString filename = bodyUI->smileyPackBrowser->itemData(index).toString();
|
||||||
|
|
|
@ -36,6 +36,7 @@ private slots:
|
||||||
void onEnableIPv6Updated();
|
void onEnableIPv6Updated();
|
||||||
void onUseTranslationUpdated();
|
void onUseTranslationUpdated();
|
||||||
void onMakeToxPortableUpdated();
|
void onMakeToxPortableUpdated();
|
||||||
|
void onSetAutostartInTray();
|
||||||
void onSmileyBrowserIndexChanged(int index);
|
void onSmileyBrowserIndexChanged(int index);
|
||||||
void onUDPUpdated();
|
void onUDPUpdated();
|
||||||
void onProxyAddrEdited();
|
void onProxyAddrEdited();
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>527</width>
|
<width>527</width>
|
||||||
<height>367</height>
|
<height>369</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -46,6 +46,13 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="startInTray">
|
||||||
|
<property name="text">
|
||||||
|
<string>Start in tray</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
@ -344,6 +344,14 @@ void Widget::onTransferClicked()
|
||||||
activeChatroomWidget = nullptr;
|
activeChatroomWidget = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Widget::onIconClick()
|
||||||
|
{
|
||||||
|
if(this->isHidden() == true)
|
||||||
|
this->show();
|
||||||
|
else
|
||||||
|
this->hide();
|
||||||
|
}
|
||||||
|
|
||||||
void Widget::onSettingsClicked()
|
void Widget::onSettingsClicked()
|
||||||
{
|
{
|
||||||
hideMainForms();
|
hideMainForms();
|
||||||
|
|
|
@ -105,6 +105,7 @@ private slots:
|
||||||
void onMessageSendResult(int friendId, const QString& message, int messageId);
|
void onMessageSendResult(int friendId, const QString& message, int messageId);
|
||||||
void onGroupSendResult(int groupId, const QString& message, int result);
|
void onGroupSendResult(int groupId, const QString& message, int result);
|
||||||
void playRingtone();
|
void playRingtone();
|
||||||
|
void onIconClick();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void hideMainForms();
|
void hideMainForms();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user