Skip to content

Commit

Permalink
Fixed progress seed not loading when negative (#282) + adapted PR #284
Browse files Browse the repository at this point in the history
  • Loading branch information
Cubitect committed Feb 11, 2024
1 parent a9c51e7 commit 73f6f97
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 7 deletions.
6 changes: 5 additions & 1 deletion cubiomes-viewer.pro
Original file line number Diff line number Diff line change
Expand Up @@ -236,4 +236,8 @@ with_network: {
HEADERS += src/updater.h
}


# enable dbus features with: qmake CONFIG+=with_dbus
with_dbus: {
QT += dbus
DEFINES += "WITH_DBUS=1"
}
5 changes: 2 additions & 3 deletions etc/com.github.cubitect.cubiomes-viewer.metainfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
<description>
<p>Changes:</p>
<ul>
<li>Added progress indication via app icon</li>
<li>Tweaked app icon</li>
<li>Tweaked sceenshots</li>
<li>Fixed search progress not loading properly when stopped on a negative seed</li>
<li>Tweaked app icon and screenshots</li>
<li>Tweaked default layout</li>
</ul>
</description>
Expand Down
2 changes: 1 addition & 1 deletion src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ bool SearchConfig::read(const QString& line)
if (sscanf(p, "#Search: %d", &searchtype) == 1) return true;
if (line.startsWith("#List64: ")) { slist64path = line.mid(11).trimmed(); return true; }
if (sscanf(p, "#Threads: %d", &threads) == 1) return true;
if (sscanf(p, "#Progress: %" PRId64, &startseed) == 1) return true;
if (sscanf(p, "#Progress: %" PRIu64, &startseed) == 1) return true;
if (sscanf(p, "#ResStop: %d", &tmp) == 1) { stoponres = tmp; return true; }
if (sscanf(p, "#SMin: %" PRIu64, &smin) == 1) return true;
if (sscanf(p, "#SMax: %" PRIu64, &smax) == 1) return true;
Expand Down
2 changes: 2 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "world.h"

#include <QApplication>
#include <QGuiApplication>
#include <QFontDatabase>
#include <QStandardPaths>
#include <QDir>
Expand Down Expand Up @@ -116,6 +117,7 @@ int main(int argc, char *argv[])
}
else
{
QGuiApplication::setDesktopFileName("com.github.cubitect.cubiomes-viewer");
QApplication::setAttribute(Qt::AA_UseStyleSheetPropagationInWidgetStyles, false);

QApplication app(argc, argv);
Expand Down
29 changes: 27 additions & 2 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@
#include <QTranslator>
#include <QLibraryInfo>
#include <QFontDatabase>
#include <QGuiApplication>

#if WITH_DBUS
#include <QDBusMessage>
#include <QDBusConnection>
#endif


MainWindow::MainWindow(QString sessionpath, QString resultspath, QWidget *parent)
Expand Down Expand Up @@ -694,19 +700,37 @@ void MainWindow::setBiomeColorRc(QString rc)

void MainWindow::setProgressIndication(double value)
{
int v = (int) floor(100 * value);
int v = (int) floor(10000 * value);
if (v == progval)
return;
progval = v;

#if WITH_DBUS
auto message = QDBusMessage::createSignal("/", "com.canonical.Unity.LauncherEntry", "Update");
QVariantMap properties;
if (value >= 0 && value <= 1)
{
properties.insert("progress-visible", true);
properties.insert("progress", value);
}
else
{
properties.insert("progress-visible", false);
properties.insert("progress", 0);
}
message << QString("application://%1.desktop").arg(QGuiApplication::desktopFileName()) << properties;
QDBusConnection::sessionBus().send(message);
#endif

#if 0
QPixmap pixmap(":/icons/logo.png");

if (value >= 0 && value <= 1)
{
QPainter painter(&pixmap);
QRect view = painter.viewport();

QString txt = QString::asprintf("%2d", progval);
QString txt = QString::asprintf("%2d", progval / 100);
QFont f = font();
f.setPixelSize(48);

Expand All @@ -728,6 +752,7 @@ void MainWindow::setProgressIndication(double value)
}

setWindowIcon(QIcon(pixmap));
#endif
}

void MainWindow::on_comboBoxMC_currentIndexChanged(int)
Expand Down

0 comments on commit 73f6f97

Please sign in to comment.