diff --git a/App/main.cpp b/App/main.cpp index 8ade38d3632cc82be7e73bbbc0f5feca868cc055..d5d5870c1612d901cc7797dee10100c72a0d0f6a 100644 --- a/App/main.cpp +++ b/App/main.cpp @@ -16,6 +16,7 @@ #include "Base/Util/Assert.h" #include "GUI/Support/Util/Path.h" #include "GUI/View/Main/MainWindow.h" +#include "GUI/View/Setup/FrameActions.h" #include "GUI/View/Tool/Globals.h" #include "GUI/View/Widget/ApplicationSettings.h" #include "config_build.h" @@ -76,6 +77,8 @@ int main(int argc, char* argv[]) MainWindow win; GUI::Global::mainWindow = &win; + gActions = new FrameActions; + if (options.find("geometry")) win.resize(options.mainWindowSize()); if (options.find("project-file")) diff --git a/Doc/graph/mask-classes.gv b/Doc/graph/mask-classes.gv index 811e3435a4d93412b10f2760b34d3d8b712c4737..e422ffc8aea89a2f7fa335e37031d307afd6a51a 100644 --- a/Doc/graph/mask-classes.gv +++ b/Doc/graph/mask-classes.gv @@ -11,15 +11,15 @@ node[shape=box]; # DatafilesStack[label="DatafilesStack\n< ItemStackWidget\n< QWidget" style=filled fillcolor=orchid]; MaskEditingFrame[label="MaskEditingFrame\n< DataAccessWidget\n< QWidget" style=filled fillcolor=orchid]; -MaskEditingFrame->MaskEditorActions; +MaskEditingFrame->FrameActions; MaskEditingFrame->MaskPanel; MaskEditingFrame->MaskEditorCanvas; MaskEditingFrame->MaskToolbar[style=dashed color=blue] MaskToolbar[label="MaskToolbar\n< QToolBar\n< QWidget" style=filled fillcolor=orchid] -MaskEditorActions[label="MaskEditorActions\n< QObject" style=filled fillcolor=beige]; -MaskEditorActions->MaskeditorListmodel; +FrameActions[label="FrameActions\n< QObject" style=filled fillcolor=beige]; +FrameActions->MaskeditorListmodel; MaskeditorListmodel[label="MaskeditorListmodel\n < QAbstractListModel\n... < QObject" style=filled fillcolor=beige]; MaskeditorListmodel->MaskList; @@ -65,7 +65,7 @@ MaskGraphicsProxy[label="MaskGraphicsProxy\n< QGraphicsProxyWidget\n... < QGraph ColorMap[label="ColorMap\n< ScientificPlot\n< QWidget" style=filled fillcolor=orchid]; ColorMap->Data2DItem; -MaskToolbar->MaskEditorActions[style=dotted color=magenta]; +MaskToolbar->FrameActions[style=dotted color=magenta]; Data2DItem[label="Data2DItem\n< DataItem\n< QObject" style=filled fillcolor=beige]; Data2DItem->MaskList; diff --git a/GUI/View/Frame/MaskEditingFrame.cpp b/GUI/View/Frame/MaskEditingFrame.cpp index 7006632e731cf5bc81f09bda501cb349ff537021..79d71703a8e6ca9c6c1dc74a0673a23c0c4bc2ec 100644 --- a/GUI/View/Frame/MaskEditingFrame.cpp +++ b/GUI/View/Frame/MaskEditingFrame.cpp @@ -20,7 +20,7 @@ #include "GUI/Model/Project/ProjectDocument.h" #include "GUI/View/Canvas/MaskEditorCanvas.h" #include "GUI/View/Scene/MaskGraphicsScene.h" -#include "GUI/View/Setup/MaskEditorActions.h" +#include "GUI/View/Setup/FrameActions.h" #include "GUI/View/Setup/MaskPanel.h" #include "GUI/View/Setup/MaskToolbar.h" #include <QMenu> @@ -29,7 +29,6 @@ MaskEditingFrame::MaskEditingFrame(QWidget* parent) : DataAccessWidget(parent) - , m_actions(new MaskEditorActions) , m_panel(new MaskPanel) , m_canvas2D(new MaskEditorCanvas) { @@ -45,46 +44,46 @@ MaskEditingFrame::MaskEditingFrame(QWidget* parent) splitter->addWidget(m_panel); splitter->setCollapsible(1, true); - auto* toolbar = new MaskToolbar(m_actions); + auto* toolbar = new MaskToolbar(gActions); layout->addWidget(toolbar); m_panel->setPanelHidden(true); //... Connections - connect(m_actions->toggle_mask_value, &QAction::triggered, [this] { + connect(gActions->toggle_mask_value, &QAction::triggered, [this] { if (MaskeditorListmodel* mask_list_model = currentListmodel()) { mask_list_model->toggleMaskValue(); gDoc->setModified(); } }); - connect(m_actions->bring_to_front, &QAction::triggered, [this] { + connect(gActions->bring_to_front, &QAction::triggered, [this] { if (MaskeditorListmodel* mask_list_model = currentListmodel()) { mask_list_model->moveUp(); gDoc->setModified(); } }); - connect(m_actions->send_to_back, &QAction::triggered, [this] { + connect(gActions->send_to_back, &QAction::triggered, [this] { if (MaskeditorListmodel* mask_list_model = currentListmodel()) { mask_list_model->moveUp(); gDoc->setModified(); } }); - connect(m_actions->delete_mask, &QAction::triggered, [this] { + connect(gActions->delete_mask, &QAction::triggered, [this] { if (MaskeditorListmodel* mask_list_model = currentListmodel()) { mask_list_model->removeSelected(); gDoc->setModified(); } }); - connect(m_actions->reset_view, &QAction::triggered, m_canvas2D, + connect(gActions->reset_view, &QAction::triggered, m_canvas2D, &MaskEditorCanvas::onResetViewRequest); - connect(m_actions->save_plot, &QAction::triggered, m_canvas2D, + connect(gActions->save_plot, &QAction::triggered, m_canvas2D, &MaskEditorCanvas::onSavePlotRequest); - connect(m_actions->toggle_panel, &QAction::triggered, + connect(gActions->toggle_panel, &QAction::triggered, [this] { m_panel->setPanelHidden(!m_panel->isHidden()); }); connect(toolbar, &MaskToolbar::activityChanged, m_canvas2D->getScene(), @@ -98,7 +97,7 @@ MaskEditingFrame::MaskEditingFrame(QWidget* parent) &MaskToolbar::onChangeActivityRequest); connect(m_canvas2D, &MaskEditorCanvas::deleteSelectedRequest, - [this] { m_actions->delete_mask->trigger(); }); + [this] { gActions->delete_mask->trigger(); }); connect(m_canvas2D->getScene(), &MaskGraphicsScene::itemContextMenuRequest, this, &MaskEditingFrame::onItemContextMenuRequest); @@ -124,7 +123,7 @@ void MaskEditingFrame::setJobOrDatafileItem(QObject* item) QList<QAction*> MaskEditingFrame::actionList() { - return {m_actions->reset_view, m_actions->toggle_panel}; + return {gActions->reset_view, gActions->toggle_panel}; } void MaskEditingFrame::updateFrame() @@ -163,20 +162,20 @@ void MaskEditingFrame::onItemContextMenuRequest(const QPoint& point) return; const bool canBringToBack = (indexes.front().row() != 0); - m_actions->send_to_back->setEnabled(canBringToBack); + gActions->send_to_back->setEnabled(canBringToBack); const bool canBringToFront = (indexes.front().row() != mask_list_model->maskContItem()->size() - 1); - m_actions->bring_to_front->setEnabled(canBringToFront); + gActions->bring_to_front->setEnabled(canBringToFront); QMenu menu; - menu.addAction(m_actions->toggle_mask_value); - menu.addAction(m_actions->bring_to_front); - menu.addAction(m_actions->send_to_back); + menu.addAction(gActions->toggle_mask_value); + menu.addAction(gActions->bring_to_front); + menu.addAction(gActions->send_to_back); menu.addSeparator(); - menu.addAction(m_actions->delete_mask); + menu.addAction(gActions->delete_mask); menu.exec(point); - m_actions->send_to_back->setEnabled(true); - m_actions->bring_to_front->setEnabled(true); + gActions->send_to_back->setEnabled(true); + gActions->bring_to_front->setEnabled(true); } } diff --git a/GUI/View/Frame/MaskEditingFrame.h b/GUI/View/Frame/MaskEditingFrame.h index 0b8a4f354cda9a2b65c6766eb6893d419a322c2c..4b1a0d17b0e6cead4e401133f2ac14678572fade 100644 --- a/GUI/View/Frame/MaskEditingFrame.h +++ b/GUI/View/Frame/MaskEditingFrame.h @@ -17,7 +17,6 @@ #include "GUI/View/Access/DataAccessWidget.h" -class MaskEditorActions; class MaskEditorCanvas; class MaskPanel; class MaskeditorListmodel; @@ -41,7 +40,6 @@ private: void hideEvent(QHideEvent*) override; void onItemContextMenuRequest(const QPoint& point); - MaskEditorActions* m_actions; MaskPanel* m_panel; MaskEditorCanvas* m_canvas2D; }; diff --git a/GUI/View/Setup/MaskEditorActions.cpp b/GUI/View/Setup/FrameActions.cpp similarity index 89% rename from GUI/View/Setup/MaskEditorActions.cpp rename to GUI/View/Setup/FrameActions.cpp index 598bd861cd6e743f0f189738668de1f7ffa2361d..e118bbddaa3d69dddc79d85ff520a8d672fc9b5a 100644 --- a/GUI/View/Setup/MaskEditorActions.cpp +++ b/GUI/View/Setup/FrameActions.cpp @@ -2,8 +2,8 @@ // // BornAgain: simulate and fit reflection and scattering // -//! @file GUI/View/Setup/MaskEditorActions.cpp -//! @brief Implement class MaskEditorActions +//! @file GUI/View/Setup/FrameActions.cpp +//! @brief Implement class FrameActions //! //! @homepage http://www.bornagainproject.org //! @license GNU General Public License v3 or higher (see COPYING) @@ -12,10 +12,12 @@ // // ************************************************************************************************ -#include "GUI/View/Setup/MaskEditorActions.h" +#include "GUI/View/Setup/FrameActions.h" #include "GUI/View/Access/DataActions.h" -MaskEditorActions::MaskEditorActions() +FrameActions* gActions; //<! Global pointer to single instance. + +FrameActions::FrameActions() : toggle_mask_value(new QAction) , bring_to_front(new QAction) , send_to_back(new QAction) diff --git a/GUI/View/Setup/MaskEditorActions.h b/GUI/View/Setup/FrameActions.h similarity index 75% rename from GUI/View/Setup/MaskEditorActions.h rename to GUI/View/Setup/FrameActions.h index f9683f98ce9362180b195fa241ce2c0672f9eb82..cfe5783a9d438c45b2d58f2c118757de6adeb2f8 100644 --- a/GUI/View/Setup/MaskEditorActions.h +++ b/GUI/View/Setup/FrameActions.h @@ -2,8 +2,8 @@ // // BornAgain: simulate and fit reflection and scattering // -//! @file GUI/View/Setup/MaskEditorActions.h -//! @brief Defines class MaskEditorActions. +//! @file GUI/View/Setup/FrameActions.h +//! @brief Defines class FrameActions. //! //! @homepage http://www.bornagainproject.org //! @license GNU General Public License v3 or higher (see COPYING) @@ -12,8 +12,8 @@ // // ************************************************************************************************ -#ifndef BORNAGAIN_GUI_VIEW_SETUP_MASKEDITORACTIONS_H -#define BORNAGAIN_GUI_VIEW_SETUP_MASKEDITORACTIONS_H +#ifndef BORNAGAIN_GUI_VIEW_SETUP_FRAMEACTIONS_H +#define BORNAGAIN_GUI_VIEW_SETUP_FRAMEACTIONS_H #include <QAction> #include <QObject> @@ -22,10 +22,10 @@ //! lower/rize mask in the stack, delete mask). If more than one MaskItem is selected, //! action will be applied to the whole selection, if possible. -class MaskEditorActions : public QObject { +class FrameActions : public QObject { Q_OBJECT public: - MaskEditorActions(); + FrameActions(); QAction* toggle_mask_value; QAction* bring_to_front; @@ -37,4 +37,6 @@ public: QAction* toggle_panel; }; -#endif // BORNAGAIN_GUI_VIEW_SETUP_MASKEDITORACTIONS_H +extern FrameActions* gActions; + +#endif // BORNAGAIN_GUI_VIEW_SETUP_FRAMEACTIONS_H diff --git a/GUI/View/Setup/MaskToolbar.cpp b/GUI/View/Setup/MaskToolbar.cpp index 56a4fde06eb767f7683bd9f00a8dacd13e47ac64..5cf7ea4d2eb37f3086f56b6bfe182dbd52cb8a4d 100644 --- a/GUI/View/Setup/MaskToolbar.cpp +++ b/GUI/View/Setup/MaskToolbar.cpp @@ -14,7 +14,7 @@ #include "GUI/View/Setup/MaskToolbar.h" #include "Base/Util/Assert.h" -#include "GUI/View/Setup/MaskEditorActions.h" +#include "GUI/View/Setup/FrameActions.h" #include "GUI/View/Tool/mainwindow_constants.h" #include <QLabel> #include <QRadioButton> @@ -22,7 +22,7 @@ #include <QToolButton> #include <QVariant> -MaskToolbar::MaskToolbar(MaskEditorActions* actions) +MaskToolbar::MaskToolbar(FrameActions* actions) : m_activity_button_group(new QButtonGroup(this)) { setOrientation(Qt::Vertical); diff --git a/GUI/View/Setup/MaskToolbar.h b/GUI/View/Setup/MaskToolbar.h index 3f960ac1a6d23db5d6dfe1e8982e4e29f1d52441..8d2f11ef5cabb8133ee185c1ad26160708ddc3a7 100644 --- a/GUI/View/Setup/MaskToolbar.h +++ b/GUI/View/Setup/MaskToolbar.h @@ -19,14 +19,14 @@ #include <QButtonGroup> #include <QToolBar> -class MaskEditorActions; +class FrameActions; //! Iconic representation of mask editing tools. class MaskToolbar : public QToolBar { Q_OBJECT public: - MaskToolbar(MaskEditorActions* actions); + MaskToolbar(FrameActions* actions); public slots: void onChangeActivityRequest(MaskFlags::MaskMode mask_mode);