diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 1bfcd86e..c688c3e5 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -248,6 +248,8 @@ add_files( utility/messaging/type/MessageGraphNodeExpand.h utility/messaging/type/MessageGraphNodeMove.h utility/messaging/type/MessageInterruptTasks.h + utility/messaging/type/MessageLoadAfter.h + utility/messaging/type/MessageLoadBefore.h utility/messaging/type/MessageLoadProject.h utility/messaging/type/MessageMoveIDECursor.h utility/messaging/type/MessageProjectEdit.h diff --git a/src/lib/utility/messaging/type/MessageLoadAfter.h b/src/lib/utility/messaging/type/MessageLoadAfter.h new file mode 100644 index 00000000..1bee329e --- /dev/null +++ b/src/lib/utility/messaging/type/MessageLoadAfter.h @@ -0,0 +1,21 @@ +#ifndef MESSAGE_LOAD_AFTER_H +#define MESSAGE_LOAD_AFTER_H + +#include "utility/messaging/Message.h" + +class MessageLoadAfter + : public Message +{ +public: + MessageLoadAfter() + { + setSendAsTask(false); + } + + static const std::string getStaticType() + { + return "MessageLoadAfter"; + } +}; + +#endif // MESSAGE_LOAD_AFTER_H diff --git a/src/lib/utility/messaging/type/MessageLoadBefore.h b/src/lib/utility/messaging/type/MessageLoadBefore.h new file mode 100644 index 00000000..cf37d10d --- /dev/null +++ b/src/lib/utility/messaging/type/MessageLoadBefore.h @@ -0,0 +1,21 @@ +#ifndef MESSAGE_LOAD_BEFORE_H +#define MESSAGE_LOAD_BEFORE_H + +#include "utility/messaging/Message.h" + +class MessageLoadBefore + : public Message +{ +public: + MessageLoadBefore() + { + setSendAsTask(false); + } + + static const std::string getStaticType() + { + return "MessageLoadBefore"; + } +}; + +#endif // MESSAGE_LOAD_BEFORE_H diff --git a/src/lib_gui/CMakeLists.txt b/src/lib_gui/CMakeLists.txt index c6d02708..4439d314 100644 --- a/src/lib_gui/CMakeLists.txt +++ b/src/lib_gui/CMakeLists.txt @@ -102,6 +102,8 @@ add_files( qt/view/QtUndoRedoView.h qt/view/QtViewFactory.cpp qt/view/QtViewFactory.h + qt/view/QtViewOverlay.cpp + qt/view/QtViewOverlay.h qt/view/QtViewWidgetWrapper.cpp qt/view/QtViewWidgetWrapper.h diff --git a/src/lib_gui/qt/view/QtGraphView.cpp b/src/lib_gui/qt/view/QtGraphView.cpp index 3307f46d..cffa2901 100644 --- a/src/lib_gui/qt/view/QtGraphView.cpp +++ b/src/lib_gui/qt/view/QtGraphView.cpp @@ -19,7 +19,6 @@ #include "qt/utility/utilityQt.h" #include "qt/graphics/QtGraphicsView.h" -#include "qt/view/QtViewWidgetWrapper.h" #include "qt/view/graphElements/nodeComponents/QtGraphNodeComponentClickable.h" #include "qt/view/graphElements/nodeComponents/QtGraphNodeComponentMoveable.h" #include "qt/view/graphElements/QtGraphEdge.h" @@ -27,6 +26,8 @@ #include "qt/view/graphElements/QtGraphNodeBundle.h" #include "qt/view/graphElements/QtGraphNodeData.h" #include "qt/view/graphElements/QtGraphNodeExpandToggle.h" +#include "qt/view/QtViewOverlay.h" +#include "qt/view/QtViewWidgetWrapper.h" #include "settings/ColorScheme.h" QtGraphView::QtGraphView(ViewLayout* viewLayout) @@ -72,6 +73,8 @@ void QtGraphView::initView() connect(view, SIGNAL(emptySpaceClicked()), this, SLOT(clickedInEmptySpace())); + m_overlay = new QtViewOverlay(widget); + doRefreshView(); } diff --git a/src/lib_gui/qt/view/QtGraphView.h b/src/lib_gui/qt/view/QtGraphView.h index 447d062c..0c36ac3f 100644 --- a/src/lib_gui/qt/view/QtGraphView.h +++ b/src/lib_gui/qt/view/QtGraphView.h @@ -15,6 +15,7 @@ class QSequentialAnimationGroup; class QtGraphEdge; class QtGraphicsView; class QtGraphNode; +class QtViewOverlay; class QtGraphView : public QObject @@ -108,6 +109,8 @@ private: std::shared_ptr m_transition; QPointF m_sceneRectOffset; + + QtViewOverlay* m_overlay; }; #endif // QT_GRAPH_VIEW_H diff --git a/src/lib_gui/qt/view/QtViewOverlay.cpp b/src/lib_gui/qt/view/QtViewOverlay.cpp new file mode 100644 index 00000000..89493f02 --- /dev/null +++ b/src/lib_gui/qt/view/QtViewOverlay.cpp @@ -0,0 +1,58 @@ +#include "qt/view/QtViewOverlay.h" + +#include +#include + +ResizeFilter::ResizeFilter(QWidget* widget) + : m_widget(widget) +{ +} + +bool ResizeFilter::eventFilter(QObject* obj, QEvent* event) +{ + if (event->type() == QEvent::Resize) + { + QWidget* parent = dynamic_cast(obj); + m_widget->setGeometry(0, 0, parent->width(), parent->height()); + } + + return QObject::eventFilter(obj, event); +} + + +QtViewOverlay::QtViewOverlay(QWidget* parent) + : m_parent(parent) + , m_beforeFunctor(std::bind(&QtViewOverlay::doBefore, this)) + , m_afterFunctor(std::bind(&QtViewOverlay::doAfter, this)) +{ + m_overlay = new QWidget(m_parent); + m_parent->installEventFilter(new ResizeFilter(m_overlay)); + + std::string frameStyle = + "#overlay {" + "background: #55FF0000; " + "}"; + m_overlay->setStyleSheet(frameStyle.c_str()); + m_overlay->setObjectName("overlay"); + m_overlay->hide(); +} + +void QtViewOverlay::handleMessage(MessageLoadBefore* message) +{ + m_beforeFunctor(); +} + +void QtViewOverlay::handleMessage(MessageLoadAfter* message) +{ + m_afterFunctor(); +} + +void QtViewOverlay::doBefore() +{ + m_overlay->show(); +} + +void QtViewOverlay::doAfter() +{ + m_overlay->hide(); +} diff --git a/src/lib_gui/qt/view/QtViewOverlay.h b/src/lib_gui/qt/view/QtViewOverlay.h new file mode 100644 index 00000000..7ef48eaa --- /dev/null +++ b/src/lib_gui/qt/view/QtViewOverlay.h @@ -0,0 +1,53 @@ +#ifndef QT_VIEW_OVERLAY +#define QT_VIEW_OVERLAY + +#include + +#include "qt/utility/QtThreadedFunctor.h" +#include "utility/messaging/MessageListener.h" +#include "utility/messaging/type/MessageLoadBefore.h" +#include "utility/messaging/type/MessageLoadAfter.h" + +class QWidget; + +class ResizeFilter + : public QObject +{ + Q_OBJECT + +signals: + void triggered(); + +public: + ResizeFilter(QWidget* widget); + +protected: + bool eventFilter(QObject* obj, QEvent* event); + +private: + QWidget* m_widget; +}; + + +class QtViewOverlay + : public MessageListener + , public MessageListener +{ +public: + QtViewOverlay(QWidget* parent = 0); + +private: + void handleMessage(MessageLoadBefore* message); + void handleMessage(MessageLoadAfter* message); + + void doBefore(); + void doAfter(); + + QWidget* m_parent; + QWidget* m_overlay; + + QtThreadedFunctor m_beforeFunctor; + QtThreadedFunctor m_afterFunctor; +}; + +#endif // QT_VIEW_OVERLAY diff --git a/src/lib_gui/qt/window/QtMainWindow.cpp b/src/lib_gui/qt/window/QtMainWindow.cpp index 70d83ab7..78fb3462 100644 --- a/src/lib_gui/qt/window/QtMainWindow.cpp +++ b/src/lib_gui/qt/window/QtMainWindow.cpp @@ -27,6 +27,7 @@ #include "utility/messaging/type/MessageDispatchWhenLicenseValid.h" #include "utility/messaging/type/MessageFind.h" #include "utility/messaging/type/MessageInterruptTasks.h" +#include "utility/messaging/type/MessageLoadBefore.h" #include "utility/messaging/type/MessageLoadProject.h" #include "utility/messaging/type/MessageRedo.h" #include "utility/messaging/type/MessageRefresh.h" @@ -370,6 +371,8 @@ void QtMainWindow::showStartScreen() connect(startScreen, SIGNAL(openOpenProjectDialog()), this, SLOT(openProject())); connect(startScreen, SIGNAL(openNewProjectDialog()), this, SLOT(newProject())); + + MessageLoadBefore().dispatch(); } void QtMainWindow::hideStartScreen()