Implement progress bar in taskbar for non-windows platforms, Fixes #2605

This commit is contained in:
Zion Nimchuk 2017-09-06 12:09:58 -07:00 committed by Ani
parent 11aa0be04a
commit bfe2bccc51
3 changed files with 50 additions and 2 deletions

View File

@ -12,8 +12,14 @@ if (WIN32)
set(RPCS3_QT_LIBS Qt5::Widgets Qt5::WinExtras)
include_directories(${Qt5Widgets_INCLUDE_DIRS} ${Qt5WinExtras_INCLUDE_DIRS})
else()
set(RPCS3_QT_LIBS Qt5::Widgets)
include_directories(${Qt5Widgets_INCLUDE_DIRS})
find_package(Qt5DBus)
if (Qt5DBus_FOUND)
set(RPCS3_QT_LIBS Qt5::Widgets Qt5::DBus)
add_definitions(-DHAVE_QTDBUS)
else()
set(RPCS3_QT_LIBS Qt5::Widgets)
endif()
include_directories(${Qt5Widgets_INCLUDE_DIRS})
endif()
# Let's make sure we have Qt before we continue

View File

@ -65,6 +65,9 @@ void msg_dialog_frame::Create(const std::string& msg)
m_tb_progress = m_tb_button->progress();
m_tb_progress->setRange(0, m_gauge_max);
m_tb_progress->setVisible(true);
#elif HAVE_QTDBUS
UpdateProgress(0);
progressValue = new int(0);
#endif
}
@ -268,6 +271,12 @@ msg_dialog_frame::~msg_dialog_frame()
{
m_tb_button->deleteLater();
}
#elif HAVE_QTDBUS
if (progressValue)
{
UpdateProgress(0, false);
delete progressValue;
}
#endif
if (m_dialog)
{
@ -295,6 +304,8 @@ void msg_dialog_frame::ProgressBarReset(u32 index)
m_gauge1->reset();
#ifdef _WIN32
m_tb_progress->reset();
#elif HAVE_QTDBUS
UpdateProgress(0);
#endif
}
@ -313,6 +324,9 @@ void msg_dialog_frame::ProgressBarInc(u32 index, u32 delta)
m_gauge1->setValue(m_gauge1->value() + delta);
#ifdef _WIN32
m_tb_progress->setValue(m_tb_progress->value() + delta);
#elif HAVE_QTDBUS
*progressValue += delta;
UpdateProgress(*progressValue);
#endif
}
@ -322,3 +336,21 @@ void msg_dialog_frame::ProgressBarInc(u32 index, u32 delta)
}
}
}
#ifdef HAVE_QTDBUS
void msg_dialog_frame::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_gauge_max);
message << QStringLiteral("application://rpcs3.desktop") << properties;
QDBusConnection::sessionBus().send(message);
}
#endif

View File

@ -23,6 +23,9 @@
#include <QWinTaskbarButton>
#include <QWinTHumbnailToolbar>
#include <QWinTHumbnailToolbutton>
#elif HAVE_QTDBUS
#include <QtDBus/QDBusMessage>
#include <QtDBus/QDBusConnection>
#endif
class custom_dialog;
@ -34,6 +37,9 @@ class msg_dialog_frame : public QObject, public MsgDialogBase
#ifdef _WIN32
QWinTaskbarButton* m_tb_button = nullptr;
QWinTaskbarProgress* m_tb_progress = nullptr;
#elif HAVE_QTDBUS
int* progressValue = nullptr;
#endif
custom_dialog* m_dialog =nullptr;
QLabel* m_text = nullptr;
@ -59,6 +65,10 @@ public:
virtual void ProgressBarSetMsg(u32 progressBarIndex, const std::string& msg) override;
virtual void ProgressBarReset(u32 progressBarIndex) override;
virtual void ProgressBarInc(u32 progressBarIndex, u32 delta) override;
#ifdef HAVE_QTDBUS
private:
void UpdateProgress(int progress, bool disable = false);
#endif
};
class custom_dialog : public QDialog