Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
linphone-desktop
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
linphone-desktop
Commits
ef3cbf50
Commit
ef3cbf50
authored
Aug 08, 2017
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(MessagesCountNotifier): use a blink in sys tray icon on GNU/Linux
parent
7fc1047e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
5 deletions
+38
-5
MessagesCountNotifierLinux.cpp
...re/messages-count-notifier/MessagesCountNotifierLinux.cpp
+31
-5
MessagesCountNotifierLinux.hpp
...re/messages-count-notifier/MessagesCountNotifierLinux.hpp
+7
-0
No files found.
src/components/core/messages-count-notifier/MessagesCountNotifierLinux.cpp
View file @
ef3cbf50
...
...
@@ -24,9 +24,11 @@
#include <QPainter>
#include <QSvgRenderer>
#include <QSystemTrayIcon>
#include <QTimer>
#include "../../../app/App.hpp"
#include "../../../utils/LinphoneUtils.hpp"
#include "../../../utils/Utils.hpp"
#include "MessagesCountNotifierLinux.hpp"
...
...
@@ -35,6 +37,7 @@
#define ICON_COUNTER_BACKGROUND_COLOR "#FF3C31"
#define ICON_COUNTER_BACKGROUND_RADIUS 100
#define ICON_COUNTER_BLINK_INTERVAL 1000
#define ICON_COUNTER_TEXT_COLOR "#FFFBFA"
#define ICON_COUNTER_TEXT_PIXEL_SIZE 144
...
...
@@ -52,10 +55,21 @@ MessagesCountNotifier::MessagesCountNotifier (QObject *parent) : AbstractMessage
renderer
.
render
(
&
painter
);
mBuf
=
new
QPixmap
(
buf
);
mBufWithCounter
=
new
QPixmap
();
mBlinkTimer
=
new
QTimer
(
this
);
mBlinkTimer
->
setInterval
(
ICON_COUNTER_BLINK_INTERVAL
);
QObject
::
connect
(
mBlinkTimer
,
&
QTimer
::
timeout
,
this
,
&
MessagesCountNotifier
::
update
);
Utils
::
connectOnce
(
App
::
getInstance
(),
&
App
::
focusWindowChanged
,
this
,
&
MessagesCountNotifier
::
updateUnreadMessagesCount
);
}
MessagesCountNotifier
::~
MessagesCountNotifier
()
{
delete
mBuf
;
delete
mBufWithCounter
;
}
void
MessagesCountNotifier
::
notifyUnreadMessagesCount
(
int
n
)
{
...
...
@@ -64,15 +78,16 @@ void MessagesCountNotifier::notifyUnreadMessagesCount (int n) {
return
;
if
(
!
n
)
{
mBlinkTimer
->
stop
();
sysTrayIcon
->
setIcon
(
QIcon
(
*
mBuf
));
return
;
}
QPixmap
buf
(
*
mBuf
)
;
QPainter
p
(
&
buf
);
*
mBufWithCounter
=
*
mBuf
;
QPainter
p
(
mBufWithCounter
);
const
int
width
=
buf
.
width
();
const
int
height
=
buf
.
height
();
const
int
width
=
mBufWithCounter
->
width
();
const
int
height
=
mBufWithCounter
->
height
();
// Draw background.
{
...
...
@@ -90,5 +105,16 @@ void MessagesCountNotifier::notifyUnreadMessagesCount (int n) {
p
.
drawText
(
QRect
(
0
,
0
,
width
,
height
),
Qt
::
AlignCenter
,
QString
::
number
(
n
));
}
sysTrayIcon
->
setIcon
(
QIcon
(
buf
));
// Change counter.
mBlinkTimer
->
stop
();
mBlinkTimer
->
start
();
mDisplayCounter
=
true
;
update
();
}
void
MessagesCountNotifier
::
update
()
{
QSystemTrayIcon
*
sysTrayIcon
=
App
::
getInstance
()
->
getSystemTrayIcon
();
Q_CHECK_PTR
(
sysTrayIcon
);
sysTrayIcon
->
setIcon
(
QIcon
(
mDisplayCounter
?
*
mBufWithCounter
:
*
mBuf
));
mDisplayCounter
=
!
mDisplayCounter
;
}
src/components/core/messages-count-notifier/MessagesCountNotifierLinux.hpp
View file @
ef3cbf50
...
...
@@ -24,6 +24,8 @@
// =============================================================================
class
QTimer
;
class
MessagesCountNotifier
:
public
AbstractMessagesCountNotifier
{
public:
MessagesCountNotifier
(
QObject
*
parent
=
Q_NULLPTR
);
...
...
@@ -33,5 +35,10 @@ protected:
void
notifyUnreadMessagesCount
(
int
n
)
override
;
private:
void
update
();
const
QPixmap
*
mBuf
=
nullptr
;
QPixmap
*
mBufWithCounter
=
nullptr
;
QTimer
*
mBlinkTimer
=
nullptr
;
bool
mDisplayCounter
=
false
;
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment