Skip to content

Commit

Permalink
Cleaning the project
Browse files Browse the repository at this point in the history
  • Loading branch information
francescmm committed Mar 2, 2020
1 parent e34df9d commit 07992ed
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 108 deletions.
98 changes: 25 additions & 73 deletions GitQlientPlugin.cpp
Original file line number Diff line number Diff line change
@@ -1,50 +1,20 @@
#include "GitQlientPlugin.h"
#include "GitQlientPluginConstants.h"

#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/command.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/fancytabwidget.h>
#include <coreplugin/icontext.h>
#include <coreplugin/icore.h>
#include <coreplugin/id.h>
#include <coreplugin/modemanager.h>
#include <extensionsystem/pluginmanager.h>

#include <QAction>
#include <QLabel>
#include <QMainWindow>
#include <QMenu>
#include <QMessageBox>
#include <QPushButton>
#include <QSplitter>
#include <QVBoxLayout>

#include <coreplugin/coreconstants.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/minisplitter.h>
#include <coreplugin/navigationwidget.h>
#include <coreplugin/outputpane.h>
#include <coreplugin/rightpane.h>

#include <plugins/projectexplorer/projectexplorer.h>

#include <QDebug>
#include <GitQlient.h>

#include <coreplugin/modemanager.h>
#include <utils/macroexpander.h>
#include <projectexplorer/session.h>
#include <projectexplorer/project.h>

#include <GitQlient.h>

#include <utils/icon.h>

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 } });
Expand All @@ -53,7 +23,7 @@ MyMode::MyMode()
Core::Id id("GitQlient");

setDisplayName("GitQlient");
setPriority(88);
setPriority(0);
setEnabled(true);
setId(id);

Expand All @@ -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;
}

Expand Down
15 changes: 6 additions & 9 deletions GitQlientPlugin.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
#ifndef GitQlientPlugin_H
#define GitQlientPlugin_H
#pragma once

#include "GitQlientPlugin_global.h"
#include <coreplugin/imode.h>

#include <extensionsystem/iplugin.h>
#include <coreplugin/idocument.h>

using namespace Core;

Expand All @@ -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;
};
Expand All @@ -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
4 changes: 1 addition & 3 deletions GitQlientPlugin.pro
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ SOURCES += \
GitQlientPlugin.cpp

HEADERS += \
GitQlientPlugin.h \
GitQlientPlugin_global.h \
GitQlientPluginConstants.h
GitQlientPlugin.h

INCLUDEPATH+= src

Expand Down
11 changes: 0 additions & 11 deletions GitQlientPluginConstants.h

This file was deleted.

12 changes: 0 additions & 12 deletions GitQlientPlugin_global.h

This file was deleted.

0 comments on commit 07992ed

Please sign in to comment.