1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2010 Robert Bieber
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #include "skinviewer.h"
23 #include "ui_skinviewer.h"
25 SkinViewer::SkinViewer(QWidget
*parent
) :
27 ui(new Ui::SkinViewer
)
31 QObject::connect(ui
->zoomOutButton
, SIGNAL(pressed()),
32 this, SLOT(zoomOut()));
33 QObject::connect(ui
->zoomInButton
, SIGNAL(pressed()),
34 this, SLOT(zoomIn()));
35 QObject::connect(ui
->zoomEvenButton
, SIGNAL(pressed()),
36 this, SLOT(zoomEven()));
40 SkinViewer::~SkinViewer()
45 void SkinViewer::changeEvent(QEvent
*e
)
47 QWidget::changeEvent(e
);
49 case QEvent::LanguageChange
:
50 ui
->retranslateUi(this);
57 void SkinViewer::connectSkin(SkinDocument
*skin
)
61 ui
->viewer
->setScene(skin
->scene());
62 QObject::connect(skin
, SIGNAL(antiSync(bool)),
63 ui
->codeGenButton
, SLOT(setEnabled(bool)));
64 QObject::connect(skin
, SIGNAL(antiSync(bool)),
65 ui
->codeUndoButton
, SLOT(setEnabled(bool)));
67 QObject::connect(ui
->codeGenButton
, SIGNAL(pressed()),
68 skin
, SLOT(genCode()));
69 QObject::connect(ui
->codeUndoButton
, SIGNAL(pressed()),
70 skin
, SLOT(parseCode()));
72 QObject::connect(skin
->scene(), SIGNAL(mouseMoved(QString
)),
73 ui
->coordinateLabel
, SLOT(setText(QString
)));
79 ui
->viewer
->setScene(0);
80 ui
->coordinateLabel
->setText("");
86 if(skin
&& !skin
->isSynced())
91 ui
->codeGenButton
->setEnabled(antiSync
);
92 ui
->codeUndoButton
->setEnabled(antiSync
);
95 void SkinViewer::zoomIn()
97 ui
->viewer
->scale(1.2, 1.2);
100 void SkinViewer::zoomOut()
102 ui
->viewer
->scale(1/1.2, 1/1.2);
105 void SkinViewer::zoomEven()
107 ui
->viewer
->resetTransform();