[kde-doc-english] [kajongg] /: Remove ruleset editor from config dialog
Wolfgang Rohdewald
wolfgang at rohdewald.de
Wed Sep 11 10:18:23 UTC 2013
Git commit 7f78baf44ed7e281a0329017e5b20a96f7da49fe by Wolfgang Rohdewald.
Committed on 02/09/2013 at 14:06.
Pushed by wrohdewald into branch 'master'.
Remove ruleset editor from config dialog
because changes in this editor are applied immediately, no cancel option.
Instead give it its own menu entry.
M +- -- doc/config_background.png
M +- -- doc/config_play.png
M +- -- doc/config_tiles.png
M +8 -0 doc/index.docbook
M +- -- doc/ruleseteditor.png
M +1 -0 src/kajonggui.rc
M +19 -14 src/playfield.py
M +34 -9 src/rulesetselector.py
http://commits.kde.org/kajongg/7f78baf44ed7e281a0329017e5b20a96f7da49fe
diff --git a/doc/config_background.png b/doc/config_background.png
index ff85c80..561b884 100644
Binary files a/doc/config_background.png and b/doc/config_background.png differ
diff --git a/doc/config_play.png b/doc/config_play.png
index ada5ae4..3071fa8 100644
Binary files a/doc/config_play.png and b/doc/config_play.png differ
diff --git a/doc/config_tiles.png b/doc/config_tiles.png
index bbbbe68..b7a5f12 100644
Binary files a/doc/config_tiles.png and b/doc/config_tiles.png differ
diff --git a/doc/index.docbook b/doc/index.docbook
index 1b5adf8..0398048 100644
--- a/doc/index.docbook
+++ b/doc/index.docbook
@@ -521,6 +521,14 @@
</varlistentry>
<varlistentry>
<term><menuchoice>
+ <guimenu>Settings</guimenu>
+ <guimenuitem>Rulesets</guimenuitem>
+ </menuchoice></term>
+ <listitem><para><action>Customize rulesets.</action></para>
+ <para>Use the Ruleset Editor to customize rulesets. For details see <link linkend="ruleset-options">here</link>.</para></listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><menuchoice>
<shortcut><keycombo action="simul">&Ctrl;<keycap>G</keycap></keycombo></shortcut>
<guimenu>Settings</guimenu>
<guimenuitem>Change Visual Angle</guimenuitem>
diff --git a/doc/ruleseteditor.png b/doc/ruleseteditor.png
index c361a27..b7c3520 100644
Binary files a/doc/ruleseteditor.png and b/doc/ruleseteditor.png differ
diff --git a/src/kajonggui.rc b/src/kajonggui.rc
index e0af27f..5760036 100644
--- a/src/kajonggui.rc
+++ b/src/kajonggui.rc
@@ -18,6 +18,7 @@
</Menu>
<Menu name="settings" >
<Action name="players" />
+ <Action name="rulesets" />
<Action name="angle" />
<Action name="fullscreen" />
<Action name="demoMode" />
diff --git a/src/playfield.py b/src/playfield.py
index 07189a2..9ee919d 100644
--- a/src/playfield.py
+++ b/src/playfield.py
@@ -150,16 +150,13 @@ class ConfigDialog(KConfigDialog):
"""configuration dialog with several pages"""
def __init__(self, parent, name):
super(ConfigDialog, self).__init__(parent, QString(name), Preferences)
- self.rulesetSelector = RulesetSelector(self)
- self.pages = []
- self.pages.append(self.addPage(PlayConfigTab(self),
- m18nc('kajongg','Play'), "arrow-right"))
- self.pages.append(self.addPage(TilesetSelector(self),
- m18n("Tiles"), "games-config-tiles"))
- self.pages.append(self.addPage(BackgroundSelector(self),
- m18n("Backgrounds"), "games-config-background"))
- self.pages.append(self.addPage(self.rulesetSelector,
- m18n("Rulesets"), "games-kajongg-law"))
+ self.pages = [
+ self.addPage(PlayConfigTab(self),
+ m18nc('kajongg','Play'), "arrow-right"),
+ self.addPage(TilesetSelector(self),
+ m18n("Tiles"), "games-config-tiles"),
+ self.addPage(BackgroundSelector(self),
+ m18n("Backgrounds"), "games-config-background")]
StateSaver(self)
def keyPressEvent(self, event):
@@ -171,10 +168,6 @@ class ConfigDialog(KConfigDialog):
return
KConfigDialog.keyPressEvent(self, event)
- def showEvent(self, dummyEvent):
- """start transaction"""
- self.rulesetSelector.refresh()
-
class SwapDialog(QMessageBox):
"""ask the user if two players should change seats"""
def __init__(self, swappers):
@@ -417,6 +410,7 @@ class PlayField(KXmlGuiWindow):
self.clientDialog = None
self.playerWindow = None
+ self.rulesetWindow = None
self.scoreTable = None
self.explainView = None
self.scoringDialog = None
@@ -504,6 +498,7 @@ class PlayField(KXmlGuiWindow):
QGraphicsView.drawBackground always wants a pixmap
for a huge rect like 4000x3000 where my screen only has
1920x1200"""
+ # pylint: disable=R0915
self.setObjectName("MainWindow")
centralWidget = QWidget()
scene = MJScene()
@@ -535,6 +530,7 @@ class PlayField(KXmlGuiWindow):
self.actionAbortGame.setEnabled(False)
self.actionQuit = self.__kajonggAction("quit", "application-exit", self.quit, Qt.Key_Q)
self.actionPlayers = self.__kajonggAction("players", "im-user", self.slotPlayers)
+ self.actionRulesets = self.__kajonggAction("rulesets", "games-kajongg-law", self.slotRulesets)
self.actionChat = self.__kajonggToggleAction("chat", "call-start",
shortcut=Qt.Key_H, actionData=ChatWindow)
game = self.game
@@ -718,6 +714,9 @@ class PlayField(KXmlGuiWindow):
self.actionPlayers.setText(m18nc('@action:intoolbar', "&Players"))
self.actionPlayers.setHelpText(m18nc('kajongg @info:tooltip', 'define your players.'))
+ self.actionRulesets.setText(m18nc('@action:intoolbar', "&Rulesets"))
+ self.actionRulesets.setHelpText(m18nc('kajongg @info:tooltip', 'customize rulesets.'))
+
self.actionAngle.setText(m18nc('@action:inmenu', "&Change Visual Angle"))
self.actionAngle.setIconText(m18nc('@action:intoolbar', "Angle"))
self.actionAngle.setHelpText(m18nc('kajongg @info:tooltip', "Change the visual appearance of the tiles."))
@@ -757,6 +756,12 @@ class PlayField(KXmlGuiWindow):
self.playerWindow = PlayerList(self)
self.playerWindow.show()
+ def slotRulesets(self):
+ """show the player list"""
+ if not self.rulesetWindow:
+ self.rulesetWindow = RulesetSelector()
+ self.rulesetWindow.show()
+
def selectScoringGame(self):
"""show all games, select an existing game or create a new game"""
Players.load()
diff --git a/src/rulesetselector.py b/src/rulesetselector.py
index dedaadf..7f2cc35 100644
--- a/src/rulesetselector.py
+++ b/src/rulesetselector.py
@@ -20,7 +20,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
"""
-from PyQt4.QtCore import Qt, QVariant
+from PyQt4.QtCore import Qt, QVariant, QSize
from PyQt4.QtGui import QWidget, QHBoxLayout, QVBoxLayout, \
QPushButton, QSpacerItem, QSizePolicy, \
QTreeView, QFont, QAbstractItemView, QHeaderView
@@ -30,9 +30,10 @@ from util import m18n, m18nc, english, uniqueList
from differ import RulesetDiffer
from common import Debug
from tree import TreeItem, RootItem, TreeModel
-from kde import Sorry
+from kde import Sorry, KApplication
from modeltest import ModelTest
from genericdelegates import RightAlignedCheckboxDelegate
+from statesaver import StateSaver
class RuleRootItem(RootItem):
"""the root item for the ruleset tree"""
@@ -454,13 +455,15 @@ class RuleTreeView(QTreeView):
class RulesetSelector( QWidget):
"""presents all available rulesets with previews"""
- def __init__(self, parent):
+ def __init__(self, parent=None):
super(RulesetSelector, self).__init__(parent)
self.setContentsMargins(0, 0, 0, 0)
self.setupUi()
def setupUi(self):
"""layout the window"""
+ self.setWindowTitle(m18n('Customize rulesets') + ' - Kajongg')
+ self.setObjectName('Rulesets')
hlayout = QHBoxLayout(self)
v1layout = QVBoxLayout()
self.v1widget = QWidget()
@@ -470,12 +473,11 @@ class RulesetSelector( QWidget):
hlayout.addLayout(v2layout)
for widget in [self.v1widget, hlayout, v1layout, v2layout]:
widget.setContentsMargins(0, 0, 0, 0)
- v1layout.setContentsMargins(0, 0, 0, 0)
- v2layout.setContentsMargins(0, 0, 0, 0)
hlayout.setStretchFactor(self.v1widget, 10)
self.btnCopy = QPushButton()
self.btnRemove = QPushButton()
self.btnCompare = QPushButton()
+ self.btnClose = QPushButton()
self.rulesetView = RuleTreeView(m18nc('kajongg','Rule'), self.btnCopy, self.btnRemove, self.btnCompare)
v1layout.addWidget(self.rulesetView)
self.rulesetView.setWordWrap(True)
@@ -487,12 +489,34 @@ class RulesetSelector( QWidget):
self.btnCopy.clicked.connect(self.rulesetView.copyRow)
self.btnRemove.clicked.connect(self.rulesetView.removeRow)
self.btnCompare.clicked.connect(self.rulesetView.compareRow)
+ self.btnClose.clicked.connect(self.hide)
v2layout.addItem(spacerItem)
+ v2layout.addWidget(self.btnClose)
self.retranslateUi()
+ StateSaver(self)
+ self.show()
+
+ def sizeHint(self):
+ """we never want a horizontal scrollbar for player names,
+ we always want to see them in full"""
+ result = QWidget.sizeHint(self)
+ available = KApplication.kApplication().desktop().availableGeometry()
+ height = max(result.height(), available.height() * 2 // 3)
+ width = max(result.width(), available.width() // 2)
+ return QSize(width, height)
+
+ def minimumSizeHint(self):
+ """we never want a horizontal scrollbar for player names,
+ we always want to see them in full"""
+ return self.sizeHint()
+
+ def showEvent(self, dummyEvent):
+ """reload the rulesets"""
self.refresh()
def refresh(self):
- """reload the rulesets"""
+ """retranslate and reload rulesets"""
+ self.retranslateUi()
self.rulesetView.rulesets = Ruleset.availableRulesets()
def hideEvent(self, event):
@@ -504,6 +528,7 @@ class RulesetSelector( QWidget):
def retranslateUi(self):
"""translate to current language"""
- self.btnCopy.setText(m18n("&Copy"))
- self.btnRemove.setText(m18n("R&emove"))
- self.btnCompare.setText(m18nc('Kajongg ruleset comparer', 'C&ompare'))
+ self.btnCopy.setText(m18n("Copy"))
+ self.btnCompare.setText(m18nc('Kajongg ruleset comparer', 'Compare'))
+ self.btnRemove.setText(m18n("Remove"))
+ self.btnClose.setText(m18n('Close'))
More information about the kde-doc-english
mailing list