Index: CMakeLists.txt =================================================================== --- CMakeLists.txt +++ CMakeLists.txt @@ -18,11 +18,14 @@ include(KDEInstallDirs) include(KDECMakeSettings) include(FeatureSummary) +include(ECMQtDeclareLoggingCategory) +include(KDECMakeSettings) +include(WriteBasicConfigVersionFile) set(QT_MIN_VERSION "5.5.0") find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED Core Widgets) set(KF5_DEP_VERSION "5.15.0") -find_package(KF5 ${KF5_DEP_VERSION} REQUIRED COMPONENTS TextEditor I18n KCMUtils JobWidgets Service Parts KIO CoreAddons ItemModels) +find_package(KF5 ${KF5_DEP_VERSION} REQUIRED COMPONENTS Config TextEditor I18n KCMUtils JobWidgets Service Parts KIO CoreAddons ItemModels XmlGui) find_package(KDevPlatform ${KDEVPLATFORM_VERSION} REQUIRED) include_directories( @@ -43,12 +46,23 @@ uploadprofileitem.cpp uploadprofilemodel.cpp uploadprojectmodel.cpp + uploadpreferences.cpp ) set(kdevupload_UI uploaddialog.ui uploadprofiledlg.ui + uploadpreferences.ui +) + +ecm_qt_declare_logging_category(projectfilter_SRCS + HEADER debug.h + IDENTIFIER PLUGIN_PROJECTFILTER + CATEGORY_NAME "kdevelop.plugins.upload" ) +ki18n_wrap_ui(uploadpreferences_PART_SRCS uploadpreferences.ui uploadprofiledlg.ui uploaddialog.ui) +kconfig_add_kcfg_files( kdevupload_PART_SRCS uploadconfig.kcfgc ) + add_library(kdevupload_PART_SRCS ${kdevupload_UI}) qt5_add_resources(kdevupload_PART_SRCS kdevupload.qrc) @@ -67,32 +81,3 @@ KF5::KIONTLM KF5::CoreAddons ) - -#preferences-plugin -set(uploadpreferences_PART_SRCS - uploadpreferences.cpp - uploadprofilemodel.cpp - uploadprofileitem.cpp - uploadprofiledlg.cpp -) -ki18n_wrap_ui(uploadpreferences_PART_SRCS uploadpreferences.ui uploadprofiledlg.ui uploaddialog.ui) -add_library(uploadpreferences_PART_SRCS uploadpreferences.ui uploadprofiledlg.ui uploaddialog.ui) - -add_library(kcm_kdev_upload ${uploadpreferences_PART_SRCS}) - -target_link_libraries(kcm_kdev_upload - KDev::Interfaces - KDev::Util - - KF5::I18n - KF5::KCMUtils - KF5::Service - KF5::Parts - KF5::KIOCore - KF5::KIOFileWidgets - KF5::KIOWidgets - KF5::KIONTLM -) - -install(TARGETS kcm_kdev_upload DESTINATION ${PLUGIN_INSTALL_DIR}) -install(FILES kcm_kdev_upload.desktop DESTINATION ${SERVICES_INSTALL_DIR}) Index: kdevuploadplugin.h =================================================================== --- kdevuploadplugin.h +++ kdevuploadplugin.h @@ -35,7 +35,6 @@ public: UploadPlugin(QObject *parent, const QVariantList & = QVariantList() ); ~UploadPlugin() override; - void unload() override; /** * Returns the Upload-Action for the Contextmenu. @@ -47,6 +46,9 @@ * Creates the output-view (only the first time called) */ QStandardItemModel* outputModel(); + + int perProjectConfigPages() const override; + KDevelop::ConfigPage* perProjectConfigPage(int number, const KDevelop::ProjectConfigOptions& options, QWidget* parent) override; private Q_SLOTS: /** Index: kdevuploadplugin.cpp =================================================================== --- kdevuploadplugin.cpp +++ kdevuploadplugin.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -40,6 +41,7 @@ #include "uploadprojectmodel.h" #include "uploadprofilemodel.h" #include "uploadprofileitem.h" +#include "uploadpreferences.h" #include "allprofilesmodel.h" #include @@ -193,10 +195,6 @@ } } -void UploadPlugin::unload() -{ -} - KDevelop::ContextMenuExtension UploadPlugin::contextMenuExtension(KDevelop::Context* context, QWidget* parent) { if (context->type() == KDevelop::Context::ProjectItemContext) { @@ -232,6 +230,17 @@ return KDevelop::IPlugin::contextMenuExtension(context, parent); } +int UploadPlugin::perProjectConfigPages() const +{ + return 1; +} + + +KDevelop::ConfigPage* UploadPlugin::perProjectConfigPage(int number, const KDevelop::ProjectConfigOptions& options, QWidget* parent) +{ + return number == 0 ? new UploadPreferences(this, options, parent) : nullptr; +} + void UploadPlugin::upload() { if (m_ctxUrlList.isEmpty()) return; Index: uploadconfig.kcfg =================================================================== --- /dev/null +++ uploadconfig.kcfg @@ -0,0 +1,7 @@ + + + + Index: uploadconfig.kcfgc =================================================================== --- /dev/null +++ uploadconfig.kcfgc @@ -0,0 +1,9 @@ +File=uploadconfig.kcfg +ClassName=UploadSettings +Singleton=true +Mutators=true +SetUserTexts=true +ItemAccessors=true +Inherits=KDevelop::ProjectConfigSkeleton +IncludeFiles=project/projectconfigskeleton.h +SourceIncludeFiles=uploadpreferences.h Index: uploadpreferences.h =================================================================== --- uploadpreferences.h +++ uploadpreferences.h @@ -11,10 +11,13 @@ #ifndef UPLOADPREFERENCES_H #define UPLOADPREFERENCES_H -#include #include #include +#include + +#include "uploadconfig.h" + namespace Ui { class UploadPreferences; } @@ -25,15 +28,21 @@ /** * KCModule for upload profiles configuration */ -class UploadPreferences : public KCModule +class UploadPreferences : public ProjectConfigPage { Q_OBJECT public: - UploadPreferences( QWidget *parent, const QVariantList &args = QVariantList() ); + UploadPreferences(KDevelop::IPlugin* plugin, const KDevelop::ProjectConfigOptions& options, QWidget* parent); ~UploadPreferences() override; - void save() override; + void reset() override; + void apply() override; + void defaults() override; + + QString name() const override; + QString fullName() const override; + QIcon icon() const override; private Q_SLOTS: void addProfile(); Index: uploadpreferences.cpp =================================================================== --- uploadpreferences.cpp +++ uploadpreferences.cpp @@ -12,9 +12,6 @@ #include #include -#include -#include - #include #include #include @@ -25,39 +22,22 @@ #include "ui_uploadpreferences.h" #include "uploadprofiledlg.h" #include "uploadprofileitem.h" -#include "kdevuploadplugin.h" using namespace KDevelop; -K_PLUGIN_FACTORY(UploadPreferencesFactory, registerPlugin(); ) - -UploadPreferences::UploadPreferences( QWidget *parent, const QVariantList &args ) - : KCModule( parent, args ) +UploadPreferences::UploadPreferences( KDevelop::IPlugin* plugin, const KDevelop::ProjectConfigOptions& options, QWidget* parent ) + : ProjectConfigPage(plugin, options, parent) { - IProject* project = nullptr; - Q_FOREACH (IProject* p, KDevelop::ICore::self()->projectController()->projects()) { - if (p->projectFile().path() == args.at(1).toString()) { - project = p; - break; - } - } - Q_ASSERT(project); - - - setButtons(Help | Apply); - - QVBoxLayout * l = new QVBoxLayout( this ); - setLayout(l); - QWidget* w = new QWidget(); - l->addWidget(w); + IProject* project = options.project; m_ui = new Ui::UploadPreferences(); - m_ui->setupUi(w); + m_ui->setupUi(this); m_model = new UploadProfileModel(); m_model->setProject(project); m_ui->profilesList->setModel(m_model); + connect(m_model, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(changed())); connect(m_model, SIGNAL(rowsRemoved(QModelIndex, int, int)), @@ -80,9 +60,20 @@ delete m_ui; } -void UploadPreferences::save() +void UploadPreferences::reset() +{ + ProjectConfigPage::reset(); +} + +void UploadPreferences::apply() { m_model->submit(); + ProjectConfigPage::apply(); +} + +void UploadPreferences::defaults() +{ + ProjectConfigPage::defaults(); } void UploadPreferences::addProfile() @@ -114,5 +105,19 @@ } } -#include "uploadpreferences.moc" +QString UploadPreferences::name() const +{ + return i18n("Upload"); +} + +QString UploadPreferences::fullName() const +{ + return i18n("Configure Upload settings"); +} + +QIcon UploadPreferences::icon() const +{ + return QIcon::fromTheme(QStringLiteral("go-up")); +} + // kate: space-indent on; indent-width 4; tab-width 4; replace-tabs on