Skip to content
Commits on Source (2)
......@@ -141,6 +141,7 @@ public slots:
void stitchSelectionChange();
void refreshStitchList();
void refreshStitch(OE_stitchs* stitch);
void styleChange();
};
......@@ -129,7 +129,8 @@ SOURCES += \
src/qt/OE_ui_toolbox.cpp \
src/qt/OE_ui_stitchlist.cpp \
src/qt/listviewdelegate.cpp \
src/OE_preferences.cpp
src/OE_preferences.cpp \
src/qt/OE_ui_viewportoptions.cpp
HEADERS += \
src/qt/mainwindow.h \
......@@ -262,7 +263,8 @@ HEADERS += \
src/qt/OE_ui_toolbox.h \
src/qt/OE_ui_stitchlist.h \
src/qt/listviewdelegate.h \
src/OE_preferences.h
src/OE_preferences.h \
src/qt/OE_ui_viewportoptions.h
FORMS += \
src/qt/mainwindow.ui
......
......@@ -86,6 +86,7 @@ bool OE_interfaceDisplay::setDisplayStyle(unsigned int displayStyleId)
if (displayStyles.size()>displayStyleId)
{
OE_display::setDisplayStyle(displayStyles[displayStyleId]);
emit styleChange();
return true;
}
return false;
......
#include "OE_ui_viewportoptions.h"
OE_ui_viewportOptions::OE_ui_viewportOptions(MainWindow* window, OE_root* root)
{
this->root = root;
this->window = window;
topGlWindowBar();
this->setMargin(0);
this->setContentsMargins(0,0,0,0);
onRefresh();
connect(getInterfaceDisplay(), SIGNAL(styleChange()), this, SLOT(onRefresh()));
}
QtMaterialIconButton* OE_ui_viewportOptions::setIconButton(QString iconFile, const QObject *receiver = NULL, const char * method = NULL)
{
QIcon icon;
icon.addFile(iconFile, QSize(), QIcon::Normal, QIcon::Off);
QtMaterialIconButton* button = new QtMaterialIconButton(icon);
button->setUseThemeColors(false);
button->setIconSize(QSize(25,25));
button->setRole(Material::Primary);
if (method)
connect(button, SIGNAL(clicked()), receiver, method);
return button;
}
void OE_ui_viewportOptions::topGlWindowBar()
{
setAlignment(Qt::AlignTop);
setSpacing(4);
setMargin(3);
addWidget(setIconButton(":/resources/zoom_selection.svg",getInterfaceDisplay(),SLOT(zoomOnSelection())));
addWidget(setIconButton(":/resources/zoom_document.svg"));
addSpacing(8);
gridButton = setIconButton(":/resources/grid.svg", this, SLOT(onToggleGrid()));
gridButton->setCheckable( true );
addWidget(gridButton);
showCurvesButton = setIconButton(":/resources/show_curve.svg", this, SLOT(onToggleShowCurve()));
showCurvesButton->setCheckable( true );
addWidget(showCurvesButton);
showStitchButton = setIconButton(":/resources/show_stitch.svg", this, SLOT(onToggleShowStitch()));
showStitchButton->setCheckable( true );
addWidget(showStitchButton);
addSpacing(8);
selectCurvesButton = setIconButton(":/resources/select_curve.svg", this, SLOT(onToggleSelectCurve()));
selectCurvesButton->setCheckable( true );
addWidget(selectCurvesButton);
selectStitchButton = setIconButton(":/resources/select_stitch.svg", this, SLOT(onToggleSelectStitch()));
selectStitchButton->setCheckable( true );
addWidget(selectStitchButton);
}
OE_controller* OE_ui_viewportOptions::getController()
{
return this->root->interfaceDisplay->getController();
}
OE_interfaceDisplay* OE_ui_viewportOptions::getInterfaceDisplay()
{
return this->root->interfaceDisplay;
}
OE_document* OE_ui_viewportOptions::getDocument()
{
return this->root->interfaceDisplay->getDocument();
}
void OE_ui_viewportOptions::onRefresh()
{
gridButton->setChecked(getInterfaceDisplay()->style->drawGrid);
showCurvesButton->setChecked(getInterfaceDisplay()->style->drawCurves);
showStitchButton->setChecked(getInterfaceDisplay()->style->drawStitches);
selectCurvesButton->setChecked(getInterfaceDisplay()->style->selectCurves);
selectStitchButton->setChecked(getInterfaceDisplay()->style->selectStitches);
}
void OE_ui_viewportOptions::onToggleGrid()
{
getInterfaceDisplay()->style->drawGrid = !getInterfaceDisplay()->style->drawGrid;
getInterfaceDisplay()->update();
}
void OE_ui_viewportOptions::onToggleShowCurve()
{
getInterfaceDisplay()->style->drawCurves = !getInterfaceDisplay()->style->drawCurves;
getInterfaceDisplay()->update();
}
void OE_ui_viewportOptions::onToggleShowStitch()
{
getInterfaceDisplay()->style->drawStitches = !getInterfaceDisplay()->style->drawStitches;
getInterfaceDisplay()->update();
}
void OE_ui_viewportOptions::onToggleSelectCurve()
{
getInterfaceDisplay()->style->selectCurves = !getInterfaceDisplay()->style->selectCurves;
getInterfaceDisplay()->update();
}
void OE_ui_viewportOptions::onToggleSelectStitch()
{
getInterfaceDisplay()->style->selectStitches = !getInterfaceDisplay()->style->selectStitches;
getInterfaceDisplay()->update();
}
#ifndef OE_UI_VIEWPORTOPTIONS_H
#define OE_UI_VIEWPORTOPTIONS_H
#include "main.h"
#include <QWidget>
#include <QHBoxLayout>
#include <qtmaterialiconbutton.h>
class MainWindow;
class OE_ui_viewportOptions : public QHBoxLayout
{
Q_OBJECT
public:
OE_ui_viewportOptions(MainWindow* window, OE_root* root);
OE_controller* getController();
OE_interfaceDisplay* getInterfaceDisplay();
OE_document* getDocument();
private:
void topGlWindowBar();
QtMaterialIconButton* setIconButton(QString iconFile, const QObject *receiver, const char * method);
OE_root* root;
MainWindow* window;
QtMaterialIconButton* gridButton;
QtMaterialIconButton* showCurvesButton;
QtMaterialIconButton* showStitchButton;
QtMaterialIconButton* selectCurvesButton;
QtMaterialIconButton* selectStitchButton;
signals:
public slots:
void onRefresh();
void onToggleGrid();
void onToggleShowCurve();
void onToggleShowStitch();
void onToggleSelectCurve();
void onToggleSelectStitch();
};
#endif // OE_UI_VIEWPORTOPTIONS_H
......@@ -10,6 +10,7 @@
#include "qtmaterialtoggle.h"
#include "qtmaterialcheckbox.h"
#include "OE_ui_toolbox.h"
#include "OE_ui_viewportoptions.h"
#include "OE_ui_stitchlist.h"
MainWindow::MainWindow(QWidget *parent) :
......@@ -87,14 +88,14 @@ void MainWindow::addTab()
openglWidgetLayout->setStretch(0, 0);
//viewport top bar (viewport options)
QBoxLayout *topGlWindowLayout = topGlWindowBar();
openglWidgetLayout->addLayout(topGlWindowLayout);
openglWidgetLayout->setStretch(1, 0);
m_viewportOptionBar = new OE_ui_viewportOptions(this, newRoot);
openglWidgetLayout->addLayout(m_viewportOptionBar);
openglWidgetLayout->setStretch(1, 0);
openglWidgetLayout->addStretch(1);
//viewport top bar (viewport options)
//selected stitches param
QBoxLayout *stitchParamLayout = stitchParam();
openglWidgetLayout->addLayout(stitchParamLayout);
openglWidgetLayout->setStretch(3, 0);
......@@ -131,40 +132,6 @@ void MainWindow::addTab()
update();
}
QtMaterialIconButton* MainWindow::setIconButton(QString iconFile, const char * method = NULL)
{
QIcon icon;
icon.addFile(iconFile, QSize(), QIcon::Normal, QIcon::Off);
QtMaterialIconButton* button = new QtMaterialIconButton(icon);
button->setUseThemeColors(false);
button->setIconSize(QSize(25,25));
if (method)
connect(button, SIGNAL(clicked(bool)), this, method);
return button;
}
QBoxLayout* MainWindow::topGlWindowBar()
{
QHBoxLayout *topGlWindowLayout = new QHBoxLayout;
topGlWindowLayout->setAlignment(Qt::AlignTop);
topGlWindowLayout->setSpacing(4);
topGlWindowLayout->setMargin(3);
topGlWindowLayout->addWidget(setIconButton(":/resources/zoom_selection.svg"));
topGlWindowLayout->addWidget(setIconButton(":/resources/zoom_document.svg"));
topGlWindowLayout->addSpacing(8);
topGlWindowLayout->addWidget(setIconButton(":/resources/grid.svg"));
topGlWindowLayout->addWidget(setIconButton(":/resources/show_curve.svg"));
topGlWindowLayout->addWidget(setIconButton(":/resources/show_stitch.svg"));
topGlWindowLayout->addSpacing(8);
topGlWindowLayout->addWidget(setIconButton(":/resources/select_curve.svg"));
topGlWindowLayout->addWidget(setIconButton(":/resources/select_stitch.svg"));
return topGlWindowLayout;
}
QBoxLayout* MainWindow::stitchParam()
{
QVBoxLayout *topGlWindowLayout = new QVBoxLayout;
......@@ -181,20 +148,6 @@ QBoxLayout* MainWindow::stitchParam()
return topGlWindowLayout;
}
QtMaterialFlatButton* MainWindow::setButton(QString name, const char * method = NULL)
{
QtMaterialFlatButton* button = new QtMaterialFlatButton(name);
button->setFont(QFont("Roboto", 8, QFont::Medium));
button->setUseThemeColors(true);
button->setHaloVisible(false);
button->setMinimumHeight(0);
if (method)
connect(button, SIGNAL(clicked(bool)), this, method);
return button;
}
OE_interfaceDisplay* MainWindow::getItfDisplay()
{
QWidget* widget = ui->tabWidget->currentWidget();
......
......@@ -28,6 +28,7 @@ class MainWindow;
class OE_interfaceDisplay;
class OE_root;
class OE_ui_toolBox;
class OE_ui_viewportOptions;
class OE_ui_stitchList;
class MainWindow : public QMainWindow
......@@ -40,11 +41,10 @@ public:
void addTab();
OE_ui_toolBox* m_leftToolTab;
QBoxLayout* topGlWindowBar();
OE_ui_viewportOptions* m_viewportOptionBar;
//QBoxLayout* topGlWindowBar();
QBoxLayout* stitchParam();
OE_ui_stitchList *stitchesList;
QtMaterialIconButton* setIconButton(QString iconFile, const char * method);
QtMaterialFlatButton* setButton(QString name, const char * method);
void keyPressEvent(QKeyEvent* event);
void keyReleaseEvent(QKeyEvent* event);
......