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
** @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 <QtDebug>
//---------------------------------------------------------------------------------------------------------------------
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));

View File

@ -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 <QDialog>
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

View File

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

View File

@ -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

View File

@ -28,9 +28,10 @@
#include "puzzlemainwindow.h"
#include <QFileDialog>
#include <QCloseEvent>
#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();
}