[Pymoul-svn] SF.net SVN: pymoul: [131] pymoul/trunk/src/moul/qt
Status: Alpha
Brought to you by:
tiran
|
From: <ti...@us...> - 2007-02-03 21:56:02
|
Revision: 131
http://pymoul.svn.sourceforge.net/pymoul/?rev=131&view=rev
Author: tiran
Date: 2007-02-03 13:55:59 -0800 (Sat, 03 Feb 2007)
Log Message:
-----------
Added dirty handler
Modified Paths:
--------------
pymoul/trunk/src/moul/qt/mainwindow.py
pymoul/trunk/src/moul/qt/simpleprogressbar.py
pymoul/trunk/src/moul/qt/threadlet.py
pymoul/trunk/src/moul/qt/wdysini.py
Property Changed:
----------------
pymoul/trunk/src/moul/qt/errorhandler.py
pymoul/trunk/src/moul/qt/simpleprogressbar.py
pymoul/trunk/src/moul/qt/threadlet.py
pymoul/trunk/src/moul/qt/ui/simpleprogressbar.py
pymoul/trunk/src/moul/qt/ui/simpleprogressbar.ui
pymoul/trunk/src/moul/qt/utils.py
Property changes on: pymoul/trunk/src/moul/qt/errorhandler.py
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Modified: pymoul/trunk/src/moul/qt/mainwindow.py
===================================================================
--- pymoul/trunk/src/moul/qt/mainwindow.py 2007-02-03 19:26:53 UTC (rev 130)
+++ pymoul/trunk/src/moul/qt/mainwindow.py 2007-02-03 21:55:59 UTC (rev 131)
@@ -35,7 +35,6 @@
from moul.config import lookupDir
from moul.file.directory import UruGameDataDirectory
from moul.file.directory import UruPersonalDataDirectory
-from moul.file.wdysini import videoModes
from moul.log import getLogger
from moul.log import signalLogDecorator
from moul.osdependent import isMoulRunning
@@ -62,11 +61,12 @@
self.main_buttonbox_reset = but(QtGui.QDialogButtonBox.Reset)
self.main_buttonbox_save = but(QtGui.QDialogButtonBox.Save)
self.main_buttonbox_close = but(QtGui.QDialogButtonBox.Close)
-
+ self.main_buttonbox_save.setEnabled(False)
+ self.main_buttonbox_reset.setEnabled(False)
+
# dirty flag: unsaved changes
- self._dirty = False
- self.setDirty(False)
-
+ self._dirty = {}
+
# set directory handlers
self.urugamedir = UruGameDataDirectory(lookupDir('install'))
self.urugamedir.initializeFactories()
@@ -150,15 +150,34 @@
event.accept()
event.ignore()
- def setDirty(self, boolean):
+ def isDirty(self):
"""
+ Check if we have unsaved changes
+ """
+ if any(self._dirty.values()):
+ return True
+ else:
+ return False
+
+ def clearDirty(self):
+ """
+ Clear dirty state
+ """
+ self._dirty.clear()
+ self.main_buttonbox_save.setEnabled(False)
+ self.main_buttonbox_reset.setEnabled(False)
+
+ def notifyDirty(self, name, boolean):
+ """
Sets the save state
"""
- self._dirty = bool(boolean)
- #self.main_buttonbox_reset.setEnabled(boolean)
- #self.main_buttonbox_save.setEnabled(boolean)
- self.main_buttonbox_save.setEnabled(True)
- self.main_buttonbox_reset.setEnabled(True)
+ self._dirty[name] = boolean
+ if self.isDirty():
+ self.main_buttonbox_save.setEnabled(True)
+ self.main_buttonbox_reset.setEnabled(True)
+ else:
+ self.main_buttonbox_save.setEnabled(False)
+ self.main_buttonbox_reset.setEnabled(False)
# ************************************************************************
# tasks
Modified: pymoul/trunk/src/moul/qt/simpleprogressbar.py
===================================================================
--- pymoul/trunk/src/moul/qt/simpleprogressbar.py 2007-02-03 19:26:53 UTC (rev 130)
+++ pymoul/trunk/src/moul/qt/simpleprogressbar.py 2007-02-03 21:55:59 UTC (rev 131)
@@ -19,8 +19,8 @@
"""Moul QT GUI main windows
"""
__author__ = "Christian Heimes"
-__version__ = "$Id: mainwindow.py 116 2007-02-02 03:32:28Z tiran $"
-__revision__ = "$Revision: 116 $"
+__version__ = "$Id$"
+__revision__ = "$Revision$"
__all__ = ['SimpleProgressbar']
Property changes on: pymoul/trunk/src/moul/qt/simpleprogressbar.py
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Modified: pymoul/trunk/src/moul/qt/threadlet.py
===================================================================
--- pymoul/trunk/src/moul/qt/threadlet.py 2007-02-03 19:26:53 UTC (rev 130)
+++ pymoul/trunk/src/moul/qt/threadlet.py 2007-02-03 21:55:59 UTC (rev 131)
@@ -20,8 +20,8 @@
"""Threadlet - execute a function in a seperate thread
"""
__author__ = "Christian Heimes"
-__version__ = "$Id: moulqt.py 110 2007-01-31 15:40:51Z tiran $"
-__revision__ = "$Revision: 110 $"
+__version__ = "$Id$"
+__revision__ = "$Revision$"
import sys
from PyQt4 import QtCore
Property changes on: pymoul/trunk/src/moul/qt/threadlet.py
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Property changes on: pymoul/trunk/src/moul/qt/ui/simpleprogressbar.py
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Property changes on: pymoul/trunk/src/moul/qt/ui/simpleprogressbar.ui
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: pymoul/trunk/src/moul/qt/utils.py
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Modified: pymoul/trunk/src/moul/qt/wdysini.py
===================================================================
--- pymoul/trunk/src/moul/qt/wdysini.py 2007-02-03 19:26:53 UTC (rev 130)
+++ pymoul/trunk/src/moul/qt/wdysini.py 2007-02-03 21:55:59 UTC (rev 131)
@@ -45,21 +45,40 @@
class IniFileContainer(QNamespaceContainer):
def initialize(self):
# graphics.ini
+ self.connect(self.context, SIGNAL("graphicsChanged(bool)"), self.on_graphicsChanged)
self.connect(self.context, SIGNAL("graphicsini_loaded()"), self.on_graphicsini_loaded)
self.connect(self.context, SIGNAL("graphicsini_reset()"), self.on_graphicsini_reset)
self.connect(self.context, SIGNAL("graphicsini_save()"), self.on_graphicsini_save)
self.connect(self.main_buttonbox_reset, SIGNAL("clicked()"), self.on_graphicsini_reset)
self.connect(self.main_buttonbox_save, SIGNAL("clicked()"), self.on_graphicsini_save)
- self.context.emit(SIGNAL("graphicsini_loaded()")) # XXX: hard coded emit
# audio.ini
+ self.connect(self.context, SIGNAL("audioChanged(bool)"), self.on_audioChanged)
self.connect(self.context, SIGNAL("audioini_loaded()"), self.on_audioini_loaded)
self.connect(self.context, SIGNAL("audiini_reset()"), self.on_audioini_reset)
self.connect(self.context, SIGNAL("audiini_save()"), self.on_audioini_save)
self.connect(self.main_buttonbox_reset, SIGNAL("clicked()"), self.on_audioini_reset)
self.connect(self.main_buttonbox_save, SIGNAL("clicked()"), self.on_audioini_save)
+
self.context.emit(SIGNAL("audioini_loaded()")) # XXX: hard coded emit
+ self.context.emit(SIGNAL("graphicsini_loaded()")) # XXX: hard coded emit
@signalLogDecorator(LOG)
+ @pyqtSignature("bool")
+ def on_graphicsChanged(self, boolean):
+ """
+ @qtslot on_graphicsChanged(bool): notify when graphics settings are changed
+ """
+ self.context.notifyDirty('graphicsini', boolean)
+
+ @signalLogDecorator(LOG)
+ @pyqtSignature("bool")
+ def on_audioChanged(self, boolean):
+ """
+ @qtslot on_audioChanged(bool): notify when audio settings are changed
+ """
+ self.context.notifyDirty('audioini', boolean)
+
+ @signalLogDecorator(LOG)
@pyqtSignature("")
def on_graphicsini_loaded(self):
"""
@@ -75,6 +94,7 @@
self.trUtf8("""Something bad happend while opening the graphics.ini\n%s""" % msg))
return
self._graphicsini_setstate()
+ self.emit(SIGNAL("graphicsChanged(bool)"), False)
@signalLogDecorator(LOG)
@pyqtSignature("")
@@ -82,6 +102,7 @@
"""
SIGNAL graphicsini_reset()
"""
+ self.emit(SIGNAL("graphicsChanged(bool)"), False)
self.urupersonaldir.graphicsini.reset()
self._graphicsini_setstate()
@@ -91,7 +112,7 @@
"""
SIGNAL graphicsini_save()
"""
- #self._notimplemented()
+ self.emit(SIGNAL("graphicsChanged(bool)"), False)
self.urupersonaldir.graphicsini.write()
self.setDirty(False)
@@ -121,6 +142,7 @@
"""
SIGNAL: valueChanged (int)
"""
+ self.emit(SIGNAL("graphicsChanged(bool)"), True)
self.urupersonaldir.graphicsini.screenres = idx
@signalLogDecorator(LOG)
@@ -129,6 +151,7 @@
"""
SIGNAL: sliderMoved(int)
"""
+ self.emit(SIGNAL("graphicsChanged(bool)"), True)
txt = videoModes.getVidModeHuman(idx)
self.lb_screenres.setText(QtCore.QString(txt))
@@ -138,6 +161,7 @@
"""
SIGNAL: valueChanged (int)
"""
+ self.emit(SIGNAL("graphicsChanged(bool)"), True)
self.urupersonaldir.graphicsini.quality = idx
@signalLogDecorator(LOG)
@@ -146,6 +170,7 @@
"""
SIGNAL: valueChanged (int)
"""
+ self.emit(SIGNAL("graphicsChanged(bool)"), True)
self.urupersonaldir.graphicsini.texture = idx
@signalLogDecorator(LOG)
@@ -154,6 +179,7 @@
"""
SIGNAL: valueChanged (int)
"""
+ self.emit(SIGNAL("graphicsChanged(bool)"), True)
self.urupersonaldir.graphicsini.antialias = idx
@signalLogDecorator(LOG)
@@ -162,6 +188,7 @@
"""
SIGNAL: valueChanged (int)
"""
+ self.emit(SIGNAL("graphicsChanged(bool)"), True)
self.urupersonaldir.graphicsini.anisotropic = idx
@signalLogDecorator(LOG)
@@ -170,6 +197,7 @@
"""
SIGNAL: valueChanged (int)
"""
+ self.emit(SIGNAL("graphicsChanged(bool)"), True)
self.urupersonaldir.graphicsini.shadow = idx
@signalLogDecorator(LOG)
@@ -178,6 +206,7 @@
"""
SIGNAL: stateChanged(int)
"""
+ self.emit(SIGNAL("graphicsChanged(bool)"), True)
self.urupersonaldir.graphicsini.windowed = state
@signalLogDecorator(LOG)
@@ -186,6 +215,7 @@
"""
SIGNAL: stateChanged(int)
"""
+ self.emit(SIGNAL("graphicsChanged(bool)"), True)
self.urupersonaldir.graphicsini.vsync = state
@signalLogDecorator(LOG)
@@ -194,6 +224,7 @@
"""
SIGNAL: stateChanged(int)
"""
+ self.emit(SIGNAL("graphicsChanged(bool)"), True)
self.urupersonaldir.graphicsini.shadow_enabled = state
# ************************************************************************
@@ -214,12 +245,14 @@
self.trUtf8("""Something bad happend while opening the audio.ini\n%s""" % msg))
return
self._audioini_setstate()
+ self.emit(SIGNAL("audioChanged(bool)"), False)
@signalLogDecorator(LOG)
def on_audioini_reset(self):
"""
SIGNAL audioini_reset()
"""
+ self.emit(SIGNAL("audioChanged(bool)"), False)
self.urupersonaldir.audioini.reset()
self._audioini_setstate()
@@ -228,7 +261,7 @@
"""
SIGNAL audioini_save()
"""
- #self._notimplemented()
+ self.emit(SIGNAL("audioChanged(bool)"), False)
self.urupersonaldir.audioini.write()
self.setDirty(False) # urks
@@ -259,45 +292,54 @@
@signalLogDecorator(LOG)
@pyqtSignature("int")
def on_sl_aud_device_sliderMoved(self, idx):
+ self.emit(SIGNAL("audioChanged(bool)"), True)
txt = self.urupersonaldir.audioini.getDeviceName(idx)
self.lb_aud_device.setText(QtCore.QString(txt[1:-1]))
@signalLogDecorator(LOG)
@pyqtSignature("int")
def on_sl_aud_npc_valueChanged(self, idx):
+ self.emit(SIGNAL("audioChanged(bool)"), True)
self.urupersonaldir.audioini.npc = idx
@signalLogDecorator(LOG)
@pyqtSignature("int")
def on_sl_aud_music_valueChanged(self, idx):
+ self.emit(SIGNAL("audioChanged(bool)"), True)
self.urupersonaldir.audioini.music = idx
@signalLogDecorator(LOG)
@pyqtSignature("int")
def on_sl_aud_fx_valueChanged(self, idx):
+ self.emit(SIGNAL("audioChanged(bool)"), True)
self.urupersonaldir.audioini.fx = idx
@signalLogDecorator(LOG)
@pyqtSignature("int")
def on_sl_aud_ambience_valueChanged(self, idx):
+ self.emit(SIGNAL("audioChanged(bool)"), True)
self.urupersonaldir.audioini.ambience = idx
@signalLogDecorator(LOG)
@pyqtSignature("int")
def on_sl_aud_priority_valueChanged(self, idx):
+ self.emit(SIGNAL("audioChanged(bool)"), True)
self.urupersonaldir.audioini.priority = idx
@signalLogDecorator(LOG)
@pyqtSignature("int")
def on_cb_aud_eax_stateChanged (self, state):
+ self.emit(SIGNAL("audioChanged(bool)"), True)
self.urupersonaldir.audioini.eax = state
@signalLogDecorator(LOG)
@pyqtSignature("int")
def on_cb_aud_mute_stateChanged (self, state):
+ self.emit(SIGNAL("audioChanged(bool)"), True)
self.urupersonaldir.audioini.mute = state
@signalLogDecorator(LOG)
@pyqtSignature("int")
def on_cb_aud_voicechat_stateChanged (self, state):
+ self.emit(SIGNAL("audioChanged(bool)"), True)
self.urupersonaldir.audioini.voicechat = state
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|