eric6/UI/UserInterface.py

branch
maintenance
changeset 8450
be7369a19dc9
parent 8400
b3eefd7e58d1
parent 8429
ab23dbabd491
equal deleted inserted replaced
8401:832e9474cf77 8450:be7369a19dc9
20 from PyQt5.QtCore import ( 20 from PyQt5.QtCore import (
21 pyqtSlot, QTimer, QFile, QFileInfo, pyqtSignal, PYQT_VERSION_STR, QDate, 21 pyqtSlot, QTimer, QFile, QFileInfo, pyqtSignal, PYQT_VERSION_STR, QDate,
22 QIODevice, qVersion, QProcess, QSize, QUrl, QObject, Qt, QUuid, QThread, 22 QIODevice, qVersion, QProcess, QSize, QUrl, QObject, Qt, QUuid, QThread,
23 QUrlQuery 23 QUrlQuery
24 ) 24 )
25 from PyQt5.QtGui import QKeySequence, QDesktopServices 25 from PyQt5.QtGui import QKeySequence, QDesktopServices, QGuiApplication
26 from PyQt5.QtWidgets import ( 26 from PyQt5.QtWidgets import (
27 QSizePolicy, QWidget, QWhatsThis, QToolBar, QDialog, QSplitter, 27 QSizePolicy, QWidget, QWhatsThis, QToolBar, QDialog, QSplitter,
28 QApplication, QMenu, QVBoxLayout, QDockWidget, QAction, QLabel 28 QApplication, QMenu, QVBoxLayout, QDockWidget, QAction, QLabel
29 ) 29 )
30 from PyQt5.Qsci import QSCINTILLA_VERSION_STR 30 from PyQt5.Qsci import QSCINTILLA_VERSION_STR
128 """ 128 """
129 self.buffer += str(s) 129 self.buffer += str(s)
130 self.__nWrite(self.__bufferedWrite()) 130 self.__nWrite(self.__bufferedWrite())
131 131
132 132
133 # TODO: add support for QSessionManager to save changed files
134 class UserInterface(E5MainWindow): 133 class UserInterface(E5MainWindow):
135 """ 134 """
136 Class implementing the main user interface. 135 Class implementing the main user interface.
137 136
138 @signal appendStderr(str) emitted to write data to stderr logger 137 @signal appendStderr(str) emitted to write data to stderr logger
744 743
745 # set the keyboard input interval 744 # set the keyboard input interval
746 interval = Preferences.getUI("KeyboardInputInterval") 745 interval = Preferences.getUI("KeyboardInputInterval")
747 if interval > 0: 746 if interval > 0:
748 QApplication.setKeyboardInputInterval(interval) 747 QApplication.setKeyboardInputInterval(interval)
748
749 # connect to the desktop environment session manager
750 QGuiApplication.setFallbackSessionManagementEnabled(False)
751 app.commitDataRequest.connect(self.__commitData,
752 Qt.ConnectionType.DirectConnection)
749 753
750 def networkAccessManager(self): 754 def networkAccessManager(self):
751 """ 755 """
752 Public method to get a reference to the network access manager object. 756 Public method to get a reference to the network access manager object.
753 757
7509 7513
7510 @return reference to the code documentation viewer 7514 @return reference to the code documentation viewer
7511 @rtype CodeDocumentationViewer 7515 @rtype CodeDocumentationViewer
7512 """ 7516 """
7513 return self.codeDocumentationViewer 7517 return self.codeDocumentationViewer
7518
7519 ###############################################
7520 ## Support for Desktop session management below
7521 ###############################################
7522
7523 def __commitData(self, manager):
7524 """
7525 Private slot to commit unsaved data when instructed by the desktop
7526 session manager.
7527
7528 @param manager reference to the desktop session manager
7529 @type QSessionManager
7530 """
7531 if self.viewmanager.hasDirtyEditor():
7532 if manager.allowsInteraction():
7533 res = E5MessageBox.warning(
7534 self,
7535 self.tr("Unsaved Data Detected"),
7536 self.tr("Some editors contain unsaved data. Shall these"
7537 " be saved?"),
7538 E5MessageBox.Abort |
7539 E5MessageBox.Discard |
7540 E5MessageBox.Save |
7541 E5MessageBox.SaveAll,
7542 E5MessageBox.SaveAll)
7543 if res == E5MessageBox.SaveAll:
7544 manager.release()
7545 self.viewmanager.saveAllEditors()
7546 elif res == E5MessageBox.Save:
7547 manager.release()
7548 ok = self.viewmanager.checkAllDirty()
7549 if not ok:
7550 manager.cancel()
7551 elif res == E5MessageBox.Discard:
7552 # nothing to do
7553 pass
7554 else:
7555 # default action is to abort shutdown
7556 manager.cancel()
7557 else:
7558 # We did not get permission to interact, play it safe and
7559 # save all data.
7560 self.viewmanager.saveAllEditors()

eric ide

mercurial