diff --git a/Linux/Helper.py b/Linux/Helper.py index 59940b7..73dc912 100644 --- a/Linux/Helper.py +++ b/Linux/Helper.py @@ -5,6 +5,8 @@ from PyQt4.QtGui import * from PyQt4.QtNetwork import QNetworkAccessManager, QNetworkRequest, QNetworkReply from PyQt4.QtWebKit import QWebView +import array + class WebPage(QtWebKit.QWebPage): def __init__(self, parent=0, app=None): super(QtWebKit.QWebPage, self).__init__(parent) @@ -84,3 +86,30 @@ class PostModel: self.imageFilePath = None self.isPrivate = False +class RestorableWindow(QtGui.QMainWindow): + + def __init__(self, action, app): + self.action = action + self.app = app + QtGui.QMainWindow.__init__(self) + self.restoreGeometry(QtCore.QByteArray.fromRawData(self.app.controller.stringForKey("mainWindowGeometry-" + self.action))) + self.restoreState(QtCore.QByteArray.fromRawData(self.app.controller.stringForKey("mainWindowState-" + self.action))) + + def closeEvent(self, event): + self._saveGeometry() + + def _saveGeometry(self): + self.app.controller.setStringForKey(self.saveGeometry(), "mainWindowGeometry-" + self.action) + self.app.controller.setStringForKey(self.saveState(), "mainWindowState-" + self.action) + + def hide(self): + self._saveGeometry() + QtGui.QMainWindow.hide(self) + + def sizeHint(self): + return QtCore.QSize(300, 500) + + def show(self): + QtGui.QMainWindow.show(self) + self.activateWindow() + self.raise_() \ No newline at end of file diff --git a/Linux/Windows.py b/Linux/Windows.py index e7831e7..3e47163 100644 --- a/Linux/Windows.py +++ b/Linux/Windows.py @@ -81,32 +81,16 @@ class Timeline: self.action = action self.title = title - self.window = QtGui.QMainWindow() - + self.window = Helper.RestorableWindow(action, self.app) self.window.setWindowTitle(title) - - self.window.resize(380, 600) - self.window.setMinimumSize(200, 200) -# - #x, y = 0, 0 - #if action == "mentions": - # x, y = 20, 20 - #elif action == "conversation": - # x, y = 40, 20 - #elif action == "profile": - # x, y = 40, 40 - - #self.moveWindow(x, y) + self.window.setWindowIcon(QtGui.QIcon(self.app.resources_path() + "/images/Icon.png")) self.webView = Helper.WebViewCreator(self.app, True, self.window) self.webView.load_local(self.load_finished) self.window.setCentralWidget(self.webView) - # self.window.addWidget(self.webView) self.initUI() - self.window.setWindowIcon(QtGui.QIcon(self.app.resources_path() + "/images/Icon.png")) - def moveWindow(self, x=0, y=0): self.show() geo = self.window.geometry() @@ -247,10 +231,10 @@ class Login(QtGui.QDialog): #self.buttonLogin.clicked.connect(callback) #self.label.setText("The server " + url.host() + " requires a username and password.") -class NewPost(QtGui.QMainWindow): +class NewPost(Helper.RestorableWindow): def __init__(self, app): self.app = app - QtGui.QPlainTextEdit.__init__(self) + Helper.RestorableWindow.__init__(self, "newpost", self.app) self.setWindowIcon(QtGui.QIcon(self.app.resources_path() + "/images/Icon.png"))