Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:epopov:branches:openSUSE:Factory
kate
2000-project-plugin.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 2000-project-plugin.patch of Package kate
diff --git a/apps/lib/katemainwindow.cpp b/apps/lib/katemainwindow.cpp index 42a74b92c76288debda8dd973a0dbf6da16bfeae..a054a39504be1a25689533345148b65491edb6e3 100644 --- a/apps/lib/katemainwindow.cpp +++ b/apps/lib/katemainwindow.cpp @@ -1372,14 +1372,50 @@ bool KateMainWindow::event(QEvent *e) return KateMDI::MainWindow::event(e); } -QObject *KateMainWindow::pluginView(const QString &name) +QObject *KateMainWindow::pluginView(const QString &name, bool askToActivate) { - KTextEditor::Plugin *plugin = KateApp::self()->pluginManager()->plugin(name); - if (!plugin) { + if (KTextEditor::Plugin *plugin = KateApp::self()->pluginManager()->plugin(name)) { + return m_pluginViews.value(plugin); + } + + if (!askToActivate) { + return nullptr; + } + + // try to find and activate the plugin + KatePluginList &pluginList = KateApp::self()->pluginManager()->pluginList(); + KatePluginList::iterator i = std::find_if(pluginList.begin(), pluginList.end(), [&name](const KatePluginInfo &pluginInfo) { + return pluginInfo.metaData.pluginId() == name; + }); + + QString text; + if (i == pluginList.end()) { + text = i18n("The required plugin was not found"); + KMessageBox::error(this, text); return nullptr; } - return m_pluginViews.contains(plugin) ? m_pluginViews.value(plugin) : nullptr; + KatePluginInfo &pluginInfo = *i; + text = i18n("In order to continue, the <b>%1</b> plugin must be enabled. Enable it?", pluginInfo.metaData.name()); + if (KMessageBox::questionTwoActions(this, + text, + i18nc("@title:window", "Enable Plugin"), + KGuiItem(i18nc("@action:button", "Enable"), + QStringLiteral("dialog-ok")), + KStandardGuiItem::cancel()) + == KMessageBox::SecondaryAction) { + return nullptr; + } + + if (!KateApp::self()->pluginManager()->loadPlugin(&pluginInfo)) { + text = i18n("Failed to enable the <b>%1</b> plugin", pluginInfo.metaData.name()); + KMessageBox::error(this, text); + return nullptr; + } + + KateApp::self()->pluginManager()->enablePluginGUI(&pluginInfo); + + return m_pluginViews.value(pluginInfo.plugin); } bool KateMainWindow::addWidget(QWidget *widget) diff --git a/apps/lib/katemainwindow.h b/apps/lib/katemainwindow.h index 840fb5755608a40cbdb2ddcd3103dc4a974ff403..0e9263c3a46a868f51ebf5a45663effa3357aa63 100644 --- a/apps/lib/katemainwindow.h +++ b/apps/lib/katemainwindow.h @@ -551,7 +551,7 @@ public Q_SLOTS: * \return pointer to the plugin view if a plugin with \p name is loaded and has a view for this mainwindow, * otherwise NULL */ - QObject *pluginView(const QString &name); + QObject *pluginView(const QString &name, bool askToActivate = false); /** * Add a widget to the main window. diff --git a/apps/lib/kateviewmanager.cpp b/apps/lib/kateviewmanager.cpp index ca11e3ccd1549df39dc0899905cb91d1bb316b7f..624819720b2955e9fce6f3aca59ece33cd15225f 100644 --- a/apps/lib/kateviewmanager.cpp +++ b/apps/lib/kateviewmanager.cpp @@ -486,6 +486,19 @@ void KateViewManager::openUrl(const QUrl &url) openUrl(url, QString()); } +void KateViewManager::openProject() +{ + if (KateApp::isKWrite()) { + const QString text = i18n("%1 cannot open folders", KAboutData::applicationData().displayName()); + KMessageBox::error(mainWindow(), text); + return; + } + + if (QObject *pluginView = mainWindow()->pluginView(QStringLiteral("kateprojectplugin"), true)) { + QMetaObject::invokeMethod(pluginView, "openDirectoryOrProject"); + } +} + void KateViewManager::openUrlOrProject(const QUrl &url) { if (!url.isLocalFile()) { @@ -506,46 +519,9 @@ void KateViewManager::openUrlOrProject(const QUrl &url) return; } - // try to open the folder - static const QString projectPluginId = QStringLiteral("kateprojectplugin"); - QObject *projectPluginView = mainWindow()->pluginView(projectPluginId); - if (!projectPluginView) { - // try to find and enable the Projects plugin - KatePluginList &pluginList = KateApp::self()->pluginManager()->pluginList(); - KatePluginList::iterator i = std::find_if(pluginList.begin(), pluginList.end(), [](const KatePluginInfo &pluginInfo) { - return pluginInfo.metaData.pluginId() == projectPluginId; - }); - - QString text; - if (i == pluginList.end()) { - text = i18n("The plugin required to open folders was not found"); - KMessageBox::error(mainWindow(), text); - return; - } - - KatePluginInfo &projectPluginInfo = *i; - text = i18n("In order to open folders, the <b>%1</b> plugin must be enabled. Enable it?", projectPluginInfo.metaData.name()); - if (KMessageBox::questionTwoActions(mainWindow(), - text, - i18nc("@title:window", "Open Folder"), - KGuiItem(i18nc("@action:button", "Enable"), QStringLiteral("dialog-ok")), - KStandardGuiItem::cancel()) - == KMessageBox::SecondaryAction) { - return; - } - - if (!KateApp::self()->pluginManager()->loadPlugin(&projectPluginInfo)) { - text = i18n("Failed to enable <b>%1</b> plugin", projectPluginInfo.metaData.name()); - KMessageBox::error(mainWindow(), text); - return; - } - - KateApp::self()->pluginManager()->enablePluginGUI(&projectPluginInfo); - projectPluginView = mainWindow()->pluginView(projectPluginId); + if (QObject *pluginView = mainWindow()->pluginView(QStringLiteral("kateprojectplugin"), true)) { + QMetaObject::invokeMethod(pluginView, "openDirectoryOrProject", Q_ARG(const QDir &, dir)); } - - Q_ASSERT(projectPluginView); - QMetaObject::invokeMethod(projectPluginView, "openDirectoryOrProject", Q_ARG(const QDir &, dir)); } KTextEditor::View *KateViewManager::openViewForDoc(KTextEditor::Document *doc) diff --git a/apps/lib/kateviewmanager.h b/apps/lib/kateviewmanager.h index a9412fdfde31cca4b2a3f882680f3135f4e55757..7edacbced0154914ff67fa0370bf47fab8d11599 100644 --- a/apps/lib/kateviewmanager.h +++ b/apps/lib/kateviewmanager.h @@ -77,6 +77,7 @@ public: public Q_SLOTS: void openUrl(const QUrl &url); + void openProject(); void openUrlOrProject(const QUrl &url); void addPositionToHistory(const QUrl &url, KTextEditor::Cursor pos); diff --git a/apps/lib/welcomeview/welcomeview.cpp b/apps/lib/welcomeview/welcomeview.cpp index 05ed011962daff986365393535657b8df619bec6..397e1d7e7b679a35bf50d45c0751de1ac7aada2c 100644 --- a/apps/lib/welcomeview/welcomeview.cpp +++ b/apps/lib/welcomeview/welcomeview.cpp @@ -89,9 +89,9 @@ WelcomeView::WelcomeView(KateViewManager *viewManager, QWidget *parent) connect(buttonNewFile, &QPushButton::clicked, m_viewManager, &KateViewManager::slotDocumentNew); connect(buttonOpenFile, &QPushButton::clicked, m_viewManager, &KateViewManager::slotDocumentOpen); - connect(buttonClearRecentItems, &QPushButton::clicked, this, [recentFilesAction]() { - recentFilesAction->clear(); - }); + connect(buttonOpenFolder, &QPushButton::clicked, m_viewManager, &KateViewManager::openProject); + connect(buttonClearRecentItems, &QPushButton::clicked, + recentFilesAction, &KRecentFilesAction::clear); connect(labelHomepage, qOverload<>(&KUrlLabel::leftClickedUrl), this, [aboutData]() { QDesktopServices::openUrl(QUrl(aboutData.homepage())); @@ -99,17 +99,11 @@ WelcomeView::WelcomeView(KateViewManager *viewManager, QWidget *parent) connect(labelContribute, qOverload<>(&KUrlLabel::leftClickedUrl), this, []() { QDesktopServices::openUrl(QUrl(QStringLiteral("https://kate-editor.org/join-us"))); }); - connect(labelHandbook, qOverload<>(&KUrlLabel::leftClickedUrl), this, [this]() { - m_viewManager->mainWindow()->appHelpActivated(); - }); - - onPluginViewChanged(); - - const KTextEditor::MainWindow *mainWindow = m_viewManager->mainWindow()->wrapper(); - connect(mainWindow, &KTextEditor::MainWindow::pluginViewCreated, this, &WelcomeView::onPluginViewChanged); - connect(mainWindow, &KTextEditor::MainWindow::pluginViewDeleted, this, &WelcomeView::onPluginViewChanged); + connect(labelHandbook, qOverload<>(&KUrlLabel::leftClickedUrl), + m_viewManager->mainWindow(), &KateMainWindow::appHelpActivated); if (KateApp::isKWrite()) { + buttonOpenFolder->hide(); widgetSavedSessions->hide(); } else { m_placeholderSavedSessions = new Placeholder; @@ -209,20 +203,6 @@ bool WelcomeView::eventFilter(QObject *watched, QEvent *event) return QScrollArea::eventFilter(watched, event); } -void WelcomeView::onPluginViewChanged(const QString &pluginName) -{ - static const QString projectPluginName = QStringLiteral("kateprojectplugin"); - if (pluginName.isEmpty() || pluginName == projectPluginName) { - QObject *projectPluginView = m_viewManager->mainWindow()->pluginView(projectPluginName); - if (projectPluginView) { - connect(buttonOpenFolder, SIGNAL(clicked()), projectPluginView, SLOT(openDirectoryOrProject())); - buttonOpenFolder->show(); - } else { - buttonOpenFolder->hide(); - } - } -} - void WelcomeView::onRecentItemsContextMenuRequested(const QPoint &pos) { const QModelIndex index = listViewRecentItems->indexAt(pos); diff --git a/apps/lib/welcomeview/welcomeview.h b/apps/lib/welcomeview/welcomeview.h index 23a2b0afc2478558569368478e43b27fc96cd3ee..267260b6eae0f5b84d381ec3a95277b3ed7b8f58 100644 --- a/apps/lib/welcomeview/welcomeview.h +++ b/apps/lib/welcomeview/welcomeview.h @@ -28,7 +28,6 @@ protected: bool eventFilter(QObject *watched, QEvent *event) override; private Q_SLOTS: - void onPluginViewChanged(const QString &pluginName = QString()); void onRecentItemsContextMenuRequested(const QPoint &pos); bool shouldClose() {
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor