Theme Editor: Replaced line edits for key names with combo boxes

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26868 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Robert Bieber 2010-06-16 07:47:03 +00:00
parent da4089d836
commit 0d48448500
4 changed files with 229 additions and 16 deletions

View file

@ -36,9 +36,24 @@ ConfigDocument::ConfigDocument(QMap<QString, QString>& settings, QString file,
{ {
ui->setupUi(this); ui->setupUi(this);
/* Populating the known keys list */
QFile fin(":/resources/configkeys");
fin.open(QFile::ReadOnly);
QStringList* container = &primaryKeys;
while(!fin.atEnd())
{
QString current = QString(fin.readLine());
if(current == "-\n")
container = &secondaryKeys;
else if(current != "\n")
container->append(current.trimmed());
}
QMap<QString, QString>::iterator i; QMap<QString, QString>::iterator i;
for(i = settings.begin(); i != settings.end(); i++) for(i = settings.begin(); i != settings.end(); i++)
addRow(i.key(), i.value()); if(i.key() != "themebase")
addRow(i.key(), i.value());
saved = toPlainText(); saved = toPlainText();
@ -160,7 +175,7 @@ QString ConfigDocument::toPlainText() const
for(int i = 0; i < keys.count(); i++) for(int i = 0; i < keys.count(); i++)
{ {
buffer += keys[i]->text(); buffer += keys[i]->currentText();
buffer += ":"; buffer += ":";
buffer += values[i]->text(); buffer += values[i]->text();
buffer += "\n"; buffer += "\n";
@ -172,11 +187,24 @@ QString ConfigDocument::toPlainText() const
void ConfigDocument::addRow(QString key, QString value) void ConfigDocument::addRow(QString key, QString value)
{ {
QHBoxLayout* layout = new QHBoxLayout(); QHBoxLayout* layout = new QHBoxLayout();
QLineEdit* keyEdit = new QLineEdit(key, this); QComboBox* keyEdit = new QComboBox(this);
QLineEdit* valueEdit = new QLineEdit(value, this); QLineEdit* valueEdit = new QLineEdit(value, this);
QPushButton* delButton = new QPushButton(tr("-"), this); QPushButton* delButton = new QPushButton(tr("-"), this);
QLabel* label = new QLabel(":");
/* Loading the combo box options */
keyEdit->setInsertPolicy(QComboBox::InsertAlphabetically);
keyEdit->setEditable(true);
keyEdit->addItems(primaryKeys);
keyEdit->insertSeparator(keyEdit->count());
keyEdit->addItems(secondaryKeys);
if(keyEdit->findText(key) != -1)
keyEdit->setCurrentIndex(keyEdit->findText(key));
else
keyEdit->setEditText(key);
layout->addWidget(keyEdit); layout->addWidget(keyEdit);
layout->addWidget(label);
layout->addWidget(valueEdit); layout->addWidget(valueEdit);
layout->addWidget(delButton); layout->addWidget(delButton);
@ -185,7 +213,8 @@ void ConfigDocument::addRow(QString key, QString value)
QObject::connect(delButton, SIGNAL(clicked()), QObject::connect(delButton, SIGNAL(clicked()),
this, SLOT(deleteClicked())); this, SLOT(deleteClicked()));
QObject::connect(keyEdit, SIGNAL(currentIndexChanged(QString)),
this, SLOT(textChanged()));
QObject::connect(keyEdit, SIGNAL(textChanged(QString)), QObject::connect(keyEdit, SIGNAL(textChanged(QString)),
this, SLOT(textChanged())); this, SLOT(textChanged()));
QObject::connect(valueEdit, SIGNAL(textChanged(QString)), QObject::connect(valueEdit, SIGNAL(textChanged(QString)),
@ -197,6 +226,7 @@ void ConfigDocument::addRow(QString key, QString value)
keys.append(keyEdit); keys.append(keyEdit);
values.append(valueEdit); values.append(valueEdit);
deleteButtons.append(delButton); deleteButtons.append(delButton);
labels.append(label);
} }
@ -209,11 +239,13 @@ void ConfigDocument::deleteClicked()
keys[row]->deleteLater(); keys[row]->deleteLater();
values[row]->deleteLater(); values[row]->deleteLater();
containers[row]->deleteLater(); containers[row]->deleteLater();
labels[row]->deleteLater();
deleteButtons.removeAt(row); deleteButtons.removeAt(row);
keys.removeAt(row); keys.removeAt(row);
values.removeAt(row); values.removeAt(row);
containers.removeAt(row); containers.removeAt(row);
labels.removeAt(row);
if(saved != toPlainText()) if(saved != toPlainText())
emit titleChanged(title() + "*"); emit titleChanged(title() + "*");

View file

@ -24,8 +24,10 @@
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QLineEdit> #include <QLineEdit>
#include <QComboBox>
#include <QPushButton> #include <QPushButton>
#include <QWidget> #include <QWidget>
#include <QLabel>
#include <QMap> #include <QMap>
#include "tabcontent.h" #include "tabcontent.h"
@ -55,18 +57,6 @@ public:
protected: protected:
void changeEvent(QEvent *e); void changeEvent(QEvent *e);
private:
Ui::ConfigDocument *ui;
QList<QHBoxLayout*> containers;
QList<QLineEdit*> keys;
QList<QLineEdit*> values;
QList<QPushButton*> deleteButtons;
QString filePath;
QString saved;
void addRow(QString key, QString value);
signals: signals:
void configFileChanged(QString); void configFileChanged(QString);
@ -74,6 +64,23 @@ private slots:
void deleteClicked(); void deleteClicked();
void addClicked(); void addClicked();
void textChanged(); void textChanged();
private:
Ui::ConfigDocument *ui;
QList<QHBoxLayout*> containers;
QList<QComboBox*> keys;
QList<QLineEdit*> values;
QList<QPushButton*> deleteButtons;
QList<QLabel*> labels;
QStringList primaryKeys;
QStringList secondaryKeys;
QString filePath;
QString saved;
void addRow(QString key, QString value);
}; };
#endif // CONFIGDOCUMENT_H #endif // CONFIGDOCUMENT_H

View file

@ -4,5 +4,6 @@
<file>resources/document-new.png</file> <file>resources/document-new.png</file>
<file>resources/document-open.png</file> <file>resources/document-open.png</file>
<file>resources/document-save.png</file> <file>resources/document-save.png</file>
<file alias="configkeys">resources/configkeys</file>
</qresource> </qresource>
</RCC> </RCC>

View file

@ -0,0 +1,173 @@
wps
rwps
sbs
rsbs
fms
rfms
volume
backdrop
foreground colour
background colour
foreground color
background color
font
iconset
-
bass
treble
balance
ui viewport
channels
stereo_width
shuffle
repeat
play selected
party mode
scan min step
seek acceleration
antiskip
volume fade
sort case
show files
show filename exts
follow playlist
playlist viewer icons
playlist viewer indices
playlist viewer track display
recursive directory insert
scroll speed
scroll delay
scroll step
screen scroll step
Screen Scrolls Out Of View
bidir limit
scroll paginated
hold_lr_for_scroll_in_list
show path in browser
contrast
backlight timeout
backlight timeout plugged
backlight filters first keypress
backlight on button hold
caption backlight
brightness
disk spindown
battery capacity
usb hid
usb keypad mode
idle poweroff
max files in playlist
max files in dir
lang
autocreate bookmarks
autoload bookmarks
use most-recent-bookmarks
pause on headphone unplug
rewind duration on pause
disable autoresume if phones not present
Last.fm Logging
talk dir
talk dir clip
talk file
talk file clip
talk filetype
talk menu
Announce Battery Level
hotkey wps
hotkey tree
sort files
sort dirs
sort interpret number
tagcache_autoupdate
warn when erasing dynamic playlist
cuesheet support
folder navigation
gather runtime data
skip length
prevent track skip
start in screen
playlist catalog directory
list_accel_start_delay
list_accel_wait
replaygain type
replaygain noclip
replaygain preamp
crossfade
crossfade fade in delay
crossfade fade out delay
crossfade fade in duration
crossfade fade out duration
crossfade fade out mode
crossfeed
crossfeed direct gain
crossfeed cross gain
crossfeed hf attenuation
crossfeed hf cutoff
eq enabled
eq precut
eq band 0 cutoff
eq band 1 cutoff
eq band 2 cutoff
eq band 3 cutoff
eq band 4 cutoff
eq band 0 q
eq band 1 q
eq band 2 q
eq band 3 q
eq band 4 q
eq band 0 gain
eq band 1 gain
eq band 2 gain
eq band 3 gain
eq band 4 gain
dithering enabled
timestretch enabled
compressor threshold
compressor makeup gain
compressor ratio
compressor knee
compressor release time
beep
keyclick
keyclick repeats
dircache
tagcache_ram
peak meter release
peak meter hold
peak meter clip hold
peak meter busy
peak meter dbfs
peak meter min
peak meter max
statusbar
scrollbar
scrollbar width
volume display
battery display
kbd
invert
flip display
selector type
show icons
viewers iconset
line selector start colour
line selector start color
line selector end colour
line selector end color
line selector text colour
line selector text color
filetype colours
filetype colors
time format
rec quality
rec frequency
rec source
rec channels
rec mic gain
rec left gain
rec right gain
editable recordings
rec timesplit
pre-recording time
rec directory