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:
parent
88160b6e27
commit
69dce7cc2d
4 changed files with 256 additions and 20 deletions
|
@ -22,7 +22,8 @@
|
|||
#include "editorwindow.h"
|
||||
#include "ui_editorwindow.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <QDesktopWidget>
|
||||
#include <QFileSystemModel>
|
||||
|
||||
EditorWindow::EditorWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
|
@ -37,10 +38,25 @@ EditorWindow::EditorWindow(QWidget *parent) :
|
|||
void EditorWindow::loadSettings()
|
||||
{
|
||||
/* 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()
|
||||
{
|
||||
/* 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 */
|
||||
tree = new ParseTreeModel(ui->codeEdit->document()->toPlainText().
|
||||
toAscii());
|
||||
|
@ -70,10 +86,15 @@ void EditorWindow::codeChanged()
|
|||
ui->parseTree->expandAll();
|
||||
}
|
||||
|
||||
void EditorWindow::closeEvent(QCloseEvent* event)
|
||||
{
|
||||
event->accept();
|
||||
}
|
||||
|
||||
void EditorWindow::updateCode()
|
||||
{
|
||||
tree->genCode();
|
||||
ui->codeEdit->document()->setPlainText(tree->genCode());
|
||||
if(tree)
|
||||
ui->codeEdit->document()->setPlainText(tree->genCode());
|
||||
}
|
||||
|
||||
EditorWindow::~EditorWindow()
|
||||
|
|
|
@ -37,6 +37,9 @@ public:
|
|||
EditorWindow(QWidget *parent = 0);
|
||||
~EditorWindow();
|
||||
|
||||
protected:
|
||||
virtual void closeEvent(QCloseEvent* event);
|
||||
|
||||
private slots:
|
||||
void updateCode();
|
||||
void codeChanged();
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>400</height>
|
||||
<width>628</width>
|
||||
<height>433</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -33,7 +33,7 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<width>628</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -41,30 +41,102 @@
|
|||
<property name="title">
|
||||
<string>File</string>
|
||||
</property>
|
||||
<addaction name="actionPreferences"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionQuit"/>
|
||||
</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="menuView"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<widget class="QDockWidget" name="outputDock">
|
||||
<widget class="QDockWidget" name="skinPreviewDock">
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>2</number>
|
||||
</attribute>
|
||||
<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">
|
||||
<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>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Parse Tree</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>parseTree</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTreeView" name="parseTree"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="fromTree">
|
||||
<property name="text">
|
||||
<string>Update Code</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
@ -77,6 +149,47 @@
|
|||
<string>Ctrl+Q</string>
|
||||
</property>
|
||||
</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>
|
||||
<resources/>
|
||||
<connections>
|
||||
|
@ -96,5 +209,101 @@
|
|||
</hint>
|
||||
</hints>
|
||||
</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>
|
||||
</ui>
|
||||
|
|
|
@ -131,7 +131,10 @@ int ParseTreeModel::rowCount(const QModelIndex &parent) const
|
|||
|
||||
int ParseTreeModel::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
return numColumns;
|
||||
if(parent.isValid())
|
||||
return numColumns;
|
||||
else
|
||||
return numColumns;
|
||||
}
|
||||
|
||||
QVariant ParseTreeModel::data(const QModelIndex &index, int role) const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue