refactoring dialog about

This commit is contained in:
Ronan Le Tiec 2020-05-23 13:49:38 +02:00
parent e2cfe7d0cc
commit 213863ae98
5 changed files with 30 additions and 28 deletions

View File

@ -1,6 +1,6 @@
/************************************************************************ /************************************************************************
** **
** @file dialogaboutpuzzle.cpp ** @file vpdialogabout.cpp
** @author Ronan Le Tiec ** @author Ronan Le Tiec
** @date 11 4, 2020 ** @date 11 4, 2020
** **
@ -26,8 +26,8 @@
** **
*************************************************************************/ *************************************************************************/
#include "dialogaboutpuzzle.h" #include "vpdialogabout.h"
#include "ui_dialogaboutpuzzle.h" #include "ui_vpdialogabout.h"
#include "../version.h" #include "../version.h"
#include "../vmisc/def.h" #include "../vmisc/def.h"
#include "../fervor/fvupdater.h" #include "../fervor/fvupdater.h"
@ -40,9 +40,9 @@
#include <QtDebug> #include <QtDebug>
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
DialogAboutPuzzle::DialogAboutPuzzle(QWidget *parent) VPDialogAbout::VPDialogAbout(QWidget *parent)
:QDialog(parent), :QDialog(parent),
ui(new Ui::DialogAboutPuzzle), ui(new Ui::VPDialogAbout),
isInitialized(false) isInitialized(false)
{ {
ui->setupUi(this); ui->setupUi(this);
@ -57,7 +57,7 @@ DialogAboutPuzzle::DialogAboutPuzzle(QWidget *parent)
qWarning() << tr("Cannot open your default browser"); 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, []() connect(ui->pushButtonCheckUpdate, &QPushButton::clicked, []()
{ {
// Set feed URL before doing anything else // Set feed URL before doing anything else
@ -72,13 +72,13 @@ DialogAboutPuzzle::DialogAboutPuzzle(QWidget *parent)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
DialogAboutPuzzle::~DialogAboutPuzzle() VPDialogAbout::~VPDialogAbout()
{ {
delete ui; delete ui;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogAboutPuzzle::changeEvent(QEvent *event) void VPDialogAbout::changeEvent(QEvent *event)
{ {
if (event->type() == QEvent::LanguageChange) 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 ); QDialog::showEvent( event );
if ( event->spontaneous() ) 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) 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->label_Puzzle_Version->setText(QString("Puzzle %1").arg(APP_VERSION_STR));
ui->labelBuildRevision->setText(tr("Build revision: %1").arg(BUILD_REVISION)); ui->labelBuildRevision->setText(tr("Build revision: %1").arg(BUILD_REVISION));

View File

@ -1,6 +1,6 @@
/************************************************************************ /************************************************************************
** **
** @file dialogaboutpuzzle.h ** @file vpdialogabout.h
** @author Ronan Le Tiec ** @author Ronan Le Tiec
** @date 11 4, 2020 ** @date 11 4, 2020
** **
@ -26,31 +26,31 @@
** **
*************************************************************************/ *************************************************************************/
#ifndef DIALOGABOUTPUZZLE_H #ifndef VPDIALOGABOUT_H
#define DIALOGABOUTPUZZLE_H #define VPDIALOGABOUT_H
#include <QDialog> #include <QDialog>
namespace Ui namespace Ui
{ {
class DialogAboutPuzzle; class VPDialogAbout;
} }
class DialogAboutPuzzle : public QDialog class VPDialogAbout : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit DialogAboutPuzzle(QWidget *parent = nullptr); explicit VPDialogAbout(QWidget *parent = nullptr);
virtual ~DialogAboutPuzzle(); virtual ~VPDialogAbout();
protected: protected:
virtual void changeEvent(QEvent* event) override; virtual void changeEvent(QEvent* event) override;
virtual void showEvent(QShowEvent *event) override; virtual void showEvent(QShowEvent *event) override;
private: private:
Q_DISABLE_COPY(DialogAboutPuzzle) Q_DISABLE_COPY(VPDialogAbout)
Ui::DialogAboutPuzzle *ui; Ui::VPDialogAbout *ui;
bool isInitialized; bool isInitialized;
void FontPointSize(QWidget *w, int pointSize); void FontPointSize(QWidget *w, int pointSize);
@ -58,4 +58,4 @@ private:
void RetranslateUi(); void RetranslateUi();
}; };
#endif // DIALOGABOUTPUZZLE_H #endif // VPDIALOGABOUT_H

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>DialogAboutPuzzle</class> <class>VPDialogAbout</class>
<widget class="QDialog" name="DialogAboutPuzzle"> <widget class="QDialog" name="VPDialogAbout">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
@ -296,6 +296,7 @@
</widget> </widget>
<resources> <resources>
<include location="../share/resources/puzzleicon.qrc"/> <include location="../share/resources/puzzleicon.qrc"/>
<include location="../share/resources/puzzleicon.qrc"/>
</resources> </resources>
<connections/> <connections/>
</ui> </ui>

View File

@ -2,13 +2,13 @@
# This need for corect working file translations.pro # This need for corect working file translations.pro
SOURCES += \ SOURCES += \
$$PWD/dialogs/vpdialogabout.cpp \
$$PWD/main.cpp \ $$PWD/main.cpp \
$$PWD/puzzlecommands.cpp \ $$PWD/puzzlecommands.cpp \
$$PWD/puzzlemainwindow.cpp \ $$PWD/puzzlemainwindow.cpp \
$$PWD/puzzleapplication.cpp \ $$PWD/puzzleapplication.cpp \
$$PWD/vpiececarrouselpiecepreview.cpp \ $$PWD/vpiececarrouselpiecepreview.cpp \
$$PWD/vpuzzlecommandline.cpp \ $$PWD/vpuzzlecommandline.cpp \
$$PWD/dialogs/dialogaboutpuzzle.cpp \
$$PWD/vpiececarrousel.cpp \ $$PWD/vpiececarrousel.cpp \
$$PWD/vpuzzlegraphicslayout.cpp \ $$PWD/vpuzzlegraphicslayout.cpp \
$$PWD/vpuzzlegraphicspiece.cpp \ $$PWD/vpuzzlegraphicspiece.cpp \
@ -27,13 +27,13 @@ SOURCES += \
*msvc*:SOURCES += $$PWD/stable.cpp *msvc*:SOURCES += $$PWD/stable.cpp
HEADERS += \ HEADERS += \
$$PWD/dialogs/vpdialogabout.h \
$$PWD/puzzlecommands.h \ $$PWD/puzzlecommands.h \
$$PWD/puzzlemainwindow.h \ $$PWD/puzzlemainwindow.h \
$$PWD/stable.h \ $$PWD/stable.h \
$$PWD/puzzleapplication.h \ $$PWD/puzzleapplication.h \
$$PWD/vpiececarrouselpiecepreview.h \ $$PWD/vpiececarrouselpiecepreview.h \
$$PWD/vpuzzlecommandline.h \ $$PWD/vpuzzlecommandline.h \
$$PWD/dialogs/dialogaboutpuzzle.h \
$$PWD/vpiececarrousel.h \ $$PWD/vpiececarrousel.h \
$$PWD/vpuzzlegraphicslayout.h \ $$PWD/vpuzzlegraphicslayout.h \
$$PWD/vpuzzlegraphicspiece.h \ $$PWD/vpuzzlegraphicspiece.h \
@ -50,6 +50,6 @@ HEADERS += \
$$PWD/vpiececarrouselpiece.h $$PWD/vpiececarrouselpiece.h
FORMS += \ FORMS += \
$$PWD/dialogs/vpdialogabout.ui \
$$PWD/puzzlemainwindow.ui \ $$PWD/puzzlemainwindow.ui \
$$PWD/dialogs/dialogaboutpuzzle.ui \
$$PWD/vpiececarrousel.ui $$PWD/vpiececarrousel.ui

View File

@ -28,9 +28,10 @@
#include "puzzlemainwindow.h" #include "puzzlemainwindow.h"
#include <QFileDialog> #include <QFileDialog>
#include <QCloseEvent>
#include "ui_puzzlemainwindow.h" #include "ui_puzzlemainwindow.h"
#include "dialogs/dialogaboutpuzzle.h" #include "dialogs/vpdialogabout.h"
#include "xml/vpuzzlelayoutfilewriter.h" #include "xml/vpuzzlelayoutfilewriter.h"
#include "xml/vpuzzlelayoutfilereader.h" #include "xml/vpuzzlelayoutfilereader.h"
#include "puzzleapplication.h" #include "puzzleapplication.h"
@ -754,7 +755,7 @@ void PuzzleMainWindow::on_actionAboutQt_triggered()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void PuzzleMainWindow::on_actionAboutPuzzle_triggered() void PuzzleMainWindow::on_actionAboutPuzzle_triggered()
{ {
auto *aboutDialog = new DialogAboutPuzzle(this); auto *aboutDialog = new VPDialogAbout(this);
aboutDialog->setAttribute(Qt::WA_DeleteOnClose, true); aboutDialog->setAttribute(Qt::WA_DeleteOnClose, true);
aboutDialog->show(); aboutDialog->show();
} }