summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAleks Kissinger <aleks0@gmail.com>2018-08-02 17:44:37 +0200
committerAleks Kissinger <aleks0@gmail.com>2018-08-02 17:44:37 +0200
commit31a78ae551b781eccc47546a2f6d4bf121af24cf (patch)
treeb997a471d484f9b096878919fcd38b074dc7a59a /src/gui
parentf978634e8607f568b83952db9255e08f3f7cbe92 (diff)
started style editor
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/mainwindow.ui6
-rw-r--r--src/gui/styleeditor.cpp230
-rw-r--r--src/gui/styleeditor.h41
-rw-r--r--src/gui/styleeditor.ui752
-rw-r--r--src/gui/stylepalette.cpp33
-rw-r--r--src/gui/stylepalette.h1
-rw-r--r--src/gui/stylepalette.ui18
7 files changed, 1052 insertions, 29 deletions
diff --git a/src/gui/mainwindow.ui b/src/gui/mainwindow.ui
index 137d6cf..cae5735 100644
--- a/src/gui/mainwindow.ui
+++ b/src/gui/mainwindow.ui
@@ -10,6 +10,12 @@
<height>580</height>
</rect>
</property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="windowTitle">
<string>TikZiT - untitled</string>
</property>
diff --git a/src/gui/styleeditor.cpp b/src/gui/styleeditor.cpp
new file mode 100644
index 0000000..fae5e1a
--- /dev/null
+++ b/src/gui/styleeditor.cpp
@@ -0,0 +1,230 @@
+#include <QColorDialog>
+#include <QDebug>
+
+#include "tikzit.h"
+#include "styleeditor.h"
+#include "ui_styleeditor.h"
+
+StyleEditor::StyleEditor(QWidget *parent) :
+ QMainWindow(parent),
+ ui(new Ui::StyleEditor)
+{
+ ui->setupUi(this);
+
+ setColor(ui->fillColor, QColor(Qt::white));
+ setColor(ui->drawColor, QColor(Qt::black));
+ setColor(ui->tikzitFillColor, QColor(Qt::white));
+ setColor(ui->tikzitDrawColor, QColor(Qt::black));
+
+ TikzStyles *styles = tikzit->styles();
+
+ _nodeModel = new QStandardItemModel(this);
+ _edgeModel = new QStandardItemModel(this);
+
+ ui->styleListView->setModel(_nodeModel);
+ ui->styleListView->setViewMode(QListView::IconMode);
+ ui->styleListView->setMovement(QListView::Static);
+ ui->styleListView->setGridSize(QSize(48,48));
+
+
+ ui->edgeStyleListView->setModel(_edgeModel);
+ ui->edgeStyleListView->setViewMode(QListView::IconMode);
+ ui->edgeStyleListView->setMovement(QListView::Static);
+ ui->edgeStyleListView->setGridSize(QSize(48,48));
+
+ // setup the color dialog to display only the named colors that tikzit/xcolor knows
+ // about as "standard colors".
+ for (int i = 0; i < 48; ++i) {
+ QColorDialog::setStandardColor(i, QColor(Qt::white));
+ }
+
+ // grayscale in column 1
+ int pos = 0;
+ for (int i=0; i < 5; ++i) {
+ QColorDialog::setStandardColor(pos, styles->colorByIndex(i));
+ pos += 1;
+ }
+
+ // rainbow in column 2
+ pos = 6;
+ for (int i=5; i < 11; ++i) {
+ QColorDialog::setStandardColor(pos, styles->colorByIndex(i));
+ pos += 1;
+ }
+
+ // brown/green/teal spectrum in column 3
+ pos = 12;
+ for (int i=11; i < 16; ++i) {
+ QColorDialog::setStandardColor(pos, styles->colorByIndex(i));
+ pos += 1;
+ }
+
+ // pinks in column 4
+ pos = 18;
+ for (int i=16; i < 19; ++i) {
+ QColorDialog::setStandardColor(pos, styles->colorByIndex(i));
+ pos += 1;
+ }
+
+ _activeNodeStyle = 0;
+ _activeEdgeStyle = 0;
+ updateFields();
+}
+
+StyleEditor::~StyleEditor()
+{
+ delete ui;
+}
+
+void StyleEditor::showEvent(QShowEvent *)
+{
+ tikzit->styles()->refreshModels(_nodeModel, _edgeModel);
+}
+
+void StyleEditor::updateFields()
+{
+ ui->name->setEnabled(false);
+ ui->category->setEnabled(false);
+ ui->fillColor->setEnabled(false);
+ ui->drawColor->setEnabled(false);
+ ui->tikzitFillColor->setEnabled(false);
+ ui->tikzitDrawColor->setEnabled(false);
+ ui->hasTikzitFillColor->setEnabled(false);
+ ui->hasTikzitDrawColor->setEnabled(false);
+ ui->shape->setEnabled(false);
+ ui->hasTikzitShape->setEnabled(false);
+ ui->tikzitShape->setEnabled(false);
+ ui->leftArrow->setEnabled(false);
+ ui->rightArrow->setEnabled(false);
+ ui->properties->setEnabled(false);
+
+ if (_activeNodeStyle != 0) {
+ ui->name->setEnabled(true);
+ ui->name->setText(_activeNodeStyle->name());
+
+ ui->category->setEnabled(true);
+ // TODO
+
+ // passing 'false' to these methods prevents 'tikzit foo' from overriding property 'foo'
+ QColor realFill = _activeNodeStyle->fillColor(false);
+ QColor fill = _activeNodeStyle->fillColor();
+ bool fillOverride = realFill != fill;
+ QColor realDraw = _activeNodeStyle->strokeColor(false);
+ QColor draw = _activeNodeStyle->strokeColor();
+ bool drawOverride = realDraw != draw;
+
+ ui->fillColor->setEnabled(true);
+ setColor(ui->fillColor, realFill);
+
+ ui->drawColor->setEnabled(true);
+ setColor(ui->drawColor, realDraw);
+
+
+ ui->hasTikzitFillColor->setEnabled(true);
+ ui->hasTikzitFillColor->setChecked(fillOverride);
+
+ ui->tikzitFillColor->setEnabled(fillOverride);
+ setColor(ui->tikzitFillColor, fill);
+
+ ui->hasTikzitDrawColor->setEnabled(true);
+ ui->hasTikzitDrawColor->setChecked(drawOverride);
+
+ ui->tikzitDrawColor->setEnabled(drawOverride);
+ setColor(ui->tikzitDrawColor, draw);
+
+ // TODO
+ ui->shape->setEnabled(true);
+ ui->hasTikzitShape->setEnabled(true);
+ ui->tikzitShape->setEnabled(true);
+ ui->properties->setEnabled(true);
+ } else if (_activeEdgeStyle != 0) {
+ ui->name->setEnabled(true);
+ ui->name->setText(_activeEdgeStyle->name());
+
+ ui->category->setEnabled(true);
+ // TODO
+
+
+ setColor(ui->fillColor, QColor(Qt::gray));
+ setColor(ui->tikzitFillColor, QColor(Qt::gray));
+ ui->hasTikzitFillColor->setChecked(false);
+
+
+ // passing 'false' to these methods prevents 'tikzit foo' from overriding property 'foo'
+ QColor realDraw = _activeEdgeStyle->strokeColor(false);
+ QColor draw = _activeEdgeStyle->strokeColor();
+ bool drawOverride = realDraw != draw;
+
+ ui->drawColor->setEnabled(true);
+ setColor(ui->drawColor, realDraw);
+
+ ui->hasTikzitDrawColor->setEnabled(true);
+ ui->hasTikzitDrawColor->setChecked(drawOverride);
+
+ ui->tikzitDrawColor->setEnabled(drawOverride);
+ setColor(ui->tikzitDrawColor, draw);
+
+ // TODO
+ ui->leftArrow->setEnabled(true);
+ ui->rightArrow->setEnabled(true);
+ ui->properties->setEnabled(true);
+ } else {
+ setColor(ui->fillColor, QColor(Qt::gray));
+ setColor(ui->drawColor, QColor(Qt::gray));
+ setColor(ui->tikzitDrawColor, QColor(Qt::gray));
+ setColor(ui->tikzitFillColor, QColor(Qt::gray));
+ }
+}
+
+
+void StyleEditor::on_fillColor_clicked()
+{
+ QColor col = QColorDialog::getColor(
+ color(ui->fillColor),
+ this,
+ "Fill Color",
+ QColorDialog::DontUseNativeDialog);
+ if (col.isValid()) setColor(ui->fillColor, col);
+}
+
+void StyleEditor::on_styleListView_clicked()
+{
+ _activeNodeStyle = 0;
+ _activeEdgeStyle = 0;
+ const QModelIndexList i = ui->styleListView->selectionModel()->selectedIndexes();
+ QString sty;
+ if (!i.isEmpty()) {
+ sty = i[0].data().toString();
+ if (sty != "none")
+ _activeNodeStyle = tikzit->styles()->nodeStyle(sty);
+ }
+ updateFields();
+}
+
+void StyleEditor::on_edgeStyleListView_clicked()
+{
+ _activeNodeStyle = 0;
+ _activeEdgeStyle = 0;
+ const QModelIndexList i = ui->edgeStyleListView->selectionModel()->selectedIndexes();
+ QString sty;
+ if (!i.isEmpty()) {
+ sty = i[0].data().toString();
+ if (sty != "none")
+ _activeEdgeStyle = tikzit->styles()->edgeStyle(sty);
+ }
+ updateFields();
+}
+
+void StyleEditor::setColor(QPushButton *btn, QColor col)
+{
+ QPalette pal = btn->palette();
+ pal.setColor(QPalette::Button, col);
+ btn->setPalette(pal);
+ btn->update();
+}
+
+QColor StyleEditor::color(QPushButton *btn)
+{
+ QPalette pal = btn->palette();
+ return pal.color(QPalette::Button);
+}
diff --git a/src/gui/styleeditor.h b/src/gui/styleeditor.h
new file mode 100644
index 0000000..3a8dd9d
--- /dev/null
+++ b/src/gui/styleeditor.h
@@ -0,0 +1,41 @@
+#ifndef STYLEEDITOR_H
+#define STYLEEDITOR_H
+
+#include "nodestyle.h"
+#include "edgestyle.h"
+
+#include <QMainWindow>
+#include <QPushButton>
+#include <QStandardItemModel>
+
+namespace Ui {
+class StyleEditor;
+}
+
+class StyleEditor : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ explicit StyleEditor(QWidget *parent = 0);
+ ~StyleEditor();
+
+ void showEvent(QShowEvent *) override;
+ void updateFields();
+
+public slots:
+ void on_fillColor_clicked();
+ void on_styleListView_clicked();
+ void on_edgeStyleListView_clicked();
+
+private:
+ Ui::StyleEditor *ui;
+ void setColor(QPushButton *btn, QColor col);
+ QColor color(QPushButton *btn);
+ QStandardItemModel *_nodeModel;
+ QStandardItemModel *_edgeModel;
+ NodeStyle *_activeNodeStyle;
+ EdgeStyle *_activeEdgeStyle;
+};
+
+#endif // STYLEEDITOR_H
diff --git a/src/gui/styleeditor.ui b/src/gui/styleeditor.ui
new file mode 100644
index 0000000..9888954
--- /dev/null
+++ b/src/gui/styleeditor.ui
@@ -0,0 +1,752 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>StyleEditor</class>
+ <widget class="QMainWindow" name="StyleEditor">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>580</width>
+ <height>519</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>MainWindow</string>
+ </property>
+ <widget class="QWidget" name="centralwidget">
+ <widget class="QComboBox" name="currentCategory">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>10</y>
+ <width>181</width>
+ <height>22</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QLabel" name="labelName">
+ <property name="geometry">
+ <rect>
+ <x>200</x>
+ <y>50</y>
+ <width>61</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>10</pointsize>
+ </font>
+ </property>
+ <property name="text">
+ <string>Name</string>
+ </property>
+ <property name="scaledContents">
+ <bool>false</bool>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ <widget class="QLabel" name="labelCategory">
+ <property name="geometry">
+ <rect>
+ <x>200</x>
+ <y>80</y>
+ <width>61</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>10</pointsize>
+ </font>
+ </property>
+ <property name="text">
+ <string>Category</string>
+ </property>
+ <property name="scaledContents">
+ <bool>false</bool>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ <widget class="QLabel" name="labelFillColor">
+ <property name="geometry">
+ <rect>
+ <x>200</x>
+ <y>110</y>
+ <width>61</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>10</pointsize>
+ </font>
+ </property>
+ <property name="text">
+ <string>Fill Color</string>
+ </property>
+ <property name="scaledContents">
+ <bool>false</bool>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ <widget class="QLabel" name="labelDrawColor">
+ <property name="geometry">
+ <rect>
+ <x>200</x>
+ <y>140</y>
+ <width>61</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>10</pointsize>
+ </font>
+ </property>
+ <property name="text">
+ <string>Draw Color</string>
+ </property>
+ <property name="scaledContents">
+ <bool>false</bool>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ <widget class="QLineEdit" name="name">
+ <property name="geometry">
+ <rect>
+ <x>270</x>
+ <y>50</y>
+ <width>301</width>
+ <height>20</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QComboBox" name="category">
+ <property name="geometry">
+ <rect>
+ <x>270</x>
+ <y>80</y>
+ <width>301</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="fillColor">
+ <property name="geometry">
+ <rect>
+ <x>270</x>
+ <y>110</y>
+ <width>31</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="autoFillBackground">
+ <bool>true</bool>
+ </property>
+ <property name="styleSheet">
+ <string notr="true"/>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="drawColor">
+ <property name="geometry">
+ <rect>
+ <x>270</x>
+ <y>140</y>
+ <width>31</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="autoFillBackground">
+ <bool>true</bool>
+ </property>
+ <property name="styleSheet">
+ <string notr="true"/>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QCheckBox" name="hasTikzitFillColor">
+ <property name="geometry">
+ <rect>
+ <x>380</x>
+ <y>110</y>
+ <width>71</width>
+ <height>17</height>
+ </rect>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>10</pointsize>
+ <italic>false</italic>
+ </font>
+ </property>
+ <property name="text">
+ <string>in TikZiT:</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" name="hasTikzitDrawColor">
+ <property name="geometry">
+ <rect>
+ <x>380</x>
+ <y>140</y>
+ <width>71</width>
+ <height>17</height>
+ </rect>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>10</pointsize>
+ <italic>false</italic>
+ </font>
+ </property>
+ <property name="text">
+ <string>in TikZiT:</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="tikzitFillColor">
+ <property name="geometry">
+ <rect>
+ <x>450</x>
+ <y>110</y>
+ <width>31</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="autoFillBackground">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="tikzitDrawColor">
+ <property name="geometry">
+ <rect>
+ <x>450</x>
+ <y>140</y>
+ <width>31</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="autoFillBackground">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QLabel" name="labelShape">
+ <property name="geometry">
+ <rect>
+ <x>200</x>
+ <y>170</y>
+ <width>61</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>10</pointsize>
+ </font>
+ </property>
+ <property name="text">
+ <string>Shape</string>
+ </property>
+ <property name="scaledContents">
+ <bool>false</bool>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ <widget class="QComboBox" name="shape">
+ <property name="geometry">
+ <rect>
+ <x>270</x>
+ <y>170</y>
+ <width>211</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ <item>
+ <property name="text">
+ <string/>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>circle</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>rectangle</string>
+ </property>
+ </item>
+ </widget>
+ <widget class="QCheckBox" name="hasTikzitShape">
+ <property name="geometry">
+ <rect>
+ <x>280</x>
+ <y>200</y>
+ <width>71</width>
+ <height>17</height>
+ </rect>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>10</pointsize>
+ <italic>false</italic>
+ </font>
+ </property>
+ <property name="text">
+ <string>in TikZiT:</string>
+ </property>
+ </widget>
+ <widget class="QComboBox" name="tikzitShape">
+ <property name="geometry">
+ <rect>
+ <x>350</x>
+ <y>200</y>
+ <width>131</width>
+ <height>22</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QLabel" name="labelArrowhead">
+ <property name="geometry">
+ <rect>
+ <x>200</x>
+ <y>230</y>
+ <width>61</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>10</pointsize>
+ </font>
+ </property>
+ <property name="text">
+ <string>Arrowhead</string>
+ </property>
+ <property name="scaledContents">
+ <bool>false</bool>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ <widget class="QComboBox" name="leftArrow">
+ <property name="geometry">
+ <rect>
+ <x>270</x>
+ <y>230</y>
+ <width>71</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ <item>
+ <property name="text">
+ <string/>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>&lt;</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>&gt;</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>|</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>stealth</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>latex</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>[</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>]</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>(</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>)</string>
+ </property>
+ </item>
+ </widget>
+ <widget class="QLabel" name="labelDash">
+ <property name="geometry">
+ <rect>
+ <x>350</x>
+ <y>230</y>
+ <width>16</width>
+ <height>21</height>
+ </rect>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>16</pointsize>
+ </font>
+ </property>
+ <property name="text">
+ <string>-</string>
+ </property>
+ </widget>
+ <widget class="QComboBox" name="rightArrow">
+ <property name="geometry">
+ <rect>
+ <x>370</x>
+ <y>230</y>
+ <width>71</width>
+ <height>22</height>
+ </rect>
+ </property>
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ <item>
+ <property name="text">
+ <string/>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>&gt;</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>&lt;</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>|</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>stealth</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>latex</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>]</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>[</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>)</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>(</string>
+ </property>
+ </item>
+ </widget>
+ <widget class="QLabel" name="labelProperties">
+ <property name="geometry">
+ <rect>
+ <x>200</x>
+ <y>270</y>
+ <width>61</width>
+ <height>20</height>
+ </rect>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>10</pointsize>
+ </font>
+ </property>
+ <property name="text">
+ <string>Properties</string>
+ </property>
+ <property name="scaledContents">
+ <bool>false</bool>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ <widget class="QTreeWidget" name="properties">
+ <property name="geometry">
+ <rect>
+ <x>270</x>
+ <y>270</y>
+ <width>301</width>
+ <height>211</height>
+ </rect>
+ </property>
+ <column>
+ <property name="text">
+ <string notr="true">Name</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Value</string>
+ </property>
+ </column>
+ </widget>
+ <widget class="QToolButton" name="addProperty">
+ <property name="geometry">
+ <rect>
+ <x>270</x>
+ <y>490</y>
+ <width>23</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>+</string>
+ </property>
+ </widget>
+ <widget class="QToolButton" name="addAtom">
+ <property name="geometry">
+ <rect>
+ <x>300</x>
+ <y>490</y>
+ <width>23</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>+a</string>
+ </property>
+ </widget>
+ <widget class="QToolButton" name="removeProperty">
+ <property name="geometry">
+ <rect>
+ <x>330</x>
+ <y>490</y>
+ <width>23</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>-</string>
+ </property>
+ </widget>
+ <widget class="QToolButton" name="propertyUp">
+ <property name="geometry">
+ <rect>
+ <x>360</x>
+ <y>490</y>
+ <width>23</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>^</string>
+ </property>
+ </widget>
+ <widget class="QToolButton" name="propertyDown">
+ <property name="geometry">
+ <rect>
+ <x>390</x>
+ <y>490</y>
+ <width>23</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>v</string>
+ </property>
+ </widget>
+ <widget class="QListView" name="styleListView">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>40</y>
+ <width>181</width>
+ <height>251</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QListView" name="edgeStyleListView">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>330</y>
+ <width>181</width>
+ <height>151</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QToolButton" name="addStyle">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>300</y>
+ <width>23</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>+</string>
+ </property>
+ </widget>
+ <widget class="QToolButton" name="removeStyle">
+ <property name="geometry">
+ <rect>
+ <x>40</x>
+ <y>300</y>
+ <width>23</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>-</string>
+ </property>
+ </widget>
+ <widget class="QToolButton" name="styleUp">
+ <property name="geometry">
+ <rect>
+ <x>70</x>
+ <y>300</y>
+ <width>23</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>^</string>
+ </property>
+ </widget>
+ <widget class="QToolButton" name="styleDown">
+ <property name="geometry">
+ <rect>
+ <x>100</x>
+ <y>300</y>
+ <width>23</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>v</string>
+ </property>
+ </widget>
+ <widget class="QToolButton" name="removeEdgeStyle">
+ <property name="geometry">
+ <rect>
+ <x>40</x>
+ <y>490</y>
+ <width>23</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>-</string>
+ </property>
+ </widget>
+ <widget class="QToolButton" name="addEdgeStyle">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>490</y>
+ <width>23</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>+</string>
+ </property>
+ </widget>
+ <widget class="QToolButton" name="edgeStyleUp">
+ <property name="geometry">
+ <rect>
+ <x>70</x>
+ <y>490</y>
+ <width>23</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>^</string>
+ </property>
+ </widget>
+ <widget class="QToolButton" name="edgeStyleDown">
+ <property name="geometry">
+ <rect>
+ <x>100</x>
+ <y>490</y>
+ <width>23</width>
+ <height>18</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>v</string>
+ </property>
+ </widget>
+ </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/src/gui/stylepalette.cpp b/src/gui/stylepalette.cpp
index b5e1475..500384b 100644
--- a/src/gui/stylepalette.cpp
+++ b/src/gui/stylepalette.cpp
@@ -67,36 +67,10 @@ StylePalette::~StylePalette()
void StylePalette::reloadStyles()
{
- _nodeModel->clear();
- _edgeModel->clear();
QString f = tikzit->styleFile();
ui->styleFile->setText(f);
- QStandardItem *it;
-
- it = new QStandardItem(noneStyle->icon(), noneStyle->name());
- it->setEditable(false);
- it->setData(noneStyle->name());
- _nodeModel->appendRow(it);
-
- foreach(NodeStyle *ns, tikzit->styles()->nodeStyles()) {
- it = new QStandardItem(ns->icon(), ns->name());
- it->setEditable(false);
- it->setData(ns->name());
- _nodeModel->appendRow(it);
- }
-
- it = new QStandardItem(noneEdgeStyle->icon(), noneEdgeStyle->name());
- it->setEditable(false);
- it->setData(noneEdgeStyle->name());
- _edgeModel->appendRow(it);
-
- foreach(EdgeStyle *es, tikzit->styles()->edgeStyles()) {
- it = new QStandardItem(es->icon(), es->name());
- it->setEditable(false);
- it->setData(es->name());
- _edgeModel->appendRow(it);
- }
+ tikzit->styles()->refreshModels(_nodeModel, _edgeModel);
}
void StylePalette::changeNodeStyle(int increment)
@@ -161,6 +135,11 @@ void StylePalette::on_buttonOpenTikzstyles_clicked()
tikzit->openTikzStyles();
}
+void StylePalette::on_buttonEditTikzstyles_clicked()
+{
+ tikzit->showStyleEditor();
+}
+
void StylePalette::on_buttonRefreshTikzstyles_clicked()
{
QSettings settings("tikzit", "tikzit");
diff --git a/src/gui/stylepalette.h b/src/gui/stylepalette.h
index 45dc8da..3c0c721 100644
--- a/src/gui/stylepalette.h
+++ b/src/gui/stylepalette.h
@@ -44,6 +44,7 @@ public slots:
void nodeStyleDoubleClicked(const QModelIndex &index);
void edgeStyleDoubleClicked(const QModelIndex &index);
void on_buttonOpenTikzstyles_clicked();
+ void on_buttonEditTikzstyles_clicked();
void on_buttonRefreshTikzstyles_clicked();
//void on_buttonApplyNodeStyle_clicked();
diff --git a/src/gui/stylepalette.ui b/src/gui/stylepalette.ui
index 4f5b58d..10b80fb 100644
--- a/src/gui/stylepalette.ui
+++ b/src/gui/stylepalette.ui
@@ -7,11 +7,11 @@
<x>0</x>
<y>0</y>
<width>88</width>
- <height>518</height>
+ <height>506</height>
</rect>
</property>
<property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
+ <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -72,6 +72,20 @@
</widget>
</item>
<item>
+ <widget class="QToolButton" name="buttonEditTikzstyles">
+ <property name="toolTip">
+ <string>New Project</string>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="icon">
+ <iconset resource="../../tikzit.qrc">
+ <normaloff>:/images/document-new.svg</normaloff>:/images/document-new.svg</iconset>
+ </property>
+ </widget>
+ </item>
+ <item>
<widget class="QToolButton" name="buttonRefreshTikzstyles">
<property name="text">
<string/>