mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
Theme Editor: Added a preferences dialog and allowed modification of the syntax highlighting and editor colors
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26640 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
fbfdaf5c79
commit
53b619c6e8
10 changed files with 563 additions and 23 deletions
|
@ -32,6 +32,7 @@ EditorWindow::EditorWindow(QWidget *parent) :
|
||||||
ui(new Ui::EditorWindow)
|
ui(new Ui::EditorWindow)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
prefs = new PreferencesDialog(this);
|
||||||
loadSettings();
|
loadSettings();
|
||||||
setupUI();
|
setupUI();
|
||||||
setupMenus();
|
setupMenus();
|
||||||
|
@ -43,7 +44,7 @@ void EditorWindow::loadSettings()
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
|
||||||
/* Main Window location */
|
/* Main Window location */
|
||||||
settings.beginGroup("MainWindow");
|
settings.beginGroup("EditorWindow");
|
||||||
QSize size = settings.value("size").toSize();
|
QSize size = settings.value("size").toSize();
|
||||||
QPoint pos = settings.value("position").toPoint();
|
QPoint pos = settings.value("position").toPoint();
|
||||||
QByteArray state = settings.value("state").toByteArray();
|
QByteArray state = settings.value("state").toByteArray();
|
||||||
|
@ -65,7 +66,7 @@ void EditorWindow::saveSettings()
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
|
||||||
/* Saving window and panel positions */
|
/* Saving window and panel positions */
|
||||||
settings.beginGroup("MainWindow");
|
settings.beginGroup("EditorWindow");
|
||||||
settings.setValue("position", pos());
|
settings.setValue("position", pos());
|
||||||
settings.setValue("size", size());
|
settings.setValue("size", size());
|
||||||
settings.setValue("state", saveState());
|
settings.setValue("state", saveState());
|
||||||
|
@ -89,6 +90,10 @@ void EditorWindow::setupUI()
|
||||||
QObject::connect(ui->fromTree, SIGNAL(pressed()),
|
QObject::connect(ui->fromTree, SIGNAL(pressed()),
|
||||||
this, SLOT(updateCurrent()));
|
this, SLOT(updateCurrent()));
|
||||||
|
|
||||||
|
/* Connecting the preferences dialog */
|
||||||
|
QObject::connect(ui->actionPreferences, SIGNAL(triggered()),
|
||||||
|
prefs, SLOT(exec()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorWindow::setupMenus()
|
void EditorWindow::setupMenus()
|
||||||
|
@ -124,15 +129,23 @@ void EditorWindow::setupMenus()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditorWindow::addTab(SkinDocument *doc)
|
||||||
void EditorWindow::newTab()
|
|
||||||
{
|
{
|
||||||
SkinDocument* doc = new SkinDocument;
|
|
||||||
ui->editorTabs->addTab(doc, doc->getTitle());
|
ui->editorTabs->addTab(doc, doc->getTitle());
|
||||||
|
|
||||||
/* Connecting to title change events */
|
/* Connecting to title change events */
|
||||||
QObject::connect(doc, SIGNAL(titleChanged(QString)),
|
QObject::connect(doc, SIGNAL(titleChanged(QString)),
|
||||||
this, SLOT(tabTitleChanged(QString)));
|
this, SLOT(tabTitleChanged(QString)));
|
||||||
|
|
||||||
|
/* Connecting to settings change events */
|
||||||
|
doc->connectPrefs(prefs);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void EditorWindow::newTab()
|
||||||
|
{
|
||||||
|
SkinDocument* doc = new SkinDocument;
|
||||||
|
addTab(doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorWindow::shiftTab(int index)
|
void EditorWindow::shiftTab(int index)
|
||||||
|
@ -208,10 +221,7 @@ void EditorWindow::openFile()
|
||||||
|
|
||||||
/* Adding a new document for each file name */
|
/* Adding a new document for each file name */
|
||||||
SkinDocument* doc = new SkinDocument(current);
|
SkinDocument* doc = new SkinDocument(current);
|
||||||
ui->editorTabs->addTab(doc, doc->getTitle());
|
addTab(doc);
|
||||||
|
|
||||||
QObject::connect(doc, SIGNAL(titleChanged(QString)),
|
|
||||||
this, SLOT(tabTitleChanged(QString)));
|
|
||||||
|
|
||||||
/* And setting the new default directory */
|
/* And setting the new default directory */
|
||||||
current.chop(current.length() - current.lastIndexOf('/') - 1);
|
current.chop(current.length() - current.lastIndexOf('/') - 1);
|
||||||
|
@ -270,4 +280,5 @@ void EditorWindow::updateCurrent()
|
||||||
EditorWindow::~EditorWindow()
|
EditorWindow::~EditorWindow()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
|
delete prefs;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include "parsetreemodel.h"
|
#include "parsetreemodel.h"
|
||||||
#include "skinhighlighter.h"
|
#include "skinhighlighter.h"
|
||||||
#include "skindocument.h"
|
#include "skindocument.h"
|
||||||
|
#include "preferencesdialog.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class EditorWindow;
|
class EditorWindow;
|
||||||
|
@ -59,8 +60,10 @@ private:
|
||||||
void saveSettings();
|
void saveSettings();
|
||||||
void setupUI();
|
void setupUI();
|
||||||
void setupMenus();
|
void setupMenus();
|
||||||
|
void addTab(SkinDocument* doc);
|
||||||
|
|
||||||
Ui::EditorWindow *ui;
|
Ui::EditorWindow *ui;
|
||||||
|
PreferencesDialog* prefs;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // EDITORWINDOW_H
|
#endif // EDITORWINDOW_H
|
||||||
|
|
164
utils/themeeditor/preferencesdialog.cpp
Normal file
164
utils/themeeditor/preferencesdialog.cpp
Normal file
|
@ -0,0 +1,164 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* __________ __ ___.
|
||||||
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||||
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||||
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
|
* \/ \/ \/ \/ \/
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Robert Bieber
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
|
* KIND, either express or implied.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "preferencesdialog.h"
|
||||||
|
#include "ui_preferencesdialog.h"
|
||||||
|
|
||||||
|
#include <QSettings>
|
||||||
|
#include <QColorDialog>
|
||||||
|
|
||||||
|
PreferencesDialog::PreferencesDialog(QWidget *parent) :
|
||||||
|
QDialog(parent),
|
||||||
|
ui(new Ui::PreferencesDialog)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
setupUI();
|
||||||
|
loadSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
PreferencesDialog::~PreferencesDialog()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreferencesDialog::loadSettings()
|
||||||
|
{
|
||||||
|
loadColors();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreferencesDialog::loadColors()
|
||||||
|
{
|
||||||
|
|
||||||
|
QSettings settings;
|
||||||
|
|
||||||
|
/* The list of buttons from the SkinHighlighter group */
|
||||||
|
|
||||||
|
settings.beginGroup("SkinHighlighter");
|
||||||
|
|
||||||
|
commentColor = settings.value("commentColor",
|
||||||
|
QColor(0, 180, 0)).value<QColor>();
|
||||||
|
setButtonColor(ui->commentButton, commentColor);
|
||||||
|
|
||||||
|
escapedColor = settings.value("escapedColor",
|
||||||
|
QColor(120,120,120)).value<QColor>();
|
||||||
|
setButtonColor(ui->escapedButton, escapedColor);
|
||||||
|
|
||||||
|
conditionalColor = settings.value("conditionalColor",
|
||||||
|
QColor(0, 0, 180)).value<QColor>();
|
||||||
|
setButtonColor(ui->conditionalButton, conditionalColor);
|
||||||
|
|
||||||
|
tagColor = settings.value("tagColor",
|
||||||
|
QColor(180, 0, 0)).value<QColor>();
|
||||||
|
setButtonColor(ui->tagButton, tagColor);
|
||||||
|
|
||||||
|
settings.endGroup();
|
||||||
|
|
||||||
|
/* Buttons from the editor group */
|
||||||
|
settings.beginGroup("SkinDocument");
|
||||||
|
|
||||||
|
fgColor = settings.value("fgColor", Qt::black).value<QColor>();
|
||||||
|
setButtonColor(ui->fgButton, fgColor);
|
||||||
|
|
||||||
|
bgColor = settings.value("bgColor", Qt::white).value<QColor>();
|
||||||
|
setButtonColor(ui->bgButton, bgColor);
|
||||||
|
|
||||||
|
settings.endGroup();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreferencesDialog::saveSettings()
|
||||||
|
{
|
||||||
|
saveColors();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreferencesDialog::saveColors()
|
||||||
|
{
|
||||||
|
QSettings settings;
|
||||||
|
|
||||||
|
/* Saving the editor colors */
|
||||||
|
settings.beginGroup("SkinDocument");
|
||||||
|
|
||||||
|
settings.setValue("fgColor", fgColor);
|
||||||
|
settings.setValue("bgColor", bgColor);
|
||||||
|
|
||||||
|
settings.endGroup();
|
||||||
|
|
||||||
|
/* Saving the highlighting colors */
|
||||||
|
settings.beginGroup("SkinHighlighter");
|
||||||
|
|
||||||
|
settings.setValue("tagColor", tagColor);
|
||||||
|
settings.setValue("commentColor", commentColor);
|
||||||
|
settings.setValue("conditionalColor", conditionalColor);
|
||||||
|
settings.setValue("escapedColor", escapedColor);
|
||||||
|
|
||||||
|
settings.endGroup();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreferencesDialog::setupUI()
|
||||||
|
{
|
||||||
|
/* Connecting color buttons */
|
||||||
|
QList<QPushButton*> buttons;
|
||||||
|
buttons.append(ui->bgButton);
|
||||||
|
buttons.append(ui->fgButton);
|
||||||
|
buttons.append(ui->commentButton);
|
||||||
|
buttons.append(ui->tagButton);
|
||||||
|
buttons.append(ui->conditionalButton);
|
||||||
|
buttons.append(ui->escapedButton);
|
||||||
|
|
||||||
|
for(int i = 0; i < buttons.count(); i++)
|
||||||
|
QObject::connect(buttons[i], SIGNAL(pressed()),
|
||||||
|
this, SLOT(colorClicked()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreferencesDialog::colorClicked()
|
||||||
|
{
|
||||||
|
QColor* toEdit = 0;
|
||||||
|
|
||||||
|
if(QObject::sender() == ui->bgButton)
|
||||||
|
toEdit = &bgColor;
|
||||||
|
else if(QObject::sender() == ui->fgButton)
|
||||||
|
toEdit = &fgColor;
|
||||||
|
else if(QObject::sender() == ui->commentButton)
|
||||||
|
toEdit = &commentColor;
|
||||||
|
else if(QObject::sender() == ui->tagButton)
|
||||||
|
toEdit = &tagColor;
|
||||||
|
else if(QObject::sender() == ui->conditionalButton)
|
||||||
|
toEdit = &conditionalColor;
|
||||||
|
else if(QObject::sender() == ui->escapedButton)
|
||||||
|
toEdit = &escapedColor;
|
||||||
|
|
||||||
|
if(!toEdit)
|
||||||
|
return;
|
||||||
|
|
||||||
|
*toEdit = QColorDialog::getColor(*toEdit, this);
|
||||||
|
setButtonColor(dynamic_cast<QPushButton*>(QObject::sender()), *toEdit);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreferencesDialog::accept()
|
||||||
|
{
|
||||||
|
saveSettings();
|
||||||
|
QDialog::accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PreferencesDialog::reject()
|
||||||
|
{
|
||||||
|
loadSettings();
|
||||||
|
QDialog::reject();
|
||||||
|
}
|
69
utils/themeeditor/preferencesdialog.h
Normal file
69
utils/themeeditor/preferencesdialog.h
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* __________ __ ___.
|
||||||
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||||
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||||
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
|
* \/ \/ \/ \/ \/
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010 Robert Bieber
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
|
* KIND, either express or implied.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef PREFERENCESDIALOG_H
|
||||||
|
#define PREFERENCESDIALOG_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class PreferencesDialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
class PreferencesDialog : public QDialog {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
PreferencesDialog(QWidget *parent = 0);
|
||||||
|
~PreferencesDialog();
|
||||||
|
|
||||||
|
static void setButtonColor(QPushButton* button, QColor color)
|
||||||
|
{
|
||||||
|
QString style = "* { background:" + color.name() + "}";
|
||||||
|
button->setStyleSheet(style);
|
||||||
|
}
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void accept();
|
||||||
|
void reject();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void colorClicked();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::PreferencesDialog *ui;
|
||||||
|
|
||||||
|
void loadSettings();
|
||||||
|
void loadColors();
|
||||||
|
void saveSettings();
|
||||||
|
void saveColors();
|
||||||
|
|
||||||
|
void setupUI();
|
||||||
|
|
||||||
|
QColor fgColor;
|
||||||
|
QColor bgColor;
|
||||||
|
QColor commentColor;
|
||||||
|
QColor escapedColor;
|
||||||
|
QColor tagColor;
|
||||||
|
QColor conditionalColor;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // PREFERENCESDIALOG_H
|
235
utils/themeeditor/preferencesdialog.ui
Normal file
235
utils/themeeditor/preferencesdialog.ui
Normal file
|
@ -0,0 +1,235 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>PreferencesDialog</class>
|
||||||
|
<widget class="QDialog" name="PreferencesDialog">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>370</width>
|
||||||
|
<height>370</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Dialog</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QToolBox" name="prefsGroups">
|
||||||
|
<property name="currentIndex">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="highlighting">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>352</width>
|
||||||
|
<height>288</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<attribute name="label">
|
||||||
|
<string>Editor Colors</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Foreground</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>fgButton</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>Background</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>bgButton</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_4">
|
||||||
|
<property name="text">
|
||||||
|
<string>Comment</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>commentButton</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_5">
|
||||||
|
<property name="text">
|
||||||
|
<string>Escaped Character</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>escapedButton</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_6">
|
||||||
|
<property name="text">
|
||||||
|
<string>Conditional</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>conditionalButton</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Tag</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>tagButton</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="fgButton">
|
||||||
|
<property name="autoFillBackground">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Click To Change</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="bgButton">
|
||||||
|
<property name="autoFillBackground">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Click To Change</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="commentButton">
|
||||||
|
<property name="autoFillBackground">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Click To Change</string>
|
||||||
|
</property>
|
||||||
|
<property name="flat">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="escapedButton">
|
||||||
|
<property name="autoFillBackground">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Click To Change</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="conditionalButton">
|
||||||
|
<property name="autoFillBackground">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Click To Change</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="tagButton">
|
||||||
|
<property name="autoFillBackground">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Click To Change</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>PreferencesDialog</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>248</x>
|
||||||
|
<y>254</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>157</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>PreferencesDialog</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>316</x>
|
||||||
|
<y>260</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>286</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
#include <QColor>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
|
||||||
|
@ -61,6 +62,14 @@ SkinDocument::~SkinDocument()
|
||||||
delete model;
|
delete model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SkinDocument::connectPrefs(PreferencesDialog* prefs)
|
||||||
|
{
|
||||||
|
QObject::connect(prefs, SIGNAL(accepted()),
|
||||||
|
this, SLOT(colorsChanged()));
|
||||||
|
QObject::connect(prefs, SIGNAL(accepted()),
|
||||||
|
highlighter, SLOT(loadSettings()));
|
||||||
|
}
|
||||||
|
|
||||||
bool SkinDocument::requestClose()
|
bool SkinDocument::requestClose()
|
||||||
{
|
{
|
||||||
if(editor->document()->toPlainText() != saved)
|
if(editor->document()->toPlainText() != saved)
|
||||||
|
@ -106,9 +115,7 @@ void SkinDocument::setupUI()
|
||||||
setLayout(layout);
|
setLayout(layout);
|
||||||
|
|
||||||
/* Attaching the syntax highlighter */
|
/* Attaching the syntax highlighter */
|
||||||
highlighter = new SkinHighlighter(QColor(0,180,0), QColor(255,0,0),
|
highlighter = new SkinHighlighter(editor->document());
|
||||||
QColor(0,0,255), QColor(120,120,120),
|
|
||||||
editor->document());
|
|
||||||
|
|
||||||
/* Setting up the model */
|
/* Setting up the model */
|
||||||
model = new ParseTreeModel("");
|
model = new ParseTreeModel("");
|
||||||
|
@ -116,6 +123,27 @@ void SkinDocument::setupUI()
|
||||||
/* Connecting the editor's signal */
|
/* Connecting the editor's signal */
|
||||||
QObject::connect(editor, SIGNAL(textChanged()),
|
QObject::connect(editor, SIGNAL(textChanged()),
|
||||||
this, SLOT(codeChanged()));
|
this, SLOT(codeChanged()));
|
||||||
|
|
||||||
|
colorsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SkinDocument::colorsChanged()
|
||||||
|
{
|
||||||
|
/* Setting the editor colors */
|
||||||
|
QSettings settings;
|
||||||
|
settings.beginGroup("SkinDocument");
|
||||||
|
|
||||||
|
QColor fg = settings.value("fgColor", Qt::black).value<QColor>();
|
||||||
|
QColor bg = settings.value("bgColor", Qt::white).value<QColor>();
|
||||||
|
QPalette palette;
|
||||||
|
palette.setColor(QPalette::All, QPalette::Base, bg);
|
||||||
|
palette.setColor(QPalette::All, QPalette::Text, fg);
|
||||||
|
|
||||||
|
editor->setPalette(palette);
|
||||||
|
editor->repaint();
|
||||||
|
|
||||||
|
settings.endGroup();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkinDocument::codeChanged()
|
void SkinDocument::codeChanged()
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
#include "skinhighlighter.h"
|
#include "skinhighlighter.h"
|
||||||
#include "parsetreemodel.h"
|
#include "parsetreemodel.h"
|
||||||
|
#include "preferencesdialog.h"
|
||||||
|
|
||||||
class SkinDocument : public QWidget
|
class SkinDocument : public QWidget
|
||||||
{
|
{
|
||||||
|
@ -47,6 +48,8 @@ public:
|
||||||
SkinDocument(QString file, QWidget* parent = 0);
|
SkinDocument(QString file, QWidget* parent = 0);
|
||||||
virtual ~SkinDocument();
|
virtual ~SkinDocument();
|
||||||
|
|
||||||
|
void connectPrefs(PreferencesDialog* prefs);
|
||||||
|
|
||||||
ParseTreeModel* getModel(){ return model; }
|
ParseTreeModel* getModel(){ return model; }
|
||||||
QString getTitle(){ return title; }
|
QString getTitle(){ return title; }
|
||||||
void genCode(){ editor->document()->setPlainText(model->genCode()); }
|
void genCode(){ editor->document()->setPlainText(model->genCode()); }
|
||||||
|
@ -59,6 +62,9 @@ public:
|
||||||
signals:
|
signals:
|
||||||
void titleChanged(QString);
|
void titleChanged(QString);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void colorsChanged();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void codeChanged();
|
void codeChanged();
|
||||||
|
|
||||||
|
|
|
@ -21,13 +21,12 @@
|
||||||
|
|
||||||
#include "skinhighlighter.h"
|
#include "skinhighlighter.h"
|
||||||
|
|
||||||
SkinHighlighter::SkinHighlighter(QColor comment, QColor tag, QColor conditional,
|
#include <QSettings>
|
||||||
QColor escaped, QTextDocument* doc)
|
|
||||||
:QSyntaxHighlighter(doc),
|
|
||||||
escaped(escaped), tag(tag),
|
|
||||||
conditional(conditional), comment(comment)
|
|
||||||
{
|
|
||||||
|
|
||||||
|
SkinHighlighter::SkinHighlighter(QTextDocument* doc)
|
||||||
|
:QSyntaxHighlighter(doc)
|
||||||
|
{
|
||||||
|
loadSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
SkinHighlighter::~SkinHighlighter()
|
SkinHighlighter::~SkinHighlighter()
|
||||||
|
@ -151,3 +150,23 @@ void SkinHighlighter::highlightBlock(const QString& text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SkinHighlighter::loadSettings()
|
||||||
|
{
|
||||||
|
QSettings settings;
|
||||||
|
|
||||||
|
settings.beginGroup("SkinHighlighter");
|
||||||
|
|
||||||
|
/* Loading the highlighting colors */
|
||||||
|
tag = settings.value("tagColor", QColor(180,0,0)).value<QColor>();
|
||||||
|
conditional = settings.value("conditionalColor",
|
||||||
|
QColor(0, 0, 180)).value<QColor>();
|
||||||
|
escaped = settings.value("escapedColor",
|
||||||
|
QColor(120,120,120)).value<QColor>();
|
||||||
|
comment = settings.value("commentColor",
|
||||||
|
QColor(0, 180, 0)).value<QColor>();
|
||||||
|
|
||||||
|
settings.endGroup();
|
||||||
|
|
||||||
|
rehighlight();
|
||||||
|
}
|
||||||
|
|
|
@ -40,12 +40,14 @@ public:
|
||||||
* conditional - The color for conditionals and their delimiters
|
* conditional - The color for conditionals and their delimiters
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
SkinHighlighter(QColor comment, QColor tag, QColor conditional,
|
SkinHighlighter(QTextDocument* doc);
|
||||||
QColor escaped, QTextDocument* doc);
|
|
||||||
virtual ~SkinHighlighter();
|
virtual ~SkinHighlighter();
|
||||||
|
|
||||||
void highlightBlock(const QString& text);
|
void highlightBlock(const QString& text);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void loadSettings();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QColor escaped;
|
QColor escaped;
|
||||||
QColor tag;
|
QColor tag;
|
||||||
|
|
|
@ -13,7 +13,8 @@ HEADERS += tag_table.h \
|
||||||
parsetreenode.h \
|
parsetreenode.h \
|
||||||
editorwindow.h \
|
editorwindow.h \
|
||||||
skinhighlighter.h \
|
skinhighlighter.h \
|
||||||
skindocument.h
|
skindocument.h \
|
||||||
|
preferencesdialog.h
|
||||||
SOURCES += tag_table.c \
|
SOURCES += tag_table.c \
|
||||||
skin_parser.c \
|
skin_parser.c \
|
||||||
skin_scan.c \
|
skin_scan.c \
|
||||||
|
@ -23,7 +24,8 @@ SOURCES += tag_table.c \
|
||||||
parsetreenode.cpp \
|
parsetreenode.cpp \
|
||||||
editorwindow.cpp \
|
editorwindow.cpp \
|
||||||
skinhighlighter.cpp \
|
skinhighlighter.cpp \
|
||||||
skindocument.cpp
|
skindocument.cpp \
|
||||||
|
preferencesdialog.cpp
|
||||||
OTHER_FILES += README \
|
OTHER_FILES += README \
|
||||||
resources/windowicon.png \
|
resources/windowicon.png \
|
||||||
resources/appicon.xcf \
|
resources/appicon.xcf \
|
||||||
|
@ -31,5 +33,6 @@ OTHER_FILES += README \
|
||||||
resources/document-save.png \
|
resources/document-save.png \
|
||||||
resources/document-open.png \
|
resources/document-open.png \
|
||||||
resources/document-new.png
|
resources/document-new.png
|
||||||
FORMS += editorwindow.ui
|
FORMS += editorwindow.ui \
|
||||||
|
preferencesdialog.ui
|
||||||
RESOURCES += resources.qrc
|
RESOURCES += resources.qrc
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue