OSDN Git Service

Implemented experimental dark mode, based on QDarkStyleSheet.
[x264-launcher/x264-launcher.git] / src / win_main.cpp
index 0f00a3c..e2722d5 100644 (file)
@@ -1,6 +1,6 @@
 ///////////////////////////////////////////////////////////////////////////////
 // Simple x264 Launcher
-// Copyright (C) 2004-2018 LoRd_MuldeR <MuldeR2@GMX.de>
+// Copyright (C) 2004-2020 LoRd_MuldeR <MuldeR2@GMX.de>
 //
 // This program is free software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
@@ -71,7 +71,7 @@
 #include <QFileDialog>
 #include <QSystemTrayIcon>
 #include <QMovie>
-
+#include <QTextDocument>
 #include <ctime>
 
 //Constants
@@ -141,6 +141,9 @@ MainWindow::MainWindow(const MUtils::CPUFetaures::cpu_info_t &cpuFeatures, MUtil
        m_options.reset(new OptionsModel(m_sysinfo.data()));
        OptionsModel::loadTemplate(m_options.data(), QString::fromLatin1(tpl_last));
 
+       //DPI scaling
+       MUtils::GUI::scale_widget(this);
+
        //Freeze minimum size
        setMinimumSize(size());
        ui->splitter->setSizes(QList<int>() << 16 << 196);
@@ -218,6 +221,7 @@ MainWindow::MainWindow(const MUtils::CPUFetaures::cpu_info_t &cpuFeatures, MUtil
        connect(ui->actionOpen,             SIGNAL(triggered()), this, SLOT(openActionTriggered()));
        connect(ui->actionCleanup_Finished, SIGNAL(triggered()), this, SLOT(cleanupActionTriggered()));
        connect(ui->actionCleanup_Enqueued, SIGNAL(triggered()), this, SLOT(cleanupActionTriggered()));
+       connect(ui->actionPostOp_DoNothing, SIGNAL(triggered()), this, SLOT(postOpActionTriggered()));
        connect(ui->actionPostOp_PowerDown, SIGNAL(triggered()), this, SLOT(postOpActionTriggered()));
        connect(ui->actionPostOp_Hibernate, SIGNAL(triggered()), this, SLOT(postOpActionTriggered()));
        connect(ui->actionAbout,            SIGNAL(triggered()), this, SLOT(showAbout()));
@@ -225,6 +229,7 @@ MainWindow::MainWindow(const MUtils::CPUFetaures::cpu_info_t &cpuFeatures, MUtil
        connect(ui->actionCheckForUpdates,  SIGNAL(triggered()), this, SLOT(checkUpdates()));
        ui->actionCleanup_Finished->setData(QVariant(bool(0)));
        ui->actionCleanup_Enqueued->setData(QVariant(bool(1)));
+       ui->actionPostOp_DoNothing->setData(QVariant(POST_OP_DONOTHING));
        ui->actionPostOp_PowerDown->setData(QVariant(POST_OP_POWERDOWN));
        ui->actionPostOp_Hibernate->setData(QVariant(POST_OP_HIBERNATE));
        ui->actionPostOp_Hibernate->setEnabled(MUtils::OS::is_hibernation_supported());
@@ -233,11 +238,12 @@ MainWindow::MainWindow(const MUtils::CPUFetaures::cpu_info_t &cpuFeatures, MUtil
        SETUP_WEBLINK(ui->actionWebMulder,          home_url);
        SETUP_WEBLINK(ui->actionWebX264,            "http://www.videolan.org/developers/x264.html");
        SETUP_WEBLINK(ui->actionWebX265,            "http://www.videolan.org/developers/x265.html");
+       SETUP_WEBLINK(ui->actionWebX264LigH,        "http://www.mediafire.com/?bxvu1vvld31k1");
+       SETUP_WEBLINK(ui->actionWebX264VideoLAN,    "http://artifacts.videolan.org/x264/");
        SETUP_WEBLINK(ui->actionWebX264Komisar,     "http://komisar.gin.by/");
-       SETUP_WEBLINK(ui->actionWebX264VideoLAN,    "http://download.videolan.org/pub/x264/binaries/");
+       SETUP_WEBLINK(ui->actionWebX265LigH,        "http://www.mediafire.com/?6lfp2jlygogwa");
        SETUP_WEBLINK(ui->actionWebX264FreeCodecs,  "http://www.free-codecs.com/x264_video_codec_download.htm");
        SETUP_WEBLINK(ui->actionWebX265Fllear,      "http://x265.ru/en/builds/");
-       SETUP_WEBLINK(ui->actionWebX265LigH,        "https://www.mediafire.com/?6lfp2jlygogwa");
        SETUP_WEBLINK(ui->actionWebX265Snowfag,     "http://builds.x265.eu/");
        SETUP_WEBLINK(ui->actionWebX265FreeCodecs,  "http://www.free-codecs.com/x265_hevc_encoder_download.htm");
        SETUP_WEBLINK(ui->actionWebAvisynth32,      "https://sourceforge.net/projects/avisynth2/files/AviSynth%202.6/");
@@ -432,26 +438,15 @@ void MainWindow::postOpActionTriggered(void)
                if (data.isValid() && (data.type() == QVariant::Int))
                {
                        const postOp_t mode = (postOp_t)data.toInt();
-                       if (sender->isChecked())
+                       if ((mode >= POST_OP_DONOTHING) && (mode <= POST_OP_HIBERNATE))
                        {
                                m_postOperation = mode;
-                               if (mode != POST_OP_POWERDOWN)
-                               {
-                                       ui->actionPostOp_PowerDown->setChecked(false);
-                               }
-                               if (mode != POST_OP_HIBERNATE)
-                               {
-                                       ui->actionPostOp_Hibernate->setChecked(false);
-                               }
-                       }
-                       else
-                       {
-                               m_postOperation = POST_OP_DONOTHING;
+                               ui->actionPostOp_PowerDown->setChecked(mode == POST_OP_POWERDOWN);
+                               ui->actionPostOp_Hibernate->setChecked(mode == POST_OP_HIBERNATE);
+                               ui->actionPostOp_DoNothing->setChecked(mode == POST_OP_DONOTHING);
                        }
                }
        }
-
-       qWarning("Post-operation: %d", m_postOperation);
 }
 
 /*
@@ -900,10 +895,11 @@ void MainWindow::init(void)
        //---------------------------------------
                
        qDebug("[Validating binaries]");
-       if(!BinariesCheckThread::check(m_sysinfo.data()))
+       QString failedPath;
+       if(!BinariesCheckThread::check(m_sysinfo.data(), &failedPath))
        {
-               QMessageBox::critical(this, tr("Invalid File!"), tr("<nobr>At least one tool is missing or is not a valid Win32/Win64 binary.<br>Please re-install the program in order to fix the problem!</nobr>").replace("-", "&minus;"));
-               qFatal("At least one tool is missing or is not a valid Win32/Win64 binary!");
+               QMessageBox::critical(this, tr("Invalid File!"), tr("<nobr>At least one tool is missing or is not a valid Win32/Win64 binary:</nobr><br><tt>%1</tt><br><br><nobr>Please re-install the program in order to fix the problem!</nobr>").replace("-", "&minus;").arg(Qt::escape(QDir::toNativeSeparators(failedPath))));
+               qFatal("At least one tool is missing or is not a valid Win32/Win64 binary. Program will exit now!");
        }
        qDebug(" ");