mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-09-14 05:46:48 +08:00
fix: improve how default background is determinated, hopefully improves #219
This commit is contained in:
parent
cdfa4ff7a1
commit
9712f20140
@ -107,6 +107,11 @@ CApplicationContext::CApplicationContext (int argc, char* argv []) {
|
|||||||
// to have any value
|
// to have any value
|
||||||
this->settings.general.screenBackgrounds [lastScreen] = translateBackground (optarg);
|
this->settings.general.screenBackgrounds [lastScreen] = translateBackground (optarg);
|
||||||
this->settings.general.screenScalings [lastScreen] = this->settings.render.window.scalingMode;
|
this->settings.general.screenScalings [lastScreen] = this->settings.render.window.scalingMode;
|
||||||
|
|
||||||
|
// update default background if not set
|
||||||
|
if (this->settings.general.defaultBackground.empty()) {
|
||||||
|
this->settings.general.defaultBackground = translateBackground (optarg);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'o': {
|
case 'o': {
|
||||||
|
@ -27,7 +27,6 @@ namespace WallpaperEngine::Application {
|
|||||||
CWallpaperApplication::CWallpaperApplication (CApplicationContext& context,
|
CWallpaperApplication::CWallpaperApplication (CApplicationContext& context,
|
||||||
WallpaperEngine::WebBrowser::CWebBrowserContext& browserContext) :
|
WallpaperEngine::WebBrowser::CWebBrowserContext& browserContext) :
|
||||||
m_context (context),
|
m_context (context),
|
||||||
m_defaultBackground (nullptr),
|
|
||||||
m_browserContext (browserContext) {
|
m_browserContext (browserContext) {
|
||||||
this->loadBackgrounds ();
|
this->loadBackgrounds ();
|
||||||
this->setupProperties ();
|
this->setupProperties ();
|
||||||
@ -168,17 +167,12 @@ void CWallpaperApplication::setupContainer (CCombinedContainer& container, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CWallpaperApplication::loadBackgrounds () {
|
void CWallpaperApplication::loadBackgrounds () {
|
||||||
// load default background if specified
|
for (const auto& [screen, path] : this->m_context.settings.general.screenBackgrounds) {
|
||||||
if (!this->m_context.settings.general.defaultBackground.empty ()) {
|
// screens with no screen should use the default
|
||||||
this->m_defaultBackground = this->loadBackground (this->m_context.settings.general.defaultBackground);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const auto& [background, path] : this->m_context.settings.general.screenBackgrounds) {
|
|
||||||
// screens with no background should use the default
|
|
||||||
if (path.empty ()) {
|
if (path.empty ()) {
|
||||||
this->m_backgrounds [background] = this->m_defaultBackground;
|
this->m_backgrounds [screen] = this->loadBackground (this->m_context.settings.general.defaultBackground);
|
||||||
} else {
|
} else {
|
||||||
this->m_backgrounds [background] = this->loadBackground (path);
|
this->m_backgrounds [screen] = this->loadBackground (path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -211,9 +205,6 @@ void CWallpaperApplication::setupPropertiesForProject (const Core::CProject* pro
|
|||||||
void CWallpaperApplication::setupProperties () {
|
void CWallpaperApplication::setupProperties () {
|
||||||
for (const auto& [backgrounc, info] : this->m_backgrounds)
|
for (const auto& [backgrounc, info] : this->m_backgrounds)
|
||||||
this->setupPropertiesForProject (info);
|
this->setupPropertiesForProject (info);
|
||||||
|
|
||||||
if (this->m_defaultBackground != nullptr)
|
|
||||||
this->setupPropertiesForProject (this->m_defaultBackground);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWallpaperApplication::takeScreenshot (const std::filesystem::path& filename, FREE_IMAGE_FORMAT format) {
|
void CWallpaperApplication::takeScreenshot (const std::filesystem::path& filename, FREE_IMAGE_FORMAT format) {
|
||||||
@ -419,10 +410,6 @@ const std::map<std::string, Core::CProject*>& CWallpaperApplication::getBackgrou
|
|||||||
return this->m_backgrounds;
|
return this->m_backgrounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::CProject* CWallpaperApplication::getDefaultBackground () const {
|
|
||||||
return this->m_defaultBackground;
|
|
||||||
}
|
|
||||||
|
|
||||||
CApplicationContext& CWallpaperApplication::getContext () const {
|
CApplicationContext& CWallpaperApplication::getContext () const {
|
||||||
return this->m_context;
|
return this->m_context;
|
||||||
}
|
}
|
||||||
|
@ -59,10 +59,6 @@ class CWallpaperApplication {
|
|||||||
* @return Maps screens to loaded backgrounds
|
* @return Maps screens to loaded backgrounds
|
||||||
*/
|
*/
|
||||||
[[nodiscard]] const std::map<std::string, Core::CProject*>& getBackgrounds () const;
|
[[nodiscard]] const std::map<std::string, Core::CProject*>& getBackgrounds () const;
|
||||||
/**
|
|
||||||
* @return The default background to use if no specific project is loaded
|
|
||||||
*/
|
|
||||||
[[nodiscard]] Core::CProject* getDefaultBackground () const;
|
|
||||||
/**
|
/**
|
||||||
* @return The current application context
|
* @return The current application context
|
||||||
*/
|
*/
|
||||||
@ -114,8 +110,6 @@ class CWallpaperApplication {
|
|||||||
*/
|
*/
|
||||||
void takeScreenshot (const std::filesystem::path& filename, FREE_IMAGE_FORMAT format);
|
void takeScreenshot (const std::filesystem::path& filename, FREE_IMAGE_FORMAT format);
|
||||||
|
|
||||||
/** The default background to display if no specific background was loaded */
|
|
||||||
Core::CProject* m_defaultBackground;
|
|
||||||
/** The application context that contains the current app settings */
|
/** The application context that contains the current app settings */
|
||||||
CApplicationContext& m_context;
|
CApplicationContext& m_context;
|
||||||
/** Maps screens to backgrounds */
|
/** Maps screens to backgrounds */
|
||||||
|
@ -27,19 +27,6 @@ const ITexture* CTextureCache::resolve (const std::string& filename) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->getContext ().getApp ().getDefaultBackground () != nullptr) {
|
|
||||||
try {
|
|
||||||
const ITexture* texture =
|
|
||||||
this->getContext ().getApp ().getDefaultBackground ()->getContainer ()->readTexture (filename);
|
|
||||||
|
|
||||||
this->store (filename, texture);
|
|
||||||
|
|
||||||
return texture;
|
|
||||||
} catch (CAssetLoadException&) {
|
|
||||||
// ignored, this happens if we're looking at the wrong background
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
throw CAssetLoadException (filename, "Cannot find file");
|
throw CAssetLoadException (filename, "Cannot find file");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user