Skip to content
Snippets Groups Projects
Commit c5b1e906 authored by Pospelov, Gennady's avatar Pospelov, Gennady
Browse files

SampleViewToolBar now requires actions as initializer.

parent d742f887
No related branches found
No related tags found
No related merge requests found
...@@ -28,9 +28,10 @@ ...@@ -28,9 +28,10 @@
//! main tool bar on top of SampleView window //! main tool bar on top of SampleView window
SampleToolBar::SampleToolBar(SampleModel* sampleModel, QItemSelectionModel* selectionModel, SampleToolBar::SampleToolBar(SampleModel* sampleModel, QItemSelectionModel* selectionModel,
SampleViewActions* sampleActions,
QWidget* parent) QWidget* parent)
: StyledToolBar(parent), m_sampleModel(sampleModel), m_selectionModel(selectionModel), : StyledToolBar(parent), m_sampleModel(sampleModel), m_selectionModel(selectionModel),
m_dialog(nullptr), m_dialog_on(false) m_dialog(nullptr), m_sampleViewActions(sampleActions), m_dialog_on(false)
{ {
// Select & Pan // Select & Pan
auto selectionPointerButton = new QToolButton; auto selectionPointerButton = new QToolButton;
...@@ -164,10 +165,20 @@ void SampleToolBar::onRealSpaceViewerCall() ...@@ -164,10 +165,20 @@ void SampleToolBar::onRealSpaceViewerCall()
// keep only one instance of dialog alive using a boolean flag // keep only one instance of dialog alive using a boolean flag
if (!m_dialog_on) { if (!m_dialog_on) {
m_dialog_on = true; m_dialog_on = true;
m_dialog = new RealSpaceDialog(m_sampleModel, m_selectionModel, this); m_dialog = new RealSpaceDialog(sampleModel(), selectionModel(), this);
m_dialog->show(); m_dialog->show();
// undo the flag when the dialog is destroyed on close event // undo the flag when the dialog is destroyed on close event
connect(m_dialog, &QAction::destroyed, this, [&]() { m_dialog_on = false; }); connect(m_dialog, &QAction::destroyed, this, [&]() { m_dialog_on = false; });
} }
} }
SampleModel* SampleToolBar::sampleModel()
{
return m_sampleModel;
}
QItemSelectionModel* SampleToolBar::selectionModel()
{
return m_selectionModel;
}
...@@ -26,6 +26,7 @@ class QString; ...@@ -26,6 +26,7 @@ class QString;
class QButtonGroup; class QButtonGroup;
class SampleModel; class SampleModel;
class RealSpaceDialog; class RealSpaceDialog;
class SampleViewActions;
//! The SampleToolBar class represents a main toolbar on top of SampleView window //! The SampleToolBar class represents a main toolbar on top of SampleView window
...@@ -36,6 +37,7 @@ class BA_CORE_API_ SampleToolBar : public StyledToolBar ...@@ -36,6 +37,7 @@ class BA_CORE_API_ SampleToolBar : public StyledToolBar
public: public:
explicit SampleToolBar(SampleModel* sampleModel = nullptr, explicit SampleToolBar(SampleModel* sampleModel = nullptr,
QItemSelectionModel* selectionModel = nullptr, QItemSelectionModel* selectionModel = nullptr,
SampleViewActions* sampleActions = nullptr,
QWidget* parent = nullptr); QWidget* parent = nullptr);
signals: signals:
...@@ -54,6 +56,9 @@ public slots: ...@@ -54,6 +56,9 @@ public slots:
void onRealSpaceViewerCall(); void onRealSpaceViewerCall();
private: private:
SampleModel* sampleModel();
QItemSelectionModel* selectionModel();
QButtonGroup* m_pointerModeGroup; QButtonGroup* m_pointerModeGroup;
QToolButton* m_removeButton; QToolButton* m_removeButton;
QToolButton* m_centerViewButton; QToolButton* m_centerViewButton;
...@@ -68,6 +73,8 @@ private: ...@@ -68,6 +73,8 @@ private:
QItemSelectionModel* m_selectionModel; QItemSelectionModel* m_selectionModel;
RealSpaceDialog* m_dialog; RealSpaceDialog* m_dialog;
SampleViewActions* m_sampleViewActions;
bool m_dialog_on; bool m_dialog_on;
}; };
......
...@@ -32,6 +32,8 @@ SampleView::SampleView(MainWindow* mainWindow) ...@@ -32,6 +32,8 @@ SampleView::SampleView(MainWindow* mainWindow)
, m_statusBar(new SampleViewStatusBar(mainWindow)) , m_statusBar(new SampleViewStatusBar(mainWindow))
{ {
setObjectName("SampleView"); setObjectName("SampleView");
m_actions->setSelectionModel(selectionModel());
connectSignals(); connectSignals();
} }
...@@ -64,7 +66,7 @@ void SampleView::connectSignals() ...@@ -64,7 +66,7 @@ void SampleView::connectSignals()
this, &SampleView::onDockMenuRequest); this, &SampleView::onDockMenuRequest);
// toolBar should be initialized after MaterialBrowser // toolBar should be initialized after MaterialBrowser
m_toolBar = new SampleToolBar(models()->sampleModel(), selectionModel(), this); m_toolBar = new SampleToolBar(models()->sampleModel(), selectionModel(), m_actions, this);
connect(m_toolBar, SIGNAL(deleteItems()), sampleDesigner()->getView(), connect(m_toolBar, SIGNAL(deleteItems()), sampleDesigner()->getView(),
SLOT(deleteSelectedItems())); SLOT(deleteSelectedItems()));
connect(m_toolBar, SIGNAL(selectionMode(int)), sampleDesigner()->getView(), connect(m_toolBar, SIGNAL(selectionMode(int)), sampleDesigner()->getView(),
......
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