forked from len0rd/rockbox
Theme Editor: Refactored main window init code, moved parse tree into dock widget
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26519 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
3f44f1c151
commit
88160b6e27
3 changed files with 59 additions and 23 deletions
|
@ -29,33 +29,51 @@ EditorWindow::EditorWindow(QWidget *parent) :
|
||||||
ui(new Ui::EditorWindow)
|
ui(new Ui::EditorWindow)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
loadSettings();
|
||||||
|
setupUI();
|
||||||
|
setupMenus();
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditorWindow::loadSettings()
|
||||||
|
{
|
||||||
|
/* When there are settings to load, they'll be loaded here */
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditorWindow::setupUI()
|
||||||
|
{
|
||||||
/* Establishing the parse tree */
|
/* Establishing the parse tree */
|
||||||
tree = new ParseTreeModel(ui->code->document()->toPlainText().toAscii());
|
tree = new ParseTreeModel(ui->codeEdit->document()->toPlainText().
|
||||||
|
toAscii());
|
||||||
ui->parseTree->setModel(tree);
|
ui->parseTree->setModel(tree);
|
||||||
|
|
||||||
/* Setting up the syntax highlighter */
|
/* Setting up the syntax highlighter */
|
||||||
highlighter = new SkinHighlighter(QColor(0,255,0), QColor(255,0,0),
|
highlighter = new SkinHighlighter(QColor(0,255,0), QColor(255,0,0),
|
||||||
QColor(0,0,255), QColor(150,150,150),
|
QColor(0,0,255), QColor(150,150,150),
|
||||||
ui->code->document());
|
ui->codeEdit->document());
|
||||||
|
|
||||||
/* Connecting the buttons */
|
/* Connecting the buttons */
|
||||||
QObject::connect(ui->code, SIGNAL(cursorPositionChanged()),
|
QObject::connect(ui->codeEdit, SIGNAL(cursorPositionChanged()),
|
||||||
this, SLOT(updateTree()));
|
this, SLOT(codeChanged()));
|
||||||
QObject::connect(ui->fromTree, SIGNAL(pressed()),
|
QObject::connect(ui->fromTree, SIGNAL(pressed()),
|
||||||
this, SLOT(updateCode()));
|
this, SLOT(updateCode()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorWindow::updateTree()
|
void EditorWindow::setupMenus()
|
||||||
{
|
{
|
||||||
tree->changeTree(ui->code->document()->toPlainText().toAscii());
|
/* When there are menus to setup, they'll be set up here */
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditorWindow::codeChanged()
|
||||||
|
{
|
||||||
|
tree->changeTree(ui->codeEdit->document()->toPlainText().toAscii());
|
||||||
ui->parseTree->expandAll();
|
ui->parseTree->expandAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorWindow::updateCode()
|
void EditorWindow::updateCode()
|
||||||
{
|
{
|
||||||
tree->genCode();
|
tree->genCode();
|
||||||
ui->code->document()->setPlainText(tree->genCode());
|
ui->codeEdit->document()->setPlainText(tree->genCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorWindow::~EditorWindow()
|
EditorWindow::~EditorWindow()
|
||||||
|
|
|
@ -39,9 +39,14 @@ public:
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void updateCode();
|
void updateCode();
|
||||||
void updateTree();
|
void codeChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
/* Setup functions */
|
||||||
|
void loadSettings();
|
||||||
|
void setupUI();
|
||||||
|
void setupMenus();
|
||||||
|
|
||||||
Ui::EditorWindow *ui;
|
Ui::EditorWindow *ui;
|
||||||
ParseTreeModel* tree;
|
ParseTreeModel* tree;
|
||||||
SkinHighlighter* highlighter;
|
SkinHighlighter* highlighter;
|
||||||
|
|
|
@ -15,24 +15,14 @@
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralwidget">
|
<widget class="QWidget" name="centralwidget">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
|
||||||
<item>
|
|
||||||
<widget class="QTreeView" name="parseTree"/>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="fromTree">
|
|
||||||
<property name="text">
|
|
||||||
<string>Update Code</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPlainTextEdit" name="code"/>
|
<widget class="QPlainTextEdit" name="codeEdit">
|
||||||
|
<property name="lineWrapMode">
|
||||||
|
<enum>QPlainTextEdit::NoWrap</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
@ -56,6 +46,29 @@
|
||||||
<addaction name="menuFile"/>
|
<addaction name="menuFile"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QStatusBar" name="statusbar"/>
|
<widget class="QStatusBar" name="statusbar"/>
|
||||||
|
<widget class="QDockWidget" name="outputDock">
|
||||||
|
<attribute name="dockWidgetArea">
|
||||||
|
<number>2</number>
|
||||||
|
</attribute>
|
||||||
|
<widget class="QWidget" name="dockWidgetContents">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<item>
|
||||||
|
<widget class="QTreeView" name="parseTree"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="fromTree">
|
||||||
|
<property name="text">
|
||||||
|
<string>Update Code</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
<action name="actionQuit">
|
<action name="actionQuit">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Quit</string>
|
<string>Quit</string>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue