From 0d48448500129669c35f3316d86a98a41c0c8452 Mon Sep 17 00:00:00 2001 From: Robert Bieber Date: Wed, 16 Jun 2010 07:47:03 +0000 Subject: 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 --- utils/themeeditor/configdocument.cpp | 40 +++++++- utils/themeeditor/configdocument.h | 25 +++-- utils/themeeditor/resources.qrc | 1 + utils/themeeditor/resources/configkeys | 173 +++++++++++++++++++++++++++++++++ 4 files changed, 226 insertions(+), 13 deletions(-) create mode 100644 utils/themeeditor/resources/configkeys (limited to 'utils') diff --git a/utils/themeeditor/configdocument.cpp b/utils/themeeditor/configdocument.cpp index 5bc4b77504..a897d3b9e3 100644 --- a/utils/themeeditor/configdocument.cpp +++ b/utils/themeeditor/configdocument.cpp @@ -36,9 +36,24 @@ ConfigDocument::ConfigDocument(QMap& settings, QString file, { 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::iterator 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(); @@ -160,7 +175,7 @@ QString ConfigDocument::toPlainText() const for(int i = 0; i < keys.count(); i++) { - buffer += keys[i]->text(); + buffer += keys[i]->currentText(); buffer += ":"; buffer += values[i]->text(); buffer += "\n"; @@ -172,11 +187,24 @@ QString ConfigDocument::toPlainText() const void ConfigDocument::addRow(QString key, QString value) { QHBoxLayout* layout = new QHBoxLayout(); - QLineEdit* keyEdit = new QLineEdit(key, this); + QComboBox* keyEdit = new QComboBox(this); QLineEdit* valueEdit = new QLineEdit(value, 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(label); layout->addWidget(valueEdit); layout->addWidget(delButton); @@ -185,7 +213,8 @@ void ConfigDocument::addRow(QString key, QString value) QObject::connect(delButton, SIGNAL(clicked()), this, SLOT(deleteClicked())); - + QObject::connect(keyEdit, SIGNAL(currentIndexChanged(QString)), + this, SLOT(textChanged())); QObject::connect(keyEdit, SIGNAL(textChanged(QString)), this, SLOT(textChanged())); QObject::connect(valueEdit, SIGNAL(textChanged(QString)), @@ -197,6 +226,7 @@ void ConfigDocument::addRow(QString key, QString value) keys.append(keyEdit); values.append(valueEdit); deleteButtons.append(delButton); + labels.append(label); } @@ -209,11 +239,13 @@ void ConfigDocument::deleteClicked() keys[row]->deleteLater(); values[row]->deleteLater(); containers[row]->deleteLater(); + labels[row]->deleteLater(); deleteButtons.removeAt(row); keys.removeAt(row); values.removeAt(row); containers.removeAt(row); + labels.removeAt(row); if(saved != toPlainText()) emit titleChanged(title() + "*"); diff --git a/utils/themeeditor/configdocument.h b/utils/themeeditor/configdocument.h index 114cb5bbfc..8493c7a138 100644 --- a/utils/themeeditor/configdocument.h +++ b/utils/themeeditor/configdocument.h @@ -24,8 +24,10 @@ #include #include +#include #include #include +#include #include #include "tabcontent.h" @@ -55,25 +57,30 @@ public: protected: void changeEvent(QEvent *e); +signals: + void configFileChanged(QString); + +private slots: + void deleteClicked(); + void addClicked(); + void textChanged(); + + private: Ui::ConfigDocument *ui; QList containers; - QList keys; + QList keys; QList values; QList deleteButtons; + QList labels; + + QStringList primaryKeys; + QStringList secondaryKeys; QString filePath; QString saved; void addRow(QString key, QString value); - -signals: - void configFileChanged(QString); - -private slots: - void deleteClicked(); - void addClicked(); - void textChanged(); }; #endif // CONFIGDOCUMENT_H diff --git a/utils/themeeditor/resources.qrc b/utils/themeeditor/resources.qrc index b882e23a1d..bba483f210 100644 --- a/utils/themeeditor/resources.qrc +++ b/utils/themeeditor/resources.qrc @@ -4,5 +4,6 @@ resources/document-new.png resources/document-open.png resources/document-save.png + resources/configkeys diff --git a/utils/themeeditor/resources/configkeys b/utils/themeeditor/resources/configkeys new file mode 100644 index 0000000000..67b84b8e68 --- /dev/null +++ b/utils/themeeditor/resources/configkeys @@ -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 + -- cgit v1.2.3