Skip to content
Snippets Groups Projects
Commit 55c2393c authored by Matthias Puchner's avatar Matthias Puchner
Browse files

fill toolbar with actions, not with buttons

this fixes #103 (GUI: "More..." button in JobWidget is not working)

explanation for changes: filling toolbars with buttons breaks the "more"-button functionality, therefore use the already existing actions to fill the toolbar
parent 3377d9d9
No related branches found
No related tags found
1 merge request!225fill toolbar with actions, not with buttons
Pipeline #41947 failed
...@@ -47,8 +47,11 @@ private: ...@@ -47,8 +47,11 @@ private:
bool canRunJob(const QModelIndex& index) const; bool canRunJob(const QModelIndex& index) const;
bool canRemoveJob(const QModelIndex& index) const; bool canRemoveJob(const QModelIndex& index) const;
public:
QAction* m_runJobAction; QAction* m_runJobAction;
QAction* m_removeJobAction; QAction* m_removeJobAction;
private:
QItemSelectionModel* m_selectionModel; QItemSelectionModel* m_selectionModel;
JobModel* m_jobModel; JobModel* m_jobModel;
}; };
......
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file GUI/Views/JobWidgets/JobSelectorToolBar.cpp
//! @brief Implements class JobSelectorToolBar
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2018
//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
// ************************************************************************************************
#include "GUI/Views/JobWidgets/JobSelectorToolBar.h"
#include "GUI/Views/JobWidgets/JobSelectorActions.h"
#include <QToolButton>
JobSelectorToolBar::JobSelectorToolBar(JobSelectorActions* actions, QWidget* parent)
: StyledToolBar(parent), m_runJobButton(new QToolButton), m_removeJobButton(new QToolButton)
{
setMinimumSize(minimumHeight(), minimumHeight());
m_runJobButton->setText("Run");
m_runJobButton->setIcon(QIcon(":/images/play.svg"));
m_runJobButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
m_runJobButton->setToolTip("Run currently selected job");
addWidget(m_runJobButton);
m_removeJobButton->setText("Remove");
m_removeJobButton->setIcon(QIcon(":/images/delete.svg"));
m_removeJobButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
m_removeJobButton->setToolTip("Remove currently selected job.");
addWidget(m_removeJobButton);
connect(m_runJobButton, &QToolButton::clicked, actions, &JobSelectorActions::onRunJob);
connect(m_removeJobButton, &QToolButton::clicked, actions, &JobSelectorActions::onRemoveJob);
}
// ************************************************************************************************
//
// BornAgain: simulate and fit reflection and scattering
//
//! @file GUI/Views/JobWidgets/JobSelectorToolBar.h
//! @brief Defines class JobSelectorToolBar
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2018
//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
//
// ************************************************************************************************
#ifndef BORNAGAIN_GUI_VIEWS_JOBWIDGETS_JOBSELECTORTOOLBAR_H
#define BORNAGAIN_GUI_VIEWS_JOBWIDGETS_JOBSELECTORTOOLBAR_H
#include "GUI/Views/CommonWidgets/StyledToolBar.h"
class QAction;
class QToolButton;
class JobSelectorActions;
//! Styled tool bar on top of JobSelector with run/remove job buttons.
class JobSelectorToolBar : public StyledToolBar {
Q_OBJECT
public:
explicit JobSelectorToolBar(JobSelectorActions* actions, QWidget* parent = nullptr);
private:
QToolButton* m_runJobButton;
QToolButton* m_removeJobButton;
};
#endif // BORNAGAIN_GUI_VIEWS_JOBWIDGETS_JOBSELECTORTOOLBAR_H
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include "GUI/Views/JobWidgets/JobListWidget.h" #include "GUI/Views/JobWidgets/JobListWidget.h"
#include "GUI/Views/JobWidgets/JobPropertiesWidget.h" #include "GUI/Views/JobWidgets/JobPropertiesWidget.h"
#include "GUI/Views/JobWidgets/JobSelectorActions.h" #include "GUI/Views/JobWidgets/JobSelectorActions.h"
#include "GUI/Views/JobWidgets/JobSelectorToolBar.h"
#include "GUI/Views/Tools/mainwindow_constants.h" #include "GUI/Views/Tools/mainwindow_constants.h"
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QSplitter> #include <QSplitter>
...@@ -26,7 +25,6 @@ ...@@ -26,7 +25,6 @@
JobSelectorWidget::JobSelectorWidget(JobModel* jobModel, QWidget* parent) JobSelectorWidget::JobSelectorWidget(JobModel* jobModel, QWidget* parent)
: QWidget(parent) : QWidget(parent)
, m_jobSelectorActions(new JobSelectorActions(jobModel, this)) , m_jobSelectorActions(new JobSelectorActions(jobModel, this))
, m_toolBar(new JobSelectorToolBar(m_jobSelectorActions, this))
, m_jobListWidget(new JobListWidget) , m_jobListWidget(new JobListWidget)
, m_jobProperties(new JobPropertiesWidget) , m_jobProperties(new JobPropertiesWidget)
, m_jobModel(nullptr) , m_jobModel(nullptr)
...@@ -44,11 +42,17 @@ JobSelectorWidget::JobSelectorWidget(JobModel* jobModel, QWidget* parent) ...@@ -44,11 +42,17 @@ JobSelectorWidget::JobSelectorWidget(JobModel* jobModel, QWidget* parent)
splitter->addWidget(m_jobProperties); splitter->addWidget(m_jobProperties);
splitter->setChildrenCollapsible(true); splitter->setChildrenCollapsible(true);
QToolBar* toolBar = new StyledToolBar(this);
toolBar->setMinimumSize(toolBar->minimumHeight(), toolBar->minimumHeight());
toolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
toolBar->addAction(m_jobSelectorActions->m_runJobAction);
toolBar->addAction(m_jobSelectorActions->m_removeJobAction);
auto mainLayout = new QVBoxLayout; auto mainLayout = new QVBoxLayout;
mainLayout->setMargin(0); mainLayout->setMargin(0);
mainLayout->setSpacing(0); mainLayout->setSpacing(0);
mainLayout->setContentsMargins(0, 0, 0, 0); mainLayout->setContentsMargins(0, 0, 0, 0);
mainLayout->addWidget(m_toolBar); mainLayout->addWidget(toolBar);
mainLayout->addWidget(splitter); mainLayout->addWidget(splitter);
setLayout(mainLayout); setLayout(mainLayout);
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
class JobModel; class JobModel;
class JobItem; class JobItem;
class JobSelectorToolBar;
class JobSelectorActions; class JobSelectorActions;
class JobListWidget; class JobListWidget;
class JobPropertiesWidget; class JobPropertiesWidget;
...@@ -51,7 +50,6 @@ private slots: ...@@ -51,7 +50,6 @@ private slots:
private: private:
JobSelectorActions* m_jobSelectorActions; JobSelectorActions* m_jobSelectorActions;
JobSelectorToolBar* m_toolBar;
JobListWidget* m_jobListWidget; JobListWidget* m_jobListWidget;
JobPropertiesWidget* m_jobProperties; JobPropertiesWidget* m_jobProperties;
JobModel* m_jobModel; JobModel* m_jobModel;
......
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