Permalink
Browse files

Layers GUI

  • Loading branch information...
feragon committed Jul 15, 2016
1 parent 5ab27c9 commit bb8205b39ea5db8e5bc4139692d6197aa2c86da3
View
@@ -35,9 +35,12 @@ operations/trimoperation.h
widgets/clicommand.h
widgets/luascript.h
widgets/toolbar.h
widgets/toolbartab.h
widgets/toolbartab.h
widgets/layers.h
widgets/layermodel.h
lua/qtbridge.h
lua/luaqobject.h)
lua/luaqobject.h
dialogs/addlayerdialog.h)
set(UI_srcs
cadmdichild.cpp
@@ -51,15 +54,20 @@ operations/trimoperation.cpp
widgets/clicommand.cpp
widgets/luascript.cpp
widgets/toolbar.cpp
widgets/toolbartab.cpp
widgets/toolbartab.cpp
widgets/layers.cpp
widgets/layermodel.cpp
lua/qtbridge.cpp
lua/luaqobject.cpp)
lua/luaqobject.cpp
dialogs/addlayerdialog.cpp)
QT5_WRAP_UI(UI_HEADERS
widgets/clicommand.ui
widgets/luascript.ui
widgets/toolbar.ui
widgets/toolbartab.ui)
widgets/toolbartab.ui
widgets/layers.ui
dialogs/addlayerdialog.ui)
qt5_add_resources(UI_RESOURCES
ui/resource.qrc)
@@ -0,0 +1,54 @@
#include "addlayerdialog.h"
#include "ui_addlayerdialog.h"
AddLayerDialog::AddLayerDialog(QWidget* parent) :
QDialog(parent),
ui(new Ui::AddLayerDialog){
ui->setupUi(this);
}
AddLayerDialog::~AddLayerDialog() {
delete ui;
}
void AddLayerDialog::accept() {
if(ui->name->text().isEmpty()) {
QToolTip::showText(ui->name->mapToGlobal(QPoint()), tr("Name cannot be empty."));
return;
}
auto layer = std::make_shared<const lc::Layer>(
ui->name->text().toStdString(),
lc::MetaLineWidthByValue(ui->width->value()),
lc::Color(ui->r->value(),
ui->g->value(),
ui->b->value(),
ui->a->value()
)
);
emit newLayer(layer);
this->close();
}
void AddLayerDialog::on_pickColorButton_clicked() {
QColor currentColor(ui->r->value(),
ui->g->value(),
ui->b->value(),
ui->a->value());
auto colorDialog = new QColorDialog();
colorDialog->setCurrentColor(currentColor);
colorDialog->show();
connect(colorDialog, &QColorDialog::colorSelected, this, &AddLayerDialog::on_colorChanged);
}
void AddLayerDialog::on_colorChanged(const QColor& color) {
ui->r->setValue(color.red());
ui->g->setValue(color.green());
ui->b->setValue(color.blue());
ui->a->setValue(color.alpha());
}
@@ -0,0 +1,31 @@
#pragma once
#include <QDialog>
#include <QColorDialog>
#include <QToolTip>
#include <cad/meta/layer.h>
#include <cad/meta/metalinewidth.h>
namespace Ui {
class AddLayerDialog;
}
class AddLayerDialog : public QDialog {
Q_OBJECT
public:
AddLayerDialog(QWidget* parent = 0);
~AddLayerDialog();
signals:
void newLayer(lc::Layer_CSPtr);
private slots:
void accept();
void on_pickColorButton_clicked();
void on_colorChanged(const QColor& color);
private:
Ui::AddLayerDialog* ui;
};
@@ -0,0 +1,174 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AddLayerDialog</class>
<widget class="QDialog" name="AddLayerDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>514</width>
<height>178</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="nameLabel">
<property name="text">
<string>Name:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="name"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="colorLabel">
<property name="text">
<string>Color:</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="widthLabel">
<property name="text">
<string>Width:</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="linePatternLabel">
<property name="text">
<string>Line pattern:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="colorLayout">
<item>
<widget class="QSpinBox" name="r">
<property name="frame">
<bool>true</bool>
</property>
<property name="prefix">
<string>R: </string>
</property>
<property name="maximum">
<number>255</number>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="g">
<property name="prefix">
<string>G: </string>
</property>
<property name="maximum">
<number>255</number>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="b">
<property name="prefix">
<string>B: </string>
</property>
<property name="maximum">
<number>255</number>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="a">
<property name="frame">
<bool>true</bool>
</property>
<property name="prefix">
<string>A: </string>
</property>
<property name="maximum">
<number>255</number>
</property>
<property name="value">
<number>255</number>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pickColorButton">
<property name="text">
<string>Pick color</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="width">
<property name="wrapping">
<bool>false</bool>
</property>
<property name="frame">
<bool>true</bool>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="maximum">
<double>100.000000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>AddLayerDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>AddLayerDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
View
@@ -250,9 +250,18 @@ void addLCBindings(lua_State *L) {
.addFunction("addEntity", &LCViewer::TempEntities::addEntity)
.addFunction("removeEntity", &LCViewer::TempEntities::removeEntity)
.endClass()
.beginExtendClass<Layers, QDockWidget>("Layers")
.addFactory([](QMdiArea* mdiArea) {
return new Layers(mdiArea);
})
.addFunction("activeLayer", &Layers::activeLayer)
.endClass()
.endModule();
}
void addQtMetaTypes() {
qRegisterMetaType<lc::geo::Coordinate>();
}
View
@@ -29,6 +29,7 @@ extern "C"
#include "widgets/clicommand.h"
#include "widgets/toolbar.h"
#include "widgets/toolbartab.h"
#include "widgets/layers.h"
#include <drawables/tempentities.h>
Oops, something went wrong.

0 comments on commit bb8205b

Please sign in to comment.