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
22c0987e
Commit
22c0987e
authored
Aug 08, 2017
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(app): add a message counter on sys tray icon (GNU/Linux)
parent
ca214de2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
70 additions
and
6 deletions
+70
-6
App.cpp
src/app/App.cpp
+2
-0
App.hpp
src/app/App.hpp
+7
-0
MessagesCountNotifierLinux.cpp
...re/messages-count-notifier/MessagesCountNotifierLinux.cpp
+59
-3
MessagesCountNotifierLinux.hpp
...re/messages-count-notifier/MessagesCountNotifierLinux.hpp
+2
-3
No files found.
src/app/App.cpp
View file @
22c0987e
...
@@ -474,6 +474,8 @@ void App::setTrayIcon () {
...
@@ -474,6 +474,8 @@ void App::setTrayIcon () {
systemTrayIcon
->
setIcon
(
QIcon
(
WINDOW_ICON_PATH
));
systemTrayIcon
->
setIcon
(
QIcon
(
WINDOW_ICON_PATH
));
systemTrayIcon
->
setToolTip
(
"Linphone"
);
systemTrayIcon
->
setToolTip
(
"Linphone"
);
systemTrayIcon
->
show
();
systemTrayIcon
->
show
();
mSystemTrayIcon
=
systemTrayIcon
;
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
...
...
src/app/App.hpp
View file @
22c0987e
...
@@ -35,6 +35,7 @@
...
@@ -35,6 +35,7 @@
// =============================================================================
// =============================================================================
class
QCommandLineParser
;
class
QCommandLineParser
;
class
QSystemTrayIcon
;
class
Cli
;
class
Cli
;
class
DefaultTranslator
;
class
DefaultTranslator
;
...
@@ -72,6 +73,10 @@ public:
...
@@ -72,6 +73,10 @@ public:
return
mColors
;
return
mColors
;
}
}
QSystemTrayIcon
*
getSystemTrayIcon
()
const
{
return
mSystemTrayIcon
;
}
QQuickWindow
*
getMainWindow
()
const
;
QQuickWindow
*
getMainWindow
()
const
;
bool
hasFocus
()
const
;
bool
hasFocus
()
const
;
...
@@ -137,6 +142,8 @@ private:
...
@@ -137,6 +142,8 @@ private:
Colors
*
mColors
=
nullptr
;
Colors
*
mColors
=
nullptr
;
QSystemTrayIcon
*
mSystemTrayIcon
=
nullptr
;
Cli
*
mCli
=
nullptr
;
Cli
*
mCli
=
nullptr
;
};
};
...
...
src/components/core/messages-count-notifier/MessagesCountNotifierLinux.cpp
View file @
22c0987e
...
@@ -20,19 +20,75 @@
...
@@ -20,19 +20,75 @@
* Author: Ronan Abhamon
* Author: Ronan Abhamon
*/
*/
#include <QIcon>
#include <QPainter>
#include <QSvgRenderer>
#include <QSvgRenderer>
#include <QSystemTrayIcon>
#include "../../../app/App.hpp"
#include "../../../utils/LinphoneUtils.hpp"
#include "../../../utils/LinphoneUtils.hpp"
#include "MessagesCountNotifierLinux.hpp"
#include "MessagesCountNotifierLinux.hpp"
#define ICON_WIDTH 256
#define ICON_HEIGHT 256
#define ICON_COUNTER_BACKGROUND_COLOR "#FF3C31"
#define ICON_COUNTER_BACKGROUND_RADIUS 100
#define ICON_COUNTER_TEXT_COLOR "#FFFBFA"
#define ICON_COUNTER_TEXT_PIXEL_SIZE 144
// =============================================================================
// =============================================================================
MessagesCountNotifier
::
MessagesCountNotifier
(
QObject
*
parent
)
:
AbstractMessagesCountNotifier
(
parent
)
{
MessagesCountNotifier
::
MessagesCountNotifier
(
QObject
*
parent
)
:
AbstractMessagesCountNotifier
(
parent
)
{
mSvgRenderer
=
new
QSvgRenderer
(
QStringLiteral
(
WINDOW_ICON_PATH
),
this
);
QSvgRenderer
renderer
(
QStringLiteral
(
WINDOW_ICON_PATH
));
if
(
!
renderer
.
isValid
())
qFatal
(
"Invalid SVG Image."
);
QPixmap
buf
(
ICON_WIDTH
,
ICON_HEIGHT
);
buf
.
fill
(
QColor
(
Qt
::
transparent
));
QPainter
painter
(
&
buf
);
renderer
.
render
(
&
painter
);
mBuf
=
new
QPixmap
(
buf
);
}
MessagesCountNotifier
::~
MessagesCountNotifier
()
{
delete
mBuf
;
}
}
void
MessagesCountNotifier
::
notifyUnreadMessagesCount
(
int
n
)
{
void
MessagesCountNotifier
::
notifyUnreadMessagesCount
(
int
n
)
{
// TODO.
QSystemTrayIcon
*
sysTrayIcon
=
App
::
getInstance
()
->
getSystemTrayIcon
();
(
void
)
n
;
if
(
!
sysTrayIcon
)
return
;
if
(
!
n
)
{
sysTrayIcon
->
setIcon
(
QIcon
(
*
mBuf
));
return
;
}
QPixmap
buf
(
*
mBuf
);
QPainter
p
(
&
buf
);
const
int
width
=
buf
.
width
();
const
int
height
=
buf
.
height
();
// Draw background.
{
p
.
setBrush
(
QColor
(
ICON_COUNTER_BACKGROUND_COLOR
));
p
.
drawEllipse
(
QPointF
(
width
/
2
,
height
/
2
),
ICON_COUNTER_BACKGROUND_RADIUS
,
ICON_COUNTER_BACKGROUND_RADIUS
);
}
// Draw text.
{
QFont
font
=
p
.
font
();
font
.
setPixelSize
(
ICON_COUNTER_TEXT_PIXEL_SIZE
);
p
.
setFont
(
font
);
p
.
setPen
(
QPen
(
QColor
(
ICON_COUNTER_TEXT_COLOR
),
1
));
p
.
drawText
(
QRect
(
0
,
0
,
width
,
height
),
Qt
::
AlignCenter
,
QString
::
number
(
n
));
}
sysTrayIcon
->
setIcon
(
QIcon
(
buf
));
}
}
src/components/core/messages-count-notifier/MessagesCountNotifierLinux.hpp
View file @
22c0987e
...
@@ -24,15 +24,14 @@
...
@@ -24,15 +24,14 @@
// =============================================================================
// =============================================================================
class
QSvgRenderer
;
class
MessagesCountNotifier
:
public
AbstractMessagesCountNotifier
{
class
MessagesCountNotifier
:
public
AbstractMessagesCountNotifier
{
public:
public:
MessagesCountNotifier
(
QObject
*
parent
=
Q_NULLPTR
);
MessagesCountNotifier
(
QObject
*
parent
=
Q_NULLPTR
);
~
MessagesCountNotifier
();
protected:
protected:
void
notifyUnreadMessagesCount
(
int
n
)
override
;
void
notifyUnreadMessagesCount
(
int
n
)
override
;
private:
private:
QSvgRenderer
*
mSvgRenderer
=
nullptr
;
const
QPixmap
*
mBuf
=
nullptr
;
};
};
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