Git commit f4039346058640b500a5a11093daffa9e6a80834 by Michael Reeves. Committed on 02/05/2023 at 18:46. Pushed by mreeves into branch 'master'.
Drop KParts support Unable to effectivly test this aging code. M +0 -25 doc/en/index.docbook M +0 -4 src/CMakeLists.txt M +24 -40 src/kdiff3.cpp M +3 -10 src/kdiff3.h D +0 -281 src/kdiff3_part.cpp D +0 -74 src/kdiff3_part.h D +0 -29 src/kdiff3_part.rc M +15 -19 src/kdiff3_shell.cpp M +2 -10 src/kdiff3_shell.h D +0 -39 src/kdiff3part.desktop M +2 -1 src/pdiff.cpp https://invent.kde.org/sdk/kdiff3/commit/f4039346058640b500a5a11093daffa9e6a80834 diff --git a/doc/en/index.docbook b/doc/en/index.docbook index ddf6ab0e..d89d866d 100644 --- a/doc/en/index.docbook +++ b/doc/en/index.docbook @@ -1842,31 +1842,6 @@ Other things that are possible, but probably less useful are: </sect2> </sect1> -<sect1 id="kpart"> -<title>Using &kdiff3; as a KPart</title> -<para> -&kdiff3; is a KPart. Currently it implements the KParts::ReadOnlyPart interface. -</para><para> -It's main use is as difference-viewer in &kdevelop;. &kdevelop; always starts the -internal difference viewer first. To invoke &kdiff3; press the &RMB; -on the difference viewer window and select <guimenuitem>Show in KDiff3Part</guimenuitem> from the context menu. -</para><para> -&kdiff3; normally requires two complete files as input. When used as part &kdiff3; -will assume that the input file is a patch-file in the unified format. &kdiff3; -then retrieves the original filenames from the patch-file. At least one of -the two files must be available. &kdiff3; will then invoke <command>patch</command> to -recreate the second file. -</para><para> -In &dolphin; you can select a patch-file and select <menuchoice><guimenuitem>Preview -in</guimenuitem><guisubmenu>KDiff3Part</guisubmenu></menuchoice> item from the context -menu. Be aware that this won't work if none of the original files are available, and it -is not reliable if the original file(s) have changed since the patch-file was generated. -</para><para> -When run as a part &kdiff3; only provides the a two-file-diff, a very small toolbar -and menu. Merging or folder comparison are not supported then. -</para> -</sect1> - <sect1 id="git"> <title>Using &kdiff3; as a &git; Diff and Merging Tool</title> <para> diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index aab51c7e..03604baf 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -6,7 +6,6 @@ set(kdiff3part_PART_SRCS - kdiff3_part.cpp kdiff3.cpp directorymergewindow.cpp merger.cpp @@ -55,8 +54,6 @@ set_target_properties(kdiff3part PROPERTIES DEFINE_SYMBOL KDIFF3_PART) target_link_libraries(kdiff3part Qt::PrintSupport KF5::I18n KF5::CoreAddons KF5::Parts KF5::Crash) target_compile_definitions(kdiff3part PRIVATE -DTRANSLATION_DOMAIN=\"kdiff3\") -install(TARGETS kdiff3part DESTINATION ${KDE_INSTALL_PLUGINDIR}/kf5/parts ) - ########### kdiff3 executable ############### set(kdiff3_SRCS @@ -98,7 +95,6 @@ install(TARGETS kdiff3 ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) ########### install files ############### install( FILES kdiff3part.desktop DESTINATION ${KDE_INSTALL_KSERVICESDIR} ) -install( FILES kdiff3_part.rc DESTINATION ${KDE_INSTALL_KXMLGUIDIR}/kdiff3part ) install( FILES kdiff3_shell.rc DESTINATION ${KDE_INSTALL_KXMLGUIDIR}/kdiff3 ) install( PROGRAMS org.kde.kdiff3.desktop DESTINATION ${KDE_INSTALL_APPDIR} ) install( FILES org.kde.kdiff3.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR} ) diff --git a/src/kdiff3.cpp b/src/kdiff3.cpp index e6ea8305..fed7d435 100644 --- a/src/kdiff3.cpp +++ b/src/kdiff3.cpp @@ -17,7 +17,6 @@ #include "directorymergewindow.h" #include "fileaccess.h" #include "guiutils.h" -#include "kdiff3_part.h" #include "kdiff3_shell.h" #include "mergeresultwindow.h" #include "optiondialog.h" @@ -82,33 +81,24 @@ constexpr QLatin1String MAIN_TOOLBAR_NAME = QLatin1String("mainToolBar", sizeof( KActionCollection* KDiff3App::actionCollection() const { - if(m_pKDiff3Shell == nullptr) - return m_pKDiff3Part->actionCollection(); + assert(m_pKDiff3Shell != nullptr); return m_pKDiff3Shell->actionCollection(); } QStatusBar* KDiff3App::statusBar() const { - if(m_pKDiff3Shell == nullptr) - return nullptr; + assert(m_pKDiff3Shell != nullptr); return m_pKDiff3Shell->statusBar(); } KToolBar* KDiff3App::toolBar(const QLatin1String& toolBarId) const { - if(m_pKDiff3Shell == nullptr) - return nullptr; - + assert(m_pKDiff3Shell != nullptr); return m_pKDiff3Shell->toolBar(toolBarId); } -bool KDiff3App::isPart() const -{ - return m_pKDiff3Shell == nullptr; -} - bool KDiff3App::isFileSaved() const { return m_bFileSaved; @@ -122,13 +112,12 @@ bool KDiff3App::isDirComparison() const /* Don't call completeInit from here it will be called in KDiff3Shell as needed. */ -KDiff3App::KDiff3App(QWidget* pParent, const QString& name, KDiff3Part* pKDiff3Part): - QMainWindow(pParent) //previously KMainWindow +KDiff3App::KDiff3App(QWidget* pParent, const QString& name, KDiff3Shell* pKDiff3Shell): + QMainWindow(pParent) { setWindowFlags(Qt::Widget); setObjectName(name); - m_pKDiff3Part = pKDiff3Part; - m_pKDiff3Shell = qobject_cast<KParts::MainWindow*>(pParent); + m_pKDiff3Shell = pKDiff3Shell; m_pCentralWidget = new QWidget(this); QVBoxLayout* pCentralLayout = new QVBoxLayout(m_pCentralWidget); @@ -169,7 +158,7 @@ KDiff3App::KDiff3App(QWidget* pParent, const QString& name, KDiff3Part* pKDiff3P // Option handling: Only when pParent==0 (no parent) int argCount = KDiff3Shell::getParser()->optionNames().count() + KDiff3Shell::getParser()->positionalArguments().count(); - bool hasArgs = !isPart() && argCount > 0; + bool hasArgs = argCount > 0; if(hasArgs) { QString s; @@ -317,7 +306,8 @@ KDiff3App::KDiff3App(QWidget* pParent, const QString& name, KDiff3Part* pKDiff3P /////////////////////////////////////////////////////////////////// // call inits to invoke all other construction parts - //Warning: Call this before connecting KDiff3App::slotUpdateAvailabilities or calling KXMLGUIClient::setXMLFile + // Warning: Call this before connecting KDiff3App::slotUpdateAvailabilities or + // calling KXMLGUIClient::setXMLFile or KXMLGUIClient::createGUI initActions(actionCollection()); initStatusBar(); @@ -332,21 +322,20 @@ KDiff3App::KDiff3App(QWidget* pParent, const QString& name, KDiff3Part* pKDiff3P showWhiteSpaceCharacters->setEnabled(m_pOptions->m_bShowWhiteSpace); showLineNumbers->setChecked(m_pOptions->m_bShowLineNumbers); wordWrap->setChecked(m_pOptions->wordWrapOn()); - if(!isPart()) - { - /* - No need to restore window size and position here that is done later. - See KDiff3App::completeInit - */ - viewStatusBar->setChecked(m_pOptions->isStatusBarVisable()); - slotViewStatusBar(); - KToolBar* mainToolBar = toolBar(MAIN_TOOLBAR_NAME); - if(mainToolBar != nullptr) - { - mainToolBar->mainWindow()->addToolBar(Qt::TopToolBarArea, mainToolBar); - } + /* + No need to restore window size and position here that is done later. + See KDiff3App::completeInit + */ + viewStatusBar->setChecked(m_pOptions->isStatusBarVisable()); + slotViewStatusBar(); + + KToolBar* mainToolBar = toolBar(MAIN_TOOLBAR_NAME); + if(mainToolBar != nullptr) + { + mainToolBar->mainWindow()->addToolBar(Qt::TopToolBarArea, mainToolBar); } + slotRefresh(); m_pDirectoryMergeDock = new QDockWidget(i18n("Directory merge"), this); @@ -533,7 +522,7 @@ void KDiff3App::completeInit(const QString& fn1, const QString& fn2, const QStri m_bAutoMode = false; } - if(!m_bAutoMode && !isPart()) + if(!m_bAutoMode) showMainWindow(); g_pProgressDialog->setStayHidden(false); @@ -650,8 +639,7 @@ void KDiff3App::initActions(KActionCollection* ac) viewStatusBar->setStatusTip(i18n("Enables/disables the statusbar")); KStandardAction::keyBindings(this, &KDiff3App::slotConfigureKeys, ac); QAction* pAction = KStandardAction::preferences(this, &KDiff3App::slotConfigure, ac); - if(isPart()) - pAction->setText(i18n("Configure KDiff3...")); + pAction->setText(i18n("Configure KDiff3...")); #include "xpm/autoadvance.xpm" #include "xpm/currentpos.xpm" @@ -784,11 +772,7 @@ void KDiff3App::saveOptions(KSharedConfigPtr config) { if(!m_bAutoMode) { - if(!isPart()) - { - saveWindow(config); - } - + saveWindow(config); m_pOptionDialog->saveOptions(std::move(config)); } } diff --git a/src/kdiff3.h b/src/kdiff3.h index f38d9d2d..5bef6842 100644 --- a/src/kdiff3.h +++ b/src/kdiff3.h @@ -54,11 +54,7 @@ class QMenu; class KToolBar; class KActionCollection; -namespace KParts { -class MainWindow; -} - -class KDiff3Part; +class KDiff3Shell; class DirectoryMergeWindow; class DirectoryMergeInfo; @@ -126,11 +122,9 @@ class KDiff3App: public QMainWindow public: /** constructor of KDiff3App, calls all init functions to create the application. */ - KDiff3App(QWidget* parent, const QString& name, KDiff3Part* pKDiff3Part); + KDiff3App(QWidget* parent, const QString& name, KDiff3Shell* pKDiff3Shell); ~KDiff3App() override; - [[nodiscard]] bool isPart() const; - /** initializes the KActions of the application */ void initActions(KActionCollection*); @@ -473,8 +467,7 @@ public Q_SLOTS: bool m_bFinishMainInit = false; bool m_bLoadFiles = false; - KDiff3Part* m_pKDiff3Part = nullptr; - KParts::MainWindow* m_pKDiff3Shell = nullptr; + KDiff3Shell* m_pKDiff3Shell = nullptr; bool m_bAutoFlag = false; bool m_bAutoMode = false; bool m_bRecalcWordWrapPosted = false; diff --git a/src/kdiff3_part.cpp b/src/kdiff3_part.cpp deleted file mode 100644 index bfbcbed7..00000000 --- a/src/kdiff3_part.cpp +++ /dev/null @@ -1,281 +0,0 @@ -// clang-format off -/* - * KDiff3 - Text Diff And Merge Tool - * - * SPDX-FileCopyrightText: 2002-2011 Joachim Eibl, joachim.eibl at gmx.de - * SPDX-FileCopyrightText: 2018-2020 Michael Reeves [email protected] - * SPDX-License-Identifier: GPL-2.0-or-later - */ -// clang-format on - -#include "kdiff3_part.h" - -#include "fileaccess.h" -#include "kdiff3.h" -#include "Logging.h" - -#include <QFile> -#include <QProcess> -#include <QTemporaryFile> -#include <QTextStream> - -#include <KAboutData> -#include <KCrash> -#include <KLocalizedString> -#include <KMessageBox> -#include <KParts/MainWindow> - -#include <version.h> - -//A bit of a hack but I don't have control over the constructor for KDiff3Part since its a KPart plugin. -bool KDiff3Part::bNeedInit = true; - -K_PLUGIN_FACTORY(KDiff3PartFactory, registerPlugin<KDiff3Part>();) - -KDiff3Part::KDiff3Part(QWidget* parentWidget, QObject* parent, const QVariantList& args) - : KParts::ReadWritePart(parent) -{ - KCrash::initialize(); - assert(parentWidget); - - if(!args.isEmpty()) - { - const QString widgetName = args[0].toString(); - - // this should be your custom internal widget - m_widget = new KDiff3App(parentWidget, widgetName, this); - } - else - m_widget = new KDiff3App(parentWidget, u8"KDiff3Part", this); - - // notify the part that this is our internal widget - setWidget(m_widget); - - // create our actions - //KStandardAction::open(this, &KDiff3Part:fileOpen, actionCollection()); - //KStandardAction::saveAs(this, &KDiff3Part:fileSaveAs, actionCollection()); - //KStandardAction::save(this, &KDiff3Part:save, actionCollection()); - - setXMLFile("kdiff3_part.rc"); - - // we are read-write by default - setReadWrite(true); - - // we are not modified since we haven't done anything yet - setModified(false); - - if(bNeedInit) - m_widget->completeInit(); -} - -KDiff3Part::~KDiff3Part() -{ - //TODO: Is parent check needed? - if(m_widget != nullptr && qobject_cast<KParts::MainWindow*>(parent()) != nullptr) - { - m_widget->saveOptions(KSharedConfig::openConfig()); - } -} - -void KDiff3Part::setReadWrite(bool /*rw*/) -{ - // ReadWritePart::setReadWrite(rw); -} - -void KDiff3Part::setModified(bool /*modified*/) -{ - /* - // get a handle on our Save action and make sure it is valid - QAction *save = actionCollection()->action(KStandardAction::stdName(KStandardAction::Save)); - if (!save) - return; - - // if so, we either enable or disable it based on the current - // state - if (modified) - save->setEnabled(true); - else - save->setEnabled(false); - - // in any event, we want our parent to do it's thing - ReadWritePart::setModified(modified); -*/ -} - -void KDiff3Part::getNameAndVersion(const QString& str, const QString& lineStart, QString& fileName, QString& version) -{ - if(str.startsWith(lineStart) && fileName.isEmpty()) - { - //Skip the start string - int pos = lineStart.length(); - //Skip white space if any after start string. - while(pos < str.length() && (str[pos] == ' ' || str[pos] == '\t')) ++pos; - int pos2 = str.length() - 1; - while(pos2 > pos) - { - //skip trailing whitespace - while(pos2 > pos && str[pos2] != ' ' && str[pos2] != '\t') --pos2; - fileName = str.mid(pos, pos2 - pos); - qCDebug(kdiffMain) << "KDiff3Part::getNameAndVersion: fileName = " << fileName; - //Always fails for cvs output this is a designed failure. - if(FileAccess(fileName).exists()) break; - --pos2; - } - - int vpos = str.lastIndexOf("\t", -1); - if(vpos > 0 && vpos > pos2) - { - version = str.mid(vpos + 1); - while(!version.right(1)[0].isLetterOrNumber()) - version.truncate(version.length() - 1); - } - } -} - -bool KDiff3Part::openFile() -{ - // m_file is always local so we can use QFile on it - //fprintf(stderr, "KDiff3: %s\n", localFilePath().toLatin1().constData()); - qCDebug(kdiffMain) << "KDiff3Part::openFile(): localFilePath() == " << localFilePath(); - QFile file(localFilePath()); - if(!file.open(QIODevice::ReadOnly)) - return false; - - //get version and name - QTextStream stream(&file); - QString str; - QString fileName1; - QString fileName2; - QString version1; - QString version2; - QStringList errors; - - /* - This assumes use of -u otherwise the patch file may not be recognized. - Also assumes cvs or diff was used to gernerate the path. - */ - while(!stream.atEnd() && (fileName1.isEmpty() || fileName2.isEmpty())) - { - str = stream.readLine() + '\n'; - getNameAndVersion(str, "---", fileName1, version1); - getNameAndVersion(str, "+++", fileName2, version2); - } - - file.close(); - - if(fileName1.isEmpty() && fileName2.isEmpty()) - { - KMessageBox::error(m_widget, i18n("Could not find files for comparison.")); - return false; - } - - const FileAccess f1(fileName1); - const FileAccess f2(fileName2); - - if(f1.exists() && f2.exists() && fileName1 != fileName2) - { - m_widget->slotFileOpen2(errors, fileName1, fileName2, "", "", "", "", "", nullptr); - return true; - } - else if(version1.isEmpty() && f1.exists()) - { - // Normal patch - // patch -f -u --ignore-whitespace -i [inputfile] -o [outfile] [patchfile] - QTemporaryFile tmpFile; - FileAccess::createTempFile(tmpFile); - const QString tempFileName = tmpFile.fileName(); - const QString cmd = "patch"; - QStringList args = {"-f", "-u", "--ignore-whitespace", "-i", '"' + localFilePath() + '"', - "-o", '"' + tempFileName + '"', '"' + fileName1 + '"'}; - - QProcess process; - process.start(cmd, args); - process.waitForFinished(-1); - - m_widget->slotFileOpen2(errors, fileName1, tempFileName, "", "", - "", version2.isEmpty() ? fileName2 : "REV:" + version2 + ':' + fileName2, "", nullptr); // alias names // std::cerr << "KDiff3: f1:" << fileName1.toLatin1() <<"<->"<<tempFileName.toLatin1()<< std::endl; - } - else if(version2.isEmpty() && f2.exists()) - { - // Reverse patch - // patch -f -u -R --ignore-whitespace -i [inputfile] -o [outfile] [patchfile] - QTemporaryFile tmpFile; - FileAccess::createTempFile(tmpFile); - const QString tempFileName = tmpFile.fileName(); - const QString cmd = "patch"; - const QStringList args = {"-f", "-u", "-R", "--ignore-whitespace", "-i", '"' + localFilePath() + '"', - "-o", '"' + tempFileName + '"', '"' + fileName2 + '"'}; - - QProcess process; - process.start(cmd, args); - process.waitForFinished(-1); - - m_widget->slotFileOpen2(errors, tempFileName, fileName2, "", "", - version1.isEmpty() ? fileName1 : "REV:" + version1 + ':' + fileName1, "", "", nullptr); // alias name - } - else if(!version1.isEmpty() && !version2.isEmpty()) - { - qCDebug(kdiffMain) << "KDiff3Part::openFile():" << fileName1 << "<->" << fileName2 << "\n"; - // FIXME: Why must this be cvs? - // Assuming that files are on CVS: Try to get them - // cvs update -p -r [REV] [FILE] > [OUTPUTFILE] - - QTemporaryFile tmpFile1; - FileAccess::createTempFile(tmpFile1); - const QString tempFileName1 = tmpFile1.fileName(); - const QString cmd = "cvs"; - QStringList args = {"update", "-p", "-r", version1, '"' + fileName1 + '"'}; - QProcess process1; - - process1.setStandardOutputFile(tempFileName1); - process1.start(cmd, args); - process1.waitForFinished(-1); - - QTemporaryFile tmpFile2; - FileAccess::createTempFile(tmpFile2); - QString tempFileName2 = tmpFile2.fileName(); - - args = QStringList{"update", "-p", "-r", version2, '"' + fileName2 + '"'}; - QProcess process2; - process2.setStandardOutputFile(tempFileName2); - process2.start(cmd, args); - process2.waitForFinished(-1); - - m_widget->slotFileOpen2(errors, tempFileName1, tempFileName2, "", "", - "REV:" + version1 + ':' + fileName1, - "REV:" + version2 + ':' + fileName2, - "", nullptr); - - qCDebug(kdiffMain) << "KDiff3Part::openFile():" << tempFileName1 << "<->" << tempFileName2 << "\n"; - return true; - } - else - { - KMessageBox::error(m_widget, i18n("Could not find files for comparison.")); - } - - return true; -} - -bool KDiff3Part::saveFile() -{ - /* // if we aren't read-write, return immediately - if (isReadWrite() == false) - return false; - - // localFilePath() is always local, so we use QFile - QFile file(localFilePath()); - if (file.open(IO_WriteOnly) == false) - return false; - - // use QTextStream to dump the text to the file - QTextStream stream(&file); - //stream << m_widget->text(); - - file.close(); - return true; -*/ - return false; // Not implemented -} - -#include "kdiff3_part.moc" diff --git a/src/kdiff3_part.h b/src/kdiff3_part.h deleted file mode 100644 index 2433cf33..00000000 --- a/src/kdiff3_part.h +++ /dev/null @@ -1,74 +0,0 @@ -// clang-format off -/* - * KDiff3 - Text Diff And Merge Tool - * - * SPDX-FileCopyrightText: 2002-2011 Joachim Eibl, joachim.eibl at gmx.de - * SPDX-FileCopyrightText: 2018-2020 Michael Reeves [email protected] - * SPDX-License-Identifier: GPL-2.0-or-later - */ -// clang-format on - -#ifndef KDIFF3PART_H -#define KDIFF3PART_H - -#include <kparts/part.h> -#include <KPluginFactory> -#include <KParts/ReadWritePart> - -class QWidget; -class KDiff3App; - -/** - * This is a "Part". It that does all the real work in a KPart - * application. - * - * @short Main Part - * @author Joachim Eibl <joachim.eibl at gmx.de> - */ -class KDiff3Part : public KParts::ReadWritePart -{ - Q_OBJECT -public: - /** - * Default constructor - */ - KDiff3Part(QWidget *parentWidget, QObject *parent, const QVariantList &args ); - - /** - * Destructor - */ - ~KDiff3Part() override; - - /** - * This is a virtual function inherited from KParts::ReadWritePart. - * A shell will use this to inform this Part if it should act - * read-only - */ - void setReadWrite(bool rw) override; - - /** - * Reimplemented to disable and enable Save action - */ - void setModified(bool modified) override; - - static void noInit() { bNeedInit = false; } -protected: - /** - * This must be implemented by each part - */ - bool openFile() override; - - /** - * This must be implemented by each read-write part - */ - bool saveFile() override; - - static bool bNeedInit; -private: - void getNameAndVersion(const QString& str, const QString& lineStart, QString& fileName, QString& version); - KAboutData createAboutData(); - - QPointer<KDiff3App> m_widget; -}; - -#endif // _KDIFF3PART_H_ diff --git a/src/kdiff3_part.rc b/src/kdiff3_part.rc deleted file mode 100644 index 24fa0601..00000000 --- a/src/kdiff3_part.rc +++ /dev/null @@ -1,29 +0,0 @@ -<!DOCTYPE gui SYSTEM "kpartgui.dtd"> -<!-- -SPDX-FileCopyrightText: 2002-2011 Joachim Eibl, joachim.eibl at gmx.de -SPDX-FileCopyrightText: 2018-2020 Michael Reeves [email protected] -SPDX-License-Identifier: GPL-2.0-or-later ---> -<gui name="kdiff3_part" version="9"> -<MenuBar> - <Menu name="movement"><text>&KDiff3</text> - <Action name="go_top"/> - <Action name="go_bottom"/> - <Action name="go_prev_delta"/> - <Action name="go_next_delta"/> - <Action name="diff_showwhitespace"/> - <Action name="diff_showlinenumbers"/> - <Action name="diff_wordwrap"/> - <Action name="win_toggle_split_orientation"/> - <Action name="options_configure"><text>Configure KDiff3</text></Action> - </Menu> -</MenuBar> -<ToolBar name="mainToolBar"><text>KDiff3</text> - <Action name="go_top"/> - <Action name="go_bottom"/> - <Action name="go_prev_delta"/> - <Action name="go_next_delta"/> - <Action name="diff_showwhitespace"/> - <Action name="diff_showlinenumbers"/> -</ToolBar> -</gui> diff --git a/src/kdiff3_shell.cpp b/src/kdiff3_shell.cpp index 0e0b028f..f42c434c 100644 --- a/src/kdiff3_shell.cpp +++ b/src/kdiff3_shell.cpp @@ -11,7 +11,6 @@ #include "kdiff3_shell.h" #include "compat.h" #include "kdiff3.h" -#include "kdiff3_part.h" #include <QApplication> #include <QCloseEvent> @@ -28,22 +27,19 @@ KDiff3Shell::KDiff3Shell(const QString& fn1, const QString& fn2, const QString& fn3) { m_bUnderConstruction = true; - // set the shell's ui resource file - setXMLFile("kdiff3_shell.rc"); - // and a status bar - statusBar()->show(); + m_widget = new KDiff3App(this, u8"KDiff3Part", this); - //Avoid redudant init call. - KDiff3Part::noInit(); - - m_part = new KDiff3Part(this, this, {QVariant(u8"KDiff3Part")}); - - if(m_part) + if(m_widget) { - m_widget = qobject_cast<KDiff3App*>(m_part->widget()); + // set the shell's ui resource file + //setXMLFile("kdiff3_shell.rc"); + + setupGUI(Default, "kdiff3_shell.rc"); + // and a status bar + statusBar()->show(); // and integrate the part's GUI with the shell's - createGUI(m_part); + //createGUI(m_part); //toolBar()->setToolButtonStyle( Qt::ToolButtonIconOnly ); // tell the KParts::MainWindow that this is indeed the main widget @@ -51,6 +47,12 @@ KDiff3Shell::KDiff3Shell(const QString& fn1, const QString& fn2, const QString& m_widget->completeInit(fn1, fn2, fn3); chk_connect(m_widget, &KDiff3App::createNewInstance, this, &KDiff3Shell::slotNewInstance); + + // 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; } else { @@ -64,12 +66,6 @@ KDiff3Shell::KDiff3Shell(const QString& fn1, const QString& fn2, const QString& 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() = default; diff --git a/src/kdiff3_shell.h b/src/kdiff3_shell.h index b276d9e3..fb5cd3d8 100644 --- a/src/kdiff3_shell.h +++ b/src/kdiff3_shell.h @@ -17,16 +17,9 @@ #include <QPointer> #include <QString> -#include <KParts/MainWindow> +#include <KXmlGuiWindow> class KToggleAction; - -// clang-format off -namespace KParts { - class ReadWritePart; -} -// clang-format on - class KDiff3App; /** @@ -36,7 +29,7 @@ class KDiff3App; * @short Application Shell * @author Joachim Eibl <joachim.eibl at gmx.de> */ -class KDiff3Shell: public KParts::MainWindow +class KDiff3Shell: public KXmlGuiWindow { Q_OBJECT public: @@ -69,7 +62,6 @@ class KDiff3Shell: public KParts::MainWindow void slotNewInstance(const QString& fn1, const QString& fn2, const QString& fn3); private: - KParts::ReadWritePart* m_part; QPointer<KDiff3App> m_widget; KToggleAction* m_toolbarAction; diff --git a/src/kdiff3part.desktop b/src/kdiff3part.desktop deleted file mode 100644 index 6e5bb737..00000000 --- a/src/kdiff3part.desktop +++ /dev/null @@ -1,39 +0,0 @@ -[Desktop Entry] -Name=KDiff3 Part -Name[bg]=KDiff3 Part -Name[ca]=Part del KDiff3 -Name[ca@valencia]=Part de KDiff3 -Name[cs]=Komponenta KDiff3 -Name[de]=KDiff3-Komponente -Name[en_GB]=KDiff3 Part -Name[eo]=KDiff3-Parto -Name[es]=Parte de KDiff3 -Name[eu]=KDiff3 atala -Name[fi]=KDiff3-osa -Name[fr]=Partie de KDiff3 -Name[ia]=KDiff3Part -Name[it]=KDiff3 Part -Name[ka]=KDiff3 Part -Name[ko]=KDiff3 부분 -Name[nl]=KDiff3 Part -Name[pl]=Człon KDiff3 -Name[pt]=Componente do KDiff3 -Name[pt_BR]=KDiff3 Part -Name[ru]=Компонент KDiff3 -Name[sl]=KDiff3 Part -Name[sv]=Kdiff3-del -Name[tr]=KDiff3 Kısmı -Name[uk]=Модуль KDiff3 -Name[x-test]=xxKDiff3 Partxx -Name[zh_CN]=KDiff3 部件 -ServiceTypes=KParts/ReadOnlyPart,KParts/ReadWritePart -MimeType=text/x-patch; -X-KDE-Library=kf5/parts/kdiff3part -Type=Service -X-KDE-PluginInfo-Name=KDiff3Part -X-KDE-PluginInfo-License=GPLv2 -X-KDE-PluginInfo-Description= A KPart for displaying diffs -X-KDE-PluginInfo-Authors=Joachim Eibl;Michael Reeves -X-KDE-PluginInfo-Emails=joachim.eibl at gmx.de;[email protected] -X-KDE-PluginInfo-Version=1.10.70 - diff --git a/src/pdiff.cpp b/src/pdiff.cpp index aaa97655..f3070141 100644 --- a/src/pdiff.cpp +++ b/src/pdiff.cpp @@ -15,6 +15,7 @@ #include "directorymergewindow.h" #include "fileaccess.h" #include "kdiff3.h" +#include "kdiff3_shell.h" #include "Logging.h" #include "optiondialog.h" #include "progress.h" @@ -403,7 +404,7 @@ void KDiff3App::mainInit(TotalDiffStatus* pTotalDiffStatus, const InitFlags inFl m_pMergeWindowFrame->show(); // Try to create a meaningful but not too long caption - if(!isPart() && mErrors.isEmpty()) + if(mErrors.isEmpty()) { createCaption(); }
