Skip to content

Commit 2683e15

Browse files
committed
Close #18 new version fixes
1 parent 95e593a commit 2683e15

File tree

11 files changed

+131
-55
lines changed

11 files changed

+131
-55
lines changed

src/constants.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
#define APP_INSTALLER_FILENAME "umwp-installer.exe"
1919
#define APP_LOG_FILENAME "debug.log"
2020

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

src/gui/mainwindow.cpp

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -614,26 +614,22 @@ void MainWindow::onHotkey()
614614
*/
615615
void MainWindow::onNewVersion()
616616
{
617-
QString _version = m_enviro->newVersion().code;
617+
QString version = m_enviro->newVersion().code;
618618

619-
// message in status bar
620-
QPushButton* statusLabel = new QPushButton(tr("A new version is available : %1").arg(_version));
621-
statusLabel->setFlat(true);
622-
statusLabel->setStyleSheet("QPushButton { color : red; } QPushButton:flat:pressed { border: none; }");
623-
statusLabel->setCursor(Qt::PointingHandCursor);
624-
m_statusBar->addPermanentWidget(statusLabel);
625-
626-
connect(statusLabel, SIGNAL(clicked()), this, SLOT(openNewVersionDialog()));
627-
628-
if (!isVisible())
629-
{
630-
// tray tootlip
631-
m_trayIcon->showMessage(APP_NAME, tr("A new version is available : %1").arg(_version));
632-
connect(m_trayIcon, SIGNAL(messageClicked()), this, SLOT(toggleWindow()));
633-
}
634-
else
619+
if (QString(version).compare(m_settings->param(UM::CONF::ignore_update).toString()) > 0)
635620
{
636-
openNewVersionDialog();
621+
m_statusBar->newVersion(version);
622+
623+
if (!isVisible())
624+
{
625+
// tray tootlip
626+
m_trayIcon->showMessage(APP_NAME, tr("A new version is available : %1").arg(version));
627+
connect(m_trayIcon, SIGNAL(messageClicked()), this, SLOT(toggleWindow()));
628+
}
629+
else
630+
{
631+
openNewVersionDialog();
632+
}
637633
}
638634
}
639635

@@ -643,7 +639,12 @@ void MainWindow::onNewVersion()
643639
void MainWindow::openNewVersionDialog()
644640
{
645641
NewVersionDialog dialog(this, m_ctrl);
646-
dialog.exec();
642+
int res = dialog.exec();
643+
644+
if (res == QDialog::Rejected)
645+
{
646+
m_settings->setParam(UM::CONF::ignore_update, m_enviro->newVersion().code);
647+
}
647648
}
648649

649650
/**

src/gui/newversiondialog.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ NewVersionDialog::NewVersionDialog(QWidget* _parent, Controller* _ctrl) :
2323

2424
ui->progressBar->setVisible(false);
2525
ui->label->setText(tr("A new version is available : %1").arg(m_version.code));
26+
27+
ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Close"));
28+
ui->buttonBox->button(QDialogButtonBox::Cancel)->setText(tr("Close and don't show this message again"));
2629
}
2730

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

60+
QLOG_DEBUG() << "Download" << m_version.link;
61+
5762
QNetworkAccessManager* manager = new QNetworkAccessManager();
5863
m_reply = manager->get(QNetworkRequest(QUrl(m_version.link)));
5964

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

128134
m_file.remove();
129135
errorMessage();

src/gui/newversiondialog.ui

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,8 @@
4343
</item>
4444
<item>
4545
<widget class="QDialogButtonBox" name="buttonBox">
46-
<property name="orientation">
47-
<enum>Qt::Horizontal</enum>
48-
</property>
4946
<property name="standardButtons">
50-
<set>QDialogButtonBox::Close</set>
47+
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
5148
</property>
5249
</widget>
5350
</item>

src/gui/statusbar.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#include <QMovie>
2+
#include <QPushButton>
23

4+
#include "mainwindow.h"
35
#include "statusbar.h"
46

57
/**
@@ -30,6 +32,21 @@ StatusBar::StatusBar(QWidget* _parent, Controller* _ctrl) :
3032
hideLoader();
3133
}
3234

35+
/**
36+
* @brief Displays the "New version" message
37+
* @param string _version
38+
*/
39+
void StatusBar::newVersion(const QString &_version)
40+
{
41+
QPushButton* statusLabel = new QPushButton(tr("A new version is available : %1").arg(_version));
42+
statusLabel->setFlat(true);
43+
statusLabel->setStyleSheet("QPushButton { color : red; } QPushButton:flat:pressed { border: none; }");
44+
statusLabel->setCursor(Qt::PointingHandCursor);
45+
addWidget(statusLabel);
46+
47+
connect(statusLabel, SIGNAL(clicked()), (MainWindow*) parent(), SLOT(openNewVersionDialog()));
48+
}
49+
3350
/**
3451
* @brief Show the loader
3552
*/

src/gui/statusbar.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ class StatusBar : public QStatusBar
1818
public:
1919
StatusBar(QWidget* _parent, Controller* _ctrl);
2020

21+
void newVersion(const QString &_version);
22+
2123
public slots:
2224
void showLoader();
2325
void hideLoader();

src/lang/en_GB/main.ts

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@
396396
<context>
397397
<name>MainWindow</name>
398398
<message>
399-
<location filename="../../gui/mainwindow.cpp" line="664"/>
399+
<location filename="../../gui/mainwindow.cpp" line="665"/>
400400
<source>Quit</source>
401401
<translation type="unfinished"></translation>
402402
</message>
@@ -504,13 +504,12 @@
504504
<translation type="unfinished"></translation>
505505
</message>
506506
<message>
507-
<location filename="../../gui/mainwindow.cpp" line="620"/>
508-
<location filename="../../gui/mainwindow.cpp" line="631"/>
507+
<location filename="../../gui/mainwindow.cpp" line="626"/>
509508
<source>A new version is available : %1</source>
510509
<translation type="unfinished"></translation>
511510
</message>
512511
<message>
513-
<location filename="../../gui/mainwindow.cpp" line="668"/>
512+
<location filename="../../gui/mainwindow.cpp" line="669"/>
514513
<source>Close and don&apos;t show this message again</source>
515514
<translation type="unfinished"></translation>
516515
</message>
@@ -520,7 +519,7 @@
520519
<translation type="unfinished"></translation>
521520
</message>
522521
<message>
523-
<location filename="../../gui/mainwindow.cpp" line="665"/>
522+
<location filename="../../gui/mainwindow.cpp" line="666"/>
524523
<source>If you quit the application now,&lt;br&gt;the wallpaper will not change anymore.</source>
525524
<translation type="unfinished"></translation>
526525
</message>
@@ -647,17 +646,27 @@
647646
<translation type="unfinished"></translation>
648647
</message>
649648
<message>
650-
<location filename="../../gui/newversiondialog.cpp" line="55"/>
649+
<location filename="../../gui/newversiondialog.cpp" line="27"/>
650+
<source>Close</source>
651+
<translation type="unfinished"></translation>
652+
</message>
653+
<message>
654+
<location filename="../../gui/newversiondialog.cpp" line="28"/>
655+
<source>Close and don&apos;t show this message again</source>
656+
<translation type="unfinished"></translation>
657+
</message>
658+
<message>
659+
<location filename="../../gui/newversiondialog.cpp" line="58"/>
651660
<source>Downloading UMWP_Autochanger_%1_Setup.exe ...</source>
652661
<translation type="unfinished"></translation>
653662
</message>
654663
<message>
655-
<location filename="../../gui/newversiondialog.cpp" line="71"/>
664+
<location filename="../../gui/newversiondialog.cpp" line="76"/>
656665
<source>Unable to download installer file.</source>
657666
<translation type="unfinished"></translation>
658667
</message>
659668
<message>
660-
<location filename="../../gui/newversiondialog.cpp" line="71"/>
669+
<location filename="../../gui/newversiondialog.cpp" line="76"/>
661670
<source>Error</source>
662671
<translation type="unfinished"></translation>
663672
</message>
@@ -670,12 +679,12 @@
670679
<translation type="unfinished"></translation>
671680
</message>
672681
<message>
673-
<location filename="../../gui/previewdialog.cpp" line="143"/>
682+
<location filename="../../gui/previewdialog.cpp" line="151"/>
674683
<source>Delete</source>
675684
<translation type="unfinished"></translation>
676685
</message>
677686
<message>
678-
<location filename="../../gui/previewdialog.cpp" line="143"/>
687+
<location filename="../../gui/previewdialog.cpp" line="151"/>
679688
<source>Are you sure?</source>
680689
<translation type="unfinished"></translation>
681690
</message>
@@ -923,6 +932,14 @@
923932
<translation type="unfinished"></translation>
924933
</message>
925934
</context>
935+
<context>
936+
<name>StatusBar</name>
937+
<message>
938+
<location filename="../../gui/statusbar.cpp" line="41"/>
939+
<source>A new version is available : %1</source>
940+
<translation type="unfinished"></translation>
941+
</message>
942+
</context>
926943
<context>
927944
<name>TrayIcon</name>
928945
<message>

src/lang/fr_FR/main.ts

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@
411411
<context>
412412
<name>MainWindow</name>
413413
<message>
414-
<location filename="../../gui/mainwindow.cpp" line="664"/>
414+
<location filename="../../gui/mainwindow.cpp" line="665"/>
415415
<source>Quit</source>
416416
<translation>Quitter</translation>
417417
</message>
@@ -519,13 +519,12 @@
519519
<translation>Sets actuels : %1</translation>
520520
</message>
521521
<message>
522-
<location filename="../../gui/mainwindow.cpp" line="620"/>
523-
<location filename="../../gui/mainwindow.cpp" line="631"/>
522+
<location filename="../../gui/mainwindow.cpp" line="626"/>
524523
<source>A new version is available : %1</source>
525524
<translation>Une nouvelle version est disponible : %1</translation>
526525
</message>
527526
<message>
528-
<location filename="../../gui/mainwindow.cpp" line="668"/>
527+
<location filename="../../gui/mainwindow.cpp" line="669"/>
529528
<source>Close and don&apos;t show this message again</source>
530529
<translation>Fermer et ne plus afficher ce message</translation>
531530
</message>
@@ -535,7 +534,7 @@
535534
<translation>%1 est toujours en cours d&apos;éxécution</translation>
536535
</message>
537536
<message>
538-
<location filename="../../gui/mainwindow.cpp" line="665"/>
537+
<location filename="../../gui/mainwindow.cpp" line="666"/>
539538
<source>If you quit the application now,&lt;br&gt;the wallpaper will not change anymore.</source>
540539
<translation>Si vous quittez l&apos;application maintenant,&lt;br&gt;le fond d&apos;écran ne changera plus.</translation>
541540
</message>
@@ -666,17 +665,27 @@
666665
<translation>Une nouvelle version est disponible : %1</translation>
667666
</message>
668667
<message>
669-
<location filename="../../gui/newversiondialog.cpp" line="55"/>
668+
<location filename="../../gui/newversiondialog.cpp" line="27"/>
669+
<source>Close</source>
670+
<translation>Fermer</translation>
671+
</message>
672+
<message>
673+
<location filename="../../gui/newversiondialog.cpp" line="28"/>
674+
<source>Close and don&apos;t show this message again</source>
675+
<translation>Fermer et ne plus afficher ce message</translation>
676+
</message>
677+
<message>
678+
<location filename="../../gui/newversiondialog.cpp" line="58"/>
670679
<source>Downloading UMWP_Autochanger_%1_Setup.exe ...</source>
671680
<translation>Téléchargement de UMWP_Autochanger_%1_Setup.exe ...</translation>
672681
</message>
673682
<message>
674-
<location filename="../../gui/newversiondialog.cpp" line="71"/>
683+
<location filename="../../gui/newversiondialog.cpp" line="76"/>
675684
<source>Unable to download installer file.</source>
676685
<translation>Impossible de télécharger le fichier.</translation>
677686
</message>
678687
<message>
679-
<location filename="../../gui/newversiondialog.cpp" line="71"/>
688+
<location filename="../../gui/newversiondialog.cpp" line="76"/>
680689
<source>Error</source>
681690
<translation>Erreur</translation>
682691
</message>
@@ -693,12 +702,12 @@
693702
<translation type="vanished">Dossiers actifs</translation>
694703
</message>
695704
<message>
696-
<location filename="../../gui/previewdialog.cpp" line="143"/>
705+
<location filename="../../gui/previewdialog.cpp" line="151"/>
697706
<source>Delete</source>
698707
<translation>Supprimer</translation>
699708
</message>
700709
<message>
701-
<location filename="../../gui/previewdialog.cpp" line="143"/>
710+
<location filename="../../gui/previewdialog.cpp" line="151"/>
702711
<source>Are you sure?</source>
703712
<translation>Êtes-vous sûr ?</translation>
704713
</message>
@@ -958,6 +967,14 @@
958967
<translation>Le nom ne peut être vide</translation>
959968
</message>
960969
</context>
970+
<context>
971+
<name>StatusBar</name>
972+
<message>
973+
<location filename="../../gui/statusbar.cpp" line="41"/>
974+
<source>A new version is available : %1</source>
975+
<translation>Une nouvelle version est disponible : %1</translation>
976+
</message>
977+
</context>
961978
<context>
962979
<name>TrayIcon</name>
963980
<message>

0 commit comments

Comments
 (0)