mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Tray icon notification of new messages
This commit is contained in:
parent
6c477a0a19
commit
b7dd4bf829
10
img/taskbar/dark/taskbar_event.svg
Normal file
10
img/taskbar/dark/taskbar_event.svg
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Generator: Adobe Illustrator 18.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||||
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||||
|
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||||
|
viewBox="0 0 16.1 16" enable-background="new 0 0 16.1 16" xml:space="preserve">
|
||||||
|
<path fill="#252325" d="M8,0C6.1,0,4.2,1.3,4.2,3.9v1.9h-1c-1.1,0-1.8,0.8-1.8,1.9v6.5c0,1.1,0.7,1.9,1.9,1.9l9.6,0
|
||||||
|
c1.1,0,1.9-0.8,1.9-1.9V7.6c0-1.1-0.8-1.9-1.9-1.9h-0.9l0-1.9C11.9,1.3,10,0,8,0z M8,1.6c1.3,0,2.2,1,2.2,2.2C10.3,5,9.8,6.2,8,6.9
|
||||||
|
c0.3-0.5,0.4-0.7,0.5-1.2C6.7,5.9,5.8,4.9,5.8,3.8S6.7,1.6,8,1.6z"/>
|
||||||
|
<path fill="#ff9400" d="M11.4,11c0,1.9-1.5,3.4-3.4,3.4c-1.9,0-3.4-1.5-3.4-3.4c0-1.9,1.5-3.4,3.4-3.4C9.9,7.6,11.4,9.1,11.4,11"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 885 B |
12
img/taskbar/light/taskbar_event.svg
Normal file
12
img/taskbar/light/taskbar_event.svg
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Generator: Adobe Illustrator 18.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||||
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||||
|
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||||
|
viewBox="0 0 16 16" enable-background="new 0 0 16 16" xml:space="preserve">
|
||||||
|
<g>
|
||||||
|
<path fill="#FFFFFF" d="M8,0C6.1,0,4.1,1.3,4.1,3.9v1.9h-1C2,5.7,1.3,6.5,1.3,7.6v6.5c0,1.1,0.7,1.9,1.9,1.9l9.6,0
|
||||||
|
c1.1,0,1.9-0.8,1.9-1.9V7.6c0-1.1-0.8-1.9-1.9-1.9h-0.9l0-1.9C11.9,1.3,9.9,0,8,0z M8,1.6c1.3,0,2.2,1,2.2,2.2
|
||||||
|
C10.2,5,9.7,6.2,8,6.9c0.3-0.5,0.4-0.7,0.5-1.2C6.7,5.9,5.8,4.9,5.8,3.8S6.7,1.6,8,1.6z"/>
|
||||||
|
<path fill="#ff9400" d="M11.4,11c0,1.9-1.5,3.4-3.4,3.4c-1.9,0-3.4-1.5-3.4-3.4c0-1.9,1.5-3.4,3.4-3.4C9.9,7.6,11.4,9.1,11.4,11"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 894 B |
2
res.qrc
2
res.qrc
@ -41,10 +41,12 @@
|
|||||||
<file>img/taskbar/dark/taskbar_away.svg</file>
|
<file>img/taskbar/dark/taskbar_away.svg</file>
|
||||||
<file>img/taskbar/dark/taskbar_busy.svg</file>
|
<file>img/taskbar/dark/taskbar_busy.svg</file>
|
||||||
<file>img/taskbar/dark/taskbar_offline.svg</file>
|
<file>img/taskbar/dark/taskbar_offline.svg</file>
|
||||||
|
<file>img/taskbar/dark/taskbar_event.svg</file>
|
||||||
<file>img/taskbar/light/taskbar_online.svg</file>
|
<file>img/taskbar/light/taskbar_online.svg</file>
|
||||||
<file>img/taskbar/light/taskbar_away.svg</file>
|
<file>img/taskbar/light/taskbar_away.svg</file>
|
||||||
<file>img/taskbar/light/taskbar_busy.svg</file>
|
<file>img/taskbar/light/taskbar_busy.svg</file>
|
||||||
<file>img/taskbar/light/taskbar_offline.svg</file>
|
<file>img/taskbar/light/taskbar_offline.svg</file>
|
||||||
|
<file>img/taskbar/light/taskbar_event.svg</file>
|
||||||
<file>img/transfer.png</file>
|
<file>img/transfer.png</file>
|
||||||
<file>smileys/cylgom/angel.png</file>
|
<file>smileys/cylgom/angel.png</file>
|
||||||
<file>smileys/cylgom/angry.png</file>
|
<file>smileys/cylgom/angry.png</file>
|
||||||
|
@ -65,7 +65,9 @@ Widget *Widget::instance{nullptr};
|
|||||||
Widget::Widget(QWidget *parent)
|
Widget::Widget(QWidget *parent)
|
||||||
: QMainWindow(parent),
|
: QMainWindow(parent),
|
||||||
ui(new Ui::MainWindow),
|
ui(new Ui::MainWindow),
|
||||||
activeChatroomWidget{nullptr}
|
activeChatroomWidget{nullptr},
|
||||||
|
eventFlag(false),
|
||||||
|
eventIcon(false)
|
||||||
{
|
{
|
||||||
translator = new QTranslator;
|
translator = new QTranslator;
|
||||||
setTranslation();
|
setTranslation();
|
||||||
@ -75,8 +77,8 @@ void Widget::init()
|
|||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
idleTimer = new QTimer();
|
timer = new QTimer();
|
||||||
idleTimer->start(1000);
|
timer->start(1000);
|
||||||
|
|
||||||
//restore window state
|
//restore window state
|
||||||
restoreGeometry(Settings::getInstance().getWindowGeometry());
|
restoreGeometry(Settings::getInstance().getWindowGeometry());
|
||||||
@ -265,7 +267,8 @@ void Widget::init()
|
|||||||
connect(setStatusAway, SIGNAL(triggered()), this, SLOT(setStatusAway()));
|
connect(setStatusAway, SIGNAL(triggered()), this, SLOT(setStatusAway()));
|
||||||
connect(setStatusBusy, SIGNAL(triggered()), this, SLOT(setStatusBusy()));
|
connect(setStatusBusy, SIGNAL(triggered()), this, SLOT(setStatusBusy()));
|
||||||
connect(addFriendForm, SIGNAL(friendRequested(QString, QString)), this, SIGNAL(friendRequested(QString, QString)));
|
connect(addFriendForm, SIGNAL(friendRequested(QString, QString)), this, SIGNAL(friendRequested(QString, QString)));
|
||||||
connect(idleTimer, &QTimer::timeout, this, &Widget::onUserAwayCheck);
|
connect(timer, &QTimer::timeout, this, &Widget::onUserAwayCheck);
|
||||||
|
connect(timer, &QTimer::timeout, this, &Widget::onEventIconTick);
|
||||||
|
|
||||||
coreThread->start();
|
coreThread->start();
|
||||||
|
|
||||||
@ -297,11 +300,15 @@ void Widget::setTranslation()
|
|||||||
|
|
||||||
void Widget::updateTrayIcon()
|
void Widget::updateTrayIcon()
|
||||||
{
|
{
|
||||||
if (!icon)
|
QString status;
|
||||||
return;
|
if (eventIcon)
|
||||||
QString status = ui->statusButton->property("status").toString();
|
status = "event";
|
||||||
if (!status.length())
|
else
|
||||||
status = "offline";
|
{
|
||||||
|
status = ui->statusButton->property("status").toString();
|
||||||
|
if (!status.length())
|
||||||
|
status = "offline";
|
||||||
|
}
|
||||||
QString color = Settings::getInstance().getLightTrayIcon() ? "light" : "dark";
|
QString color = Settings::getInstance().getLightTrayIcon() ? "light" : "dark";
|
||||||
QString pic = ":img/taskbar/" + color + "/taskbar_" + status + ".svg";
|
QString pic = ":img/taskbar/" + color + "/taskbar_" + status + ".svg";
|
||||||
icon->setIcon(QIcon(pic));
|
icon->setIcon(QIcon(pic));
|
||||||
@ -318,7 +325,7 @@ Widget::~Widget()
|
|||||||
delete settingsWidget;
|
delete settingsWidget;
|
||||||
delete addFriendForm;
|
delete addFriendForm;
|
||||||
delete filesForm;
|
delete filesForm;
|
||||||
delete idleTimer;
|
delete timer;
|
||||||
|
|
||||||
FriendList::clear();
|
FriendList::clear();
|
||||||
GroupList::clear();
|
GroupList::clear();
|
||||||
@ -413,11 +420,11 @@ QList<QString> Widget::searchProfiles()
|
|||||||
{
|
{
|
||||||
QList<QString> out;
|
QList<QString> out;
|
||||||
QDir dir(Settings::getSettingsDirPath());
|
QDir dir(Settings::getSettingsDirPath());
|
||||||
dir.setFilter(QDir::Files | QDir::NoDotAndDotDot);
|
dir.setFilter(QDir::Files | QDir::NoDotAndDotDot);
|
||||||
dir.setNameFilters(QStringList("*.tox"));
|
dir.setNameFilters(QStringList("*.tox"));
|
||||||
for (QFileInfo file : dir.entryInfoList())
|
for (QFileInfo file : dir.entryInfoList())
|
||||||
out += file.completeBaseName();
|
out += file.completeBaseName();
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Widget::askProfiles()
|
QString Widget::askProfiles()
|
||||||
@ -858,6 +865,9 @@ void Widget::newMessageAlert(GenericChatroomWidget* chat)
|
|||||||
|
|
||||||
QApplication::alert(this);
|
QApplication::alert(this);
|
||||||
|
|
||||||
|
if (inactiveWindow)
|
||||||
|
eventFlag = true;
|
||||||
|
|
||||||
if (Settings::getInstance().getShowWindow())
|
if (Settings::getInstance().getShowWindow())
|
||||||
{
|
{
|
||||||
show();
|
show();
|
||||||
@ -1097,20 +1107,20 @@ bool Widget::isFriendWidgetCurActiveWidget(Friend* f)
|
|||||||
|
|
||||||
bool Widget::event(QEvent * e)
|
bool Widget::event(QEvent * e)
|
||||||
{
|
{
|
||||||
switch(e->type()) {
|
switch(e->type())
|
||||||
|
{
|
||||||
case QEvent::WindowActivate:
|
case QEvent::WindowActivate:
|
||||||
if (activeChatroomWidget != nullptr)
|
if (activeChatroomWidget != nullptr)
|
||||||
{
|
{
|
||||||
activeChatroomWidget->resetEventFlags();
|
activeChatroomWidget->resetEventFlags();
|
||||||
activeChatroomWidget->updateStatusLight();
|
activeChatroomWidget->updateStatusLight();
|
||||||
}
|
}
|
||||||
case QEvent::MouseButtonPress:
|
if (eventFlag)
|
||||||
case QEvent::MouseButtonRelease:
|
{
|
||||||
case QEvent::Wheel:
|
eventFlag = false;
|
||||||
case QEvent::KeyPress:
|
eventIcon = false;
|
||||||
case QEvent::KeyRelease:
|
updateTrayIcon();
|
||||||
if (autoAwayActive)
|
}
|
||||||
onUserAwayCheck(); // Just so we get back from away faster when interacting with app
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1146,6 +1156,15 @@ void Widget::onUserAwayCheck()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Widget::onEventIconTick()
|
||||||
|
{
|
||||||
|
if (eventFlag)
|
||||||
|
{
|
||||||
|
eventIcon ^= true;
|
||||||
|
updateTrayIcon();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Widget::setStatusOnline()
|
void Widget::setStatusOnline()
|
||||||
{
|
{
|
||||||
core->setStatus(Status::Online);
|
core->setStatus(Status::Online);
|
||||||
|
@ -134,6 +134,7 @@ private slots:
|
|||||||
void playRingtone();
|
void playRingtone();
|
||||||
void onIconClick(QSystemTrayIcon::ActivationReason);
|
void onIconClick(QSystemTrayIcon::ActivationReason);
|
||||||
void onUserAwayCheck();
|
void onUserAwayCheck();
|
||||||
|
void onEventIconTick();
|
||||||
void getPassword(QString info, int passtype, uint8_t* salt);
|
void getPassword(QString info, int passtype, uint8_t* salt);
|
||||||
void onFriendTypingChanged(int friendId, bool isTyping);
|
void onFriendTypingChanged(int friendId, bool isTyping);
|
||||||
void onSetShowSystemTray(bool newValue);
|
void onSetShowSystemTray(bool newValue);
|
||||||
@ -172,9 +173,11 @@ private:
|
|||||||
bool notify(QObject *receiver, QEvent *event);
|
bool notify(QObject *receiver, QEvent *event);
|
||||||
bool autoAwayActive = false;
|
bool autoAwayActive = false;
|
||||||
Status beforeDisconnect = Status::Offline;
|
Status beforeDisconnect = Status::Offline;
|
||||||
QTimer* idleTimer;
|
QTimer* timer;
|
||||||
QTranslator* translator;
|
QTranslator* translator;
|
||||||
QRegExp nameMention, sanitizedNameMention;
|
QRegExp nameMention, sanitizedNameMention;
|
||||||
|
bool eventFlag;
|
||||||
|
bool eventIcon;
|
||||||
};
|
};
|
||||||
|
|
||||||
void toxActivateEventHandler(const QByteArray& data);
|
void toxActivateEventHandler(const QByteArray& data);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user