asioita

Thu, 05 Nov 2020 14:29:58 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Thu, 05 Nov 2020 14:29:58 +0200
changeset 95
06a1aef170aa
parent 94
164f53fb5921
child 96
165777a20dc7

asioita

src/widgets/colorselectdialog.h file | annotate | diff | comparison | revisions
src/widgets/colorselectdialog.ui file | annotate | diff | comparison | revisions
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/widgets/colorselectdialog.h	Thu Nov 05 14:29:58 2020 +0200
@@ -0,0 +1,30 @@
+#pragma once
+#include "../main.h"
+#include "../colors.h"
+#include <QPushButton>
+#include <QAbstractTableModel>
+#include <QDialog>
+#include <QGridLayout>
+
+class ColorSelectDialog : public QDialog
+{
+	Q_OBJECT
+public:
+	explicit ColorSelectDialog(const ldraw::ColorTable& colorTable, QWidget* parent = nullptr);
+	~ColorSelectDialog();
+	void setCurrentColor(ldraw::Color color);
+	ldraw::Color currentColor() const;
+private slots:
+	void populateColors();
+	void updateSelectedColorTexts();
+	void handleButtonClick();
+	void spinboxEdited();
+	void chooseDirectColor();
+private:
+	void makeColorButtons();
+	bool filterColor(ldraw::Color color) const;
+	class Ui_ColorSelectDialog& ui;
+	const ldraw::ColorTable& colorTable;
+	std::vector<QPushButton*> buttons;
+	ldraw::Color selectedColor = ldraw::mainColor;
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/widgets/colorselectdialog.ui	Thu Nov 05 14:29:58 2020 +0200
@@ -0,0 +1,131 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ColorSelectDialog</class>
+ <widget class="QWidget" name="ColorSelectDialog">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>750</width>
+    <height>500</height>
+   </rect>
+  </property>
+  <property name="minimumSize">
+   <size>
+    <width>750</width>
+    <height>500</height>
+   </size>
+  </property>
+  <property name="windowTitle">
+   <string>Choose colour</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout" stretch="1,0,0,0,0">
+   <item>
+    <widget class="QScrollArea" name="scrollArea">
+     <property name="horizontalScrollBarPolicy">
+      <enum>Qt::ScrollBarAlwaysOff</enum>
+     </property>
+     <property name="widgetResizable">
+      <bool>true</bool>
+     </property>
+     <widget class="QWidget" name="widget">
+      <property name="geometry">
+       <rect>
+        <x>0</x>
+        <y>0</y>
+        <width>732</width>
+        <height>329</height>
+       </rect>
+      </property>
+      <layout class="QGridLayout" name="gridLayout">
+       <item row="1" column="0">
+        <spacer name="verticalSpacer">
+         <property name="orientation">
+          <enum>Qt::Vertical</enum>
+         </property>
+         <property name="sizeHint" stdset="0">
+          <size>
+           <width>20</width>
+           <height>40</height>
+          </size>
+         </property>
+        </spacer>
+       </item>
+       <item row="0" column="0">
+        <widget class="QWidget" name="colorFrame" native="true"/>
+       </item>
+      </layout>
+     </widget>
+    </widget>
+   </item>
+   <item>
+    <widget class="QLineEdit" name="filter">
+     <property name="placeholderText">
+      <string>Search...</string>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="QLabel" name="selectedColorName">
+     <property name="text">
+      <string>TextLabel</string>
+     </property>
+     <property name="alignment">
+      <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_2">
+     <item>
+      <spacer name="horizontalSpacer">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <layout class="QFormLayout" name="formLayout">
+       <item row="0" column="0">
+        <widget class="QLabel" name="label">
+         <property name="text">
+          <string>Colour index:</string>
+         </property>
+        </widget>
+       </item>
+       <item row="0" column="1">
+        <widget class="QSpinBox" name="colorIndex">
+         <property name="maximum">
+          <number>2147483647</number>
+         </property>
+        </widget>
+       </item>
+       <item row="1" column="1">
+        <widget class="QPushButton" name="directColorButton">
+         <property name="text">
+          <string>Direct colour...</string>
+         </property>
+        </widget>
+       </item>
+      </layout>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <widget class="QDialogButtonBox" name="buttonBox">
+     <property name="standardButtons">
+      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

mercurial