diff --git a/CMakeLists.txt b/CMakeLists.txt index 578380458..46a117d5b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,19 +1,52 @@ project(Konsole) -find_package(KDE4 4.7.0 REQUIRED) +option(QT5_BUILD "Build using Qt5" OFF) +include(FeatureSummary) +if(QT5_BUILD) + find_package(Qt5Core NO_MODULE) + set_package_properties(Qt5Core PROPERTIES TYPE REQUIRED) + message(STATUS "Qt5 build") + find_package(ECM 0.0.9 NO_MODULE) + set_package_properties(ECM PROPERTIES TYPE REQUIRED) + set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH}) + find_package(Qt5Transitional MODULE) + set_package_properties(Qt5Transitional PROPERTIES TYPE REQUIRED) + find_package(kdeqt5staging NO_MODULE) + set_package_properties(kdeqt5staging PROPERTIES TYPE REQUIRED) + find_package(KF5 MODULE REQUIRED COMPONENTS CMake Compiler InstallDirs + KDBusAddons KCoreAddons KConfig + KCodecs KI18n KService KWidgetsAddons + KWindowSystem KCrash Sonnet + KArchive ItemModels KAuth KGuiAddons KConfigWidgets + ItemViews KNotifications KJS + KJobWidgets KIconThemes KCompletion KTextWidgets + XmlGui Solid KWallet KIO KUnitConversion KDE4Attic + ) + find_package(KDELibs4 NO_MODULE) #needed for KDE4Support + set_package_properties(KDELibs4 PROPERTIES TYPE REQUIRED) + find_package(KDE4Support NO_MODULE) + set_package_properties(KDE4Support PROPERTIES TYPE REQUIRED) + remove_definitions(-DQT_NO_SIGNALS_SLOTS_KEYWORDS -DQT_NO_CAST_FROM_ASCII) + add_definitions(-Wno-deprecated-declarations) + set(KDE4_KIO_LIBS ${KDE4_KIO_LIBS} ${KDE4Support_LIBRARIES}) +else() + message(STATUS "Qt4 build") + find_package(KDE4 4.10.0) + set_package_properties(KDE4 PROPERTIES TYPE REQUIRED) + include(KDE4Defaults) + add_definitions(${QT_DEFINITIONS} ${KDE4_DEFINITIONS}) + kde4_no_enable_final(konsole) +endif() + -include(KDE4Defaults) -add_definitions(${QT_DEFINITIONS} ${KDE4_DEFINITIONS}) add_definitions(-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS) add_definitions(-DKDE_DEFAULT_DEBUG_AREA=1211) include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${KDE4_INCLUDES}) -kde4_no_enable_final(konsole) - add_subdirectory( src ) add_subdirectory( data ) add_subdirectory( desktop ) add_subdirectory( doc/manual ) -macro_display_feature_log() +feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/src/BookmarkHandler.cpp b/src/BookmarkHandler.cpp index 9fc1600aa..a270d235b 100644 --- a/src/BookmarkHandler.cpp +++ b/src/BookmarkHandler.cpp @@ -31,6 +31,8 @@ #include #include #include +#include +#include // Konsole #include "ViewProperties.h" @@ -38,7 +40,11 @@ using namespace Konsole; BookmarkHandler::BookmarkHandler(KActionCollection* collection, +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) KMenu* menu, +#else + QMenu* menu, +#endif bool toplevel, QObject* parent) : QObject(parent), diff --git a/src/BookmarkHandler.h b/src/BookmarkHandler.h index 76c33269e..cd95d8062 100644 --- a/src/BookmarkHandler.h +++ b/src/BookmarkHandler.h @@ -26,11 +26,13 @@ // KDE #include +#include // Konsole #include "konsole_export.h" class KMenu; +class QMenu; class KBookmarkMenu; class KActionCollection; @@ -62,7 +64,11 @@ public: * @param toplevel TODO: Document me * @param parent The parent object */ +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) BookmarkHandler(KActionCollection* collection , KMenu* menu, bool toplevel , QObject* parent); +#else + BookmarkHandler(KActionCollection* collection , QMenu* menu, bool toplevel , QObject* parent); +#endif ~BookmarkHandler(); virtual QString currentUrl() const; @@ -75,7 +81,11 @@ public: /** * Returns the menu which this bookmark handler inserts its actions into. */ +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) KMenu* menu() const { +#else + QMenu* menu() const { +#endif return _menu; } @@ -105,7 +115,11 @@ signals: * @param urls The urls of the bookmarks in the folder whose * 'Open Folder in Tabs' action was triggered */ +#if QT_VERSION < 0x50000 //moc doesn't understand the QT_VERSION_CHECK macro void openUrls(const QList& urls); +#else + void openUrls(const QList& urls); +#endif private slots: void openBookmark(const KBookmark& bm, Qt::MouseButtons, Qt::KeyboardModifiers); @@ -114,7 +128,11 @@ private: QString titleForView(ViewProperties* view) const; QString urlForView(ViewProperties* view) const; +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) KMenu* _menu; +#else + QMenu* _menu; +#endif KBookmarkMenu* _bookmarkMenu; QString _file; bool _toplevel; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 48601a147..2693e6008 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,11 +1,13 @@ -# cmake-options : -WITH_LibKonq=ON or OFF; default is ON -macro_optional_find_package(LibKonq) -macro_bool_to_01(LIBKONQ_FOUND HAVE_LIBKONQ) +# cmake-options : -DCMAKE_DISABLE_FIND_PACKAGE_LibKonq=TRUE or FALSE; default is FALSE -macro_log_feature(LIBKONQ_FOUND "LibKonq" - "Provides high-level file management functions" - "https://projects.kde.org/projects/kde/applications/kde-baseapps" - FALSE "" "Required for drag-n-drop menus") +if (NOT QT5_BUILD) # there is no libkonq for Qt5 yet + find_package(LibKonq) + set_package_properties(LibKonq PROPERTIES DESCRIPTION "Provides high-level file management functions" + URL "https://projects.kde.org/projects/kde/applications/kde-baseapps" TYPE OPTIONAL + PURPOSE "Required for drag-n-drop menus") +endif() + +macro_bool_to_01(LIBKONQ_FOUND HAVE_LIBKONQ) if(HAVE_LIBKONQ) include_directories(${LIBKONQ_INCLUDE_DIR}) diff --git a/src/ColorScheme.cpp b/src/ColorScheme.cpp index 6945c3914..53bfb8646 100644 --- a/src/ColorScheme.cpp +++ b/src/ColorScheme.cpp @@ -292,7 +292,7 @@ void ColorScheme::read(const KConfig& config) const QString schemeDescription = configGroup.readEntry("Description", I18N_NOOP("Un-named Color Scheme")); - _description = i18n(schemeDescription.toUtf8()); + _description = i18n(schemeDescription.toUtf8().constData()); _opacity = configGroup.readEntry("Opacity", qreal(1.0)); setWallpaper(configGroup.readEntry("Wallpaper", QString())); diff --git a/src/ColorSchemeEditor.cpp b/src/ColorSchemeEditor.cpp index afe13c3a4..93a8a9f01 100644 --- a/src/ColorSchemeEditor.cpp +++ b/src/ColorSchemeEditor.cpp @@ -29,6 +29,9 @@ #include #include #include +#include +#include +#include // Konsole #include "ui_ColorSchemeEditor.h" @@ -156,7 +159,7 @@ void ColorSchemeEditor::editColorItem(QTableWidgetItem* item) } void ColorSchemeEditor::selectWallpaper() { - const KUrl url = KFileDialog::getImageOpenUrl(_ui->wallpaperPath->text(), + const KUrl url = KFileDialog::getImageOpenUrl(KUrl(_ui->wallpaperPath->text()), this, i18nc("@action:button", "Select wallpaper image file")); diff --git a/src/ColorSchemeManager.cpp b/src/ColorSchemeManager.cpp index 802f5d7f9..8fe888ab4 100644 --- a/src/ColorSchemeManager.cpp +++ b/src/ColorSchemeManager.cpp @@ -149,7 +149,7 @@ bool KDE3ColorSchemeReader::readTitleLine(const QString& line, ColorScheme* sche QString description = line.mid(spacePos + 1); - scheme->setDescription(i18n(description.toUtf8())); + scheme->setDescription(i18n(description.toUtf8().constData())); return true; } diff --git a/src/EditProfileDialog.cpp b/src/EditProfileDialog.cpp index cf7be3d72..0c5c143c0 100644 --- a/src/EditProfileDialog.cpp +++ b/src/EditProfileDialog.cpp @@ -48,6 +48,7 @@ #include #include #include +#include // Konsole #include "ColorScheme.h" @@ -261,7 +262,11 @@ void EditProfileDialog::setupGeneralPage(const Profile::Ptr profile) _ui->commandEdit->setText(command.fullCommand()); KUrlCompletion* exeCompletion = new KUrlCompletion(KUrlCompletion::ExeCompletion); exeCompletion->setParent(this); +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) exeCompletion->setDir(QString()); +#else + exeCompletion->setDir(QUrl()); +#endif _ui->commandEdit->setCompletionObject(exeCompletion); _ui->initialDirEdit->setText(profile->defaultWorkingDirectory()); @@ -395,7 +400,7 @@ void EditProfileDialog::commandChanged(const QString& command) } void EditProfileDialog::selectInitialDir() { - const KUrl url = KFileDialog::getExistingDirectoryUrl(_ui->initialDirEdit->text(), + const KUrl url = KFileDialog::getExistingDirectoryUrl(KUrl(_ui->initialDirEdit->text()), this, i18n("Select Initial Directory")); @@ -1213,7 +1218,11 @@ void EditProfileDialog::showFontDialog() QFont currentFont = _ui->fontPreviewLabel->font(); QWeakPointer dialog = new KFontDialog(this, KFontChooser::FixedFontsOnly); +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) dialog.data()->setCaption(i18n("Select Fixed Width Font")); +#else + dialog.data()->setWindowTitle(i18n("Select Fixed Width Font")); +#endif dialog.data()->setFont(currentFont, true); // TODO (hindenburg): When https://git.reviewboard.kde.org/r/103357 is diff --git a/src/Emulation.cpp b/src/Emulation.cpp index 02ed4be48..172032058 100644 --- a/src/Emulation.cpp +++ b/src/Emulation.cpp @@ -192,7 +192,7 @@ void Emulation::sendKeyEvent(QKeyEvent* ev) // A block of text // Note that the text is proper unicode. // We should do a conversion here - emit sendData(ev->text().toUtf8(), ev->text().length()); + emit sendData(ev->text().toUtf8().constData(), ev->text().length()); } } diff --git a/src/Filter.cpp b/src/Filter.cpp index 8f40c0c59..8ea6eed57 100644 --- a/src/Filter.cpp +++ b/src/Filter.cpp @@ -30,6 +30,7 @@ // KDE #include #include +#include // Konsole #include "TerminalCharacterDecoder.h" @@ -423,7 +424,7 @@ void UrlFilter::HotSpot::activate(QObject* object) url.prepend("mailto:"); } - new KRun(url, QApplication::activeWindow()); + new KRun(KUrl(url), QApplication::activeWindow()); } } diff --git a/src/KeyBindingEditor.cpp b/src/KeyBindingEditor.cpp index 005b9e320..7a4885707 100644 --- a/src/KeyBindingEditor.cpp +++ b/src/KeyBindingEditor.cpp @@ -22,6 +22,8 @@ // Qt #include +// KDE +#include // Konsole #include "ui_KeyBindingEditor.h" diff --git a/src/KeyboardTranslator.cpp b/src/KeyboardTranslator.cpp index 8fe2acb40..879b3023f 100644 --- a/src/KeyboardTranslator.cpp +++ b/src/KeyboardTranslator.cpp @@ -90,7 +90,7 @@ KeyboardTranslatorReader::KeyboardTranslatorReader(QIODevice* source) while (_description.isEmpty() && !source->atEnd()) { QList tokens = tokenize(QString::fromLocal8Bit(source->readLine())); if (!tokens.isEmpty() && tokens.first().type == Token::TitleKeyword) - _description = i18n(tokens[1].text.toUtf8()); + _description = i18n(tokens[1].text.toUtf8().constData()); } // read first entry (if any) readNext(); diff --git a/src/KeyboardTranslator.h b/src/KeyboardTranslator.h index 99c71743d..8ad94b293 100644 --- a/src/KeyboardTranslator.h +++ b/src/KeyboardTranslator.h @@ -25,6 +25,7 @@ // Qt #include #include +#include //#include #include diff --git a/src/KeyboardTranslatorManager.cpp b/src/KeyboardTranslatorManager.cpp index 4d4621051..dc891e9a7 100644 --- a/src/KeyboardTranslatorManager.cpp +++ b/src/KeyboardTranslatorManager.cpp @@ -28,6 +28,7 @@ // KDE #include +#include #include using namespace Konsole; diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 285d6347b..823231ccc 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -42,6 +42,8 @@ #include #include #include +#include +#include // Konsole #include "BookmarkHandler.h" @@ -153,7 +155,9 @@ void MainWindow::removeMenuAccelerators() { foreach(QAction* menuItem, menuBar()->actions()) { QString itemText = menuItem->text(); +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) itemText = KGlobal::locale()->removeAcceleratorMarker(itemText); +#endif menuItem->setText(itemText); } } @@ -283,12 +287,18 @@ IncrementalSearchBar* MainWindow::searchBar() const void MainWindow::setupActions() { KActionCollection* collection = actionCollection(); +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) KAction* menuAction = 0; +#else + QAction* menuAction = 0; +#endif // File Menu _newTabMenuAction = new KActionMenu(KIcon("tab-new"), i18nc("@action:inmenu", "&New Tab"), collection); _newTabMenuAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_T)); +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) _newTabMenuAction->setShortcutConfigurable(true); +#endif _newTabMenuAction->setAutoRepeat(false); connect(_newTabMenuAction, SIGNAL(triggered()), this, SLOT(newTab())); collection->addAction("new-tab", _newTabMenuAction); @@ -317,7 +327,11 @@ void MainWindow::setupActions() KActionMenu* bookmarkMenu = new KActionMenu(i18nc("@title:menu", "&Bookmarks"), collection); _bookmarkHandler = new BookmarkHandler(collection, bookmarkMenu->menu(), true, this); collection->addAction("bookmark", bookmarkMenu); +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) connect(_bookmarkHandler, SIGNAL(openUrls(QList)), this, SLOT(openUrls(QList))); +#else + connect(_bookmarkHandler, SIGNAL(openUrls(QList)), this, SLOT(openUrls(QList))); +#endif // Settings Menu _toggleMenuBarAction = KStandardAction::showMenubar(menuBar(), SLOT(setVisible(bool)), collection); @@ -373,7 +387,12 @@ void MainWindow::profileListChanged(const QList& sessionActions) // it if it is the non-default profile. if (sessionActions.size() > 2) { // Update the 'New Tab' KActionMenu +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) KMenu* newTabMenu = _newTabMenuAction->menu(); +#else + QMenu* newTabMenu = _newTabMenuAction->menu(); +#endif + newTabMenu->clear(); foreach(QAction* sessionAction, sessionActions) { newTabMenu->addAction(sessionAction); @@ -389,7 +408,11 @@ void MainWindow::profileListChanged(const QList& sessionActions) } } } else { +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) KMenu* newTabMenu = _newTabMenuAction->menu(); +#else + QMenu* newTabMenu = _newTabMenuAction->menu(); +#endif newTabMenu->clear(); Profile::Ptr profile = ProfileManager::instance()->defaultProfile(); @@ -416,7 +439,11 @@ QString MainWindow::activeSessionDir() const } } +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) void MainWindow::openUrls(const QList& urls) +#else +void MainWindow::openUrls(const QList& urls) +#endif { Profile::Ptr defaultProfile = ProfileManager::instance()->defaultProfile(); diff --git a/src/MainWindow.h b/src/MainWindow.h index b297883eb..c4b7ee07a 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -163,8 +163,12 @@ private slots: void updateWindowIcon(); void updateWindowCaption(); - +//moc doesn't understand QT_VERSION_CHECK +#if QT_VERSION < 0x50000 void openUrls(const QList& urls); +#else + void openUrls(const QList& urls); +#endif // Sets the list of profiles to be displayed under the "New Tab" action void setProfileList(ProfileList* list); diff --git a/src/Part.cpp b/src/Part.cpp index 33e2d3849..b76ebbdc5 100644 --- a/src/Part.cpp +++ b/src/Part.cpp @@ -30,6 +30,9 @@ #include #include #include +#include +#include +#include #include // Konsole @@ -54,10 +57,12 @@ Part::Part(QWidget* parentWidget , QObject* parent, const QVariantList&) , _pluggedController(0) , _manageProfilesAction(0) { +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) // make sure the konsole catalog is loaded KGlobal::locale()->insertCatalog("konsole"); // make sure the libkonq catalog is loaded( needed for drag & drop ) KGlobal::locale()->insertCatalog("libkonq"); +#endif // setup global actions createGlobalActions(); @@ -321,10 +326,16 @@ void Part::changeSessionSettings(const QString& text) sendInput(command); } - // Konqueror integration +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) bool Part::openUrl(const KUrl& aUrl) { +#else +bool Part::openUrl(const QUrl& aQUrl) +{ + KUrl aUrl = aQUrl; +#endif + if (url() == aUrl) { emit completed(); return true; diff --git a/src/Part.h b/src/Part.h index 2806bcdb0..589a854ea 100644 --- a/src/Part.h +++ b/src/Part.h @@ -33,6 +33,7 @@ class QAction; class QStringList; class QKeyEvent; +class KUrl; namespace Konsole { @@ -191,8 +192,13 @@ signals: protected: /** Reimplemented from KParts::PartBase. */ +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) virtual bool openFile(); virtual bool openUrl(const KUrl& url); +#else + virtual bool openFile() Q_DECL_OVERRIDE; + virtual bool openUrl(const QUrl& url) Q_DECL_OVERRIDE; +#endif private slots: void activeViewChanged(SessionController* controller); @@ -202,7 +208,6 @@ private slots: void newTab(); void overrideTerminalShortcut(QKeyEvent*, bool& override); void sessionStateChanged(int state); - private: Session* activeSession() const; void createGlobalActions(); diff --git a/src/PrintOptions.cpp b/src/PrintOptions.cpp index 5e802987d..31d295f7c 100644 --- a/src/PrintOptions.cpp +++ b/src/PrintOptions.cpp @@ -23,6 +23,7 @@ // KDE #include +#include #include using namespace Konsole; diff --git a/src/Profile.cpp b/src/Profile.cpp index 14946ce69..4480ed6c9 100644 --- a/src/Profile.cpp +++ b/src/Profile.cpp @@ -189,7 +189,7 @@ FallbackProfile::FallbackProfile() setProperty(LineSpacing, 0); setProperty(CursorShape, Enum::BlockCursor); setProperty(UseCustomCursorColor, false); - setProperty(CustomCursorColor, Qt::black); + setProperty(CustomCursorColor, QColor(Qt::black)); setProperty(BellMode, Enum::NotifyBell); setProperty(DefaultEncoding, QString(QTextCodec::codecForLocale()->name())); diff --git a/src/SessionController.cpp b/src/SessionController.cpp index 88fc50c6a..c255ae18b 100644 --- a/src/SessionController.cpp +++ b/src/SessionController.cpp @@ -50,8 +50,10 @@ #include #include #include +#include #include #include +#include #include #if KDE_IS_VERSION(4, 9, 1) @@ -90,9 +92,10 @@ using namespace Konsole; // TODO - Replace the icon choices below when suitable icons for silence and // activity are available -const KIcon SessionController::_activityIcon("dialog-information"); -const KIcon SessionController::_silenceIcon("dialog-information"); -const KIcon SessionController::_broadcastIcon("emblem-important"); +//having global static KIcons no longer works with Qt5/KF5, use K_GLOBAL_STATIC +K_GLOBAL_STATIC_WITH_ARGS(KIcon, _activityIcon, ("dialog-information")); +K_GLOBAL_STATIC_WITH_ARGS(KIcon, _silenceIcon, ("dialog-information")); +K_GLOBAL_STATIC_WITH_ARGS(KIcon, _broadcastIcon, ("emblem-important")); QSet SessionController::_allControllers; int SessionController::_lastControllerId; @@ -548,7 +551,12 @@ void SessionController::setShowMenuAction(QAction* action) void SessionController::setupCommonActions() { +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) KAction* action = 0; +#else + QAction* action = 0; +#endif + KActionCollection* collection = actionCollection(); // Close Session @@ -573,10 +581,17 @@ void SessionController::setupCommonActions() action->setEnabled(false); action = KStandardAction::paste(this, SLOT(paste()), collection); +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) KShortcut pasteShortcut = action->shortcut(); pasteShortcut.setPrimary(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_V)); pasteShortcut.setAlternate(QKeySequence(Qt::SHIFT + Qt::Key_Insert)); action->setShortcut(pasteShortcut); +#else + QList pasteShortcut; + pasteShortcut.append(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_V)); + pasteShortcut.append(QKeySequence(Qt::SHIFT + Qt::Key_Insert)); + action->setShortcuts(pasteShortcut); +#endif action = collection->addAction("paste-selection", this, SLOT(pasteFromX11Selection())); action->setText(i18n("Paste Selection")); @@ -643,7 +658,11 @@ void SessionController::setupCommonActions() void SessionController::setupExtraActions() { +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) KAction* action = 0; +#else + QAction* action = 0; +#endif KToggleAction* toggleAction = 0; KActionCollection* collection = actionCollection(); @@ -702,15 +721,27 @@ void SessionController::setupExtraActions() action = collection->addAction("enlarge-font", this, SLOT(increaseFontSize())); action->setText(i18n("Enlarge Font")); action->setIcon(KIcon("format-font-size-more")); +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) KShortcut enlargeFontShortcut = action->shortcut(); enlargeFontShortcut.setPrimary(QKeySequence(Qt::CTRL + Qt::Key_Plus)); enlargeFontShortcut.setAlternate(QKeySequence(Qt::CTRL + Qt::Key_Equal)); action->setShortcut(enlargeFontShortcut); +#else + QList enlargeFontShortcut; + enlargeFontShortcut.append(QKeySequence(Qt::CTRL + Qt::Key_Plus)); + enlargeFontShortcut.append(QKeySequence(Qt::CTRL + Qt::Key_Equal)); + action->setShortcuts(enlargeFontShortcut); +#endif action = collection->addAction("shrink-font", this, SLOT(decreaseFontSize())); action->setText(i18n("Shrink Font")); action->setIcon(KIcon("format-font-size-less")); +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) action->setShortcut(KShortcut(Qt::CTRL | Qt::Key_Minus)); +#else + action->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_Minus)); +#endif + // Send signal KSelectAction* sendSignalActions = collection->add("send-signal"); @@ -918,10 +949,19 @@ void SessionController::openBrowser() { KUrl currentUrl = url(); - if (currentUrl.isLocalFile()) + if (currentUrl.isLocalFile()) { +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) new KRun(currentUrl, QApplication::activeWindow(), 0, true, true); - else +#else + new KRun(currentUrl, QApplication::activeWindow(), true); +#endif + } else { +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) new KRun(KUrl(QDir::homePath()), QApplication::activeWindow(), 0, true, true); +#else + new KRun(QUrl::fromLocalFile(QDir::homePath()), QApplication::activeWindow(), true); +#endif + } } void SessionController::copy() @@ -1381,7 +1421,7 @@ void SessionController::updateSessionIcon() // Visualize that the session is broadcasting to others if (_copyToGroup && _copyToGroup->sessions().count() > 1) { // Master Mode: set different icon, to warn the user to be careful - setIcon(_broadcastIcon); + setIcon(*_broadcastIcon); } else { if (!_keepIconUntilInteraction) { // Not in Master Mode: use normal icon @@ -1393,7 +1433,11 @@ void SessionController::sessionTitleChanged() { if (_sessionIconName != _session->iconName()) { _sessionIconName = _session->iconName(); +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) _sessionIcon = KIcon(_sessionIconName); +#else + _sessionIcon = QIcon::fromTheme(_sessionIconName); +#endif updateSessionIcon(); } @@ -1484,10 +1528,10 @@ void SessionController::sessionStateChanged(int state) return; if (state == NOTIFYACTIVITY) { - setIcon(_activityIcon); + setIcon(*_activityIcon); _keepIconUntilInteraction = true; } else if (state == NOTIFYSILENCE) { - setIcon(_silenceIcon); + setIcon(*_silenceIcon); _keepIconUntilInteraction = true; } else if (state == NOTIFYNORMAL) { if (_sessionIconName != _session->iconName()) { @@ -1509,7 +1553,7 @@ void SessionController::zmodemDownload() } if (!zmodem.isEmpty()) { const QString path = KFileDialog::getExistingDirectory( - QString(), _view, + KUrl(), _view, i18n("Save ZModem Download to...")); if (!path.isEmpty()) { @@ -1598,7 +1642,7 @@ void SaveHistoryTask::execute() // TODO - show a warning ( preferably passive ) if saving the history output fails // - KFileDialog* dialog = new KFileDialog(QString(":konsole") /* check this */, + KFileDialog* dialog = new KFileDialog(KUrl(QString(":konsole")) /* check this */, QString(), QApplication::activeWindow()); dialog->setOperationMode(KFileDialog::Saving); dialog->setConfirmOverwrite(true); @@ -1612,7 +1656,11 @@ void SaveHistoryTask::execute() // to save that session's history. // then start a KIO job to transfer the data from the history to the chosen URL foreach(const SessionPtr& session, sessions()) { +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) dialog->setCaption(i18n("Save Output From %1", session->title(Session::NameRole))); +#else + dialog->setWindowTitle(i18n("Save Output From %1", session->title(Session::NameRole))); +#endif int result = dialog->exec(); diff --git a/src/SessionController.h b/src/SessionController.h index 036e05349..0fb147a47 100644 --- a/src/SessionController.h +++ b/src/SessionController.h @@ -301,18 +301,22 @@ private: ProfileList* _profileList; +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) KIcon _sessionIcon; +#else + QIcon _sessionIcon; +#endif QString _sessionIconName; int _previousState; UrlFilter* _viewUrlFilter; RegExpFilter* _searchFilter; - KAction* _copyInputToAllTabsAction; + QAction* _copyInputToAllTabsAction; - KAction* _findAction; - KAction* _findNextAction; - KAction* _findPreviousAction; + QAction* _findAction; + QAction* _findNextAction; + QAction* _findPreviousAction; QTimer* _interactionTimer; @@ -336,9 +340,6 @@ private: static QSet _allControllers; static int _lastControllerId; - static const KIcon _activityIcon; - static const KIcon _silenceIcon; - static const KIcon _broadcastIcon; QStringList _bookmarkValidProgramsToClear; diff --git a/src/ShellCommand.cpp b/src/ShellCommand.cpp index 2b059a16e..790b789e9 100644 --- a/src/ShellCommand.cpp +++ b/src/ShellCommand.cpp @@ -141,7 +141,7 @@ bool ShellCommand::expandEnv(QString& text) const int len = endPos - dollarPos; const QString key = text.mid(dollarPos + 1, len - 1); - const QString value = QString::fromLocal8Bit(qgetenv(key.toLocal8Bit())); + const QString value = QString::fromLocal8Bit(qgetenv(key.toLocal8Bit().constData())); if (!value.isEmpty()) { text.replace(dollarPos, len, value); diff --git a/src/TerminalDisplay.cpp b/src/TerminalDisplay.cpp index acfddc176..d0e716db1 100644 --- a/src/TerminalDisplay.cpp +++ b/src/TerminalDisplay.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include // KDE @@ -278,8 +279,12 @@ namespace Konsole QAccessibleInterface* accessibleInterfaceFactory(const QString &key, QObject *object) { Q_UNUSED(key) +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) if (TerminalDisplay *display = qobject_cast(object)) return new TerminalDisplayAccessible(display); +#else +#pragma message("This code needs proper porting to Qt5") +#endif return 0; } } @@ -3088,7 +3093,7 @@ void TerminalDisplay::dropEvent(QDropEvent* event) if (event->mimeData()->hasFormat("text/plain") || event->mimeData()->hasFormat("text/uri-list")) { - emit sendStringToEmu(dropText.toLocal8Bit()); + emit sendStringToEmu(dropText.toLocal8Bit().constData()); } } @@ -3097,7 +3102,7 @@ void TerminalDisplay::dropMenuPasteActionTriggered() if (sender()) { const QAction* action = qobject_cast(sender()); if (action) { - emit sendStringToEmu(action->data().toString().toLocal8Bit()); + emit sendStringToEmu(action->data().toString().toLocal8Bit().constData()); } } } @@ -3107,7 +3112,7 @@ void TerminalDisplay::dropMenuCdActionTriggered() if (sender()) { const QAction* action = qobject_cast(sender()); if (action) { - emit sendStringToEmu(action->data().toString().toLocal8Bit()); + emit sendStringToEmu(action->data().toString().toLocal8Bit().constData()); } } } diff --git a/src/TerminalDisplayAccessible.cpp b/src/TerminalDisplayAccessible.cpp index 8d37dc5e1..c6dea7a54 100644 --- a/src/TerminalDisplayAccessible.cpp +++ b/src/TerminalDisplayAccessible.cpp @@ -21,6 +21,9 @@ #include "TerminalDisplayAccessible.h" +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + + #if QT_VERSION >= 0x040800 // added in Qt 4.8.0 QString Q_GUI_EXPORT qTextBeforeOffsetFromString(int offset, QAccessible2::BoundaryType boundaryType, int* startOffset, int* endOffset, const QString& text); @@ -214,3 +217,7 @@ TerminalDisplay* TerminalDisplayAccessible::display() { return static_cast(object()); } + +#else +#pragma message("This code needs proper porting to Qt5") +#endif diff --git a/src/TerminalDisplayAccessible.h b/src/TerminalDisplayAccessible.h index c69644125..8067fc7cf 100644 --- a/src/TerminalDisplayAccessible.h +++ b/src/TerminalDisplayAccessible.h @@ -22,6 +22,10 @@ #ifndef TERMINALDISPLAYACCESSIBLE_H #define TERMINALDISPLAYACCESSIBLE_H +#include + +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + #include #include #include @@ -89,5 +93,8 @@ private: } // namespace +#else +#pragma message("This code needs proper porting to Qt5") +#endif #endif // TERMINALDISPLAYACCESSIBLE_H diff --git a/src/ViewManager.cpp b/src/ViewManager.cpp index 4b9708e4a..1984116b4 100644 --- a/src/ViewManager.cpp +++ b/src/ViewManager.cpp @@ -193,7 +193,7 @@ void ViewManager::setupActions() multiViewOnlyActions << shrinkActiveAction; - KAction* detachViewAction = collection->addAction("detach-view"); + QAction* detachViewAction = collection->addAction("detach-view"); detachViewAction->setIcon(KIcon("tab-detach")); detachViewAction->setText(i18nc("@action:inmenu", "D&etach Current Tab")); // Ctrl+Shift+D is not used as a shortcut by default because it is too close diff --git a/src/Vt102Emulation.cpp b/src/Vt102Emulation.cpp index 0b6d2ed2f..6bb51b3e1 100644 --- a/src/Vt102Emulation.cpp +++ b/src/Vt102Emulation.cpp @@ -945,7 +945,7 @@ void Vt102Emulation::sendMouseEvent(int cb, int cx, int cy , int eventType) coords[1] = cy + 0x20; QString coordsStr = QString(coords, 2); QByteArray utf8 = coordsStr.toUtf8(); - snprintf(command, sizeof(command), "\033[M%c%s", cb + 0x20, (const char *)utf8); + snprintf(command, sizeof(command), "\033[M%c%s", cb + 0x20, utf8.constData()); } } else if (cx <= 223 && cy <= 223) { snprintf(command, sizeof(command), "\033[M%c%c%c", cb + 0x20, cx + 0x20, cy + 0x20); diff --git a/src/main.cpp b/src/main.cpp index 2afc62c72..de3d5d097 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -25,16 +25,26 @@ #include // KDE +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) #include +#else +#include +#endif #include #include + + #define KONSOLE_VERSION "2.11.999" using Konsole::Application; // fill the KAboutData structure with information about contributors to Konsole. +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) void fillAboutData(KAboutData& aboutData); +#else +void fillAboutData(K4AboutData& aboutData); +#endif // fill the KCmdLineOptions object with konsole specific options. void fillCommandLineOptions(KCmdLineOptions& options); @@ -51,12 +61,21 @@ void restoreSession(Application& app); // *** extern "C" int KDE_EXPORT kdemain(int argc, char** argv) { +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) KAboutData about("konsole", +#else + K4AboutData about("konsole", +#endif 0, ki18nc("@title", "Konsole"), KONSOLE_VERSION, ki18nc("@title", "Terminal emulator"), +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) KAboutData::License_GPL_V2 +#else + K4AboutData::License_GPL_V2 +#endif + ); fillAboutData(about); @@ -79,8 +98,10 @@ extern "C" int KDE_EXPORT kdemain(int argc, char** argv) Application app; +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) // make sure the d&d popup menu provided by libkonq get translated. KGlobal::locale()->insertCatalog("libkonq"); +#endif restoreSession(app); return app.exec(); @@ -192,7 +213,11 @@ void fillCommandLineOptions(KCmdLineOptions& options) " with the -e option).")); } +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) void fillAboutData(KAboutData& aboutData) +#else +void fillAboutData(K4AboutData& aboutData) +#endif { aboutData.setProgramIconName("utilities-terminal"); aboutData.setHomepage("http://konsole.kde.org"); diff --git a/src/tests/PartTest.cpp b/src/tests/PartTest.cpp index 72cd27de0..9ca8fadc6 100644 --- a/src/tests/PartTest.cpp +++ b/src/tests/PartTest.cpp @@ -65,7 +65,11 @@ void PartTest::testFd() } if (pingExe.isEmpty()) { +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) QSKIP("ping command not found.", SkipSingle); +#else + QSKIP("ping command not found."); +#endif return; } diff --git a/src/tests/ShellCommandTest.cpp b/src/tests/ShellCommandTest.cpp index d03964fda..837e18530 100644 --- a/src/tests/ShellCommandTest.cpp +++ b/src/tests/ShellCommandTest.cpp @@ -63,7 +63,7 @@ void ShellCommandTest::testExpandEnvironmentVariable() QString text = "PATH=$PATH:~/bin"; const QString env = "PATH"; const QString value = "/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin"; - qputenv(env.toLocal8Bit(), value.toLocal8Bit()); + qputenv(env.toLocal8Bit().constData(), value.toLocal8Bit()); const QString result = ShellCommand::expand(text); const QString expected = text.replace('$' + env, value); QCOMPARE(result, expected);