-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
349 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,5 @@ fvupdateconfig.h | |
|
||
# Qt | ||
*.pro.user | ||
*.qm | ||
Sample-build-* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
QT += core gui webkit | ||
|
||
DEFINES += FV_APP_NAME=\\\"$$TARGET\\\" | ||
DEFINES += FV_APP_VERSION=\\\"$$VERSION\\\" | ||
|
||
# FIXME unit tests | ||
DEFINES += FV_DEBUG=1 | ||
DEPENDPATH += "$$PWD/tests/" | ||
INCLUDEPATH += "$$PWD/tests/" | ||
CONFIG += qtestlib | ||
|
||
|
||
|
||
DEPENDPATH += "$$PWD" | ||
INCLUDEPATH += "$$PWD" | ||
|
||
SOURCES += fvupdatewindow.cpp \ | ||
fvupdater.cpp \ | ||
fvversioncomparator.cpp \ | ||
tests/fvversioncomparatortest.cpp | ||
|
||
HEADERS += fvupdatewindow.h \ | ||
fvupdateconfig.h \ | ||
fvupdater.h \ | ||
fvversioncomparator.h \ | ||
tests/fvversioncomparatortest.h | ||
|
||
FORMS += fvupdatewindow.ui | ||
|
||
TRANSLATIONS += fervor_lt.ts | ||
CODECFORTR = UTF-8 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!DOCTYPE TS> | ||
<TS version="2.0" language="lt_LT"> | ||
<defaultcodec>UTF-8</defaultcodec> | ||
<context> | ||
<name>FvUpdateWindow</name> | ||
<message> | ||
<location filename="fvupdatewindow.ui" line="14"/> | ||
<source>Software Update</source> | ||
<translation>Programos atnaujinimas</translation> | ||
</message> | ||
<message> | ||
<location filename="fvupdatewindow.ui" line="53"/> | ||
<source>A new version of %1 is available!</source> | ||
<oldsource>A new version of %s is available!</oldsource> | ||
<translation>Išleista nauja programos „%1“ versija!</translation> | ||
</message> | ||
<message> | ||
<location filename="fvupdatewindow.ui" line="60"/> | ||
<source>%1 %2 is now available - you have %3. Would you like to download it now?</source> | ||
<oldsource>%s %s is now available - you have %s. Would you like to download it now?</oldsource> | ||
<translation>Išleista programos „%1“ versija %2 - Jūs naudojate %3. Ar norėtumėte atnaujinti? </translation> | ||
</message> | ||
<message> | ||
<location filename="fvupdatewindow.ui" line="73"/> | ||
<source>Release Notes:</source> | ||
<translation>Naujojo leidimo pastabos:</translation> | ||
</message> | ||
<message> | ||
<location filename="fvupdatewindow.ui" line="80"/> | ||
<source>about:blank</source> | ||
<translation>about:blank</translation> | ||
</message> | ||
<message> | ||
<location filename="fvupdatewindow.ui" line="93"/> | ||
<source>Skip This Version</source> | ||
<translation>Praleisti šią versiją</translation> | ||
</message> | ||
<message> | ||
<location filename="fvupdatewindow.ui" line="102"/> | ||
<source>Remind Me Later</source> | ||
<translation>Priminti vėliau</translation> | ||
</message> | ||
<message> | ||
<location filename="fvupdatewindow.ui" line="109"/> | ||
<source>Install Update</source> | ||
<translation>Įdiegti atnaujinimą</translation> | ||
</message> | ||
</context> | ||
</TS> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#include "fvupdater.h" | ||
#include "fvupdatewindow.h" | ||
|
||
#ifdef FV_DEBUG | ||
// Unit tests | ||
#include "fvversioncomparatortest.h" | ||
#endif | ||
|
||
|
||
FvUpdater* FvUpdater::m_Instance = 0; | ||
|
||
|
||
FvUpdater* FvUpdater::sharedUpdater() | ||
{ | ||
static QMutex mutex; | ||
if (! m_Instance) { | ||
mutex.lock(); | ||
|
||
if (! m_Instance) { | ||
m_Instance = new FvUpdater; | ||
} | ||
|
||
mutex.unlock(); | ||
} | ||
|
||
return m_Instance; | ||
} | ||
|
||
void FvUpdater::drop() | ||
{ | ||
static QMutex mutex; | ||
mutex.lock(); | ||
delete m_Instance; | ||
m_Instance = 0; | ||
mutex.unlock(); | ||
} | ||
|
||
FvUpdater::FvUpdater() : QObject(0) | ||
{ | ||
m_updaterWindow = 0; | ||
|
||
#ifdef FV_DEBUG | ||
// Unit tests | ||
FvVersionComparatorTest* test = new FvVersionComparatorTest(); | ||
test->runAll(); | ||
delete test; | ||
#endif | ||
|
||
} | ||
|
||
FvUpdater::~FvUpdater() | ||
{ | ||
destroyUpdaterWindow(); | ||
} | ||
|
||
void FvUpdater::destroyUpdaterWindow() | ||
{ | ||
if (m_updaterWindow) { | ||
m_updaterWindow->hide(); | ||
delete m_updaterWindow; | ||
m_updaterWindow = 0; | ||
} | ||
} | ||
|
||
|
||
bool FvUpdater::CheckForUpdates(bool notifyAboutUpToDateApplication) | ||
{ | ||
destroyUpdaterWindow(); | ||
|
||
m_updaterWindow = new FvUpdateWindow(); | ||
m_updaterWindow->show(); | ||
|
||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#ifndef FVUPDATER_H | ||
#define FVUPDATER_H | ||
|
||
#include <QObject> | ||
#include <QMutex> | ||
class FvUpdateWindow; | ||
|
||
|
||
class FvUpdater : public QObject | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
|
||
// Singleton | ||
static FvUpdater* sharedUpdater(); | ||
static void drop(); | ||
|
||
public slots: | ||
|
||
// Check for updates | ||
bool CheckForUpdates(bool notifyAboutUpToDateApplication = false); | ||
|
||
private: | ||
|
||
// Hide main constructor | ||
FvUpdater(); | ||
~FvUpdater(); | ||
|
||
// Hide copy constructor | ||
FvUpdater(const FvUpdater&); | ||
|
||
// Hide assign op | ||
// we leave just the declarations, so the compiler will warn us | ||
// if we try to use those two functions by accident | ||
FvUpdater& operator=(const FvUpdater&); | ||
|
||
// Singleton instance | ||
static FvUpdater* m_Instance; | ||
|
||
// Updater window | ||
FvUpdateWindow* m_updaterWindow; | ||
|
||
void destroyUpdaterWindow(); | ||
|
||
}; | ||
|
||
#endif // FVUPDATER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,66 @@ | ||
#include "fvupdatewindow.h" | ||
#include "ui_fvupdatewindow.h" | ||
#include "fvupdateconfig.h" | ||
#include <QTranslator> | ||
#include <QTextCodec> | ||
#include <QApplication> | ||
#include <QLibraryInfo> | ||
#include <QDebug> | ||
#include <QIcon> | ||
#include <QGraphicsScene> | ||
|
||
|
||
#ifndef FV_APP_NAME | ||
# error "FV_APP_NAME is undefined (must have been defined by Fervor.pri)" | ||
#endif | ||
#ifndef FV_APP_VERSION | ||
# error "FV_APP_VERSION is undefined (must have been defined by Fervor.pri)" | ||
#endif | ||
|
||
|
||
FvUpdateWindow::FvUpdateWindow(QWidget *parent) : | ||
QWidget(parent), | ||
ui(new Ui::FvUpdateWindow) | ||
m_ui(new Ui::FvUpdateWindow) | ||
{ | ||
ui->setupUi(this); | ||
m_ui->setupUi(this); | ||
|
||
// Initialize translation | ||
installTranslator(); | ||
|
||
// Set application name / version is not set yet | ||
if (QApplication::applicationName().isEmpty()) { | ||
QString appName = QString::fromUtf8(FV_APP_NAME); | ||
qWarning() << "QApplication::applicationName is not set, setting it to '" << appName << "'"; | ||
QApplication::setApplicationName(appName); | ||
} | ||
if (QApplication::applicationVersion().isEmpty()) { | ||
QString appVersion = QString::fromUtf8(FV_APP_VERSION); | ||
qWarning() << "QApplication::applicationVersion is not set, setting it to '" << appVersion << "'"; | ||
QApplication::setApplicationVersion(appVersion); | ||
} | ||
|
||
// Set application icon | ||
QIcon appIcon = QApplication::windowIcon(); | ||
QGraphicsScene appIconScene; | ||
appIconScene.addPixmap(appIcon.pixmap(m_ui->appIconGraphicsView->size())); | ||
|
||
QString newVersString = m_ui->newVersionIsAvailableLabel->text().arg(QApplication::applicationName()); | ||
m_ui->newVersionIsAvailableLabel->setText(newVersString); | ||
|
||
QString downloadString = m_ui->wouldYouLikeToDownloadLabel->text().arg(QApplication::applicationName(), "newvers", QApplication::applicationVersion()); | ||
m_ui->wouldYouLikeToDownloadLabel->setText(downloadString); | ||
} | ||
|
||
FvUpdateWindow::~FvUpdateWindow() | ||
{ | ||
delete ui; | ||
delete m_ui; | ||
} | ||
|
||
void FvUpdateWindow::installTranslator() | ||
{ | ||
QTranslator translator; | ||
QString locale = QLocale::system().name(); | ||
translator.load(QString("fervor_") + locale); | ||
QTextCodec::setCodecForTr(QTextCodec::codecForName("utf8")); | ||
qApp->installTranslator(&translator); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.