6 Commits
v8 ... v18

Author SHA1 Message Date
1b6fac05be second try 2025-09-30 14:33:31 +03:00
b1a73990e6 first try for v18 2025-09-30 14:26:26 +03:00
10afcc9045 add label.txt content to project name 2025-09-30 14:02:32 +03:00
ea1547bb70 miss VendorId 2025-01-09 13:53:44 +03:00
62ec870192 first try 2025-01-09 13:49:30 +03:00
8ef5bef4b7 json 2025-01-09 13:12:41 +03:00
6 changed files with 57 additions and 39 deletions

View File

@@ -1,11 +1,14 @@
{
\"Name\" : \"ProjectFilesystemPlugin\",
\"Version\" : \"2.0.0\",
\"CompatVersion\" : \"1.1.0\",
\"Vendor\" : \"Peri4\",
\"Copyright\" : \"(C) Peri4\",
\"License\" : \"LGPLv3\",
\"Description\" : \"LGPLv3\",
\"Url\" : \"\",
$$dependencyList
"Id": "projectfilesystemplugin",
"Name" : "ProjectFilesystemPlugin",
"Version" : "3.0.0",
"CompatVersion" : "${IDE_VERSION_COMPAT}",
"VendorId" : "peri4",
"Vendor" : "Peri4",
"Copyright" : "(C) Peri4",
"License" : "LGPLv3",
"Description" : "LGPLv3",
"Url" : "",
${DESIGNER_PLUGIN_ARGUMENTS}
${IDE_PLUGIN_DEPENDENCIES}
}

View File

@@ -30,7 +30,7 @@ namespace ProjectFilesystemPlugin {
// Delete members
}
bool ProjectFilesystemPluginPlugin::initialize(const QStringList &arguments, QString *errorString)
Utils::Result<> ProjectFilesystemPluginPlugin::initialize(const QStringList &arguments)
{
// Register objects in the plugin manager's object pool
// Load settings
@@ -40,7 +40,6 @@ namespace ProjectFilesystemPlugin {
// depends on have initialized their members.
Q_UNUSED(arguments)
Q_UNUSED(errorString)
/*auto action = new QAction(tr("ProjectFilesystemPlugin Action"), this);
Core::Command *cmd = Core::ActionManager::registerAction(action, Constants::ACTION_ID,
@@ -57,12 +56,12 @@ namespace ProjectFilesystemPlugin {
//addAutoReleasedObject(new ProjectFSWidgetFactory());
(new ProjectFSWidgetFactory())->setParent(this);
return true;
return Utils::ResultOk;
}
void ProjectFilesystemPluginPlugin::extensionsInitialized()
{
Utils::globalMacroExpander()->registerPrefix("ProjectFilesystem", "Project filesystem plugin", [](QString v) -> QString {return v;} );
Utils::globalMacroExpander()->registerPrefix("ProjectFilesystem", "ProjectFilesystem", "Project filesystem plugin", [](QString v) -> QString {return v;} );
Utils::globalMacroExpander()->registerFileVariables("ProjectFilesystem", "Selected item",
[]() -> Utils::FilePath { return Utils::FilePath::fromString(projectfs_menu_target.absoluteFilePath());}, true);
// Retrieve objects from the plugin manager's object pool

View File

@@ -17,7 +17,7 @@ namespace ProjectFilesystemPlugin {
ProjectFilesystemPluginPlugin();
~ProjectFilesystemPluginPlugin();
bool initialize(const QStringList &arguments, QString *errorString) override;
Utils::Result<> initialize(const QStringList &arguments) override;
void extensionsInitialized() override;
ShutdownFlag aboutToShutdown() override;

View File

@@ -4,7 +4,6 @@
#include <coreplugin/icore.h>
#include <coreplugin/fileutils.h>
#include <coreplugin/navigationwidget.h>
#include <coreplugin/fileiconprovider.h>
#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/editormanager/ieditor.h>
@@ -17,10 +16,11 @@
#include <projectexplorer/project.h>
#include <projectexplorer/projectnodes.h>
#include <projectexplorer/buildmanager.h>
#include <projectexplorer/session.h>
#include <projectexplorer/projectmanager.h>
#include <projectexplorer/target.h>
#include <utils/utilsicons.h>
#include <utils/macroexpander.h>
#include <utils/fsengine/fileiconprovider.h>
#include <QApplication>
#include <QDesktopServices>
#include <QMessageBox>
@@ -40,6 +40,15 @@ const int roleFullPath = Qt::UserRole;
const int roleItemType = Qt::UserRole + 1;
const int roleIsDir = Qt::UserRole + 2;
const int roleProject = Qt::UserRole + 3;
const int roleLabel = Qt::UserRole + 4;
void setItemProjectName(ProjectExplorer::Project * pr, QTreeWidgetItem * item) {
if (!pr || !item) return;
QString dn = pr->displayName(), l = item->data(0, roleLabel).toString();
if (!l.isEmpty()) dn += " (" + l + ")";
item->setText(0, dn);
}
QAction * newSeparator() {
@@ -48,6 +57,7 @@ QAction * newSeparator() {
return sep;
}
ProjectFilesystemWidget::ProjectFilesystemWidget(QWidget * parent): QWidget(parent) {
setupUi(this);
item_target = nullptr;
@@ -59,7 +69,7 @@ ProjectFilesystemWidget::ProjectFilesystemWidget(QWidget * parent): QWidget(pare
buttonCollapse->setIcon(Utils::Icons::COLLAPSE.icon());
actionOpen_here->setIcon(Utils::Icons::OPENFILE.icon());
actionOpen_external->setIcon(Utils::Icons::OPENFILE.icon());
actionShow_external->setIcon(Core::FileIconProvider::icon(QFileIconProvider::Folder));
actionShow_external->setIcon(Utils::FileIconProvider::icon(QFileIconProvider::Folder));
actionCopy_name->setIcon(Utils::Icons::COPY.icon());
actionCopy_path->setIcon(Utils::Icons::COPY.icon());
actionBuild->setIcon(ProjectExplorer::Icons::BUILD_SMALL.icon());
@@ -77,23 +87,23 @@ ProjectFilesystemWidget::ProjectFilesystemWidget(QWidget * parent): QWidget(pare
this_actions << actionCopy_name << actionCopy_path;
proj_plug = 0;
//connect(ProjectExplorer::ProjectTree::instance(), SIGNAL(subtreeChanged(ProjectExplorer::FolderNode*)), this, SLOT(projectsChanged()));
connect(ProjectExplorer::SessionManager::instance(), SIGNAL(startupProjectChanged(ProjectExplorer::Project *)), this, SLOT(startupProjectChanged()));
connect(ProjectExplorer::SessionManager::instance(), &ProjectExplorer::SessionManager::projectAdded, [this](ProjectExplorer::Project * p){
connect(ProjectExplorer::ProjectManager::instance(), SIGNAL(startupProjectChanged(ProjectExplorer::Project *)), this, SLOT(startupProjectChanged()));
connect(ProjectExplorer::ProjectManager::instance(), &ProjectExplorer::ProjectManager::projectAdded, [this](ProjectExplorer::Project * p){
createProjectTree(p);
filter();
startupProjectChanged();
});
connect(ProjectExplorer::SessionManager::instance(), &ProjectExplorer::SessionManager::projectDisplayNameChanged, [this](ProjectExplorer::Project * p){
connect(ProjectExplorer::ProjectManager::instance(), &ProjectExplorer::ProjectManager::projectDisplayNameChanged, [this](ProjectExplorer::Project * p){
projectNameChanged();
});
connect(ProjectExplorer::SessionManager::instance(), &ProjectExplorer::SessionManager::projectRemoved, [this](ProjectExplorer::Project * p){
connect(ProjectExplorer::ProjectManager::instance(), &ProjectExplorer::ProjectManager::projectRemoved, [this](ProjectExplorer::Project * p){
QTreeWidgetItem * pi = projectItem(p);
if (!pi) return;
delete pi;
cleanMappedItems();
startupProjectChanged();
});
//connect(ProjectExplorer::SessionManager::instance(), SIGNAL(), this, SLOT(startupProjectChanged()));
//connect(ProjectExplorer::ProjectManager::instance(), SIGNAL(), this, SLOT(startupProjectChanged()));
connect(Core::EditorManager::instance(), SIGNAL(currentEditorChanged(Core::IEditor*)), this, SLOT(currentFileChanged()));
connect(&fs_watcher, SIGNAL(directoryChanged(const QString &)), this, SLOT(directoryChanged(const QString &)));
projectsChanged();
@@ -146,7 +156,7 @@ void ProjectFilesystemWidget::projectNameChanged() {
for (int i = 0; i < tree->topLevelItemCount(); ++i) {
ProjectExplorer::Project * p = (ProjectExplorer::Project *)itemProject(tree->topLevelItem(i));
if (!p) continue;
tree->topLevelItem(i)->setText(0, p->displayName());
setItemProjectName(p, tree->topLevelItem(i));
}
}
@@ -170,7 +180,7 @@ void ProjectFilesystemWidget::createTree(QTreeWidgetItem * ti, const QString & d
}
QTreeWidgetItem * ni = new QTreeWidgetItem();
ni->setText(0, nit);
ni->setIcon(0, Core::FileIconProvider::icon(Utils::FilePath::fromString(i.absoluteFilePath())));
ni->setIcon(0, Utils::FileIconProvider::icon(Utils::FilePath::fromString(i.absoluteFilePath())));
ni->setData(0, roleFullPath, i.absoluteFilePath());
ni->setData(0, roleItemType, i.isDir() ? itDir : itFile);
ni->setData(0, roleIsDir, i.isDir());
@@ -276,7 +286,7 @@ void ProjectFilesystemWidget::projectsChanged() {
tree->clear();
fs_watcher.removePaths(fs_watcher.directories());
QApplication::setOverrideCursor(Qt::WaitCursor);
QList<ProjectExplorer::Project *> pl = ProjectExplorer::SessionManager::projects();
QList<ProjectExplorer::Project *> pl = ProjectExplorer::ProjectManager::projects();
for (ProjectExplorer::Project * p: pl) {
createProjectTree(p);
}
@@ -299,17 +309,23 @@ void ProjectFilesystemWidget::createProjectTree(void * p) {
if (!p) return;
ProjectExplorer::Project * pr = (ProjectExplorer::Project *)p;
QTreeWidgetItem * ri = new QTreeWidgetItem();
QString dir = pr->projectDirectory().toString();
ri->setText(0, pr->displayName());
QString dir = pr->projectDirectory().toUrlishString();
QFile logo(dir + "/logo.png");
if (logo.exists())
ri->setIcon(0, QIcon(logo.fileName()));
else
ri->setIcon(0, Core::FileIconProvider::icon(QFileIconProvider::Folder));
ri->setIcon(0, Utils::FileIconProvider::icon(QFileIconProvider::Folder));
QFile label(dir + "/label.txt");
if (label.exists()) {
label.open(QIODevice::ReadOnly);
ri->setData(0, roleLabel, QString::fromUtf8(label.readAll()).trimmed());
} else
ri->setData(0, roleLabel, QString());
ri->setData(0, roleProject, (qulonglong)pr);
ri->setData(0, roleFullPath, dir);
ri->setData(0, roleIsDir, true);
ri->setData(0, roleItemType, itProject);
setItemProjectName(pr, ri);
createTree(ri, dir);
tree->addTopLevelItem(ri);
}
@@ -325,7 +341,7 @@ void ProjectFilesystemWidget::filterClicked() {
void ProjectFilesystemWidget::currentFileChanged() {
Core::IDocument * cd = Core::EditorManager::instance()->currentDocument();
if (!cd) return;
QString np = cd->filePath().toString();
QString np = cd->filePath().toUrlishString();
QTreeWidgetItem * ti = item_map.value(np);
if (!ti) return;
tree->setCurrentItem(ti);
@@ -334,14 +350,14 @@ void ProjectFilesystemWidget::currentFileChanged() {
void ProjectFilesystemWidget::startupProjectChanged() {
ProjectExplorer::Project * sp = ProjectExplorer::SessionManager::startupProject();
ProjectExplorer::Project * sp = ProjectExplorer::ProjectManager::startupProject();
QFont f(tree->font()), bf(f);
bf.setBold(true);
for (int i = 0; i < tree->topLevelItemCount(); ++i) {
QTreeWidgetItem * ti = tree->topLevelItem(i);
ti->setFont(0, f);
if (!sp) continue;
if (sp->projectDirectory().toString() == ti->data(0, roleFullPath).toString())
if (sp->projectDirectory().toUrlishString() == ti->data(0, roleFullPath).toString())
ti->setFont(0, bf);
}
}
@@ -428,7 +444,7 @@ void ProjectFilesystemWidget::on_tree_customContextMenuRequested(const QPoint &
/*if (item->data(0, roleItemType).toInt() == itProject) {
QString proj_path = item->data(0, roleFullPath).toString();
ProjectExplorer::Project * project = Utils::findOrDefault(ProjectExplorer::SessionManager::projects(),
ProjectExplorer::Project * project = Utils::findOrDefault(ProjectExplorer::ProjectManager::projects(),
[proj_path](const ProjectExplorer::Project * p) {return p->containerNode()->path() == proj_path;});
//ProjectExplorer::ProjectTree::instance()->setCurrent
@@ -439,7 +455,7 @@ void ProjectFilesystemWidget::on_tree_customContextMenuRequested(const QPoint &
}*/
ProjectExplorer::Project * p = (ProjectExplorer::Project *)itemProject(item_target);
if (p) {
actionSet_as_startup->setVisible(p != ProjectExplorer::SessionManager::startupProject());
actionSet_as_startup->setVisible(p != ProjectExplorer::ProjectManager::startupProject());
bool can_build = !p->needsConfiguration(), can_run = false;
if (p->activeTarget()) {
can_build = can_build && p->activeTarget()->activeBuildConfiguration();
@@ -480,13 +496,13 @@ void ProjectFilesystemWidget::on_actionOpen_external_triggered() {
void ProjectFilesystemWidget::on_actionShow_external_triggered() {
if (projectfs_menu_target.path().isEmpty()) return;
Core::FileUtils::showInGraphicalShell(Core::ICore::mainWindow(), Utils::FilePath::fromString(projectfs_menu_target.absoluteFilePath()));
Core::FileUtils::showInGraphicalShell(Utils::FilePath::fromString(projectfs_menu_target.absoluteFilePath()));
}
void ProjectFilesystemWidget::on_actionOpen_terminal_triggered() {
if (projectfs_menu_target.path().isEmpty()) return;
Core::FileUtils::openTerminal(Utils::FilePath::fromString(QDir(projectfs_menu_target.absoluteFilePath()).path()));
Core::FileUtils::openTerminal(Utils::FilePath::fromString(QDir(projectfs_menu_target.absoluteFilePath()).path()), {});
}
@@ -505,7 +521,7 @@ void ProjectFilesystemWidget::on_actionCopy_path_triggered() {
void ProjectFilesystemWidget::on_actionSet_as_startup_triggered() {
ProjectExplorer::Project * p = (ProjectExplorer::Project *)itemProject(item_target);
if (!p) return;
ProjectExplorer::SessionManager::setStartupProject(p);
ProjectExplorer::ProjectManager::setStartupProject(p);
}
@@ -542,5 +558,5 @@ void ProjectFilesystemWidget::on_actionClose_project_triggered() {
if (!p) return;
if (QMessageBox::question(0, "Project close", tr("Are you sure to close project \"%1\"?").arg(p->displayName())) != QMessageBox::Yes)
return;
ProjectExplorer::SessionManager::removeProject(p);
ProjectExplorer::ProjectManager::removeProject(p);
}

View File

@@ -45,7 +45,7 @@ void ProjectFSWidgetFactory::saveSettings(Utils::QtcSettings * settings, int pos
}
void ProjectFSWidgetFactory::restoreSettings(QSettings * settings, int position, QWidget * widget) {
void ProjectFSWidgetFactory::restoreSettings(Utils::QtcSettings * settings, int position, QWidget * widget) {
ProjectFilesystemWidget * w = qobject_cast<ProjectFilesystemWidget * >(widget);
if (!w) return;
settings->beginGroup("ProjectFilesystem");

View File

@@ -13,7 +13,7 @@ public:
Core::NavigationView createWidget() override;
void saveSettings(Utils::QtcSettings * settings, int position, QWidget * widget) override;
void restoreSettings(QSettings * settings, int position, QWidget * widget) override;
void restoreSettings(Utils::QtcSettings * settings, int position, QWidget * widget) override;
//void changeEvent(QEvent * e) override;