1 # Copyright (c) 2010 Citrix Systems, Inc.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at:
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 from OVEStandard import *
16 from OVELogger import *
17 from Ui_LogWindow import *
19 class OVELogWindow(QtGui.QDialog):
20 LOAD_KEY = 'LogWindow/window'
21 def __init__(self, app):
22 QtGui.QDialog.__init__(self)
24 self.ui = Ui_LogWindow()
28 self.connect(OVELogger.Inst(), QtCore.SIGNAL("logUpdated()"), self.logUpdated)
29 self.connect(self.ui.buttonBox, QtCore.SIGNAL("clicked(QAbstractButton *)"), self.xon_actionButton_Box_clicked)
31 def xon_actionButton_Box_clicked(self, button):
32 role = self.ui.buttonBox.buttonRole(button)
33 if role == QtGui.QDialogButtonBox.ResetRole:
34 OVELogger.Inst().reset()
38 self.ui.textBrowser.setText("\n".join(OVELogger.Inst().contents))
39 self.ui.textBrowser.moveCursor(QtGui.QTextCursor.End)
40 self.ui.textBrowser.ensureCursorVisible()
42 def saveSettings(self):
44 settings = QtCore.QSettings()
45 settings.setValue(key+"/loadable", QVariant(True))
46 settings.setValue(key+"/pos", QVariant(self.pos()))
47 settings.setValue(key+"/size", QVariant(self.size()))
48 settings.setValue(key+"/visible", QVariant(self.isVisible()))
50 def loadSettings(self):
52 settings = QtCore.QSettings()
53 pos = settings.value(key+"/pos", QVariant(QtCore.QPoint(200, 200))).toPoint()
54 size = settings.value(key+"/size", QVariant(QtCore.QSize(400, 400))).toSize()
55 visible = settings.value(key+"/visible", QVariant(True)).toBool()
58 self.setVisible(visible)
63 settings = QtCore.QSettings()
64 return settings.value(key+"/loadable", QVariant(False)).toBool()