Skip to content

Commit

Permalink
Make Qt 5.15.0 the minimum requirement
Browse files Browse the repository at this point in the history
and remove all conditions checking for Qt versions
  • Loading branch information
Jojo-Schmitz authored and igorkorsukov committed Oct 9, 2020
1 parent 8da9191 commit 484f8dc
Show file tree
Hide file tree
Showing 53 changed files with 53 additions and 347 deletions.
6 changes: 1 addition & 5 deletions CMakeLists.txt
Expand Up @@ -80,11 +80,7 @@ endif (BUILD_WEBENGINE)

set(SCRIPT_INTERFACE TRUE)
# Look for Qt5
if (SCRIPT_INTERFACE)
SET(QT_MIN_VERSION "5.8.0")
else (SCRIPT_INTERFACE)
SET(QT_MIN_VERSION "5.7.0")
endif (SCRIPT_INTERFACE)
SET(QT_MIN_VERSION "5.15.0")
# Include modules
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/build" ${CMAKE_MODULE_PATH})
include (FindQt5)
Expand Down
5 changes: 0 additions & 5 deletions awl/pitchlabel.cpp
Expand Up @@ -57,13 +57,8 @@ QSize PitchLabel::sizeHint() const
QFontMetrics fm(font());
int fw = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
int h = fm.height() + fw * 2;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
// int w = 2 + fm.horizontalAdvance(QString("A#8")) + fw * 4;
int w = 2 + fm.horizontalAdvance(QString("-9999")) + fw * 4; // must display 14Bit controller values
#else
// int w = 2 + fm.width(QString("A#8")) + fw * 4;
int w = 2 + fm.width(QString("-9999")) + fw * 4; // must display 14Bit controller values
#endif
return QSize(w, h).expandedTo(QApplication::globalStrut());
}

Expand Down
8 changes: 0 additions & 8 deletions awl/poslabel.cpp
Expand Up @@ -68,19 +68,11 @@ QSize PosLabel::sizeHint() const
int fw = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
int h = fm.height() + fw * 2;
int w;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
if (_smpte) {
w = 2 + fm.horizontalAdvance('9') * 9 + fm.horizontalAdvance(':') * 3 + fw * 4;
} else {
w = 2 + fm.horizontalAdvance('9') * 9 + fm.horizontalAdvance('.') * 2 + fw * 4;
}
#else
if (_smpte) {
w = 2 + fm.width('9') * 9 + fm.width(':') * 3 + fw * 4;
} else {
w = 2 + fm.width('9') * 9 + fm.width('.') * 2 + fw * 4;
}
#endif
return QSize(w, h).expandedTo(QApplication::globalStrut());
}

Expand Down
4 changes: 0 additions & 4 deletions framework/ui/view/qmldialog.cpp
Expand Up @@ -63,11 +63,7 @@ void QmlDialog::componentComplete()

if (m_content) {
QQmlEngine* engine = nullptr;
#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0)
engine = framework::ioc()->resolve<framework::IUiEngine>("appshell")->qmlEngine();
#else
engine = m_content->engine();
#endif

m_view = new QQuickView(engine, nullptr);
m_view->setResizeMode(QQuickView::SizeRootObjectToView);
Expand Down
Expand Up @@ -27,11 +27,7 @@ void DoubleInputValidator::fixup(QString& string) const
string.append(zeros(m_decimal));
}

#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList strList = string.split(".", Qt::SkipEmptyParts);
#else
QStringList strList = string.split(".", QString::SkipEmptyParts);
#endif

QString intPart = strList.at(0);
QString floatPart = strList.at(1);
Expand Down
12 changes: 0 additions & 12 deletions libmscore/chordlist.cpp
Expand Up @@ -29,11 +29,7 @@ HChord::HChord(const QString& str)
{ "C", "Db", "D", "Eb", "E", "F", "Gb", "G", "Ab", "A", "Bb", "B" }
};
keys = 0;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList sl = str.split(" ", Qt::SkipEmptyParts);
#else
QStringList sl = str.split(" ", QString::SkipEmptyParts);
#endif
for (const QString& s : sl) {
for (int i = 0; i < 12; ++i) {
if (s == scaleNames[0][i] || s == scaleNames[1][i]) {
Expand Down Expand Up @@ -320,18 +316,10 @@ void HChord::add(const QList<HDegree>& degreeList)
static void readRenderList(QString val, QList<RenderAction>& renderList)
{
renderList.clear();
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList sl = val.split(" ", Qt::SkipEmptyParts);
#else
QStringList sl = val.split(" ", QString::SkipEmptyParts);
#endif
for (const QString& s : sl) {
if (s.startsWith("m:")) {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList ssl = s.split(":", Qt::SkipEmptyParts);
#else
QStringList ssl = s.split(":", QString::SkipEmptyParts);
#endif
if (ssl.size() == 3) {
// m:x:y
RenderAction a;
Expand Down
4 changes: 0 additions & 4 deletions libmscore/figuredbass.cpp
Expand Up @@ -1389,11 +1389,7 @@ void FiguredBass::endEdit(EditData& ed)
}

// split text into lines and create an item for each line
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList list = txt.split("\n", Qt::SkipEmptyParts);
#else
QStringList list = txt.split('\n', QString::SkipEmptyParts);
#endif
qDeleteAll(items);
items.clear();
QString normalizedText = QString();
Expand Down
4 changes: 0 additions & 4 deletions libmscore/harmony.cpp
Expand Up @@ -2103,11 +2103,7 @@ QString Harmony::generateScreenReaderInfo() const
aux = aux.replace("#", QObject::tr("")).replace("<", "");
QString extension = "";

#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
for (QString s : aux.split(">", Qt::SkipEmptyParts)) {
#else
for (QString s : aux.split(">", QString::SkipEmptyParts)) {
#endif
if (!s.contains("blues")) {
s.replace("b", QObject::tr(""));
}
Expand Down
4 changes: 0 additions & 4 deletions libmscore/lyrics.cpp
Expand Up @@ -402,11 +402,7 @@ void Lyrics::paste(EditData& ed)
#endif
QString txt = QApplication::clipboard()->text(mode);
QString regex = QString("[^\\S") + QChar(0xa0) + QChar(0x202F) + "]+";
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList sl = txt.split(QRegExp(regex), Qt::SkipEmptyParts);
#else
QStringList sl = txt.split(QRegExp(regex), QString::SkipEmptyParts);
#endif
if (sl.empty()) {
return;
}
Expand Down
14 changes: 0 additions & 14 deletions libmscore/mscore.cpp
Expand Up @@ -396,20 +396,6 @@ void MScore::init()
}
}

#endif
// Workaround for QTBUG-73241 (solved in Qt 5.12.2) in Windows 10, see https://musescore.org/en/node/280244
#if defined(Q_OS_WIN) && (QT_VERSION < QT_VERSION_CHECK(5, 12, 2))
if (QOperatingSystemVersion::current().majorVersion() >= 10) {
const QDir additionalFontsDir(QString("%1/Microsoft/Windows/Fonts").arg(QStandardPaths::writableLocation(QStandardPaths::
GenericDataLocation)));
if (additionalFontsDir.exists()) {
QFileInfoList fileList = additionalFontsDir.entryInfoList();
for (int i = 0; i < fileList.size(); ++i) {
QFileInfo fileInfo = fileList.at(i);
QFontDatabase::addApplicationFont(fileInfo.filePath());
}
}
}
#endif
initScoreFonts();
StaffType::initStaffTypes();
Expand Down
13 changes: 3 additions & 10 deletions libmscore/page.cpp
Expand Up @@ -356,17 +356,10 @@ QString Page::replaceTextMacros(const QString& s) const
case 'D':
{
QString creationDate = score()->metaTag("creationDate");
if (creationDate.isNull())
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
{ // ToDo for Qt 5.15: Qt::DefaultLocaleShortDate vs. QLocale ??
if (creationDate.isNull()) {
// ToDo for Qt 5.15: Qt::DefaultLocaleShortDate vs. QLocale ??
d += masterScore()->fileInfo()->birthTime().date().toString(Qt::DefaultLocaleShortDate);
}
#else
{
d += masterScore()->fileInfo()->created().date().toString(Qt::DefaultLocaleShortDate);
}
#endif
else {
} else {
// ToDo for Qt 5.15: Qt::DefaultLocaleShortDate vs. QLocale ??
d += QDate::fromString(creationDate, Qt::ISODate).toString(Qt::DefaultLocaleShortDate);
}
Expand Down
4 changes: 0 additions & 4 deletions libmscore/read114.cpp
Expand Up @@ -1303,11 +1303,7 @@ static void readVolta114(XmlReader& e, Volta* volta)
const QStringRef& tag(e.name());
if (tag == "endings") {
QString s = e.readElementText();
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList sl = s.split(",", Qt::SkipEmptyParts);
#else
QStringList sl = s.split(",", QString::SkipEmptyParts);
#endif
volta->endings().clear();
for (const QString& l : sl) {
int i = l.simplified().toInt();
Expand Down
4 changes: 0 additions & 4 deletions libmscore/read206.cpp
Expand Up @@ -2435,11 +2435,7 @@ static void readVolta206(XmlReader& e, Volta* volta)
const QStringRef& tag(e.name());
if (tag == "endings") {
QString s = e.readElementText();
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList sl = s.split(",", Qt::SkipEmptyParts);
#else
QStringList sl = s.split(",", QString::SkipEmptyParts);
#endif
volta->endings().clear();
for (const QString& l : sl) {
int i = l.simplified().toInt();
Expand Down
7 changes: 0 additions & 7 deletions libmscore/scorediff.cpp
Expand Up @@ -127,17 +127,10 @@ std::vector<TextDiff> MscxModeDiff::lineModeDiff(const QString& s1, const QStrin
typedef std::pair<elem, dtl::elemInfo> sesElem;
typedef std::vector<sesElem> sesElemVec;

# if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
const QVector<QStringRef> linesVec1 = s1.splitRef('\n');
std::vector<QStringRef> lines1(linesVec1.begin(), linesVec1.end());
const QVector<QStringRef> linesVec2 = s2.splitRef('\n');
std::vector<QStringRef> lines2(linesVec2.begin(), linesVec2.end());
#else
// QVector does not contain range constructor used inside dtl
// so we have to convert to std::vector.
std::vector<QStringRef> lines1 = s1.splitRef('\n').toStdVector();
std::vector<QStringRef> lines2 = s2.splitRef('\n').toStdVector();
#endif
dtl::Diff<QStringRef, std::vector<QStringRef> > diff(lines1, lines2);

diff.compose();
Expand Down
8 changes: 0 additions & 8 deletions libmscore/staff.cpp
Expand Up @@ -157,11 +157,7 @@ void Staff::swapBracket(int oldIdx, int newIdx)
fillBrackets(idx);
_brackets[oldIdx]->setColumn(newIdx);
_brackets[newIdx]->setColumn(oldIdx);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 13, 0))
_brackets.swapItemsAt(oldIdx, newIdx);
#else
_brackets.swap(oldIdx, newIdx);
#endif
cleanBrackets();
}

Expand All @@ -179,11 +175,7 @@ void Staff::changeBracketColumn(int oldColumn, int newColumn)
int newIdx = i + step;
_brackets[oldIdx]->setColumn(newIdx);
_brackets[newIdx]->setColumn(oldIdx);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 13, 0))
_brackets.swapItemsAt(oldIdx, newIdx);
#else
_brackets.swap(oldIdx, newIdx);
#endif
}
cleanBrackets();
}
Expand Down
4 changes: 0 additions & 4 deletions libmscore/undo.cpp
Expand Up @@ -2067,11 +2067,7 @@ void RemoveExcerpt::redo(EditData*)

void SwapExcerpt::flip(EditData*)
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 13, 0))
score->excerpts().swapItemsAt(pos1, pos2);
#else
score->excerpts().swap(pos1, pos2);
#endif
score->setExcerptsChanged(true);
}

Expand Down
4 changes: 0 additions & 4 deletions libmscore/volta.cpp
Expand Up @@ -145,11 +145,7 @@ void Volta::read(XmlReader& e)
const QStringRef& tag(e.name());
if (tag == "endings") {
QString s = e.readElementText();
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QStringList sl = s.split(",", Qt::SkipEmptyParts);
#else
QStringList sl = s.split(",", QString::SkipEmptyParts);
#endif
_endings.clear();
for (const QString& l : sl) {
int i = l.simplified().toInt();
Expand Down
21 changes: 8 additions & 13 deletions libmscore/xmlwriter.cpp
Expand Up @@ -14,11 +14,6 @@
#include "property.h"
#include "scoreElement.h"

#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) //???
#define endl Qt::endl
#define dec Qt::dec
#endif

namespace Ms {
//---------------------------------------------------------
// Xml
Expand Down Expand Up @@ -78,7 +73,7 @@ void XmlWriter::header()
void XmlWriter::stag(const QString& s)
{
putLevel();
*this << '<' << s << '>' << endl;
*this << '<' << s << '>' << Qt::endl;
stack.append(s.split(' ')[0]);
}

Expand All @@ -104,7 +99,7 @@ void XmlWriter::stag(const QString& name, const ScoreElement* se, const QString&
if (!attributes.isEmpty()) {
*this << ' ' << attributes;
}
*this << '>' << endl;
*this << '>' << Qt::endl;
stack.append(name);

if (_recordElements) {
Expand All @@ -120,7 +115,7 @@ void XmlWriter::stag(const QString& name, const ScoreElement* se, const QString&
void XmlWriter::etag()
{
putLevel();
*this << "</" << stack.takeLast() << '>' << endl;
*this << "</" << stack.takeLast() << '>' << Qt::endl;
}

//---------------------------------------------------------
Expand All @@ -138,7 +133,7 @@ void XmlWriter::tagE(const char* format, ...)
vsnprintf(buffer, BS, format, args);
*this << buffer;
va_end(args);
*this << "/>" << endl;
*this << "/>" << Qt::endl;
}

//---------------------------------------------------------
Expand Down Expand Up @@ -169,7 +164,7 @@ void XmlWriter::ntag(const char* name)

void XmlWriter::netag(const char* s)
{
*this << "</" << s << '>' << endl;
*this << "</" << s << '>' << Qt::endl;
}

//---------------------------------------------------------
Expand Down Expand Up @@ -325,7 +320,7 @@ void XmlWriter::tag(const char* name, const QWidget* g)
void XmlWriter::comment(const QString& text)
{
putLevel();
*this << "<!-- " << text << " -->" << endl;
*this << "<!-- " << text << " -->" << Qt::endl;
}

//---------------------------------------------------------
Expand Down Expand Up @@ -381,15 +376,15 @@ void XmlWriter::dump(int len, const unsigned char* p)
for (int i = 0; i < len; ++i, ++col) {
if (col >= 16) {
setFieldWidth(0);
*this << endl;
*this << Qt::endl;
col = 0;
putLevel();
setFieldWidth(5);
}
*this << (p[i] & 0xff);
}
if (col) {
*this << endl << dec;
*this << Qt::endl << Qt::dec;
}
setFieldWidth(0);
setIntegerBase(10);
Expand Down
9 changes: 0 additions & 9 deletions mscore/chordview.cpp
Expand Up @@ -415,17 +415,8 @@ void ChordView::wheelEvent(QWheelEvent* event)
emit xposChanged(xpos);
}
} else if (event->modifiers() == Qt::ShiftModifier) {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
# if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 1)) //???
QWheelEvent we(event->position(), event->globalPosition(), event->pixelDelta(), event->angleDelta(),
event->buttons(), event->modifiers(), event->phase(), event->inverted(), event->source());
# else
QWheelEvent we(event->pos(), event->globalPos(), event->pixelDelta(), event->angleDelta(), event->buttons(),
event->modifiers(), event->phase(), event->inverted(), event->source());
# endif
#else
QWheelEvent we(event->pos(), event->delta(), event->buttons(), 0, Qt::Horizontal);
#endif
QGraphicsView::wheelEvent(&we);
} else if (event->modifiers() == 0) {
QGraphicsView::wheelEvent(event);
Expand Down
4 changes: 0 additions & 4 deletions mscore/cloud/uploadscoredialog.cpp
Expand Up @@ -101,11 +101,7 @@ void UploadScoreDialog::upload(int nid)
{
Score* score = mscore->currentScore()->masterScore();
const QString scoreTitle = title->text().trimmed().isEmpty() ? score->title() : title->text();
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
QString path = QDir::tempPath() + QString("/temp_%1.mscz").arg(QRandomGenerator::global()->generate() % 100000);
#else
QString path = QDir::tempPath() + QString("/temp_%1.mscz").arg(qrand() % 100000);
#endif
if (mscore->saveAs(score, true, path, "mscz")) {
_nid = nid;
_loginManager->upload(path, nid, scoreTitle);
Expand Down
4 changes: 0 additions & 4 deletions mscore/debugger/debugger.cpp
Expand Up @@ -1873,11 +1873,7 @@ QSize DoubleLabel::sizeHint() const
QFontMetrics fm = fontMetrics();
int h = fm.height() + 4;
int n = 3 + 3;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
int w = fm.horizontalAdvance(QString("-0.")) + fm.horizontalAdvance('0') * n + 6;
#else
int w = fm.width(QString("-0.")) + fm.width('0') * n + 6;
#endif
return QSize(w, h);
}

Expand Down

0 comments on commit 484f8dc

Please sign in to comment.