summaryrefslogtreecommitdiff
path: root/utils/themeeditor
diff options
context:
space:
mode:
authorRobert Bieber <robby@bieberphoto.com>2010-06-15 20:55:56 +0000
committerRobert Bieber <robby@bieberphoto.com>2010-06-15 20:55:56 +0000
commit267a446887dbeafe02a4e1991af4489979fbb044 (patch)
tree66167168fa73f662712a9b6e668b198a10bc86ec /utils/themeeditor
parent0c26a790ee2a5702a8c87a9cd1af666d17afcc05 (diff)
downloadrockbox-267a446887dbeafe02a4e1991af4489979fbb044.zip
rockbox-267a446887dbeafe02a4e1991af4489979fbb044.tar.gz
rockbox-267a446887dbeafe02a4e1991af4489979fbb044.tar.bz2
rockbox-267a446887dbeafe02a4e1991af4489979fbb044.tar.xz
Theme Editor: Implemented save/save as in the configuration file editor
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26863 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/themeeditor')
-rw-r--r--utils/themeeditor/configdocument.cpp16
-rw-r--r--utils/themeeditor/configdocument.h4
-rw-r--r--utils/themeeditor/editorwindow.cpp39
-rw-r--r--utils/themeeditor/editorwindow.h3
-rw-r--r--utils/themeeditor/projectmodel.cpp15
5 files changed, 70 insertions, 7 deletions
diff --git a/utils/themeeditor/configdocument.cpp b/utils/themeeditor/configdocument.cpp
index c212cc5..5bc4b77 100644
--- a/utils/themeeditor/configdocument.cpp
+++ b/utils/themeeditor/configdocument.cpp
@@ -116,6 +116,7 @@ void ConfigDocument::saveAs()
saved = toPlainText();
emit titleChanged(title());
+ emit configFileChanged(file());
}
@@ -150,7 +151,7 @@ bool ConfigDocument::requestClose()
return false;
}
}
- return false;
+ return true;
}
QString ConfigDocument::toPlainText() const
@@ -185,6 +186,11 @@ void ConfigDocument::addRow(QString key, QString value)
QObject::connect(delButton, SIGNAL(clicked()),
this, SLOT(deleteClicked()));
+ QObject::connect(keyEdit, SIGNAL(textChanged(QString)),
+ this, SLOT(textChanged()));
+ QObject::connect(valueEdit, SIGNAL(textChanged(QString)),
+ this, SLOT(textChanged()));
+
ui->configBoxes->addLayout(layout);
containers.append(layout);
@@ -219,3 +225,11 @@ void ConfigDocument::addClicked()
{
addRow(tr("Key"), tr("Value"));
}
+
+void ConfigDocument::textChanged()
+{
+ if(toPlainText() != saved)
+ emit titleChanged(title() + "*");
+ else
+ emit titleChanged(title());
+}
diff --git a/utils/themeeditor/configdocument.h b/utils/themeeditor/configdocument.h
index 9aa1a63..114cb5b 100644
--- a/utils/themeeditor/configdocument.h
+++ b/utils/themeeditor/configdocument.h
@@ -67,9 +67,13 @@ private:
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/editorwindow.cpp b/utils/themeeditor/editorwindow.cpp
index 3603b24..56968a3 100644
--- a/utils/themeeditor/editorwindow.cpp
+++ b/utils/themeeditor/editorwindow.cpp
@@ -201,7 +201,7 @@ void EditorWindow::shiftTab(int index)
{
TabContent* widget = dynamic_cast<TabContent*>
(ui->editorTabs->currentWidget());
- if(index < 0 || widget->type() != TabContent::Skin)
+ if(index < 0)
{
ui->parseTree->setModel(0);
ui->actionSave_Document->setEnabled(false);
@@ -210,6 +210,13 @@ void EditorWindow::shiftTab(int index)
ui->actionToolbarSave->setEnabled(false);
ui->fromTree->setEnabled(false);
}
+ else if(widget->type() == TabContent::Config)
+ {
+ ui->actionSave_Document->setEnabled(true);
+ ui->actionSave_Document_As->setEnabled(true);
+ ui->actionClose_Document->setEnabled(true);
+ ui->actionToolbarSave->setEnabled(true);
+ }
else
{
/* Syncing the tree view and the status bar */
@@ -318,6 +325,34 @@ void EditorWindow::openProject()
}
+void EditorWindow::configFileChanged(QString configFile)
+{
+
+ QSettings settings;
+
+ settings.beginGroup("ProjectModel");
+
+ if(QFile::exists(configFile))
+ {
+
+ if(project)
+ delete project;
+
+ project = new ProjectModel(configFile, this);
+ ui->projectTree->setModel(project);
+
+ QObject::connect(ui->projectTree, SIGNAL(activated(QModelIndex)),
+ project, SLOT(activated(QModelIndex)));
+
+ configFile.chop(configFile.length() - configFile.lastIndexOf('/') - 1);
+ settings.setValue("defaultDirectory", configFile);
+
+ }
+
+ settings.endGroup();
+
+}
+
void EditorWindow::tabTitleChanged(QString title)
{
TabContent* sender = dynamic_cast<TabContent*>(QObject::sender());
@@ -342,7 +377,7 @@ void EditorWindow::closeEvent(QCloseEvent* event)
/* Closing all the tabs */
for(int i = 0; i < ui->editorTabs->count(); i++)
{
- if(!dynamic_cast<SkinDocument*>
+ if(!dynamic_cast<TabContent*>
(ui->editorTabs->widget(i))->requestClose())
{
event->ignore();
diff --git a/utils/themeeditor/editorwindow.h b/utils/themeeditor/editorwindow.h
index 7e62caa..51ca7a6 100644
--- a/utils/themeeditor/editorwindow.h
+++ b/utils/themeeditor/editorwindow.h
@@ -53,6 +53,9 @@ public:
protected:
virtual void closeEvent(QCloseEvent* event);
+public slots:
+ void configFileChanged(QString configFile);
+
private slots:
void showPanel();
void newTab();
diff --git a/utils/themeeditor/projectmodel.cpp b/utils/themeeditor/projectmodel.cpp
index 2df4c0a..632e0aa 100644
--- a/utils/themeeditor/projectmodel.cpp
+++ b/utils/themeeditor/projectmodel.cpp
@@ -114,11 +114,18 @@ QVariant ProjectModel::data(const QModelIndex &index, int role) const
void ProjectModel::activated(const QModelIndex &index)
{
if(index.row() == 0)
- mainWindow->loadConfigTab(new ConfigDocument(settings,
- settings.value("themebase",
- "") + "/" +
- files[index.row()]));
+ {
+ ConfigDocument* doc = new ConfigDocument(settings,
+ settings.value("themebase",
+ "") + "/" +
+ files[index.row()]);
+ QObject::connect(doc, SIGNAL(configFileChanged(QString)),
+ mainWindow, SLOT(configFileChanged(QString)));
+ mainWindow->loadConfigTab(doc);
+ }
else
+ {
mainWindow->loadTabFromSkinFile(settings.value("themebase", "")
+ "/" + files[index.row()]);
+ }
}