@@ -21,6 +21,3 @@ Claudia: | |||||
PatchCanvas: | PatchCanvas: | ||||
- Implement export to Catarina file | - Implement export to Catarina file | ||||
Systray: | |||||
- Implement hide-on-close |
@@ -7,7 +7,7 @@ | |||||
<x>0</x> | <x>0</x> | ||||
<y>0</y> | <y>0</y> | ||||
<width>739</width> | <width>739</width> | ||||
<height>549</height> | |||||
<height>529</height> | |||||
</rect> | </rect> | ||||
</property> | </property> | ||||
<property name="windowTitle"> | <property name="windowTitle"> | ||||
@@ -515,7 +515,7 @@ | |||||
<x>0</x> | <x>0</x> | ||||
<y>0</y> | <y>0</y> | ||||
<width>366</width> | <width>366</width> | ||||
<height>120</height> | |||||
<height>100</height> | |||||
</rect> | </rect> | ||||
</property> | </property> | ||||
<attribute name="label"> | <attribute name="label"> | ||||
@@ -663,7 +663,7 @@ | |||||
<x>0</x> | <x>0</x> | ||||
<y>0</y> | <y>0</y> | ||||
<width>366</width> | <width>366</width> | ||||
<height>117</height> | |||||
<height>97</height> | |||||
</rect> | </rect> | ||||
</property> | </property> | ||||
<attribute name="label"> | <attribute name="label"> | ||||
@@ -804,7 +804,7 @@ | |||||
<x>0</x> | <x>0</x> | ||||
<y>0</y> | <y>0</y> | ||||
<width>366</width> | <width>366</width> | ||||
<height>117</height> | |||||
<height>97</height> | |||||
</rect> | </rect> | ||||
</property> | </property> | ||||
<attribute name="label"> | <attribute name="label"> | ||||
@@ -1511,7 +1511,7 @@ | |||||
<rect> | <rect> | ||||
<x>0</x> | <x>0</x> | ||||
<y>0</y> | <y>0</y> | ||||
<width>76</width> | |||||
<width>94</width> | |||||
<height>76</height> | <height>76</height> | ||||
</rect> | </rect> | ||||
</property> | </property> | ||||
@@ -1529,7 +1529,7 @@ | |||||
<rect> | <rect> | ||||
<x>0</x> | <x>0</x> | ||||
<y>0</y> | <y>0</y> | ||||
<width>89</width> | |||||
<width>94</width> | |||||
<height>76</height> | <height>76</height> | ||||
</rect> | </rect> | ||||
</property> | </property> | ||||
@@ -1547,7 +1547,7 @@ | |||||
<rect> | <rect> | ||||
<x>0</x> | <x>0</x> | ||||
<y>0</y> | <y>0</y> | ||||
<width>89</width> | |||||
<width>94</width> | |||||
<height>76</height> | <height>76</height> | ||||
</rect> | </rect> | ||||
</property> | </property> | ||||
@@ -1565,7 +1565,7 @@ | |||||
<rect> | <rect> | ||||
<x>0</x> | <x>0</x> | ||||
<y>0</y> | <y>0</y> | ||||
<width>89</width> | |||||
<width>94</width> | |||||
<height>76</height> | <height>76</height> | ||||
</rect> | </rect> | ||||
</property> | </property> | ||||
@@ -2066,14 +2066,6 @@ Default is off</string> | |||||
</item> | </item> | ||||
</layout> | </layout> | ||||
</widget> | </widget> | ||||
<action name="act_quit"> | |||||
<property name="text"> | |||||
<string>&Quit</string> | |||||
</property> | |||||
<property name="shortcut"> | |||||
<string>Ctrl+Q</string> | |||||
</property> | |||||
</action> | |||||
</widget> | </widget> | ||||
<customwidgets> | <customwidgets> | ||||
<customwidget> | <customwidget> | ||||
@@ -2087,22 +2079,6 @@ Default is off</string> | |||||
<include location="../resources.qrc"/> | <include location="../resources.qrc"/> | ||||
</resources> | </resources> | ||||
<connections> | <connections> | ||||
<connection> | |||||
<sender>act_quit</sender> | |||||
<signal>triggered()</signal> | |||||
<receiver>CadenceMainW</receiver> | |||||
<slot>close()</slot> | |||||
<hints> | |||||
<hint type="sourcelabel"> | |||||
<x>-1</x> | |||||
<y>-1</y> | |||||
</hint> | |||||
<hint type="destinationlabel"> | |||||
<x>399</x> | |||||
<y>299</y> | |||||
</hint> | |||||
</hints> | |||||
</connection> | |||||
<connection> | <connection> | ||||
<sender>tw_tweaks</sender> | <sender>tw_tweaks</sender> | ||||
<signal>currentCellChanged(int,int,int,int)</signal> | <signal>currentCellChanged(int,int,int,int)</signal> | ||||
@@ -2052,11 +2052,6 @@ class CadenceMainW(QMainWindow, ui_cadence.Ui_CadenceMainW): | |||||
if geometry: | if geometry: | ||||
self.restoreGeometry(self.settings.value("Geometry", "")) | self.restoreGeometry(self.settings.value("Geometry", "")) | ||||
self.m_savedSettings = { | |||||
"Main/UseSystemTray": self.settings.value("Main/UseSystemTray", True, type=bool), | |||||
"Main/CloseToTray": self.settings.value("Main/CloseToTray", True, type=bool) | |||||
} | |||||
self.cb_jack_autostart.setChecked(GlobalSettings.value("JACK/AutoStart", True, type=bool)) | self.cb_jack_autostart.setChecked(GlobalSettings.value("JACK/AutoStart", True, type=bool)) | ||||
self.cb_a2j_autostart.setChecked(GlobalSettings.value("A2J/AutoStart", True, type=bool)) | self.cb_a2j_autostart.setChecked(GlobalSettings.value("A2J/AutoStart", True, type=bool)) | ||||
self.cb_pulse_autostart.setChecked(GlobalSettings.value("Pulse2JACK/AutoStart", havePulseAudio, type=bool)) | self.cb_pulse_autostart.setChecked(GlobalSettings.value("Pulse2JACK/AutoStart", havePulseAudio, type=bool)) | ||||
@@ -2097,8 +2092,7 @@ class CadenceMainW(QMainWindow, ui_cadence.Ui_CadenceMainW): | |||||
def closeEvent(self, event): | def closeEvent(self, event): | ||||
self.saveSettings() | self.saveSettings() | ||||
self.systray.close() | |||||
QMainWindow.closeEvent(self, event) | |||||
self.systray.handleQtCloseEvent(event) | |||||
#--------------- main ------------------ | #--------------- main ------------------ | ||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
@@ -2494,11 +2494,10 @@ class ClaudiaMainW(QMainWindow, ui_claudia.Ui_ClaudiaMainW): | |||||
def closeEvent(self, event): | def closeEvent(self, event): | ||||
self.saveSettings() | self.saveSettings() | ||||
if self.systray: | if self.systray: | ||||
#if self.saved_settings["Main/CloseToTray"] and self.systray.isTrayAvailable() and self.isVisible(): | |||||
#self.hide() | |||||
#self.systray.setActionText("show", QStringStr(gui.tr("Restore"))) | |||||
#event.ignore() | |||||
#return | |||||
if self.m_savedSettings["Main/CloseToTray"]: | |||||
if self.systray.handleQtCloseEvent(event): | |||||
patchcanvas.clear() | |||||
return | |||||
self.systray.close() | self.systray.close() | ||||
patchcanvas.clear() | patchcanvas.clear() | ||||
QMainWindow.closeEvent(self, event) | QMainWindow.closeEvent(self, event) | ||||
@@ -2542,10 +2541,10 @@ if __name__ == '__main__': | |||||
setUpSignals(gui) | setUpSignals(gui) | ||||
# App-Loop | # App-Loop | ||||
#if gui.systray: | |||||
#ret = gui.systray.exec_(app) | |||||
#else: | |||||
ret = app.exec_() | |||||
if gui.systray: | |||||
ret = gui.systray.exec_(app) | |||||
else: | |||||
ret = app.exec_() | |||||
# Close Jack | # Close Jack | ||||
if jack.client: | if jack.client: | ||||
@@ -19,7 +19,7 @@ | |||||
# Imports (Global) | # Imports (Global) | ||||
import os, sys | import os, sys | ||||
from PyQt4.QtCore import QTimer, SIGNAL | from PyQt4.QtCore import QTimer, SIGNAL | ||||
from PyQt4.QtGui import QAction, QIcon, QMenu, QSystemTrayIcon | |||||
from PyQt4.QtGui import QAction, QIcon, QMainWindow, QMenu, QSystemTrayIcon | |||||
try: | try: | ||||
if os.getenv("DESKTOP_SESSION") in ("ubuntu", "ubuntu-2d") and not os.path.exists("/var/cadence/no_app_indicators"): | if os.getenv("DESKTOP_SESSION") in ("ubuntu", "ubuntu-2d") and not os.path.exists("/var/cadence/no_app_indicators"): | ||||
@@ -81,6 +81,7 @@ class GlobalSysTray(object): | |||||
def __init__(self, parent, name, icon): | def __init__(self, parent, name, icon): | ||||
object.__init__(self) | object.__init__(self) | ||||
self._app = None | |||||
self._parent = parent | self._parent = parent | ||||
self._gtk_running = False | self._gtk_running = False | ||||
self._quit_added = False | self._quit_added = False | ||||
@@ -491,6 +492,17 @@ class GlobalSysTray(object): | |||||
else: | else: | ||||
return False | return False | ||||
def handleQtCloseEvent(self, event): | |||||
if self.isTrayAvailable() and self._parent.isVisible(): | |||||
event.ignore() | |||||
self.__hideShowCall() | |||||
return False | |||||
else: | |||||
self.close() | |||||
QMainWindow.closeEvent(self._parent, event) | |||||
return True | |||||
# ------------------------------------------------------------------------------------------- | # ------------------------------------------------------------------------------------------- | ||||
def show(self): | def show(self): | ||||
@@ -531,6 +543,7 @@ class GlobalSysTray(object): | |||||
self.menu.close() | self.menu.close() | ||||
def exec_(self, app): | def exec_(self, app): | ||||
self._app = app | |||||
if TrayEngine == "AppIndicator": | if TrayEngine == "AppIndicator": | ||||
self._gtk_running = True | self._gtk_running = True | ||||
return Gtk.main() | return Gtk.main() | ||||
@@ -616,6 +629,10 @@ class GlobalSysTray(object): | |||||
if self._parent.isVisible(): | if self._parent.isVisible(): | ||||
self.setActionText("show", self._parent.tr("Restore")) | self.setActionText("show", self._parent.tr("Restore")) | ||||
self._parent.hide() | self._parent.hide() | ||||
if self._app: | |||||
self._app.setQuitOnLastWindowClosed(False) | |||||
else: | else: | ||||
self.setActionText("show", self._parent.tr("Minimize")) | self.setActionText("show", self._parent.tr("Minimize")) | ||||
@@ -624,9 +641,16 @@ class GlobalSysTray(object): | |||||
else: | else: | ||||
self._parent.showNormal() | self._parent.showNormal() | ||||
QTimer.singleShot(100, self.__raiseWindow) | |||||
if self._app: | |||||
self._app.setQuitOnLastWindowClosed(True) | |||||
QTimer.singleShot(500, self.__raiseWindow) | |||||
def __quitCall(self): | def __quitCall(self): | ||||
if self._app: | |||||
self._app.setQuitOnLastWindowClosed(True) | |||||
self._parent.hide() | |||||
self._parent.close() | self._parent.close() | ||||
def __raiseWindow(self): | def __raiseWindow(self): | ||||