enable updater dialog again and add a donate button

This commit is contained in:
Martin Marmsoler 2022-04-10 21:20:30 +02:00
parent 2652b7f9d2
commit 6c50891a5a
7 changed files with 36 additions and 20 deletions

View File

@ -0,0 +1,2 @@
source: https://icon-icons.com/icon/liberapay/130890
License: CC Atribution

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -66,5 +66,6 @@
<file>misc.png</file>
<file>misc@2x.png</file>
<file>logo-type_light@2x.png</file>
<file>liberapay_icon_130890.png</file>
</qresource>
</RCC>

View File

@ -63,10 +63,10 @@ void openCloneDialog(CloneDialog::Kind kind)
dialog->open();
}
const QString donationUrlLiberapay = QStringLiteral("https://liberapay.com/Gittyup/donate");
} // anon. namespace
const QString MenuBar::donationUrlLiberapay = QStringLiteral("https://liberapay.com/Gittyup/donate");
bool MenuBar::sDebugMenuVisible = false;
static Hotkey newFileHotkey = HotkeyManager::registerHotkey(

View File

@ -48,6 +48,8 @@ public:
*/
bool isMaximized();
static const QString donationUrlLiberapay;
private:
QWidget *window() const;
/*!

View File

@ -10,6 +10,7 @@
#include "UpdateDialog.h"
#include "DownloadDialog.h"
#include "Updater.h"
#include "ui/MenuBar.h"
#include "conf/Settings.h"
#include "dialogs/IconLabel.h"
#include <QCheckBox>
@ -21,6 +22,7 @@
#include <QPushButton>
#include <QTextBrowser>
#include <QVBoxLayout>
#include <QDesktopServices>
namespace {
@ -87,10 +89,20 @@ UpdateDialog::UpdateDialog(
reject();
});
QHBoxLayout* l = new QHBoxLayout();
QPushButton* supportButton = new QPushButton(QIcon(":/liberapay_icon_130890.png"), tr("Donate"), this);
QSpacerItem* spacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
l->addWidget(download);
l->addItem(spacer);
l->addWidget(supportButton);
connect(supportButton, &QPushButton::pressed, [] () {
QDesktopServices::openUrl(QUrl(MenuBar::donationUrlLiberapay));
});
QVBoxLayout *content = new QVBoxLayout;
content->addWidget(new QLabel(label, this));
content->addWidget(browser);
content->addWidget(download);
content->addLayout(l);
content->addWidget(buttons);
QHBoxLayout *layout = new QHBoxLayout(this);

View File

@ -75,24 +75,23 @@ Updater::Updater(QObject *parent)
connect(this, &Updater::updateAvailable,
[this](const QString &version, const QString &log, const QString &link) {
// For now the update dialog is disabled.
// // Show the update dialog.
// QVersionNumber appVersion =
// QVersionNumber::fromString(QCoreApplication::applicationVersion());
// QVersionNumber newVersion = QVersionNumber::fromString(version);
// if (newVersion.majorVersion() > appVersion.majorVersion() ||
// !Settings::instance()->value("update/download").toBool()) {
// UpdateDialog *dialog = new UpdateDialog(version, log, link);
// connect(dialog, &UpdateDialog::rejected, this, &Updater::updateCanceled);
// dialog->show();
// return;
// }
// Show the update dialog.
QVersionNumber appVersion =
QVersionNumber::fromString(QCoreApplication::applicationVersion());
QVersionNumber newVersion = QVersionNumber::fromString(version);
if (newVersion.majorVersion() > appVersion.majorVersion() ||
!Settings::instance()->value("update/download").toBool()) {
UpdateDialog *dialog = new UpdateDialog(version, log, link);
connect(dialog, &UpdateDialog::rejected, this, &Updater::updateCanceled);
dialog->show();
return;
}
// // Skip the update dialog and just start downloading.
// if (Updater::DownloadRef download = this->download(link)) {
// DownloadDialog *dialog = new DownloadDialog(download);
// dialog->show();
// }
// Skip the update dialog and just start downloading.
if (Updater::DownloadRef download = this->download(link)) {
DownloadDialog *dialog = new DownloadDialog(download);
dialog->show();
}
});
connect(this, &Updater::updateError,