diff --git a/GUI/View/Project/ProjectsView.cpp b/GUI/View/Project/ProjectsView.cpp index 5b5d23e1f5f8388370936cc0f233f434e38f4adf..b5cb27e9864ed47184da4385fbfe173ab5c8a793 100644 --- a/GUI/View/Project/ProjectsView.cpp +++ b/GUI/View/Project/ProjectsView.cpp @@ -17,50 +17,60 @@ #include "GUI/Support/Util/Path.h" #include "GUI/View/Project/ProjectManager.h" #include "GUI/View/Widget/GroupBoxes.h" -#include "ui_ProjectsView.h" +#include "GUI/View/Widget/StyledToolbar.h" #include <QCommandLinkButton> #include <QDesktopServices> #include <QDir> #include <QUrl> +#include <QVBoxLayout> ProjectsView::ProjectsView(QWidget* parent) : QWidget(parent) - , m_ui(new Ui::ProjectsView) { - m_ui->setupUi(this); + ProjectManager* pm = ProjectManager::instance(); - GroupBoxCollapser::installIntoGroupBox(m_ui->groupBox_2); + auto* layout = new QVBoxLayout; + setLayout(layout); - QPalette palette = this->palette(); - palette.setColor(QPalette::Window, Qt::white); - setPalette(palette); + auto* toolbar = new StyledToolbar(this); + layout->addWidget(toolbar); + toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); - 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); + 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, [=]() { pm->newProject(); }); - updateRecentProjectPanel(); -} + 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, [=]() { pm->openProject(); }); -ProjectManager* ProjectsView::projectManager() -{ - return ProjectManager::instance(); -} + auto* prjList = new QVBoxLayout; + layout->addLayout(prjList); -void ProjectsView::updateRecentProjectPanel() -{ - GUI::Util::Layout::clearLayout(m_ui->recentProjectsLayout); + 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); }); - 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); } diff --git a/GUI/View/Project/ProjectsView.h b/GUI/View/Project/ProjectsView.h index 793ecdebbba3e241224003fbebf0267fed78b0ee..4189e850449e7f95db52eb558ca3dd4216fa0486 100644 --- a/GUI/View/Project/ProjectsView.h +++ b/GUI/View/Project/ProjectsView.h @@ -19,20 +19,10 @@ class ProjectManager; -namespace Ui { -class ProjectsView; -} - class ProjectsView : public QWidget { Q_OBJECT public: ProjectsView(QWidget* parent); - -private: - ProjectManager* projectManager(); - void updateRecentProjectPanel(); - - Ui::ProjectsView* m_ui; }; #endif // BORNAGAIN_GUI_VIEW_PROJECT_PROJECTSVIEW_H diff --git a/GUI/View/Project/ProjectsView.ui b/GUI/View/Project/ProjectsView.ui deleted file mode 100644 index f86620ed3a6b01787e42b88d96b716cd94e2ce80..0000000000000000000000000000000000000000 --- a/GUI/View/Project/ProjectsView.ui +++ /dev/null @@ -1,178 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ProjectsView</class> - <widget class="QWidget" name="ProjectsView"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>1064</width> - <height>914</height> - </rect> - </property> - <property name="windowTitle"> - <string>Form</string> - </property> - <property name="autoFillBackground"> - <bool>true</bool> - </property> - <layout class="QVBoxLayout" name="verticalLayout_5"> - <property name="spacing"> - <number>6</number> - </property> - <property name="leftMargin"> - <number>9</number> - </property> - <property name="topMargin"> - <number>9</number> - </property> - <property name="rightMargin"> - <number>9</number> - </property> - <property name="bottomMargin"> - <number>9</number> - </property> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <property name="spacing"> - <number>30</number> - </property> - <item> - <layout class="QVBoxLayout" name="verticalLayout"> - <property name="spacing"> - <number>7</number> - </property> - <item> - <widget class="QPushButton" name="newButton"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>140</width> - <height>45</height> - </size> - </property> - <property name="toolTip"> - <string>Create new project</string> - </property> - <property name="text"> - <string>New project</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="openButton"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>140</width> - <height>45</height> - </size> - </property> - <property name="toolTip"> - <string>Open existing project</string> - </property> - <property name="text"> - <string>Open project...</string> - </property> - </widget> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - <item> - <widget class="QFrame" name="frame"> - <property name="frameShape"> - <enum>QFrame::VLine</enum> - </property> - <property name="frameShadow"> - <enum>QFrame::Plain</enum> - </property> - </widget> - </item> - <item> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <property name="spacing"> - <number>7</number> - </property> - <item> - <widget class="QGroupBox" name="groupBox_2"> - <property name="title"> - <string>Recent projects</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_6"> - <item> - <widget class="QScrollArea" name="scrollArea"> - <property name="frameShape"> - <enum>QFrame::NoFrame</enum> - </property> - <property name="horizontalScrollBarPolicy"> - <enum>Qt::ScrollBarAlwaysOff</enum> - </property> - <property name="widgetResizable"> - <bool>true</bool> - </property> - <widget class="QWidget" name="scrollAreaWidgetContents"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>821</width> - <height>850</height> - </rect> - </property> - <layout class="QVBoxLayout" name="verticalLayout_3"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="QWidget" name="widgetForRecentProjects" native="true"> - <layout class="QVBoxLayout" name="recentProjectsLayout"/> - </widget> - </item> - </layout> - </widget> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </item> - </layout> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/GUI/View/SampleDesigner/SampleForm.cpp b/GUI/View/SampleDesigner/SampleForm.cpp index 3074077176383c98f76be2d16f325fff020d38a1..ae1ef5ef4449653d464fa01bf0bb240cbbe8a9c3 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 1a87c9690e206893be5d30ba46dc3cf013edb694..35b792a6261a1531a24e958394a2b151f5bfa180 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)