Revert changes to window showing/hiding logic as they break starting of GUI

This commit is contained in:
Kovid Goyal 2009-06-21 13:02:48 -07:00
parent ad78fd2a68
commit 5adfd154bf

View File

@ -167,7 +167,7 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
self.connect(self.quit_action, SIGNAL('triggered(bool)'), self.quit)
self.connect(self.donate_action, SIGNAL('triggered(bool)'), self.donate)
self.connect(self.restore_action, SIGNAL('triggered()'),
self.show_windows)
self.show)
self.connect(self.action_show_book_details,
SIGNAL('triggered(bool)'), self.show_book_info)
self.connect(self.action_restart, SIGNAL('triggered()'),
@ -317,7 +317,6 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
pm = QMenu()
ap = self.action_preferences
pm.addAction(ap.icon(), ap.text())
pm.addAction(self.preferences_action)
pm.addAction(_('Run welcome wizard'))
self.connect(pm.actions()[1], SIGNAL('triggered(bool)'),
self.run_wizard)
@ -403,9 +402,9 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
self.card_a_view.connect_dirtied_signal(self.upload_booklists)
self.card_b_view.connect_dirtied_signal(self.upload_booklists)
self.show_windows()
self.show()
if self.system_tray_icon.isVisible() and opts.start_in_tray:
self.hide_windows()
self.hide()
self.stack.setCurrentIndex(0)
try:
db = LibraryDatabase2(self.library_path)
@ -522,18 +521,12 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
def system_tray_icon_activated(self, r):
if r == QSystemTrayIcon.Trigger:
if self.isVisible():
self.hide_windows()
else:
self.show_windows()
def hide_windows(self):
for window in QApplication.topLevelWidgets():
if isinstance(window, (MainWindow, QDialog)) and \
window.isVisible():
window.hide()
setattr(window, '__systray_minimized', True)
def show_windows(self):
else:
for window in QApplication.topLevelWidgets():
if getattr(window, '__systray_minimized', False):
window.show()
@ -648,7 +641,7 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
self.add_filesystem_book(path)
self.setWindowState(self.windowState() & \
~Qt.WindowMinimized|Qt.WindowActive)
self.show_windows()
self.show()
self.raise_()
self.activateWindow()
elif msg.startswith('refreshdb:'):
@ -1665,7 +1658,7 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
self.spare_servers.pop().close()
self.device_manager.keep_going = False
self.cover_cache.stop()
self.hide_windows()
self.hide()
self.cover_cache.terminate()
self.emailer.stop()
try:
@ -1677,7 +1670,7 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
time.sleep(2)
except KeyboardInterrupt:
pass
self.hide_windows()
self.hide()
return True
def run_wizard(self, *args):
@ -1701,7 +1694,7 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
'choose <b>Quit</b> in the context menu of the '
'system tray.')).exec_()
dynamic['systray_msg'] = True
self.hide_windows()
self.hide()
e.ignore()
else:
if self.confirm_quit():