v.licheni.net
/
stack
/
code
/
dboxswitch.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
wait some time for systray to appear
[stack/code/dboxswitch.git]
/
gui.py
diff --git
a/gui.py
b/gui.py
index
a0c10f5
..
bb156a0
100644
(file)
--- a/
gui.py
+++ b/
gui.py
@@
-33,6
+33,7
@@
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""
import sys
import os
"""
import sys
import os
+from time import sleep
from PyQt4 import QtGui, QtCore
from PyQt4.QtCore import SIGNAL
from qmenutooltip import QMenuToolTip
from PyQt4 import QtGui, QtCore
from PyQt4.QtCore import SIGNAL
from qmenutooltip import QMenuToolTip
@@
-47,7
+48,11
@@
class Gui(QtGui.QDialog):
Default actions are builded and profile manager stored from argument (instance of ProfHandler """
self.app = QtGui.QApplication(sys.argv)
Default actions are builded and profile manager stored from argument (instance of ProfHandler """
self.app = QtGui.QApplication(sys.argv)
-
+ for i in range(3):
+ if not QtGui.QSystemTrayIcon.isSystemTrayAvailable():
+ sleep(4)
+ else:
+ break
#check if system tray is avaiable on the system
if not QtGui.QSystemTrayIcon.isSystemTrayAvailable():
QtGui.QMessageBox.critical(None, "Systray",
#check if system tray is avaiable on the system
if not QtGui.QSystemTrayIcon.isSystemTrayAvailable():
QtGui.QMessageBox.critical(None, "Systray",
@@
-72,7
+77,6
@@
class Gui(QtGui.QDialog):
""" Like Gtk application this main executes the app, thi is somewhat writed for
compatibility in porting the app """
""" Like Gtk application this main executes the app, thi is somewhat writed for
compatibility in porting the app """
- self.show()
sys.exit(self.app.exec_())
def closeEvent(self, event):
sys.exit(self.app.exec_())
def closeEvent(self, event):
@@
-91,16
+95,23
@@
class Gui(QtGui.QDialog):
triggered=QtGui.qApp.quit)
#profile manager component
triggered=QtGui.qApp.quit)
#profile manager component
- self.addProfile = QtGui.QAction(" Add &Profile ", self,
+ self.addProfile
Action
= QtGui.QAction(" Add &Profile ", self,
triggered=self.addProfile)
def createMainDialog(self):
""" Build the main dialog layout """
self.setWindowTitle("Profile manager / Dboxswitch - dropbox profile switcher")
triggered=self.addProfile)
def createMainDialog(self):
""" Build the main dialog layout """
self.setWindowTitle("Profile manager / Dboxswitch - dropbox profile switcher")
+ #add a default action to create a profile
+ self.addButton = QtGui.QPushButton(QtGui.QIcon(appconf.addpicon),
+ "Add Profile")
+ self.addButton.clicked.connect(self.addProfile)
+ self.addButton.setVisible(False)
self.la = QtGui.QFormLayout()
self.la = QtGui.QFormLayout()
- self.la.sizePolicy = QtGui.QSizePolicy.Expanding
+
+ self.la.addRow(self.addButton)
+ self.la.sizePolicy = QtGui.QSizePolicy.Minimum
self.la.setVerticalSpacing(15)
self.la.setHorizontalSpacing(15)
self.formGroupBox = QtGui.QGroupBox("Manage profiles:")
self.la.setVerticalSpacing(15)
self.la.setHorizontalSpacing(15)
self.formGroupBox = QtGui.QGroupBox("Manage profiles:")
@@
-125,7
+136,12
@@
class Gui(QtGui.QDialog):
delButton.setDefaultAction(delAction)
self.profiles.append((label, delButton))
delButton.setDefaultAction(delAction)
self.profiles.append((label, delButton))
- self.sizeHint()
+ #if profiles was empty
+ if len(profiles) == 0:
+ self.addButton.setVisible(True)
+ else:
+ self.addButton.setVisible(False)
+
super(Gui, self).show()
def hide(self):
super(Gui, self).show()
def hide(self):
@@
-136,8
+152,8
@@
class Gui(QtGui.QDialog):
for ws in self.profiles:
for w in ws:
for ws in self.profiles:
for w in ws:
+ w.setVisible(False)
w.setParent(None)
w.setParent(None)
- w.close()
super(Gui, self).hide()
def createTrayIcon(self):
super(Gui, self).hide()
def createTrayIcon(self):
@@
-187,7
+203,7
@@
class Gui(QtGui.QDialog):
self.menuProfiles.addSeparator()
#action and menu item for adding a New Profile
self.menuProfiles.addSeparator()
#action and menu item for adding a New Profile
- self.menuProfiles.addAction(self.addProfile)
+ self.menuProfiles.addAction(self.addProfile
Action
)
self.menuProfiles.activateWindow()
self.menuProfiles.popup(QtGui.QCursor.pos())
self.menuProfiles.activateWindow()
self.menuProfiles.popup(QtGui.QCursor.pos())
@@
-211,10
+227,10
@@
class Gui(QtGui.QDialog):
def f():
try:
def f():
try:
-
#
self.profileManager.delProfile(pr)
+ self.profileManager.delProfile(pr)
for w in prWidgets:
w.setParent(None)
for w in prWidgets:
w.setParent(None)
- w.
close(
)
+ w.
setVisible(False
)
except AppError, e:
self.showError(str(e))
return f
except AppError, e:
self.showError(str(e))
return f