File indexing completed on 2024-05-19 05:19:21
0001 /* 0002 This file is part of KJots. 0003 0004 SPDX-FileCopyrightText: 2008 Stephen Kelly <steveire@gmail.com> 0005 0006 SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0 0007 */ 0008 0009 #include "kjotspart.h" 0010 #include "aboutdata.h" 0011 #include "kjotswidget.h" 0012 0013 #include <QIcon> 0014 #include <QAction> 0015 0016 #include <KActionCollection> 0017 #include <KPluginFactory> 0018 #include <KLocalizedString> 0019 0020 0021 K_PLUGIN_CLASS_WITH_JSON(KJotsPart, "kjotspart.json") 0022 0023 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) 0024 KJotsPart::KJotsPart(QWidget *parentWidget, QObject *parent, const QVariantList &) 0025 : KParts::ReadOnlyPart(parent) 0026 #else 0027 KJotsPart::KJotsPart(QWidget *parentWidget, QObject *parent, const KPluginMetaData &data, const QVariantList &) 0028 : KParts::ReadOnlyPart(parent, data) 0029 #endif 0030 { 0031 // this should be your custom internal widget 0032 mComponent = new KJotsWidget(parentWidget, this); 0033 0034 // notify the part that this is our internal widget 0035 setWidget(mComponent); 0036 initAction(); 0037 0038 // set our XML-UI resource file 0039 setComponentName(QStringLiteral("kjots"), i18n("KJots")); 0040 setXMLFile(QStringLiteral("kjotsui.rc")); 0041 0042 connect(mComponent, &KJotsWidget::captionChanged, this, &KJotsPart::setWindowCaption); 0043 } 0044 0045 KJotsPart::~KJotsPart() 0046 { 0047 mComponent->queryClose(); 0048 } 0049 0050 void KJotsPart::initAction() 0051 { 0052 auto action = new QAction(QIcon::fromTheme(QStringLiteral("configure")), i18n("&Configure KJots..."), this); 0053 actionCollection()->addAction(QStringLiteral("kjots_configure"), action); 0054 connect(action, &QAction::triggered, mComponent, &KJotsWidget::configure); 0055 } 0056 0057 bool KJotsPart::openFile() 0058 { 0059 return false; 0060 } 0061 0062 #include "kjotspart.moc" 0063 0064 #include "moc_kjotspart.cpp"