diff --git a/CMakeLists.txt b/CMakeLists.txt index 1cab530..51a5549 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,122 +1,126 @@ #cmake < 3.1 has no sane way of checking C++11 features and needed flags cmake_minimum_required(VERSION 3.1 FATAL_ERROR) project(kdiff3) set(CMAKE_CXX_EXTENSIONS OFF ) #don't use non-standard extensions set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(ECM_MIN_VERSION "5.10.0") set(QT_MIN_VERSION "5.6.0") set(KF5_MIN_VERSION "5.23.0") find_package(ECM ${ECM_MIN_VERSION} CONFIG REQUIRED) set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ) include(KDEInstallDirs) include(KDECompilerSettings NO_POLICY_SCOPE) include(KDECMakeSettings NO_POLICY_SCOPE) include(FeatureSummary) include(ECMInstallIcons) include(ECMAddAppIcon) include(ECMSetupVersion) include(ECMAddTests) ecm_setup_version(1.9.70 VARIABLE_PREFIX KDIFF3 VERSION_HEADER ${CMAKE_BINARY_DIR}/src/version.h) find_package( Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS Core Gui Widgets PrintSupport ) find_package( KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS I18n CoreAddons Crash IconThemes OPTIONAL_COMPONENTS DocTools ) set_package_properties(KF5DocTools PROPERTIES PURPOSE "Allows generating and installing docs.") option(ENABLE_AUTO "Enable kdiff3's '--auto' flag" ON) option(ENABLE_CLANG_TIDY "Run clang-tidy if available and cmake version >=3.6" OFF) set(KDiff3_LIBRARIES ${Qt5PrintSupport_LIBRARIES} KF5::I18n KF5::CoreAddons KF5::IconThemes ) if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") #Adjust clang specific warnings set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wshadow") set(CLANG_WARNING_FLAGS "-Wno-invalid-pp-token -Wno-comment -Wshorten-64-to-32 -Wstring-conversion -Wc++11-narrowing -fstack-protector-all") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CLANG_WARNING_FLAGS}") elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") add_definitions(-DNOMINMAX) #Suppress MSVCs min/max macros elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-check") if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wduplicated-cond -Wduplicated-branches -Wshadow") endif() endif() #new in cmake 3.6+ integrate clang-tidy if(ENABLE_CLANG_TIDY AND NOT ${CMAKE_VERSION} VERSION_LESS "3.6.0") find_program(CLANG_TIDY_EXE NAMES "clang-tidy" "clang-tidy-7" "clang-tidy-6.0" "clang-tidy-6" DOC "Path to clang-tidy executable") if(NOT CLANG_TIDY_EXE) message(STATUS "clang-tidy not found disabling integration.") else() message(STATUS "Found clang-tidy: ${CLANG_TIDY_EXE}") set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXE}" "-header-filter=.*") endif() endif() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_CXX_FLAGS}") set( needed_features cxx_nullptr cxx_override cxx_nonstatic_member_init cxx_inheriting_constructors cxx_static_assert ) if(ENABLE_AUTO) add_definitions( -DENABLE_AUTO ) endif() add_definitions( -DQT_DEPRECATED_WARNINGS #Get warnings from QT about deprecated functions. -DQT_NO_URL_CAST_FROM_STRING # casting from string to url does not always behave as you might think -DQT_RESTRICTED_CAST_FROM_ASCII #casting from char*/QByteArray to QString can produce unexpected results for non-latin characters. -DQT_NO_CAST_TO_ASCII + -DQT_DISABLE_DEPRECATED_BEFORE=0x050600#disable depriated api for Qt<5.6. + #KF5 5.64+ flags + #Don't warn for API depreciated after 5.22.0 + -DKF_DEPRECATED_WARNINGS_SINCE=ECM_GENERATEEXPORTHEADER_VERSION_VALUE(5,22,0) ) add_subdirectory(src) if(KF5DocTools_FOUND) add_subdirectory(doc) kdoctools_install(po) else() message(WARNING "DocTools not found.") endif() ki18n_install(po) add_subdirectory(kdiff3fileitemactionplugin) feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/src/kdiff3_shell.cpp b/src/kdiff3_shell.cpp index 7325b3f..eebb98c 100644 --- a/src/kdiff3_shell.cpp +++ b/src/kdiff3_shell.cpp @@ -1,172 +1,172 @@ /*************************************************************************** * Copyright (C) 2003-2007 by Joachim Eibl * * Copyright (C) 2018 Michael Reeves reeves.87@gmail.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "kdiff3_shell.h" #include "kdiff3.h" #include "kdiff3_part.h" #include #include #include #include #include #include #include #include #include #include KDiff3Shell::KDiff3Shell(bool bCompleteInit) { m_bUnderConstruction = true; // set the shell's ui resource file setXMLFile("kdiff3_shell.rc"); // and a status bar statusBar()->show(); /*const QVector plugin_offers = KPluginLoader::findPlugins( "kf5/kdiff3part" ); foreach( const KPluginMetaData & service, plugin_offers ) { KPluginFactory *factory = KPluginLoader( service.fileName() ).factory(); m_part = factory->create( this, QVariantList() << QVariant( QLatin1String( "KDiff3Part" ) ) ); if( m_part ) break; }*/ m_part = new KDiff3Part(this, this, QVariantList() << QVariant(QLatin1String("KDiff3Part"))); m_widget = qobject_cast(m_part->widget()); if(m_part) { // and integrate the part's GUI with the shell's createGUI(m_part); //toolBar()->setToolButtonStyle( Qt::ToolButtonIconOnly ); // tell the KParts::MainWindow that this is indeed the main widget setCentralWidget(m_widget); if(bCompleteInit) m_widget->completeInit(QString()); connect(m_widget, &KDiff3App::createNewInstance, this, &KDiff3Shell::slotNewInstance); } else { // if we couldn't find our Part, we exit since the Shell by // itself can't do anything useful KMessageBox::error(this, i18n("Could not initialize the KDiff3 part.\n" "This usually happens due to an installation problem. " "Please read the README-file in the source package for details.")); //kapp->quit(); ::exit(-1); //kapp->quit() doesn't work here yet. // we return here, cause kapp->quit() only means "exit the // next time we enter the event loop... return; } // apply the saved mainwindow settings, if any, and ask the mainwindow // to automatically save settings if changed: window size, toolbar // position, icon size, etc. setAutoSaveSettings(); m_bUnderConstruction = false; } KDiff3Shell::~KDiff3Shell() { } bool KDiff3Shell::queryClose() { if(m_part) return ((KDiff3App*)m_part->widget())->queryClose(); else return true; } bool KDiff3Shell::queryExit() { return true; } void KDiff3Shell::closeEvent(QCloseEvent* e) { if(queryClose()) { e->accept(); bool bFileSaved = ((KDiff3App*)m_part->widget())->isFileSaved(); bool bDirCompare = ((KDiff3App*)m_part->widget())->isDirComparison(); QApplication::exit(bFileSaved || bDirCompare ? 0 : 1); } else e->ignore(); } void KDiff3Shell::optionsShowToolbar() { // this is all very cut and paste code for showing/hiding the // toolbar if(m_toolbarAction->isChecked()) toolBar()->show(); else toolBar()->hide(); } void KDiff3Shell::optionsShowStatusbar() { // this is all very cut and paste code for showing/hiding the // statusbar if(m_statusbarAction->isChecked()) statusBar()->show(); else statusBar()->hide(); } void KDiff3Shell::optionsConfigureKeys() { KShortcutsDialog::configure(actionCollection() /*, "kdiff3_shell.rc" */); } void KDiff3Shell::optionsConfigureToolbars() { KConfigGroup mainWindowGroup(KSharedConfig::openConfig(), "MainWindow"); saveMainWindowSettings(mainWindowGroup); // use the standard toolbar editor KEditToolBar dlg(factory()); - connect(&dlg, &KEditToolBar::newToolbarConfig, this, &KDiff3Shell::applyNewToolbarConfig); + connect(&dlg, &KEditToolBar::newToolBarConfig, this, &KDiff3Shell::applyNewToolbarConfig); dlg.exec(); } void KDiff3Shell::applyNewToolbarConfig() { KConfigGroup mainWindowGroup(KSharedConfig::openConfig(), "MainWindow"); applyMainWindowSettings(mainWindowGroup); } void KDiff3Shell::slotNewInstance(const QString& fn1, const QString& fn2, const QString& fn3) { static KDiff3Shell* pKDiff3Shell = new KDiff3Shell(false); ((KDiff3App*)pKDiff3Shell->m_part->widget())->completeInit(fn1, fn2, fn3); } //#include "kdiff3_shell.moc"