summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rw-r--r--utils/themeeditor/gui/devicestate.cpp182
-rw-r--r--utils/themeeditor/gui/devicestate.h25
-rw-r--r--utils/themeeditor/gui/devicestate.ui130
-rw-r--r--utils/themeeditor/gui/editorwindow.cpp4
-rw-r--r--utils/themeeditor/gui/editorwindow.ui5
-rw-r--r--utils/themeeditor/gui/preferencesdialog.ui8
-rw-r--r--utils/themeeditor/resources.qrc3
-rw-r--r--utils/themeeditor/resources/deviceoptions39
-rw-r--r--utils/themeeditor/themeeditor.pro6
9 files changed, 257 insertions, 145 deletions
diff --git a/utils/themeeditor/gui/devicestate.cpp b/utils/themeeditor/gui/devicestate.cpp
index af0b846372..fb35e77b36 100644
--- a/utils/themeeditor/gui/devicestate.cpp
+++ b/utils/themeeditor/gui/devicestate.cpp
@@ -22,14 +22,188 @@
#include "devicestate.h"
#include "ui_devicestate.h"
+#include <QScrollArea>
+#include <QFile>
+#include <QCheckBox>
+#include <QSpinBox>
+#include <QComboBox>
+
DeviceState::DeviceState(QWidget *parent) :
- QWidget(parent),
- ui(new Ui::DeviceState)
+ QWidget(parent), tabs(this)
{
- ui->setupUi(this);
+ /* UI stuff */
+ resize(500,400);
+ setWindowIcon(QIcon(":/resources/windowicon.png"));
+ setWindowTitle(tr("Device Settings"));
+
+ QVBoxLayout* layout = new QVBoxLayout(this);
+ layout->addWidget(&tabs);
+ this->setLayout(layout);
+
+ /* Loading the tabs */
+ QScrollArea* currentArea;
+ QHBoxLayout* subLayout;
+ QWidget* panel;
+ QWidget* temp;
+
+ QFile fin(":/resources/deviceoptions");
+ fin.open(QFile::Text | QFile::ReadOnly);
+ while(!fin.atEnd())
+ {
+ QString line = QString(fin.readLine());
+ line = line.trimmed();
+
+ /* Continue on a comment or an empty line */
+ if(line[0] == '#' || line.length() == 0)
+ continue;
+
+ if(line[0] == '[')
+ {
+ QString buffer;
+ for(int i = 1; line[i] != ']'; i++)
+ buffer.append(line[i]);
+ buffer = buffer.trimmed();
+
+ panel = new QWidget();
+ currentArea = new QScrollArea();
+ layout = new QVBoxLayout(panel);
+ currentArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
+ currentArea->setWidget(panel);
+ currentArea->setWidgetResizable(true);
+
+ tabs.addTab(currentArea, buffer);
+
+ continue;
+ }
+
+ QStringList elements = line.split(";");
+ QString tag = elements[0].trimmed();
+ QString title = elements[1].trimmed();
+ QString type = elements[2].trimmed();
+ QString defVal = elements[3].trimmed();
+
+ subLayout = new QHBoxLayout();
+ if(type != "check")
+ subLayout->addWidget(new QLabel(elements[1].trimmed(), currentArea));
+ layout->addLayout(subLayout);
+
+
+ elements = type.split("(");
+ if(elements[0].trimmed() == "text")
+ {
+ temp = new QLineEdit(defVal, currentArea);
+ subLayout->addWidget(temp);
+ inputs.insert(tag, QPair<InputType, QWidget*>(Text, temp));
+ }
+ else if(elements[0].trimmed() == "check")
+ {
+ temp = new QCheckBox(title, currentArea);
+ subLayout->addWidget(temp);
+ if(defVal.toLower() == "true")
+ dynamic_cast<QCheckBox*>(temp)->setChecked(true);
+ else
+ dynamic_cast<QCheckBox*>(temp)->setChecked(false);
+ inputs.insert(tag, QPair<InputType, QWidget*>(Check, temp));
+ }
+ else if(elements[0].trimmed() == "slider")
+ {
+ elements = elements[1].trimmed().split(",");
+ int min = elements[0].trimmed().toInt();
+ QString maxS = elements[1].trimmed();
+ maxS.chop(1);
+ int max = maxS.toInt();
+
+ temp = new QSlider(Qt::Horizontal, currentArea);
+ dynamic_cast<QSlider*>(temp)->setMinimum(min);
+ dynamic_cast<QSlider*>(temp)->setMaximum(max);
+ dynamic_cast<QSlider*>(temp)->setValue(defVal.toInt());
+ subLayout->addWidget(temp);
+ inputs.insert(tag, QPair<InputType, QWidget*>(Slide, temp));
+ }
+ else if(elements[0].trimmed() == "spin")
+ {
+ elements = elements[1].trimmed().split(",");
+ int min = elements[0].trimmed().toInt();
+ QString maxS = elements[1].trimmed();
+ maxS.chop(1);
+ int max = maxS.toInt();
+
+ temp = new QSpinBox(currentArea);
+ dynamic_cast<QSpinBox*>(temp)->setMinimum(min);
+ dynamic_cast<QSpinBox*>(temp)->setMaximum(max);
+ dynamic_cast<QSpinBox*>(temp)->setValue(defVal.toInt());
+ subLayout->addWidget(temp);
+ inputs.insert(tag, QPair<InputType, QWidget*>(Spin, temp));
+ }
+ else if(elements[0].trimmed() == "fspin")
+ {
+ elements = elements[1].trimmed().split(",");
+ int min = elements[0].trimmed().toDouble();
+ QString maxS = elements[1].trimmed();
+ maxS.chop(1);
+ int max = maxS.toDouble();
+
+ temp = new QDoubleSpinBox(currentArea);
+ dynamic_cast<QDoubleSpinBox*>(temp)->setMinimum(min);
+ dynamic_cast<QDoubleSpinBox*>(temp)->setMaximum(max);
+ dynamic_cast<QDoubleSpinBox*>(temp)->setValue(defVal.toDouble());
+ dynamic_cast<QDoubleSpinBox*>(temp)->setSingleStep(0.1);
+ subLayout->addWidget(temp);
+ inputs.insert(tag, QPair<InputType, QWidget*>(DSpin, temp));
+ }
+ else if(elements[0].trimmed() == "combo")
+ {
+ elements = elements[1].trimmed().split(",");
+
+ int defIndex;
+ temp = new QComboBox(currentArea);
+ for(int i = 0; i < elements.count(); i++)
+ {
+ QString current = elements[i].trimmed();
+ if(i == elements.count() - 1)
+ current.chop(1);
+ dynamic_cast<QComboBox*>(temp)->addItem(current, i);
+ if(current == defVal)
+ defIndex = i;
+ }
+ dynamic_cast<QComboBox*>(temp)->setCurrentIndex(defIndex);
+ subLayout->addWidget(temp);
+ inputs.insert(tag, QPair<InputType, QWidget*>(Combo, temp));
+ }
+
+ }
}
DeviceState::~DeviceState()
{
- delete ui;
+}
+
+QVariant DeviceState::data(QString tag)
+{
+ QPair<InputType, QWidget*> found =
+ inputs.value(tag, QPair<InputType, QWidget*>(Slide, 0));
+
+ if(found.second == 0)
+ return QVariant();
+
+ switch(found.first)
+ {
+ case Text:
+ return dynamic_cast<QLineEdit*>(found.second)->text();
+
+ case Slide:
+ return dynamic_cast<QSlider*>(found.second)->value();
+
+ case Spin:
+ return dynamic_cast<QSpinBox*>(found.second)->value();
+
+ case DSpin:
+ return dynamic_cast<QDoubleSpinBox*>(found.second)->value();
+
+ case Combo:
+ return dynamic_cast<QComboBox*>(found.second)->currentIndex();
+
+ case Check:
+ return dynamic_cast<QCheckBox*>(found.second)->isChecked();
+ }
}
diff --git a/utils/themeeditor/gui/devicestate.h b/utils/themeeditor/gui/devicestate.h
index 66cd98be78..8938e01f29 100644
--- a/utils/themeeditor/gui/devicestate.h
+++ b/utils/themeeditor/gui/devicestate.h
@@ -23,19 +23,34 @@
#define DEVICESTATE_H
#include <QWidget>
-
-namespace Ui {
- class DeviceState;
-}
+#include <QMap>
+#include <QPair>
+#include <QVariant>
+#include <QTabWidget>
class DeviceState : public QWidget {
+
Q_OBJECT
+
public:
+ enum InputType
+ {
+ Text,
+ Slide,
+ Spin,
+ DSpin,
+ Combo,
+ Check
+ };
+
DeviceState(QWidget *parent = 0);
virtual ~DeviceState();
+ QVariant data(QString tag);
+
private:
- Ui::DeviceState *ui;
+ QMap<QString, QPair<InputType, QWidget*> > inputs;
+ QTabWidget tabs;
};
#endif // DEVICESTATE_H
diff --git a/utils/themeeditor/gui/devicestate.ui b/utils/themeeditor/gui/devicestate.ui
deleted file mode 100644
index 17f6129c9e..0000000000
--- a/utils/themeeditor/gui/devicestate.ui
+++ /dev/null
@@ -1,130 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>DeviceState</class>
- <widget class="QWidget" name="DeviceState">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>400</width>
- <height>300</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Device Settings</string>
- </property>
- <property name="windowIcon">
- <iconset resource="../resources.qrc">
- <normaloff>:/resources/resources/windowicon.png</normaloff>:/resources/resources/windowicon.png</iconset>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="QToolBox" name="toolBox">
- <property name="currentIndex">
- <number>1</number>
- </property>
- <widget class="QWidget" name="page">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>382</width>
- <height>220</height>
- </rect>
- </property>
- <attribute name="label">
- <string>Device Basics</string>
- </attribute>
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Screen Width</string>
- </property>
- <property name="buddy">
- <cstring>widthBox</cstring>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="widthBox"/>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_2">
- <item>
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Screen Height</string>
- </property>
- <property name="buddy">
- <cstring>heightBox</cstring>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="heightBox"/>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_3">
- <item>
- <widget class="QLabel" name="label_3">
- <property name="text">
- <string>Remote Width</string>
- </property>
- <property name="buddy">
- <cstring>rWidthBox</cstring>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="rWidthBox"/>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_4">
- <item>
- <widget class="QLabel" name="label_4">
- <property name="text">
- <string>Remote Height</string>
- </property>
- <property name="buddy">
- <cstring>rHeightBox</cstring>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="rHeightBox"/>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- <widget class="QWidget" name="page_2">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>382</width>
- <height>220</height>
- </rect>
- </property>
- <attribute name="label">
- <string>Device Status</string>
- </attribute>
- </widget>
- </widget>
- </item>
- </layout>
- </widget>
- <resources>
- <include location="../resources.qrc"/>
- </resources>
- <connections/>
-</ui>
diff --git a/utils/themeeditor/gui/editorwindow.cpp b/utils/themeeditor/gui/editorwindow.cpp
index 2bd3b5343e..1aec46a7cc 100644
--- a/utils/themeeditor/gui/editorwindow.cpp
+++ b/utils/themeeditor/gui/editorwindow.cpp
@@ -144,6 +144,10 @@ void EditorWindow::setupUI()
viewer = new SkinViewer(this);
ui->skinPreviewLayout->addWidget(viewer);
+ /* Positioning the device settings dialog */
+ QPoint thisPos = pos();
+ deviceConfig.move(thisPos.x() + width() / 4, thisPos.y() + height() / 4);
+
}
void EditorWindow::setupMenus()
diff --git a/utils/themeeditor/gui/editorwindow.ui b/utils/themeeditor/gui/editorwindow.ui
index a7d804bd6b..2f84d384c8 100644
--- a/utils/themeeditor/gui/editorwindow.ui
+++ b/utils/themeeditor/gui/editorwindow.ui
@@ -15,7 +15,7 @@
</property>
<property name="windowIcon">
<iconset resource="../resources.qrc">
- <normaloff>:/resources/resources/windowicon.png</normaloff>:/resources/resources/windowicon.png</iconset>
+ <normaloff>:/resources/windowicon.png</normaloff>:/resources/windowicon.png</iconset>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout">
@@ -299,6 +299,9 @@
<property name="text">
<string>&amp;Device Configuration</string>
</property>
+ <property name="shortcut">
+ <string>Ctrl+D</string>
+ </property>
</action>
</widget>
<tabstops>
diff --git a/utils/themeeditor/gui/preferencesdialog.ui b/utils/themeeditor/gui/preferencesdialog.ui
index 1da7811b62..7dddcf9057 100644
--- a/utils/themeeditor/gui/preferencesdialog.ui
+++ b/utils/themeeditor/gui/preferencesdialog.ui
@@ -13,6 +13,10 @@
<property name="windowTitle">
<string>Preferences</string>
</property>
+ <property name="windowIcon">
+ <iconset resource="../resources.qrc">
+ <normaloff>:/resources/windowicon.png</normaloff>:/resources/windowicon.png</iconset>
+ </property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTabWidget" name="prefsGroups">
@@ -268,7 +272,9 @@
</item>
</layout>
</widget>
- <resources/>
+ <resources>
+ <include location="../resources.qrc"/>
+ </resources>
<connections>
<connection>
<sender>buttonBox</sender>
diff --git a/utils/themeeditor/resources.qrc b/utils/themeeditor/resources.qrc
index 6815ccf8ea..27d808c240 100644
--- a/utils/themeeditor/resources.qrc
+++ b/utils/themeeditor/resources.qrc
@@ -1,10 +1,11 @@
<RCC>
<qresource prefix="/resources">
- <file>resources/windowicon.png</file>
+ <file alias="windowicon.png">resources/windowicon.png</file>
<file>resources/document-new.png</file>
<file>resources/document-open.png</file>
<file>resources/document-save.png</file>
<file alias="configkeys">resources/configkeys</file>
+ <file alias="deviceoptions">resources/deviceoptions</file>
</qresource>
<qresource prefix="/render">
<file alias="scenebg.png">resources/render/scenebg.png</file>
diff --git a/utils/themeeditor/resources/deviceoptions b/utils/themeeditor/resources/deviceoptions
new file mode 100644
index 0000000000..cd306f50db
--- /dev/null
+++ b/utils/themeeditor/resources/deviceoptions
@@ -0,0 +1,39 @@
+# This file defines the options for the device configuration panel
+# Declare a section with a line containing a string inside brackets, i.e.
+# [Some Section]
+# Declare options within the section in the following format, one per line
+# tag;Tag Label;[input];default
+# tag is the skin tag represented by that option
+#
+# Tag Label is a human-readable label to attach to the input
+#
+# [input] is the type of widget that should be used for the tag, and its range
+# if applicable. The valid forms are
+# check - Inserts a true/false checkbox
+# text - Inserts a line edit box
+# slider(min, max) - Inserts a horizontal slider with range specified
+# spin(min, max) - Inserts a spin box with range specified
+# fspin(min, max) - Inserts a floating point spin box with range specified
+# combo(option1, option2...) - Inserts a combo box with the options specified
+#
+# default is the default value for the input
+#
+# Note that there aren't any provisions for escaping characters at the moment,
+# so don't include [, ], or ; in your text, or (, ) in combo box choices
+#
+# Blank lines are ignored
+#
+# Be warned: because this file is compiled into the application, I'm not
+# performing much of any error checking on it: screwing up the syntax may very
+# well segfault the application on startup
+
+[Test Section 1]
+a ; Text Input ; text ; Some text
+b ; Checkbox ; check ; false
+c ; Slider 1 - 5 ; slider(1, 5) ; 4
+
+[Test Section 2]
+d ; Spinbox 6 - 10 ; spin(6, 10) ; 8
+e ; Float Spinbox 2.5 - 6.3; fspin(2.5, 6.3) ; 3.9
+# A combo box ends up returning an integer from 0 to n - 1, with n choices
+f ; Combo Box; combo(An option, Another Option, A Third option) ; Another Option
diff --git a/utils/themeeditor/themeeditor.pro b/utils/themeeditor/themeeditor.pro
index 6237ee8f70..50cafe054d 100644
--- a/utils/themeeditor/themeeditor.pro
+++ b/utils/themeeditor/themeeditor.pro
@@ -64,10 +64,10 @@ OTHER_FILES += README \
resources/COPYING \
resources/document-save.png \
resources/document-open.png \
- resources/document-new.png
+ resources/document-new.png \
+ resources/deviceoptions
FORMS += gui/editorwindow.ui \
gui/preferencesdialog.ui \
gui/configdocument.ui \
- gui/skinviewer.ui \
- gui/devicestate.ui
+ gui/skinviewer.ui
RESOURCES += resources.qrc