dglent / meteo-qt

System tray application for weather status information
GNU General Public License v3.0
82 stars 21 forks source link

allow initial panel visibility to be defined in the configuration file #79

Closed GiorgioGhisotti closed 5 years ago

GiorgioGhisotti commented 5 years ago

Hello,

I use i3wm and I noticed there isn't a convenient way to assign a shortcut to show the panel (at least as far as I could tell, please correct me if I'm wrong); I know this is usually handled by plasma, so I came up with a quick solution that doesn't require you to write an entire shortcut system.

Usually when I want a popup window I configure i3 to move it to the "scratchpad" workspace and assign a shortcut to move it to the current workspace. This can be done with any window as long as it has a unique name. All I need to make it completely automatic with meteo-qt is to make the panel visible by default.

I verified this to work by adding

start_minimized = self.settings.value('StartMinimized') or 'true'
if start_minimized == 'false':
            self.showpanel()

to the overviewcity method in the SystemTrayIcon class. Now I can set StartMinimized=false in meteo-qt.conf and the panel will be visible whenever I launch the program.

--edit-- The check would also need to be run whenever the widget is updated

GiorgioGhisotti commented 5 years ago

Here's a diff of my changes:

diff --git a/meteo_qt/meteo_qt.py b/meteo_qt/meteo_qt.py
index e012117..259f388 100644
--- a/meteo_qt/meteo_qt.py
+++ b/meteo_qt/meteo_qt.py
@@ -420,6 +420,13 @@ class SystemTrayIcon(QMainWindow):
         self.setWindowTitle(self.tr('Weather status'))
         self.restoreGeometry(self.settings.value("MainWindow/Geometry",
                                                  QByteArray()))
+##  Option to start with the panel closed, true by defaut
+#   starting with the panel open can be useful for users who don't have plasma
+#   installed (to set keyboard shortcuts or other default window behaviours)
+        start_minimized = self.settings.value('StartMinimized') or 'true'
+        if start_minimized == 'false':
+            self.showpanel()
+

     def daylight_delta(self, s1, s2):
         FMT = '%H:%M'
@@ -1655,10 +1662,14 @@ class SystemTrayIcon(QMainWindow):
         self.activate(3)

     def activate(self, reason):
+##  Option to start with the panel closed, true by defaut
+#   starting with the panel open can be useful for users who don't have plasma
+#   installed (to set keyboard shortcuts or other default window behaviours)
+        start_minimized = self.settings.value('StartMinimized') or 'true'
         if reason == 3:
             if self.inerror or self.id_ is None or self.id_ == '':
                 return
-            if self.isVisible():
+            if self.isVisible() and start_minimized == 'true':
                 self.hide()
             else:
                 self.show()
dglent commented 5 years ago

Hello

I will add this

Thanks

dglent commented 5 years ago

Could you check that this is the wanted behaviour ? https://github.com/dglent/meteo-qt/commit/f69ede290088b526fbf5d48db5b33cef770b6250

With the option unchecked, you cannot minimize the window to the tray at all.

GiorgioGhisotti commented 5 years ago

Yes, I confirm it works as I intended. I never need to minimize it (I hide the window through the window manager), but it may be a good idea to change it in some way that allows that in a future patch.