diff --git a/cubiomes-viewer.pro b/cubiomes-viewer.pro index 2d2d0c5..0c94555 100644 --- a/cubiomes-viewer.pro +++ b/cubiomes-viewer.pro @@ -229,4 +229,7 @@ with_network: { HEADERS += src/updater.h } - +with_dbus: { + QT += dbus + DEFINES += "WITH_DBUS=1" +} diff --git a/src/formsearchcontrol.cpp b/src/formsearchcontrol.cpp index d7ceb57..19613da 100644 --- a/src/formsearchcontrol.cpp +++ b/src/formsearchcontrol.cpp @@ -14,7 +14,12 @@ #include #include #include +#include +#if WITH_DBUS + #include + #include +#endif QVariant SeedTableModel::data(const QModelIndex& index, int role) const { @@ -716,6 +721,15 @@ void FormSearchControl::searchProgressReset() ui->progressBar->setValue(0); ui->progressBar->setFormat(fmt); + + #if WITH_DBUS + auto message = QDBusMessage::createSignal("/", "com.canonical.Unity.LauncherEntry", "Update"); + QVariantMap properties; + properties.insert("progress-visible", false); + properties.insert("progress", 0); + message << QString("application://%1.desktop").arg(QGuiApplication::desktopFileName()) << properties; + QDBusConnection::sessionBus().send(message); + #endif } void FormSearchControl::updateSearchProgress(uint64_t prog, uint64_t end, int64_t seed) @@ -746,6 +760,15 @@ void FormSearchControl::updateSearchProgress(uint64_t prog, uint64_t end, int64_ } } ui->progressBar->setFormat(fmt); + + #if WITH_DBUS + auto message = QDBusMessage::createSignal("/", "com.canonical.Unity.LauncherEntry", "Update"); + QVariantMap properties; + properties.insert("progress-visible", true); + properties.insert("progress", (double) v / 10000); + message << QString("application://%1.desktop").arg(QGuiApplication::desktopFileName()) << properties; + QDBusConnection::sessionBus().send(message); + #endif } } @@ -759,6 +782,15 @@ void FormSearchControl::searchFinish(bool done) ui->lineStart->setText(QString::asprintf("%" PRId64, sthread.smax)); ui->progressBar->setValue(10000); ui->progressBar->setFormat(tr("Done", "Progressbar")); + + #if WITH_DBUS + auto message = QDBusMessage::createSignal("/", "com.canonical.Unity.LauncherEntry", "Update"); + QVariantMap properties; + properties.insert("progress-visible", false); + properties.insert("progress", 0); + message << QString("application://%1.desktop").arg(QGuiApplication::desktopFileName()) << properties; + QDBusConnection::sessionBus().send(message); + #endif } ui->labelStatus->setText(tr("Idle", "Progressbar")); searchLockUi(false); diff --git a/src/main.cpp b/src/main.cpp index 7eeba01..bf268cd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -116,6 +116,7 @@ int main(int argc, char *argv[]) } else { + QGuiApplication::setDesktopFileName("com.github.cubitect.cubiomes-viewer"); QApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true); QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true); QApplication::setAttribute(Qt::AA_UseStyleSheetPropagationInWidgetStyles, false);