diff --git a/mkspecs/common/msvc-based-version.conf b/mkspecs/common/msvc-based-version.conf new file mode 100644 index 0000000000..38aecbaf59 --- /dev/null +++ b/mkspecs/common/msvc-based-version.conf @@ -0,0 +1,32 @@ +# +# qmake configuration for Compilers based on the Microsoft Visual Studio +# C/C++ Compilers like win32-clang-msvc + +# +# Version-specific changes +# + +isEmpty(QMAKE_MSC_VER): error("msvc-based-version.conf loaded but QMAKE_MSC_VER isn't set") + +MSVC_VER = 14.0 +COMPAT_MKSPEC = win32-msvc2015 + +# -utf-8 compiler option for Visual Studio 2015 Update 2 +greaterThan(QMAKE_MSC_FULL_VER, 190023918):!intel_icl { + isEmpty(QT_CLANG_MAJOR_VERSION)|!lessThan(QT_CLANG_MAJOR_VERSION, 4) { + QMAKE_CFLAGS_UTF8_SOURCE = -utf-8 + } +} + +greaterThan(QMAKE_MSC_VER, 1909) { + # Visual Studio 2017 (15.0) / Visual C++ 19.10 and up + MSVC_VER = 15.0 + COMPAT_MKSPEC = win32-msvc2017 +} + +greaterThan(QMAKE_MSC_VER, 1910) { + # No compat spec past MSVC 2017 + COMPAT_MKSPEC = +} + +!isEmpty(COMPAT_MKSPEC):!$$COMPAT_MKSPEC: CONFIG += $$COMPAT_MKSPEC diff --git a/mkspecs/common/msvc-version.conf b/mkspecs/common/msvc-version.conf index 3fb55c9d81..de8ba56b7b 100644 --- a/mkspecs/common/msvc-version.conf +++ b/mkspecs/common/msvc-version.conf @@ -1,7 +1,6 @@ # # qmake configuration for Microsoft Visual Studio C/C++ Compiler -# This file is used by win32-msvc, win32-clang-msvc, and all -# winrt-XXX-msvcXXX specs +# This file is used by win32-msvc and all winrt-XXX-msvcXXX specs # # @@ -70,11 +69,8 @@ greaterThan(QMAKE_MSC_VER, 1899) { QMAKE_CXXFLAGS += -Zc:strictStrings -Zc:throwingNew QMAKE_CXXFLAGS_WARN_ON += -w44456 -w44457 -w44458 -wd4577 -wd4467 - greaterThan(QMAKE_MSC_FULL_VER, 190023918):!intel_icl { - isEmpty(QT_CLANG_MAJOR_VERSION)|!lessThan(QT_CLANG_MAJOR_VERSION, 4) { - QMAKE_CFLAGS_UTF8_SOURCE = -utf-8 - } - } + # -utf-8 compiler option for Visual Studio 2015 Update 2 + greaterThan(QMAKE_MSC_FULL_VER, 190023918): QMAKE_CFLAGS_UTF8_SOURCE = -utf-8 } greaterThan(QMAKE_MSC_VER, 1909) { diff --git a/mkspecs/features/qt_common.prf b/mkspecs/features/qt_common.prf index 669ac902a8..ae859a81ff 100644 --- a/mkspecs/features/qt_common.prf +++ b/mkspecs/features/qt_common.prf @@ -112,16 +112,17 @@ warnings_are_errors:warning_clean { QMAKE_CXXFLAGS_WARN_ON += -Werror -Wno-error=\\$${LITERAL_HASH}warnings -Wno-error=deprecated-declarations $$WERROR } } else:intel_icc:linux { - # Intel CC 13.0 - 17.0, on Linux only + # Intel CC 13.0 - 18.0, on Linux only ver = $${QT_ICC_MAJOR_VERSION}.$${QT_ICC_MINOR_VERSION} - linux:contains(ver, "(1[3456]\\.|17\\.0)") { + linux:contains(ver, "(1[345678]\\.|19\\.0)") { # 177: function "entity" was declared but never referenced # (too aggressive; ICC reports even for functions created due to template instantiation) # 1224: #warning directive # 1478: function "entity" (declared at line N) was declared deprecated + # 1786: function "entity" (declared at line N of "file") was declared deprecated ("message") # 1881: argument must be a constant null pointer value # (NULL in C++ is usually a literal 0) - QMAKE_CXXFLAGS_WARN_ON += -Werror -ww177,1224,1478,1881 $$WERROR + QMAKE_CXXFLAGS_WARN_ON += -Werror -ww177,1224,1478,1786,1881 $$WERROR } } else:gcc:!clang:!intel_icc:!rim_qcc { # GCC 4.6-4.9, 5.x, ... diff --git a/mkspecs/features/toolchain.prf b/mkspecs/features/toolchain.prf index 55295f271f..c7ea20e180 100644 --- a/mkspecs/features/toolchain.prf +++ b/mkspecs/features/toolchain.prf @@ -178,13 +178,16 @@ isEmpty($${target_prefix}.INCDIRS) { QMAKE_DEFAULT_INCDIRS = $$split(INCLUDE, $$QMAKE_DIRLIST_SEP) } - unix { + unix:if(!cross_compile|host_build) { isEmpty(QMAKE_DEFAULT_INCDIRS): QMAKE_DEFAULT_INCDIRS = /usr/include /usr/local/include isEmpty(QMAKE_DEFAULT_LIBDIRS): QMAKE_DEFAULT_LIBDIRS = /lib /usr/lib } - cache($${target_prefix}.INCDIRS, set stash, QMAKE_DEFAULT_INCDIRS) - cache($${target_prefix}.LIBDIRS, set stash, QMAKE_DEFAULT_LIBDIRS) + # cache() complains about undefined variables and doesn't persist empty ones. + !isEmpty(QMAKE_DEFAULT_INCDIRS): \ + cache($${target_prefix}.INCDIRS, set stash, QMAKE_DEFAULT_INCDIRS) + !isEmpty(QMAKE_DEFAULT_LIBDIRS): \ + cache($${target_prefix}.LIBDIRS, set stash, QMAKE_DEFAULT_LIBDIRS) } else { QMAKE_DEFAULT_INCDIRS = $$eval($${target_prefix}.INCDIRS) QMAKE_DEFAULT_LIBDIRS = $$eval($${target_prefix}.LIBDIRS) @@ -278,4 +281,8 @@ QMAKE_COMPILER_DEFINES += __cplusplus=$$QT_COMPILER_STDCXX QMAKE_CFLAGS += $$QMAKE_CFLAGS_MSVC_COMPAT QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_MSVC_COMPAT -msvc:!intel_icl:!clang_cl: include(../common/msvc-version.conf) +clang_cl|intel_icl { + include(../common/msvc-based-version.conf) +} else: msvc { + include(../common/msvc-version.conf) +} diff --git a/qmake/generators/unix/unixmake.cpp b/qmake/generators/unix/unixmake.cpp index 50ec8db79e..4cbe06d9dc 100644 --- a/qmake/generators/unix/unixmake.cpp +++ b/qmake/generators/unix/unixmake.cpp @@ -399,6 +399,8 @@ UnixMakefileGenerator::findLibraries(bool linkPrl, bool mergeLflags) libdirs.append(QMakeLocalFileName(dlib.toQString())); frameworkdirs.append(QMakeLocalFileName("/System/Library/Frameworks")); frameworkdirs.append(QMakeLocalFileName("/Library/Frameworks")); + ProStringList extens; + extens << project->first("QMAKE_EXTENSION_SHLIB") << "a"; static const char * const lflags[] = { "LIBS", "LIBS_PRIVATE", "QMAKE_LIBS", "QMAKE_LIBS_PRIVATE", nullptr }; for (int i = 0; lflags[i]; i++) { @@ -417,8 +419,6 @@ UnixMakefileGenerator::findLibraries(bool linkPrl, bool mergeLflags) libdirs.insert(libidx++, f); } else if(opt.startsWith("-l")) { QString lib = opt.mid(2); - ProStringList extens; - extens << project->first("QMAKE_EXTENSION_SHLIB") << "a"; for (QList::Iterator dep_it = libdirs.begin(); dep_it != libdirs.end(); ++dep_it) { QString libBase = (*dep_it).local() + '/' @@ -521,8 +521,18 @@ UnixMakefileGenerator::findLibraries(bool linkPrl, bool mergeLflags) lflags[arch].append(opt); } } else if(!opt.isNull()) { + for (const ProString &ext : extens) { + if (opt.size() > ext.size() && opt.endsWith(ext) + && opt.at(opt.size() - ext.size() - 1) == '.') { + // Make sure we keep the dependency order of libraries + lflags[arch].removeAll(opt); + lflags[arch].append(opt); + goto found2; + } + } if(!lflags[arch].contains(opt)) lflags[arch].append(opt); + found2: ; } } diff --git a/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp b/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp index 0248640369..03904659f5 100644 --- a/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp @@ -279,21 +279,23 @@ const TInputType &myMin(const TInputType &value1, const TInputType &value2) void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg) { QByteArray localMsg = msg.toLocal8Bit(); + const char *file = context.file ? context.file : ""; + const char *function = context.function ? context.function : ""; switch (type) { case QtDebugMsg: - fprintf(stderr, "Debug: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function); + fprintf(stderr, "Debug: %s (%s:%u, %s)\n", localMsg.constData(), file, context.line, function); break; case QtInfoMsg: - fprintf(stderr, "Info: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function); + fprintf(stderr, "Info: %s (%s:%u, %s)\n", localMsg.constData(), file, context.line, function); break; case QtWarningMsg: - fprintf(stderr, "Warning: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function); + fprintf(stderr, "Warning: %s (%s:%u, %s)\n", localMsg.constData(), file, context.line, function); break; case QtCriticalMsg: - fprintf(stderr, "Critical: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function); + fprintf(stderr, "Critical: %s (%s:%u, %s)\n", localMsg.constData(), file, context.line, function); break; case QtFatalMsg: - fprintf(stderr, "Fatal: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function); + fprintf(stderr, "Fatal: %s (%s:%u, %s)\n", localMsg.constData(), file, context.line, function); break; } } diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp index 6313d6b2d3..9db20a5395 100644 --- a/src/tools/uic/cpp/cppwriteinitialization.cpp +++ b/src/tools/uic/cpp/cppwriteinitialization.cpp @@ -36,6 +36,7 @@ #include #include +#include #include #include @@ -1747,6 +1748,13 @@ QString WriteInitialization::domColor2QString(const DomColor *c) .arg(c->elementBlue()); } +static inline QVersionNumber colorRoleVersionAdded(const QString &roleName) +{ + if (roleName == QLatin1String("PlaceholderText")) + return QVersionNumber(5, 12, 0); + return QVersionNumber(); +} + void WriteInitialization::writeColorGroup(DomColorGroup *colorGroup, const QString &group, const QString &paletteName) { if (!colorGroup) @@ -1767,10 +1775,19 @@ void WriteInitialization::writeColorGroup(DomColorGroup *colorGroup, const QStri const auto &colorRoles = colorGroup->elementColorRole(); for (const DomColorRole *colorRole : colorRoles) { if (colorRole->hasAttributeRole()) { + const QString roleName = colorRole->attributeRole(); + const QVersionNumber versionAdded = colorRoleVersionAdded(roleName); const QString brushName = writeBrushInitialization(colorRole->elementBrush()); + if (!versionAdded.isNull()) { + m_output << "#if QT_VERSION >= QT_VERSION_CHECK(" + << versionAdded.majorVersion() << ", " << versionAdded.minorVersion() + << ", " << versionAdded.microVersion() << ")\n"; + } m_output << m_indent << paletteName << ".setBrush(" << group - << ", " << "QPalette::" << colorRole->attributeRole() + << ", " << "QPalette::" << roleName << ", " << brushName << ");\n"; + if (!versionAdded.isNull()) + m_output << "#endif\n"; } } } diff --git a/src/widgets/widgets/qabstractslider.cpp b/src/widgets/widgets/qabstractslider.cpp index 99ee1eccb7..2172ebc99c 100644 --- a/src/widgets/widgets/qabstractslider.cpp +++ b/src/widgets/widgets/qabstractslider.cpp @@ -829,7 +829,6 @@ void QAbstractSlider::keyPressEvent(QKeyEvent *ev) break; #endif - // It seems we need to use invertedAppearance for Left and right, otherwise, things look weird. case Qt::Key_Left: #ifdef QT_KEYPAD_NAVIGATION // In QApplication::KeypadNavigationDirectional, we want to change the slider @@ -848,9 +847,9 @@ void QAbstractSlider::keyPressEvent(QKeyEvent *ev) else #endif if (isRightToLeft()) - action = d->invertedAppearance ? SliderSingleStepSub : SliderSingleStepAdd; + action = d->invertedControls ? SliderSingleStepSub : SliderSingleStepAdd; else - action = !d->invertedAppearance ? SliderSingleStepSub : SliderSingleStepAdd; + action = !d->invertedControls ? SliderSingleStepSub : SliderSingleStepAdd; break; case Qt::Key_Right: #ifdef QT_KEYPAD_NAVIGATION @@ -868,9 +867,9 @@ void QAbstractSlider::keyPressEvent(QKeyEvent *ev) else #endif if (isRightToLeft()) - action = d->invertedAppearance ? SliderSingleStepAdd : SliderSingleStepSub; + action = d->invertedControls ? SliderSingleStepAdd : SliderSingleStepSub; else - action = !d->invertedAppearance ? SliderSingleStepAdd : SliderSingleStepSub; + action = !d->invertedControls ? SliderSingleStepAdd : SliderSingleStepSub; break; case Qt::Key_Up: #ifdef QT_KEYPAD_NAVIGATION diff --git a/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp b/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp index 70ae453896..1a0d7a9289 100644 --- a/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp +++ b/tests/auto/widgets/widgets/qabstractslider/tst_qabstractslider.cpp @@ -467,160 +467,1001 @@ void tst_QAbstractSlider::keyPressed_data() QTest::addColumn("maximum"); QTest::addColumn("stepSize"); QTest::addColumn("pageSize"); + QTest::addColumn("invertedAppearance"); + QTest::addColumn("invertedControls"); QTest::addColumn >("keySequence"); - QTest::addColumn("expectedSliderPositionHorizontal"); - QTest::addColumn("expectedSliderPositionVertical"); - QTest::addColumn("expectedSliderPositionHorizontalInverted"); // :) - QTest::addColumn("expectedSliderPositionVerticalInverted"); - + QTest::addColumn("expectedSliderPosition"); QList list; - list << Qt::Key_Down; - QTest::newRow("Step down once 1") << 10 // initial position - << 0 // minimum - << 100 // maximum - << 3 // single step size - << 0 // page step size - << list // key sequence - << 7 // result in case of horizontal slider - << 7 // result in case of vertical slider - << 13 // result in case of inverted horiz. slider - << 13; // result in case of inverted vertical slider + QTest::newRow("Step down once 1, horizontal") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 0 // page step size + << false// inverted appearance + << false// inverted controls + << list // key sequence + << 7; // expected position + + QTest::newRow("Step down once 1, horizontal, appearance inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 0 // page step size + << true // inverted appearance + << false// inverted controls + << list // key sequence + << 7; // expected position + + QTest::newRow("Step down once 1, horizontal, controls inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 0 // page step size + << false// inverted appearance + << true // inverted controls + << list // key sequence + << 13; // expected position + + QTest::newRow("Step down once 1, horizontal, both inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 0 // page step size + << true // inverted appearance + << true // inverted controls + << list // key sequence + << 13; // expected position + + QTest::newRow("Step down once 1, vertical") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 0 // page step size + << false// inverted appearance + << false// inverted controls + << list // key sequence + << 7; // expected position + + QTest::newRow("Step down once 1, vertical, appearance inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 0 // page step size + << true // inverted appearance + << false// inverted controls + << list // key sequence + << 7; // expected position + + QTest::newRow("Step down once 1, vertical, controls inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 0 // page step size + << false// inverted appearance + << true // inverted controls + << list // key sequence + << 13; // expected position + + QTest::newRow("Step down once 1, vertical, both inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 0 // page step size + << true // inverted appearance + << true // inverted controls + << list // key sequence + << 13; // expected position list = QList(); list << Qt::Key_Up; - QTest::newRow("Step down once 2") << 10 // initial position - << 0 // minimum - << 100 // maximum - << 3 // single step size - << 0 // page step size - << list // key sequence - << 13 // result in case of horizontal slider - << 13 // result in case of vertical slider - << 7 // result in case of inverted horiz. slider - << 7; // result in case of inverted vertical slider + QTest::newRow("Step up once 2, horizontal") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 0 // page step size + << false// inverted appearance + << false// inverted controls + << list // key sequence + << 13; // expected position + QTest::newRow("Step up once 2, horizontal, appearance inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 0 // page step size + << true // inverted appearance + << false// inverted controls + << list // key sequence + << 13; // expected position + + QTest::newRow("Step up once 2, horizontal, controls inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 0 // page step size + << false// inverted appearance + << true // inverted controls + << list // key sequence + << 7; // expected position + + QTest::newRow("Step up once 2, horizontal, both inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 0 // page step size + << true // inverted appearance + << true // inverted controls + << list // key sequence + << 7; // expected position + + QTest::newRow("Step up once 2, vertical") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 0 // page step size + << false// inverted appearance + << false// inverted controls + << list // key sequence + << 13; // expected position + + QTest::newRow("Step up once 2, vertical, appearance inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 0 // page step size + << true // inverted appearance + << false// inverted controls + << list // key sequence + << 13; // expected position + + QTest::newRow("Step up once 2, vertical, controls inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 0 // page step size + << false// inverted appearance + << true // inverted controls + << list // key sequence + << 7; // expected position + + QTest::newRow("Step up once 2, vertical, both inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 0 // page step size + << true // inverted appearance + << true // inverted controls + << list // key sequence + << 7; // expected position list = QList(); list << Qt::Key_Left; - QTest::newRow("Step left once") << 10 // initial position - << 0 // minimum - << 100 // maximum - << 3 // single step size - << 0 // page step size - << list // key sequence - << 7 // result in case of horizontal slider - << 7 // result in case of vertical slider - << 13 // result in case of inverted horiz. slider - << 13; // result in case of inverted vertical slider + QTest::newRow("Step left once 2, horizontal") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 0 // page step size + << false// inverted appearance + << false// inverted controls + << list // key sequence + << 7; // expected position + + QTest::newRow("Step left once 2, horizontal, appearance inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 0 // page step size + << true // inverted appearance + << false// inverted controls + << list // key sequence + << 7; // expected position + + QTest::newRow("Step left once 2, horizontal, controls inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 0 // page step size + << false// inverted appearance + << true // inverted controls + << list // key sequence + << 13; // expected position + + QTest::newRow("Step left once 2, horizontal, both inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 0 // page step size + << true // inverted appearance + << true // inverted controls + << list // key sequence + << 13; // expected position + + QTest::newRow("Step left once 2, vertical") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 0 // page step size + << false// inverted appearance + << false// inverted controls + << list // key sequence + << 7; // expected position + + QTest::newRow("Step left once 2, vertical, appearance inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 0 // page step size + << true // inverted appearance + << false// inverted controls + << list // key sequence + << 7; // expected position + + QTest::newRow("Step left once 2, vertical, controls inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 0 // page step size + << false// inverted appearance + << true // inverted controls + << list // key sequence + << 13; // expected position + + QTest::newRow("Step left once 2, vertical, both inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 0 // page step size + << true // inverted appearance + << true // inverted controls + << list // key sequence + << 13; // expected position list = QList(); list << Qt::Key_Right; - QTest::newRow("Step right once") << 10 // initial position - << 0 // minimum - << 100 // maximum - << 3 // single step size - << 0 // page step size - << list // key sequence - << 13 // result in case of horizontal slider - << 13 // result in case of vertical slider - << 7 // result in case of inverted horiz. slider - << 7; // result in case of inverted vertical slider + QTest::newRow("Step right once 2, horizontal") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 0 // page step size + << false// inverted appearance + << false// inverted controls + << list // key sequence + << 13; // expected position + + QTest::newRow("Step right once 2, horizontal, appearance inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 0 // page step size + << true // inverted appearance + << false// inverted controls + << list // key sequence + << 13; // expected position + + QTest::newRow("Step right once 2, horizontal, controls inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 0 // page step size + << false// inverted appearance + << true // inverted controls + << list // key sequence + << 7; // expected position + + QTest::newRow("Step right once 2, horizontal, both inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 0 // page step size + << true // inverted appearance + << true // inverted controls + << list // key sequence + << 7; // expected position + + QTest::newRow("Step right once 2, vertical") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 0 // page step size + << false// inverted appearance + << false// inverted controls + << list // key sequence + << 13; // expected position + + QTest::newRow("Step right once 2, vertical, appearance inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 0 // page step size + << true // inverted appearance + << false// inverted controls + << list // key sequence + << 13; // expected position + + QTest::newRow("Step right once 2, vertical, controls inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 0 // page step size + << false// inverted appearance + << true // inverted controls + << list // key sequence + << 7; // expected position + + QTest::newRow("Step right once 2, vertical, both inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 0 // page step size + << true // inverted appearance + << true // inverted controls + << list // key sequence + << 7; // expected position list = QList(); list << Qt::Key_PageDown; - QTest::newRow("Page down once") << 10 // initial position - << 0 // minimum - << 100 // maximum - << 0 // single step size - << 3 // page step size - << list // key sequence - << 7 // result in case of horizontal slider - << 7 // result in case of vertical slider - << 13 // result in case of inverted horiz. slider - << 13; // result in case of inverted vertical slider + QTest::newRow("Page down once, horizontal") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 0 // single step size + << 3 // page step size + << false// inverted appearance + << false// inverted controls + << list // key sequence + << 7; // expected position + + QTest::newRow("Page down once, horizontal, appearance inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 0 // single step size + << 3 // page step size + << true // inverted appearance + << false// inverted controls + << list // key sequence + << 7; // expected position + + QTest::newRow("Page down once, horizontal, controls inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 0 // single step size + << 3 // page step size + << false// inverted appearance + << true // inverted controls + << list // key sequence + << 13; // expected position + + QTest::newRow("Page down once, horizontal, both inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 0 // single step size + << 3 // page step size + << true // inverted appearance + << true // inverted controls + << list // key sequence + << 13; // expected position + + QTest::newRow("Page down once, vertical") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 0 // single step size + << 3 // page step size + << false// inverted appearance + << false// inverted controls + << list // key sequence + << 7; // expected position + + QTest::newRow("Page down once, vertical, appearance inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 0 // single step size + << 3 // page step size + << true // inverted appearance + << false// inverted controls + << list // key sequence + << 7; // expected position + + QTest::newRow("Page down once, vertical, controls inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 0 // single step size + << 3 // page step size + << false// inverted appearance + << true // inverted controls + << list // key sequence + << 13; // expected position + + QTest::newRow("Page down once, vertical, both inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 0 // single step size + << 3 // page step size + << true // inverted appearance + << true // inverted controls + << list // key sequence + << 13; // expected position list = QList(); list << Qt::Key_PageUp; - QTest::newRow("Page up once") << 10 // initial position - << 0 // minimum - << 100 // maximum - << 0 // single step size - << 3 // page step size - << list // key sequence - << 13 // result in case of horizontal slider - << 13 // result in case of vertical slider - << 7 // result in case of inverted horiz. slider - << 7; // result in case of inverted vertical slider + QTest::newRow("Page up once, horizontal") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 0 // single step size + << 3 // page step size + << false// inverted appearance + << false// inverted controls + << list // key sequence + << 13; // expected position + + QTest::newRow("Page up once, horizontal, appearance inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 0 // single step size + << 3 // page step size + << true // inverted appearance + << false// inverted controls + << list // key sequence + << 13; // expected position + + QTest::newRow("Page up once, horizontal, controls inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 0 // single step size + << 3 // page step size + << false// inverted appearance + << true // inverted controls + << list // key sequence + << 7; // expected position + + QTest::newRow("Page up once, horizontal, both inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 0 // single step size + << 3 // page step size + << true // inverted appearance + << true // inverted controls + << list // key sequence + << 7; // expected position + + QTest::newRow("Page up once, vertical") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 0 // single step size + << 3 // page step size + << false// inverted appearance + << false// inverted controls + << list // key sequence + << 13; // expected position + + QTest::newRow("Page up once, vertical, appearance inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 0 // single step size + << 3 // page step size + << true // inverted appearance + << false// inverted controls + << list // key sequence + << 13; // expected position + + QTest::newRow("Page up once, vertical, controls inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 0 // single step size + << 3 // page step size + << false// inverted appearance + << true // inverted controls + << list // key sequence + << 7; // expected position + + QTest::newRow("Page up once, vertical, both inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 0 // single step size + << 3 // page step size + << true // inverted appearance + << true // inverted controls + << list // key sequence + << 7; // expected position list = QList(); list << Qt::Key_Up << Qt::Key_Up << Qt::Key_PageDown << Qt::Key_PageDown << Qt::Key_Left << Qt::Key_Left << Qt::Key_Right << Qt::Key_Down << Qt::Key_PageUp << Qt::Key_PageUp << Qt::Key_Down << Qt::Key_Right; - QTest::newRow("Symmetric seq") << 50 // initial position - << 0 // minimum - << 100 // maximum - << 3 // single step size - << 3 // page step size - << list // key sequence - << 50 // result in case of horizontal slider - << 50 // result in case of vertical slider - << 50 // result in case of inverted horiz. slider - << 50; // result in case of inverted vertical slider + QTest::newRow("Symmetric seq, horizontal") + << 50 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 3 // page step size + << false// inverted appearance + << false// inverted controls + << list // key sequence + << 50; // expected position + QTest::newRow("Symmetric seq, horizontal, appearance inverted") + << 50 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 3 // page step size + << true // inverted appearance + << false// inverted controls + << list // key sequence + << 50; // expected position + + QTest::newRow("Symmetric seq, horizontal, controls inverted") + << 50 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 3 // page step size + << false// inverted appearance + << true // inverted controls + << list // key sequence + << 50; // expected position + + QTest::newRow("Symmetric seq, horizontal, both inverted") + << 50 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 3 // page step size + << true // inverted appearance + << true // inverted controls + << list // key sequence + << 50; // expected position + + QTest::newRow("Symmetric seq, vertical") + << 50 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 3 // page step size + << false// inverted appearance + << false// inverted controls + << list // key sequence + << 50; // expected position + + QTest::newRow("Symmetric seq, vertical, appearance inverted") + << 50 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 3 // page step size + << true // inverted appearance + << false// inverted controls + << list // key sequence + << 50; // expected position + + QTest::newRow("Symmetric seq, vertical, controls inverted") + << 50 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 3 // page step size + << false// inverted appearance + << true // inverted controls + << list // key sequence + << 50; // expected position + + QTest::newRow("Symmetric seq, vertical, both inverted") + << 50 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 3 // page step size + << true // inverted appearance + << true // inverted controls + << list // key sequence + << 50; // expected position list = QList(); list << Qt::Key_Home; - QTest::newRow("Home") << 10 // initial position - << 0 // minimum - << 100 // maximum - << 0 // single step size - << 3 // page step size - << list // key sequence - << 0 // result in case of horizontal slider - << 0 // result in case of vertical slider - << 0 // result in case of inverted horiz. slider - << 0; // result in case of inverted vertical slider + QTest::newRow("Home, horizontal") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 0 // single step size + << 3 // page step size + << false// inverted appearance + << false// inverted controls + << list // key sequence + << 0; // expected position + + QTest::newRow("Home, horizontal, appearance inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 0 // single step size + << 3 // page step size + << true // inverted appearance + << false// inverted controls + << list // key sequence + << 0; // expected position + + QTest::newRow("Home, horizontal, controls inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 0 // single step size + << 3 // page step size + << false// inverted appearance + << true // inverted controls + << list // key sequence + << 0; // expected position + + QTest::newRow("Home, horizontal, both inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 0 // single step size + << 3 // page step size + << true // inverted appearance + << true // inverted controls + << list // key sequence + << 0; // expected position + + QTest::newRow("Home, vertical") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 0 // single step size + << 3 // page step size + << false// inverted appearance + << false// inverted controls + << list // key sequence + << 0; // expected position + + QTest::newRow("Home, vertical, appearance inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 0 // single step size + << 3 // page step size + << true // inverted appearance + << false// inverted controls + << list // key sequence + << 0; // expected position + + QTest::newRow("Home, vertical, controls inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 0 // single step size + << 3 // page step size + << false// inverted appearance + << true // inverted controls + << list // key sequence + << 0; // expected position + + QTest::newRow("Home, vertical, both inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 0 // single step size + << 3 // page step size + << true // inverted appearance + << true // inverted controls + << list // key sequence + << 0; // expected position list = QList(); list << Qt::Key_End; - QTest::newRow("End") << 10 // initial position - << 0 // minimum - << 100 // maximum - << 0 // single step size - << 3 // page step size - << list // key sequence - << 100 // result in case of horizontal slider - << 100 // result in case of vertical slider - << 100 // result in case of inverted horiz. slider - << 100; // result in case of inverted vertical slider + QTest::newRow("End, horizontal") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 0 // single step size + << 3 // page step size + << false// inverted appearance + << false// inverted controls + << list // key sequence + << 100; // expected position + + QTest::newRow("End, horizontal, appearance inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 0 // single step size + << 3 // page step size + << true // inverted appearance + << false// inverted controls + << list // key sequence + << 100; // expected position + + QTest::newRow("End, horizontal, controls inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 0 // single step size + << 3 // page step size + << false// inverted appearance + << true // inverted controls + << list // key sequence + << 100; // expected position + + QTest::newRow("End, horizontal, both inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 0 // single step size + << 3 // page step size + << true // inverted appearance + << true // inverted controls + << list // key sequence + << 100; // expected position + + QTest::newRow("End, vertical") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 0 // single step size + << 3 // page step size + << false// inverted appearance + << false// inverted controls + << list // key sequence + << 100; // expected position + + QTest::newRow("End, vertical, appearance inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 0 // single step size + << 3 // page step size + << true // inverted appearance + << false// inverted controls + << list // key sequence + << 100; // expected position + + QTest::newRow("End, vertical, controls inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 0 // single step size + << 3 // page step size + << false// inverted appearance + << true // inverted controls + << list // key sequence + << 100; // expected position + + QTest::newRow("End, vertical, both inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 0 // single step size + << 3 // page step size + << true // inverted appearance + << true // inverted controls + << list // key sequence + << 100; // expected position list = QList(); list << Qt::Key_End << Qt::Key_Up; - QTest::newRow("Past end")<< 10 // initial position - << 0 // minimum - << 100 // maximum - << 3 // single step size - << 3 // page step size - << list // key sequence - << 100 // result in case of horizontal slider - << 100 // result in case of vertical slider - << 97 // result in case of inverted horiz. slider - << 97; // result in case of inverted vertical slider + QTest::newRow("Past end, horizontal") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 3 // page step size + << false// inverted appearance + << false// inverted controls + << list // key sequence + << 100; // expected position + + QTest::newRow("Past end, horizontal, appearance inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 3 // page step size + << true // inverted appearance + << false// inverted controls + << list // key sequence + << 100; // expected position + + QTest::newRow("Past end, horizontal, controls inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 3 // page step size + << false// inverted appearance + << true // inverted controls + << list // key sequence + << 97; // expected position + + QTest::newRow("Past end, horizontal, both inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 3 // page step size + << true // inverted appearance + << true // inverted controls + << list // key sequence + << 97; // expected position + + QTest::newRow("Past end, vertical") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 3 // page step size + << false// inverted appearance + << false// inverted controls + << list // key sequence + << 100; // expected position + + QTest::newRow("Past end, vertical, appearance inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 3 // page step size + << true // inverted appearance + << false// inverted controls + << list // key sequence + << 100; // expected position + + QTest::newRow("Past end, vertical, controls inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 3 // page step size + << false// inverted appearance + << true // inverted controls + << list // key sequence + << 97; // expected position + + QTest::newRow("Past end, vertical, both inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 3 // page step size + << true // inverted appearance + << true // inverted controls + << list // key sequence + << 97; // expected position list = QList(); list << Qt::Key_Home << Qt::Key_Down; - QTest::newRow("Past home")<< 10 // initial position - << 0 // minimum - << 100 // maximum - << 3 // single step size - << 3 // page step size - << list // key sequence - << 0 // result in case of horizontal slider - << 0 // result in case of vertical slider - << 3 // result in case of inverted horiz. slider - << 3; // result in case of inverted vertical slider + QTest::newRow("Past home, horizontal") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 3 // page step size + << false// inverted appearance + << false// inverted controls + << list // key sequence + << 0; // expected position + QTest::newRow("Past home, horizontal, appearance inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 3 // page step size + << true // inverted appearance + << false// inverted controls + << list // key sequence + << 0; // expected position + + QTest::newRow("Past home, horizontal, controls inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 3 // page step size + << false// inverted appearance + << true // inverted controls + << list // key sequence + << 3; // expected position + + QTest::newRow("Past home, horizontal, both inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 3 // page step size + << true // inverted appearance + << true // inverted controls + << list // key sequence + << 3; // expected position + + QTest::newRow("Past home, vertical") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 3 // page step size + << false// inverted appearance + << false// inverted controls + << list // key sequence + << 0; // expected position + + QTest::newRow("Past home, vertical, appearance inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 3 // page step size + << false// inverted appearance + << false// inverted controls + << list // key sequence + << 0; // expected position + + QTest::newRow("Past home, vertical, controls inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 3 // page step size + << false// inverted appearance + << true // inverted controls + << list // key sequence + << 3; // expected position + + QTest::newRow("Past home, vertical, both inverted") + << 10 // initial position + << 0 // minimum + << 100 // maximum + << 3 // single step size + << 3 // page step size + << true // inverted appearance + << true // inverted controls + << list // key sequence + << 3; // expected position } void tst_QAbstractSlider::keyPressed() @@ -630,60 +1471,22 @@ void tst_QAbstractSlider::keyPressed() QFETCH(int, maximum); QFETCH(int, stepSize); QFETCH(int, pageSize); + QFETCH(bool, invertedAppearance); + QFETCH(bool, invertedControls); QFETCH(QList, keySequence); - QFETCH(int, expectedSliderPositionHorizontal); - QFETCH(int, expectedSliderPositionVertical); - QFETCH(int, expectedSliderPositionHorizontalInverted); - QFETCH(int, expectedSliderPositionVerticalInverted); + QFETCH(int, expectedSliderPosition); - // Horizontal non-inverted slider->setRange(minimum,maximum); slider->setSliderPosition(initialSliderPosition); slider->setSingleStep(stepSize); slider->setPageStep(pageSize); slider->setOrientation(Qt::Horizontal); - slider->setInvertedAppearance(false); - slider->setInvertedControls(false); + slider->setInvertedAppearance(invertedAppearance); + slider->setInvertedControls(invertedControls); for (int i=0;isliderPosition(), expectedSliderPositionHorizontal); - - // Horizontal inverted - slider->setRange(minimum,maximum); - slider->setSliderPosition(initialSliderPosition); - slider->setSingleStep(stepSize); - slider->setPageStep(pageSize); - slider->setOrientation(Qt::Horizontal); - slider->setInvertedAppearance(true); - slider->setInvertedControls(true); - for (int i=0;isliderPosition(), expectedSliderPositionHorizontalInverted); - - // Vertical non-inverted - slider->setRange(minimum,maximum); - slider->setSliderPosition(initialSliderPosition); - slider->setSingleStep(stepSize); - slider->setPageStep(pageSize); - slider->setOrientation(Qt::Vertical); - slider->setInvertedAppearance(false); - slider->setInvertedControls(false); - for (int i=0;isliderPosition(), expectedSliderPositionVertical); - - // Vertical inverted - slider->setRange(minimum,maximum); - slider->setSliderPosition(initialSliderPosition); - slider->setSingleStep(stepSize); - slider->setPageStep(pageSize); - slider->setOrientation(Qt::Vertical); - slider->setInvertedAppearance(true); - slider->setInvertedControls(true); - for (int i=0;isliderPosition(), expectedSliderPositionVerticalInverted); + QCOMPARE(slider->sliderPosition(), expectedSliderPosition); } #if QT_CONFIG(wheelevent)