Skip to content
Snippets Groups Projects
Commit 43af1947 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

project list restored

parent da496f9b
No related branches found
No related tags found
1 merge request!2064Project view without .ui
Pipeline #117589 failed
......@@ -27,6 +27,8 @@
ProjectsView::ProjectsView(QWidget* parent)
: QWidget(parent)
{
ProjectManager* pm = ProjectManager::instance();
auto* layout = new QVBoxLayout;
setLayout(layout);
......@@ -40,7 +42,7 @@ ProjectsView::ProjectsView(QWidget* parent)
actionNew->setIcon(QIcon(":/images/shape-square-plus.svg"));
actionNew->setIconText("New");
actionNew->setToolTip("Create new project");
connect(actionNew, &QAction::triggered, [this]() { projectManager()->newProject(); });
connect(actionNew, &QAction::triggered, [=]() { pm->newProject(); });
auto* actionLoad = new QAction(this);
toolbar->addAction(actionLoad);
......@@ -48,33 +50,27 @@ ProjectsView::ProjectsView(QWidget* parent)
actionLoad->setIcon(QIcon(":/images/import.svg"));
actionLoad->setIconText("Load");
actionLoad->setToolTip("Load project from file");
connect(actionLoad, &QAction::triggered, [this]() { projectManager()->openProject(); });
connect(projectManager(), &ProjectManager::recentListModified, this,
&ProjectsView::updateRecentProjectPanel);
connect(actionLoad, &QAction::triggered, [=]() { pm->openProject(); });
updateRecentProjectPanel();
}
auto* prjList = new QVBoxLayout;
layout->addLayout(prjList);
ProjectManager* ProjectsView::projectManager()
{
return ProjectManager::instance();
}
auto updateProjects = [prjList, pm]() {
GUI::Util::Layout::clearLayout(prjList);
for (const auto& file : pm->recentProjects()) {
auto* button = new QCommandLinkButton;
button->setText(QFileInfo(file).baseName());
button->setDescription(GUI::Base::Path::withTildeHomePath(QDir::toNativeSeparators(file)));
button->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
connect(button, &QCommandLinkButton::clicked,
[pm, file] { pm->openProject(file); });
void ProjectsView::updateRecentProjectPanel()
{
/*
GUI::Util::Layout::clearLayout(m_ui->recentProjectsLayout);
*/
for (const auto& file : projectManager()->recentProjects()) {
auto* button = new QCommandLinkButton;
button->setText(QFileInfo(file).baseName());
button->setDescription(GUI::Base::Path::withTildeHomePath(QDir::toNativeSeparators(file)));
button->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
connect(button, &QCommandLinkButton::clicked,
[this, file] { projectManager()->openProject(file); });
prjList->addWidget(button);
}
// m_ui->recentProjectsLayout->addStretch(1);
};
connect(pm, &ProjectManager::recentListModified, [=]() { updateProjects(); });
updateProjects();
// m_ui->recentProjectsLayout->addWidget(button);
}
// m_ui->recentProjectsLayout->addStretch(1);
layout->addStretch(1);
}
......@@ -23,10 +23,6 @@ class ProjectsView : public QWidget {
Q_OBJECT
public:
ProjectsView(QWidget* parent);
private:
ProjectManager* projectManager();
void updateRecentProjectPanel();
};
#endif // BORNAGAIN_GUI_VIEW_PROJECT_PROJECTSVIEW_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment