mirror of https://github.com/RPCS3/rpcs3.git
Qt: implement progress_dialog
This commit is contained in:
parent
2f7d621fc8
commit
917ee472d4
|
@ -894,6 +894,7 @@
|
||||||
<ClCompile Include="rpcs3qt\gamepads_settings_dialog.cpp" />
|
<ClCompile Include="rpcs3qt\gamepads_settings_dialog.cpp" />
|
||||||
<ClCompile Include="rpcs3qt\game_list_grid.cpp" />
|
<ClCompile Include="rpcs3qt\game_list_grid.cpp" />
|
||||||
<ClCompile Include="rpcs3qt\game_list_grid_delegate.cpp" />
|
<ClCompile Include="rpcs3qt\game_list_grid_delegate.cpp" />
|
||||||
|
<ClCompile Include="rpcs3qt\progress_dialog.cpp" />
|
||||||
<ClCompile Include="rpcs3qt\syntax_highlighter.cpp" />
|
<ClCompile Include="rpcs3qt\syntax_highlighter.cpp" />
|
||||||
<ClCompile Include="rpcs3qt\save_data_info_dialog.cpp" />
|
<ClCompile Include="rpcs3qt\save_data_info_dialog.cpp" />
|
||||||
<ClCompile Include="rpcs3qt\save_manager_dialog.cpp" />
|
<ClCompile Include="rpcs3qt\save_manager_dialog.cpp" />
|
||||||
|
@ -1341,6 +1342,32 @@
|
||||||
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug - LLVM|x64'">$(QTDIR)\bin\moc.exe;%(FullPath);$(QTDIR)\bin\moc.exe;%(FullPath);$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs>
|
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug - LLVM|x64'">$(QTDIR)\bin\moc.exe;%(FullPath);$(QTDIR)\bin\moc.exe;%(FullPath);$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs>
|
||||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug - LLVM|x64'">"$(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"</Command>
|
<Command Condition="'$(Configuration)|$(Platform)'=='Debug - LLVM|x64'">"$(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"</Command>
|
||||||
</CustomBuild>
|
</CustomBuild>
|
||||||
|
<CustomBuild Include="rpcs3qt\progress_dialog.h">
|
||||||
|
<Message Condition="'$(Configuration)|$(Platform)'=='Release - LLVM|x64'">
|
||||||
|
</Message>
|
||||||
|
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release - LLVM|x64'">
|
||||||
|
</Outputs>
|
||||||
|
<Command Condition="'$(Configuration)|$(Platform)'=='Release - LLVM|x64'">
|
||||||
|
</Command>
|
||||||
|
<Message Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
</Message>
|
||||||
|
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
</Outputs>
|
||||||
|
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
</Command>
|
||||||
|
<Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
</Message>
|
||||||
|
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
</Outputs>
|
||||||
|
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
</Command>
|
||||||
|
<Message Condition="'$(Configuration)|$(Platform)'=='Debug - LLVM|x64'">
|
||||||
|
</Message>
|
||||||
|
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug - LLVM|x64'">
|
||||||
|
</Outputs>
|
||||||
|
<Command Condition="'$(Configuration)|$(Platform)'=='Debug - LLVM|x64'">
|
||||||
|
</Command>
|
||||||
|
</CustomBuild>
|
||||||
<ClInclude Include="rpcs3qt\save_data_dialog.h" />
|
<ClInclude Include="rpcs3qt\save_data_dialog.h" />
|
||||||
<ClInclude Include="rpcs3qt\register_editor_dialog.h" />
|
<ClInclude Include="rpcs3qt\register_editor_dialog.h" />
|
||||||
<CustomBuild Include="rpcs3qt\save_data_info_dialog.h">
|
<CustomBuild Include="rpcs3qt\save_data_info_dialog.h">
|
||||||
|
|
|
@ -560,6 +560,9 @@
|
||||||
<ClCompile Include="rpcs3qt\trophy_manager_dialog.cpp">
|
<ClCompile Include="rpcs3qt\trophy_manager_dialog.cpp">
|
||||||
<Filter>Gui\trophy</Filter>
|
<Filter>Gui\trophy</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="rpcs3qt\progress_dialog.cpp">
|
||||||
|
<Filter>Gui\misc dialogs</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="\rpcs3qt\*.h">
|
<ClInclude Include="\rpcs3qt\*.h">
|
||||||
|
@ -747,6 +750,9 @@
|
||||||
<CustomBuild Include="rpcs3qt\save_manager_dialog.h">
|
<CustomBuild Include="rpcs3qt\save_manager_dialog.h">
|
||||||
<Filter>Gui\save</Filter>
|
<Filter>Gui\save</Filter>
|
||||||
</CustomBuild>
|
</CustomBuild>
|
||||||
|
<CustomBuild Include="rpcs3qt\progress_dialog.h">
|
||||||
|
<Filter>Gui\misc dialogs</Filter>
|
||||||
|
</CustomBuild>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Image Include="rpcs3.ico" />
|
<Image Include="rpcs3.ico" />
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QDockWidget>
|
#include <QDockWidget>
|
||||||
#include <QProgressDialog>
|
|
||||||
#include <QDesktopWidget>
|
#include <QDesktopWidget>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
|
|
||||||
|
@ -26,6 +25,7 @@
|
||||||
#include "emu_settings.h"
|
#include "emu_settings.h"
|
||||||
#include "about_dialog.h"
|
#include "about_dialog.h"
|
||||||
#include "gamepads_settings_dialog.h"
|
#include "gamepads_settings_dialog.h"
|
||||||
|
#include "progress_dialog.h"
|
||||||
|
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
|
@ -357,20 +357,14 @@ void main_window::InstallPkg(const QString& dropPath)
|
||||||
const std::string fileName = sstr(QFileInfo(filePath).fileName());
|
const std::string fileName = sstr(QFileInfo(filePath).fileName());
|
||||||
const std::string path = sstr(filePath);
|
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.setWindowTitle(tr("RPCS3 Package Installer"));
|
||||||
|
pdlg.setLabelText(tr("Installing package ... please wait ..."));
|
||||||
|
pdlg.setCancelButtonText(tr("Cancel"));
|
||||||
pdlg.setWindowModality(Qt::WindowModal);
|
pdlg.setWindowModality(Qt::WindowModal);
|
||||||
pdlg.setFixedWidth(QLabel("This is the very length of the progressdialog due to hidpi reasons.").sizeHint().width());
|
pdlg.setFixedWidth(QLabel("This is the very length of the progressdialog due to hidpi reasons.").sizeHint().width());
|
||||||
pdlg.show();
|
pdlg.show();
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
std::unique_ptr<QWinTaskbarButton> taskbar_button = std::make_unique<QWinTaskbarButton>();
|
|
||||||
taskbar_button->setWindow(windowHandle());
|
|
||||||
QWinTaskbarProgress* taskbar_progress = taskbar_button->progress();
|
|
||||||
taskbar_progress->setRange(0, 1000);
|
|
||||||
taskbar_progress->setVisible(true);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Synchronization variable
|
// Synchronization variable
|
||||||
atomic_t<double> progress(0.);
|
atomic_t<double> progress(0.);
|
||||||
{
|
{
|
||||||
|
@ -397,19 +391,13 @@ void main_window::InstallPkg(const QString& dropPath)
|
||||||
// Update progress window
|
// Update progress window
|
||||||
double pval = progress;
|
double pval = progress;
|
||||||
pval < 0 ? pval += 1. : pval;
|
pval < 0 ? pval += 1. : pval;
|
||||||
pdlg.setValue(static_cast<int>(pval * pdlg.maximum()));
|
pdlg.SetValue(static_cast<int>(pval * pdlg.maximum()));
|
||||||
#ifdef _WIN32
|
|
||||||
taskbar_progress->setValue(static_cast<int>(pval * taskbar_progress->maximum()));
|
|
||||||
#endif
|
|
||||||
QCoreApplication::processEvents();
|
QCoreApplication::processEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (progress > 0.)
|
if (progress > 0.)
|
||||||
{
|
{
|
||||||
pdlg.setValue(pdlg.maximum());
|
pdlg.SetValue(pdlg.maximum());
|
||||||
#ifdef _WIN32
|
|
||||||
taskbar_progress->setValue(taskbar_progress->maximum());
|
|
||||||
#endif
|
|
||||||
std::this_thread::sleep_for(100ms);
|
std::this_thread::sleep_for(100ms);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -420,10 +408,6 @@ void main_window::InstallPkg(const QString& dropPath)
|
||||||
LOG_SUCCESS(GENERAL, "Successfully installed %s.", fileName);
|
LOG_SUCCESS(GENERAL, "Successfully installed %s.", fileName);
|
||||||
guiSettings->ShowInfoBox(gui::ib_pkg_success, tr("Success!"), tr("Successfully installed software from package!"), this);
|
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)
|
void main_window::InstallPup(const QString& dropPath)
|
||||||
|
@ -485,20 +469,14 @@ void main_window::InstallPup(const QString& dropPath)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QProgressDialog pdlg(tr("Installing firmware version %1\nPlease wait...").arg(qstr(version_string)), tr("Cancel"), 0, static_cast<int>(updatefilenames.size()), this);
|
progress_dialog pdlg(0, static_cast<int>(updatefilenames.size()), this);
|
||||||
pdlg.setWindowTitle(tr("RPCS3 Firmware Installer"));
|
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.setWindowModality(Qt::WindowModal);
|
||||||
pdlg.setFixedWidth(QLabel("This is the very length of the progressdialog due to hidpi reasons.").sizeHint().width());
|
pdlg.setFixedWidth(QLabel("This is the very length of the progressdialog due to hidpi reasons.").sizeHint().width());
|
||||||
pdlg.show();
|
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<int>(updatefilenames.size()));
|
|
||||||
taskbar_progress->setVisible(true);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Synchronization variable
|
// Synchronization variable
|
||||||
atomic_t<int> progress(0);
|
atomic_t<int> progress(0);
|
||||||
{
|
{
|
||||||
|
@ -543,17 +521,10 @@ void main_window::InstallPup(const QString& dropPath)
|
||||||
if (pdlg.wasCanceled())
|
if (pdlg.wasCanceled())
|
||||||
{
|
{
|
||||||
progress = -1;
|
progress = -1;
|
||||||
#ifdef _WIN32
|
|
||||||
taskbar_progress->hide();
|
|
||||||
taskbar_button->~QWinTaskbarButton();
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Update progress window
|
// Update progress window
|
||||||
pdlg.setValue(static_cast<int>(progress));
|
pdlg.SetValue(static_cast<int>(progress));
|
||||||
#ifdef _WIN32
|
|
||||||
taskbar_progress->setValue(static_cast<int>(progress));
|
|
||||||
#endif
|
|
||||||
QCoreApplication::processEvents();
|
QCoreApplication::processEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -562,10 +533,7 @@ void main_window::InstallPup(const QString& dropPath)
|
||||||
|
|
||||||
if (progress > 0)
|
if (progress > 0)
|
||||||
{
|
{
|
||||||
pdlg.setValue(pdlg.maximum());
|
pdlg.SetValue(pdlg.maximum());
|
||||||
#ifdef _WIN32
|
|
||||||
taskbar_progress->setValue(taskbar_progress->maximum());
|
|
||||||
#endif
|
|
||||||
std::this_thread::sleep_for(100ms);
|
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);
|
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);
|
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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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<QWinTaskbarButton>();
|
||||||
|
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
|
|
@ -0,0 +1,32 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "stdafx.h"
|
||||||
|
|
||||||
|
#include <QProgressDialog>
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <QWinTaskbarProgress>
|
||||||
|
#include <QWinTaskbarButton>
|
||||||
|
#include <QWinTHumbnailToolbar>
|
||||||
|
#include <QWinTHumbnailToolbutton>
|
||||||
|
#elif HAVE_QTDBUS
|
||||||
|
#include <QtDBus/QDBusMessage>
|
||||||
|
#include <QtDBus/QDBusConnection>
|
||||||
|
#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<QWinTaskbarButton> m_tb_button = nullptr;
|
||||||
|
QWinTaskbarProgress* m_tb_progress = nullptr;
|
||||||
|
#elif HAVE_QTDBUS
|
||||||
|
int m_max = 100;
|
||||||
|
void UpdateProgress(int progress, bool disable = false);
|
||||||
|
#endif
|
||||||
|
};
|
Loading…
Reference in New Issue