Added newly sized pictures, Systemtrayicon now draws numbers. Some refactorings.
@ -276,8 +276,12 @@ if(WIN32)
|
||||
RUNTIME DESTINATION ./)
|
||||
install(DIRECTORY resources/graphics/themes/mini-oxygen
|
||||
DESTINATION ./themes)
|
||||
install(FILES resources/graphics/${APP_LOW_NAME}.png
|
||||
DESTINATION ./)
|
||||
install(FILES resources/graphics/${APP_LOW_NAME}_128.png
|
||||
DESTINATION ./
|
||||
RENAME ${APP_LOW_NAME}.png)
|
||||
install(FILES resources/graphics/${APP_LOW_NAME}_plain_128.png
|
||||
DESTINATION ./
|
||||
RENAME ${APP_LOW_NAME}_plain.png)
|
||||
install(FILES ${APP_QM}
|
||||
DESTINATION ./l10n)
|
||||
install(FILES ${APP_MISC}
|
||||
@ -290,8 +294,12 @@ elseif(UNIX)
|
||||
DESTINATION share/${APP_LOW_NAME}/themes)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/resources/desktop/${APP_LOW_NAME}.desktop
|
||||
DESTINATION share/applications)
|
||||
install(FILES resources/graphics/${APP_LOW_NAME}.png
|
||||
DESTINATION share/icons/hicolor/256x256/apps/)
|
||||
install(FILES resources/graphics/${APP_LOW_NAME}_128.png
|
||||
DESTINATION share/icons/hicolor/128x128/apps/
|
||||
RENAME ${APP_LOW_NAME}.png)
|
||||
install(FILES resources/graphics/${APP_LOW_NAME}_plain_128.png
|
||||
DESTINATION share/icons/hicolor/128x128/apps/
|
||||
RENAME ${APP_LOW_NAME}_plain.png)
|
||||
install(FILES ${APP_QM}
|
||||
DESTINATION share/${APP_LOW_NAME}/l10n)
|
||||
install(FILES ${APP_MISC}
|
||||
|
BIN
resources/graphics/rssguard_128.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
resources/graphics/rssguard_22.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
resources/graphics/rssguard_256.png
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
resources/graphics/rssguard_48.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 66 KiB |
BIN
resources/graphics/rssguard_64.png
Normal file
After Width: | Height: | Size: 5.0 KiB |
BIN
resources/graphics/rssguard_plain_128.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
@ -29,13 +29,15 @@
|
||||
#define APP_SKIN_PATH APP_PREFIX + QString("/share/rssguard/skins")
|
||||
#define APP_INFO_PATH APP_PREFIX + QString("/share/rssguard/information")
|
||||
#define APP_THEME_PATH APP_PREFIX + QString("/share/rssguard/themes")
|
||||
#define APP_ICON_PATH APP_PREFIX + QString("/share/icons/hicolor/256x256/apps/rssguard.png")
|
||||
#define APP_ICON_PATH APP_PREFIX + QString("/share/icons/hicolor/128x128/apps/@APP_LOW_NAME@.png")
|
||||
#define APP_ICON_PLAIN_PATH APP_PREFIX + QString("/share/icons/hicolor/128x128/apps/@APP_LOW_NAME@_plain.png")
|
||||
#elif defined(Q_OS_WIN)
|
||||
#define APP_LANG_PATH QApplication::applicationDirPath() + QString("/l10n")
|
||||
#define APP_SKIN_PATH QApplication::applicationDirPath() + QString("/skins")
|
||||
#define APP_INFO_PATH QApplication::applicationDirPath()
|
||||
#define APP_THEME_PATH QApplication::applicationDirPath() + QString("/themes")
|
||||
#define APP_ICON_PATH QApplication::applicationDirPath() + QString("/rssguard.png")
|
||||
#define APP_ICON_PATH QApplication::applicationDirPath() + QString("/@APP_LOW_NAME@.png")
|
||||
#define APP_ICON_PLAIN_PATH QApplication::applicationDirPath() + QString("/@APP_LOW_NAME@_plain.png")
|
||||
#endif
|
||||
|
||||
#endif // DEFS_H
|
||||
|
@ -24,7 +24,6 @@ FormMain::FormMain(QWidget *parent) : QMainWindow(parent), m_ui(new Ui::FormMain
|
||||
|
||||
// testing purposes
|
||||
SystemTrayIcon *icon = SystemTrayIcon::getInstance();
|
||||
icon->setIcon(QIcon(APP_ICON_PATH));
|
||||
icon->show();
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include <QPainter>
|
||||
|
||||
#include "gui/systemtrayicon.h"
|
||||
#include "gui/formmain.h"
|
||||
#include "core/settings.h"
|
||||
@ -6,8 +8,14 @@
|
||||
|
||||
QPointer<SystemTrayIcon> SystemTrayIcon::m_trayIcon;
|
||||
|
||||
SystemTrayIcon::SystemTrayIcon(QObject *parent) : QSystemTrayIcon(parent) {
|
||||
SystemTrayIcon::SystemTrayIcon(const QString &normal_icon,
|
||||
const QString &plain_icon,
|
||||
QObject *parent)
|
||||
: QSystemTrayIcon(parent), m_normalIcon(normal_icon), m_plainIcon(plain_icon) {
|
||||
qDebug("Creating SystemTrayIcon instance.");
|
||||
|
||||
// Initialize icon.
|
||||
setNumber();
|
||||
}
|
||||
|
||||
SystemTrayIcon::~SystemTrayIcon() {
|
||||
@ -26,9 +34,54 @@ bool SystemTrayIcon::isSystemTrayActivated() {
|
||||
|
||||
SystemTrayIcon *SystemTrayIcon::getInstance() {
|
||||
if (m_trayIcon.isNull()) {
|
||||
m_trayIcon = new SystemTrayIcon(FormMain::getInstance());
|
||||
m_trayIcon = new SystemTrayIcon(APP_ICON_PATH,
|
||||
APP_ICON_PLAIN_PATH,
|
||||
FormMain::getInstance());
|
||||
}
|
||||
|
||||
return m_trayIcon;
|
||||
}
|
||||
|
||||
void SystemTrayIcon::setNumber(int number) {
|
||||
if (number < 0) {
|
||||
QSystemTrayIcon::setIcon(QIcon(m_normalIcon));
|
||||
}
|
||||
else {
|
||||
QPixmap background = QPixmap(APP_ICON_PLAIN_PATH);
|
||||
QPainter trayPainter;
|
||||
QFont font = QFont();
|
||||
|
||||
font.setBold(true);
|
||||
trayPainter.begin(&background);
|
||||
trayPainter.setPen(Qt::black);
|
||||
|
||||
// Numbers with more than 2 digits won't be readable, display
|
||||
// infinity symbol in that case.
|
||||
if (number > 99) {
|
||||
font.setPixelSize(90);
|
||||
trayPainter.setFont(font);
|
||||
trayPainter.drawText(QRect(0, 0, 128, 128),
|
||||
Qt::AlignVCenter | Qt::AlignCenter ,
|
||||
"∞");
|
||||
}
|
||||
else {
|
||||
// Smaller number if it has 2 digits.
|
||||
if (number > 9) {
|
||||
font.setPixelSize(70);
|
||||
}
|
||||
// Bigger number if it has just one digit.
|
||||
else {
|
||||
font.setPixelSize(90);
|
||||
}
|
||||
|
||||
trayPainter.setFont(font);
|
||||
trayPainter.drawText(QRect(0, 0, 128, 128),
|
||||
Qt::AlignVCenter | Qt::AlignCenter ,
|
||||
QString::number(number));
|
||||
}
|
||||
|
||||
trayPainter.end();
|
||||
|
||||
QSystemTrayIcon::setIcon(QIcon(background));
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,9 @@
|
||||
class SystemTrayIcon : public QSystemTrayIcon {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SystemTrayIcon(QObject *parent = 0);
|
||||
explicit SystemTrayIcon(const QString &normal_icon,
|
||||
const QString &plain_icon,
|
||||
QObject *parent = 0);
|
||||
~SystemTrayIcon();
|
||||
|
||||
// Returns true if tray icon CAN be constructed on this machine.
|
||||
@ -22,6 +24,9 @@ class SystemTrayIcon : public QSystemTrayIcon {
|
||||
// WARNING: Use this in cooperation with SystemTrayIcon::isSystemTrayActivated().
|
||||
static SystemTrayIcon *getInstance();
|
||||
|
||||
// Sets the number to be visible in the tray icon, -1 removes it.
|
||||
void setNumber(int number = -1);
|
||||
|
||||
// TODO: Implement method for manual clearing of the tray icon. Creating of tray icon
|
||||
// handled by getInstance().
|
||||
signals:
|
||||
@ -29,6 +34,9 @@ class SystemTrayIcon : public QSystemTrayIcon {
|
||||
public slots:
|
||||
|
||||
private:
|
||||
QString m_normalIcon;
|
||||
QString m_plainIcon;
|
||||
|
||||
static QPointer<SystemTrayIcon> m_trayIcon;
|
||||
};
|
||||
|
||||
|
@ -68,6 +68,10 @@ QString ThemeFactory::getCurrentIconTheme() {
|
||||
return current_theme_name;
|
||||
}
|
||||
|
||||
QIcon ThemeFactory::fromTheme(const QString &name, const QIcon &fallback) {
|
||||
return QIcon::fromTheme(name, fallback);
|
||||
}
|
||||
|
||||
void ThemeFactory::setCurrentIconTheme(const QString &theme_name) {
|
||||
Settings::getInstance()->setValue(APP_CFG_GUI,
|
||||
"icon_theme",
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include <QString>
|
||||
#include <QEvent>
|
||||
#include <QIcon>
|
||||
|
||||
|
||||
class ThemeFactory {
|
||||
@ -35,6 +36,11 @@ class ThemeFactory {
|
||||
|
||||
// Sets icon theme with given name as the active one.
|
||||
static void setCurrentIconTheme(const QString &theme_name);
|
||||
|
||||
// Wrapper for QIcon::fromTheme.
|
||||
// If icon is not found in user-defined icon theme,
|
||||
// then it is searched in system-default theme (ThemeFactory::getSystemIconTheme()).
|
||||
static QIcon fromTheme(const QString & name, const QIcon & fallback = QIcon());
|
||||
};
|
||||
|
||||
class ThemeFactoryEvent : public QEvent {
|
||||
|
@ -50,7 +50,7 @@ int main(int argc, char *argv[]) {
|
||||
// This is useful for styles, encoders, ...
|
||||
// This is probably not needed on Windows or Linux, not sure about Mac OS X.
|
||||
#if defined(Q_OS_MAC)
|
||||
QApplication::addLibraryPath(APP_PLUGIN_PATH);
|
||||
QtSingleApplication::addLibraryPath(APP_PLUGIN_PATH);
|
||||
#endif
|
||||
|
||||
// Add an extra path for non-system icon themes.
|
||||
@ -64,7 +64,7 @@ int main(int argc, char *argv[]) {
|
||||
QtSingleApplication::setApplicationVersion(APP_VERSION);
|
||||
QtSingleApplication::setOrganizationName(APP_AUTHORS);
|
||||
QtSingleApplication::setOrganizationDomain(APP_URL);
|
||||
QtSingleApplication::setWindowIcon(QIcon(APP_INFO_PATH));
|
||||
QtSingleApplication::setWindowIcon(QIcon(APP_ICON_PATH));
|
||||
|
||||
// Instantiate main application window.
|
||||
FormMain window;
|
||||
|