Merge branch 'feature-embed' of github.com:Ximi1970/systray-x into feature-embed

This commit is contained in:
Ximi1970
2020-02-24 16:08:12 +01:00
4 changed files with 52 additions and 8 deletions

View File

@@ -8,7 +8,8 @@ The add-on and system tray application can do:
- display number of unread mails
- show / hide Thunderbird (minimize)
- minimizing hides to tray
- minimize on close
- minimize on close (Linux)
- to be implemented: minimize on close (Windows)
- to be implemented: start a new mail
- to be implemented: open the last used account

View File

@@ -35,8 +35,14 @@ unix:!macx: {
QMAKE_LFLAGS += -lX11
}
win32: {
LIBS += User32.lib
# QMAKE_LFLAGS += -static -lwinpthread -static-libgcc -static-libstdc++ $$(QMAKE_LFLAGS_WINDOWS)
#
# Windows host (not used in cross compiling with mingw on Linux)
#
contains(QMAKE_HOST.os, Windows): {
LIBS += User32.lib
}
}
unix:macx: {
QMAKE_LFLAGS += -framework IOKit -framework Foundation

View File

@@ -16,6 +16,8 @@
#include <QCloseEvent>
#include <QVBoxLayout>
#include <QWindow>
/*
* Constructor
*/
@@ -81,12 +83,34 @@ void Container::closeEvent( QCloseEvent *event )
}
}
#ifdef FF_NEET
bool Container::eventFilter( QObject* watched, QEvent* event )
{
if( event->type() == QEvent::WindowStateChange)
{
QWindowStateChangeEvent* e = static_cast<QWindowStateChangeEvent *>(event);
QWindow* window = reinterpret_cast<QWindow *>(watched);
if( ( window->windowState() == Qt::WindowMinimized )
&& ( e->oldState() != Qt::WindowMinimized ) )
{
// Restore old state
window->setWindowState( reinterpret_cast<QWindowStateChangeEvent *>(event)->oldState() );
return true;
}
}
// Do not filter event
return false;
}
#ifdef FF_NEET
/*
* Override the minimize event
*/
void Container::changeEvent( QEvent * event )
void Container::changeEvent( QEvent* event )
{
switch( event->type() )
{
@@ -94,8 +118,7 @@ void Container::changeEvent( QEvent * event )
{
if( isMinimized() )
{
setWindowState(reinterpret_cast<QWindowStateChangeEvent *>(event)->oldState());
event->accept();
hide();
}
break;
@@ -110,7 +133,6 @@ void Container::changeEvent( QEvent * event )
#endif
/**
* @brief slotMinimizeOnClose. Hnadle preference minimize on close signal.
*/

View File

@@ -42,6 +42,10 @@ class Container : public QWidget
*/
void removeWidget( QWidget* widget );
protected:
bool eventFilter( QObject* obj, QEvent* ev );
private:
/**
@@ -49,7 +53,18 @@ class Container : public QWidget
*
* @param event The event.
*/
void closeEvent( QCloseEvent *event );
void closeEvent( QCloseEvent* event );
#ifdef FF_NEET
/**
* @brief changeEvent. Override minimize event handler.
*
* @param event The event
*/
void changeEvent( QEvent* event );
#endif
signals: