diff --git a/utils/themeeditor/editorwindow.cpp b/utils/themeeditor/editorwindow.cpp index 0721ee9131..675520dc28 100644 --- a/utils/themeeditor/editorwindow.cpp +++ b/utils/themeeditor/editorwindow.cpp @@ -27,6 +27,7 @@ #include #include #include +#include EditorWindow::EditorWindow(QWidget *parent) : QMainWindow(parent), @@ -136,7 +137,18 @@ void EditorWindow::setupUI() parseStatus = new QLabel(this); ui->statusbar->addPermanentWidget(parseStatus); + /* Setting the selection for parse tree highlighting initially NULL */ 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() diff --git a/utils/themeeditor/editorwindow.h b/utils/themeeditor/editorwindow.h index 0dee4a1e6e..6f73735100 100644 --- a/utils/themeeditor/editorwindow.h +++ b/utils/themeeditor/editorwindow.h @@ -31,6 +31,7 @@ #include "skindocument.h" #include "configdocument.h" #include "preferencesdialog.h" +#include "skinviewer.h" class ProjectModel; class TabContent; @@ -86,6 +87,7 @@ private: QLabel* parseStatus; ProjectModel* project; QItemSelectionModel* parseTreeSelection; + SkinViewer* viewer; }; #endif // EDITORWINDOW_H diff --git a/utils/themeeditor/editorwindow.ui b/utils/themeeditor/editorwindow.ui index 11cfb6b94f..10e2c524c6 100644 --- a/utils/themeeditor/editorwindow.ui +++ b/utils/themeeditor/editorwindow.ui @@ -40,7 +40,7 @@ 0 0 628 - 27 + 25 @@ -79,10 +79,10 @@ 2 - + - + @@ -296,7 +296,6 @@ projectTree - skinPreview parseTree fromTree editorTabs diff --git a/utils/themeeditor/skinviewer.cpp b/utils/themeeditor/skinviewer.cpp new file mode 100644 index 0000000000..152450e149 --- /dev/null +++ b/utils/themeeditor/skinviewer.cpp @@ -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); +} diff --git a/utils/themeeditor/skinviewer.h b/utils/themeeditor/skinviewer.h new file mode 100644 index 0000000000..599a204fd7 --- /dev/null +++ b/utils/themeeditor/skinviewer.h @@ -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 +#include + +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 diff --git a/utils/themeeditor/skinviewer.ui b/utils/themeeditor/skinviewer.ui new file mode 100644 index 0000000000..ed260d0650 --- /dev/null +++ b/utils/themeeditor/skinviewer.ui @@ -0,0 +1,42 @@ + + + SkinViewer + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + + + + + + + Zoom In + + + + + + + Zoom Out + + + + + + + + + + diff --git a/utils/themeeditor/themeeditor.pro b/utils/themeeditor/themeeditor.pro index c336edf2f5..ef3f4995ff 100644 --- a/utils/themeeditor/themeeditor.pro +++ b/utils/themeeditor/themeeditor.pro @@ -18,7 +18,8 @@ HEADERS += tag_table.h \ codeeditor.h \ projectmodel.h \ tabcontent.h \ - configdocument.h + configdocument.h \ + skinviewer.h SOURCES += tag_table.c \ skin_parser.c \ skin_scan.c \ @@ -32,7 +33,8 @@ SOURCES += tag_table.c \ preferencesdialog.cpp \ codeeditor.cpp \ projectmodel.cpp \ - configdocument.cpp + configdocument.cpp \ + skinviewer.cpp OTHER_FILES += README \ resources/windowicon.png \ resources/appicon.xcf \ @@ -42,5 +44,6 @@ OTHER_FILES += README \ resources/document-new.png FORMS += editorwindow.ui \ preferencesdialog.ui \ - configdocument.ui + configdocument.ui \ + skinviewer.ui RESOURCES += resources.qrc