Clang warnings.

This commit is contained in:
Roman Telezhynskyi 2021-09-24 14:57:30 +03:00
parent b3e52d351e
commit ed7703c60c
10 changed files with 50 additions and 37 deletions

View File

@ -1711,7 +1711,7 @@ void VPMainWindow::ReadSettings()
{ {
restoreGeometry(settings->GetGeometry()); restoreGeometry(settings->GetGeometry());
restoreState(settings->GetWindowState()); restoreState(settings->GetWindowState());
restoreState(settings->GetToolbarsState(), APP_VERSION); restoreState(settings->GetToolbarsState(), AppVersion());
// Text under tool buton icon // Text under tool buton icon
ToolBarStyles(); ToolBarStyles();
@ -1737,7 +1737,7 @@ void VPMainWindow::WriteSettings()
VPSettings *settings = VPApplication::VApp()->PuzzleSettings(); VPSettings *settings = VPApplication::VApp()->PuzzleSettings();
settings->SetGeometry(saveGeometry()); settings->SetGeometry(saveGeometry());
settings->SetWindowState(saveState()); settings->SetWindowState(saveState());
settings->SetToolbarsState(saveState(APP_VERSION)); settings->SetToolbarsState(saveState(AppVersion()));
settings->SetDockWidgetPropertiesActive(ui->dockWidgetProperties->isEnabled()); settings->SetDockWidgetPropertiesActive(ui->dockWidgetProperties->isEnabled());
settings->SetDockWidgetPropertiesContentsActive(ui->dockWidgetPropertiesContents->isEnabled()); settings->SetDockWidgetPropertiesContentsActive(ui->dockWidgetPropertiesContents->isEnabled());

View File

@ -3423,7 +3423,7 @@ void TMainWindow::ReadSettings()
{ {
restoreGeometry(settings->GetGeometry()); restoreGeometry(settings->GetGeometry());
restoreState(settings->GetWindowState()); restoreState(settings->GetWindowState());
restoreState(settings->GetToolbarsState(), APP_VERSION); restoreState(settings->GetToolbarsState(), AppVersion());
// Text under tool buton icon // Text under tool buton icon
ToolBarStyles(); ToolBarStyles();
@ -3443,7 +3443,7 @@ void TMainWindow::WriteSettings()
VTapeSettings *settings = MApplication::VApp()->TapeSettings(); VTapeSettings *settings = MApplication::VApp()->TapeSettings();
settings->SetGeometry(saveGeometry()); settings->SetGeometry(saveGeometry());
settings->SetWindowState(saveState()); settings->SetWindowState(saveState());
settings->SetToolbarsState(saveState(APP_VERSION)); settings->SetToolbarsState(saveState(AppVersion()));
settings->sync(); settings->sync();
if (settings->status() == QSettings::AccessError) if (settings->status() == QSettings::AccessError)

View File

@ -4558,7 +4558,7 @@ void MainWindow::ReadSettings()
{ {
restoreGeometry(settings->GetGeometry()); restoreGeometry(settings->GetGeometry());
restoreState(settings->GetWindowState()); restoreState(settings->GetWindowState());
restoreState(settings->GetToolbarsState(), APP_VERSION); restoreState(settings->GetToolbarsState(), AppVersion());
ui->dockWidgetGroups->setVisible(settings->IsDockWidgetGroupsActive()); ui->dockWidgetGroups->setVisible(settings->IsDockWidgetGroupsActive());
ui->dockWidgetToolOptions->setVisible(settings->IsDockWidgetToolOptionsActive()); ui->dockWidgetToolOptions->setVisible(settings->IsDockWidgetToolOptionsActive());
@ -4600,7 +4600,7 @@ void MainWindow::WriteSettings()
VValentinaSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings(); VValentinaSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings();
settings->SetGeometry(saveGeometry()); settings->SetGeometry(saveGeometry());
settings->SetWindowState(saveState()); settings->SetWindowState(saveState());
settings->SetToolbarsState(saveState(APP_VERSION)); settings->SetToolbarsState(saveState(AppVersion()));
settings->SetDockWidgetGroupsActive(ui->dockWidgetGroups->isEnabled()); settings->SetDockWidgetGroupsActive(ui->dockWidgetGroups->isEnabled());
settings->SetDockWidgetToolOptionsActive(ui->dockWidgetToolOptions->isEnabled()); settings->SetDockWidgetToolOptionsActive(ui->dockWidgetToolOptions->isEnabled());

View File

@ -532,7 +532,7 @@ bool FvUpdater::VersionIsIgnored(const QString &version)
// 3) A newer version (don't ignore) // 3) A newer version (don't ignore)
// 'version' is not likely to contain an older version in any case. // 'version' is not likely to contain an older version in any case.
int decVersion = 0x0; unsigned decVersion = 0x0;
try try
{ {
decVersion = VAbstractConverter::GetFormatVersion(version); decVersion = VAbstractConverter::GetFormatVersion(version);
@ -543,12 +543,12 @@ bool FvUpdater::VersionIsIgnored(const QString &version)
return true; // Ignore invalid version return true; // Ignore invalid version
} }
if (decVersion == APP_VERSION) if (decVersion == AppVersion())
{ {
return true; return true;
} }
const int lastSkippedVersion = VAbstractApplication::VApp()->Settings()->GetLatestSkippedVersion(); const unsigned lastSkippedVersion = VAbstractApplication::VApp()->Settings()->GetLatestSkippedVersion();
if (lastSkippedVersion != 0x0) if (lastSkippedVersion != 0x0)
{ {
if (decVersion == lastSkippedVersion) if (decVersion == lastSkippedVersion)
@ -558,7 +558,7 @@ bool FvUpdater::VersionIsIgnored(const QString &version)
} }
} }
if (decVersion > APP_VERSION) if (decVersion > AppVersion())
{ {
// Newer version - do not skip // Newer version - do not skip
return false; return false;
@ -571,7 +571,7 @@ bool FvUpdater::VersionIsIgnored(const QString &version)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void FvUpdater::IgnoreVersion(const QString &version) void FvUpdater::IgnoreVersion(const QString &version)
{ {
int decVersion = 0x0; unsigned decVersion = 0x0;
try try
{ {
decVersion = VAbstractConverter::GetFormatVersion(version); decVersion = VAbstractConverter::GetFormatVersion(version);
@ -582,7 +582,7 @@ void FvUpdater::IgnoreVersion(const QString &version)
return ; // Ignore invalid version return ; // Ignore invalid version
} }
if (decVersion == APP_VERSION) if (decVersion == AppVersion())
{ {
// Don't ignore the current version // Don't ignore the current version
return; return;

View File

@ -36,11 +36,7 @@
#include <QtGlobal> #include <QtGlobal>
#include "vdomdocument.h" #include "vdomdocument.h"
#include "../vmisc/projectversion.h"
constexpr inline auto FormatVersion(unsigned major, unsigned minor, unsigned patch) -> unsigned
{
return ((major<<16u)|(minor<<8u)|patch);
}
class VAbstractConverter :public VDomDocument class VAbstractConverter :public VDomDocument
{ {

View File

@ -43,9 +43,14 @@ enum CustomEventType {
}; };
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wenum-enum-conversion")
// Define undo event identifier // Define undo event identifier
const QEvent::Type UNDO_EVENT = static_cast<QEvent::Type>(QEvent::User + CustomEventType::UndoEventType); const QEvent::Type UNDO_EVENT = static_cast<QEvent::Type>(QEvent::User + CustomEventType::UndoEventType);
QT_WARNING_POP
class UndoEvent : public QEvent class UndoEvent : public QEvent
{ {
public: public:
@ -57,8 +62,13 @@ public:
}; };
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wenum-enum-conversion")
const QEvent::Type LITE_PARSE_EVENT = static_cast<QEvent::Type>(QEvent::User + CustomEventType::LiteParseEventType); const QEvent::Type LITE_PARSE_EVENT = static_cast<QEvent::Type>(QEvent::User + CustomEventType::LiteParseEventType);
QT_WARNING_POP
class LiteParseEvent : public QEvent class LiteParseEvent : public QEvent
{ {
public: public:
@ -70,9 +80,14 @@ public:
}; };
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wenum-enum-conversion")
const QEvent::Type FIT_BEST_CURRENT_EVENT = static_cast<QEvent::Type>(QEvent::User + const QEvent::Type FIT_BEST_CURRENT_EVENT = static_cast<QEvent::Type>(QEvent::User +
CustomEventType::FitBestCurrentEventType); CustomEventType::FitBestCurrentEventType);
QT_WARNING_POP
class FitBestCurrentEvent : public QEvent class FitBestCurrentEvent : public QEvent
{ {
public: public:
@ -84,9 +99,14 @@ public:
}; };
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wenum-enum-conversion")
const QEvent::Type WARNING_MESSAGE_EVENT = static_cast<QEvent::Type>(QEvent::User + const QEvent::Type WARNING_MESSAGE_EVENT = static_cast<QEvent::Type>(QEvent::User +
CustomEventType::WarningMessageEventType); CustomEventType::WarningMessageEventType);
QT_WARNING_POP
class WarningMessageEvent : public QEvent class WarningMessageEvent : public QEvent
{ {
public: public:

View File

@ -40,10 +40,6 @@
#include <QSysInfo> #include <QSysInfo>
#include <QtGlobal> #include <QtGlobal>
extern const int MAJOR_VERSION = 0;
extern const int MINOR_VERSION = 7;
extern const int DEBUG_VERSION = 49;
extern const QString APP_VERSION_STR(QStringLiteral("%1.%2.%3.%4").arg(MAJOR_VERSION).arg(MINOR_VERSION) extern const QString APP_VERSION_STR(QStringLiteral("%1.%2.%3.%4").arg(MAJOR_VERSION).arg(MINOR_VERSION)
.arg(DEBUG_VERSION).arg(LATEST_TAG_DISTANCE)); .arg(DEBUG_VERSION).arg(LATEST_TAG_DISTANCE));

View File

@ -31,20 +31,21 @@
class QString; class QString;
extern const int MAJOR_VERSION; constexpr unsigned MAJOR_VERSION = 0;
extern const int MINOR_VERSION; constexpr unsigned MINOR_VERSION = 7;
extern const int DEBUG_VERSION; constexpr unsigned DEBUG_VERSION = 49;
extern const QString APP_VERSION_STR; extern const QString APP_VERSION_STR;
/* constexpr inline auto FormatVersion(unsigned major, unsigned minor, unsigned patch) -> unsigned
APP_VERSION is (major << 16) + (minor << 8) + patch. {
*/ return ((major<<16u)|(minor<<8u)|patch);
#define APP_VERSION V_VERSION_CHECK(MAJOR_VERSION, MINOR_VERSION, DEBUG_VERSION) }
/*
can be used like #if (APP_VERSION >= V_VERSION_CHECK(0, 7, 0)) constexpr inline auto AppVersion() -> unsigned
*/ {
#define V_VERSION_CHECK(major, minor, patch) ((major<<16)|(minor<<8)|(patch)) return FormatVersion(MAJOR_VERSION, MINOR_VERSION, DEBUG_VERSION);
}
// Change version number in projectversion.cpp too. // Change version number in projectversion.cpp too.
// Synchronize valentina.nsi // Synchronize valentina.nsi

View File

@ -800,14 +800,14 @@ void VCommonSettings::SetFinalMeasurementsDialogSize(const QSize &sz)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int VCommonSettings::GetLatestSkippedVersion() const unsigned VCommonSettings::GetLatestSkippedVersion() const
{ {
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename); QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
return settings.value(*settingLatestSkippedVersion, 0x0).toInt(); return settings.value(*settingLatestSkippedVersion, 0x0).toUInt();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::SetLatestSkippedVersion(int value) void VCommonSettings::SetLatestSkippedVersion(unsigned value)
{ {
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename); QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
settings.setValue(*settingLatestSkippedVersion, value); settings.setValue(*settingLatestSkippedVersion, value);

View File

@ -153,8 +153,8 @@ public:
QSize GetFinalMeasurementsDialogSize() const; QSize GetFinalMeasurementsDialogSize() const;
void SetFinalMeasurementsDialogSize(const QSize& sz); void SetFinalMeasurementsDialogSize(const QSize& sz);
int GetLatestSkippedVersion() const; unsigned GetLatestSkippedVersion() const;
void SetLatestSkippedVersion(int value); void SetLatestSkippedVersion(unsigned value);
QDate GetDateOfLastRemind() const; QDate GetDateOfLastRemind() const;
void SetDateOfLastRemind(const QDate &date); void SetDateOfLastRemind(const QDate &date);