mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-09-03 01:42:20 +08:00
Support save current theme setting when exit; Use QScreen::primaryScreen() instead of QDesktopWidget to get desktop size; Ensure only one instance will be running at the same time.
45 lines
996 B
C++
45 lines
996 B
C++
#include "progressload.h"
|
|
|
|
#include <DApplicationHelper>
|
|
|
|
ProgressLoad::ProgressLoad(QWidget *parent) :
|
|
QWidget(parent),
|
|
m_progess(new QWidget(this)),
|
|
timer(new QTimer),
|
|
value(0)
|
|
{
|
|
m_progess->move(0,0);
|
|
m_progess->show();
|
|
|
|
timer->setInterval(10);
|
|
timer->start();
|
|
connect(timer, &QTimer::timeout, [=]()
|
|
{
|
|
m_progess->setFixedWidth(width() / 100 * value);
|
|
m_progess->setFixedHeight(height());
|
|
});
|
|
}
|
|
|
|
void ProgressLoad::setValue(int v)
|
|
{
|
|
value = v;
|
|
m_progess->setFixedWidth(width() / 100 * value);
|
|
}
|
|
|
|
void ProgressLoad::setTheme(bool dark, QColor color)
|
|
{
|
|
if(dark)
|
|
{
|
|
plt.setColor(QPalette::Background, QColor(40, 40, 40));
|
|
setAutoFillBackground(true);
|
|
setPalette(plt);
|
|
}
|
|
else
|
|
{
|
|
plt.setColor(QPalette::Background, QColor(255, 255, 255));
|
|
setAutoFillBackground(true);
|
|
setPalette(plt);
|
|
}
|
|
m_progess->setStyleSheet("background-color: " + color.name() + ";");
|
|
}
|