|
@@ -12,28 +12,33 @@
|
|
#include <QDesktopWidget>
|
|
#include <QDesktopWidget>
|
|
#include <QtConcurrent/QtConcurrent>
|
|
#include <QtConcurrent/QtConcurrent>
|
|
|
|
|
|
-MainWindow::MainWindow(LotroManager* mgr, QSettings* settings, QWidget *parent) :
|
|
|
|
- QMainWindow(parent, Qt::Window | Qt::FramelessWindowHint), app(app),
|
|
|
|
|
|
+MainWindow::MainWindow(QWidget *parent) :
|
|
|
|
+ QMainWindow(parent, Qt::Window | Qt::FramelessWindowHint),
|
|
ui(new Ui::MainWindow), menuHoverWidget(nullptr), menuHoverWidgetAnimation(nullptr)
|
|
ui(new Ui::MainWindow), menuHoverWidget(nullptr), menuHoverWidgetAnimation(nullptr)
|
|
{
|
|
{
|
|
|
|
+ ui->setupUi(this);
|
|
|
|
|
|
- QDebug << "Initialising Settings module";
|
|
|
|
|
|
+ qDebug() << "Initialising Settings module";
|
|
QSettings *settings = new QSettings(qApp->applicationDirPath() + "/legacy_v2.ini", QSettings::IniFormat);
|
|
QSettings *settings = new QSettings(qApp->applicationDirPath() + "/legacy_v2.ini", QSettings::IniFormat);
|
|
|
|
|
|
|
|
|
|
- QDebug << "Creating lotro manager instance & thread";
|
|
|
|
|
|
+ qDebug() << "Creating lotro manager instance & thread";
|
|
QThread *lotro_mgr_thread = new QThread();
|
|
QThread *lotro_mgr_thread = new QThread();
|
|
LotroManager *lotro_mgr = new LotroManager(settings);
|
|
LotroManager *lotro_mgr = new LotroManager(settings);
|
|
- QObject::connect(lotro_mgr_thread, &QThread::finished, lotro_mgr, &QObject::deleteLater, type=Qt::QueuedConnection);
|
|
|
|
|
|
+ QObject::connect(lotro_mgr_thread, &QThread::finished, lotro_mgr, &QObject::deleteLater, Qt::QueuedConnection);
|
|
lotro_mgr->moveToThread(lotro_mgr_thread);
|
|
lotro_mgr->moveToThread(lotro_mgr_thread);
|
|
- lotro_mgr_thread->run();
|
|
|
|
|
|
+ lotro_mgr_thread->start();
|
|
|
|
|
|
- QDebug << "Creating widgets";
|
|
|
|
|
|
+ qDebug() << "Creating widgets";
|
|
|
|
+ qDebug() << "1";
|
|
browse_widget = new BrowseWidget(lotro_mgr, settings, this);
|
|
browse_widget = new BrowseWidget(lotro_mgr, settings, this);
|
|
|
|
+ qDebug() << "2";
|
|
import_widget = new ImportWidget(lotro_mgr, settings, this);
|
|
import_widget = new ImportWidget(lotro_mgr, settings, this);
|
|
|
|
+ qDebug() << "3";
|
|
export_widget = new ExportWidget(lotro_mgr, settings, this);
|
|
export_widget = new ExportWidget(lotro_mgr, settings, this);
|
|
|
|
+ qDebug() << "4";
|
|
manage_widget = new ManageWidget(lotro_mgr, settings, this);
|
|
manage_widget = new ManageWidget(lotro_mgr, settings, this);
|
|
-
|
|
|
|
|
|
+ qDebug() << "Done. Adding to layouts";
|
|
ui->content_layout->addWidget(export_widget);
|
|
ui->content_layout->addWidget(export_widget);
|
|
ui->content_layout->addWidget(import_widget);
|
|
ui->content_layout->addWidget(import_widget);
|
|
ui->content_layout->addWidget(manage_widget);
|
|
ui->content_layout->addWidget(manage_widget);
|
|
@@ -48,16 +53,17 @@ MainWindow::MainWindow(LotroManager* mgr, QSettings* settings, QWidget *parent)
|
|
changeFontSizeRecursive(100, this);
|
|
changeFontSizeRecursive(100, this);
|
|
|
|
|
|
qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
|
|
qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
|
|
- background = new QPixmap();
|
|
|
|
- background->load(":/assets/backgrounds/bg" + QString::number(qrand() % MAX_PIXMAP_ID + 1) + ".png");
|
|
|
|
- setupWindowBackgroundAndMask();
|
|
|
|
|
|
+ current_bg_id = qrand() % MAX_PIXMAP_ID + 1;
|
|
|
|
+ QPixmap background(":/backgrounds/bg" + QString::number(current_bg_id) + ".png");
|
|
|
|
+ setupWindowBackgroundAndMask(background);
|
|
|
|
+
|
|
setupMenuHoverWidget();
|
|
setupMenuHoverWidget();
|
|
|
|
|
|
updateGeometry();
|
|
updateGeometry();
|
|
repaint();
|
|
repaint();
|
|
|
|
|
|
qDebug() << "Initialising background updates";
|
|
qDebug() << "Initialising background updates";
|
|
- background_update_timer.setInterval(30 * 1000);
|
|
|
|
|
|
+ background_update_timer.setInterval(20 * 1000);
|
|
connect(&background_update_timer, &QTimer::timeout, this, &MainWindow::randomChangeBackground);
|
|
connect(&background_update_timer, &QTimer::timeout, this, &MainWindow::randomChangeBackground);
|
|
background_update_timer.start();
|
|
background_update_timer.start();
|
|
|
|
|
|
@@ -94,7 +100,7 @@ void MainWindow::resizeEvent(QResizeEvent * event)
|
|
|
|
|
|
ui->content_area->move(width * 25 / 2000, height * 250 / 1296);
|
|
ui->content_area->move(width * 25 / 2000, height * 250 / 1296);
|
|
ui->content_area->resize(width * 1950 / 2000, height * 1000 / 1296);
|
|
ui->content_area->resize(width * 1950 / 2000, height * 1000 / 1296);
|
|
- setupWindowBackgroundAndMask();
|
|
|
|
|
|
+ setupWindowBackgroundAndMask(current_bg);
|
|
}
|
|
}
|
|
|
|
|
|
void MainWindow::randomChangeBackground()
|
|
void MainWindow::randomChangeBackground()
|
|
@@ -104,42 +110,33 @@ void MainWindow::randomChangeBackground()
|
|
|
|
|
|
qDebug() << "Starting background update";
|
|
qDebug() << "Starting background update";
|
|
|
|
|
|
- if (fade_animation_timer.isActive()) {
|
|
|
|
- qDebug() << "MainWindow::startBackgroundUpdate() - cannot start, because update is still active";
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
|
|
|
|
- next_pixmap_opacity = 0;
|
|
|
|
int next_pixmap_id = qrand() % MAX_PIXMAP_ID + 1;
|
|
int next_pixmap_id = qrand() % MAX_PIXMAP_ID + 1;
|
|
-
|
|
|
|
- if (!next_pixmap)
|
|
|
|
- next_pixmap = new QPixmap();
|
|
|
|
-
|
|
|
|
- next_pixmap->load(":/assets/backgrounds/bg" + QString::number(next_pixmap_id) + ".png");
|
|
|
|
- qDebug() << "Next pixmap id" << next_pixmap_id << "!";
|
|
|
|
-
|
|
|
|
- if (next_pixmap->isNull()) {
|
|
|
|
- qDebug() << "Incorrect pixmap id " << next_pixmap_id << "!";
|
|
|
|
- return;
|
|
|
|
|
|
+ while (next_pixmap_id == current_bg_id) {
|
|
|
|
+ next_pixmap_id = qrand() % MAX_PIXMAP_ID + 1;
|
|
}
|
|
}
|
|
|
|
+ qDebug() << "Next background id = " << next_pixmap_id;
|
|
|
|
+
|
|
|
|
+ QPixmap *cur_bg = new QPixmap(current_bg.scaled(size()));
|
|
|
|
+ QPixmap *new_bg= new QPixmap(QPixmap(":/backgrounds/bg" + QString::number(next_pixmap_id) + ".png").scaled(size()));
|
|
|
|
+ current_bg_id = next_pixmap_id;
|
|
|
|
|
|
- QtConcurrent::run([this](){
|
|
|
|
- qDebug() << "Starting background update";
|
|
|
|
- while (next_pixmap_opacity < 1 && qApp) {
|
|
|
|
- if (!qApp)
|
|
|
|
- return;
|
|
|
|
|
|
+ QtConcurrent::run([cur_bg, new_bg, this](){
|
|
|
|
+ const int iterations_num = 100;
|
|
|
|
+ const int iteration_sleep = 75;
|
|
|
|
|
|
|
|
+ for (int i = 0; i < iterations_num && qApp; i++) {
|
|
QPainter painter;
|
|
QPainter painter;
|
|
- painter.begin(background);
|
|
|
|
- painter.setOpacity(next_pixmap_opacity);
|
|
|
|
|
|
+ painter.begin(cur_bg);
|
|
|
|
+ painter.setOpacity(double(10 + i) / double(iterations_num));
|
|
painter.setCompositionMode(QPainter::CompositionMode_SourceIn);
|
|
painter.setCompositionMode(QPainter::CompositionMode_SourceIn);
|
|
- painter.drawPixmap(0,0, *next_pixmap);
|
|
|
|
|
|
+ painter.drawPixmap(0,0, *new_bg);
|
|
painter.end();
|
|
painter.end();
|
|
-
|
|
|
|
- setupWindowBackgroundAndMask();
|
|
|
|
- next_pixmap_opacity += 0.005;
|
|
|
|
- QThread::msleep(50);
|
|
|
|
|
|
+ QMetaObject::invokeMethod(this, "setupWindowBackgroundAndMask", Qt::QueuedConnection, Q_ARG(QPixmap, *cur_bg));
|
|
|
|
+ QThread::msleep(iteration_sleep);
|
|
}
|
|
}
|
|
|
|
+ delete cur_bg;
|
|
|
|
+ delete new_bg;
|
|
qDebug() << "Background update finished";
|
|
qDebug() << "Background update finished";
|
|
});
|
|
});
|
|
}
|
|
}
|
|
@@ -179,9 +176,11 @@ void MainWindow::onHoverMenuentry()
|
|
moveMenuHoverWidget(MenuEntry::getHoverLabel());
|
|
moveMenuHoverWidget(MenuEntry::getHoverLabel());
|
|
}
|
|
}
|
|
|
|
|
|
-void MainWindow::setupWindowBackgroundAndMask()
|
|
|
|
|
|
+void MainWindow::setupWindowBackgroundAndMask(QPixmap background)
|
|
{
|
|
{
|
|
- current_bg = background->scaled(width(), height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
|
|
|
|
|
+ if (!qApp)
|
|
|
|
+ return;
|
|
|
|
+ current_bg = background.scaled(width(), height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
|
current_mask = current_bg.mask();
|
|
current_mask = current_bg.mask();
|
|
setMask(current_mask);
|
|
setMask(current_mask);
|
|
|
|
|
|
@@ -243,10 +242,10 @@ void MainWindow::checkMenuIsHovered()
|
|
|
|
|
|
void MainWindow::hideAllContentWidgets()
|
|
void MainWindow::hideAllContentWidgets()
|
|
{
|
|
{
|
|
- export_frame->hide();
|
|
|
|
- import_frame->hide();
|
|
|
|
- manage_frame->hide();
|
|
|
|
- browse_frame->hide();
|
|
|
|
|
|
+ export_widget->hide();
|
|
|
|
+ import_widget->hide();
|
|
|
|
+ manage_widget->hide();
|
|
|
|
+ browse_widget->hide();
|
|
}
|
|
}
|
|
|
|
|
|
void MainWindow::changeFontSizeRecursive(size_t percent, QWidget *widget)
|
|
void MainWindow::changeFontSizeRecursive(size_t percent, QWidget *widget)
|