diff --git a/rpcs3/rpcs3.vcxproj b/rpcs3/rpcs3.vcxproj index c15f8e9d41..0c929c90da 100644 --- a/rpcs3/rpcs3.vcxproj +++ b/rpcs3/rpcs3.vcxproj @@ -894,6 +894,7 @@ + @@ -1341,6 +1342,32 @@ $(QTDIR)\bin\moc.exe;%(FullPath);$(QTDIR)\bin\moc.exe;%(FullPath);$(QTDIR)\bin\moc.exe;%(FullPath) "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\QTGeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -D_WINDOWS -DUNICODE -DWIN32 -DWIN64 -DQT_OPENGL_LIB -DQT_WIDGETS_LIB -DQT_QUICK_LIB -DQT_GUI_LIB -DQT_QML_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_WINEXTRAS_LIB -DLLVM_AVAILABLE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE "-I.\..\Vulkan\Vulkan-LoaderAndValidationLayers\include" "-I.\.." "-I.\..\3rdparty\minidx12\Include" "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtOpenGL" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtQuick" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtQml" "-I$(QTDIR)\include\QtNetwork" "-I$(QTDIR)\include\QtCore" "-I.\debug" "-I$(QTDIR)\mkspecs\win32-msvc2015" "-I.\QTGeneratedFiles\$(ConfigurationName)\." "-I.\QTGeneratedFiles" "-I$(QTDIR)\include\QtWinExtras" + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/rpcs3/rpcs3.vcxproj.filters b/rpcs3/rpcs3.vcxproj.filters index 6a180a2ab8..359b99fbb9 100644 --- a/rpcs3/rpcs3.vcxproj.filters +++ b/rpcs3/rpcs3.vcxproj.filters @@ -560,6 +560,9 @@ Gui\trophy + + Gui\misc dialogs + @@ -747,6 +750,9 @@ Gui\save + + Gui\misc dialogs + diff --git a/rpcs3/rpcs3qt/main_window.cpp b/rpcs3/rpcs3qt/main_window.cpp index 2b6fd3d81d..7a83f97ad6 100644 --- a/rpcs3/rpcs3qt/main_window.cpp +++ b/rpcs3/rpcs3qt/main_window.cpp @@ -5,7 +5,6 @@ #include #include #include -#include #include #include @@ -26,6 +25,7 @@ #include "emu_settings.h" #include "about_dialog.h" #include "gamepads_settings_dialog.h" +#include "progress_dialog.h" #include @@ -357,20 +357,14 @@ void main_window::InstallPkg(const QString& dropPath) const std::string fileName = sstr(QFileInfo(filePath).fileName()); const std::string path = sstr(filePath); - QProgressDialog pdlg(tr("Installing package ... please wait ..."), tr("Cancel"), 0, 1000, this); + progress_dialog pdlg(0, 1000, this); pdlg.setWindowTitle(tr("RPCS3 Package Installer")); + pdlg.setLabelText(tr("Installing package ... please wait ...")); + pdlg.setCancelButtonText(tr("Cancel")); pdlg.setWindowModality(Qt::WindowModal); pdlg.setFixedWidth(QLabel("This is the very length of the progressdialog due to hidpi reasons.").sizeHint().width()); pdlg.show(); -#ifdef _WIN32 - std::unique_ptr taskbar_button = std::make_unique(); - taskbar_button->setWindow(windowHandle()); - QWinTaskbarProgress* taskbar_progress = taskbar_button->progress(); - taskbar_progress->setRange(0, 1000); - taskbar_progress->setVisible(true); -#endif - // Synchronization variable atomic_t progress(0.); { @@ -397,19 +391,13 @@ void main_window::InstallPkg(const QString& dropPath) // Update progress window double pval = progress; pval < 0 ? pval += 1. : pval; - pdlg.setValue(static_cast(pval * pdlg.maximum())); -#ifdef _WIN32 - taskbar_progress->setValue(static_cast(pval * taskbar_progress->maximum())); -#endif + pdlg.SetValue(static_cast(pval * pdlg.maximum())); QCoreApplication::processEvents(); } if (progress > 0.) { - pdlg.setValue(pdlg.maximum()); -#ifdef _WIN32 - taskbar_progress->setValue(taskbar_progress->maximum()); -#endif + pdlg.SetValue(pdlg.maximum()); std::this_thread::sleep_for(100ms); } } @@ -420,10 +408,6 @@ void main_window::InstallPkg(const QString& dropPath) LOG_SUCCESS(GENERAL, "Successfully installed %s.", fileName); guiSettings->ShowInfoBox(gui::ib_pkg_success, tr("Success!"), tr("Successfully installed software from package!"), this); } - -#ifdef _WIN32 - taskbar_progress->hide(); -#endif } void main_window::InstallPup(const QString& dropPath) @@ -485,20 +469,14 @@ void main_window::InstallPup(const QString& dropPath) return; } - QProgressDialog pdlg(tr("Installing firmware version %1\nPlease wait...").arg(qstr(version_string)), tr("Cancel"), 0, static_cast(updatefilenames.size()), this); + progress_dialog pdlg(0, static_cast(updatefilenames.size()), this); pdlg.setWindowTitle(tr("RPCS3 Firmware Installer")); + pdlg.setLabelText(tr("Installing firmware version %1\nPlease wait...").arg(qstr(version_string))); + pdlg.setCancelButtonText(tr("Cancel")); pdlg.setWindowModality(Qt::WindowModal); pdlg.setFixedWidth(QLabel("This is the very length of the progressdialog due to hidpi reasons.").sizeHint().width()); pdlg.show(); -#ifdef _WIN32 - QWinTaskbarButton *taskbar_button = new QWinTaskbarButton(); - taskbar_button->setWindow(windowHandle()); - QWinTaskbarProgress *taskbar_progress = taskbar_button->progress(); - taskbar_progress->setRange(0, static_cast(updatefilenames.size())); - taskbar_progress->setVisible(true); -#endif - // Synchronization variable atomic_t progress(0); { @@ -543,17 +521,10 @@ void main_window::InstallPup(const QString& dropPath) if (pdlg.wasCanceled()) { progress = -1; -#ifdef _WIN32 - taskbar_progress->hide(); - taskbar_button->~QWinTaskbarButton(); -#endif break; } // Update progress window - pdlg.setValue(static_cast(progress)); -#ifdef _WIN32 - taskbar_progress->setValue(static_cast(progress)); -#endif + pdlg.SetValue(static_cast(progress)); QCoreApplication::processEvents(); } @@ -562,10 +533,7 @@ void main_window::InstallPup(const QString& dropPath) if (progress > 0) { - pdlg.setValue(pdlg.maximum()); -#ifdef _WIN32 - taskbar_progress->setValue(taskbar_progress->maximum()); -#endif + pdlg.SetValue(pdlg.maximum()); std::this_thread::sleep_for(100ms); } } @@ -574,11 +542,6 @@ void main_window::InstallPup(const QString& dropPath) { LOG_SUCCESS(GENERAL, "Successfully installed PS3 firmware version %s.", version_string); guiSettings->ShowInfoBox(gui::ib_pup_success, tr("Success!"), tr("Successfully installed PS3 firmware and LLE Modules!"), this); - -#ifdef _WIN32 - taskbar_progress->hide(); - taskbar_button->~QWinTaskbarButton(); -#endif } } diff --git a/rpcs3/rpcs3qt/progress_dialog.cpp b/rpcs3/rpcs3qt/progress_dialog.cpp new file mode 100644 index 0000000000..422c60a032 --- /dev/null +++ b/rpcs3/rpcs3qt/progress_dialog.cpp @@ -0,0 +1,56 @@ +#include "progress_dialog.h" + +progress_dialog::progress_dialog(int min, int max, QWidget* parent, Qt::WindowFlags flags) : QProgressDialog(parent, flags) +{ +#ifdef _WIN32 + m_tb_button = std::make_unique(); + m_tb_button->setWindow(parent->windowHandle()); + m_tb_progress = m_tb_button->progress(); + m_tb_progress->setRange(min, max); + m_tb_progress->setVisible(true); +#elif HAVE_QTDBUS + m_max = max; + UpdateProgress(0); +#endif + + QProgressDialog::setRange(min, max); +} + +progress_dialog::~progress_dialog() +{ +#ifdef _WIN32 + m_tb_progress->hide(); +#elif HAVE_QTDBUS + UpdateProgress(0); +#endif +} + +void progress_dialog::SetValue(int progress) +{ +#ifdef _WIN32 + m_tb_progress->setValue(progress); +#elif HAVE_QTDBUS + UpdateProgress(progress); +#endif + + QProgressDialog::setValue(progress); +} + +#ifdef HAVE_QTDBUS +void progress_dialog::UpdateProgress(int progress, bool disable) +{ + QDBusMessage message = QDBusMessage::createSignal( + QStringLiteral("/"), + QStringLiteral("com.canonical.Unity.LauncherEntry"), + QStringLiteral("Update")); + QVariantMap properties; + if (disable) + properties.insert(QStringLiteral("progress-visible"), false); + else + properties.insert(QStringLiteral("progress-visible"), true); + //Progress takes a value from 0.0 to 0.1 + properties.insert(QStringLiteral("progress"), (double)progress / (double)m_max); + message << QStringLiteral("application://rpcs3.desktop") << properties; + QDBusConnection::sessionBus().send(message); +} +#endif diff --git a/rpcs3/rpcs3qt/progress_dialog.h b/rpcs3/rpcs3qt/progress_dialog.h new file mode 100644 index 0000000000..020271a59c --- /dev/null +++ b/rpcs3/rpcs3qt/progress_dialog.h @@ -0,0 +1,32 @@ +#pragma once + +#include "stdafx.h" + +#include + +#ifdef _WIN32 +#include +#include +#include +#include +#elif HAVE_QTDBUS +#include +#include +#endif + +class progress_dialog : public QProgressDialog +{ +public: + progress_dialog(int min, int max, QWidget* parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags()); + ~progress_dialog(); + void SetValue(int progress); + +private: +#ifdef _WIN32 + std::unique_ptr m_tb_button = nullptr; + QWinTaskbarProgress* m_tb_progress = nullptr; +#elif HAVE_QTDBUS + int m_max = 100; + void UpdateProgress(int progress, bool disable = false); +#endif +};