From 07992ed1c7bf04202c8e0ee23db7b2415cea634e Mon Sep 17 00:00:00 2001 From: Francesc M Date: Mon, 2 Mar 2020 21:55:23 +0100 Subject: [PATCH] Cleaning the project --- GitQlientPlugin.cpp | 98 ++++++++++---------------------------- GitQlientPlugin.h | 15 +++--- GitQlientPlugin.pro | 4 +- GitQlientPluginConstants.h | 11 ----- GitQlientPlugin_global.h | 12 ----- 5 files changed, 32 insertions(+), 108 deletions(-) delete mode 100644 GitQlientPluginConstants.h delete mode 100644 GitQlientPlugin_global.h diff --git a/GitQlientPlugin.cpp b/GitQlientPlugin.cpp index d1d43d1..486674c 100644 --- a/GitQlientPlugin.cpp +++ b/GitQlientPlugin.cpp @@ -1,50 +1,20 @@ #include "GitQlientPlugin.h" -#include "GitQlientPluginConstants.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - -#include -#include +#include +#include #include #include +#include + #include namespace GitQlientNamespace { - namespace Internal { -MyMode::MyMode() +GitQlientMode::GitQlientMode() { const Utils::Icon FLAT({ { ":/git.png", Utils::Theme::IconsBaseColor } }); const Utils::Icon FLAT_ACTIVE({ { ":/git.png", Utils::Theme::IconsModeEditActiveColor } }); @@ -53,7 +23,7 @@ MyMode::MyMode() Core::Id id("GitQlient"); setDisplayName("GitQlient"); - setPriority(88); + setPriority(0); setEnabled(true); setId(id); @@ -64,64 +34,46 @@ MyMode::MyMode() GitQlientPlugin::GitQlientPlugin() { - // Create your members + mGitQlientMode = new GitQlientMode(); } GitQlientPlugin::~GitQlientPlugin() { - // Unregister objects from the plugin manager's object pool - // Delete members + delete mGitQlientMode; } bool GitQlientPlugin::initialize(const QStringList &arguments, QString *errorString) { - // Register objects in the plugin manager's object pool - // Load settings - // Add actions to menus - // Connect to other plugins' signals - // In the initialize function, a plugin can be sure that the plugins it - // depends on have initialized their members. - Q_UNUSED(arguments) Q_UNUSED(errorString) - myMode = new MyMode(); + connect(Core::ModeManager::instance(), &Core::ModeManager::currentModeAboutToChange, this, + &GitQlientPlugin::aboutToChange); - connect(Core::ModeManager::instance(), &Core::ModeManager::currentModeAboutToChange, this, [this](Core::Id mode) { - if (mode == myMode->id()) - { - bool found; - const auto workingDirectory = Utils::globalMacroExpander()->value("CurrentProject:Path", &found); - const auto projects = ProjectExplorer::SessionManager::projects(); - QStringList currentOpenedProjects; + return true; +} - for (auto project : projects) - { - qDebug() << project->projectDirectory().toString(); - currentOpenedProjects.append(project->projectDirectory().toString()); - } +void GitQlientPlugin::aboutToChange(Core::Id mode) +{ + if (mode == mGitQlientMode->id()) + { + bool found; + const auto workingDirectory = Utils::globalMacroExpander()->value("CurrentProject:Path", &found); + QStringList currentOpenedProjects; - myMode->mGitImpl->setRepositories(currentOpenedProjects); + for (auto project : ProjectExplorer::SessionManager::projects()) + currentOpenedProjects.append(project->projectDirectory().toString()); - Core::ModeManager::instance()->setFocusToCurrentMode(); - } - }); + mGitQlientMode->mGitImpl->setRepositories(currentOpenedProjects); - return true; + Core::ModeManager::instance()->setFocusToCurrentMode(); + } } -void GitQlientPlugin::extensionsInitialized() -{ - // Retrieve objects from the plugin manager's object pool - // In the extensionsInitialized function, a plugin can be sure that all - // plugins that depend on it are completely initialized. -} +void GitQlientPlugin::extensionsInitialized() {} ExtensionSystem::IPlugin::ShutdownFlag GitQlientPlugin::aboutToShutdown() { - // Save settings - // Disconnect from signals that are not needed during shutdown - // Hide UI (if you add UI that is not in the main window directly) return SynchronousShutdown; } diff --git a/GitQlientPlugin.h b/GitQlientPlugin.h index 5bf1aed..f3bdcfe 100644 --- a/GitQlientPlugin.h +++ b/GitQlientPlugin.h @@ -1,11 +1,8 @@ -#ifndef GitQlientPlugin_H -#define GitQlientPlugin_H +#pragma once -#include "GitQlientPlugin_global.h" #include #include -#include using namespace Core; @@ -16,12 +13,12 @@ namespace GitQlientNamespace namespace Internal { -class MyMode : public Core::IMode +class GitQlientMode : public Core::IMode { Q_OBJECT public: - MyMode(); + GitQlientMode(); GitQlient *mGitImpl = nullptr; }; @@ -40,11 +37,11 @@ class GitQlientPlugin : public ExtensionSystem::IPlugin ShutdownFlag aboutToShutdown() override; private: - MyMode *myMode = nullptr; + GitQlientMode *mGitQlientMode = nullptr; QString mCurrentProject; + + void aboutToChange(Core::Id mode); }; } // namespace Internal } // namespace GitQlientPlugin - -#endif // GitQlientPlugin_H diff --git a/GitQlientPlugin.pro b/GitQlientPlugin.pro index 911edb0..f7bb6f6 100644 --- a/GitQlientPlugin.pro +++ b/GitQlientPlugin.pro @@ -9,9 +9,7 @@ SOURCES += \ GitQlientPlugin.cpp HEADERS += \ - GitQlientPlugin.h \ - GitQlientPlugin_global.h \ - GitQlientPluginConstants.h + GitQlientPlugin.h INCLUDEPATH+= src diff --git a/GitQlientPluginConstants.h b/GitQlientPluginConstants.h deleted file mode 100644 index dc5b6aa..0000000 --- a/GitQlientPluginConstants.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -namespace GitQLientPlugin -{ - -namespace Internal -{ -const char ACTION_ID[] = "GitEditorPlugin.Action"; -const char MENU_ID[] = "GitEditorPlugin.Menu"; -} -} // namespace GitQLientPlugin diff --git a/GitQlientPlugin_global.h b/GitQlientPlugin_global.h deleted file mode 100644 index 9a5ad90..0000000 --- a/GitQlientPlugin_global.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef GITEDITORPLUGIN_GLOBAL_H -#define GITEDITORPLUGIN_GLOBAL_H - -#include - -#if defined(GITQLIENTPLUGIN_LIBRARY) -# define GITQLIENTPLUGINSHARED_EXPORT Q_DECL_EXPORT -#else -# define GITQLIENTPLUGINSHARED_EXPORT Q_DECL_IMPORT -#endif - -#endif // GITEDITORPLUGIN_GLOBAL_H