Skip to content
Snippets Groups Projects
Commit 313d6c46 authored by Pospelov, Gennady's avatar Pospelov, Gennady
Browse files

Fixed few Qt deprecation warnings related to QColor and QFontMetric

parent 011a6a96
No related branches found
No related tags found
No related merge requests found
......@@ -51,7 +51,11 @@ QCPRange qcpRange(double xmin, double xmax, int nbins) {
QMargins defaultMargins(const QWidget& widget)
{
QFontMetrics fontMetric(widget.font());
#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
auto em = fontMetric.horizontalAdvance('M'), fontAscent = fontMetric.ascent();
#else
auto em = fontMetric.width('M'), fontAscent = fontMetric.ascent();
#endif
int left = static_cast<int>(6.0 * em);
int top = static_cast<int>(fontAscent * 1.5);
int right = static_cast<int>(em * 1.2);
......
......@@ -169,11 +169,18 @@ ExternalProperty MaterialItemUtils::selectColorProperty(const ExternalProperty&
{
ExternalProperty result;
#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
auto oldColor = previous.color();
auto newColor = QColorDialog::getColor(oldColor);
if (oldColor != newColor)
result = MaterialItemUtils::colorProperty(newColor);
#else
bool ok = false;
QRgb oldRgba = previous.color().rgba();
QRgb newRgba = QColorDialog::getRgba(oldRgba, &ok, nullptr);
if (ok && newRgba != oldRgba)
result = MaterialItemUtils::colorProperty(QColor::fromRgba(newRgba));
#endif
return result;
}
......
......@@ -80,9 +80,16 @@ SampleToolBar::SampleToolBar(SampleViewActions* sampleActions,
QStringList scales = QStringList() << "25%" << "50%" << "75%" << "100%" << "125%" << "150%";
m_scaleCombo->addItems(scales);
m_scaleCombo->setCurrentIndex(3);
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
connect(m_scaleCombo,
static_cast<void(QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged),
this, &SampleToolBar::onScaleComboChanged);
#else
connect(m_scaleCombo,
static_cast<void(QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &SampleToolBar::onScaleComboChanged);
#endif
addWidget(m_scaleCombo);
// MaterialEditor
......
......@@ -395,7 +395,11 @@ QString ProjectManager::untitledProjectName()
if (projectDir.exists()) {
for (size_t i = 1; i < 99; ++i) {
result = QString("Untitled") + QString::number(i);
#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
projectDir.setPath(workingDirectory() + "/" + result);
#else
projectDir = workingDirectory() + "/" + result;
#endif
if (!projectDir.exists())
break;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment