Refactoring VPuzzleSettings

This commit is contained in:
Ronan Le Tiec 2020-05-23 15:44:44 +02:00
parent 83666c090f
commit 22a5e2094c
6 changed files with 28 additions and 28 deletions

View File

@ -19,7 +19,7 @@ SOURCES += \
$$PWD/vpmimedatapiece.cpp \ $$PWD/vpmimedatapiece.cpp \
$$PWD/vppiece.cpp \ $$PWD/vppiece.cpp \
$$PWD/vppiecelist.cpp \ $$PWD/vppiecelist.cpp \
$$PWD/vpuzzlesettings.cpp \ $$PWD/vpsettings.cpp \
$$PWD/xml/vplayoutfilereader.cpp \ $$PWD/xml/vplayoutfilereader.cpp \
$$PWD/xml/vplayoutfilewriter.cpp \ $$PWD/xml/vplayoutfilewriter.cpp \
$$PWD/xml/vplayoutliterals.cpp $$PWD/xml/vplayoutliterals.cpp
@ -43,8 +43,8 @@ HEADERS += \
$$PWD/vpmimedatapiece.h \ $$PWD/vpmimedatapiece.h \
$$PWD/vppiece.h \ $$PWD/vppiece.h \
$$PWD/vppiecelist.h \ $$PWD/vppiecelist.h \
$$PWD/vpsettings.h \
$$PWD/vpstable.h \ $$PWD/vpstable.h \
$$PWD/vpuzzlesettings.h \
$$PWD/xml/vplayoutfilereader.h \ $$PWD/xml/vplayoutfilereader.h \
$$PWD/xml/vplayoutfilewriter.h \ $$PWD/xml/vplayoutfilewriter.h \
$$PWD/xml/vplayoutliterals.h $$PWD/xml/vplayoutliterals.h

View File

@ -405,21 +405,21 @@ const VTranslateVars *VPApplication::TrVars()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPApplication::OpenSettings() void VPApplication::OpenSettings()
{ {
settings = new VPuzzleSettings(QSettings::IniFormat, QSettings::UserScope, QCoreApplication::organizationName(), settings = new VPSettings(QSettings::IniFormat, QSettings::UserScope, QCoreApplication::organizationName(),
QCoreApplication::applicationName(), this); QCoreApplication::applicationName(), this);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPuzzleSettings *VPApplication::PuzzleSettings() VPSettings *VPApplication::PuzzleSettings()
{ {
SCASSERT(settings != nullptr) SCASSERT(settings != nullptr)
return qobject_cast<VPuzzleSettings *>(settings); return qobject_cast<VPSettings *>(settings);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPApplication::ActivateDarkMode() void VPApplication::ActivateDarkMode()
{ {
VPuzzleSettings *settings = qApp->PuzzleSettings(); VPSettings *settings = qApp->PuzzleSettings();
if (settings->GetDarkMode()) if (settings->GetDarkMode())
{ {
QFile f(":qdarkstyle/style.qss"); QFile f(":qdarkstyle/style.qss");

View File

@ -29,7 +29,7 @@
#define VPAPPLICATION_H #define VPAPPLICATION_H
#include "../vmisc/def.h" #include "../vmisc/def.h"
#include "vpuzzlesettings.h" #include "vpsettings.h"
#include "../vmisc/vabstractapplication.h" #include "../vmisc/vabstractapplication.h"
#include "vpcommandline.h" #include "vpcommandline.h"
@ -65,7 +65,7 @@ public:
virtual const VTranslateVars *TrVars() override; virtual const VTranslateVars *TrVars() override;
virtual void OpenSettings() override; virtual void OpenSettings() override;
VPuzzleSettings *PuzzleSettings(); VPSettings *PuzzleSettings();
void ActivateDarkMode(); void ActivateDarkMode();
void ParseCommandLine(const SocketConnection &connection, const QStringList &arguments); void ParseCommandLine(const SocketConnection &connection, const QStringList &arguments);

View File

@ -463,7 +463,7 @@ void VPMainWindow::SetCheckBoxValue(QCheckBox *checkbox, bool value)
void VPMainWindow::ReadSettings() void VPMainWindow::ReadSettings()
{ {
qCDebug(pWindow, "Reading settings."); qCDebug(pWindow, "Reading settings.");
const VPuzzleSettings *settings = qApp->PuzzleSettings(); const VPSettings *settings = qApp->PuzzleSettings();
if (settings->status() == QSettings::NoError) if (settings->status() == QSettings::NoError)
{ {
@ -489,7 +489,7 @@ void VPMainWindow::ReadSettings()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::WriteSettings() void VPMainWindow::WriteSettings()
{ {
VPuzzleSettings *settings = qApp->PuzzleSettings(); VPSettings *settings = qApp->PuzzleSettings();
settings->SetGeometry(saveGeometry()); settings->SetGeometry(saveGeometry());
settings->SetWindowState(saveState()); settings->SetWindowState(saveState());
settings->SetToolbarsState(saveState(APP_VERSION)); settings->SetToolbarsState(saveState(APP_VERSION));

View File

@ -1,6 +1,6 @@
/************************************************************************ /************************************************************************
** **
** @file vpuzzlesettings.cpp ** @file vpsettings.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com> ** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 16 2, 2020 ** @date 16 2, 2020
** **
@ -25,7 +25,7 @@
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
*************************************************************************/ *************************************************************************/
#include "vpuzzlesettings.h" #include "vpsettings.h"
namespace namespace
{ {
@ -34,48 +34,48 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingDockPropertiesContentsActive, (Q
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPuzzleSettings::VPuzzleSettings(Format format, Scope scope, const QString &organization, const QString &application, VPSettings::VPSettings(Format format, Scope scope, const QString &organization, const QString &application,
QObject *parent) QObject *parent)
: VCommonSettings(format, scope, organization, application, parent) : VCommonSettings(format, scope, organization, application, parent)
{} {}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPuzzleSettings::VPuzzleSettings(const QString &fileName, QSettings::Format format, QObject *parent) VPSettings::VPSettings(const QString &fileName, QSettings::Format format, QObject *parent)
: VCommonSettings(fileName, format, parent) : VCommonSettings(fileName, format, parent)
{} {}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VPuzzleSettings::IsDockWidgetPropertiesActive() const bool VPSettings::IsDockWidgetPropertiesActive() const
{ {
return value(*settingDockWidgetPropertiesActive, GetDefDockWidgetPropertiesActive()).toBool(); return value(*settingDockWidgetPropertiesActive, GetDefDockWidgetPropertiesActive()).toBool();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VPuzzleSettings::GetDefDockWidgetPropertiesActive() bool VPSettings::GetDefDockWidgetPropertiesActive()
{ {
return true; return true;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleSettings::SetDockWidgetPropertiesActive(bool value) void VPSettings::SetDockWidgetPropertiesActive(bool value)
{ {
setValue(*settingDockWidgetPropertiesActive, value); setValue(*settingDockWidgetPropertiesActive, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VPuzzleSettings::IsDockWidgetPropertiesContentsActive() const bool VPSettings::IsDockWidgetPropertiesContentsActive() const
{ {
return value(*settingDockWidgetPropertiesActive, GetDefDockWidgetPropertiesActive()).toBool(); return value(*settingDockWidgetPropertiesActive, GetDefDockWidgetPropertiesActive()).toBool();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VPuzzleSettings::GetDefDockWidgetPropertiesContentsActive() bool VPSettings::GetDefDockWidgetPropertiesContentsActive()
{ {
return true; return true;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPuzzleSettings::SetDockWidgetPropertiesContentsActive(bool value) void VPSettings::SetDockWidgetPropertiesContentsActive(bool value)
{ {
setValue(*settingDockPropertiesContentsActive, value); setValue(*settingDockPropertiesContentsActive, value);
} }

View File

@ -1,6 +1,6 @@
/************************************************************************ /************************************************************************
** **
** @file vpuzzlesettings.h ** @file vpsettings.h
** @author Roman Telezhynskyi <dismine(at)gmail.com> ** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 16 2, 2020 ** @date 16 2, 2020
** **
@ -25,20 +25,20 @@
** along with Valentina. If not, see <http://www.gnu.org/licenses/>. ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
** **
*************************************************************************/ *************************************************************************/
#ifndef VPUZZLESETTINGS_H #ifndef VPSETTINGS_H
#define VPUZZLESETTINGS_H #define VPSETTINGS_H
#include <QByteArray> #include <QByteArray>
#include "vcommonsettings.h" #include "vcommonsettings.h"
class VPuzzleSettings : public VCommonSettings class VPSettings : public VCommonSettings
{ {
Q_OBJECT Q_OBJECT
public: public:
VPuzzleSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(), VPSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(),
QObject *parent = nullptr); QObject *parent = nullptr);
VPuzzleSettings(const QString &fileName, Format format, QObject *parent = nullptr); VPSettings(const QString &fileName, Format format, QObject *parent = nullptr);
bool IsDockWidgetPropertiesActive() const; bool IsDockWidgetPropertiesActive() const;
static bool GetDefDockWidgetPropertiesActive(); static bool GetDefDockWidgetPropertiesActive();
@ -49,7 +49,7 @@ public:
void SetDockWidgetPropertiesContentsActive(bool value); void SetDockWidgetPropertiesContentsActive(bool value);
private: private:
Q_DISABLE_COPY(VPuzzleSettings) Q_DISABLE_COPY(VPSettings)
}; };
#endif // VPUZZLESETTINGS_H #endif // VPSETTINGS_H