Commit d4238ed1 authored by Alessandro Portale's avatar Alessandro Portale

ScxmlEditor: Inline the Navigator ui creation

Change-Id: I53cee0abd948cb2739815d0d7e13330fe22a900e
Reviewed-by: Alessandro Portale's avatarAlessandro Portale <alessandro.portale@qt.io>
parent 33c732c6
......@@ -61,7 +61,6 @@ FORMS += \
$$PWD/colorsettings.ui \
$$PWD/colorthemedialog.ui \
$$PWD/magnifier.ui \
$$PWD/navigator.ui \
$$PWD/navigatorslider.ui \
$$PWD/search.ui \
$$PWD/shapegroupwidget.ui \
......
......@@ -26,49 +26,51 @@
#include "navigator.h"
#include "graphicsscene.h"
#include "graphicsview.h"
#include "navigatorgraphicsview.h"
#include "navigatorslider.h"
#include "sizegrip.h"
#include <utils/utilsicons.h>
#include <QLabel>
#include <QResizeEvent>
#include <QToolBar>
#include <QToolButton>
using namespace ScxmlEditor::Common;
Navigator::Navigator(QWidget *parent)
: MovableFrame(parent)
{
m_ui.setupUi(this);
m_ui.m_closeButton->setIcon(Utils::Icons::CLOSE_TOOLBAR.icon());
connect(m_ui.m_closeButton, &QToolButton::clicked, this, &Navigator::hideFrame);
m_sizeGrip = new SizeGrip(this);
m_sizeGrip->setGeometry(0, 0, 18, 18);
createUi();
connect(m_closeButton, &QToolButton::clicked, this, &Navigator::hideFrame);
}
void Navigator::setCurrentView(GraphicsView *view)
{
if (m_currentView) {
m_currentView->disconnect(m_ui.m_navigatorView);
m_ui.m_navigatorView->disconnect(m_currentView);
m_currentView->disconnect(m_ui.m_navigatorSlider);
m_ui.m_navigatorSlider->disconnect(m_currentView);
m_currentView->disconnect(m_navigatorView);
m_navigatorView->disconnect(m_currentView);
m_currentView->disconnect(m_navigatorSlider);
m_navigatorSlider->disconnect(m_currentView);
}
m_currentView = view;
if (m_currentView) {
connect(m_currentView.data(), &GraphicsView::viewChanged, m_ui.m_navigatorView, &NavigatorGraphicsView::setMainViewPolygon);
connect(m_currentView.data(), &GraphicsView::zoomPercentChanged, m_ui.m_navigatorSlider, &NavigatorSlider::setSliderValue);
connect(m_currentView.data(), &GraphicsView::viewChanged, m_navigatorView, &NavigatorGraphicsView::setMainViewPolygon);
connect(m_currentView.data(), &GraphicsView::zoomPercentChanged, m_navigatorSlider, &NavigatorSlider::setSliderValue);
connect(m_ui.m_navigatorSlider, &NavigatorSlider::valueChanged, m_currentView.data(), &GraphicsView::zoomTo);
connect(m_ui.m_navigatorView, &NavigatorGraphicsView::moveMainViewTo, m_currentView.data(), &GraphicsView::moveToPoint);
connect(m_ui.m_navigatorView, &NavigatorGraphicsView::zoomIn, m_currentView.data(), &GraphicsView::zoomIn);
connect(m_ui.m_navigatorView, &NavigatorGraphicsView::zoomOut, m_currentView.data(), &GraphicsView::zoomOut);
connect(m_navigatorSlider, &NavigatorSlider::valueChanged, m_currentView.data(), &GraphicsView::zoomTo);
connect(m_navigatorView, &NavigatorGraphicsView::moveMainViewTo, m_currentView.data(), &GraphicsView::moveToPoint);
connect(m_navigatorView, &NavigatorGraphicsView::zoomIn, m_currentView.data(), &GraphicsView::zoomIn);
connect(m_navigatorView, &NavigatorGraphicsView::zoomOut, m_currentView.data(), &GraphicsView::zoomOut);
}
}
void Navigator::setCurrentScene(ScxmlEditor::PluginInterface::GraphicsScene *scene)
{
m_ui.m_navigatorView->setGraphicsScene(scene);
m_navigatorView->setGraphicsScene(scene);
}
void Navigator::resizeEvent(QResizeEvent *e)
......@@ -76,3 +78,33 @@ void Navigator::resizeEvent(QResizeEvent *e)
MovableFrame::resizeEvent(e);
m_sizeGrip->move(e->size().width() - m_sizeGrip->width(), e->size().height() - m_sizeGrip->height());
}
void Navigator::createUi()
{
auto titleLabel = new QLabel(tr("Navigator"));
titleLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
m_closeButton = new QToolButton;
m_closeButton->setIcon(Utils::Icons::CLOSE_TOOLBAR.icon());
auto titleToolBar = new QToolBar;
titleToolBar->addWidget(titleLabel);
titleToolBar->addWidget(m_closeButton);
m_navigatorView = new NavigatorGraphicsView;
m_navigatorSlider = new NavigatorSlider;
setLayout(new QVBoxLayout);
layout()->setSpacing(0);
layout()->setMargin(0);
layout()->addWidget(titleToolBar);
layout()->addWidget(m_navigatorView);
layout()->addWidget(m_navigatorSlider);
m_sizeGrip = new SizeGrip(this);
m_sizeGrip->setGeometry(0, 0, 18, 18);
setAutoFillBackground(true);
setMinimumSize(300, 200);
setGeometry(x(), y(), 400, 300);
}
......@@ -26,15 +26,18 @@
#pragma once
#include "movableframe.h"
#include "ui_navigator.h"
#include <QPointer>
QT_FORWARD_DECLARE_CLASS(QToolButton)
namespace ScxmlEditor {
namespace PluginInterface { class GraphicsScene; }
namespace Common {
class NavigatorGraphicsView;
class NavigatorSlider;
class SizeGrip;
class GraphicsView;
......@@ -55,9 +58,13 @@ protected:
void resizeEvent(QResizeEvent *e) override;
private:
SizeGrip *m_sizeGrip;
void createUi();
QPointer<GraphicsView> m_currentView;
Ui::Navigator m_ui;
NavigatorGraphicsView *m_navigatorView = nullptr;
NavigatorSlider *m_navigatorSlider = nullptr;
QToolButton *m_closeButton = nullptr;
SizeGrip *m_sizeGrip;
};
} // namespace Common
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ScxmlEditor::Common::Navigator</class>
<widget class="QFrame" name="ScxmlEditor::Common::Navigator">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>300</width>
<height>230</height>
</rect>
</property>
<property name="windowTitle">
<string>Frame</string>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QFrame" name="m_titleFrame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="m_title">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Navigator</string>
</property>
<property name="margin">
<number>5</number>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="m_closeButton">
<property name="minimumSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="ScxmlEditor::Common::NavigatorGraphicsView" name="m_navigatorView">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
</widget>
</item>
<item>
<widget class="ScxmlEditor::Common::NavigatorSlider" name="m_navigatorSlider">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>ScxmlEditor::Common::NavigatorGraphicsView</class>
<extends>QGraphicsView</extends>
<header>navigatorgraphicsview.h</header>
</customwidget>
<customwidget>
<class>ScxmlEditor::Common::NavigatorSlider</class>
<extends>QFrame</extends>
<header>navigatorslider.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
......@@ -72,7 +72,6 @@ QtcPlugin {
"colorpicker.ui",
"colorsettings.ui",
"colorthemedialog.ui",
"navigator.ui",
"navigatorslider.ui",
"search.ui",
"shapegroupwidget.ui",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment