diff -r ab19452732df -r 2a97a4d58bc6 Plugins/VcsPlugins/vcsMercurial/HgStatusDialog.py --- a/Plugins/VcsPlugins/vcsMercurial/HgStatusDialog.py Mon Feb 13 19:04:58 2017 +0100 +++ b/Plugins/VcsPlugins/vcsMercurial/HgStatusDialog.py Mon Feb 13 19:06:24 2017 +0100 @@ -16,7 +16,7 @@ import os -from PyQt5.QtCore import pyqtSlot, Qt, QProcess, QTimer +from PyQt5.QtCore import pyqtSlot, Qt, QProcess, QTimer, QSize from PyQt5.QtGui import QTextCursor from PyQt5.QtWidgets import QWidget, QDialogButtonBox, QMenu, QHeaderView, \ QTreeWidgetItem, QLineEdit @@ -34,7 +34,6 @@ # TODO: convert action buttons to a tool button with menu and delete status # list context menu (i.e. make it the action menu) -# TODO: save window geometry and splitter state class HgStatusDialog(QWidget, Ui_HgStatusDialog): """ Class implementing a dialog to show the output of the hg status command @@ -77,8 +76,7 @@ self.process.readyReadStandardOutput.connect(self.__readStdout) self.process.readyReadStandardError.connect(self.__readStderr) - self.diffSplitter.setSizes([350, 350]) - self.__diffSplitterState = None + self.diffSplitter.setSizes([300, 300]) self.statusList.headerItem().setText(self.__lastColumn, "") self.statusList.header().setSortIndicator( @@ -198,6 +196,62 @@ '!': self.tr('missing'), } + def closeEvent(self, e): + """ + Protected slot implementing a close event handler. + + @param e close event (QCloseEvent) + """ + if self.__hgClient: + if self.__hgClient.isExecuting(): + self.__hgClient.cancel() + else: + if self.process is not None and \ + self.process.state() != QProcess.NotRunning: + self.process.terminate() + QTimer.singleShot(2000, self.process.kill) + self.process.waitForFinished(3000) + + if self.__mq: + self.vcs.getPlugin().setPreferences( + "MqStatusDialogGeometry", self.saveGeometry()) + self.vcs.getPlugin().setPreferences( + "MqStatusDialogSplitterState", self.diffSplitter.saveState()) + else: + self.vcs.getPlugin().setPreferences( + "StatusDialogGeometry", self.saveGeometry()) + self.vcs.getPlugin().setPreferences( + "StatusDialogSplitterState", self.diffSplitter.saveState()) + + e.accept() + + def show(self): + """ + Public slot to show the dialog. + """ + super(HgStatusDialog, self).show() + + if self.__mq: + geom = self.vcs.getPlugin().getPreferences( + "MqStatusDialogGeometry") + else: + geom = self.vcs.getPlugin().getPreferences( + "StatusDialogGeometry") + if geom.isEmpty(): + s = QSize(800, 600) + self.resize(s) + else: + self.restoreGeometry(geom) + + if self.__mq: + diffSplitterState = self.vcs.getPlugin().getPreferences( + "MqStatusDialogSplitterState") + else: + diffSplitterState = self.vcs.getPlugin().getPreferences( + "StatusDialogSplitterState") + if diffSplitterState is not None: + self.diffSplitter.restoreState(diffSplitterState) + def __activeExtensionsChanged(self): """ Private slot handling a change in the activated extensions. @@ -209,15 +263,6 @@ if self.addButton.menu() is not None: self.addButton.setMenu(None) - def show(self): - """ - Public slot to show the dialog. - """ - super(HgStatusDialog, self).show() - - if not self.__mq and self.__diffSplitterState: - self.diffSplitter.restoreState(self.__diffSplitterState) - def __resort(self): """ Private method to resort the tree. @@ -259,27 +304,6 @@ if statusText not in self.__statusFilters: self.__statusFilters.append(statusText) - def closeEvent(self, e): - """ - Protected slot implementing a close event handler. - - @param e close event (QCloseEvent) - """ - if self.__hgClient: - if self.__hgClient.isExecuting(): - self.__hgClient.cancel() - else: - if self.process is not None and \ - self.process.state() != QProcess.NotRunning: - self.process.terminate() - QTimer.singleShot(2000, self.process.kill) - self.process.waitForFinished(3000) - - if not self.__mq: - self.__diffSplitterState = self.diffSplitter.saveState() - - e.accept() - def start(self, fn): """ Public slot to start the hg status command.