From 213863ae983664a5a56f20da1948db8c8e01140e Mon Sep 17 00:00:00 2001 From: Ronan Le Tiec Date: Sat, 23 May 2020 13:49:38 +0200 Subject: [PATCH] refactoring dialog about --- ...ialogaboutpuzzle.cpp => vpdialogabout.cpp} | 22 +++++++++---------- .../{dialogaboutpuzzle.h => vpdialogabout.h} | 20 ++++++++--------- ...{dialogaboutpuzzle.ui => vpdialogabout.ui} | 5 +++-- src/app/puzzle/puzzle.pri | 6 ++--- src/app/puzzle/puzzlemainwindow.cpp | 5 +++-- 5 files changed, 30 insertions(+), 28 deletions(-) rename src/app/puzzle/dialogs/{dialogaboutpuzzle.cpp => vpdialogabout.cpp} (89%) rename src/app/puzzle/dialogs/{dialogaboutpuzzle.h => vpdialogabout.h} (80%) rename src/app/puzzle/dialogs/{dialogaboutpuzzle.ui => vpdialogabout.ui} (98%) diff --git a/src/app/puzzle/dialogs/dialogaboutpuzzle.cpp b/src/app/puzzle/dialogs/vpdialogabout.cpp similarity index 89% rename from src/app/puzzle/dialogs/dialogaboutpuzzle.cpp rename to src/app/puzzle/dialogs/vpdialogabout.cpp index 89328bfab..857c0b12e 100644 --- a/src/app/puzzle/dialogs/dialogaboutpuzzle.cpp +++ b/src/app/puzzle/dialogs/vpdialogabout.cpp @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file dialogaboutpuzzle.cpp + ** @file vpdialogabout.cpp ** @author Ronan Le Tiec ** @date 11 4, 2020 ** @@ -26,8 +26,8 @@ ** *************************************************************************/ -#include "dialogaboutpuzzle.h" -#include "ui_dialogaboutpuzzle.h" +#include "vpdialogabout.h" +#include "ui_vpdialogabout.h" #include "../version.h" #include "../vmisc/def.h" #include "../fervor/fvupdater.h" @@ -40,9 +40,9 @@ #include //--------------------------------------------------------------------------------------------------------------------- -DialogAboutPuzzle::DialogAboutPuzzle(QWidget *parent) +VPDialogAbout::VPDialogAbout(QWidget *parent) :QDialog(parent), - ui(new Ui::DialogAboutPuzzle), + ui(new Ui::VPDialogAbout), isInitialized(false) { ui->setupUi(this); @@ -57,7 +57,7 @@ DialogAboutPuzzle::DialogAboutPuzzle(QWidget *parent) qWarning() << tr("Cannot open your default browser"); } }); - connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &DialogAboutPuzzle::close); + connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &VPDialogAbout::close); connect(ui->pushButtonCheckUpdate, &QPushButton::clicked, []() { // Set feed URL before doing anything else @@ -72,13 +72,13 @@ DialogAboutPuzzle::DialogAboutPuzzle(QWidget *parent) } //--------------------------------------------------------------------------------------------------------------------- -DialogAboutPuzzle::~DialogAboutPuzzle() +VPDialogAbout::~VPDialogAbout() { delete ui; } //--------------------------------------------------------------------------------------------------------------------- -void DialogAboutPuzzle::changeEvent(QEvent *event) +void VPDialogAbout::changeEvent(QEvent *event) { if (event->type() == QEvent::LanguageChange) { @@ -92,7 +92,7 @@ void DialogAboutPuzzle::changeEvent(QEvent *event) } //--------------------------------------------------------------------------------------------------------------------- -void DialogAboutPuzzle::showEvent(QShowEvent *event) +void VPDialogAbout::showEvent(QShowEvent *event) { QDialog::showEvent( event ); if ( event->spontaneous() ) @@ -113,7 +113,7 @@ void DialogAboutPuzzle::showEvent(QShowEvent *event) } //--------------------------------------------------------------------------------------------------------------------- -void DialogAboutPuzzle::FontPointSize(QWidget *w, int pointSize) +void VPDialogAbout::FontPointSize(QWidget *w, int pointSize) { SCASSERT(w != nullptr) @@ -123,7 +123,7 @@ void DialogAboutPuzzle::FontPointSize(QWidget *w, int pointSize) } //--------------------------------------------------------------------------------------------------------------------- -void DialogAboutPuzzle::RetranslateUi() +void VPDialogAbout::RetranslateUi() { ui->label_Puzzle_Version->setText(QString("Puzzle %1").arg(APP_VERSION_STR)); ui->labelBuildRevision->setText(tr("Build revision: %1").arg(BUILD_REVISION)); diff --git a/src/app/puzzle/dialogs/dialogaboutpuzzle.h b/src/app/puzzle/dialogs/vpdialogabout.h similarity index 80% rename from src/app/puzzle/dialogs/dialogaboutpuzzle.h rename to src/app/puzzle/dialogs/vpdialogabout.h index 62d0d2498..fce48ca0e 100644 --- a/src/app/puzzle/dialogs/dialogaboutpuzzle.h +++ b/src/app/puzzle/dialogs/vpdialogabout.h @@ -1,6 +1,6 @@ /************************************************************************ ** - ** @file dialogaboutpuzzle.h + ** @file vpdialogabout.h ** @author Ronan Le Tiec ** @date 11 4, 2020 ** @@ -26,31 +26,31 @@ ** *************************************************************************/ -#ifndef DIALOGABOUTPUZZLE_H -#define DIALOGABOUTPUZZLE_H +#ifndef VPDIALOGABOUT_H +#define VPDIALOGABOUT_H #include namespace Ui { - class DialogAboutPuzzle; + class VPDialogAbout; } -class DialogAboutPuzzle : public QDialog +class VPDialogAbout : public QDialog { Q_OBJECT public: - explicit DialogAboutPuzzle(QWidget *parent = nullptr); - virtual ~DialogAboutPuzzle(); + explicit VPDialogAbout(QWidget *parent = nullptr); + virtual ~VPDialogAbout(); protected: virtual void changeEvent(QEvent* event) override; virtual void showEvent(QShowEvent *event) override; private: - Q_DISABLE_COPY(DialogAboutPuzzle) - Ui::DialogAboutPuzzle *ui; + Q_DISABLE_COPY(VPDialogAbout) + Ui::VPDialogAbout *ui; bool isInitialized; void FontPointSize(QWidget *w, int pointSize); @@ -58,4 +58,4 @@ private: void RetranslateUi(); }; -#endif // DIALOGABOUTPUZZLE_H +#endif // VPDIALOGABOUT_H diff --git a/src/app/puzzle/dialogs/dialogaboutpuzzle.ui b/src/app/puzzle/dialogs/vpdialogabout.ui similarity index 98% rename from src/app/puzzle/dialogs/dialogaboutpuzzle.ui rename to src/app/puzzle/dialogs/vpdialogabout.ui index 9b4344117..f98c73aa6 100644 --- a/src/app/puzzle/dialogs/dialogaboutpuzzle.ui +++ b/src/app/puzzle/dialogs/vpdialogabout.ui @@ -1,7 +1,7 @@ - DialogAboutPuzzle - + VPDialogAbout + 0 @@ -296,6 +296,7 @@ + diff --git a/src/app/puzzle/puzzle.pri b/src/app/puzzle/puzzle.pri index 5ed131c58..9405487ca 100644 --- a/src/app/puzzle/puzzle.pri +++ b/src/app/puzzle/puzzle.pri @@ -2,13 +2,13 @@ # This need for corect working file translations.pro SOURCES += \ + $$PWD/dialogs/vpdialogabout.cpp \ $$PWD/main.cpp \ $$PWD/puzzlecommands.cpp \ $$PWD/puzzlemainwindow.cpp \ $$PWD/puzzleapplication.cpp \ $$PWD/vpiececarrouselpiecepreview.cpp \ $$PWD/vpuzzlecommandline.cpp \ - $$PWD/dialogs/dialogaboutpuzzle.cpp \ $$PWD/vpiececarrousel.cpp \ $$PWD/vpuzzlegraphicslayout.cpp \ $$PWD/vpuzzlegraphicspiece.cpp \ @@ -27,13 +27,13 @@ SOURCES += \ *msvc*:SOURCES += $$PWD/stable.cpp HEADERS += \ + $$PWD/dialogs/vpdialogabout.h \ $$PWD/puzzlecommands.h \ $$PWD/puzzlemainwindow.h \ $$PWD/stable.h \ $$PWD/puzzleapplication.h \ $$PWD/vpiececarrouselpiecepreview.h \ $$PWD/vpuzzlecommandline.h \ - $$PWD/dialogs/dialogaboutpuzzle.h \ $$PWD/vpiececarrousel.h \ $$PWD/vpuzzlegraphicslayout.h \ $$PWD/vpuzzlegraphicspiece.h \ @@ -50,6 +50,6 @@ HEADERS += \ $$PWD/vpiececarrouselpiece.h FORMS += \ + $$PWD/dialogs/vpdialogabout.ui \ $$PWD/puzzlemainwindow.ui \ - $$PWD/dialogs/dialogaboutpuzzle.ui \ $$PWD/vpiececarrousel.ui diff --git a/src/app/puzzle/puzzlemainwindow.cpp b/src/app/puzzle/puzzlemainwindow.cpp index 874477d53..9a86fa91b 100644 --- a/src/app/puzzle/puzzlemainwindow.cpp +++ b/src/app/puzzle/puzzlemainwindow.cpp @@ -28,9 +28,10 @@ #include "puzzlemainwindow.h" #include +#include #include "ui_puzzlemainwindow.h" -#include "dialogs/dialogaboutpuzzle.h" +#include "dialogs/vpdialogabout.h" #include "xml/vpuzzlelayoutfilewriter.h" #include "xml/vpuzzlelayoutfilereader.h" #include "puzzleapplication.h" @@ -754,7 +755,7 @@ void PuzzleMainWindow::on_actionAboutQt_triggered() //--------------------------------------------------------------------------------------------------------------------- void PuzzleMainWindow::on_actionAboutPuzzle_triggered() { - auto *aboutDialog = new DialogAboutPuzzle(this); + auto *aboutDialog = new VPDialogAbout(this); aboutDialog->setAttribute(Qt::WA_DeleteOnClose, true); aboutDialog->show(); }