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);
46KGameDifficultyLevel::KGameDifficultyLevel(int hardness, const QByteArray &key, const QString &title, bool isDefault)
69KGameDifficultyLevelPrivate *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("@title:menu Game difficulty level", "Difficulty"), window);
KComboBox(bool rw, QWidget *parent=nullptr)
QString readEntry(const char *key, const char *aDefault=nullptr) const
Definition kgamedifficulty.h:25
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
KGameDifficulty manages difficulty levels of a game in a standard way.
Definition kgamedifficulty.h:89
void selectedLevelChanged(const KGameDifficultyLevel *level)
Emitted after every call to select(), even when the user has rejected the change.
void editableChanged(bool editable)
Emitted when the editability changes.
static KGameDifficultyLevel::StandardLevel globalLevel()
A shortcut for KGameDifficulty::global()->currentLevel()->standardLevel().
Definition kgamedifficulty.cpp:338
void gameRunningChanged(bool gameRunning)
Emitted when a running game has been marked or unmarked.
void addStandardLevel(KGameDifficultyLevel::StandardLevel level, bool isDefault=false)
A shortcut for addLevel(new KGameDifficultyLevel(level)).
Definition kgamedifficulty.cpp:201
void select(const KGameDifficultyLevel *level)
Select a new difficulty level.
Definition kgamedifficulty.cpp:305
void setEditable(bool editable)
Set whether the difficulty level selection may be edited.
Definition kgamedifficulty.cpp:276
void setGameRunning(bool running)
KGameDifficulty has optional protection against changing the difficulty level while a game is running...
Definition kgamedifficulty.cpp:294
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 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
QList< const KGameDifficultyLevel * > levels() const
Definition kgamedifficulty.cpp:236
void currentLevelChanged(const KGameDifficultyLevel *level)
Emitted when a new difficulty level has been selected.
QAction * addAction(const QIcon &icon, const QString &text)
KSelectAction(const QIcon &icon, const QString &text, QObject *parent)
void indexTriggered(int index)
bool setCurrentItem(int index)
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
The namespace for methods to integrate KGameDifficulty into the UI.
Definition kgamedifficulty.cpp:346
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
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)
Continue
QStringView level(QStringView ifopt)
void setEnabled(bool)
void setToolTip(const QString &tip)
void setWhatsThis(const QString &what)
void activated(int index)
void addItem(const QIcon &icon, const QString &text, const QVariant &userData)
void setCurrentIndex(int index)
QIcon fromTheme(const QString &name)
qsizetype indexOf(const AT &value, qsizetype from) const const
T value(qsizetype i) const const
Q_EMITQ_EMIT
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
Q_SLOTSQ_SLOTS
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
objectName
QObject * parent() const const
void setObjectName(QAnyStringView name)
void setParent(QObject *parent)
QAction * addAction(const QIcon &icon, const QString &text)
void setEnabled(bool)
void setToolTip(const QString &)
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:50:49 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:50:49 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.