ui: statusbar
statusbar added, listen to status- , error- and parsingfinishedmessages
This commit is contained in:
@@ -19,6 +19,8 @@ add_files(
|
||||
qt/element/QtSearchBar.h
|
||||
qt/element/QtSmartSearchBox.cpp
|
||||
qt/element/QtSmartSearchBox.h
|
||||
qt/element/QtStatusBar.cpp
|
||||
qt/element/QtStatusBar.h
|
||||
|
||||
qt/graphics/QtGraphicsRoundedRectItem.cpp
|
||||
qt/graphics/QtGraphicsRoundedRectItem.h
|
||||
@@ -52,6 +54,8 @@ add_files(
|
||||
qt/view/QtMainView.h
|
||||
qt/view/QtSearchView.cpp
|
||||
qt/view/QtSearchView.h
|
||||
qt/view/QtStatusBarView.cpp
|
||||
qt/view/QtStatusBarView.h
|
||||
qt/view/QtViewFactory.cpp
|
||||
qt/view/QtViewFactory.h
|
||||
qt/view/QtViewWidgetWrapper.cpp
|
||||
|
||||
@@ -20,6 +20,7 @@ QtMainWindow::QtMainWindow()
|
||||
{
|
||||
setObjectName("QtMainWindow");
|
||||
setCentralWidget(nullptr);
|
||||
setDockNestingEnabled(true);
|
||||
|
||||
setupProjectMenu();
|
||||
setupViewMenu();
|
||||
@@ -73,8 +74,8 @@ void QtMainWindow::openProject(const QString &path)
|
||||
}
|
||||
|
||||
void QtMainWindow::saveProject()
|
||||
{
|
||||
MessageSaveProject("").dispatch();
|
||||
{
|
||||
MessageSaveProject("").dispatch();
|
||||
}
|
||||
|
||||
void QtMainWindow::saveAsProject()
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
#include "qt/element/QtStatusBar.h"
|
||||
|
||||
QtStatusBar::QtStatusBar()
|
||||
: m_text(this)
|
||||
{
|
||||
m_text.setText("hallo test test");
|
||||
addWidget(&m_text);
|
||||
}
|
||||
|
||||
QtStatusBar::~QtStatusBar()
|
||||
{
|
||||
}
|
||||
|
||||
void QtStatusBar::setText(const std::string& text, bool isError)
|
||||
{
|
||||
if (isError)
|
||||
{
|
||||
m_text.setStyleSheet("QLabel { color: red }");
|
||||
}
|
||||
m_text.setText(text.c_str());
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef QT_STATUS_BAR_H
|
||||
#define QT_STATUS_BAR_H
|
||||
|
||||
#include <string>
|
||||
#include <QStatusBar>
|
||||
#include <QProgressBar>
|
||||
#include <QLabel>
|
||||
|
||||
class QtStatusBar : public QStatusBar
|
||||
{
|
||||
public:
|
||||
QtStatusBar(void);
|
||||
~QtStatusBar(void);
|
||||
|
||||
void setText(const std::string& text, bool isError = false);
|
||||
private:
|
||||
QLabel m_text;
|
||||
};
|
||||
|
||||
#endif // !QT_STATUS_BAR_H
|
||||
@@ -51,3 +51,13 @@ void QtMainView::saveLayout()
|
||||
{
|
||||
m_window->saveLayout();
|
||||
}
|
||||
|
||||
QStatusBar* QtMainView::getStatusBar()
|
||||
{
|
||||
return m_window->statusBar();
|
||||
}
|
||||
|
||||
void QtMainView::setStatusBar(QStatusBar* statusbar)
|
||||
{
|
||||
m_window->setStatusBar(statusbar);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include <QStatusBar>
|
||||
#include "component/view/MainView.h"
|
||||
|
||||
class QtMainWindow;
|
||||
@@ -25,6 +26,9 @@ public:
|
||||
virtual void loadLayout();
|
||||
virtual void saveLayout();
|
||||
|
||||
virtual QStatusBar* getStatusBar();
|
||||
virtual void setStatusBar(QStatusBar* statusBar);
|
||||
|
||||
private:
|
||||
std::shared_ptr<QtMainWindow> m_window;
|
||||
std::vector<View*> m_views;
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
#include "qt/view/QtStatusBarView.h"
|
||||
|
||||
#include <QStatusBar>
|
||||
#include "qt/view/QtMainView.h"
|
||||
#include "qt/view/QtViewWidgetWrapper.h"
|
||||
|
||||
QtStatusBarView::QtStatusBarView( ViewLayout* viewLayout )
|
||||
: StatusBarView(viewLayout)
|
||||
, m_showMessageFunctor(std::bind(&QtStatusBarView::doShowMessage, this, std::placeholders::_1, std::placeholders::_2))
|
||||
{
|
||||
QtMainView* mw = static_cast<QtMainView*>(viewLayout);
|
||||
m_widget = std::make_shared<QtStatusBar>();
|
||||
QStatusBar* sb = static_cast<QStatusBar*>(m_widget.get());
|
||||
mw->setStatusBar(sb);
|
||||
m_widget->show();
|
||||
}
|
||||
|
||||
QtStatusBarView::~QtStatusBarView()
|
||||
{
|
||||
}
|
||||
|
||||
void QtStatusBarView::createWidgetWrapper()
|
||||
{
|
||||
//setWidgetWrapper(std::make_shared<QtViewWidgetWrapper>(m_widget));
|
||||
}
|
||||
|
||||
void QtStatusBarView::initView()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void QtStatusBarView::refreshView()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void QtStatusBarView::doShowMessage( const std::string& message, bool isError )
|
||||
{
|
||||
m_widget->setText(message, isError);
|
||||
}
|
||||
|
||||
void QtStatusBarView::showMessage( const std::string& message, bool isError )
|
||||
{
|
||||
m_showMessageFunctor(message, isError);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
#ifndef QT_STATUS_BAR_VIEW_H
|
||||
#define QT_STATUS_BAR_VIEW_H
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "component/view/StatusBarView.h"
|
||||
#include "qt/element/QtStatusBar.h"
|
||||
#include "qt/utility/QtThreadedFunctor.h"
|
||||
|
||||
class QtStatusBarView : public StatusBarView
|
||||
{
|
||||
public:
|
||||
QtStatusBarView(ViewLayout* viewLayout);
|
||||
~QtStatusBarView();
|
||||
|
||||
// View implementation
|
||||
virtual void createWidgetWrapper();
|
||||
virtual void initView();
|
||||
virtual void refreshView();
|
||||
|
||||
// StatusBar view implementation
|
||||
virtual void showMessage(const std::string& message, bool isError);
|
||||
private:
|
||||
void doShowMessage(const std::string& message, bool isError);
|
||||
std::shared_ptr<QtStatusBar> m_widget;
|
||||
|
||||
QtThreadedFunctor<const std::string&, bool> m_showMessageFunctor;
|
||||
};
|
||||
|
||||
#endif // !QT_STATUS_BAR_VIEW_H
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "qt/view/QtGraphView.h"
|
||||
#include "qt/view/QtMainView.h"
|
||||
#include "qt/view/QtSearchView.h"
|
||||
#include "qt/view/QtStatusBarView.h"
|
||||
|
||||
QtViewFactory::QtViewFactory()
|
||||
{
|
||||
@@ -32,3 +33,8 @@ std::shared_ptr<SearchView> QtViewFactory::createSearchView(ViewLayout* viewLayo
|
||||
{
|
||||
return View::create<QtSearchView>(viewLayout);
|
||||
}
|
||||
|
||||
std::shared_ptr<StatusBarView> QtViewFactory::createStatusBarView(ViewLayout* viewLayout) const
|
||||
{
|
||||
return View::createAndDontAddToLayout<QtStatusBarView>(viewLayout);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ public:
|
||||
virtual std::shared_ptr<CodeView> createCodeView(ViewLayout* viewLayout) const;
|
||||
virtual std::shared_ptr<GraphView> createGraphView(ViewLayout* viewLayout) const;
|
||||
virtual std::shared_ptr<SearchView> createSearchView(ViewLayout* viewLayout) const;
|
||||
virtual std::shared_ptr<StatusBarView> createStatusBarView(ViewLayout* viewLayout) const;
|
||||
};
|
||||
|
||||
#endif // QT_VIEW_FACTORY_H
|
||||
|
||||
@@ -121,13 +121,13 @@ void QtCorneredConnection::paint(QPainter *painter, const QStyleOptionGraphicsIt
|
||||
|
||||
if (i != 1)
|
||||
{
|
||||
if (dir % 2 == 1 && abs(a.y() - b.y()) < 2 * br)
|
||||
if (dir % 2 == 1 && std::abs(a.y() - b.y()) < 2 * br)
|
||||
{
|
||||
br = abs(a.y() - b.y()) / 2;
|
||||
br = std::abs(a.y() - b.y()) / 2;
|
||||
}
|
||||
else if (dir % 2 == 0 && abs(a.x() - b.x()) < 2 * br)
|
||||
else if (dir % 2 == 0 && std::abs(a.x() - b.x()) < 2 * br)
|
||||
{
|
||||
br = abs(a.x() - b.x()) / 2;
|
||||
br = std::abs(a.x() - b.x()) / 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user