|
@@ -2,9 +2,6 @@
|
|
|
#include "ui_mainwindow.h"
|
|
|
#include "constants.h"
|
|
|
|
|
|
-#include "models/patchdownloader.h"
|
|
|
-#include "models/lotrodatmanager.h"
|
|
|
-
|
|
|
#include "widgets/chooseversiondialog.h"
|
|
|
#include "widgets/dialogwindow.h"
|
|
|
|
|
@@ -23,91 +20,84 @@
|
|
|
#include <QNetworkAccessManager>
|
|
|
|
|
|
#include <ui_statuswidget.h>
|
|
|
+
|
|
|
namespace Ui {
|
|
|
class StatusWidget;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-MainWindow::MainWindow(QWidget *parent) :
|
|
|
- QMainWindow(parent, Qt::Window | Qt::FramelessWindowHint),
|
|
|
- ui(new Ui::MainWindow), menuHoverWidget(nullptr), menuHoverWidgetAnimation(nullptr)
|
|
|
+MainWindow::MainWindow(PatchList *legacy_patches, QWidget *parent)
|
|
|
+ : QMainWindow(parent, Qt::Window | Qt::FramelessWindowHint)
|
|
|
+ , legacy_patches_(legacy_patches)
|
|
|
+ , ui(new Ui::MainWindow)
|
|
|
+ , current_active_entry_(nullptr)
|
|
|
+ , current_hovered_entry_(nullptr)
|
|
|
+ , status_widget_(nullptr)
|
|
|
+ , settings_widget_(nullptr)
|
|
|
+ , help_widget_(nullptr)
|
|
|
+ , about_widget_(nullptr)
|
|
|
+ , choose_locale_dialog_(nullptr)
|
|
|
+ , dialog_window_(nullptr)
|
|
|
+ , menu_hover_widget_(nullptr)
|
|
|
+ , menu_hover_widget_animation_(nullptr)
|
|
|
{
|
|
|
constructFonts();
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
- currently_active_entry = ui->menuentry_1;
|
|
|
- currently_hover_entry = nullptr;
|
|
|
-
|
|
|
- qDebug() << "Creating patch downloader instance & thread";
|
|
|
- lotro_functions_thread = new QThread();
|
|
|
- patch_updater = new PatchDownloader();
|
|
|
- lotro_manager = new LotroDatManager();
|
|
|
-
|
|
|
-// connect(patch_updater, &PatchDownloader::checkForUpdatesStarted, this, &MainWindow::onPatchDownloaderStarted, Qt::BlockingQueuedConnection);
|
|
|
-// connect(patch_updater, &PatchDownloader::checkForUpdatesFinished, this, &MainWindow::onPatchDownloaderFinished, Qt::BlockingQueuedConnection);
|
|
|
-// connect(lotro_manager, &LotroDatManager::processStarted, this, &MainWindow::onLotroManagerStarted, Qt::BlockingQueuedConnection);
|
|
|
-// connect(lotro_manager, &LotroDatManager::processFinished, this, &MainWindow::onLotroManagerFinished, Qt::BlockingQueuedConnection);
|
|
|
-// connect(lotro_manager, &LotroDatManager::caughtError, this, &MainWindow::onLotroManagerErrorOccured, Qt::BlockingQueuedConnection);
|
|
|
+ current_active_entry_ = ui->menuentry_1;
|
|
|
+ current_hovered_entry_ = nullptr;
|
|
|
|
|
|
- connect(lotro_functions_thread, &QThread::finished, patch_updater, &QObject::deleteLater, Qt::QueuedConnection);
|
|
|
- connect(lotro_functions_thread, &QThread::finished, lotro_manager, &QObject::deleteLater, Qt::QueuedConnection);
|
|
|
- patch_updater->moveToThread(lotro_functions_thread);
|
|
|
- lotro_manager->moveToThread(lotro_functions_thread);
|
|
|
- lotro_functions_thread->start();
|
|
|
+ qDebug() << __FUNCTION__ << "Initialising main frame...";
|
|
|
+ status_widget_ = new StatusWidget(legacy_patches_, this);
|
|
|
+ settings_widget_ = new SettingsWidget(legacy_patches_, this);
|
|
|
+ help_widget_ = new HelpWidget(legacy_patches_, this);
|
|
|
+ about_widget_ = new AboutWidget(legacy_patches_, this);
|
|
|
|
|
|
- qDebug() << "Initialising lotro manager...";
|
|
|
- QMetaObject::invokeMethod(lotro_manager, "InitialiseManager", Qt::QueuedConnection);
|
|
|
+ ui->content_layout->addWidget(status_widget_);
|
|
|
+ ui->content_layout->addWidget(settings_widget_);
|
|
|
+ ui->content_layout->addWidget(help_widget_);
|
|
|
+ ui->content_layout->addWidget(about_widget_);
|
|
|
|
|
|
- status_widget = new StatusWidget(patch_updater, lotro_manager, this);
|
|
|
- settings_widget = new SettingsWidget(patch_updater, lotro_manager, this);
|
|
|
- help_widget = new HelpWidget(patch_updater, lotro_manager, this);
|
|
|
- about_widget = new AboutWidget(patch_updater, lotro_manager, this);
|
|
|
-
|
|
|
- choose_locale_dialog = new ChooseVersionDialog(patch_updater, lotro_manager, this);
|
|
|
- choose_locale_dialog->resize(size());
|
|
|
- choose_locale_dialog->hide();
|
|
|
- connect(choose_locale_dialog, &ChooseVersionDialog::cancelled, this, &MainWindow::hideChooseVersionDialog);
|
|
|
+ hideAllContentWidgets();
|
|
|
+ status_widget_->show();
|
|
|
|
|
|
- dialog_window = new DialogWindow(this);
|
|
|
- dialog_window->resize(size());
|
|
|
+ qDebug() << __FUNCTION__ << "Initialising additional frames...";
|
|
|
|
|
|
- ui->content_layout->addWidget(status_widget);
|
|
|
- ui->content_layout->addWidget(settings_widget);
|
|
|
- ui->content_layout->addWidget(help_widget);
|
|
|
- ui->content_layout->addWidget(about_widget);
|
|
|
+ choose_locale_dialog_ = new ChooseVersionDialog(this);
|
|
|
+ choose_locale_dialog_->resize(size());
|
|
|
+ choose_locale_dialog_->hide();
|
|
|
+ connect(choose_locale_dialog_, &ChooseVersionDialog::cancelled, choose_locale_dialog_, &ChooseVersionDialog::hide);
|
|
|
|
|
|
- hideAllContentWidgets();
|
|
|
- status_widget->show();
|
|
|
+ dialog_window_ = new DialogWindow(this);
|
|
|
+ dialog_window_->resize(size());
|
|
|
|
|
|
- qDebug() << "Making background";
|
|
|
+ qDebug() << __FUNCTION__ << "Making background";
|
|
|
|
|
|
qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
|
|
|
- current_bg_id = qrand() % MAX_PIXMAP_ID + 1;
|
|
|
- QPixmap background(":/backgrounds/bg" + QString::number(current_bg_id) + ".png");
|
|
|
+ current_bg_id_ = qrand() % MAX_PIXMAP_ID + 1;
|
|
|
+ QPixmap background(":/backgrounds/bg" + QString::number(current_bg_id_) + ".png");
|
|
|
setupWindowBackgroundAndMask(background);
|
|
|
|
|
|
setupMenuHoverWidget();
|
|
|
|
|
|
- qDebug() << "Initialising background updates";
|
|
|
- background_update_timer.setInterval(30 * 1000);
|
|
|
- connect(&background_update_timer, &QTimer::timeout, this, &MainWindow::randomChangeBackground);
|
|
|
- background_update_timer.start();
|
|
|
+ qDebug() << __FUNCTION__ << "Initialising background updates";
|
|
|
+ background_update_timer_.setInterval(30 * 1000);
|
|
|
+ connect(&background_update_timer_, &QTimer::timeout, this, &MainWindow::randomChangeBackground);
|
|
|
+ background_update_timer_.start();
|
|
|
|
|
|
- qDebug() << "Initialising main window connections";
|
|
|
+ qDebug() << __FUNCTION__ << "Initialising main window connections";
|
|
|
makeConnections();
|
|
|
|
|
|
- qDebug() << "Installing event filters to clickable objects";
|
|
|
+ qDebug() << __FUNCTION__ << "Installing event filters to clickable objects";
|
|
|
setEventFilterRecursive(this);
|
|
|
|
|
|
- qDebug() << "Finishing main frame initialisation";
|
|
|
+ qDebug() << __FUNCTION__ << "Finished main frame initialisation";
|
|
|
show();
|
|
|
- QMetaObject::invokeMethod(patch_updater, "checkForUpdates");
|
|
|
}
|
|
|
|
|
|
void MainWindow::mousePressEvent(QMouseEvent *event)
|
|
|
{
|
|
|
if (event->button() == Qt::LeftButton) {
|
|
|
- dragPosition = event->globalPos() - frameGeometry().topLeft();
|
|
|
+ drag_position_ = event->globalPos() - frameGeometry().topLeft();
|
|
|
event->accept();
|
|
|
}
|
|
|
}
|
|
@@ -115,7 +105,7 @@ void MainWindow::mousePressEvent(QMouseEvent *event)
|
|
|
void MainWindow::mouseMoveEvent(QMouseEvent *event)
|
|
|
{
|
|
|
if (event->buttons() & Qt::LeftButton) {
|
|
|
- move(event->globalPos() - dragPosition);
|
|
|
+ move(event->globalPos() - drag_position_);
|
|
|
event->accept();
|
|
|
}
|
|
|
}
|
|
@@ -139,17 +129,17 @@ void MainWindow::resizeEvent(QResizeEvent * event)
|
|
|
|
|
|
ui->content_area->move(0, height * 110 / default_window_height);
|
|
|
ui->content_area->resize(width * 1000 / default_window_width, height * 538 / default_window_height);
|
|
|
- setupWindowBackgroundAndMask(current_bg);
|
|
|
- choose_locale_dialog->resize(event->size());
|
|
|
+ setupWindowBackgroundAndMask(current_bg_);
|
|
|
+ choose_locale_dialog_->resize(event->size());
|
|
|
|
|
|
ui->closeButton->setMinimumSize(width * 20 / default_window_width, height * 20 / default_window_height);
|
|
|
ui->minimizeButton->setMinimumSize(width * 20 / default_window_width, height * 20 / default_window_height);
|
|
|
|
|
|
- choose_locale_dialog->move({0, 0});
|
|
|
- choose_locale_dialog->resize(event->size());
|
|
|
+ choose_locale_dialog_->move({0, 0});
|
|
|
+ choose_locale_dialog_->resize(event->size());
|
|
|
|
|
|
- dialog_window->move({0, 0});
|
|
|
- dialog_window->resize(size());
|
|
|
+ dialog_window_->move({0, 0});
|
|
|
+ dialog_window_->resize(size());
|
|
|
updateFontSizes();
|
|
|
}
|
|
|
|
|
@@ -158,18 +148,17 @@ void MainWindow::randomChangeBackground()
|
|
|
if (!qApp)
|
|
|
return;
|
|
|
|
|
|
- qDebug() << "Starting background update";
|
|
|
-
|
|
|
+ qDebug() << __FUNCTION__ << "Starting background update";
|
|
|
|
|
|
int next_pixmap_id = qrand() % MAX_PIXMAP_ID + 1;
|
|
|
- while (next_pixmap_id == current_bg_id) {
|
|
|
+ while (next_pixmap_id == current_bg_id_) {
|
|
|
next_pixmap_id = qrand() % MAX_PIXMAP_ID + 1;
|
|
|
}
|
|
|
- qDebug() << "Next background id = " << next_pixmap_id;
|
|
|
+ qDebug() << __FUNCTION__ << "Next background id = " << next_pixmap_id;
|
|
|
|
|
|
- QPixmap *cur_bg = new QPixmap(current_bg);
|
|
|
+ QPixmap *cur_bg = new QPixmap(current_bg_);
|
|
|
QPixmap *new_bg= new QPixmap(":/backgrounds/bg" + QString::number(next_pixmap_id) + ".png");
|
|
|
- current_bg_id = next_pixmap_id;
|
|
|
+ current_bg_id_ = next_pixmap_id;
|
|
|
|
|
|
QtConcurrent::run([cur_bg, new_bg, this](){
|
|
|
const int iterations_num = 50;
|
|
@@ -189,7 +178,7 @@ void MainWindow::randomChangeBackground()
|
|
|
}
|
|
|
delete cur_bg;
|
|
|
delete new_bg;
|
|
|
- qDebug() << "Background update finished";
|
|
|
+ qDebug() << __FUNCTION__ << "Background update finished";
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -198,80 +187,53 @@ MainWindow::~MainWindow()
|
|
|
delete ui;
|
|
|
}
|
|
|
|
|
|
+void MainWindow::showMessageDialog(QString title, QString message, QString ok_button_text, QString cancel_button_text)
|
|
|
+{
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
void MainWindow::on_menuentry_1_clicked()
|
|
|
{
|
|
|
- currently_active_entry = ui->menuentry_1;
|
|
|
+ current_active_entry_ = ui->menuentry_1;
|
|
|
hideAllContentWidgets();
|
|
|
- status_widget->show();
|
|
|
+ status_widget_->show();
|
|
|
}
|
|
|
|
|
|
void MainWindow::on_menuentry_2_clicked()
|
|
|
{
|
|
|
- currently_active_entry = ui->menuentry_2;
|
|
|
+ current_active_entry_ = ui->menuentry_2;
|
|
|
hideAllContentWidgets();
|
|
|
- settings_widget->show();
|
|
|
+ settings_widget_->show();
|
|
|
}
|
|
|
|
|
|
void MainWindow::on_menuentry_3_clicked()
|
|
|
{
|
|
|
- currently_active_entry = ui->menuentry_3;
|
|
|
+ current_active_entry_ = ui->menuentry_3;
|
|
|
hideAllContentWidgets();
|
|
|
- help_widget->show();
|
|
|
+ help_widget_->show();
|
|
|
}
|
|
|
|
|
|
void MainWindow::on_menuentry_4_clicked()
|
|
|
{
|
|
|
- currently_active_entry = ui->menuentry_4;
|
|
|
+ current_active_entry_ = ui->menuentry_4;
|
|
|
hideAllContentWidgets();
|
|
|
- about_widget->show();
|
|
|
+ about_widget_->show();
|
|
|
}
|
|
|
|
|
|
void MainWindow::onHoverMenuentry(MenuEntry *hovered_entry)
|
|
|
{
|
|
|
- if (currently_hover_entry != hovered_entry) {
|
|
|
- currently_hover_entry = hovered_entry;
|
|
|
+ if (current_hovered_entry_ != hovered_entry) {
|
|
|
+ current_hovered_entry_ = hovered_entry;
|
|
|
moveMenuHoverWidget(hovered_entry);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-void MainWindow::onPatchDownloaderStarted() {
|
|
|
- qDebug() << "Patch downloader started!";
|
|
|
-}
|
|
|
-
|
|
|
-void MainWindow::onPatchDownloaderFinished() {
|
|
|
- qDebug() << "Patch downloader finished!";
|
|
|
-
|
|
|
-// if (lotro_manager->Initialised()) {
|
|
|
-// QMetaObject::invokeMethod(lotro_manager, "InstallUpdates", Qt::QueuedConnection);
|
|
|
-// }
|
|
|
- return;
|
|
|
-}
|
|
|
-
|
|
|
-void MainWindow::onLotroManagerStarted(QString operation, QVector<QVariant> data) {
|
|
|
- qDebug() << "LotroManager: Started operation " << operation << " with parameters " << data;
|
|
|
- return;
|
|
|
-}
|
|
|
-
|
|
|
-void MainWindow::onLotroManagerFinished(QString operation, QVector<QVariant> data) {
|
|
|
- qDebug() << "LotroManager: Finished operation " << operation << " with parameters " << data;
|
|
|
-// if (operation == "")
|
|
|
- return;
|
|
|
-}
|
|
|
-
|
|
|
-void MainWindow::onLotroManagerErrorOccured(QString, QVector<QVariant>) {
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
void MainWindow::setupWindowBackgroundAndMask(QPixmap background)
|
|
|
{
|
|
|
- if (!qApp)
|
|
|
- return;
|
|
|
- current_bg = background;
|
|
|
- QPixmap scaled_bg = current_bg.scaled(width(), height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
|
|
- current_mask = scaled_bg.mask();
|
|
|
- setMask(current_mask);
|
|
|
+ current_bg_ = background;
|
|
|
+ QPixmap scaled_bg = current_bg_.scaled(width(), height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
|
|
+ current_mask_ = scaled_bg.mask();
|
|
|
+ setMask(current_mask_);
|
|
|
|
|
|
QPalette palette;
|
|
|
palette.setBrush(QPalette::Window, scaled_bg);
|
|
@@ -284,36 +246,36 @@ void MainWindow::makeConnections()
|
|
|
|
|
|
void MainWindow::setupMenuHoverWidget()
|
|
|
{
|
|
|
- menuHoverWidget = new QWidget(ui->menu_widget);
|
|
|
- menuHoverWidget->setStyleSheet("background-color: rgba(55, 37, 31, 230);");
|
|
|
- menuHoverWidget->resize(0, 0);
|
|
|
+ menu_hover_widget_ = new QWidget(ui->menu_widget);
|
|
|
+ menu_hover_widget_->setStyleSheet("background-color: rgba(55, 37, 31, 230);");
|
|
|
+ menu_hover_widget_->resize(0, 0);
|
|
|
|
|
|
connect(ui->menuentry_1, &MenuEntry::entryIsHovered, this, &MainWindow::onHoverMenuentry);
|
|
|
connect(ui->menuentry_2, &MenuEntry::entryIsHovered, this, &MainWindow::onHoverMenuentry);
|
|
|
connect(ui->menuentry_3, &MenuEntry::entryIsHovered, this, &MainWindow::onHoverMenuentry);
|
|
|
connect(ui->menuentry_4, &MenuEntry::entryIsHovered, this, &MainWindow::onHoverMenuentry);
|
|
|
|
|
|
- currently_active_entry = ui->menuentry_1;
|
|
|
- menu_hover_checker_timer.setInterval(500);
|
|
|
- connect(&menu_hover_checker_timer, &QTimer::timeout, this, &MainWindow::checkMenuIsHovered);
|
|
|
- menu_hover_checker_timer.start();
|
|
|
+ current_active_entry_ = ui->menuentry_1;
|
|
|
+ menu_hover_checker_timer_.setInterval(500);
|
|
|
+ connect(&menu_hover_checker_timer_, &QTimer::timeout, this, &MainWindow::checkMenuIsHovered);
|
|
|
+ menu_hover_checker_timer_.start();
|
|
|
}
|
|
|
|
|
|
void MainWindow::moveMenuHoverWidget(MenuEntry *target)
|
|
|
{
|
|
|
- if (menuHoverWidget->size() == QSize(0, 0)) {
|
|
|
- menuHoverWidget->resize(target->size() + QSize(10, 0));
|
|
|
- menuHoverWidget->move(target->pos() + QPoint(-5, 0));
|
|
|
+ if (menu_hover_widget_->size() == QSize(0, 0)) {
|
|
|
+ menu_hover_widget_->resize(target->size() + QSize(10, 0));
|
|
|
+ menu_hover_widget_->move(target->pos() + QPoint(-5, 0));
|
|
|
} else {
|
|
|
- if (menuHoverWidgetAnimation == nullptr)
|
|
|
- menuHoverWidgetAnimation = new QPropertyAnimation(menuHoverWidget, "geometry");
|
|
|
+ if (menu_hover_widget_animation_ == nullptr)
|
|
|
+ menu_hover_widget_animation_ = new QPropertyAnimation(menu_hover_widget_, "geometry");
|
|
|
else
|
|
|
- menuHoverWidgetAnimation->stop();
|
|
|
+ menu_hover_widget_animation_->stop();
|
|
|
|
|
|
- menuHoverWidgetAnimation->setDuration(200);
|
|
|
- menuHoverWidgetAnimation->setStartValue(QRect(menuHoverWidget->pos(), menuHoverWidget->size()));
|
|
|
- menuHoverWidgetAnimation->setEndValue(QRect(target->pos() + QPoint(-5, 0), target->size() + QSize(10, 0)));
|
|
|
- menuHoverWidgetAnimation->start();
|
|
|
+ menu_hover_widget_animation_->setDuration(200);
|
|
|
+ menu_hover_widget_animation_->setStartValue(QRect(menu_hover_widget_->pos(), menu_hover_widget_->size()));
|
|
|
+ menu_hover_widget_animation_->setEndValue(QRect(target->pos() + QPoint(-5, 0), target->size() + QSize(10, 0)));
|
|
|
+ menu_hover_widget_animation_->start();
|
|
|
}
|
|
|
|
|
|
ui->menuentry_1->raise();
|
|
@@ -328,32 +290,17 @@ void MainWindow::checkMenuIsHovered()
|
|
|
QWidget *hovered = qApp->widgetAt(pos);
|
|
|
if (!hovered || hovered->objectName().size() < 4 ||
|
|
|
(hovered->objectName().left(9) != "menuentry" && hovered->objectName() != "menu_widget")) {
|
|
|
- moveMenuHoverWidget(currently_active_entry);
|
|
|
- currently_hover_entry = nullptr;
|
|
|
+ moveMenuHoverWidget(current_active_entry_);
|
|
|
+ current_hovered_entry_ = nullptr;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void MainWindow::hideAllContentWidgets()
|
|
|
{
|
|
|
- status_widget->hide();
|
|
|
- settings_widget->hide();
|
|
|
- help_widget->hide();
|
|
|
- about_widget->hide();
|
|
|
-}
|
|
|
-
|
|
|
-void MainWindow::showChooseVersionDialog()
|
|
|
-{
|
|
|
-// QGraphicsBlurEffect *effect = new QGraphicsBlurEffect();
|
|
|
-// effect->setBlurRadius(10);
|
|
|
-// effect->setBlurHints(QGraphicsBlurEffect::QualityHint);
|
|
|
-// ui->content_area->setGraphicsEffect(effect);
|
|
|
- choose_locale_dialog->show();
|
|
|
-}
|
|
|
-
|
|
|
-void MainWindow::hideChooseVersionDialog()
|
|
|
-{
|
|
|
-// ui->content_area->setGraphicsEffect(nullptr);
|
|
|
- choose_locale_dialog->hide();
|
|
|
+ status_widget_->hide();
|
|
|
+ settings_widget_->hide();
|
|
|
+ help_widget_->hide();
|
|
|
+ about_widget_->hide();
|
|
|
}
|
|
|
|
|
|
void MainWindow::updateFontSizes()
|
|
@@ -366,7 +313,6 @@ void MainWindow::updateFontSizes()
|
|
|
|
|
|
void MainWindow::on_closeButton_clicked()
|
|
|
{
|
|
|
- hide();
|
|
|
qApp->quit();
|
|
|
}
|
|
|
|