eric6/WebBrowser/Session/SessionManagerDialog.py

Sat, 27 Feb 2021 12:08:23 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 27 Feb 2021 12:08:23 +0100
changeset 8138
169e65a6787c
parent 7923
91e843545d9a
child 8143
2c730d5fd177
permissions
-rw-r--r--

Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).

5782
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
3 # Copyright (c) 2017 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
5782
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a dialog to manage sessions.
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 from PyQt5.QtCore import pyqtSlot, Qt, QFileInfo
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 from PyQt5.QtGui import QPalette
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 from PyQt5.QtWidgets import QDialog, QTreeWidgetItem
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 from .Ui_SessionManagerDialog import Ui_SessionManagerDialog
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 from WebBrowser.WebBrowserWindow import WebBrowserWindow
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 class SessionManagerDialog(QDialog, Ui_SessionManagerDialog):
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 """
6047
39586a2de99d Fixed some forgotten source code documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5783
diff changeset
21 Class implementing a dialog to manage sessions.
5782
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 """
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 SessionFileRole = Qt.UserRole
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 BackupSessionRole = Qt.UserRole + 1
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 ActiveSessionRole = Qt.UserRole + 2
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 DefaultSessionRole = Qt.UserRole + 3
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 def __init__(self, parent=None):
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 """
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 Constructor
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 @param parent reference to the parent widget
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 @type QWidget
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 """
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 super(SessionManagerDialog, self).__init__(parent)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 self.setupUi(self)
5783
44a9f08de394 Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5782
diff changeset
37 self.setAttribute(Qt.WA_DeleteOnClose)
5782
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 self.newButton.clicked.connect(self.__newSession)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 self.renameButton.clicked.connect(self.__renameSession)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 self.cloneButton.clicked.connect(self.__cloneSession)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 self.deleteButton.clicked.connect(self.__deleteSession)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 self.switchButton.clicked.connect(self.__switchToSession)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 self.sessionsList.currentItemChanged.connect(self.__updateButtons)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 self.__refresh()
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 WebBrowserWindow.sessionManager().sessionsMetaDataChanged.connect(
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 self.__refresh)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 @pyqtSlot()
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 def __refresh(self):
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 """
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 Private slot to refresh the list of sessions.
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 """
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 self.sessionsList.clear()
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 sessions = WebBrowserWindow.sessionManager().sessionMetaData(
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 includeBackups=True)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 for session in sessions:
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 itm = QTreeWidgetItem()
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 itm.setText(0, session.name)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 itm.setText(1, QFileInfo(session.filePath).lastModified()
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 .toString("yyyy-MM-dd hh:mm"))
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 itm.setData(0, SessionManagerDialog.SessionFileRole,
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 session.filePath)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 itm.setData(0, SessionManagerDialog.BackupSessionRole,
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 session.isBackup)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 itm.setData(0, SessionManagerDialog.ActiveSessionRole,
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 session.isActive)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 itm.setData(0, SessionManagerDialog.DefaultSessionRole,
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 session.isDefault)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 self.__updateSessionItem(itm)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 self.sessionsList.addTopLevelItem(itm)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 self.__updateButtons()
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 def __updateButtons(self):
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 """
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 Private method to update the button state.
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 """
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 itm = self.sessionsList.currentItem()
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 if itm:
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 isBackup = itm.data(0, SessionManagerDialog.BackupSessionRole)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 isActive = itm.data(0, SessionManagerDialog.ActiveSessionRole)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 isDefault = itm.data(0, SessionManagerDialog.DefaultSessionRole)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 self.renameButton.setEnabled(not isDefault and not isBackup)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 self.cloneButton.setEnabled(not isBackup)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 self.deleteButton.setEnabled(not isBackup and not isDefault and
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 not isActive)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 self.switchButton.setEnabled(not isActive)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 if isBackup:
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 self.switchButton.setText(self.tr("Restore"))
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 else:
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 self.switchButton.setText(self.tr("Switch To"))
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 else:
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 self.renameButton.setEnabled(False)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 self.cloneButton.setEnabled(False)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 self.deleteButton.setEnabled(False)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 self.switchButton.setEnabled(False)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 self.switchButton.setText(self.tr("Switch To"))
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 def __updateSessionItem(self, itm):
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 """
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 Private method to set various item properties.
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 @param itm reference to the item to be updated
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 @type QTreeWidgetItem
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 """
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 isBackup = itm.data(0, SessionManagerDialog.BackupSessionRole)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111 isActive = itm.data(0, SessionManagerDialog.ActiveSessionRole)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 isDefault = itm.data(0, SessionManagerDialog.DefaultSessionRole)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 font = itm.font(0)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 if isBackup:
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 color = self.palette().color(QPalette.Disabled,
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 QPalette.WindowText)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 itm.setForeground(0, color)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 itm.setForeground(1, color)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 if isActive:
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 font.setBold(True)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 itm.setFont(0, font)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 itm.setFont(1, font)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 if isDefault:
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 font.setItalic(True)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 itm.setFont(0, font)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 itm.setFont(1, font)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 def showEvent(self, evt):
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 """
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 Protected method handling the dialog being shown.
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 @param evt reference to the event object
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 @type QShowEvent
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 """
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 super(SessionManagerDialog, self).showEvent(evt)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 self.__resizeViewHeader()
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 def resizeEvent(self, evt):
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 """
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 Protected method handling the dialog being resized.
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 @param evt reference to the event object
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 @type QResizeEvent
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 """
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 super(SessionManagerDialog, self).resizeEvent(evt)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 self.__resizeViewHeader()
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 def __resizeViewHeader(self):
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 """
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 Private method to resize the session column of the list.
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 """
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 headerWidth = self.sessionsList.header().width()
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 self.sessionsList.header().resizeSection(
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 0, headerWidth - headerWidth / 2.5)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 @pyqtSlot()
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 def __newSession(self):
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 """
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 Private slot to create a new session.
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 """
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 WebBrowserWindow.sessionManager().newSession()
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 @pyqtSlot()
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 def __renameSession(self):
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 """
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 Private slot to rename the selected session.
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 """
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 itm = self.sessionsList.currentItem()
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 if itm is None:
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 return
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 filePath = itm.data(0, SessionManagerDialog.SessionFileRole)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 if filePath:
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 WebBrowserWindow.sessionManager().renameSession(filePath)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 @pyqtSlot()
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 def __cloneSession(self):
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 """
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 Private slot to clone the selected session.
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 """
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 itm = self.sessionsList.currentItem()
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 if itm is None:
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 return
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 filePath = itm.data(0, SessionManagerDialog.SessionFileRole)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 if filePath:
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 WebBrowserWindow.sessionManager().cloneSession(filePath)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 @pyqtSlot()
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194 def __deleteSession(self):
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 """
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 Private slot to delete the selected session.
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 """
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 itm = self.sessionsList.currentItem()
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 if itm is None:
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200 return
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 filePath = itm.data(0, SessionManagerDialog.SessionFileRole)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 if filePath:
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 WebBrowserWindow.sessionManager().deleteSession(filePath)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206 @pyqtSlot()
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207 def __switchToSession(self):
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 """
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209 Private slot to switch to the selected session.
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 """
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 itm = self.sessionsList.currentItem()
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 if itm is None:
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213 return
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 filePath = itm.data(0, SessionManagerDialog.SessionFileRole)
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 if filePath:
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 if itm.data(0, SessionManagerDialog.BackupSessionRole):
7269
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
218 res = (
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
219 WebBrowserWindow.sessionManager().replaceSession(filePath)
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
220 )
5782
60874802161b Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221 else:
7269
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
222 res = (
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
223 WebBrowserWindow.sessionManager().switchToSession(filePath)
0c63ea7f94bd Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
224 )
5783
44a9f08de394 Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5782
diff changeset
225
44a9f08de394 Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5782
diff changeset
226 if res:
44a9f08de394 Continued implementing session support for the new web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5782
diff changeset
227 self.close()

eric ide

mercurial