diff --git a/src/kjotspart.cpp b/src/kjotspart.cpp index 13f721f..0d0abc5 100644 --- a/src/kjotspart.cpp +++ b/src/kjotspart.cpp @@ -1,88 +1,73 @@ /* This file is part of KJots. Copyright (c) 2008 Stephen Kelly 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. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #include "kjotspart.h" #include "aboutdata.h" #include "kjotswidget.h" #include #include #include #include #include -const KAboutData &createAboutData() -{ - static AboutData aboutData; - return aboutData; -} - K_PLUGIN_FACTORY(KJotsPartFactory, registerPlugin();) KJotsPart::KJotsPart(QWidget *parentWidget, QObject *parent, const QVariantList & /*args*/) : KParts::ReadOnlyPart(parent) { - // we need an instance - //QT5 setComponentData( KJotsPartFactory::componentData() ); - // this should be your custom internal widget mComponent = new KJotsWidget(parentWidget, this); - mStatusBar = new KParts::StatusBarExtension(this); // notify the part that this is our internal widget setWidget(mComponent); initAction(); // set our XML-UI resource file - setComponentName(QStringLiteral("kjots"), QStringLiteral("kjots")); + setComponentName(QStringLiteral("kjots"), i18n("KJots")); setXMLFile(QStringLiteral("kjotspartui.rc")); connect(mComponent, &KJotsWidget::captionChanged, this, &KJotsPart::setWindowCaption); } KJotsPart::~KJotsPart() { mComponent->queryClose(); } void KJotsPart::initAction() { auto *action = new QAction(QIcon::fromTheme(QStringLiteral("configure")), i18n("&Configure KJots..."), this); actionCollection()->addAction(QStringLiteral("kjots_configure"), action); connect(action, &QAction::triggered, mComponent, &KJotsWidget::configure); } bool KJotsPart::openFile() { return false; } -// -// bool KJotsPart::saveFile() -// { -// return false; -// } #include "kjotspart.moc" diff --git a/src/kjotspart.h b/src/kjotspart.h index 86a5549..7699b43 100644 --- a/src/kjotspart.h +++ b/src/kjotspart.h @@ -1,71 +1,67 @@ /* This file is part of KJots. Copyright (c) 2008 Stephen Kelly 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. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #ifndef KJOTSPART_H #define KJOTSPART_H #include #include class QWidget; class KAboutData; class KJotsWidget; /** * This is a "Part". It that does all the real work in a KPart * application. * * @short Main Part * @author Stephen Kelly * @version 0.1 */ class KJotsPart : public KParts::ReadOnlyPart { Q_OBJECT public: /** * Default constructor */ KJotsPart(QWidget *parentWidget, QObject *parent, const QVariantList &); /** * Destructor */ ~KJotsPart() override; - - static KAboutData *createAboutData(); - protected: /** * This must be implemented by each part */ bool openFile() override; private: void initAction(); KJotsWidget *mComponent; - KParts::StatusBarExtension *mStatusBar; }; #endif // KJOTSPART_H diff --git a/src/kontact_plugin/kjots_plugin.cpp b/src/kontact_plugin/kjots_plugin.cpp index 105b07e..640ab48 100644 --- a/src/kontact_plugin/kjots_plugin.cpp +++ b/src/kontact_plugin/kjots_plugin.cpp @@ -1,110 +1,102 @@ /* Copyright (C) 2016 Daniel Vrátil 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. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #include "kjots_plugin.h" #include "kjotspart.h" //#include "akregator_options.h" //#include "partinterface.h" #include #include #include #include #include #include #if KONTACTINTERFACE_VERSION < QT_VERSION_CHECK(5, 14, 42) /** Exports Kontact plugin. @param pluginclass the class to instantiate (must derive from KontactInterface::Plugin @param jsonFile filename of the JSON file, generated from a .desktop file */ #define EXPORT_KONTACT_PLUGIN_WITH_JSON( pluginclass, jsonFile ) \ class Instance \ { \ public: \ static QObject *createInstance( QWidget *, QObject *parent, const QVariantList &list ) \ { return new pluginclass( static_cast( parent ), list ); } \ }; \ K_PLUGIN_FACTORY_WITH_JSON( KontactPluginFactory, jsonFile, registerPlugin< pluginclass > \ ( QString(), Instance::createInstance ); ) \ K_EXPORT_PLUGIN_VERSION(KONTACT_PLUGIN_VERSION) #endif EXPORT_KONTACT_PLUGIN_WITH_JSON(KJotsPlugin, "kjotsplugin.json") KJotsPlugin::KJotsPlugin(KontactInterface::Core *core, const QVariantList &/*args*/) : KontactInterface::Plugin(core, core, "kjots") { - setComponentName(QStringLiteral("kjots"), QStringLiteral("kjots")); + setComponentName(QStringLiteral("kjots"), i18n("KJots")); mUniqueAppWatcher = new KontactInterface::UniqueAppWatcher( new KontactInterface::UniqueAppHandlerFactory(), this); } bool KJotsPlugin::isRunningStandalone() const { return mUniqueAppWatcher->isRunningStandalone(); } QStringList KJotsPlugin::invisibleToolbarActions() const { return { QStringLiteral("akonadi_note_create"), QStringLiteral("akonadi_collection_create") }; } #if KONTACTINTERFACE_VERSION >= QT_VERSION_CHECK(5, 14, 42) KParts::Part *KJotsPlugin::createPart() { return loadPart(); } #else KParts::ReadOnlyPart *KJotsPlugin::createPart() { return loadPart(); } #endif -QStringList KJotsPlugin::configModules() const -{ - QStringList modules; - modules << QStringLiteral("PIM/kjots.desktop"); - return modules; -} - - void KJotsUniqueAppHandler::loadCommandLineOptions(QCommandLineParser *parser) { Q_UNUSED(parser) } int KJotsUniqueAppHandler::activate(const QStringList &args, const QString &workingDir) { // Ensure part is loaded (void)plugin()->part(); return KontactInterface::UniqueAppHandler::activate(args, workingDir); } #include "kjots_plugin.moc" diff --git a/src/kontact_plugin/kjots_plugin.h b/src/kontact_plugin/kjots_plugin.h index a73f374..ca06d65 100644 --- a/src/kontact_plugin/kjots_plugin.h +++ b/src/kontact_plugin/kjots_plugin.h @@ -1,75 +1,74 @@ /* Copyright (C) 2016 Daniel Vrátil 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. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #ifndef KJOTS_PLUGIN_H #define KJOTS_PLUGIN_H #include #include namespace KontactInterface { class Plugin; } class KJotsUniqueAppHandler : public KontactInterface::UniqueAppHandler { Q_OBJECT public: explicit KJotsUniqueAppHandler(KontactInterface::Plugin *plugin) : KontactInterface::UniqueAppHandler(plugin) { } int activate(const QStringList &args, const QString &workingDir) Q_DECL_OVERRIDE; void loadCommandLineOptions(QCommandLineParser *parser) Q_DECL_OVERRIDE; }; class KJotsPlugin : public KontactInterface::Plugin { Q_OBJECT public: KJotsPlugin(KontactInterface::Core *core, const QVariantList &); int weight() const Q_DECL_OVERRIDE { return 475; } - virtual QStringList configModules() const; bool isRunningStandalone() const Q_DECL_OVERRIDE; QStringList invisibleToolbarActions() const Q_DECL_OVERRIDE; protected: #if KONTACTINTERFACE_VERSION >= QT_VERSION_CHECK(5, 14, 42) KParts::Part *createPart() override; #else KParts::ReadOnlyPart *createPart() Q_DECL_OVERRIDE; #endif KontactInterface::UniqueAppWatcher *mUniqueAppWatcher; }; #endif