aboutsummaryrefslogtreecommitdiff
path: root/src/aoimage.cpp
diff options
context:
space:
mode:
authorCrystalwarrior <varsash@gmail.com>2019-09-16 21:08:43 +0300
committerCrystalwarrior <varsash@gmail.com>2019-09-16 21:08:43 +0300
commitb085be5a2a0512c432bc9fd58413a9d8f93d451e (patch)
tree871d7b8c85a7df9db13ab0f9fb35703d9a50628a /src/aoimage.cpp
parentb037edc9d8360ee679cae8d5f6c4d138ede4482b (diff)
Add two new helper functions - get_design_element and get_static_image_suffix
Modify all set_image calls to utilize said suffix helper function Dynamically change betweehn chatblank, chat, chatmed, chatbig based on the showname's length Use char.ini showname if showname is set to whitespace (doesn't yet check if char.ini showname is also whitespace)
Diffstat (limited to 'src/aoimage.cpp')
-rw-r--r--src/aoimage.cpp33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/aoimage.cpp b/src/aoimage.cpp
index 7bb56bb6..17c2ea61 100644
--- a/src/aoimage.cpp
+++ b/src/aoimage.cpp
@@ -13,35 +13,40 @@ AOImage::~AOImage()
}
-void AOImage::set_image(QString p_image)
+bool AOImage::set_image(QString p_image)
{
- QString theme_image_path = ao_app->get_theme_path(p_image);
- QString default_image_path = ao_app->get_default_theme_path(p_image);
+ QString theme_image_path = ao_app->get_static_image_suffix(ao_app->get_theme_path(p_image));
+ QString default_image_path = ao_app->get_static_image_suffix(ao_app->get_default_theme_path(p_image));
QString final_image_path;
if (file_exists(theme_image_path))
final_image_path = theme_image_path;
- else
+ else if (file_exists(default_image_path))
final_image_path = default_image_path;
+ else
+ {
+ qDebug() << "Warning: Image" << p_image << "not found! Can't set!";
+ return false;
+ }
QPixmap f_pixmap(final_image_path);
this->setPixmap(f_pixmap.scaled(this->width(), this->height(), Qt::IgnoreAspectRatio));
+ return true;
}
-void AOImage::set_image_from_path(QString p_path)
+bool AOImage::set_chatbox(QString p_path)
{
- QString default_path = ao_app->get_default_theme_path("chatmed.png");
-
- QString final_path;
-
- if (file_exists(p_path))
- final_path = p_path;
- else
- final_path = default_path;
+ p_path = ao_app->get_static_image_suffix(p_path);
+ if (!file_exists(p_path))
+ {
+ qDebug() << "Warning: Chatbox" << p_path << "not found! Can't set!";
+ return false;
+ }
- QPixmap f_pixmap(final_path);
+ QPixmap f_pixmap(p_path);
this->setPixmap(f_pixmap.scaled(this->width(), this->height(), Qt::IgnoreAspectRatio));
+ return true;
}