The kde4_add_executable macro uses, should be changed into CMake's add_executable command.

The NOGUI tag in kde4_add_executable should be replaced by the ecm_mark_nongui_executable() macro in ECM

The TEST tag in kde4_add_executable should be replaced by the ecm_mark_as_test() macro in ECM

The kde4_add_plugin uses, should be changed for add_library(... MODULE ...). If WITH_PREFIX was being used, you'll have to tell CMake what prefix you want: set_target_properties(<targetname> PROPERTIES PREFIX "${CMAKE_SHARED_LIBRARY_PREFIX}")

KDE4_ADD_KDEINIT_EXECUTABLE should be turned into KF5_ADD_KDEINIT_EXECUTABLE, provided by KF5InitMacros.cmake.

include directories are automatically generated from specified target_link_library parameters, e.g., to include KTextEditor headers, add "KF5::TextEditor" to the target_link_libraries call.

kde4_add_unit_test(name sources) should be changed to add_executable(name sources) and add_test(lib-name name) and ecm_mark_as_test(name)

KArchive::writeFile takes arguments in a different order from before, so that "user" and "group" are now optional, and so that const char* data, qint64 size could be replaced with a QByteArray.

KTemporaryFile is deprecated, port to QTemporaryFile instead, see KTemporaryFile API documentation for details. (Use kde-dev-scripts/kf5/convert-ktemporaryfile.pl to automate most of the conversion. )

KTempDir is deprecated, port to QTemporaryDir instead, see KTempDir API documentation for details. (Use kde-dev-scripts/kf5/convert-ktempdir.pl to automate most of the conversion. )

KToolInvocation::invokeHelp is now KHelpClient::invokeHelp, in the KConfigWidgets framework.

KToolInvocation::klauncher() has been removed. Use startKdeinit if you just want kdeinit/klauncher to be running. For setLaunchEnv(), generate klauncher_iface.h from the installed org.kde.KLauncher.xml.

KMD5 is deprecated, port to QCryptographicHash instead. (Use kde-dev-scripts/kf5/convert-kmd5.pl to automate most of the conversion.)

qtest_kde.h is deprecated. Port to <QtTest>, for core tests, or to <QtTestWidgets> for tests that use widgets, otherwise they'll crash in code that requires QApplication internally.

K_EXPORT_PLUGIN is deprecated. Either use Qt's native plugin system for simple plugins, or the K_PLUGIN_FACTORY or the K_PLUGIN_FACTORY_WITH_JSON macro, defined in kpluginfactory.h. In both cases, remove the K_EXPORT_PLUGIN macro from your code. This case is indicated by the K_EXPORT_PLUGIN_is_deprecated_see_KDE5PORTING warning. More details about the plugin factory changes are explained in this blog post.

KAuthorized::authorizeUrlAction and KAuthorized::allowUrlAction have been moved to a new KUrlAuthorized namespace.

KDebug is deprecated, use QDebug or QLogginCategory instead.

For non-categorized logging:

kDebug() ➙ qDebug()

kError() ➙ qCritical()

kFatal() ➙ qFatal()

kWarning() ➙ qWarning()

Use kde-dev-scripts/kf5/convert-kdebug.pl to automate most of the conversion.

For categorized logging like kDebug(1221), see the kDebug -> qCDebug porting guide. (Use kde-dev-scripts/kf5/convert-kdebug-with-argument.sh to automate most of the conversion. )

KComponentData

The class is in kde4support now. Port away from it. In your main(), just remove the instantiation, use QCoreApplication::setApplicationName and QCoreApplication::setApplicationDisplayName instead. In plugins, see KPluginFactory/KPluginLoader.

dirs() has been removed. You can use kde4support's KGlobal::dirs, but better port to QStandardPaths. The only difference (for other KComponentData instances than the main one), is the "appdata" resource, which would now point to the application name rather than the component name. It's cleaner to use "data" anyway (or QStandardPaths::GenericDataLocation), and prepend the component name to the searched file.

KCmdLineArgs

Port to QCommandLineParser instead.

A major difference is that KCmdLineArgs was set up before KApplication, while QCommandLineParser should be set up after creating the Q[Core]Application. This allows to use i18n() or tr() in the option definitions.

Use kde-dev-scripts/kf5/convert-kcmdlineargs.pl to automate most of the conversion.

KAboutData

Make sure to call KAboutData::setApplicationData() from the main() of the application.

KAboutData::LicenseKey enums (e.g. KAboutData::License_LGPL) have all been moved to KAboutLicense in the KCoreAddons framework (KAboutLicense::LGPL, in this example).

KAboutData::catalogName and setCatalogName are gone, as is the constructor taking a catalogName. For KF5 software you want to use KLocalizedString::setApplicationDomain to set your translation catalog before constructing KAboutData. Alternately, there is still K4AboutData for temporary compatibility help while porting.

KCmdLineArgs uses K4AboutData rather than KAboutData: K4AboutData keeps the old mechanism for delayed translations (I18N_NOOP), while KAboutData is the one used by plugins, which can use immediate translation (i18n).

URL

KUrl has been deprecated in favour of QUrl. Warning: look at the KUrl documentation for proper porting. Do not just do a global search-and-replace. In particular:

KUrl(QString) means "absolute local file or absolute url" while QUrl(QString) means "relative url or absolute url", so for local files you have to use QUrl::fromLocalFile(QString), or if it could be local-or-remote, use QUrl::fromUserInput(QString).

KUrl u; u.setPath("/tmp"); would make it file:///tmp, while QUrl u; u.setPath("/tmp"); is an incomplete URL, without a scheme. The correct way with QUrl is QUrl::fromLocalFile("/tmp").

KUrl also provided the KUrl::List class that was mainly a QList of KUrl objects with some static helper methods to deal with MIME data. It should now be a QList<QUrl>, and the following changes should be made

KMimeType::findByPath(path, 0, true) ➙ db.mimeTypeForFile(path, QMimeDatabase::MatchExtension) (this is slightly different in case of conflicting globs though, findByPath used to return empty, so that delayed mimetype determination could then refine this; mimeTypesForFileName can be useful to detect this case. But for most applications this detail doesn't matter).

KMimeType::iconNameForUrl(url) has additional logic on top of db.mimeTypeForUrl(url).iconName(), to fallback to the protocol-specific icon (e.g. trash icon for trash:/, etc.). This logic has now moved to KIO::iconNameForUrl(from kio/global.h).

KMimeType::patterns() ➙ QMimeType::globPatterns()

KMimeType::allMimeTypes() ➙ db.allMimeTypes()

KMimeType::comment and KMimeType::iconName no longer take a KUrl argument. If you were passing such an argument (to support .directory files in directories), port the code to KFileItem::mimeComment and KFileItem::iconName.

The following fake MIME types have been removed and should be replaced as follows:

all/allfiles ➙ application/octet-stream

all/all ➙ application/octet-stream+inode/directory

uri/{mms,mmst,mmsu,pnm,rtspt,rtsptu} ➙ x-scheme-handler/...

Config

KConfig and KDesktopFile have been ported to QStandardPaths. This changes the "const char* resourceType" in the API into QStandardPaths::StandardLocation, and means that modifying the "config" resource before using KConfig has no effect on KConfig anymore.

Replace all uses of KGlobal::setLocale() with QLocale::setDefault(myLocale)

QLocale does not allow changing of default formats, i.e. with KLocale you could call "KGlobal::locale()->setDateFormat("%y-%M-%d")" to change the applications default date format, you cannot do this with QLocale. You must use the standard QLocale custom formatters each time, e.g. "QLocale().toString("yyyy-MM-dd)", or set a new application default QLocale using "QLocale::setDefault()".

QLocale formatter/parser methods are named as toString()/toDate() pairs rather than formatDate()/readDate() pairs as in KLocale, and take different enum or format strings. See the QLocale docs for full details.

QLocale date and time formatting does not use the POSIX format codes like "%y-%M-%d", you need to use the Qt format codes like "yyyy-MM-dd" instead.

QLocale does not have an option for formatByteSize(), FancyDate, formatDuration(), or prettyFormatDuration(), use KCoreAddons::KFormat instead.

Translations

Translations are now entirely handled in the Ki18n library, primarily the KLocalizedString class.

Translation catalogs are no longer dynamically inserted, so the idiom KGlobal::locale()->insertCatalog("somecatalog") is no longer available. To simply make the code build, for the sake of porting other things first, just remove or comment out these calls. This will stop translations from working, and to fully port them eventually, follow the section "Connecting Calls to Catalogs" in ki18n programmer's guide.

i18n*() functions no longer handle KUIT markup. If you use KUIT markup, use the new xi18n*() functions.

Date / Time

KDateTime, KCalendarSystem, KLocalizedDate, KTimeZone and other related classes have been deprecated and moved to kde4support. Use QDateTime and QTimeZone instead. KCalendarSystem has yet to be replaced by QCalendarSystem (planned for Qt 5.4), the few places that require this must use kde4support or wait for QCalendarSystem.

Replace all instances of KDateTime with QDateTime. The KDateTime api was deliberately very similar to QDateTime, so most method names will be unchanged, but the enums they take, and the constructors, are different:

The KDateTime::Spec class should be removed and the KDateTime::SpecType replaced with Qt::TimeSpec.

KDateTime::ClockTime has no direct Qt::TimeSpec equivalent, but Qt:LocalTime is effectively the same

KDateTime::LocalZone has no direct Qt::TimeSpec equivalent, instead just use Qt::TimeZone with the QTimeZone::systemTimeZone().

KDateTime::Invalid has no Qt::TimeSpec equivalent.

The KDateTime::TimeFormat enum is replaced with Qt::DateFormat

KDateTime::RFCDate and KDateTime::RFCDateDay are replaced by Qt::RFC2822Date, fromString() will accept with or without the day name, toString() does not write the day name so will need to be manually added.

KDateTime::ISODate supported "simplified" and other variant ISO dates like YYYYMMDD, that Qt does not.

KDateTime::RFC3339Date is replaced by Qt:ISODate.

KDateTime::QtTextDate is replaced by Qt::TextDate, but should never be used.

KDateTime::LocalDate is replaced by Qt::LocalDate, but is deprecated and should never be used. Use QLocale methods instead.

The date/time string formats are changed from the POSIX standard (such as "%y %M %d") to the Qt standard which is a hybrid of CLDR and Windows (e.g. "yyyy MM dd").

Replace all calls to the KDateTime or QDateTime toString()/fromString() using the format strings to use the QLocale equivalents instead to ensure that the local calendar system is used.

KDateTime::currentLocalDateTime() is replaced by QDateTime::currentDateTime()

KDateTime::utcOffset() is replaced by QDateTime::offsetFromUtc()

KDateTime::Comparison KDateTime::compare() has no QDateTime equivalent.

Use KDBusService for DBus registration, and optional "unique" behavior

Important: if you create a QApplication (instead of KApplication) after using KCmdLineArgs, do not pass argc and argv to it, but KCmdLineArgs::qtArgc() and KCmdLineArgs::qtArgv(). This can go away when porting away from KCmdLineArgs.

General

KLineEdit: Use QLineEdit instead, setClickMessage(...) becomes setPlaceholderText(...) (Use kde-dev-scripts/kf5/convert-klineedit.pl to automate most of the conversion. )

KIntValidator: Use QIntValidator instead, the only difference was that KIntValidator attempted to support non-decimal bases (but it was broken with prefix and suffix texts, and therefore unused in KDE SC)

KDoubleValidator: Use QDoubleValidator instead (as part of KLocale -> QLocale)

KFloatValidator: Use QDoubleValidator instead (drop-in replacement)

KSvgRenderer: Use QSvgRenderer instead (drop-in replacement)

KCursor: Use QCursor instead

KToolBar::applySettings and KMainWindow::applyMainWindowSettings don't take a "bool force" as second argument anymore (it was unused since KDE3 anyway)

the virtual method KMainWindow::queryExit doesn't exist anymore. Either use queryClose/closeEvent for things that should be done for every window (or simply if there's only ever one window), or connect to QCoreApplication::aboutToQuit for things that should only be done once on shutdown.

KXMessages: the "obsolete = false" argument has been removed from all methods, and int screen has a default value of -1 now. Remove the "-1, false" in all calls. The sendMessage and sendMessageX methods were apparently unused, and have been commented out. Email kde-frameworks-devel at kde.org if you need them back.

KNotification: setComponentData(KComponentData) is now setComponentName(QString), only the component name was used.

KUndoStack: Use QUndoStack with KUndoActions::createUndoAction() and KUndoActions::createRedoAction() instead

KRichTextWidget: createActions() does not take any KActionCollection and returns a list of QAction instead. You could use KActionCollection.addActions(KRichTextWidget.createActions()) instead.

KTextBrowser: Use QTextBrowser instead. The only difference is QTextBrowser does not support "whatsthis:" urls. (Use kde-dev-scripts/kf5/convert-ktextbrowser.pl to automate most of the conversion. )

KTextEditInterface: This was a hack to preserve the ABI. Please use the methods in KTextEdit instead.

KTimeZoneWidget: Was copied as K4TimeZoneWidget in KDE4Support framework. A new KTimeZoneWidget replacement might appear so we freed the name.

KIcon: has been deprecated and moved to kde4support, prefer QIcon. Port KIcon("foo") to QIcon::fromTheme("foo") and KIcon("foo", iconLoaderPtr) to QIcon(new KIconEngine("foo", iconLoaderPtr)) using KIconEngine from the KIconThemes framework. Note: XDG_DATA_DIRS has to be set to allow icons to be found. (Use kde-dev-scripts/kf5/convert-kicon.pl to automate most of the conversion. )

KPixmapSequence now can only be instanced with a fullPath, to use XDG icons use KIconLoader::loadPixmapSequence.

Global Settings

KGlobalSettings::*Font methods are deprecated. Use QFontDatabase::systemFonts(). ::menuFont, ::taskBarFont and ::toolBarFont are not available now (they are provided by the QPA but not public API). If cases needing those arise we'll have to find an alternative

KGlobalSettings::naturalCompare is deprecated, you'll have to specifically read the settings:

Message Box

KMessageBox is no longer a class, but a namespace, as it only had static methods. The KMessageBox namespace spans now in two frameworks:

Queued methods are deprecated and moved to kdelibs4support as kmessagebox_queued.h

All other methods are in kwidgetsaddons as kmessagebox.h

Other changes:

setDontShowAskAgainConfig was renamed to setDontShowAgainConfig

KMessageBox methods now return enums instead of ints. While code using int will continue to build, you are encouraged to switch to enums for better type safety.

KMessageBoxMessageHandler is deprecated and moved to kdelibs4support

Action

KActionCollection and KXMLGUIClient: replace setComponentData with setComponentName and setComponentDisplayName

KAction is deprecated now, use QAction or QWidgetAction. (Use kde-dev-scripts/kf5/convert-kaction.pl to automate most of the conversion. )

Shape and rocker gestures are now handled by KGestureMap. The existing KAction methods related to gesture handling delegate to KGestureMap.

KAction global shortcut handling logic moved to KGlobalAccel. So the KAction::globalShortcutChanged signal was removed and a new corresponding KGlobalAccel::globalShortcutChanged has been added. The signal semantics have not changed.

Gesture

KGestureMap changes:

addGesture renamed to setShapeGesture and setRockerGesture and now allow replacing existing gestures. When this occurs, a warning is traced with qDebug.

new setDefault[Shape|Rocker]Gesture methods allow defining default gestures for an action, providing the functionality removed from KAction.

new shapeGesture and defaultShapeGesture methods retrieves already defined shape gestures for a given action

new rockerGesture and defaultRockerGesture methods retrieves already defined rocker gestures for a given action

Event Filter

KSystemEventFilter was removed as Qt 5 uses XCB instead of XLib. To get the same functionality derive from QAbstractNativeEventFilter, filter XCB events and register the filter in the QCoreApplication:

Dialog

KDialog: It has been deprecated and moved to kde4support. Prefer QDialog. Note that there Ctrl+Enter is not set by default for accepting dialogs, we'd suggest to add them explicitly, especially in cases where QTextEdit is used, since then it's very hard to accept the dialog without using the mouse. You can do so by using:

Style

In styles based on KStyle, this will work out of the box.

KStyle: Was copied as K4Style in KDE4Support framework. New KStyle class has been trimmed down and reimplements only necessary methods to enforce some of the user settings (for example icons). K4Style users should use K_EXPORT_K4STYLE instead of K_EXPORT_STYLE

Toolbar

ToolBar has moved to XMLGUI. If you don't want to depend on XMLGUI, use QToolBar instead, with the following setup:

Set ToolButtonStyle to Qt::ToolButtonFollowStyle, this will make QToolBar use the settings for "Main Toolbar"

Additionally set QToolBar::setProperty("otherToolbar", true) to use settings for "Other toolbars"

Settings from "Other toolbars" will only work on a widget style that derives from KStyle

Font Dialog

Use QFontDialog instead of KFontDialog. Notice that, in the case of KFontDialog::getFont vs QFontDialog::getFont, QFontDialog::getFont returns the selected font instead of the dialog code, and the Accept/Cancel value is returned through a pointer to a boolean value that is passed as the first argument. Also, notice that the flags for KFontDialog::getFont (defined at KFontChooser::DisplayFlag) do not map to those of QFontDialog::getFont (defined at QFontDialog:: FontDialogOptions) and serve a different purpose.

Window Systems

KWindowSystem changes:

NETWinInfo2 class got removed. All methods are merged into NETWinInfo. Use NETWinInfo instead of NETWinInfo2.

KIO Changes

The very common job->ui()->setWindow(widget) has to be ported to KJobWidgets::setWindow(job, widget), because job->ui() is now only a KJobUiDelegate.

The deprecated KIO::Job::showErrorDialog() has been removed, use KJobWidgets::setWindow(job, parent) and job->ui()->showErrorMessage()

The KFileItem API has been ported to QMimeType. As a consequence, mimeTypePtr() is now currentMimeType().

KFileItem::run(QWidget*) has disappeared, due to core/gui separation. Use new KRun(item.targetUrl(), widget) instead.

KFileItem::pixmap(size, state=0) has disappeared, due to core/gui separation. If you can, use KDE::icon(item.iconName(), item.overlays(), 0) instead. If you really need a QPixmap, e.g. for showing in a QLabel, use this instead:

KParts Changes

With the port from KUrl to QUrl in APIs, the signature of the virtual method openUrl has changed, make sure to port your reimplemented methods to QUrl!

TerminalInterfaceV2 has been merged into TerminalInterface, you can remove the "V2" everywhere (classname, interface name).

The installed normal lowercase headers no longer define multiple classes. Now it is only one class per header, with the filename matching the classname (e.g. KParts::ReadOnlyPart is no longer defined in <kparts/part.h> but <kparts/readonlypart.h>). So make sure you now include the matching headers.

ItemViews Changes

KCategoryDrawer margins should be set by overriding the leftMargin/rightMargin methods as appropriate.

KWidgetItemDelegate::createItemWidgets now has an QModelIndex with the index to create widgets for. It does not need to be used

KArchive Changes

KFilterBase::findFilterByFileName and KFilterBase::findFilterByMimeType are gone, now you should use KCompressionDevice::filterForCompressionType

To get the CompressionType you can call KFilterDev::compressionTypeForMimeType

KEmoticons Changes

KEmoticonsProvider::save is deprecated, instead you should use KEmoticonsProvider::saveTheme

KEmoticonsTheme::save is deprecated, instead you should subclass KEmoticonsProvider and implement the pure virtual method KEmoticonsProvider::saveTheme

KEmoticonsProvider::createNew is deprecated, instead you should use KEmoticonsProvider::newTheme

KEmoticonsTheme::createNew is deprecated, instead you should subclass KEmoticonsProvider and implement the pure virtual method KEmoticonsProvider::newTheme

KEmoticonsProvider::addEmoticonsMap is deprecated, instead you should use KEmoticonsProvider::addMapItem

KEmoticonsProvider::removeEmoticonsMap is deprecated, instead you should use KEmoticonsProvider::removeMapItem

KEmoticonsProvider::addEmoticonIndex is deprecated, instead you should use KEmoticonsProvider::addIndexItem

KEmoticonsProvider::removeEmoticonIndex is deprecated, instead you should use KEmoticonsProvider::removeIndexItem

KEmoticonsTheme::loadTheme is deprecated, instead you should subclass KEmoticonsProvider and implement the pure virtual method KEmoticonsProvider::loadTheme

KEmoticonsTheme::addEmoticon is deprecated, instead you should subclass KEmoticonsProvider and implement the pure virtual method KEmoticonsProvider::addEmoticon

KEmoticonsTheme::removeEmoticon is deprecated, instead you should subclass KEmoticonsProvider and implement the pure virtual method KEmoticonsProvider::removeEmoticon

KDNSSD Changes

The include paths has changed from dnssd to kdnssd

The namespace has changed from DNSSD to KDNSSD

KNewStuff3 Changes

The include paths has changed from knewstuff3 to kns3 (Use kde-dev-scripts/kf5/adapt_knewstuff3_includes.pl to automate most of the conversion. )

KUnitConversion Changes

KUnitConversion is now a separate Tier 2 Framework, you need to link to KF5::UnitConversion

The Convertor, CategoryUnit, Unit and Value classes are all now standard Qt shared data containers, i.e. like QString. Each class is either implicitly or explicitly shared as appropriate, and should be passed by const references. The main impact of this is that existing code will need to change from calling of methods from -> to . notation.

The api now uses the enums instead of int

The api now uses qreal instead of double

The custom constructors and protected setters have been removed. If you require adding custom units, please contact the maintainer to discuss.

(The changes are "V4.2" to "V4.5" and "dtd/kdex.dtd" to "dtd/kdedbx45.dtd").

KAuth Changes

KDE4_AUTH_HELPER_MAIN should be replaced by KAUTH_HELPER_MAIN

Solid Changes

Interfaces

DvbInterface: We only supported linux plus usually this is used together with a multimedia framework. Users of this interface will be better suited using that multimedia framework to get a list of devices.

Video: We only supported linux plus usually this is used together with a multimedia framework. Users of this interface will be better suited using that multimedia framework to get a list of devices.

Button: New Async api will be added to announce button availability and state.

NetworkInterface: Use QNetworkConfigurationManager.

InternetGateway: This class mattered only for UPnP, we never had proper UPnP support so if you were using this just remove any usage.

SerialInterface: You can use UdevQt (you can find that inside Solid) for the time being. New api will be added to QtSerialport.

AudioInterface: We were only supporting Alsa here, if you were using this either use Alsa directly or UdevQt.

SmartCardReader: This was not even working since we moved from HAL (4 years ago). If you are using this please remove any usage of it.

Solid Networking

QNetworkConfigurationManager does most of the things Solid/Networking did.

Solid Powermanagement

New async api will be added, W.I.P

libkonq

KonqMimeData::populateMimeData(mimeData, kdeUrls, mostLocalUrls, cut) is now

or if one of the two URL lists was always empty, just mimeData->setUrls(urls);

KonqMimeData::addIsCutSelection(mimeData, cut) is now KIO::setClipboardDataCut(mimeData, cut);

KonqMimeData::decodeIsCutSelection is now KIO::isClipboardDataCut.

KonqStatusbarMessageLabel has moved back to konqueror, its only user.

KonqFileItemCapabilities and KonqPopupMenuInformation were removed, use KFileItemListProperties from KIO.

KonqMenuActions was removed, use KFileItemActions from KIO.

KNewMenu was removed, use KNewFileMenu from KIO.

KonqOperations::restoreTrashedItems should be replaced with

KIO::RestoreJob*job=KIO::restoreFromTrash(urls);KJobWidgets::setWindow(job,m_mainWindow);job->uiDelegate()->setAutoErrorHandlingEnabled(true);// or connect to the result signal

KonqOperations::emptyTrash should be replaced with

KIO::JobUiDelegateuiDelegate;uiDelegate.setWindow(m_mainWindow);if(uiDelegate.askDeleteConfirmation(QList<QUrl>(),KIO::JobUiDelegate::EmptyTrash,KIO::JobUiDelegate::DefaultConfirmation)){KIO::Job*job=KIO::emptyTrash();KJobWidgets::setWindow(job,m_mainWindow);job->ui()->setAutoErrorHandlingEnabled(true);// or connect to the result signal}

It's a bit more verbose, but you can choose how you want to ask confirmation and how you want to handle errors.

KonqOperations::askDeleteConfirmation should be replaced with uiDelegate.askDeleteConfirmation as in the example above.

KonqOperations::del should be replaced with

KIO::JobUiDelegateuiDelegate;uiDelegate.setWindow(m_mainWindow);if(uiDelegate.askDeleteConfirmation(urls,KIO::JobUiDelegate::TrashorDelete,KIO::JobUiDelegate::DefaultConfirmation)){KIO::Job*job=KIO::del(urls);// or KIO::trash(urls)KJobWidgets::setWindow(job,m_mainWindow);job->ui()->setAutoErrorHandlingEnabled(true);// or connect to the result signal}