YACReaderLibrary: Add a tray icon

This commit is contained in:
Felix Kauselmann 2018-02-17 13:40:04 +01:00
parent afab73cbc6
commit 1815ba64a1
2 changed files with 34 additions and 20 deletions

View File

@ -15,9 +15,6 @@
#include <QFileIconProvider>
#include <QMatrix>
#include <QSettings>
#ifndef NO_OPENGL
#include <QGLFormat>
#endif
#include <QHeaderView>
#include <iterator>
@ -88,10 +85,6 @@
#include <shellapi.h>
#endif
#ifdef Q_OS_MAC
//#include <QtMacExtras>
#endif
LibraryWindow::LibraryWindow()
:QMainWindow(),fullscreen(false),fetching(false),previousFilter(""),removeError(false),status(LibraryWindow::Normal)
{
@ -108,8 +101,6 @@ LibraryWindow::LibraryWindow()
showRootWidget();
selectedLibrary->setCurrentIndex(0);
}
}
void LibraryWindow::setupUI()
@ -147,18 +138,36 @@ void LibraryWindow::setupUI()
//if(settings->value(USE_OPEN_GL).toBool() == false)
showMaximized();
/*if(settings->contains(COMICS_VIEW_HEADERS_GEOMETRY))
comicsView->horizontalHeader()->restoreGeometry(settings->value(COMICS_VIEW_HEADERS_GEOMETRY).toByteArray());*/
trayIcon.setIcon(QApplication::windowIcon());
trayIcon.show();
connect(&trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
this, SLOT(trayActivation(QSystemTrayIcon::ActivationReason)));
}
/*socialDialog = new YACReaderSocialDialog(this);
socialDialog->setHidden(true);*/
void LibraryWindow::trayActivation(QSystemTrayIcon::ActivationReason reason)
{
if (reason == QSystemTrayIcon::Trigger)
{
setWindowState((windowState() & ~Qt::WindowMinimized));
show();
}
}
void LibraryWindow::changeEvent(QEvent *event)
{
if (event->type() == QEvent::WindowStateChange && isMinimized())
{
hide();
}
else
{
QMainWindow::changeEvent(event);
}
}
void LibraryWindow::doLayout()
{
//LAYOUT ELEMENTS------------------------------------------------------------
//---------------------------------------------------------------------------
QSplitter * sHorizontal = new QSplitter(Qt::Horizontal); //spliter principal
#ifdef Q_OS_MAC
sHorizontal->setStyleSheet("QSplitter::handle{image:none;background-color:#B8B8B8;} QSplitter::handle:vertical {height:1px;}");

View File

@ -5,6 +5,8 @@
#include <QMap>
#include <QModelIndex>
#include <QFileInfo>
#include <QSystemTrayIcon>
#include "yacreader_global_gui.h"
#include "yacreader_libraries.h"
@ -138,14 +140,14 @@ public:
bool fetching;
int i;
QAction * backAction;
QAction * forwardAction;
QAction * openComicAction;
QAction * createLibraryAction;
QAction * openLibraryAction;
QAction * exportComicsInfoAction;
QAction * importComicsInfoAction;
@ -377,14 +379,17 @@ public slots:
void saveSelectedCoversTo();
void checkMaxNumLibraries();
void changeEvent(QEvent *event);
private:
//fullscreen mode in Windows for preventing this bug: QTBUG-41309 https://bugreports.qt.io/browse/QTBUG-41309
Qt::WindowFlags previousWindowFlags;
QPoint previousPos;
QSize previousSize;
QSystemTrayIcon trayIcon;
private slots:
void trayActivation(QSystemTrayIcon::ActivationReason reason);
};
#endif