[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdegames
From: Stefan Majewsky <majewsky () gmx ! net>
Date: 2012-02-20 21:57:36
Message-ID: 20120220215736.AE9BEAC896 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1281273 by majewsky:
Enhance the KgDifficulty API with Albert's suggestions.
M +1 -1 kdiamond/src/mainwindow.cpp
M +12 -4 libkdegames/kgdifficulty.cpp
M +16 -7 libkdegames/kgdifficulty.h
--- trunk/KDE/kdegames/kdiamond/src/mainwindow.cpp #1281272:1281273
@@ -75,7 +75,7 @@
m_difficulty = new KgDifficulty(this);
m_difficulty->addStandardLevelRange(KgDifficultyLevel::VeryEasy, KgDifficultyLevel::VeryHard);
KgDifficultyGUI::init(m_difficulty, this);
- connect(m_difficulty, SIGNAL(changed(const KgDifficultyLevel*)), SLOT(startGameDispatcher()));
+ connect(m_difficulty, SIGNAL(currentLevelChanged(const KgDifficultyLevel*)), \
SLOT(startGameDispatcher())); //late GUI initialisation
setupGUI(QSize(300, 400)); //TODO: find better solution for a minimum size
setCaption(i18nc("The application's name", "KDiamond"));
--- trunk/KDE/kdegames/libkdegames/kgdifficulty.cpp #1281272:1281273
@@ -179,9 +179,16 @@
++it;
}
d->m_levels.insert(it, level);
+ level->setParent(this);
}
typedef KgDifficultyLevel::StandardLevel DS;
+
+void KgDifficulty::addStandardLevel(DS level)
+{
+ addLevel(new KgDifficultyLevel(level));
+}
+
void KgDifficulty::addStandardLevelRange(DS from, DS to)
{
const QVector<DS> levels = QVector<DS>()
@@ -278,13 +285,13 @@
);
if (result != KMessageBox::Continue)
{
- emit selected(d->m_currentLevel);
+ emit selectedLevelChanged(d->m_currentLevel);
return;
}
}
d->m_currentLevel = level;
- emit selected(level);
- emit changed(level);
+ emit selectedLevelChanged(level);
+ emit currentLevelChanged(level);
}
//END KgDifficulty
@@ -330,7 +337,8 @@
selector->setToolTip(i18nc("Game difficulty level", "Difficulty"));
QObject::connect(selector, SIGNAL(activated(int)), selector, SLOT(slotActivated(int)));
QObject::connect(difficulty, SIGNAL(editableChanged(bool)), selector, SLOT(setEnabled(bool)));
- QObject::connect(difficulty, SIGNAL(selected(const KgDifficultyLevel*)), selector, \
SLOT(slotSelected(const KgDifficultyLevel*))); + QObject::connect(difficulty, \
SIGNAL(selectedLevelChanged(const KgDifficultyLevel*)), + selector, SLOT(slotSelected(const \
KgDifficultyLevel*))); QObject::connect(selector, SIGNAL(signalSelected(int)), selector, \
SLOT(setCurrentIndex(int)));
//create menu action
--- trunk/KDE/kdegames/libkdegames/kgdifficulty.h #1281272:1281273
@@ -30,8 +30,15 @@
* @class KgDifficultyLevel kgdifficulty.h <KgDifficultyLevel>
* @see KgDifficulty
*/
-class KDEGAMES_EXPORT KgDifficultyLevel
+class KDEGAMES_EXPORT KgDifficultyLevel : public QObject
{
+ Q_OBJECT
+ Q_DISABLE_COPY(KgDifficultyLevel)
+ Q_PROPERTY(int hardness READ hardness)
+ Q_PROPERTY(QByteArray key READ key)
+ Q_PROPERTY(QString title READ title)
+ Q_ENUMS(StandardLevel)
+ Q_PROPERTY(StandardLevel standardLevel READ standardLevel)
public:
enum StandardLevel
{
@@ -48,7 +55,7 @@
///Refer to the getters' documentation for details on the params.
KgDifficultyLevel(int hardness, const QByteArray& key, const QString& title);
- KgDifficultyLevel(StandardLevel level);
+ explicit KgDifficultyLevel(StandardLevel level);
virtual ~KgDifficultyLevel();
///@return a numeric key which is used to sort the levels by difficulty
@@ -87,18 +94,20 @@
Q_OBJECT
Q_DISABLE_COPY(KgDifficulty)
//Use currentLevel in game logic and selectedLevel in level selection UI.
- Q_PROPERTY(const KgDifficultyLevel* currentLevel READ currentLevel WRITE select NOTIFY changed)
- Q_PROPERTY(const KgDifficultyLevel* selectedLevel READ currentLevel WRITE select NOTIFY selected)
+ Q_PROPERTY(const KgDifficultyLevel* currentLevel READ currentLevel WRITE select NOTIFY \
currentLevelChanged) + Q_PROPERTY(const KgDifficultyLevel* selectedLevel READ currentLevel WRITE select \
NOTIFY selectedLevelChanged) Q_PROPERTY(bool editable READ isEditable WRITE setEditable NOTIFY \
editableChanged) Q_PROPERTY(bool gameRunning READ isGameRunning WRITE setGameRunning NOTIFY \
gameRunningChanged) public:
- KgDifficulty(QObject* parent = 0);
+ explicit KgDifficulty(QObject* parent = 0);
///Destroys this instance and all DifficultyLevel instances in it.
virtual ~KgDifficulty();
///Adds a difficulty level to this instance. This will not affect the
///currentLevel() if there is one.
void addLevel(KgDifficultyLevel* level);
+ ///A shortcut for addLevel(new KgDifficultyLevel(@a level)).
+ void addStandardLevel(KgDifficultyLevel::StandardLevel level);
///This convenience method adds a range of standard levels to this
///instance (including the boundaries). For example:
///@code
@@ -139,11 +148,11 @@
///Emitted when a running game has been marked or unmarked. @see setGameRunning
void gameRunningChanged(bool gameRunning);
///Emitted when a new difficulty level has been selected.
- void changed(const KgDifficultyLevel* level);
+ void currentLevelChanged(const KgDifficultyLevel* level);
///Emitted after every call to select(), even when the user has rejected
///the change. This is useful to reset a difficulty level selection UI
///after a rejected change.
- void selected(const KgDifficultyLevel* level);
+ void selectedLevelChanged(const KgDifficultyLevel* level);
public Q_SLOTS:
///Select a new difficulty level. The given level must already have been
///added to this instance.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic