Fix deprecation warnings.

This commit is contained in:
Roman Telezhynskyi 2023-10-24 11:03:04 +03:00
parent 8527c5936c
commit 434a1d0acf
22 changed files with 277 additions and 156 deletions

View File

@ -110,7 +110,7 @@ Module {
// You can make your code fail to compile if it uses deprecated APIs.
// In order to do so, uncomment the following line.
"QT_DISABLE_DEPRECATED_BEFORE=0x060000", // disables all the APIs deprecated before Qt 6.0.0
"QT_DISABLE_DEPRECATED_BEFORE=0x060600", // disables all the APIs deprecated before Qt 6.6.0
// Since Qt 5.4.0 the source code location is recorded only in debug builds.
// We need this information also in release builds. For this need define QT_MESSAGELOGCONTEXT.

View File

@ -29,7 +29,6 @@
#include <QMessageBox> // For QT_REQUIRE_VERSION
#include <QTimer>
#include "../vmisc/def.h"
#include "vpapplication.h"
#if defined(APPIMAGE) && defined(Q_OS_LINUX)
@ -45,6 +44,35 @@
#include <xercesc/util/PlatformUtils.hpp>
#endif
// Fix bug in Qt. Deprecation warning in QMessageBox::critical.
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
#undef QT_REQUIRE_VERSION
#define QT_REQUIRE_VERSION(argc, argv, str) \
{ \
QString s = QString::fromLatin1(str); \
QString sq = QString::fromLatin1(qVersion()); \
if ((sq.section(QChar::fromLatin1('.'), 0, 0).toInt() << 16) + \
(sq.section(QChar::fromLatin1('.'), 1, 1).toInt() << 8) + \
sq.section(QChar::fromLatin1('.'), 2, 2).toInt() < \
(s.section(QChar::fromLatin1('.'), 0, 0).toInt() << 16) + \
(s.section(QChar::fromLatin1('.'), 1, 1).toInt() << 8) + \
s.section(QChar::fromLatin1('.'), 2, 2).toInt()) \
{ \
if (!qApp) \
{ \
new QApplication(argc, argv); \
} \
QString s = QApplication::tr("Executable '%1' requires Qt %2, found Qt %3.") \
.arg(qAppName()) \
.arg(QString::fromLatin1(str)) \
.arg(QString::fromLatin1(qVersion())); \
QMessageBox::critical(0, QApplication::tr("Incompatible Qt Library Error"), s, QMessageBox::Abort, \
static_cast<QMessageBox::StandardButton>(0)); \
qFatal("%s", s.toLatin1().data()); \
} \
}
#endif
auto main(int argc, char *argv[]) -> int
{
#if defined(APPIMAGE) && defined(Q_OS_LINUX)

View File

@ -1737,15 +1737,23 @@ auto VPMainWindow::MaybeSave() -> bool
// TODO: Implement maybe save check
if (this->isWindowModified())
{
QScopedPointer<QMessageBox> messageBox(new QMessageBox(
tr("Unsaved changes"), tr("Layout has been modified. Do you want to save your changes?"),
QMessageBox::Warning, QMessageBox::Yes, QMessageBox::No, QMessageBox::Cancel, this, Qt::Sheet));
QScopedPointer<QMessageBox> messageBox(
new QMessageBox(QMessageBox::Warning, tr("Unsaved changes"),
tr("Layout has been modified. Do you want to save your changes?"),
QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, this, Qt::Sheet));
messageBox->setDefaultButton(QMessageBox::Yes);
messageBox->setEscapeButton(QMessageBox::Cancel);
messageBox->setButtonText(QMessageBox::Yes, curFile.isEmpty() || IsLayoutReadOnly() ? tr("Save…") : tr("Save"));
messageBox->setButtonText(QMessageBox::No, tr("Don't Save"));
if (QAbstractButton *button = messageBox->button(QMessageBox::Yes))
{
button->setText(curFile.isEmpty() || IsLayoutReadOnly() ? tr("Save…") : tr("Save"));
}
if (QAbstractButton *button = messageBox->button(QMessageBox::No))
{
button->setText(tr("Don't Save"));
}
messageBox->setWindowModality(Qt::ApplicationModal);
const auto ret = static_cast<QMessageBox::StandardButton>(messageBox->exec());

View File

@ -44,6 +44,35 @@
#include <xercesc/util/PlatformUtils.hpp>
#endif
// Fix bug in Qt. Deprecation warning in QMessageBox::critical.
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
#undef QT_REQUIRE_VERSION
#define QT_REQUIRE_VERSION(argc, argv, str) \
{ \
QString s = QString::fromLatin1(str); \
QString sq = QString::fromLatin1(qVersion()); \
if ((sq.section(QChar::fromLatin1('.'), 0, 0).toInt() << 16) + \
(sq.section(QChar::fromLatin1('.'), 1, 1).toInt() << 8) + \
sq.section(QChar::fromLatin1('.'), 2, 2).toInt() < \
(s.section(QChar::fromLatin1('.'), 0, 0).toInt() << 16) + \
(s.section(QChar::fromLatin1('.'), 1, 1).toInt() << 8) + \
s.section(QChar::fromLatin1('.'), 2, 2).toInt()) \
{ \
if (!qApp) \
{ \
new QApplication(argc, argv); \
} \
QString s = QApplication::tr("Executable '%1' requires Qt %2, found Qt %3.") \
.arg(qAppName()) \
.arg(QString::fromLatin1(str)) \
.arg(QString::fromLatin1(qVersion())); \
QMessageBox::critical(0, QApplication::tr("Incompatible Qt Library Error"), s, QMessageBox::Abort, \
static_cast<QMessageBox::StandardButton>(0)); \
qFatal("%s", s.toLatin1().data()); \
} \
}
#endif
auto main(int argc, char *argv[]) -> int
{
#if defined(APPIMAGE) && defined(Q_OS_LINUX)
@ -90,7 +119,7 @@ auto main(int argc, char *argv[]) -> int
MApplication app(argc, argv);
app.InitOptions();
QT_REQUIRE_VERSION(argc, argv, "5.6.0") // clazy:exclude=qstring-arg,qstring-allocations NOLINT
QT_REQUIRE_VERSION(argc, argv, "5.6.0"); // clazy:exclude=qstring-arg,qstring-allocations NOLINT
#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)
MApplication::setDesktopFileName(QStringLiteral("ua.com.smart-pattern.tape.desktop"));

View File

@ -3494,15 +3494,23 @@ auto TMainWindow::MaybeSave() -> bool
return true; // Don't ask if file was created without modifications.
}
QScopedPointer<QMessageBox> messageBox(new QMessageBox(
tr("Unsaved changes"), tr("Measurements have been modified. Do you want to save your changes?"),
QMessageBox::Warning, QMessageBox::Yes, QMessageBox::No, QMessageBox::Cancel, this, Qt::Sheet));
QScopedPointer<QMessageBox> messageBox(
new QMessageBox(QMessageBox::Warning, tr("Unsaved changes"),
tr("Measurements have been modified. Do you want to save your changes?"),
QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, this, Qt::Sheet));
messageBox->setDefaultButton(QMessageBox::Yes);
messageBox->setEscapeButton(QMessageBox::Cancel);
messageBox->setButtonText(QMessageBox::Yes, m_curFile.isEmpty() || m_mIsReadOnly ? tr("Save…") : tr("Save"));
messageBox->setButtonText(QMessageBox::No, tr("Don't Save"));
if (QAbstractButton *button = messageBox->button(QMessageBox::Yes))
{
button->setText(m_curFile.isEmpty() || m_mIsReadOnly ? tr("Save…") : tr("Save"));
}
if (QAbstractButton *button = messageBox->button(QMessageBox::No))
{
button->setText(tr("Don't Save"));
}
messageBox->setWindowModality(Qt::ApplicationModal);
const auto ret = static_cast<QMessageBox::StandardButton>(messageBox->exec());
@ -3533,7 +3541,7 @@ auto TMainWindow::MaybeSave() -> bool
auto TMainWindow::AddCell(const QString &text, int row, int column, int aligment, bool ok) -> QTableWidgetItem *
{
auto *item = new QTableWidgetItem(text);
item->setTextAlignment(aligment);
SetTextAlignment(item, static_cast<Qt::Alignment>(aligment));
item->setToolTip(text);
// set the item non-editable (view only), and non-selectable

View File

@ -28,6 +28,7 @@
#include "dialogfinalmeasurements.h"
#include "../qmuparser/qmudef.h"
#include "../vmisc/compatibility.h"
#include "../vmisc/theme/vtheme.h"
#include "../vmisc/vabstractvalapplication.h"
#include "../vmisc/vvalentinasettings.h"
@ -38,10 +39,6 @@
#include <QMenu>
#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0)
#include "../vmisc/compatibility.h"
#endif
using namespace Qt::Literals::StringLiterals;
constexpr int DIALOG_MAX_FORMULA_HEIGHT = 64;
@ -571,7 +568,7 @@ void DialogFinalMeasurements::ShowUnits()
void DialogFinalMeasurements::AddCell(const QString &text, int row, int column, int aligment, bool ok)
{
auto *item = new QTableWidgetItem(text);
item->setTextAlignment(aligment);
SetTextAlignment(item, static_cast<Qt::Alignment>(aligment));
// set the item non-editable (view only), and non-selectable
Qt::ItemFlags flags = item->flags();

View File

@ -331,7 +331,7 @@ auto DialogIncrements::AddCell(QTableWidget *table, const QString &text, int row
SCASSERT(table != nullptr)
auto *item = new QTableWidgetItem(text);
item->setTextAlignment(aligment);
SetTextAlignment(item, static_cast<Qt::Alignment>(aligment));
item->setToolTip(text);
// set the item non-editable (view only), and non-selectable

View File

@ -48,6 +48,35 @@
#include <xercesc/util/PlatformUtils.hpp>
#endif
// Fix bug in Qt. Deprecation warning in QMessageBox::critical.
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
#undef QT_REQUIRE_VERSION
#define QT_REQUIRE_VERSION(argc, argv, str) \
{ \
QString s = QString::fromLatin1(str); \
QString sq = QString::fromLatin1(qVersion()); \
if ((sq.section(QChar::fromLatin1('.'), 0, 0).toInt() << 16) + \
(sq.section(QChar::fromLatin1('.'), 1, 1).toInt() << 8) + \
sq.section(QChar::fromLatin1('.'), 2, 2).toInt() < \
(s.section(QChar::fromLatin1('.'), 0, 0).toInt() << 16) + \
(s.section(QChar::fromLatin1('.'), 1, 1).toInt() << 8) + \
s.section(QChar::fromLatin1('.'), 2, 2).toInt()) \
{ \
if (!qApp) \
{ \
new QApplication(argc, argv); \
} \
QString s = QApplication::tr("Executable '%1' requires Qt %2, found Qt %3.") \
.arg(qAppName()) \
.arg(QString::fromLatin1(str)) \
.arg(QString::fromLatin1(qVersion())); \
QMessageBox::critical(0, QApplication::tr("Incompatible Qt Library Error"), s, QMessageBox::Abort, \
static_cast<QMessageBox::StandardButton>(0)); \
qFatal("%s", s.toLatin1().data()); \
} \
}
#endif
//---------------------------------------------------------------------------------------------------------------------
auto main(int argc, char *argv[]) -> int

View File

@ -5652,18 +5652,25 @@ auto MainWindow::MaybeSave() -> bool
{
if (this->isWindowModified() && m_guiEnabled)
{
QScopedPointer<QMessageBox> messageBox(new QMessageBox(
tr("Unsaved changes"), tr("The pattern has been modified. Do you want to save your changes?"),
QMessageBox::Warning, QMessageBox::Yes, QMessageBox::No, QMessageBox::Cancel, this, Qt::Sheet));
QScopedPointer<QMessageBox> messageBox(
new QMessageBox(QMessageBox::Warning, tr("Unsaved changes"),
tr("The pattern has been modified. Do you want to save your changes?"),
QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, this, Qt::Sheet));
messageBox->setDefaultButton(QMessageBox::Yes);
messageBox->setEscapeButton(QMessageBox::Cancel);
messageBox->setButtonText(QMessageBox::Yes,
VAbstractValApplication::VApp()->GetPatternPath().isEmpty() || m_patternReadOnly
? tr("Save…")
: tr("Save"));
messageBox->setButtonText(QMessageBox::No, tr("Don't Save"));
if (QAbstractButton *button = messageBox->button(QMessageBox::Yes))
{
button->setText(VAbstractValApplication::VApp()->GetPatternPath().isEmpty() || m_patternReadOnly
? tr("Save…")
: tr("Save"));
}
if (QAbstractButton *button = messageBox->button(QMessageBox::No))
{
button->setText(tr("Don't Save"));
}
messageBox->setWindowModality(Qt::ApplicationModal);
const auto ret = static_cast<QMessageBox::StandardButton>(messageBox->exec());

View File

@ -496,15 +496,23 @@ auto WatermarkWindow::MaybeSave() -> bool
{
if (this->isWindowModified())
{
QScopedPointer<QMessageBox> messageBox(new QMessageBox(
tr("Unsaved changes"), tr("The watermark has been modified. Do you want to save your changes?"),
QMessageBox::Warning, QMessageBox::Yes, QMessageBox::No, QMessageBox::Cancel, this, Qt::Sheet));
QScopedPointer<QMessageBox> messageBox(
new QMessageBox(QMessageBox::Warning, tr("Unsaved changes"),
tr("The watermark has been modified. Do you want to save your changes?"),
QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, this, Qt::Sheet));
messageBox->setDefaultButton(QMessageBox::Yes);
messageBox->setEscapeButton(QMessageBox::Cancel);
messageBox->setButtonText(QMessageBox::Yes, m_curFile.isEmpty() ? tr("Save") : tr("Save as"));
messageBox->setButtonText(QMessageBox::No, tr("Don't Save"));
if (QAbstractButton *button = messageBox->button(QMessageBox::Yes))
{
button->setText(m_curFile.isEmpty() ? tr("Save") : tr("Save as"));
}
if (QAbstractButton *button = messageBox->button(QMessageBox::No))
{
button->setText(tr("Don't Save"));
}
messageBox->setWindowModality(Qt::ApplicationModal);
const auto ret = static_cast<QMessageBox::StandardButton>(messageBox->exec());

View File

@ -31,6 +31,7 @@
#include <QFontMetrics>
#include <QLibraryInfo>
#include <QLineF>
#include <QListWidgetItem>
#include <QSet>
#include <QStringList>
#include <QVector>
@ -437,4 +438,41 @@ inline auto FontFromString(const QString &descrip) -> QFont
return font;
}
//---------------------------------------------------------------------------------------------------------------------
template <typename T> inline auto TerritoryToString(const T &territory) -> QString
{
using namespace Qt::Literals::StringLiterals;
// Since Qt 5.12 country names have spaces
#if QT_VERSION < QT_VERSION_CHECK(6, 2, 0)
return QLocale::countryToString(territory).remove(' '_L1);
#else
return QLocale::territoryToString(territory).remove(' '_L1);
#endif
}
//---------------------------------------------------------------------------------------------------------------------
// NOLINTNEXTLINE(readability-inconsistent-declaration-parameter-name)
template <> inline auto TerritoryToString<QLocale>(const QLocale &loc) -> QString
{
using namespace Qt::Literals::StringLiterals;
// Since Qt 5.12 country names have spaces
#if QT_VERSION < QT_VERSION_CHECK(6, 2, 0)
return QLocale::countryToString(loc.country()).remove(' '_L1);
#else
return QLocale::territoryToString(loc.territory()).remove(' '_L1);
#endif
}
//---------------------------------------------------------------------------------------------------------------------
template <typename T> inline void SetTextAlignment(T *item, Qt::Alignment alignment)
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 4, 0)
item->setTextAlignment(alignment);
#else
item->setTextAlignment(static_cast<int>(alignment));
#endif
}
#endif // COMPATIBILITY_H

View File

@ -59,11 +59,8 @@
#include "vdatastreamenum.h"
#endif
#include "../ifc/exception/vexception.h"
#include "literals.h"
#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0)
#include "compatibility.h"
#endif
#include "literals.h"
using namespace Qt::Literals::StringLiterals;
@ -118,8 +115,7 @@ void InitLanguageList(QComboBox *combobox)
QLocale loc = QLocale(locale);
QString lang = loc.nativeLanguageName();
// Since Qt 5.12 country names have spaces
QString country = QLocale::countryToString(loc.country()).remove(' ');
QString country = TerritoryToString(loc);
if (country == "Czechia"_L1)
{
country = "CzechRepublic"_L1;
@ -133,7 +129,9 @@ void InitLanguageList(QComboBox *combobox)
{
// English language is internal and doens't have own *.qm file.
// Since Qt 5.12 country names have spaces
QIcon ico(u"://flags/%1.png"_s.arg(QLocale::countryToString(QLocale::UnitedStates).remove(' ')));
QIcon ico(u"://flags/%1.png"_s.arg(TerritoryToString(QLocale::UnitedStates))
);
QString lang = QLocale(en_US).nativeLanguageName();
combobox->addItem(ico, lang, en_US);
}

View File

@ -28,6 +28,7 @@
#include <QSize>
#include <QSizePolicy>
#include <QSpacerItem>
#include <QStyle>
#include <QVBoxLayout>
#include <QVariant>
@ -166,8 +167,10 @@ auto CheckableMessageBox::iconPixmap() const -> QPixmap
return QPixmap(*p);
}
return QPixmap();
#else
#elif QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
return d->pixmapLabel->pixmap(Qt::ReturnByValue);
#else
return d->pixmapLabel->pixmap();
#endif
}
@ -260,7 +263,7 @@ auto CheckableMessageBox::question(QWidget *parent, const QString &title, const
{
CheckableMessageBox mb(parent);
mb.setWindowTitle(title);
mb.setIconPixmap(QMessageBox::standardIcon(QMessageBox::Question));
mb.setIconPixmap(QApplication::style()->standardIcon(QStyle::SP_MessageBoxQuestion).pixmap(32, 32));
mb.setText(question);
mb.setCheckBoxText(checkBoxText);
mb.setChecked(*checkBoxSetting);
@ -279,7 +282,7 @@ auto CheckableMessageBox::information(QWidget *parent, const QString &title, con
{
CheckableMessageBox mb(parent);
mb.setWindowTitle(title);
mb.setIconPixmap(QMessageBox::standardIcon(QMessageBox::Information));
mb.setIconPixmap(QApplication::style()->standardIcon(QStyle::SP_MessageBoxInformation).pixmap(32, 32));
mb.setText(text);
mb.setCheckBoxText(checkBoxText);
mb.setChecked(*checkBoxSetting);
@ -320,7 +323,9 @@ void CheckableMessageBox::initDoNotAskAgainMessageBox(CheckableMessageBox &messa
{
messageBox.setWindowTitle(title);
messageBox.setIconPixmap(
QMessageBox::standardIcon(type == Information ? QMessageBox::Information : QMessageBox::Question));
QApplication::style()
->standardIcon(type == Information ? QStyle::SP_MessageBoxInformation : QStyle::SP_MessageBoxQuestion)
.pixmap(32, 32));
messageBox.setText(text);
messageBox.setCheckBoxVisible(true);
messageBox.setCheckBoxText(type == Information ? CheckableMessageBox::msgDoNotShowAgain()

View File

@ -471,8 +471,7 @@ auto AbstractTest::CopyRecursively(const QString &srcFilePath, const QString &tg
const QString dirName = QFileInfo(tgtFilePath).fileName();
if (not targetDir.mkdir(dirName))
{
const QString msg = QStringLiteral("Can't create dir '%1'.").arg(dirName);
QWARN(qUtf8Printable(msg));
qWarning("Can't create dir '%s'.", qUtf8Printable(dirName));
return false;
}
QDir sourceDir(srcFilePath);
@ -492,16 +491,15 @@ auto AbstractTest::CopyRecursively(const QString &srcFilePath, const QString &tg
{
if (QFileInfo::exists(tgtFilePath))
{
const QString msg = QStringLiteral("File '%1' exists.").arg(srcFilePath);
QWARN(qUtf8Printable(msg));
qWarning("File '%s' exists.", qUtf8Printable(srcFilePath));
if (QFile::remove(tgtFilePath))
{
QWARN("File successfully removed.");
qWarning("File successfully removed.");
}
else
{
QWARN("Can't remove file.");
qWarning("Can't remove file.");
return false;
}
}
@ -510,18 +508,16 @@ auto AbstractTest::CopyRecursively(const QString &srcFilePath, const QString &tg
QFile srcFile(srcFilePath);
if (not srcFile.open(QFile::ReadOnly))
{
const QString msg =
QStringLiteral("Can't copy file '%1'. Error: %2").arg(srcFilePath, srcFile.errorString());
QWARN(qUtf8Printable(msg));
qWarning("Can't copy file '%s'. Error: %s", qUtf8Printable(srcFilePath),
qUtf8Printable(srcFile.errorString()));
return false;
}
srcFile.close();
if (not srcFile.copy(tgtFilePath))
{
const QString msg = QStringLiteral("Can't copy file '%1' to '%2'. Error: %3")
.arg(srcFilePath, tgtFilePath, srcFile.errorString());
QWARN(qUtf8Printable(msg));
qWarning("Can't copy file '%s' to '%s'. Error: %s", qUtf8Printable(srcFilePath),
qUtf8Printable(tgtFilePath), qUtf8Printable(srcFile.errorString()));
return false;
}
}

View File

@ -39,6 +39,7 @@
#include "../ifc/xml/vlabeltemplateconverter.h"
#include "../tools/dialogtool.h"
#include "../vformat/vlabeltemplate.h"
#include "../vmisc/compatibility.h"
#include "../vpatterndb/calculator.h"
#include "../vpatterndb/floatItemData/vpiecelabeldata.h"
#include "../vpatterndb/variables/vmeasurement.h"
@ -52,10 +53,6 @@
#include <QMenu>
#include <QMessageBox>
#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0)
#include "../vmisc/compatibility.h"
#endif
using namespace Qt::Literals::StringLiterals;
//---------------------------------------------------------------------------------------------------------------------
@ -773,7 +770,7 @@ void DialogEditLabel::SetTemplate(const QVector<VLabelTemplateLine> &lines)
for (const auto &line : lines)
{
auto *item = new QListWidgetItem(line.line);
item->setTextAlignment(line.alignment);
SetTextAlignment(item, static_cast<Qt::Alignment>(line.alignment));
item->setData(Qt::UserRole, line.fontSizeIncrement);
QFont font = item->font();
@ -855,7 +852,7 @@ void DialogEditLabel::InitPreviewLines(const QVector<VLabelTemplateLine> &lines)
for (const auto &line : lines)
{
auto *item = new QListWidgetItem(ReplacePlaceholders(line.line));
item->setTextAlignment(line.alignment);
SetTextAlignment(item, static_cast<Qt::Alignment>(line.alignment));
item->setData(Qt::UserRole, line.fontSizeIncrement);
QFont font = item->font();

View File

@ -130,6 +130,6 @@ void TST_TapeCommandLine::cleanupTestCase()
QDir tmpDir(*tmpTestFolder);
if (not tmpDir.removeRecursively())
{
QWARN("Fail to remove temp directory.");
qWarning("Fail to remove temp directory.");
}
}

View File

@ -273,7 +273,7 @@ void TST_ValentinaCommandLine::cleanupTestCase()
QDir tmpDir(*tmpTestFolder);
if (not tmpDir.removeRecursively())
{
QWARN("Fail to remove test temp directory.");
qWarning("Fail to remove test temp directory.");
}
}
@ -281,7 +281,7 @@ void TST_ValentinaCommandLine::cleanupTestCase()
QDir tmpDir(*tmpTestCollectionFolder);
if (not tmpDir.removeRecursively())
{
QWARN("Fail to remove collection temp directory.");
qWarning("Fail to remove collection temp directory.");
}
}
}

View File

@ -72,10 +72,8 @@ auto TST_AbstractRegExp::LoadVariables(const QString &checkedLocale) -> int
if (QFileInfo(path + '/'_L1 + file).size() <= 34)
{
const QString message =
u"Translation variables for locale = %1 is empty. \nFull path: %2/%3"_s.arg(checkedLocale, path, file);
QWARN(qUtf8Printable(message));
qWarning("Translation variables for locale = %s is empty. \nFull path: %s/%s", qUtf8Printable(checkedLocale),
qUtf8Printable(path), qUtf8Printable(file));
return ErrorSize;
}
@ -83,23 +81,17 @@ auto TST_AbstractRegExp::LoadVariables(const QString &checkedLocale) -> int
if (not m_vTranslator->load(file, path))
{
const QString message =
u"Can't load translation variables for locale = %1. \nFull path: %2/%3"_s.arg(checkedLocale, path, file);
QWARN(qUtf8Printable(message));
qWarning("Can't load translation variables for locale = %s. \nFull path: %s/%s", qUtf8Printable(checkedLocale),
qUtf8Printable(path), qUtf8Printable(file));
delete m_vTranslator;
return ErrorLoad;
}
if (not QCoreApplication::installTranslator(m_vTranslator))
{
const QString message =
u"Can't install translation variables for locale = %1. \nFull path: %2/%3"_s.arg(checkedLocale, path, file);
QWARN(qUtf8Printable(message));
qWarning("Can't install translation variables for locale = %s. \nFull path: %s/%s",
qUtf8Printable(checkedLocale), qUtf8Printable(path), qUtf8Printable(file));
delete m_vTranslator;
return ErrorInstall;
}
@ -115,8 +107,7 @@ void TST_AbstractRegExp::RemoveTrVariables(const QString &checkedLocale)
if (result == false)
{
const QString message = u"Can't remove translation variables for locale = %1"_s.arg(checkedLocale);
QWARN(qUtf8Printable(message));
qWarning("Can't remove translation variables for locale = %s", qUtf8Printable(checkedLocale));
}
delete m_vTranslator;
}

View File

@ -60,15 +60,13 @@ auto TST_AbstractTranslation::LoadTSFile(const QString &filename) -> QDomNodeLis
tsFile = QSharedPointer<QFile>(new QFile(u"%1/%2"_s.arg(TS_DIR, filename)));
if (not tsFile->exists())
{
const QString message = u"Can't find '%1'.\n%2."_s.arg(filename, tsFile->errorString());
QWARN(qUtf8Printable(message));
qWarning("Can't find '%s'.\n%s.", qUtf8Printable(filename), qUtf8Printable(tsFile->errorString()));
return QDomNodeList();
}
if (tsFile->open(QIODevice::ReadOnly) == false)
{
const QString message = u"Can't open file '%1'.\n%2."_s.arg(filename, tsFile->errorString());
QWARN(qUtf8Printable(message));
qWarning("Can't open file '%s'.\n%s.", qUtf8Printable(filename), qUtf8Printable(tsFile->errorString()));
return QDomNodeList();
}
@ -79,16 +77,14 @@ auto TST_AbstractTranslation::LoadTSFile(const QString &filename) -> QDomNodeLis
tsXML = QSharedPointer<QDomDocument>(new QDomDocument());
if (tsXML->setContent(tsFile.data(), &errorMsg, &errorLine, &errorColumn) == false)
{
const QString message =
u"Parsing error file %1 in line %2 column %3."_s.arg(filename).arg(errorLine).arg(errorColumn);
QWARN(qUtf8Printable(message));
qWarning("Parsing error file %s in line %d column %d.", qUtf8Printable(filename), errorLine, errorColumn);
return QDomNodeList();
}
const QDomNodeList messages = tsXML->elementsByTagName(TagMessage);
if (messages.isEmpty())
{
QWARN("File doesn't contain any messages.");
qWarning("File doesn't contain any messages.");
return QDomNodeList();
}

View File

@ -240,19 +240,17 @@ auto TST_MeasurementRegExp::LoadMeasurements(const QString &checkedSystem, const
if (not info.exists())
{
const QString message =
u"File for translation for system = %1 and locale = %2 doesn't exists. \nFull path: %3/%4"_s.arg(
checkedSystem, checkedLocale, path, file);
QWARN(qUtf8Printable(message));
qWarning("File for translation for system = %s and locale = %s doesn't exists. \nFull path: %s/%s",
qUtf8Printable(checkedSystem), qUtf8Printable(checkedLocale), qUtf8Printable(path),
qUtf8Printable(file));
return ErrorMissing;
}
if (QFileInfo(path + '/'_L1 + file).size() <= 34)
{
const QString message = u"Translation for system = %1 and locale = %2 is empty. \nFull path: %3/%4"_s.arg(
checkedSystem, checkedLocale, path, file);
QWARN(qUtf8Printable(message));
qWarning("Translation for system = %s and locale = %s is empty. \nFull path: %s/%s",
qUtf8Printable(checkedSystem), qUtf8Printable(checkedLocale), qUtf8Printable(path),
qUtf8Printable(file));
return ErrorSize;
}
@ -262,9 +260,9 @@ auto TST_MeasurementRegExp::LoadMeasurements(const QString &checkedSystem, const
if (not m_pmsTranslator->load(file, path))
{
const QString message = u"Can't load translation for system = %1 and locale = %2. \nFull path: %3/%4"_s.arg(
checkedSystem, checkedLocale, path, file);
QWARN(qUtf8Printable(message));
qWarning("Can't load translation for system = %s and locale = %s. \nFull path: %s/%s",
qUtf8Printable(checkedSystem), qUtf8Printable(checkedLocale), qUtf8Printable(path),
qUtf8Printable(file));
delete m_pmsTranslator;
@ -273,9 +271,9 @@ auto TST_MeasurementRegExp::LoadMeasurements(const QString &checkedSystem, const
if (not QCoreApplication::installTranslator(m_pmsTranslator))
{
const QString message = u"Can't install translation for system = %1 and locale = %2. \nFull path: %3/%4"_s.arg(
checkedSystem, checkedLocale, path, file);
QWARN(qUtf8Printable(message));
qWarning("Can't install translation for system = %s and locale = %s. \nFull path: %s/%s",
qUtf8Printable(checkedSystem), qUtf8Printable(checkedLocale), qUtf8Printable(path),
qUtf8Printable(file));
delete m_pmsTranslator;
@ -294,9 +292,8 @@ void TST_MeasurementRegExp::RemoveTrMeasurements(const QString &checkedSystem, c
if (result == false)
{
const QString message =
u"Can't remove translation for system = %1 and locale = %2"_s.arg(checkedSystem, checkedLocale);
QWARN(qUtf8Printable(message));
qWarning("Can't remove translation for system = %s and locale = %s", qUtf8Printable(checkedSystem),
qUtf8Printable(checkedLocale));
}
delete m_pmsTranslator;
}

View File

@ -160,10 +160,8 @@ auto TST_QmuParserErrorMsg::LoadTranslation(const QString &checkedLocale) -> int
if (QFileInfo(path + '/'_L1 + file).size() <= 34)
{
const QString message =
u"Translation for locale = %1 is empty. \nFull path: %2/%3"_s.arg(checkedLocale, path, file);
QWARN(qUtf8Printable(message));
qWarning("Translation for locale = %s is empty. \nFull path: %s/%s", qUtf8Printable(checkedLocale),
qUtf8Printable(path), qUtf8Printable(file));
return ErrorSize;
}
@ -171,23 +169,17 @@ auto TST_QmuParserErrorMsg::LoadTranslation(const QString &checkedLocale) -> int
if (not appTranslator->load(file, path))
{
const QString message =
u"Can't load translation for locale = %1. \nFull path: %2/%3"_s.arg(checkedLocale, path, file);
QWARN(qUtf8Printable(message));
qWarning("Can't load translation for locale = %s. \nFull path: %s/%s", qUtf8Printable(checkedLocale),
qUtf8Printable(path), qUtf8Printable(file));
delete appTranslator;
return ErrorLoad;
}
if (not QCoreApplication::installTranslator(appTranslator))
{
const QString message =
u"Can't install translation for locale = %1. \nFull path: %2/%3"_s.arg(checkedLocale, path, file);
QWARN(qUtf8Printable(message));
qWarning("Can't install translation for locale = %s. \nFull path: %s/%s", qUtf8Printable(checkedLocale),
qUtf8Printable(path), qUtf8Printable(file));
delete appTranslator;
return ErrorInstall;
}
@ -206,8 +198,7 @@ void TST_QmuParserErrorMsg::RemoveTranslation()
if (result == false)
{
const QString message = u"Can't remove translation for locale = %1"_s.arg(m_locale);
QWARN(qUtf8Printable(message));
qWarning("Can't remove translation for locale = %s", qUtf8Printable(m_locale));
}
delete appTranslator;
}

View File

@ -34,7 +34,7 @@
//---------------------------------------------------------------------------------------------------------------------
TST_VSpline::TST_VSpline(QObject *parent)
:AbstractTest(parent)
: AbstractTest(parent)
{
}
@ -386,8 +386,8 @@ void TST_VSpline::GetSegmentPoints_NullSegment()
VSpline spl(p1, p2, p3, p4, 1);
spl.SetApproximationScale(10);
const QPointF begin (146.3718263928647, 6.419281580065625);
const QPointF end (146.3718263928647, 6.419281580065625);
const QPointF begin(146.3718263928647, 6.419281580065625);
const QPointF end(146.3718263928647, 6.419281580065625);
QVector<QPointF> points;
points << spl.GetSegmentPoints(begin, end, true);
@ -543,7 +543,7 @@ void TST_VSpline::GetSegmentPoints_RotateTool()
spl.SetApproximationScale(10);
const QPointF begin(237.32422843061005, 485.80074940371367);
const QPointF end (46.623829088412336, 167.78988631718659);
const QPointF end(46.623829088412336, 167.78988631718659);
QVector<QPointF> points;
points << spl.GetSegmentPoints(begin, end, true);
@ -638,7 +638,7 @@ void TST_VSpline::GetSegmentPoints_issue767()
// Test issue with method IsPointOnLineSegment.
const QPointF begin(3964.650771379471, 3212.2173150777817);
const QPointF end (4200.023629188538, 2559.9039118110236);
const QPointF end(4200.023629188538, 2559.9039118110236);
QVector<QPointF> points;
points.append(QPointF(3964.650771379471, 3212.2173150777817));
@ -704,17 +704,17 @@ void TST_VSpline::CompareThreeWays()
VSpline spl2(spl1.GetP1(), static_cast<QPointF>(spl1.GetP2()), static_cast<QPointF>(spl1.GetP3()), spl1.GetP4(), 1);
spl2.SetApproximationScale(10);
VSpline spl3(spl1.GetP1(), spl1.GetP4(), spl1.GetStartAngle(), QString(), spl2.GetEndAngle(), QString(), spl2.GetC1Length(), QString(),
spl2.GetC2Length(), QString(), 1);
VSpline spl3(spl1.GetP1(), spl1.GetP4(), spl1.GetStartAngle(), QString(), spl2.GetEndAngle(), QString(),
spl2.GetC1Length(), QString(), spl2.GetC2Length(), QString(), 1);
spl3.SetApproximationScale(10);
QWARN("Comparing first and second splines.");
qWarning("Comparing first and second splines.");
CompareSplines(spl1, spl2);
QWARN("Comparing second and third splines.");
qWarning("Comparing second and third splines.");
CompareSplines(spl2, spl3);
QWARN("Comparing third and first splines.");
qWarning("Comparing third and first splines.");
CompareSplines(spl3, spl1);
}
@ -737,8 +737,7 @@ void TST_VSpline::TestParametrT_data()
{
QTest::newRow(qUtf8Printable(QStringLiteral("Curve 1. Step = %1").arg(step))) << spl << base * step;
step += 0.001;
}
while(step <= 1);
} while (step <= 1);
p1 = VPointF(3476.6410658375944, 334.08136371135333, QStringLiteral("p1"), -141.34148031496062, 109.00951181102363);
p4 = VPointF(3483.5141183177025, 333.72231804361377, QStringLiteral("p4"), 48, 102.99930708661418);
@ -753,8 +752,7 @@ void TST_VSpline::TestParametrT_data()
{
QTest::newRow(qUtf8Printable(QStringLiteral("Curve 2. Step = %1").arg(step))) << spl << base * step;
step += 0.001;
}
while(step <= 1);
} while (step <= 1);
QTest::newRow(qUtf8Printable(QStringLiteral("Curve 2. Bug.").arg(step))) << spl << 4.7813492845686536;
}
@ -783,7 +781,7 @@ void TST_VSpline::TestLengthByPoint_data()
QTest::addColumn<qreal>("length");
const qreal length = spl.GetLength();
const qreal testLength = length*(2.0/3.0);
const qreal testLength = length * (2.0 / 3.0);
VSpline spl1, spl2;
const QPointF p = spl.CutSpline(testLength, spl1, spl2, QString());
@ -857,33 +855,33 @@ void TST_VSpline::TestCutSpline_data()
QTest::addColumn<QString>("name");
{
VPointF p1(187.31716535433043, 51.31464566929152, QStringLiteral("p1"), 140.42872440944885, -22.62372283464567);
VPointF p4(-991.8954330708666, 9.739842519685212, QStringLiteral("p4"), 9.999987401574804, 15.0);
VPointF p1(187.31716535433043, 51.31464566929152, QStringLiteral("p1"), 140.42872440944885, -22.62372283464567);
VPointF p4(-991.8954330708666, 9.739842519685212, QStringLiteral("p4"), 9.999987401574804, 15.0);
VSpline spl(p1, p4, 181.0, QStringLiteral("181"), 356.0, QStringLiteral("356"), 548.7874015748031,
QStringLiteral("Line_Г3_Г6*1.1"), 226.7716535433071, QStringLiteral("6"));
spl.SetApproximationScale(0.5);
VSpline spl(p1, p4, 181.0, QStringLiteral("181"), 356.0, QStringLiteral("356"), 548.7874015748031,
QStringLiteral("Line_Г3_Г6*1.1"), 226.7716535433071, QStringLiteral("6"));
spl.SetApproximationScale(0.5);
QString name(QStringLiteral("з"));
qreal result = 1.35; // Correct distance in cm.
QString name(QStringLiteral("з"));
qreal result = 1.35; // Correct distance in cm.
// See file valentina_private_collection/bugs/men_jacket/issue_cut_spline.val (private collection)
// Size 54 produces incorrect spline segment distance
QTest::newRow("Size 54") << spl << result << name;
// See file valentina_private_collection/bugs/men_jacket/issue_cut_spline.val (private collection)
// Size 54 produces incorrect spline segment distance
QTest::newRow("Size 54") << spl << result << name;
}
{
VPointF p1(1898.0384322000489, -143.17624447113994, QStringLiteral("p1"), 9.999987401574804, -105.35848818897638);
VPointF p4(1557.8809518850883, -143.17624447113994, QStringLiteral("p4"), 9.999987401574804, 15.0);
VPointF p1(1898.0384322000489, -143.17624447113994, QStringLiteral("p1"), 9.999987401574804,
-105.35848818897638);
VPointF p4(1557.8809518850883, -143.17624447113994, QStringLiteral("p4"), 9.999987401574804, 15.0);
VSpline spl(p1, p4, 175.0, QStringLiteral("175"), 5.0, QStringLiteral("5"), 151.18110236220474,
QStringLiteral("4"), 151.18110236220474, QStringLiteral("4"));
VSpline spl(p1, p4, 175.0, QStringLiteral("175"), 5.0, QStringLiteral("5"), 151.18110236220474,
QStringLiteral("4"), 151.18110236220474, QStringLiteral("4"));
QString name(QStringLiteral("А193"));
const qreal result = 4.5090698038574057; // Correct distance in cm.
// See file valentina_private_collection/bugs/coat/coat.val (private collection)
QTest::newRow("Half of a curve") << spl << result << name;
QString name(QStringLiteral("А193"));
const qreal result = 4.5090698038574057; // Correct distance in cm.
// See file valentina_private_collection/bugs/coat/coat.val (private collection)
QTest::newRow("Half of a curve") << spl << result << name;
}
}