diff --git a/.arcconfig b/.arcconfig new file mode 100644 --- /dev/null +++ b/.arcconfig @@ -0,0 +1,3 @@ +{ + "phabricator.uri" : "https://phabricator.kde.org/" +} diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,7 @@ XmlGui ) -find_package(KF5KDEGames 4.9.0 REQUIRED) +find_package(KF5KDEGames 7.1.0 REQUIRED) include(FeatureSummary) include(ECMInstallIcons) diff --git a/KBlocksScene.cpp b/KBlocksScene.cpp --- a/KBlocksScene.cpp +++ b/KBlocksScene.cpp @@ -34,7 +34,7 @@ QString themeFile(Settings::theme()); mpGrafx = new KBlocksGraphics(themeFile); - mpSnd = new KBlocksSound(); + mpSnd = new KBlocksSound(themeFile); int width = (capacity >= mSceneGamesPerLine) ? mSceneGamesPerLine : (capacity % mSceneGamesPerLine); int height = (int)(capacity / (mSceneGamesPerLine + 1)) + 1; @@ -162,6 +162,8 @@ mpGrafx->loadTheme(Settings::theme()); mpGrafx->adjustForSize(viewSize); updateDimensions(); + // also update sounds fo rthe theme + mpSnd->loadTheme(Settings::theme()); } } diff --git a/KBlocksSound.h b/KBlocksSound.h --- a/KBlocksSound.h +++ b/KBlocksSound.h @@ -11,6 +11,9 @@ #ifndef KBLOCKSSOUND_H #define KBLOCKSSOUND_H +#define USE_UNSTABLE_LIBKDEGAMESPRIVATE_API +#include + class KgSound; enum class Sound { @@ -22,18 +25,24 @@ class KBlocksSound { public: - KBlocksSound(); + KBlocksSound(const QString &themeFile); ~KBlocksSound(); public: + bool loadTheme(const QString &themeFile); void setSoundsEnabled(bool p_enabled); void playSound(Sound soundType); + KGameTheme *theme() + { + return m_theme; + } private: KgSound *m_blockFallSound = nullptr; KgSound *m_blockMoveSound = nullptr; KgSound *m_blockRemoveSound = nullptr; bool sndActive; + KGameTheme *m_theme; }; diff --git a/KBlocksSound.cpp b/KBlocksSound.cpp --- a/KBlocksSound.cpp +++ b/KBlocksSound.cpp @@ -19,24 +19,58 @@ #include "kblocks_sound_debug.h" #include "settings.h" -KBlocksSound::KBlocksSound() +KBlocksSound::KBlocksSound(const QString &themeFile) { - m_blockFallSound = new KgSound(QStandardPaths::locate( - QStandardPaths::AppDataLocation, QStringLiteral("sounds/block-fall.ogg"))); - m_blockMoveSound = new KgSound(QStandardPaths::locate( - QStandardPaths::AppDataLocation, QStringLiteral("sounds/block-move.ogg"))); - m_blockRemoveSound = new KgSound(QStandardPaths::locate( - QStandardPaths::AppDataLocation, QStringLiteral("sounds/block-remove.ogg"))); - setSoundsEnabled(Settings::sounds()); + loadTheme(themeFile); } KBlocksSound::~KBlocksSound() { + delete m_theme; delete m_blockFallSound; delete m_blockMoveSound; delete m_blockRemoveSound; } +bool KBlocksSound::loadTheme(const QString &themeFile) +{ + m_theme = new KGameTheme(); + if (!m_theme->load(themeFile)) { + qCWarning(KBSound) << "Error loading KBlocks .desktop theme" + << themeFile << endl; + m_theme->loadDefault(); + } + + QString m_themeMoveSound; + if (m_theme->themeProperty("Sound_Block_Move") != "") { + m_themeMoveSound = m_theme->prefix() + m_theme->themeProperty("Sound_Block_Move"); + } else { + m_themeMoveSound = QStandardPaths::locate( + QStandardPaths::AppDataLocation, QStringLiteral("sounds/block-move.ogg")); + } + + QString m_themeFallSound; + if (m_theme->themeProperty("Sound_Block_Fall") != "") { + m_themeFallSound = m_theme->prefix() + m_theme->themeProperty("Sound_Block_Fall"); + } else { + m_themeFallSound = QStandardPaths::locate( + QStandardPaths::AppDataLocation, QStringLiteral("sounds/block-fall.ogg")); + } + + QString m_themeRemoveSound; + if (m_theme->themeProperty("Sound_Block_Remove") != "") { + m_themeRemoveSound = m_theme->prefix() + m_theme->themeProperty("Sound_Block_Remove"); + } else { + m_themeRemoveSound = QStandardPaths::locate( + QStandardPaths::AppDataLocation, QStringLiteral("sounds/block-remove.ogg")); + } + + m_blockFallSound = new KgSound(m_themeFallSound); + m_blockMoveSound = new KgSound(m_themeMoveSound); + m_blockRemoveSound = new KgSound(m_themeRemoveSound); + return true; +} + void KBlocksSound::setSoundsEnabled(bool p_enabled) { sndActive = p_enabled;