From da496f9b038cc5aba6b44a6dfaddf243d428ba97 Mon Sep 17 00:00:00 2001
From: Joachim Wuttke <j.wuttke@fz-juelich.de>
Date: Sat, 28 Oct 2023 18:52:17 +0200
Subject: [PATCH] ProjectsView + action buttons New, Load

---
 GUI/View/Project/ProjectsView.cpp          | 31 +++++++++++++++++-----
 GUI/View/SampleDesigner/SampleForm.cpp     |  1 +
 GUI/View/SampleDesigner/SampleListView.cpp |  1 +
 3 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/GUI/View/Project/ProjectsView.cpp b/GUI/View/Project/ProjectsView.cpp
index 5196091910b..ac1971879b1 100644
--- a/GUI/View/Project/ProjectsView.cpp
+++ b/GUI/View/Project/ProjectsView.cpp
@@ -17,22 +17,39 @@
 #include "GUI/Support/Util/Path.h"
 #include "GUI/View/Project/ProjectManager.h"
 #include "GUI/View/Widget/GroupBoxes.h"
+#include "GUI/View/Widget/StyledToolbar.h"
 #include <QCommandLinkButton>
 #include <QDesktopServices>
 #include <QDir>
 #include <QUrl>
+#include <QVBoxLayout>
 
 ProjectsView::ProjectsView(QWidget* parent)
     : QWidget(parent)
 {
-    QPalette palette = this->palette();
-    palette.setColor(QPalette::Window, Qt::white);
-    setPalette(palette);
+    auto* layout = new QVBoxLayout;
+    setLayout(layout);
+
+    auto* toolbar = new StyledToolbar(this);
+    layout->addWidget(toolbar);
+    toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
+
+    auto* actionNew = new QAction;
+    toolbar->addAction(actionNew);
+    actionNew->setText("Create new project");
+    actionNew->setIcon(QIcon(":/images/shape-square-plus.svg"));
+    actionNew->setIconText("New");
+    actionNew->setToolTip("Create new project");
+    connect(actionNew, &QAction::triggered, [this]() { projectManager()->newProject(); });
+
+    auto* actionLoad = new QAction(this);
+    toolbar->addAction(actionLoad);
+    actionLoad->setText("Load project from file");
+    actionLoad->setIcon(QIcon(":/images/import.svg"));
+    actionLoad->setIconText("Load");
+    actionLoad->setToolTip("Load project from file");
+    connect(actionLoad, &QAction::triggered, [this]() { projectManager()->openProject(); });
 
-    /*
-    connect(m_ui->newButton, &QPushButton::clicked, projectManager(), &ProjectManager::newProject);
-    connect(m_ui->openButton, &QPushButton::clicked, [this]() { projectManager()->openProject(); });
-    */
     connect(projectManager(), &ProjectManager::recentListModified, this,
             &ProjectsView::updateRecentProjectPanel);
 
diff --git a/GUI/View/SampleDesigner/SampleForm.cpp b/GUI/View/SampleDesigner/SampleForm.cpp
index 30740771763..ae1ef5ef444 100644
--- a/GUI/View/SampleDesigner/SampleForm.cpp
+++ b/GUI/View/SampleDesigner/SampleForm.cpp
@@ -54,6 +54,7 @@ public:
 
 } // namespace
 
+
 SampleForm::SampleForm(QWidget* parent, SampleItem* sampleItem, SampleEditorController* ec)
     : QWidget(parent)
     , m_sampleItem(sampleItem)
diff --git a/GUI/View/SampleDesigner/SampleListView.cpp b/GUI/View/SampleDesigner/SampleListView.cpp
index 1a87c9690e2..35b792a6261 100644
--- a/GUI/View/SampleDesigner/SampleListView.cpp
+++ b/GUI/View/SampleDesigner/SampleListView.cpp
@@ -61,6 +61,7 @@ protected:
 
 } // namespace
 
+
 SampleListView::SampleListView(QWidget* parent, ProjectDocument* document)
     : QListView(parent)
     , m_document(document)
-- 
GitLab