now saving the position of the windows
This commit is contained in:
parent
7e44a54bfb
commit
b0e550c6d1
2 changed files with 33 additions and 20 deletions
|
@ -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_()
|
|
@ -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"))
|
||||
|
||||
|
|
Reference in a new issue