Commit 2a3f7758 authored by Friedrich W. H. Kossebau's avatar Friedrich W. H. Kossebau
Browse files

Make shell use the KPart again instead via the plugin

parent fb49986e
......@@ -52,21 +52,7 @@ include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} )
add_subdirectory( pics )
ecm_optional_add_subdirectory(doc)
set(libkimagemapeditorcommon_SRC
areacreator.cpp
kimearea.cpp
kimecommands.cpp
kimedialogs.cpp
kimagemapeditor.cpp
drawzone.cpp
arealistview.cpp
imageslistview.cpp
mapslistview.cpp
imagemapchoosedialog.cpp
)
qt5_add_resources(libkimagemapeditorcommon_SRC kimagemapeditor.qrc)
ecm_qt_declare_logging_category(libkimagemapeditorcommon_SRC
ecm_qt_declare_logging_category(kimagemapeditor_LOG_SRC
HEADER kimagemapeditor_debug.h
IDENTIFIER KIMAGEMAPEDITOR_LOG
CATEGORY_NAME org.kde.kimagemapeditor
......@@ -75,8 +61,12 @@ ecm_qt_declare_logging_category(libkimagemapeditorcommon_SRC
########### next target ###############
set(kimagemapeditor_bin_SRCS main.cpp kimeshell.cpp ${libkimagemapeditorcommon_SRC})
set(kimagemapeditor_bin_SRCS
main.cpp
kimeshell.cpp
${kimagemapeditor_LOG_SRC}
)
qt5_add_resources(kimagemapeditor_bin_SRCS kimagemapeditor.qrc)
add_executable(kimagemapeditor_bin ${kimagemapeditor_bin_SRCS})
......@@ -89,7 +79,20 @@ install(TARGETS kimagemapeditor_bin ${INSTALL_TARGETS_DEFAULT_ARGS} )
########### next target ###############
set(kimagemapeditor_PART_SRCS ${libkimagemapeditorcommon_SRC})
set(kimagemapeditor_PART_SRCS
areacreator.cpp
kimearea.cpp
kimecommands.cpp
kimedialogs.cpp
kimagemapeditor.cpp
drawzone.cpp
arealistview.cpp
imageslistview.cpp
mapslistview.cpp
imagemapchoosedialog.cpp
${kimagemapeditor_LOG_SRC}
)
qt5_add_resources(kimagemapeditor_PART_SRCS kimagemapeditorpart.qrc)
add_library(kimagemapeditorpart MODULE ${kimagemapeditor_PART_SRCS})
kcoreaddons_desktop_to_json(kimagemapeditorpart kimagemapeditorpart.desktop)
......
......@@ -31,6 +31,7 @@
#include <KParts/ReadWritePart>
#include "kimearea.h"
#include "kimagemapeditorinterface.h"
/**
*@author Jan Schaefer
......@@ -122,8 +123,11 @@ class KAboutData;
#define STATUS_CURSOR 1000
#define STATUS_SELECTION 1001
class KImageMapEditor : public KParts::ReadWritePart {
class KImageMapEditor : public KParts::ReadWritePart, public KImageMapEditorInterface
{
Q_OBJECT
Q_INTERFACES(KImageMapEditorInterface)
public :
enum ToolType { Selection,
Rectangle,
......@@ -178,8 +182,8 @@ public :
void readConfig();
void writeConfig();
virtual void readProperties(const KConfigGroup &);
virtual void saveProperties(KConfigGroup &);
void readProperties(const KConfigGroup &) override;
void saveProperties(KConfigGroup &) override;
using KParts::ReadWritePart::closeUrl;
bool closeUrl() override;
bool queryClose() override;
......@@ -196,13 +200,13 @@ public :
* If it's an HTML file openURL is called
* If it's an Image, the image is added to the image list
*/
void openFile(const QUrl &);
void openFile(const QUrl &) override;
/**
* Opens the last URL the user worked with.
* Sets also, the last map and the last image
*/
void openLastURL(const KConfigGroup &);
void openLastURL(const KConfigGroup &) override;
void readConfig(const KConfigGroup &);
void writeConfig(KConfigGroup &);
......@@ -344,7 +348,7 @@ private:
void drawToCenter(QPainter* p, const QString & str, int y, int width);
public slots:
virtual bool openURL(const QUrl & url);
bool openURL(const QUrl & url) override;
void slotChangeStatusCoords(int x,int y);
void slotUpdateSelectionCoords();
void slotUpdateSelectionCoords( const QRect &);
......
<RCC>
<qresource prefix="/kxmlgui5/kimagemapeditor">
<file>kimagemapeditorpartui.rc</file>
<file>kimagemapeditorui.rc</file>
</qresource>
</RCC>
/***************************************************************************
kimagemapeditorinterface.h
-------------------
begin : Wed Apr 4 2001
copyright : (C) 2001 by Jan Schäfer
email : janschaefer@users.sourceforge.net
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
#ifndef KIMAGEMAPEDITORINTERFACE_H
#define KIMAGEMAPEDITORINTERFACE_H
class KConfigGroup;
class QUrl;
class KImageMapEditorInterface
{
public:
virtual ~KImageMapEditorInterface() {}
/**
* Opens the given file.
* If it's an HTML file openURL is called
* If it's an Image, the image is added to the image list
*/
virtual void openFile(const QUrl &) = 0;
virtual bool openURL(const QUrl & url) = 0;
virtual void openLastURL(const KConfigGroup &) = 0;
virtual void readProperties(const KConfigGroup &) = 0;
virtual void saveProperties(KConfigGroup &) = 0;
};
Q_DECLARE_INTERFACE(KImageMapEditorInterface, "org.kde.KImageMapEditorInterface")
#endif
<RCC>
<qresource prefix="/kxmlgui5/kimagemapeditor">
<file>kimagemapeditorpartui.rc</file>
</qresource>
</RCC>
......@@ -38,6 +38,9 @@
#include <KToolBar>
#include <KWindowConfig>
#include <KXMLGUIFactory>
#include <KPluginLoader>
#include <KPluginFactory>
#include <KPluginMetaData>
#include "drawzone.h"
#include "kimagemapeditor.h" // the KPart
......@@ -63,17 +66,45 @@ KimeShell::KimeShell(const char * )
// setMainDockWidget( mainDock); // master dockwidget
qCDebug(KIMAGEMAPEDITOR_LOG) << "KimeShell starting 0";
m_part = new KImageMapEditor((QWidget*)nullptr, this);
// setCentralWidget( part->widget() );
qCDebug(KIMAGEMAPEDITOR_LOG) << "KimeShell starting 1";
setupActions();
qCDebug(KIMAGEMAPEDITOR_LOG) << "KimeShell starting 2";
const auto plugins = KPluginLoader::findPlugins(QStringLiteral("kf5/parts"),
[](const KPluginMetaData& metaData) {
return metaData.pluginId() == QLatin1String("kimagemapeditorpart");
});
KPluginFactory *factory = plugins.isEmpty() ? nullptr : KPluginLoader(plugins.first().fileName()).factory();
if (!factory) {
// can't do anything useful without part, thus quit the app
KMessageBox::error(this, i18n("Could not find kimagemapeditorpart part!"));
qApp->quit();
// return here, because qApp->quit() only means "exit the
// next time we enter the event loop...
return;
}
m_part = factory->create<KParts::ReadWritePart>(this);
m_editorInterface = qobject_cast<KImageMapEditorInterface*>(m_part);
if (!m_part || !m_editorInterface) {
// can't do anything useful without part, thus quit the app
KMessageBox::error(this, i18n("Could not create kimagemapeditorpart part!"));
qApp->quit();
// return here, because qApp->quit() only means "exit the
// next time we enter the event loop...
return;
}
// setCentralWidget( part->widget() );
_stdout=false;
// createGUI( part );
// createGUI( m_part );
createShellGUI( true );
guiFactory()->addClient( m_part );
KParts::GUIActivateEvent ev( true );
......@@ -157,7 +188,7 @@ void KimeShell::fileNew()
void KimeShell::openFile(const QUrl & url)
{
m_part->openFile(url);
m_editorInterface->openFile(url);
}
void KimeShell::openLastFile()
......@@ -165,9 +196,9 @@ void KimeShell::openLastFile()
#ifdef __GNUC__
#warning there is no group defined
#endif
KConfigGroup cg( m_part->config(), QString() );
KConfigGroup cg( KSharedConfig::openConfig(), QString() );
if (cg.readEntry("start-with-last-used-document",true))
m_part->openLastURL( cg );
m_editorInterface->openLastURL( cg );
}
void KimeShell::fileOpen()
......@@ -182,7 +213,7 @@ void KimeShell::fileOpen()
if ( m_part->url().isEmpty() && ! m_part->isModified() )
{
// we open the file in this window...
m_part->openURL(url);
m_editorInterface->openURL(url);
}
else
{
......@@ -224,7 +255,7 @@ void KimeShell::writeConfig(KConfigGroup &config) {
void KimeShell::saveProperties(KConfigGroup &config)
{
//writeConfig(config);
m_part->saveProperties(config);
m_editorInterface->saveProperties(config);
writeConfig();
}
......@@ -232,7 +263,7 @@ void KimeShell::saveProperties(KConfigGroup &config)
void KimeShell::readProperties(const KConfigGroup &config)
{
readConfig();
m_part->readProperties(config);
m_editorInterface->readProperties(config);
}
......
......@@ -22,7 +22,10 @@
#include <KConfigGroup>
#include <QUrl>
class KImageMapEditor;
namespace KParts {
class ReadWritePart;
}
class KImageMapEditorInterface;
class KimeShell : public KParts::MainWindow
{
......@@ -66,8 +69,10 @@ private slots:
void optionsConfigureToolbars();
void applyNewToolbarConfig();
private:
KImageMapEditor *m_part;
KParts::ReadWritePart *m_part;
KImageMapEditorInterface *m_editorInterface;
bool _stdout; // write HTML-Code to stdout on exit ?
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment