1
0
Fork 0
forked from len0rd/rockbox

Theme Editor: Mocked up most of the UI, added View menu items for all dockable widgets

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26520 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Robert Bieber 2010-06-03 20:05:55 +00:00
parent 88160b6e27
commit 69dce7cc2d
4 changed files with 256 additions and 20 deletions

View file

@ -22,7 +22,8 @@
#include "editorwindow.h" #include "editorwindow.h"
#include "ui_editorwindow.h" #include "ui_editorwindow.h"
#include <iostream> #include <QDesktopWidget>
#include <QFileSystemModel>
EditorWindow::EditorWindow(QWidget *parent) : EditorWindow::EditorWindow(QWidget *parent) :
QMainWindow(parent), QMainWindow(parent),
@ -37,10 +38,25 @@ EditorWindow::EditorWindow(QWidget *parent) :
void EditorWindow::loadSettings() void EditorWindow::loadSettings()
{ {
/* When there are settings to load, they'll be loaded here */ /* When there are settings to load, they'll be loaded here */
/* For now, we'll just set the window to take up most of the screen */
QDesktopWidget* desktop = QApplication::desktop();
QRect availableSpace = desktop->availableGeometry(desktop->primaryScreen());
QRect buffer(availableSpace.left() + availableSpace.width() / 10,
availableSpace.top() + availableSpace.height() / 10,
availableSpace.width() * 8 / 10,
availableSpace.height() * 8 / 10);
this->setGeometry(buffer);
} }
void EditorWindow::setupUI() void EditorWindow::setupUI()
{ {
/* Displaying some files to test the file tree view */
QFileSystemModel* model = new QFileSystemModel;
model->setRootPath(QDir::currentPath());
ui->fileTree->setModel(model);
/* Establishing the parse tree */ /* Establishing the parse tree */
tree = new ParseTreeModel(ui->codeEdit->document()->toPlainText(). tree = new ParseTreeModel(ui->codeEdit->document()->toPlainText().
toAscii()); toAscii());
@ -70,9 +86,14 @@ void EditorWindow::codeChanged()
ui->parseTree->expandAll(); ui->parseTree->expandAll();
} }
void EditorWindow::closeEvent(QCloseEvent* event)
{
event->accept();
}
void EditorWindow::updateCode() void EditorWindow::updateCode()
{ {
tree->genCode(); if(tree)
ui->codeEdit->document()->setPlainText(tree->genCode()); ui->codeEdit->document()->setPlainText(tree->genCode());
} }

View file

@ -37,6 +37,9 @@ public:
EditorWindow(QWidget *parent = 0); EditorWindow(QWidget *parent = 0);
~EditorWindow(); ~EditorWindow();
protected:
virtual void closeEvent(QCloseEvent* event);
private slots: private slots:
void updateCode(); void updateCode();
void codeChanged(); void codeChanged();

View file

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>800</width> <width>628</width>
<height>400</height> <height>433</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -33,7 +33,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>800</width> <width>628</width>
<height>25</height> <height>25</height>
</rect> </rect>
</property> </property>
@ -41,19 +41,93 @@
<property name="title"> <property name="title">
<string>File</string> <string>File</string>
</property> </property>
<addaction name="actionPreferences"/>
<addaction name="separator"/>
<addaction name="actionQuit"/> <addaction name="actionQuit"/>
</widget> </widget>
<widget class="QMenu" name="menuView">
<property name="title">
<string>View</string>
</property>
<addaction name="actionPreview_Panel"/>
<addaction name="actionDisplay_Panel"/>
<addaction name="actionFile_Panel"/>
</widget>
<addaction name="menuFile"/> <addaction name="menuFile"/>
<addaction name="menuView"/>
</widget> </widget>
<widget class="QStatusBar" name="statusbar"/> <widget class="QStatusBar" name="statusbar"/>
<widget class="QDockWidget" name="outputDock"> <widget class="QDockWidget" name="skinPreviewDock">
<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">
<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>
<widget class="QGraphicsView" name="skinPreview"/>
</item>
</layout>
</widget>
</widget>
<widget class="QToolBar" name="toolBar">
<property name="windowTitle">
<string>toolBar</string>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>true</bool>
</attribute>
</widget>
<widget class="QDockWidget" name="fileDock">
<attribute name="dockWidgetArea">
<number>1</number>
</attribute>
<widget class="QWidget" name="dockWidgetContents_2">
<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>
<widget class="QTreeView" name="fileTree"/>
</item>
</layout>
</widget>
</widget>
<widget class="QDockWidget" name="parseTreeDock">
<attribute name="dockWidgetArea">
<number>2</number>
</attribute>
<widget class="QWidget" name="dockWidgetContents_3">
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_3">
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_2"> <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>
@ -65,8 +139,6 @@
</widget> </widget>
</item> </item>
</layout> </layout>
</item>
</layout>
</widget> </widget>
</widget> </widget>
<action name="actionQuit"> <action name="actionQuit">
@ -77,6 +149,47 @@
<string>Ctrl+Q</string> <string>Ctrl+Q</string>
</property> </property>
</action> </action>
<action name="actionDisplay_Panel">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="text">
<string>Parse Tree Panel</string>
</property>
<property name="shortcut">
<string>Ctrl+D</string>
</property>
</action>
<action name="actionPreferences">
<property name="text">
<string>Preferences</string>
</property>
</action>
<action name="actionFile_Panel">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="text">
<string>File Panel</string>
</property>
</action>
<action name="actionPreview_Panel">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="text">
<string>Preview Panel</string>
</property>
</action>
</widget> </widget>
<resources/> <resources/>
<connections> <connections>
@ -96,5 +209,101 @@
</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>

View file

@ -131,6 +131,9 @@ int ParseTreeModel::rowCount(const QModelIndex &parent) const
int ParseTreeModel::columnCount(const QModelIndex &parent) const int ParseTreeModel::columnCount(const QModelIndex &parent) const
{ {
if(parent.isValid())
return numColumns;
else
return numColumns; return numColumns;
} }