From cff159c8d84fd6f603ae0f2dbd36ffc5bf6acb90 Mon Sep 17 00:00:00 2001 From: Randy Baumgarte Date: Tue, 28 Sep 2010 21:08:06 -0400 Subject: [PATCH] Minimize to system tray if system tray icon is visible, otherwise minimize to the task bar. --- src/cx/fbn/nevernote/NeverNote.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/cx/fbn/nevernote/NeverNote.java b/src/cx/fbn/nevernote/NeverNote.java index 30a5cc7..0a09fcc 100644 --- a/src/cx/fbn/nevernote/NeverNote.java +++ b/src/cx/fbn/nevernote/NeverNote.java @@ -61,6 +61,7 @@ import com.trolltech.qt.core.QByteArray; import com.trolltech.qt.core.QDataStream; import com.trolltech.qt.core.QDateTime; import com.trolltech.qt.core.QDir; +import com.trolltech.qt.core.QEvent; import com.trolltech.qt.core.QFile; import com.trolltech.qt.core.QFileInfo; import com.trolltech.qt.core.QFileSystemWatcher; @@ -286,6 +287,7 @@ public class NeverNote extends QMainWindow{ boolean encryptOnShutdown; // should I encrypt when I close? boolean decryptOnShutdown; // should I decrypt on shutdown; String encryptCipher; // What cipher should I use? + Signal0 minimizeToTray; String iconPath = new String("classpath:cx/fbn/nevernote/icons/"); @@ -4898,7 +4900,19 @@ public class NeverNote extends QMainWindow{ } - + //************************************************* + //* Minimize to tray + //************************************************* + @Override + public void changeEvent(QEvent e) { + if (e.type() == QEvent.Type.WindowStateChange) { + if (isMinimized() && Global.showTrayIcon()) { + e.accept(); + QTimer.singleShot(200, this, "hide()"); + return; + } + } + } //************************************************* //* Check database userid & passwords -- 2.11.0