1
0
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:
novist 2014-12-11 18:49:11 +02:00
parent 6c477a0a19
commit b7dd4bf829
5 changed files with 70 additions and 24 deletions

View 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

View 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

View File

@ -41,10 +41,12 @@
<file>img/taskbar/dark/taskbar_away.svg</file>
<file>img/taskbar/dark/taskbar_busy.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_away.svg</file>
<file>img/taskbar/light/taskbar_busy.svg</file>
<file>img/taskbar/light/taskbar_offline.svg</file>
<file>img/taskbar/light/taskbar_event.svg</file>
<file>img/transfer.png</file>
<file>smileys/cylgom/angel.png</file>
<file>smileys/cylgom/angry.png</file>

View File

@ -65,7 +65,9 @@ Widget *Widget::instance{nullptr};
Widget::Widget(QWidget *parent)
: QMainWindow(parent),
ui(new Ui::MainWindow),
activeChatroomWidget{nullptr}
activeChatroomWidget{nullptr},
eventFlag(false),
eventIcon(false)
{
translator = new QTranslator;
setTranslation();
@ -75,8 +77,8 @@ void Widget::init()
{
ui->setupUi(this);
idleTimer = new QTimer();
idleTimer->start(1000);
timer = new QTimer();
timer->start(1000);
//restore window state
restoreGeometry(Settings::getInstance().getWindowGeometry());
@ -265,7 +267,8 @@ void Widget::init()
connect(setStatusAway, SIGNAL(triggered()), this, SLOT(setStatusAway()));
connect(setStatusBusy, SIGNAL(triggered()), this, SLOT(setStatusBusy()));
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();
@ -297,11 +300,15 @@ void Widget::setTranslation()
void Widget::updateTrayIcon()
{
if (!icon)
return;
QString status = ui->statusButton->property("status").toString();
if (!status.length())
status = "offline";
QString status;
if (eventIcon)
status = "event";
else
{
status = ui->statusButton->property("status").toString();
if (!status.length())
status = "offline";
}
QString color = Settings::getInstance().getLightTrayIcon() ? "light" : "dark";
QString pic = ":img/taskbar/" + color + "/taskbar_" + status + ".svg";
icon->setIcon(QIcon(pic));
@ -318,7 +325,7 @@ Widget::~Widget()
delete settingsWidget;
delete addFriendForm;
delete filesForm;
delete idleTimer;
delete timer;
FriendList::clear();
GroupList::clear();
@ -413,11 +420,11 @@ QList<QString> Widget::searchProfiles()
{
QList<QString> out;
QDir dir(Settings::getSettingsDirPath());
dir.setFilter(QDir::Files | QDir::NoDotAndDotDot);
dir.setNameFilters(QStringList("*.tox"));
for (QFileInfo file : dir.entryInfoList())
out += file.completeBaseName();
return out;
dir.setFilter(QDir::Files | QDir::NoDotAndDotDot);
dir.setNameFilters(QStringList("*.tox"));
for (QFileInfo file : dir.entryInfoList())
out += file.completeBaseName();
return out;
}
QString Widget::askProfiles()
@ -858,6 +865,9 @@ void Widget::newMessageAlert(GenericChatroomWidget* chat)
QApplication::alert(this);
if (inactiveWindow)
eventFlag = true;
if (Settings::getInstance().getShowWindow())
{
show();
@ -1097,20 +1107,20 @@ bool Widget::isFriendWidgetCurActiveWidget(Friend* f)
bool Widget::event(QEvent * e)
{
switch(e->type()) {
switch(e->type())
{
case QEvent::WindowActivate:
if (activeChatroomWidget != nullptr)
{
activeChatroomWidget->resetEventFlags();
activeChatroomWidget->updateStatusLight();
}
case QEvent::MouseButtonPress:
case QEvent::MouseButtonRelease:
case QEvent::Wheel:
case QEvent::KeyPress:
case QEvent::KeyRelease:
if (autoAwayActive)
onUserAwayCheck(); // Just so we get back from away faster when interacting with app
if (eventFlag)
{
eventFlag = false;
eventIcon = false;
updateTrayIcon();
}
default:
break;
}
@ -1146,6 +1156,15 @@ void Widget::onUserAwayCheck()
#endif
}
void Widget::onEventIconTick()
{
if (eventFlag)
{
eventIcon ^= true;
updateTrayIcon();
}
}
void Widget::setStatusOnline()
{
core->setStatus(Status::Online);

View File

@ -134,6 +134,7 @@ private slots:
void playRingtone();
void onIconClick(QSystemTrayIcon::ActivationReason);
void onUserAwayCheck();
void onEventIconTick();
void getPassword(QString info, int passtype, uint8_t* salt);
void onFriendTypingChanged(int friendId, bool isTyping);
void onSetShowSystemTray(bool newValue);
@ -172,9 +173,11 @@ private:
bool notify(QObject *receiver, QEvent *event);
bool autoAwayActive = false;
Status beforeDisconnect = Status::Offline;
QTimer* idleTimer;
QTimer* timer;
QTranslator* translator;
QRegExp nameMention, sanitizedNameMention;
bool eventFlag;
bool eventIcon;
};
void toxActivateEventHandler(const QByteArray& data);