Show button "Check For Updates" in dialogs about Valentina and Tape. Move

settings to common file.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2016-07-15 13:14:48 +03:00
parent d61c1c13bf
commit faae90363e
12 changed files with 113 additions and 73 deletions

View File

@ -30,6 +30,7 @@
#include "ui_dialogabouttape.h" #include "ui_dialogabouttape.h"
#include "../version.h" #include "../version.h"
#include "../vmisc/def.h" #include "../vmisc/def.h"
#include "../fervor/fvupdater.h"
#include <QDate> #include <QDate>
#include <QDesktopServices> #include <QDesktopServices>
@ -49,8 +50,16 @@ DialogAboutTape::DialogAboutTape(QWidget *parent)
//mApp->Settings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale(QLocale::C)); //mApp->Settings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale(QLocale::C));
RetranslateUi(); 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->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. // By default on Windows font point size 8 points we need 11 like on Linux.
FontPointSize(ui->label_Legal_Stuff, 11); FontPointSize(ui->label_Legal_Stuff, 11);
@ -99,15 +108,6 @@ void DialogAboutTape::showEvent(QShowEvent *event)
isInitialized = true;//first show windows are held 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) void DialogAboutTape::FontPointSize(QWidget *w, int pointSize)
{ {

View File

@ -31,8 +31,9 @@
#include <QDialog> #include <QDialog>
namespace Ui { namespace Ui
class DialogAboutTape; {
class DialogAboutTape;
} }
class DialogAboutTape : public QDialog class DialogAboutTape : public QDialog
@ -40,16 +41,13 @@ class DialogAboutTape : public QDialog
Q_OBJECT Q_OBJECT
public: public:
explicit DialogAboutTape(QWidget *parent = 0); explicit DialogAboutTape(QWidget *parent = nullptr);
virtual ~DialogAboutTape(); virtual ~DialogAboutTape();
protected: protected:
virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE; virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE;
virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
private slots:
void WebButtonClicked();
private: private:
Q_DISABLE_COPY(DialogAboutTape) Q_DISABLE_COPY(DialogAboutTape)
Ui::DialogAboutTape *ui; Ui::DialogAboutTape *ui;

View File

@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>559</width> <width>376</width>
<height>320</height> <height>320</height>
</rect> </rect>
</property> </property>
@ -248,20 +248,31 @@
</layout> </layout>
</item> </item>
<item> <item>
<widget class="QDialogButtonBox" name="buttonBox"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="autoFillBackground"> <item>
<bool>true</bool> <widget class="QPushButton" name="pushButtonCheckUpdate">
</property> <property name="text">
<property name="orientation"> <string>Check For Updates</string>
<enum>Qt::Horizontal</enum> </property>
</property> </widget>
<property name="standardButtons"> </item>
<set>QDialogButtonBox::Ok</set> <item>
</property> <widget class="QDialogButtonBox" name="buttonBox">
<property name="centerButtons"> <property name="autoFillBackground">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> <property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Ok</set>
</property>
<property name="centerButtons">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item> </item>
</layout> </layout>
</widget> </widget>

View File

@ -28,6 +28,7 @@
#include "tmainwindow.h" #include "tmainwindow.h"
#include "mapplication.h" #include "mapplication.h"
#include "../fervor/fvupdater.h"
#include <QMessageBox> // For QT_REQUIRE_VERSION #include <QMessageBox> // For QT_REQUIRE_VERSION
#include <QTimer> #include <QTimer>
@ -51,6 +52,9 @@ int main(int argc, char *argv[])
MApplication app(argc, argv); MApplication app(argc, argv);
app.InitOptions(); app.InitOptions();
// Set feed URL before doing anything else
FvUpdater::sharedUpdater()->SetFeedURL(defaultFeedURL);
QTimer::singleShot(0, &app, SLOT(ProcessCMD())); QTimer::singleShot(0, &app, SLOT(ProcessCMD()));
return app.exec(); return app.exec();

View File

@ -401,6 +401,15 @@ DEPENDPATH += $$PWD/../../libs/vpatterndb
win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vpatterndb/$${DESTDIR}/vpatterndb.lib 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 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 #VMisc static library
unix|win32: LIBS += -L$$OUT_PWD/../../libs/vmisc/$${DESTDIR}/ -lvmisc unix|win32: LIBS += -L$$OUT_PWD/../../libs/vmisc/$${DESTDIR}/ -lvmisc

View File

@ -35,6 +35,7 @@
#include <QtDebug> #include <QtDebug>
#include "../options.h" #include "../options.h"
#include "../core/vapplication.h" #include "../core/vapplication.h"
#include "../fervor/fvupdater.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
DialogAboutApp::DialogAboutApp(QWidget *parent) : 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)); 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. // By default on Windows font point size 8 points we need 11 like on Linux.
FontPointSize(ui->label_Legal_Stuff, 11); FontPointSize(ui->label_Legal_Stuff, 11);
@ -105,16 +115,3 @@ void DialogAboutApp::FontPointSize(QWidget *w, int pointSize)
font.setPointSize(pointSize); font.setPointSize(pointSize);
w->setFont(font); 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");
}
}

View File

@ -41,8 +41,8 @@ class DialogAboutApp : public QDialog
Q_OBJECT Q_OBJECT
public: public:
explicit DialogAboutApp(QWidget *parent = 0); explicit DialogAboutApp(QWidget *parent = nullptr);
~DialogAboutApp(); virtual ~DialogAboutApp();
protected: protected:
virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
@ -53,9 +53,6 @@ private:
Q_DISABLE_COPY(DialogAboutApp) Q_DISABLE_COPY(DialogAboutApp)
void FontPointSize(QWidget *w, int pointSize); void FontPointSize(QWidget *w, int pointSize);
private slots:
void webButtonClicked();
}; };
#endif // DIALOGABOUTAPP_H #endif // DIALOGABOUTAPP_H

View File

@ -294,20 +294,31 @@ Bettina Gatzlaff </string>
</layout> </layout>
</item> </item>
<item> <item>
<widget class="QDialogButtonBox" name="buttonBox"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="autoFillBackground"> <item>
<bool>true</bool> <widget class="QPushButton" name="pushButtonCheckUpdate">
</property> <property name="text">
<property name="orientation"> <string>Check For Updates</string>
<enum>Qt::Horizontal</enum> </property>
</property> </widget>
<property name="standardButtons"> </item>
<set>QDialogButtonBox::Ok</set> <item>
</property> <widget class="QDialogButtonBox" name="buttonBox">
<property name="centerButtons"> <property name="autoFillBackground">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> <property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Ok</set>
</property>
<property name="centerButtons">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item> </item>
</layout> </layout>
</widget> </widget>

View File

@ -57,11 +57,14 @@ int main(int argc, char *argv[])
app.InitOptions(); app.InitOptions();
// Set feed URL before doing anything else if (VApplication::IsGUIMode())
FvUpdater::sharedUpdater()->SetFeedURL("http://localhost/updateapp/Appcast.xml"); {
// Set feed URL before doing anything else
FvUpdater::sharedUpdater()->SetFeedURL(defaultFeedURL);
// Check for updates automatically // Check for updates automatically
FvUpdater::sharedUpdater()->CheckForUpdatesSilent(); FvUpdater::sharedUpdater()->CheckForUpdatesSilent();
}
MainWindow w; MainWindow w;
#if !defined(Q_OS_MAC) #if !defined(Q_OS_MAC)

View File

@ -30,6 +30,8 @@
#include <QDesktopServices> #include <QDesktopServices>
#include <QDebug> #include <QDebug>
const QString defaultFeedURL = QStringLiteral("http://localhost/updateapp/Appcast.xml");
QPointer<FvUpdater> FvUpdater::m_Instance; QPointer<FvUpdater> FvUpdater::m_Instance;
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -177,7 +179,7 @@ void FvUpdater::UpdateInstallationConfirmed()
// Open a link // Open a link
if (not QDesktopServices::openUrl(proposedUpdate->GetEnclosureUrl())) if (not QDesktopServices::openUrl(proposedUpdate->GetEnclosureUrl()))
{ {
showErrorDialog(tr("Unable to open a browser."), true); showErrorDialog(tr("Cannot open your default browser."), true);
return; return;
} }

View File

@ -32,6 +32,8 @@
#include "fvupdatewindow.h" #include "fvupdatewindow.h"
#include "fvavailableupdate.h" #include "fvavailableupdate.h"
extern const QString defaultFeedURL;
class FvUpdater : public QObject class FvUpdater : public QObject
{ {
Q_OBJECT Q_OBJECT

View File

@ -436,23 +436,29 @@ void VCommonSettings::SetPreferenceDialogSize(const QSize& sz)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int VCommonSettings::GetLatestSkippedVersion() const 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) 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 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) void VCommonSettings::SetDateOfLastRemind(const QDate &date)
{ {
setValue(SettingDateOfLastRemind, date); QSettings settings(this->format(), this->scope(), this->organizationName(), commonIniFilename);
settings.setValue(SettingDateOfLastRemind, date);
settings.sync();
} }