Permalink
Browse files

Color select

  • Loading branch information...
feragon committed Aug 9, 2016
1 parent f60aea1 commit 53541f026388d36c8d11f1b21a68646ee36642be
View
@@ -43,6 +43,7 @@ widgets/linepatternpainter.h
widgets/linepatternpathpart.h
widgets/linepatternmodel.h
widgets/linewidthselect.h
widgets/colorselect.h
lua/qtbridge.h
lua/luaqobject.h
dialogs/addlayerdialog.h
@@ -69,6 +70,7 @@ widgets/linepatternpainter.cpp
widgets/linepatternpathpart.cpp
widgets/linepatternmodel.cpp
widgets/linewidthselect.cpp
widgets/colorselect.cpp
lua/qtbridge.cpp
lua/luaqobject.cpp
dialogs/addlayerdialog.cpp
View
@@ -290,6 +290,13 @@ void addLCBindings(lua_State *L) {
.addFunction("lineWidth", &LineWidthSelect::lineWidth)
.endClass()
.beginExtendClass<ColorSelect, QComboBox>("ColorSelect")
.addFactory([](QWidget* parent, bool showByLayer, bool showByBlock){
return new ColorSelect(parent, showByLayer, showByBlock);
})
.addFunction("color", &ColorSelect::color)
.endClass()
.endModule();
}
View
@@ -33,6 +33,7 @@ extern "C"
#include "dialogs/linepatternmanager.h"
#include <drawables/tempentities.h>
#include "widgets/linewidthselect.h"
#include "widgets/colorselect.h"
Q_DECLARE_METATYPE(lc::geo::Coordinate);
@@ -0,0 +1,33 @@
#include "colorselect.h"
ColorSelect::ColorSelect(QWidget *parent, bool showByLayer, bool showByBlock) :
QComboBox(parent) {
qIconSize = QSize(32, 32);
setIconSize(qIconSize);
setMaximumHeight(32);
if(showByLayer) {
addItem(BY_LAYER);
}
if(showByBlock) {
addItem(BY_BLOCK);
}
for(auto color : QColor::colorNames()){
QPixmap pixmap(qIconSize);
pixmap.fill(color);
addItem(QIcon(pixmap), color);
}
}
lc::MetaColor_CSPtr ColorSelect::color() {
QColor color(currentText());
if(!color.isValid()) {
return nullptr;
}
return std::make_shared<lc::MetaColor>(color.redF(), color.greenF(), color.blueF(), color.alphaF());
}
View
@@ -0,0 +1,19 @@
#pragma once
#include <QComboBox>
#include <QString>
#include <QColor>
#include <cad/meta/metacolor.h>
#define BY_BLOCK "ByBlock"
#define BY_LAYER "ByLayer"
class ColorSelect : public QComboBox {
public:
ColorSelect(QWidget* parent = 0, bool showByLayer = false, bool showByBlock = false);
lc::MetaColor_CSPtr color();
private:
QSize qIconSize;
};
@@ -8,6 +8,8 @@ LinePatternSelect::LinePatternSelect(lc::Document_SPtr document, QWidget *parent
qIconSize = QSize(128, 32);
setIconSize(qIconSize);
setMaximumHeight(32);
setDocument(document);
connect(this, SIGNAL(activated(const QString&)), this, SLOT(onActivated(const QString&)));
@@ -6,6 +6,8 @@ LineWidthSelect::LineWidthSelect(QWidget* parent, bool showByLayer, bool showByB
qIconSize = QSize(128, 32);
setIconSize(qIconSize);
setMaximumHeight(32);
if(showByLayer) {
addItem(BY_LAYER);
}
@@ -48,6 +48,11 @@ function active_metaInfo()
metaInfo:add(lineWidth)
end
local color = colorSelect:color()
if(color ~= nil) then
metaInfo:add(color)
end
return metaInfo
end
@@ -113,6 +118,7 @@ function create_main_window()
linePatternSelect = lc.LinePatternSelect(mainWindow)
lineWidthSelect = lc.LineWidthSelect(mainWindow, true, true)
colorSelect = lc.ColorSelect(mainWindow, true, true)
add_toolbar()
View
@@ -128,5 +128,6 @@ function add_toolbar()
quickAccess:addWidget(metaInfoGroup, linePatternSelect, 0, 0, 1, 1)
quickAccess:addWidget(metaInfoGroup, lineWidthSelect, 0, 1, 1, 1)
quickAccess:addWidget(metaInfoGroup, colorSelect, 0, 2, 1, 1)
end

0 comments on commit 53541f0

Please sign in to comment.