From faae90363ebf260074f7ea409f5cd1aef13981ad Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Fri, 15 Jul 2016 13:14:48 +0300 Subject: [PATCH] Show button "Check For Updates" in dialogs about Valentina and Tape. Move settings to common file. --HG-- branch : feature --- src/app/tape/dialogs/dialogabouttape.cpp | 20 +++++----- src/app/tape/dialogs/dialogabouttape.h | 10 ++--- src/app/tape/dialogs/dialogabouttape.ui | 41 +++++++++++++------- src/app/tape/main.cpp | 4 ++ src/app/tape/tape.pro | 9 +++++ src/app/valentina/dialogs/dialogaboutapp.cpp | 25 ++++++------ src/app/valentina/dialogs/dialogaboutapp.h | 7 +--- src/app/valentina/dialogs/dialogaboutapp.ui | 39 ++++++++++++------- src/app/valentina/main.cpp | 11 ++++-- src/libs/fervor/fvupdater.cpp | 4 +- src/libs/fervor/fvupdater.h | 2 + src/libs/vmisc/vcommonsettings.cpp | 14 +++++-- 12 files changed, 113 insertions(+), 73 deletions(-) diff --git a/src/app/tape/dialogs/dialogabouttape.cpp b/src/app/tape/dialogs/dialogabouttape.cpp index 841d0c9f1..5c282bd9b 100644 --- a/src/app/tape/dialogs/dialogabouttape.cpp +++ b/src/app/tape/dialogs/dialogabouttape.cpp @@ -30,6 +30,7 @@ #include "ui_dialogabouttape.h" #include "../version.h" #include "../vmisc/def.h" +#include "../fervor/fvupdater.h" #include #include @@ -49,8 +50,16 @@ DialogAboutTape::DialogAboutTape(QWidget *parent) //mApp->Settings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale(QLocale::C)); RetranslateUi(); - connect(ui->pushButton_Web_Site, &QPushButton::clicked, this, &DialogAboutTape::WebButtonClicked); + connect(ui->pushButton_Web_Site, &QPushButton::clicked, [this](){ + if ( QDesktopServices::openUrl(QUrl(VER_COMPANYDOMAIN_STR)) == false) + { + qWarning() << tr("Cannot open your default browser"); + } + }); connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &DialogAboutTape::close); + connect(ui->pushButtonCheckUpdate, &QPushButton::clicked, [](){ + FvUpdater::sharedUpdater()->CheckForUpdatesNotSilent(); + }); // By default on Windows font point size 8 points we need 11 like on Linux. FontPointSize(ui->label_Legal_Stuff, 11); @@ -99,15 +108,6 @@ void DialogAboutTape::showEvent(QShowEvent *event) isInitialized = true;//first show windows are held } -//--------------------------------------------------------------------------------------------------------------------- -void DialogAboutTape::WebButtonClicked() -{ - if ( QDesktopServices::openUrl(QUrl(VER_COMPANYDOMAIN_STR)) == false) - { - qWarning() << tr("Cannot open your default browser"); - } -} - //--------------------------------------------------------------------------------------------------------------------- void DialogAboutTape::FontPointSize(QWidget *w, int pointSize) { diff --git a/src/app/tape/dialogs/dialogabouttape.h b/src/app/tape/dialogs/dialogabouttape.h index 64039ed04..286f7e2af 100644 --- a/src/app/tape/dialogs/dialogabouttape.h +++ b/src/app/tape/dialogs/dialogabouttape.h @@ -31,8 +31,9 @@ #include -namespace Ui { -class DialogAboutTape; +namespace Ui +{ + class DialogAboutTape; } class DialogAboutTape : public QDialog @@ -40,16 +41,13 @@ class DialogAboutTape : public QDialog Q_OBJECT public: - explicit DialogAboutTape(QWidget *parent = 0); + explicit DialogAboutTape(QWidget *parent = nullptr); virtual ~DialogAboutTape(); protected: virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE; virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; -private slots: - void WebButtonClicked(); - private: Q_DISABLE_COPY(DialogAboutTape) Ui::DialogAboutTape *ui; diff --git a/src/app/tape/dialogs/dialogabouttape.ui b/src/app/tape/dialogs/dialogabouttape.ui index 5a00d3df0..e070f0d65 100644 --- a/src/app/tape/dialogs/dialogabouttape.ui +++ b/src/app/tape/dialogs/dialogabouttape.ui @@ -6,7 +6,7 @@ 0 0 - 559 + 376 320 @@ -248,20 +248,31 @@ - - - true - - - Qt::Horizontal - - - QDialogButtonBox::Ok - - - true - - + + + + + Check For Updates + + + + + + + true + + + Qt::Horizontal + + + QDialogButtonBox::Ok + + + false + + + + diff --git a/src/app/tape/main.cpp b/src/app/tape/main.cpp index d1ef6b158..42e1d5e4f 100644 --- a/src/app/tape/main.cpp +++ b/src/app/tape/main.cpp @@ -28,6 +28,7 @@ #include "tmainwindow.h" #include "mapplication.h" +#include "../fervor/fvupdater.h" #include // For QT_REQUIRE_VERSION #include @@ -51,6 +52,9 @@ int main(int argc, char *argv[]) MApplication app(argc, argv); app.InitOptions(); + // Set feed URL before doing anything else + FvUpdater::sharedUpdater()->SetFeedURL(defaultFeedURL); + QTimer::singleShot(0, &app, SLOT(ProcessCMD())); return app.exec(); diff --git a/src/app/tape/tape.pro b/src/app/tape/tape.pro index a04fbeb47..75325edc0 100644 --- a/src/app/tape/tape.pro +++ b/src/app/tape/tape.pro @@ -401,6 +401,15 @@ DEPENDPATH += $$PWD/../../libs/vpatterndb win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vpatterndb/$${DESTDIR}/vpatterndb.lib else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vpatterndb/$${DESTDIR}/libvpatterndb.a +# Fervor static library (depend on VMisc, IFC) +unix|win32: LIBS += -L$$OUT_PWD/../../libs/fervor/$${DESTDIR}/ -lfervor + +INCLUDEPATH += $$PWD/../../libs/fervor +DEPENDPATH += $$PWD/../../libs/fervor + +win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/fervor/$${DESTDIR}/fervor.lib +else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/fervor/$${DESTDIR}/libfervor.a + #VMisc static library unix|win32: LIBS += -L$$OUT_PWD/../../libs/vmisc/$${DESTDIR}/ -lvmisc diff --git a/src/app/valentina/dialogs/dialogaboutapp.cpp b/src/app/valentina/dialogs/dialogaboutapp.cpp index 7081726ff..3379cafb3 100644 --- a/src/app/valentina/dialogs/dialogaboutapp.cpp +++ b/src/app/valentina/dialogs/dialogaboutapp.cpp @@ -35,6 +35,7 @@ #include #include "../options.h" #include "../core/vapplication.h" +#include "../fervor/fvupdater.h" //--------------------------------------------------------------------------------------------------------------------- DialogAboutApp::DialogAboutApp(QWidget *parent) : @@ -60,7 +61,16 @@ DialogAboutApp::DialogAboutApp(QWidget *parent) : ui->pushButton_Web_Site->setText(tr("Web site : %1").arg(VER_COMPANYDOMAIN_STR)); - connect(ui->pushButton_Web_Site, &QPushButton::clicked, this, &DialogAboutApp::webButtonClicked ); + connect(ui->pushButton_Web_Site, &QPushButton::clicked, [this](){ + if ( QDesktopServices::openUrl(QUrl(VER_COMPANYDOMAIN_STR)) == false) + { + qWarning() << tr("Cannot open your default browser"); + } + }); + + connect(ui->pushButtonCheckUpdate, &QPushButton::clicked, [](){ + FvUpdater::sharedUpdater()->CheckForUpdatesNotSilent(); + }); // By default on Windows font point size 8 points we need 11 like on Linux. FontPointSize(ui->label_Legal_Stuff, 11); @@ -105,16 +115,3 @@ void DialogAboutApp::FontPointSize(QWidget *w, int pointSize) font.setPointSize(pointSize); w->setFont(font); } - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief Fake button clicked - */ -void DialogAboutApp::webButtonClicked() -{ - if ( QDesktopServices::openUrl(QUrl(VER_COMPANYDOMAIN_STR)) == false) - { - qWarning() << tr("Cannot open your default browser"); - } - -} diff --git a/src/app/valentina/dialogs/dialogaboutapp.h b/src/app/valentina/dialogs/dialogaboutapp.h index 5e8ce6b17..e635be942 100644 --- a/src/app/valentina/dialogs/dialogaboutapp.h +++ b/src/app/valentina/dialogs/dialogaboutapp.h @@ -41,8 +41,8 @@ class DialogAboutApp : public QDialog Q_OBJECT public: - explicit DialogAboutApp(QWidget *parent = 0); - ~DialogAboutApp(); + explicit DialogAboutApp(QWidget *parent = nullptr); + virtual ~DialogAboutApp(); protected: virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; @@ -53,9 +53,6 @@ private: Q_DISABLE_COPY(DialogAboutApp) void FontPointSize(QWidget *w, int pointSize); - -private slots: - void webButtonClicked(); }; #endif // DIALOGABOUTAPP_H diff --git a/src/app/valentina/dialogs/dialogaboutapp.ui b/src/app/valentina/dialogs/dialogaboutapp.ui index 6b6ae2a24..dfa407174 100644 --- a/src/app/valentina/dialogs/dialogaboutapp.ui +++ b/src/app/valentina/dialogs/dialogaboutapp.ui @@ -294,20 +294,31 @@ Bettina Gatzlaff - - - true - - - Qt::Horizontal - - - QDialogButtonBox::Ok - - - true - - + + + + + Check For Updates + + + + + + + true + + + Qt::Horizontal + + + QDialogButtonBox::Ok + + + false + + + + diff --git a/src/app/valentina/main.cpp b/src/app/valentina/main.cpp index 48c3fa982..353e33aae 100644 --- a/src/app/valentina/main.cpp +++ b/src/app/valentina/main.cpp @@ -57,11 +57,14 @@ int main(int argc, char *argv[]) app.InitOptions(); - // Set feed URL before doing anything else - FvUpdater::sharedUpdater()->SetFeedURL("http://localhost/updateapp/Appcast.xml"); + if (VApplication::IsGUIMode()) + { + // Set feed URL before doing anything else + FvUpdater::sharedUpdater()->SetFeedURL(defaultFeedURL); - // Check for updates automatically - FvUpdater::sharedUpdater()->CheckForUpdatesSilent(); + // Check for updates automatically + FvUpdater::sharedUpdater()->CheckForUpdatesSilent(); + } MainWindow w; #if !defined(Q_OS_MAC) diff --git a/src/libs/fervor/fvupdater.cpp b/src/libs/fervor/fvupdater.cpp index 9e7f3adfd..b215a5957 100644 --- a/src/libs/fervor/fvupdater.cpp +++ b/src/libs/fervor/fvupdater.cpp @@ -30,6 +30,8 @@ #include #include +const QString defaultFeedURL = QStringLiteral("http://localhost/updateapp/Appcast.xml"); + QPointer FvUpdater::m_Instance; //--------------------------------------------------------------------------------------------------------------------- @@ -177,7 +179,7 @@ void FvUpdater::UpdateInstallationConfirmed() // Open a link if (not QDesktopServices::openUrl(proposedUpdate->GetEnclosureUrl())) { - showErrorDialog(tr("Unable to open a browser."), true); + showErrorDialog(tr("Cannot open your default browser."), true); return; } diff --git a/src/libs/fervor/fvupdater.h b/src/libs/fervor/fvupdater.h index 0191ae589..f6021f25b 100644 --- a/src/libs/fervor/fvupdater.h +++ b/src/libs/fervor/fvupdater.h @@ -32,6 +32,8 @@ #include "fvupdatewindow.h" #include "fvavailableupdate.h" +extern const QString defaultFeedURL; + class FvUpdater : public QObject { Q_OBJECT diff --git a/src/libs/vmisc/vcommonsettings.cpp b/src/libs/vmisc/vcommonsettings.cpp index a21ded0e7..179754b4e 100644 --- a/src/libs/vmisc/vcommonsettings.cpp +++ b/src/libs/vmisc/vcommonsettings.cpp @@ -436,23 +436,29 @@ void VCommonSettings::SetPreferenceDialogSize(const QSize& sz) //--------------------------------------------------------------------------------------------------------------------- int VCommonSettings::GetLatestSkippedVersion() const { - return value(SettingLatestSkippedVersion, 0x0).toInt(); + QSettings settings(this->format(), this->scope(), this->organizationName(), commonIniFilename); + return settings.value(SettingLatestSkippedVersion, 0x0).toInt(); } //--------------------------------------------------------------------------------------------------------------------- void VCommonSettings::SetLatestSkippedVersion(int value) { - setValue(SettingLatestSkippedVersion, value); + QSettings settings(this->format(), this->scope(), this->organizationName(), commonIniFilename); + settings.setValue(SettingLatestSkippedVersion, value); + settings.sync(); } //--------------------------------------------------------------------------------------------------------------------- QDate VCommonSettings::GetDateOfLastRemind() const { - return value(SettingDateOfLastRemind, QDate(1900, 1, 1)).toDate(); + QSettings settings(this->format(), this->scope(), this->organizationName(), commonIniFilename); + return settings.value(SettingDateOfLastRemind, QDate(1900, 1, 1)).toDate(); } //--------------------------------------------------------------------------------------------------------------------- void VCommonSettings::SetDateOfLastRemind(const QDate &date) { - setValue(SettingDateOfLastRemind, date); + QSettings settings(this->format(), this->scope(), this->organizationName(), commonIniFilename); + settings.setValue(SettingDateOfLastRemind, date); + settings.sync(); }