This repository has been archived by the owner on Jun 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aoimage.cpp
62 lines (46 loc) · 1.4 KB
/
aoimage.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//////////////////////////////////////////////////
//
// This work is licensed under the MIT license.
//
// You are free to copy, modify and distribute
// this work freely given that proper attribution
// is supplied and the author is not held liable.
// See LICENSE for details.
//
// Copyright (c) 2016-2018 David "OmniTroid" Skoland
//
//////////////////////////////////////////////////
#include "file_functions.h"
#include "aoimage.h"
#include <QDebug>
AOImage::AOImage(QWidget *parent, AOApplication *p_ao_app) : QLabel(parent)
{
m_parent = parent;
ao_app = p_ao_app;
}
AOImage::~AOImage()
{
}
void 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 final_image_path;
if (file_exists(theme_image_path))
final_image_path = theme_image_path;
else
final_image_path = default_image_path;
QPixmap f_pixmap(final_image_path);
this->setPixmap(f_pixmap.scaled(this->width(), this->height(), Qt::IgnoreAspectRatio));
}
void AOImage::set_image_from_path(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;
QPixmap f_pixmap(final_path);
this->setPixmap(f_pixmap.scaled(this->width(), this->height(), Qt::IgnoreAspectRatio));
}