Skip to content

Commit

Permalink
Close #18 new version fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mistic100 committed Jan 29, 2017
1 parent 95e593a commit 2683e15
Show file tree
Hide file tree
Showing 11 changed files with 131 additions and 55 deletions.
4 changes: 2 additions & 2 deletions src/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
#define APP_INSTALLER_FILENAME "umwp-installer.exe"
#define APP_LOG_FILENAME "debug.log"

#define APP_HOMEPAGE "http://www.strangeplanet.fr/work/umwp-autochanger"
#define APP_DOCUMENTATION_URL "http://www.strangeplanet.fr/work/umwp-autochanger/#help"
#define APP_HOMEPAGE "https://www.strangeplanet.fr/work/umwp-autochanger"
#define APP_DOCUMENTATION_URL "https://www.strangeplanet.fr/work/umwp-autochanger/#help"
#define APP_VERSION_URL "http://www.strangeplanet.fr/work/umwp-autochanger/last-version.txt"
#define APP_ISSUES_URL "https://github.com/mistic100/UMWP-Autochanger/issues"

Expand Down
39 changes: 20 additions & 19 deletions src/gui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -614,26 +614,22 @@ void MainWindow::onHotkey()
*/
void MainWindow::onNewVersion()
{
QString _version = m_enviro->newVersion().code;
QString version = m_enviro->newVersion().code;

// message in status bar
QPushButton* statusLabel = new QPushButton(tr("A new version is available : %1").arg(_version));
statusLabel->setFlat(true);
statusLabel->setStyleSheet("QPushButton { color : red; } QPushButton:flat:pressed { border: none; }");
statusLabel->setCursor(Qt::PointingHandCursor);
m_statusBar->addPermanentWidget(statusLabel);

connect(statusLabel, SIGNAL(clicked()), this, SLOT(openNewVersionDialog()));

if (!isVisible())
{
// tray tootlip
m_trayIcon->showMessage(APP_NAME, tr("A new version is available : %1").arg(_version));
connect(m_trayIcon, SIGNAL(messageClicked()), this, SLOT(toggleWindow()));
}
else
if (QString(version).compare(m_settings->param(UM::CONF::ignore_update).toString()) > 0)
{
openNewVersionDialog();
m_statusBar->newVersion(version);

if (!isVisible())
{
// tray tootlip
m_trayIcon->showMessage(APP_NAME, tr("A new version is available : %1").arg(version));
connect(m_trayIcon, SIGNAL(messageClicked()), this, SLOT(toggleWindow()));
}
else
{
openNewVersionDialog();
}
}
}

Expand All @@ -643,7 +639,12 @@ void MainWindow::onNewVersion()
void MainWindow::openNewVersionDialog()
{
NewVersionDialog dialog(this, m_ctrl);
dialog.exec();
int res = dialog.exec();

if (res == QDialog::Rejected)
{
m_settings->setParam(UM::CONF::ignore_update, m_enviro->newVersion().code);
}
}

/**
Expand Down
6 changes: 6 additions & 0 deletions src/gui/newversiondialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ NewVersionDialog::NewVersionDialog(QWidget* _parent, Controller* _ctrl) :

ui->progressBar->setVisible(false);
ui->label->setText(tr("A new version is available : %1").arg(m_version.code));

ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Close"));
ui->buttonBox->button(QDialogButtonBox::Cancel)->setText(tr("Close and don't show this message again"));
}

/**
Expand Down Expand Up @@ -54,6 +57,8 @@ void NewVersionDialog::on_updateButton_clicked()
{
ui->label->setText(tr("Downloading UMWP_Autochanger_%1_Setup.exe ...").arg(m_version.code));

QLOG_DEBUG() << "Download" << m_version.link;

QNetworkAccessManager* manager = new QNetworkAccessManager();
m_reply = manager->get(QNetworkRequest(QUrl(m_version.link)));

Expand Down Expand Up @@ -124,6 +129,7 @@ void NewVersionDialog::onDownloadFinished()
if (hash.compare(m_version.hash, Qt::CaseInsensitive) != 0)
{
QLOG_ERROR() << "File corrupted";
QLOG_DEBUG() << "Remote hash" << m_version.hash << "Local hash" << hash;

m_file.remove();
errorMessage();
Expand Down
5 changes: 1 addition & 4 deletions src/gui/newversiondialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,8 @@
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
Expand Down
17 changes: 17 additions & 0 deletions src/gui/statusbar.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include <QMovie>
#include <QPushButton>

#include "mainwindow.h"
#include "statusbar.h"

/**
Expand Down Expand Up @@ -30,6 +32,21 @@ StatusBar::StatusBar(QWidget* _parent, Controller* _ctrl) :
hideLoader();
}

/**
* @brief Displays the "New version" message
* @param string _version
*/
void StatusBar::newVersion(const QString &_version)
{
QPushButton* statusLabel = new QPushButton(tr("A new version is available : %1").arg(_version));
statusLabel->setFlat(true);
statusLabel->setStyleSheet("QPushButton { color : red; } QPushButton:flat:pressed { border: none; }");
statusLabel->setCursor(Qt::PointingHandCursor);
addWidget(statusLabel);

connect(statusLabel, SIGNAL(clicked()), (MainWindow*) parent(), SLOT(openNewVersionDialog()));
}

/**
* @brief Show the loader
*/
Expand Down
2 changes: 2 additions & 0 deletions src/gui/statusbar.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class StatusBar : public QStatusBar
public:
StatusBar(QWidget* _parent, Controller* _ctrl);

void newVersion(const QString &_version);

public slots:
void showLoader();
void hideLoader();
Expand Down
37 changes: 27 additions & 10 deletions src/lang/en_GB/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@
<context>
<name>MainWindow</name>
<message>
<location filename="../../gui/mainwindow.cpp" line="664"/>
<location filename="../../gui/mainwindow.cpp" line="665"/>
<source>Quit</source>
<translation type="unfinished"></translation>
</message>
Expand Down Expand Up @@ -504,13 +504,12 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../gui/mainwindow.cpp" line="620"/>
<location filename="../../gui/mainwindow.cpp" line="631"/>
<location filename="../../gui/mainwindow.cpp" line="626"/>
<source>A new version is available : %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../gui/mainwindow.cpp" line="668"/>
<location filename="../../gui/mainwindow.cpp" line="669"/>
<source>Close and don&apos;t show this message again</source>
<translation type="unfinished"></translation>
</message>
Expand All @@ -520,7 +519,7 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../gui/mainwindow.cpp" line="665"/>
<location filename="../../gui/mainwindow.cpp" line="666"/>
<source>If you quit the application now,&lt;br&gt;the wallpaper will not change anymore.</source>
<translation type="unfinished"></translation>
</message>
Expand Down Expand Up @@ -647,17 +646,27 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../gui/newversiondialog.cpp" line="55"/>
<location filename="../../gui/newversiondialog.cpp" line="27"/>
<source>Close</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../gui/newversiondialog.cpp" line="28"/>
<source>Close and don&apos;t show this message again</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../gui/newversiondialog.cpp" line="58"/>
<source>Downloading UMWP_Autochanger_%1_Setup.exe ...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../gui/newversiondialog.cpp" line="71"/>
<location filename="../../gui/newversiondialog.cpp" line="76"/>
<source>Unable to download installer file.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../gui/newversiondialog.cpp" line="71"/>
<location filename="../../gui/newversiondialog.cpp" line="76"/>
<source>Error</source>
<translation type="unfinished"></translation>
</message>
Expand All @@ -670,12 +679,12 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../gui/previewdialog.cpp" line="143"/>
<location filename="../../gui/previewdialog.cpp" line="151"/>
<source>Delete</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../gui/previewdialog.cpp" line="143"/>
<location filename="../../gui/previewdialog.cpp" line="151"/>
<source>Are you sure?</source>
<translation type="unfinished"></translation>
</message>
Expand Down Expand Up @@ -923,6 +932,14 @@
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>StatusBar</name>
<message>
<location filename="../../gui/statusbar.cpp" line="41"/>
<source>A new version is available : %1</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>TrayIcon</name>
<message>
Expand Down
37 changes: 27 additions & 10 deletions src/lang/fr_FR/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@
<context>
<name>MainWindow</name>
<message>
<location filename="../../gui/mainwindow.cpp" line="664"/>
<location filename="../../gui/mainwindow.cpp" line="665"/>
<source>Quit</source>
<translation>Quitter</translation>
</message>
Expand Down Expand Up @@ -519,13 +519,12 @@
<translation>Sets actuels : %1</translation>
</message>
<message>
<location filename="../../gui/mainwindow.cpp" line="620"/>
<location filename="../../gui/mainwindow.cpp" line="631"/>
<location filename="../../gui/mainwindow.cpp" line="626"/>
<source>A new version is available : %1</source>
<translation>Une nouvelle version est disponible : %1</translation>
</message>
<message>
<location filename="../../gui/mainwindow.cpp" line="668"/>
<location filename="../../gui/mainwindow.cpp" line="669"/>
<source>Close and don&apos;t show this message again</source>
<translation>Fermer et ne plus afficher ce message</translation>
</message>
Expand All @@ -535,7 +534,7 @@
<translation>%1 est toujours en cours d&apos;éxécution</translation>
</message>
<message>
<location filename="../../gui/mainwindow.cpp" line="665"/>
<location filename="../../gui/mainwindow.cpp" line="666"/>
<source>If you quit the application now,&lt;br&gt;the wallpaper will not change anymore.</source>
<translation>Si vous quittez l&apos;application maintenant,&lt;br&gt;le fond d&apos;écran ne changera plus.</translation>
</message>
Expand Down Expand Up @@ -666,17 +665,27 @@
<translation>Une nouvelle version est disponible : %1</translation>
</message>
<message>
<location filename="../../gui/newversiondialog.cpp" line="55"/>
<location filename="../../gui/newversiondialog.cpp" line="27"/>
<source>Close</source>
<translation>Fermer</translation>
</message>
<message>
<location filename="../../gui/newversiondialog.cpp" line="28"/>
<source>Close and don&apos;t show this message again</source>
<translation>Fermer et ne plus afficher ce message</translation>
</message>
<message>
<location filename="../../gui/newversiondialog.cpp" line="58"/>
<source>Downloading UMWP_Autochanger_%1_Setup.exe ...</source>
<translation>Téléchargement de UMWP_Autochanger_%1_Setup.exe ...</translation>
</message>
<message>
<location filename="../../gui/newversiondialog.cpp" line="71"/>
<location filename="../../gui/newversiondialog.cpp" line="76"/>
<source>Unable to download installer file.</source>
<translation>Impossible de télécharger le fichier.</translation>
</message>
<message>
<location filename="../../gui/newversiondialog.cpp" line="71"/>
<location filename="../../gui/newversiondialog.cpp" line="76"/>
<source>Error</source>
<translation>Erreur</translation>
</message>
Expand All @@ -693,12 +702,12 @@
<translation type="vanished">Dossiers actifs</translation>
</message>
<message>
<location filename="../../gui/previewdialog.cpp" line="143"/>
<location filename="../../gui/previewdialog.cpp" line="151"/>
<source>Delete</source>
<translation>Supprimer</translation>
</message>
<message>
<location filename="../../gui/previewdialog.cpp" line="143"/>
<location filename="../../gui/previewdialog.cpp" line="151"/>
<source>Are you sure?</source>
<translation>Êtes-vous sûr ?</translation>
</message>
Expand Down Expand Up @@ -958,6 +967,14 @@
<translation>Le nom ne peut être vide</translation>
</message>
</context>
<context>
<name>StatusBar</name>
<message>
<location filename="../../gui/statusbar.cpp" line="41"/>
<source>A new version is available : %1</source>
<translation>Une nouvelle version est disponible : %1</translation>
</message>
</context>
<context>
<name>TrayIcon</name>
<message>
Expand Down
Loading

0 comments on commit 2683e15

Please sign in to comment.