1
0
Fork 0
forked from len0rd/rockbox

Theme Editor: Fixed bugs with menu signals, rearranged UI some more

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26540 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Robert Bieber 2010-06-04 06:59:25 +00:00
parent d5171cc225
commit 9616389377
3 changed files with 69 additions and 160 deletions

View file

@ -57,49 +57,47 @@ void EditorWindow::setupUI()
model->setRootPath(QDir::currentPath()); model->setRootPath(QDir::currentPath());
ui->fileTree->setModel(model); ui->fileTree->setModel(model);
/* Establishing the parse tree */
tree = new ParseTreeModel(ui->codeEdit->document()->toPlainText().
toAscii());
ui->parseTree->setModel(tree);
/* Setting up the syntax highlighter */
highlighter = new SkinHighlighter(QColor(0,255,0), QColor(255,0,0),
QColor(0,0,255), QColor(150,150,150),
ui->codeEdit->document());
/* Connecting the buttons */ /* Connecting the buttons */
QObject::connect(ui->codeEdit, SIGNAL(cursorPositionChanged()),
this, SLOT(codeChanged()));
QObject::connect(ui->fromTree, SIGNAL(pressed()), QObject::connect(ui->fromTree, SIGNAL(pressed()),
this, SLOT(updateCode())); this, SLOT(updateCode()));
} }
void EditorWindow::setupMenus() void EditorWindow::setupMenus()
{ {
/* When there are menus to setup, they'll be set up here */ /* Connecting panel show actions */
QObject::connect(ui->actionFile_Panel, SIGNAL(triggered()),
this, SLOT(showPanel()));
QObject::connect(ui->actionDisplay_Panel, SIGNAL(triggered()),
this, SLOT(showPanel()));
QObject::connect(ui->actionPreview_Panel, SIGNAL(triggered()),
this, SLOT(showPanel()));
} }
void EditorWindow::codeChanged() void EditorWindow::codeChanged()
{ {
tree->changeTree(ui->codeEdit->document()->toPlainText().toAscii());
ui->parseTree->expandAll(); ui->parseTree->expandAll();
} }
void EditorWindow::updateCode()
{
}
void EditorWindow::showPanel()
{
if(sender() == ui->actionFile_Panel)
ui->fileDock->setVisible(true);
if(sender() == ui->actionPreview_Panel)
ui->skinPreviewDock->setVisible(true);
if(sender() == ui->actionDisplay_Panel)
ui->parseTreeDock->setVisible(true);
}
void EditorWindow::closeEvent(QCloseEvent* event) void EditorWindow::closeEvent(QCloseEvent* event)
{ {
event->accept(); event->accept();
} }
void EditorWindow::updateCode()
{
if(tree)
ui->codeEdit->document()->setPlainText(tree->genCode());
}
EditorWindow::~EditorWindow() EditorWindow::~EditorWindow()
{ {
delete ui; delete ui;
if(tree)
delete tree;
} }

View file

@ -43,6 +43,7 @@ protected:
private slots: private slots:
void updateCode(); void updateCode();
void codeChanged(); void codeChanged();
void showPanel();
private: private:
/* Setup functions */ /* Setup functions */
@ -51,7 +52,6 @@ private:
void setupMenus(); void setupMenus();
Ui::EditorWindow *ui; Ui::EditorWindow *ui;
ParseTreeModel* tree;
SkinHighlighter* highlighter; SkinHighlighter* highlighter;
}; };

View file

@ -20,9 +20,18 @@
<widget class="QWidget" name="centralwidget"> <widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="QPlainTextEdit" name="codeEdit"> <widget class="QTabWidget" name="editorTabs">
<property name="lineWrapMode"> <property name="tabPosition">
<enum>QPlainTextEdit::NoWrap</enum> <enum>QTabWidget::North</enum>
</property>
<property name="currentIndex">
<number>-1</number>
</property>
<property name="tabsClosable">
<bool>true</bool>
</property>
<property name="movable">
<bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
@ -41,6 +50,9 @@
<property name="title"> <property name="title">
<string>&amp;File</string> <string>&amp;File</string>
</property> </property>
<addaction name="actionNew_Document"/>
<addaction name="actionOpen_Document"/>
<addaction name="separator"/>
<addaction name="actionPreferences"/> <addaction name="actionPreferences"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionQuit"/> <addaction name="actionQuit"/>
@ -58,21 +70,14 @@
</widget> </widget>
<widget class="QStatusBar" name="statusbar"/> <widget class="QStatusBar" name="statusbar"/>
<widget class="QDockWidget" name="skinPreviewDock"> <widget class="QDockWidget" name="skinPreviewDock">
<property name="windowTitle">
<string>Skin Preview</string>
</property>
<attribute name="dockWidgetArea"> <attribute name="dockWidgetArea">
<number>2</number> <number>2</number>
</attribute> </attribute>
<widget class="QWidget" name="dockWidgetContents"> <widget class="QWidget" name="dockWidgetContents">
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Skin Preview</string>
</property>
<property name="buddy">
<cstring>skinPreview</cstring>
</property>
</widget>
</item>
<item> <item>
<widget class="QGraphicsView" name="skinPreview"/> <widget class="QGraphicsView" name="skinPreview"/>
</item> </item>
@ -87,25 +92,18 @@
<enum>TopToolBarArea</enum> <enum>TopToolBarArea</enum>
</attribute> </attribute>
<attribute name="toolBarBreak"> <attribute name="toolBarBreak">
<bool>true</bool> <bool>false</bool>
</attribute> </attribute>
</widget> </widget>
<widget class="QDockWidget" name="fileDock"> <widget class="QDockWidget" name="fileDock">
<property name="windowTitle">
<string>Files</string>
</property>
<attribute name="dockWidgetArea"> <attribute name="dockWidgetArea">
<number>1</number> <number>1</number>
</attribute> </attribute>
<widget class="QWidget" name="dockWidgetContents_2"> <widget class="QWidget" name="dockWidgetContents_2">
<layout class="QVBoxLayout" name="verticalLayout_4"> <layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Files</string>
</property>
<property name="buddy">
<cstring>fileTree</cstring>
</property>
</widget>
</item>
<item> <item>
<widget class="QTreeView" name="fileTree"/> <widget class="QTreeView" name="fileTree"/>
</item> </item>
@ -113,21 +111,14 @@
</widget> </widget>
</widget> </widget>
<widget class="QDockWidget" name="parseTreeDock"> <widget class="QDockWidget" name="parseTreeDock">
<property name="windowTitle">
<string>Parse Tree</string>
</property>
<attribute name="dockWidgetArea"> <attribute name="dockWidgetArea">
<number>2</number> <number>2</number>
</attribute> </attribute>
<widget class="QWidget" name="dockWidgetContents_3"> <widget class="QWidget" name="dockWidgetContents_3">
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Parse Tree</string>
</property>
<property name="buddy">
<cstring>parseTree</cstring>
</property>
</widget>
</item>
<item> <item>
<widget class="QTreeView" name="parseTree"/> <widget class="QTreeView" name="parseTree"/>
</item> </item>
@ -151,10 +142,10 @@
</action> </action>
<action name="actionDisplay_Panel"> <action name="actionDisplay_Panel">
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>false</bool>
</property> </property>
<property name="checked"> <property name="checked">
<bool>true</bool> <bool>false</bool>
</property> </property>
<property name="text"> <property name="text">
<string>Parse &amp;Tree Panel</string> <string>Parse &amp;Tree Panel</string>
@ -170,10 +161,10 @@
</action> </action>
<action name="actionFile_Panel"> <action name="actionFile_Panel">
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>false</bool>
</property> </property>
<property name="checked"> <property name="checked">
<bool>true</bool> <bool>false</bool>
</property> </property>
<property name="text"> <property name="text">
<string>&amp;File Panel</string> <string>&amp;File Panel</string>
@ -181,15 +172,31 @@
</action> </action>
<action name="actionPreview_Panel"> <action name="actionPreview_Panel">
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>false</bool>
</property> </property>
<property name="checked"> <property name="checked">
<bool>true</bool> <bool>false</bool>
</property> </property>
<property name="text"> <property name="text">
<string>&amp;Preview Panel</string> <string>&amp;Preview Panel</string>
</property> </property>
</action> </action>
<action name="actionNew_Document">
<property name="text">
<string>&amp;New Document</string>
</property>
<property name="shortcut">
<string>Ctrl+N</string>
</property>
</action>
<action name="actionOpen_Document">
<property name="text">
<string>&amp;Open Document</string>
</property>
<property name="shortcut">
<string>Ctrl+O</string>
</property>
</action>
</widget> </widget>
<resources> <resources>
<include location="resources.qrc"/> <include location="resources.qrc"/>
@ -211,101 +218,5 @@
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection>
<sender>actionDisplay_Panel</sender>
<signal>toggled(bool)</signal>
<receiver>parseTreeDock</receiver>
<slot>setVisible(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>680</x>
<y>129</y>
</hint>
</hints>
</connection>
<connection>
<sender>parseTreeDock</sender>
<signal>visibilityChanged(bool)</signal>
<receiver>actionDisplay_Panel</receiver>
<slot>setChecked(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>680</x>
<y>129</y>
</hint>
<hint type="destinationlabel">
<x>-1</x>
<y>-1</y>
</hint>
</hints>
</connection>
<connection>
<sender>actionFile_Panel</sender>
<signal>toggled(bool)</signal>
<receiver>fileDock</receiver>
<slot>setVisible(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>79</x>
<y>206</y>
</hint>
</hints>
</connection>
<connection>
<sender>fileDock</sender>
<signal>visibilityChanged(bool)</signal>
<receiver>actionFile_Panel</receiver>
<slot>setChecked(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>79</x>
<y>206</y>
</hint>
<hint type="destinationlabel">
<x>-1</x>
<y>-1</y>
</hint>
</hints>
</connection>
<connection>
<sender>actionPreview_Panel</sender>
<signal>toggled(bool)</signal>
<receiver>skinPreviewDock</receiver>
<slot>setVisible(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>680</x>
<y>112</y>
</hint>
</hints>
</connection>
<connection>
<sender>skinPreviewDock</sender>
<signal>visibilityChanged(bool)</signal>
<receiver>actionPreview_Panel</receiver>
<slot>setChecked(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>680</x>
<y>112</y>
</hint>
<hint type="destinationlabel">
<x>-1</x>
<y>-1</y>
</hint>
</hints>
</connection>
</connections> </connections>
</ui> </ui>