|
@@ -30,14 +30,9 @@ class StatusWidget;
|
|
|
MainWindow::MainWindow(QWidget *parent)
|
|
|
: QMainWindow(parent, Qt::Window | Qt::FramelessWindowHint)
|
|
|
, ui(new Ui::MainWindow)
|
|
|
- , current_active_entry_(nullptr)
|
|
|
- , current_hovered_entry_(nullptr)
|
|
|
- , status_widget_(nullptr)
|
|
|
- , help_widget_(nullptr)
|
|
|
- , about_widget_(nullptr)
|
|
|
- , menu_hover_widget_(nullptr)
|
|
|
- , menu_hover_widget_animation_(nullptr)
|
|
|
{
|
|
|
+ setAttribute(Qt::WA_DeleteOnClose, true);
|
|
|
+
|
|
|
constructFonts();
|
|
|
ui->setupUi(this);
|
|
|
|
|
@@ -87,12 +82,38 @@ MainWindow::MainWindow(QWidget *parent)
|
|
|
show();
|
|
|
}
|
|
|
|
|
|
-void MainWindow::mousePressEvent(QMouseEvent *event)
|
|
|
+MainWindow::~MainWindow()
|
|
|
{
|
|
|
- if (event->button() == Qt::LeftButton) {
|
|
|
- drag_position_ = event->globalPos() - frameGeometry().topLeft();
|
|
|
- event->accept();
|
|
|
+ background_update_timer_.stop();
|
|
|
+ delete ui;
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::onErrorStatusChanged(AppErrorStatus status)
|
|
|
+{
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::updateFontSizes()
|
|
|
+{
|
|
|
+ ui->menuentry_1->setFont(trajan_9pt);
|
|
|
+ ui->menuentry_2->setFont(trajan_9pt);
|
|
|
+ ui->menuentry_4->setFont(trajan_9pt);
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::closeEvent(QCloseEvent *event)
|
|
|
+{
|
|
|
+
|
|
|
+ if (show_warning_on_close) {
|
|
|
+ auto result = QMessageBox::question(this, "Подтвердите действие", "Внимание! В настоящий момент выполняются процессы установки/обновления.\n"
|
|
|
+ "Выход из приложения может привести к ошибкам и повреждению файлов игры.\n\n"
|
|
|
+ "Вы уверены, что хотите прервать работу Наследия?");
|
|
|
+ if (result != QMessageBox::Yes) {
|
|
|
+ event->ignore();
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
+ event->accept();
|
|
|
}
|
|
|
|
|
|
void MainWindow::mouseMoveEvent(QMouseEvent *event)
|
|
@@ -103,6 +124,14 @@ void MainWindow::mouseMoveEvent(QMouseEvent *event)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+void MainWindow::mousePressEvent(QMouseEvent *event)
|
|
|
+{
|
|
|
+ if (event->button() == Qt::LeftButton) {
|
|
|
+ drag_position_ = event->globalPos() - frameGeometry().topLeft();
|
|
|
+ event->accept();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
void MainWindow::resizeEvent(QResizeEvent * event)
|
|
|
{
|
|
|
if (event->size().width() == -1 || event->size().height() == -1)
|
|
@@ -130,6 +159,20 @@ void MainWindow::resizeEvent(QResizeEvent * event)
|
|
|
updateFontSizes();
|
|
|
}
|
|
|
|
|
|
+bool MainWindow::eventFilter(QObject *, QEvent *event)
|
|
|
+{
|
|
|
+ if (event->type() == QEvent::MouseButtonPress) {
|
|
|
+ mousePressEvent((QMouseEvent*)(event));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (event->type() == QEvent::MouseMove) {
|
|
|
+ mouseMoveEvent((QMouseEvent*)(event));
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
void MainWindow::randomChangeBackground()
|
|
|
{
|
|
|
if (!qApp)
|
|
@@ -169,11 +212,6 @@ void MainWindow::randomChangeBackground()
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-MainWindow::~MainWindow()
|
|
|
-{
|
|
|
- delete ui;
|
|
|
-}
|
|
|
-
|
|
|
void MainWindow::on_menuentry_1_clicked()
|
|
|
{
|
|
|
current_active_entry_ = ui->menuentry_1;
|
|
@@ -203,6 +241,16 @@ void MainWindow::onHoverMenuentry(MenuEntry *hovered_entry)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+void MainWindow::on_closeButton_clicked()
|
|
|
+{
|
|
|
+ close();
|
|
|
+}
|
|
|
+
|
|
|
+void MainWindow::on_minimizeButton_clicked()
|
|
|
+{
|
|
|
+ setWindowState(Qt::WindowMinimized);
|
|
|
+}
|
|
|
+
|
|
|
void MainWindow::setupWindowBackgroundAndMask(QPixmap background)
|
|
|
{
|
|
|
current_bg_ = background;
|
|
@@ -215,6 +263,8 @@ void MainWindow::setupWindowBackgroundAndMask(QPixmap background)
|
|
|
setPalette(palette);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
void MainWindow::makeConnections()
|
|
|
{
|
|
|
connect(&PatchInstaller::instance(), &PatchInstaller::started, this, [this](){show_warning_on_close = true;});
|
|
@@ -277,44 +327,6 @@ void MainWindow::hideAllContentWidgets()
|
|
|
about_widget_->hide();
|
|
|
}
|
|
|
|
|
|
-void MainWindow::updateFontSizes()
|
|
|
-{
|
|
|
- ui->menuentry_1->setFont(trajan_9pt);
|
|
|
- ui->menuentry_2->setFont(trajan_9pt);
|
|
|
- ui->menuentry_4->setFont(trajan_9pt);
|
|
|
-}
|
|
|
-
|
|
|
-void MainWindow::on_closeButton_clicked()
|
|
|
-{
|
|
|
- close();
|
|
|
-}
|
|
|
-
|
|
|
-void MainWindow::closeEvent(QCloseEvent *event)
|
|
|
-{
|
|
|
- if (show_warning_on_close) {
|
|
|
- auto result = QMessageBox::question(this, "Подтвердите действие", "Внимание! В настоящий момент выполняются процессы установки/обновления.\n"
|
|
|
- "Выход из приложения может привести к ошибкам и повреждению файлов игры.\n\n"
|
|
|
- "Вы уверены, что хотите прервать работу Наследия?");
|
|
|
- if (result == QMessageBox::Yes) {
|
|
|
- qApp->quit();
|
|
|
- }
|
|
|
- } else {
|
|
|
- qApp->quit();
|
|
|
- }
|
|
|
- event->ignore();
|
|
|
-}
|
|
|
-
|
|
|
-void MainWindow::onErrorStatusChanged(AppErrorStatus status)
|
|
|
-{
|
|
|
-
|
|
|
- status_widget_->onErrorStatusChanged(status);
|
|
|
-}
|
|
|
-
|
|
|
-void MainWindow::on_minimizeButton_clicked()
|
|
|
-{
|
|
|
- setWindowState(Qt::WindowMinimized);
|
|
|
-}
|
|
|
-
|
|
|
void MainWindow::setEventFilterRecursive(QObject *widget)
|
|
|
{
|
|
|
if (!widget) {
|
|
@@ -327,15 +339,3 @@ void MainWindow::setEventFilterRecursive(QObject *widget)
|
|
|
setEventFilterRecursive(child);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-bool MainWindow::eventFilter(QObject *, QEvent *event)
|
|
|
-{
|
|
|
- if (event->type() == QEvent::MouseButtonPress) {
|
|
|
- mousePressEvent((QMouseEvent*)(event));
|
|
|
- }
|
|
|
-
|
|
|
- if (event->type() == QEvent::MouseMove) {
|
|
|
- mouseMoveEvent((QMouseEvent*)(event));
|
|
|
- }
|
|
|
- return false;
|
|
|
-}
|