Skip to content

Commit

Permalink
feat:upgrade to 5.103
Browse files Browse the repository at this point in the history
* upgrade to 5.103 from upstream

log: upgrade
  • Loading branch information
Gui-Yue committed Jun 13, 2023
1 parent dabfedf commit 7d485b9
Show file tree
Hide file tree
Showing 166 changed files with 789,644 additions and 22,129 deletions.
21 changes: 14 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
cmake_minimum_required(VERSION 3.16)

set(KF_VERSION "5.90.0") # handled by release scripts
set(KF_DEP_VERSION "5.90.0") # handled by release scripts
set(KF_VERSION "5.103.0") # handled by release scripts
set(KF_DEP_VERSION "5.103.0") # handled by release scripts
project(KXmlGui VERSION ${KF_VERSION})

# ECM setup
include(FeatureSummary)
find_package(ECM 5.90.0 NO_MODULE)
find_package(ECM 5.103.0 NO_MODULE)
set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://commits.kde.org/extra-cmake-modules")
feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES)

Expand All @@ -24,6 +24,8 @@ include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE)
include(KDECMakeSettings)
include(KDEGitCommitHooks)
include(ECMQtDeclareLoggingCategory)
include(ECMDeprecationSettings)
include(CMakeDependentOption)

ecm_setup_version(PROJECT
VARIABLE_PREFIX KXMLGUI
Expand All @@ -37,7 +39,7 @@ option(FORCE_DISABLE_KGLOBALACCEL "Force building KXmlGui without KGlobalAccel.
option(BUILD_QCH "Build API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)" OFF)
add_feature_info(QCH ${BUILD_QCH} "API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)")

option(BUILD_DESIGNERPLUGIN "Build plugin for Qt Designer" ON)
cmake_dependent_option(BUILD_DESIGNERPLUGIN "Build plugin for Qt Designer" ON "NOT CMAKE_CROSSCOMPILING" OFF)
add_feature_info(DESIGNERPLUGIN ${BUILD_DESIGNERPLUGIN} "Build plugin for Qt Designer")

# Dependencies
Expand Down Expand Up @@ -65,8 +67,13 @@ if (NOT FORCE_DISABLE_KGLOBALACCEL AND NOT WIN32 AND NOT APPLE AND NOT ANDROID)
find_package(KF5GlobalAccel ${KF_DEP_VERSION} REQUIRED)
endif()
set (HAVE_GLOBALACCEL ${KF5GlobalAccel_FOUND})
add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050f02)
add_definitions(-DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x055100)

ecm_set_disabled_deprecation_versions(
QT 5.15.2
KF 5.95
KCOREADDONS 5.86 # KPluginMetaData::extraInformation
)

add_definitions(-DTRANSLATION_DOMAIN=\"kxmlgui5\")
ki18n_install(po)

Expand Down Expand Up @@ -110,7 +117,7 @@ install(EXPORT KF5XmlGuiTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE KF

install(FILES
${CMAKE_CURRENT_BINARY_DIR}/kxmlgui_version.h
DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF} COMPONENT Devel
DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF}/KXmlGui COMPONENT Devel
)

feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
Expand Down
18 changes: 18 additions & 0 deletions autotests/kmainwindow_unittest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <QResizeEvent>
#include <QStatusBar>
#include <QTest>
#include <QTimer>
#include <kmainwindow.h>
#include <ktoolbar.h>

Expand Down Expand Up @@ -196,15 +197,30 @@ void KMainWindow_UnitTest::testAutoSaveSettings()
mw.show();
KToolBar *tb = new KToolBar(&mw); // we need a toolbar to trigger an old bug in saveMainWindowSettings
tb->setObjectName(QStringLiteral("testtb"));
mw.setStateConfigGroup(group);
mw.setAutoSaveSettings(group);
mw.reallyResize(800, 600);
QVERIFY(mw.autoSaveSettings());

// Ensure we save the settings in the correct place
const auto hasWidthAndHightSaved = [](const QStringList &keys) {
const auto containsKey = [&keys](const QLatin1String &keyToCheck) {
return std::any_of(keys.begin(), keys.end(), [&keyToCheck](const QString &key) {
return key.contains(keyToCheck);
});
};
return containsKey(QLatin1String(" Width ")) && containsKey(QLatin1String(" Height "));
};
QTRY_VERIFY(hasWidthAndHightSaved(mw.stateConfigGroup().keyList()));
QTRY_VERIFY(!hasWidthAndHightSaved(mw.autoSaveConfigGroup().keyList()));
mw.close();
}

KMainWindow mw2;
mw2.show();
KToolBar *tb = new KToolBar(&mw2);
tb->setObjectName(QStringLiteral("testtb"));
mw2.setStateConfigGroup(group);
mw2.setAutoSaveSettings(group);
QTRY_COMPARE(mw2.size(), QSize(800, 600));
}
Expand All @@ -217,13 +233,15 @@ void KMainWindow_UnitTest::testNoAutoSave()
// A mainwindow with autosaving, but not of the window size.
MyMainWindow mw;
mw.show();
mw.setStateConfigGroup(group);
mw.setAutoSaveSettings(group, false);
mw.reallyResize(750, 550);
mw.close();
}

KMainWindow mw2;
mw2.show();
mw2.setStateConfigGroup(group);
mw2.setAutoSaveSettings(group, false);
// NOT 750, 550! (the 800,600 comes from testAutoSaveSettings)
QTRY_COMPARE(mw2.size(), QSize(800, 600));
Expand Down
8 changes: 8 additions & 0 deletions autotests/ktoolbar_unittest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ void tst_KToolBar::testIconSizeNoXmlGui()
const bool mainToolBarWasUsingDefaultSize = iconSize == KIconLoader::global()->currentSize(KIconLoader::MainToolbar);
const bool otherToolBarWasUsingDefaultSize = iconSize == KIconLoader::global()->currentSize(KIconLoader::Toolbar);

#ifndef Q_OS_WIN // the change notification uses DBus
// Now emulate a change of the kde-global setting (#168480#c12)
changeGlobalIconSizeSetting(32, 33);

Expand All @@ -256,6 +257,7 @@ void tst_KToolBar::testIconSizeNoXmlGui()
QCOMPARE(otherToolBar->iconSize().width(), iconSize);
}
QCOMPARE(cleanToolBar->iconSize().width(), 33);
#endif
}
}

Expand Down Expand Up @@ -321,13 +323,15 @@ void tst_KToolBar::testIconSizeXmlGui()
QVERIFY(group.group("Toolbar mainToolBar").hasKey("IconSize"));
}

#ifndef Q_OS_WIN // the change notification uses DBus
// Now emulate a change of the kde-global setting (#168480#c12)
changeGlobalIconSizeSetting(25, 16);

QCOMPARE(mainToolBar->iconSize().width(), expectedSizeMainToolbar);
QCOMPARE(otherToolBar->iconSize().width(), expectedSizeOtherToolbar);
QCOMPARE(cleanToolBar->iconSize().width(), expectedSizeCleanToolbar);
QCOMPARE(bigToolBar->iconSize().width(), expectedSizeBigToolbar);
#endif

// The big unchanged toolbar should be, well, unchanged; AppXml has priority over KDE_Default.
QCOMPARE(bigUnchangedToolBar->iconSize().width(), 32);
Expand Down Expand Up @@ -418,6 +422,7 @@ void tst_KToolBar::testToolButtonStyleNoXmlGui()
QCOMPARE((int)mainToolBar->toolButtonStyle(), (int)toolButtonStyle);
QCOMPARE((int)otherToolBar->toolButtonStyle(), (int)toolButtonStyle);

#ifndef Q_OS_WIN // the change notification uses DBus
// Now change KDE-global setting
changeGlobalToolButtonStyleSetting(QStringLiteral("IconOnly"), QStringLiteral("TextOnly"));

Expand All @@ -432,6 +437,7 @@ void tst_KToolBar::testToolButtonStyleNoXmlGui()
} else {
QCOMPARE((int)otherToolBar->toolButtonStyle(), (int)toolButtonStyle);
}
#endif
}
}

Expand Down Expand Up @@ -480,12 +486,14 @@ void tst_KToolBar::testToolButtonStyleXmlGui()
// Save settings
kmw.saveMainWindowSettings(group);

#ifndef Q_OS_WIN // the change notification uses DBus
// Now change KDE-global setting
changeGlobalToolButtonStyleSetting(QStringLiteral("IconOnly"), QStringLiteral("TextOnly"));

QCOMPARE((int)mainToolBar->toolButtonStyle(), (int)expectedStyleMainToolbar);
QCOMPARE((int)otherToolBar->toolButtonStyle(), (int)expectedStyleOtherToolbar);
QCOMPARE((int)cleanToolBar->toolButtonStyle(), (int)expectedStyleCleanToolbar);
#endif
}
}

Expand Down
54 changes: 28 additions & 26 deletions autotests/ktooltiphelper_unittest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,17 @@
QString KToolTipHelper_UnitTest::shownToolTip(QWidget *widget)
{
QTest::mouseMove(m_frameWithoutToolTip);
const bool resetWorked = QTest::qWaitFor([](){return !QToolTip::isVisible();}, 3000);
const bool resetWorked = QTest::qWaitFor(
[]() {
return !QToolTip::isVisible();
},
3000);
if (!resetWorked) {
qWarning("The tooltip did not properly hide itself after moving to an area without tooltip.");
}

QTest::mouseMove(widget);
if (!QTest::qWaitFor(&QToolTip::isVisible,
widget->style()->styleHint(QStyle::SH_ToolTip_WakeUpDelay, nullptr, widget) + 1000)
) {
if (!QTest::qWaitFor(&QToolTip::isVisible, widget->style()->styleHint(QStyle::SH_ToolTip_WakeUpDelay, nullptr, widget) + 1000)) {
return QStringLiteral("");
}
return QToolTip::text();
Expand Down Expand Up @@ -76,27 +78,31 @@ void KToolTipHelper_UnitTest::testGeneralWidget()
m_frame->setToolTip(QStringLiteral("frame's tooltip"));
QCOMPARE(shownToolTip(m_frame), m_frame->toolTip());

QHelpEvent *helpEvent = new QHelpEvent(QEvent::ToolTip, QPoint(1,1), m_frame->mapToGlobal(QPoint(1, 1)));
QHelpEvent *helpEvent = new QHelpEvent(QEvent::ToolTip, QPoint(1, 1), m_frame->mapToGlobal(QPoint(1, 1)));
QVERIFY2(!KToolTipHelper::instance()->eventFilter(m_frame, helpEvent),
"These most basic tooltips should not be filtered so applications can still rely"
"on tooltip events in most cases.");

// tests with whatsThis()
m_frame->setToolTip(QStringLiteral(""));
m_frame->setWhatsThis(QStringLiteral("frame's whatsThis"));
QVERIFY2(shownToolTip(m_frame).isEmpty(),
"No whatsThisHint should be shown when no toolTip was set.");
QVERIFY2(shownToolTip(m_frame).isEmpty(), "No whatsThisHint should be shown when no toolTip was set.");

m_frame->setToolTip(KToolTipHelper::whatsThisHintOnly());
QVERIFY2(shownToolTip(m_frame) != KToolTipHelper::whatsThisHintOnly(),
"The KToolTipHelper::whatsThisHintOnly()-string is no user-facing string"
"and should therefore never actually be displayed.");

// test when whatsThis() == toolTip()
m_frame->setToolTip(QStringLiteral("frame's whatsThis"));
const QString noWhatsThisToolTip = shownToolTip(m_frame);
QVERIFY(noWhatsThisToolTip.contains(m_frame->toolTip()));
QVERIFY2(noWhatsThisToolTip.length() == m_frame->toolTip().length(), "No whatsThisHint should be shown when the toolTip is a similar string.");

m_frame->setToolTip(QStringLiteral("frame's tooltip"));
const QString toolTip = shownToolTip(m_frame);
QVERIFY(toolTip.contains(m_frame->toolTip()));
QVERIFY2(toolTip.length() > m_frame->toolTip().length(),
"The frame's toolTip is supposed to contain the whatsThisHint.");
QVERIFY2(toolTip.length() > m_frame->toolTip().length(), "The frame's toolTip is supposed to contain the whatsThisHint.");

auto layout = new QVBoxLayout(m_frame);
auto subFrame = std::unique_ptr<QFrame>(new QFrame(m_frame));
Expand All @@ -114,7 +120,11 @@ void KToolTipHelper_UnitTest::testInvokingWhatsThis()
m_frame->setToolTip(KToolTipHelper::whatsThisHintOnly());
shownToolTip(m_frame);
QTest::keyClick(m_frame, Qt::Key_Shift);
QVERIFY2(QTest::qWaitFor([](){return !QToolTip::isVisible(); }, 4000),
QVERIFY2(QTest::qWaitFor(
[]() {
return !QToolTip::isVisible();
},
4000),
"whatsThis should be shown now.");
QVERIFY2(shownToolTip(m_frame).isEmpty(),
"A toolTip was shown which shouldn't be possible because a WhatsThis widget"
Expand All @@ -134,25 +144,22 @@ void KToolTipHelper_UnitTest::testQToolButton()
m_toolButton->setDefaultAction(action.get());
QCOMPARE(shownToolTip(m_toolButton), action->toolTip());

auto helpEvent = std::unique_ptr<QHelpEvent>(
new QHelpEvent(QEvent::ToolTip, QPoint(1,1), m_toolButton->mapToGlobal(QPoint(1, 1))));
auto helpEvent = std::unique_ptr<QHelpEvent>(new QHelpEvent(QEvent::ToolTip, QPoint(1, 1), m_toolButton->mapToGlobal(QPoint(1, 1))));
QVERIFY2(!KToolTipHelper::instance()->eventFilter(m_toolButton, helpEvent.get()),
"These most basic tooltips should not be filtered so applications can still rely"
"on tooltip events in most cases.");

action->setShortcut(Qt::CTRL | Qt::Key_K);
const QString toolTip(shownToolTip(m_toolButton));
QVERIFY(toolTip.contains(action->toolTip()));
//qDebug("%s > %s", qPrintable(toolTip), qPrintable(action->toolTip()));
QVERIFY2(toolTip.length() > action->toolTip().length(),
"The Keyboard shortcut should be visible.");
// qDebug("%s > %s", qPrintable(toolTip), qPrintable(action->toolTip()));
QVERIFY2(toolTip.length() > action->toolTip().length(), "The Keyboard shortcut should be visible.");

action->setWhatsThis(QStringLiteral("action's whatsThis"));
const QString toolTipWithWhatsThisHint(shownToolTip(m_toolButton));
QVERIFY(toolTipWithWhatsThisHint.contains(toolTip));
//qDebug("%s > %s", qPrintable(toolTipWithWhatsThisHint), qPrintable(toolTip));
QVERIFY2(toolTipWithWhatsThisHint.length() > toolTip.length(),
"The whatsThisHint should be visible.");
// qDebug("%s > %s", qPrintable(toolTipWithWhatsThisHint), qPrintable(toolTip));
QVERIFY2(toolTipWithWhatsThisHint.length() > toolTip.length(), "The whatsThisHint should be visible.");

action->setShortcut(QKeySequence());
QVERIFY(shownToolTip(m_toolButton).length() < toolTipWithWhatsThisHint.length());
Expand All @@ -161,12 +168,10 @@ void KToolTipHelper_UnitTest::testQToolButton()
QCOMPARE(shownToolTip(m_toolButton), action->toolTip());

action->setToolTip(KToolTipHelper::whatsThisHintOnly());
QVERIFY2(shownToolTip(m_toolButton).isEmpty(),
"It should not show the whatsThisHint if there is no whatsThis text.");
QVERIFY2(shownToolTip(m_toolButton).isEmpty(), "It should not show the whatsThisHint if there is no whatsThis text.");

action->setWhatsThis(QStringLiteral("action's whatsThis"));
QVERIFY2(!shownToolTip(m_toolButton).isEmpty(),
"The whatsThisHint should be shown.");
QVERIFY2(!shownToolTip(m_toolButton).isEmpty(), "The whatsThisHint should be shown.");
}

void KToolTipHelper_UnitTest::testQMenu()
Expand All @@ -186,8 +191,7 @@ void KToolTipHelper_UnitTest::testQMenu()

action->setWhatsThis(QStringLiteral("action's whatsThis"));
const QString toolTipWithWhatsThisHint(shownToolTip(menu.get()));
QVERIFY2(toolTipWithWhatsThisHint.length() > toolTip.length(),
"The tooltip is supposed to contain a whatsThisHint.");
QVERIFY2(toolTipWithWhatsThisHint.length() > toolTip.length(), "The tooltip is supposed to contain a whatsThisHint.");

action->setToolTip(KToolTipHelper::whatsThisHintOnly());
QVERIFY(shownToolTip(menu.get()).length() < toolTipWithWhatsThisHint.length());
Expand All @@ -196,11 +200,9 @@ void KToolTipHelper_UnitTest::testQMenu()
QVERIFY(shownToolTip(menu.get()).isEmpty());
}


void KToolTipHelper_UnitTest::cleanupTestCase()
{
qApp->removeEventFilter(KToolTipHelper::instance());
}


QTEST_MAIN(KToolTipHelper_UnitTest)
55 changes: 55 additions & 0 deletions autotests/kxmlgui_unittest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
#include <QDebug>
#include <QDialogButtonBox>
#include <QDir>
#include <QHBoxLayout>
#include <QMenuBar>
#include <QPushButton>
#include <QShowEvent>
#include <QTest>
#include <QWidget>

#include <KConfigGroup>
#include <KSharedConfig>
Expand Down Expand Up @@ -747,6 +749,59 @@ void KXmlGui_UnitTest::testHiddenToolBar()
mainWindow.close();
}

void KXmlGui_UnitTest::testCustomPlaceToolBar()
{
const QByteArray xml =
"<?xml version = '1.0'?>\n"
"<!DOCTYPE gui SYSTEM \"kpartgui.dtd\">\n"
"<gui version=\"1\" name=\"foo\" >\n"
"<MenuBar>\n"
"</MenuBar>\n"
"<ToolBar name=\"mainToolBar\" noMerge=\"1\">\n"
" <text>Main Toolbar</text>\n"
" <Action name=\"go_up\"/>\n"
"</ToolBar>\n"
"<ToolBar name=\"customToolBar\" noMerge=\"1\">\n"
" <text>Custom Toolbar</text>\n"
" <Action name=\"go_up\"/>\n"
" <Action name=\"file_open\"/>\n"
" <Action name=\"help_about_kde\"/>\n"
"</ToolBar>\n"
"</gui>\n";
KConfigGroup cg(KSharedConfig::openConfig(), "testHiddenToolBar");
TestXmlGuiWindow mw(xml, "kxmlgui_unittest.rc");
mw.setAutoSaveSettings(cg);

QWidget *centralWidget = new QWidget(&mw);
centralWidget->setGeometry(0, 0, 100, 100);
mw.setCentralWidget(centralWidget);
QHBoxLayout *layout = new QHBoxLayout(centralWidget);
KToolBar *customToolBar = new KToolBar(QStringLiteral("customToolBar"), centralWidget);
layout->addWidget(customToolBar);

mw.createActions(QStringList() << QStringLiteral("go_up"));
mw.createGUI();

QVERIFY(centralWidget->findChild<KToolBar *>(QStringLiteral("customToolBar")) != nullptr);

QVERIFY2(mw.toolBarArea(customToolBar) == Qt::NoToolBarArea, "The custom toolbar should not be in a ToolBarArea of the main window");

// Now open KEditToolBar, just to check it doesn't crash on apply
KXMLGUIFactory *factory = mw.guiFactory();
KEditToolBar editToolBar(factory);
// KEditToolBar loads the stuff in showEvent...
QShowEvent ev;
qApp->sendEvent(&editToolBar, &ev);
clickApply(&editToolBar);

QVERIFY2(centralWidget->findChild<KToolBar *>(QStringLiteral("customToolBar")) != nullptr,
"After a KEditToolBar action the custom toolbar should stay in the widget it was orignally added");
QVERIFY2(mw.toolBarArea(mw.toolBarByName(QStringLiteral("customToolBar"))) == Qt::NoToolBarArea,
"After a KEditToolBar action the custom toolbar should not be in a ToolBarArea of the main window");

mw.close();
}

// taken from KMainWindow_UnitTest::testAutoSaveSettings()
void KXmlGui_UnitTest::testAutoSaveSettings()
{
Expand Down
1 change: 1 addition & 0 deletions autotests/kxmlgui_unittest.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ private Q_SLOTS:
void testUiStandardsMerging();
void testActionListAndSeparator();
void testHiddenToolBar();
void testCustomPlaceToolBar();
void testDeletedContainers();
void testAutoSaveSettings();
void testXMLFileReplacement();
Expand Down
Loading

0 comments on commit 7d485b9

Please sign in to comment.