mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-20 04:53:51 +00:00
Fix most of deprecated API usage in the editor
This commit is contained in:
parent
cca69f54e7
commit
e44021b369
6 changed files with 56 additions and 1 deletions
|
@ -6,6 +6,10 @@
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
|
||||||
|
#include <QScreen>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "filewidget.hpp"
|
#include "filewidget.hpp"
|
||||||
#include "adjusterwidget.hpp"
|
#include "adjusterwidget.hpp"
|
||||||
|
|
||||||
|
@ -46,7 +50,11 @@ CSVDoc::NewGameDialogue::NewGameDialogue()
|
||||||
connect (mFileWidget, SIGNAL (nameChanged (const QString&, bool)),
|
connect (mFileWidget, SIGNAL (nameChanged (const QString&, bool)),
|
||||||
mAdjusterWidget, SLOT (setName (const QString&, bool)));
|
mAdjusterWidget, SLOT (setName (const QString&, bool)));
|
||||||
|
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
|
||||||
|
QRect scr = QGuiApplication::primaryScreen()->geometry();
|
||||||
|
#else
|
||||||
QRect scr = QApplication::desktop()->screenGeometry();
|
QRect scr = QApplication::desktop()->screenGeometry();
|
||||||
|
#endif
|
||||||
QRect rect = geometry();
|
QRect rect = geometry();
|
||||||
move (scr.center().x() - rect.center().x(), scr.center().y() - rect.center().y());
|
move (scr.center().x() - rect.center().x(), scr.center().y() - rect.center().y());
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,10 @@
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
|
||||||
|
#include <QScreen>
|
||||||
|
#endif
|
||||||
|
|
||||||
QPushButton *CSVDoc::StartupDialogue::addButton (const QString& label, const QIcon& icon)
|
QPushButton *CSVDoc::StartupDialogue::addButton (const QString& label, const QIcon& icon)
|
||||||
{
|
{
|
||||||
int column = mColumn--;
|
int column = mColumn--;
|
||||||
|
@ -119,7 +123,12 @@ CSVDoc::StartupDialogue::StartupDialogue() : mWidth (0), mColumn (2)
|
||||||
|
|
||||||
setLayout (layout);
|
setLayout (layout);
|
||||||
|
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
|
||||||
|
QRect scr = QGuiApplication::primaryScreen()->geometry();
|
||||||
|
#else
|
||||||
QRect scr = QApplication::desktop()->screenGeometry();
|
QRect scr = QApplication::desktop()->screenGeometry();
|
||||||
|
#endif
|
||||||
|
|
||||||
QRect rect = geometry();
|
QRect rect = geometry();
|
||||||
move (scr.center().x() - rect.center().x(), scr.center().y() - rect.center().y());
|
move (scr.center().x() - rect.center().x(), scr.center().y() - rect.center().y());
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,10 @@
|
||||||
#include <QStackedWidget>
|
#include <QStackedWidget>
|
||||||
#include <QListWidgetItem>
|
#include <QListWidgetItem>
|
||||||
|
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
|
||||||
|
#include <QScreen>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <components/debug/debuglog.hpp>
|
#include <components/debug/debuglog.hpp>
|
||||||
|
|
||||||
#include "../../model/prefs/state.hpp"
|
#include "../../model/prefs/state.hpp"
|
||||||
|
@ -34,7 +38,12 @@ void CSVPrefs::Dialogue::buildCategorySelector (QSplitter *main)
|
||||||
++iter)
|
++iter)
|
||||||
{
|
{
|
||||||
QString label = QString::fromUtf8 (iter->second.getKey().c_str());
|
QString label = QString::fromUtf8 (iter->second.getKey().c_str());
|
||||||
|
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5,11,0)
|
||||||
|
maxWidth = std::max (maxWidth, metrics.horizontalAdvance (label));
|
||||||
|
#else
|
||||||
maxWidth = std::max (maxWidth, metrics.width (label));
|
maxWidth = std::max (maxWidth, metrics.width (label));
|
||||||
|
#endif
|
||||||
|
|
||||||
list->addItem (label);
|
list->addItem (label);
|
||||||
}
|
}
|
||||||
|
@ -107,8 +116,15 @@ void CSVPrefs::Dialogue::show()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
|
||||||
|
QRect scr = QGuiApplication::primaryScreen()->geometry();
|
||||||
|
#else
|
||||||
|
QRect scr = QApplication::desktop()->screenGeometry();
|
||||||
|
#endif
|
||||||
|
|
||||||
// otherwise place at the centre of the screen
|
// otherwise place at the centre of the screen
|
||||||
QPoint screenCenter = QApplication::desktop()->screenGeometry().center();
|
QPoint screenCenter = scr.center();
|
||||||
|
|
||||||
move (screenCenter - QPoint(frameGeometry().width()/2, frameGeometry().height()/2));
|
move (screenCenter - QPoint(frameGeometry().width()/2, frameGeometry().height()/2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,10 @@
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QShowEvent>
|
#include <QShowEvent>
|
||||||
|
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
|
||||||
|
#include <QScreen>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "colorpickerpopup.hpp"
|
#include "colorpickerpopup.hpp"
|
||||||
|
|
||||||
CSVWidget::ColorEditor::ColorEditor(const QColor &color, QWidget *parent, const bool popupOnStart)
|
CSVWidget::ColorEditor::ColorEditor(const QColor &color, QWidget *parent, const bool popupOnStart)
|
||||||
|
@ -95,7 +99,11 @@ QPoint CSVWidget::ColorEditor::calculatePopupPosition()
|
||||||
{
|
{
|
||||||
QRect editorGeometry = geometry();
|
QRect editorGeometry = geometry();
|
||||||
QRect popupGeometry = mColorPicker->geometry();
|
QRect popupGeometry = mColorPicker->geometry();
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
|
||||||
|
QRect screenGeometry = QGuiApplication::primaryScreen()->geometry();
|
||||||
|
#else
|
||||||
QRect screenGeometry = QApplication::desktop()->screenGeometry();
|
QRect screenGeometry = QApplication::desktop()->screenGeometry();
|
||||||
|
#endif
|
||||||
|
|
||||||
// Center the popup horizontally relative to the editor
|
// Center the popup horizontally relative to the editor
|
||||||
int localPopupX = (editorGeometry.width() - popupGeometry.width()) / 2;
|
int localPopupX = (editorGeometry.width() - popupGeometry.width()) / 2;
|
||||||
|
|
|
@ -134,7 +134,12 @@ QSize CSVWorld::EnumDelegate::sizeHint(const QStyleOptionViewItem &option, const
|
||||||
itemOption.state = option.state;
|
itemOption.state = option.state;
|
||||||
|
|
||||||
const QString &valueText = mValues.at(valueIndex).second;
|
const QString &valueText = mValues.at(valueIndex).second;
|
||||||
|
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5,11,0)
|
||||||
|
QSize valueSize = QSize(itemOption.fontMetrics.horizontalAdvance(valueText), itemOption.fontMetrics.height());
|
||||||
|
#else
|
||||||
QSize valueSize = QSize(itemOption.fontMetrics.width(valueText), itemOption.fontMetrics.height());
|
QSize valueSize = QSize(itemOption.fontMetrics.width(valueText), itemOption.fontMetrics.height());
|
||||||
|
#endif
|
||||||
|
|
||||||
itemOption.currentText = valueText;
|
itemOption.currentText = valueText;
|
||||||
return QApplication::style()->sizeFromContents(QStyle::CT_ComboBox, &itemOption, valueSize);
|
return QApplication::style()->sizeFromContents(QStyle::CT_ComboBox, &itemOption, valueSize);
|
||||||
|
|
|
@ -205,7 +205,12 @@ bool CSVWorld::ScriptEdit::stringNeedsQuote (const std::string& id) const
|
||||||
void CSVWorld::ScriptEdit::setTabWidth()
|
void CSVWorld::ScriptEdit::setTabWidth()
|
||||||
{
|
{
|
||||||
// Set tab width to specified number of characters using current font.
|
// Set tab width to specified number of characters using current font.
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5,11,0)
|
||||||
|
setTabStopDistance(mTabCharCount * fontMetrics().horizontalAdvance(' '));
|
||||||
|
#else
|
||||||
setTabStopWidth(mTabCharCount * fontMetrics().width(' '));
|
setTabStopWidth(mTabCharCount * fontMetrics().width(' '));
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::ScriptEdit::wrapLines(bool wrap)
|
void CSVWorld::ScriptEdit::wrapLines(bool wrap)
|
||||||
|
@ -285,7 +290,11 @@ int CSVWorld::ScriptEdit::lineNumberAreaWidth()
|
||||||
++digits;
|
++digits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5,11,0)
|
||||||
|
int space = 3 + fontMetrics().horizontalAdvance(QLatin1Char('9')) * digits;
|
||||||
|
#else
|
||||||
int space = 3 + fontMetrics().width(QLatin1Char('9')) * digits;
|
int space = 3 + fontMetrics().width(QLatin1Char('9')) * digits;
|
||||||
|
#endif
|
||||||
|
|
||||||
return space;
|
return space;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue