Skip to content
Snippets Groups Projects

Project view without .ui

Merged Wuttke, Joachim requested to merge j.ui1 into main
2 files
+ 22
30
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -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);
}
Loading