1
0
Fork 0
forked from len0rd/rockbox

Theme Editor: Began working on skin preview viewer

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26874 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Robert Bieber 2010-06-17 00:40:07 +00:00
parent 6c94ce590d
commit 604b17aa08
7 changed files with 183 additions and 7 deletions

View file

@ -27,6 +27,7 @@
#include <QFileSystemModel> #include <QFileSystemModel>
#include <QSettings> #include <QSettings>
#include <QFileDialog> #include <QFileDialog>
#include <QGraphicsScene>
EditorWindow::EditorWindow(QWidget *parent) : EditorWindow::EditorWindow(QWidget *parent) :
QMainWindow(parent), QMainWindow(parent),
@ -136,7 +137,18 @@ void EditorWindow::setupUI()
parseStatus = new QLabel(this); parseStatus = new QLabel(this);
ui->statusbar->addPermanentWidget(parseStatus); ui->statusbar->addPermanentWidget(parseStatus);
/* Setting the selection for parse tree highlighting initially NULL */
parseTreeSelection = 0; parseTreeSelection = 0;
/* Adding the skin viewer */
viewer = new SkinViewer(this);
ui->skinPreviewLayout->addWidget(viewer);
//TODO: Remove this test code
QGraphicsScene* test = new QGraphicsScene();
test->addRect(0,0,50,50);
viewer->setScene(test);
} }
void EditorWindow::setupMenus() void EditorWindow::setupMenus()

View file

@ -31,6 +31,7 @@
#include "skindocument.h" #include "skindocument.h"
#include "configdocument.h" #include "configdocument.h"
#include "preferencesdialog.h" #include "preferencesdialog.h"
#include "skinviewer.h"
class ProjectModel; class ProjectModel;
class TabContent; class TabContent;
@ -86,6 +87,7 @@ private:
QLabel* parseStatus; QLabel* parseStatus;
ProjectModel* project; ProjectModel* project;
QItemSelectionModel* parseTreeSelection; QItemSelectionModel* parseTreeSelection;
SkinViewer* viewer;
}; };
#endif // EDITORWINDOW_H #endif // EDITORWINDOW_H

View file

@ -40,7 +40,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>628</width> <width>628</width>
<height>27</height> <height>25</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuFile"> <widget class="QMenu" name="menuFile">
@ -79,10 +79,10 @@
<attribute name="dockWidgetArea"> <attribute name="dockWidgetArea">
<number>2</number> <number>2</number>
</attribute> </attribute>
<widget class="QWidget" name="dockWidgetContents"> <widget class="QWidget" name="skinPreviewContents">
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item> <item>
<widget class="QGraphicsView" name="skinPreview"/> <layout class="QVBoxLayout" name="skinPreviewLayout"/>
</item> </item>
</layout> </layout>
</widget> </widget>
@ -296,7 +296,6 @@
</widget> </widget>
<tabstops> <tabstops>
<tabstop>projectTree</tabstop> <tabstop>projectTree</tabstop>
<tabstop>skinPreview</tabstop>
<tabstop>parseTree</tabstop> <tabstop>parseTree</tabstop>
<tabstop>fromTree</tabstop> <tabstop>fromTree</tabstop>
<tabstop>editorTabs</tabstop> <tabstop>editorTabs</tabstop>

View file

@ -0,0 +1,67 @@
/***************************************************************************
* __________ __ ___.
* 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 "skinviewer.h"
#include "ui_skinviewer.h"
SkinViewer::SkinViewer(QWidget *parent) :
QWidget(parent),
ui(new Ui::SkinViewer)
{
ui->setupUi(this);
QObject::connect(ui->zoomOutButton, SIGNAL(pressed()),
this, SLOT(zoomOut()));
QObject::connect(ui->zoomInButton, SIGNAL(pressed()),
this, SLOT(zoomIn()));
}
SkinViewer::~SkinViewer()
{
delete ui;
}
void SkinViewer::changeEvent(QEvent *e)
{
QWidget::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}
void SkinViewer::setScene(QGraphicsScene *scene)
{
ui->viewer->setScene(scene);
}
void SkinViewer::zoomIn()
{
ui->viewer->scale(1.2, 1.2);
}
void SkinViewer::zoomOut()
{
ui->viewer->scale(1/1.2, 1/1.2);
}

View file

@ -0,0 +1,51 @@
/***************************************************************************
* __________ __ ___.
* 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 SKINVIEWER_H
#define SKINVIEWER_H
#include <QWidget>
#include <QGraphicsScene>
namespace Ui {
class SkinViewer;
}
class SkinViewer : public QWidget {
Q_OBJECT
public:
SkinViewer(QWidget *parent = 0);
~SkinViewer();
void setScene(QGraphicsScene* scene);
public slots:
void zoomIn();
void zoomOut();
protected:
void changeEvent(QEvent *e);
private:
Ui::SkinViewer *ui;
};
#endif // SKINVIEWER_H

View file

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SkinViewer</class>
<widget class="QWidget" name="SkinViewer">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGraphicsView" name="viewer"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QToolButton" name="zoomInButton">
<property name="text">
<string>Zoom In</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="zoomOutButton">
<property name="text">
<string>Zoom Out</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View file

@ -18,7 +18,8 @@ HEADERS += tag_table.h \
codeeditor.h \ codeeditor.h \
projectmodel.h \ projectmodel.h \
tabcontent.h \ tabcontent.h \
configdocument.h configdocument.h \
skinviewer.h
SOURCES += tag_table.c \ SOURCES += tag_table.c \
skin_parser.c \ skin_parser.c \
skin_scan.c \ skin_scan.c \
@ -32,7 +33,8 @@ SOURCES += tag_table.c \
preferencesdialog.cpp \ preferencesdialog.cpp \
codeeditor.cpp \ codeeditor.cpp \
projectmodel.cpp \ projectmodel.cpp \
configdocument.cpp configdocument.cpp \
skinviewer.cpp
OTHER_FILES += README \ OTHER_FILES += README \
resources/windowicon.png \ resources/windowicon.png \
resources/appicon.xcf \ resources/appicon.xcf \
@ -42,5 +44,6 @@ OTHER_FILES += README \
resources/document-new.png resources/document-new.png
FORMS += editorwindow.ui \ FORMS += editorwindow.ui \
preferencesdialog.ui \ preferencesdialog.ui \
configdocument.ui configdocument.ui \
skinviewer.ui
RESOURCES += resources.qrc RESOURCES += resources.qrc