KDEGames
kgamedifficulty.cpp
42 KGameDifficultyLevelPrivate(int hardness, const QByteArray &key, const QString &title, KGameDifficultyLevel::StandardLevel level, bool isDefault);
43 static KGameDifficultyLevelPrivate *fromStandardLevel(KGameDifficultyLevel::StandardLevel level, bool isDefault);
46 KGameDifficultyLevel::KGameDifficultyLevel(int hardness, const QByteArray &key, const QString &title, bool isDefault)
69 KGameDifficultyLevelPrivate *KGameDifficultyLevelPrivate::fromStandardLevel(KGameDifficultyLevel::StandardLevel level, bool isDefault)
71 Q_ASSERT_X(level != KGameDifficultyLevel::Custom, "KGameDifficultyLevel(StandardLevel) constructor", "Custom level not allowed here");
72 // The first entry in the pair is to be used as a key so don't change it. It doesn't have to match the string to be translated
76 data = qMakePair(QByteArrayLiteral("Ridiculously Easy"), i18nc("Game difficulty level 1 out of 8", "Ridiculously Easy"));
79 data = qMakePair(QByteArrayLiteral("Very Easy"), i18nc("Game difficulty level 2 out of 8", "Very Easy"));
85 data = qMakePair(QByteArrayLiteral("Medium"), i18nc("Game difficulty level 4 out of 8", "Medium"));
91 data = qMakePair(QByteArrayLiteral("Very Hard"), i18nc("Game difficulty level 6 out of 8", "Very Hard"));
94 data = qMakePair(QByteArrayLiteral("Extremely Hard"), i18nc("Game difficulty level 7 out of 8", "Extremely Hard"));
97 data = qMakePair(QByteArrayLiteral("Impossible"), i18nc("Game difficulty level 8 out of 8", "Impossible"));
189 Q_ASSERT_X(d->m_currentLevel == nullptr, "KGameDifficulty::addLevel", "Only allowed before currentLevel() is called.");
192 auto it = std::find_if(d->m_levels.begin(), d->m_levels.end(), [newLevelHardness](const KGameDifficultyLevel *l) {
228 && (defaultLevelIndex == KGameDifficultyLevel::Custom || (defaultLevelIndex >= fromIndex && defaultLevelIndex <= toIndex)),
404 QObject::connect(difficulty, &KGameDifficulty::editableChanged, selector, &QWidget::setEnabled);
405 QObject::connect(difficulty, &KGameDifficulty::selectedLevelChanged, selector, &Selector::slotSelected);
410 KSelectAction *menu = new KGameDifficultyGUI::Menu(icon, i18nc("Game difficulty level", "Difficulty"), window);
void currentLevelChanged(const KGameDifficultyLevel *level)
Emitted when a new difficulty level has been selected.
void addStandardLevelRange(KGameDifficultyLevel::StandardLevel from, KGameDifficultyLevel::StandardLevel to)
This convenience method adds a range of standard levels to this instance (including the boundaries).
Definition: kgamedifficulty.cpp:206
KGameDifficultyLevel(int hardness, const QByteArray &key, const QString &title, bool isDefault=false)
Refer to the getters' documentation for details on the params.
Definition: kgamedifficulty.cpp:46
ButtonCode warningContinueCancel(QWidget *parent, const QString &text, const QString &title=QString(), const KGuiItem &buttonContinue=KStandardGuiItem::cont(), const KGuiItem &buttonCancel=KStandardGuiItem::cancel(), const QString &dontAskAgainName=QString(), Options options=Notify)
Q_EMITQ_EMIT
void editableChanged(bool editable)
Emitted when the editability changes.
QIcon fromTheme(const QString &name)
QStringView level(QStringView ifopt)
void setCurrentIndex(int index)
QAction * addAction(const QIcon &icon, const QString &text)
KGameDifficulty manages difficulty levels of a game in a standard way.
Definition: kgamedifficulty.h:88
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void indexTriggered(int index)
QList< const KGameDifficultyLevel * > levels() const
Definition: kgamedifficulty.cpp:236
QString i18n(const char *text, const TYPE &arg...)
int indexOf(const T &value, int from) const const
void addLevel(KGameDifficultyLevel *level)
Adds a difficulty level to this instance.
Definition: kgamedifficulty.cpp:181
~KGameDifficulty() override
Destroys this instance and all DifficultyLevel instances in it.
Definition: kgamedifficulty.cpp:174
void gameRunningChanged(bool gameRunning)
Emitted when a running game has been marked or unmarked.
Definition: kgamedifficulty.cpp:345
void setWhatsThis(const QString &what)
void setEnabled(bool)
void select(const KGameDifficultyLevel *level)
Select a new difficulty level.
Definition: kgamedifficulty.cpp:305
void addStandardLevel(KGameDifficultyLevel::StandardLevel level, bool isDefault=false)
A shortcut for addLevel(new KGameDifficultyLevel(level)).
Definition: kgamedifficulty.cpp:201
void setGameRunning(bool running)
KGameDifficulty has optional protection against changing the difficulty level while a game is running...
Definition: kgamedifficulty.cpp:294
void setToolTip(const QString &tip)
void setEnabled(bool)
void init(KXmlGuiWindow *window, KGameDifficulty *difficulty=nullptr)
Install standard GUI components for the manipulation of the given KGameDifficulty instance in the giv...
Definition: kgamedifficulty.cpp:394
void setObjectName(const QString &name)
void setParent(QObject *parent)
bool setCurrentItem(int index)
QString i18nc(const char *context, const char *text, const TYPE &arg...)
Definition: kgamedifficulty.h:24
static KGameDifficultyLevel::StandardLevel globalLevel()
A shortcut for KGameDifficulty::global()->currentLevel()->standardLevel().
Definition: kgamedifficulty.cpp:338
void addAction(QAction *action)
void setEditable(bool editable)
Set whether the difficulty level selection may be edited.
Definition: kgamedifficulty.cpp:276
void selectedLevelChanged(const KGameDifficultyLevel *level)
Emitted after every call to select(), even when the user has rejected the change.
void activated(int index)
QObject * parent() const const
T value(int i) const const
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Thu Dec 7 2023 03:50:24 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2023 The KDE developers.
Generated on Thu Dec 7 2023 03:50:24 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.