mirror of
https://github.com/YACReader/yacreader
synced 2025-05-28 03:10:27 -04:00
YACReaderLibrary: Add a tray icon
This commit is contained in:
parent
afab73cbc6
commit
1815ba64a1
@ -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;}");
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user