Pencil2D  ff90c0872e88be3bf81c548cd60f01983012ec49
Pencil2D is an animation software for both bitmap and vector graphics. It is free, multi-platform, and open source.
 All Classes Functions
displayoptionwidget.cpp
1 /*
2 
3 Pencil - Traditional Animation Software
4 Copyright (C) 2013-2017 Matt Chiawen Chang
5 
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; version 2 of the License.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14 
15 */
16 
17 #include "displayoptionwidget.h"
18 #include "ui_displayoption.h"
19 
20 #include <QFrame>
21 #include <QToolButton>
22 #include <QGridLayout>
23 #include "preferencemanager.h"
24 #include "scribblearea.h"
25 #include "editor.h"
26 #include "util.h"
27 
28 
29 DisplayOptionWidget::DisplayOptionWidget( QWidget *parent ) : BaseDockWidget( parent )
30 {
31  setWindowTitle( tr( "Display", "Window title of display options like ." ) );
32 
33  QWidget* innerWidget = new QWidget;
34  setWidget( innerWidget );
35 
36  ui = new Ui::DisplayOption;
37  ui->setupUi( innerWidget );
38 }
39 
40 DisplayOptionWidget::~DisplayOptionWidget()
41 {
42 }
43 
44 void DisplayOptionWidget::initUI()
45 {
46  updateUI();
47 }
48 
49 void DisplayOptionWidget::makeConnectionToEditor( Editor* editor )
50 {
51  PreferenceManager* prefs = editor->preference();
52  ScribbleArea* pScriArea = editor->getScribbleArea();
53 
54  connect( ui->thinLinesButton, &QToolButton::clicked, pScriArea, &ScribbleArea::toggleThinLines);
55  connect( ui->outLinesButton, &QToolButton::clicked, pScriArea, &ScribbleArea::toggleOutlines);
56  connect( ui->onionPrevButton, &QToolButton::clicked, this, &DisplayOptionWidget::onionPrevButtonClicked );
57  connect( ui->onionNextButton, &QToolButton::clicked, this, &DisplayOptionWidget::onionNextButtonClicked );
58  connect( ui->onionBlueButton, &QToolButton::clicked, this, &DisplayOptionWidget::onionBlueButtonClicked );
59  connect( ui->onionRedButton, &QToolButton::clicked, this, &DisplayOptionWidget::onionRedButtonClicked );
60  connect( ui->mirrorButton, &QToolButton::clicked, editor, &Editor::toggleMirror);
61  connect( ui->mirrorVButton, &QToolButton::clicked, editor, &Editor::toggleMirrorV);
62  //connect( ui->cameraBorderButton, &QToolButton::clicked, pScriArea, &ScribbleArea::toggleCameraBorder);
63 
64  connect( prefs, &PreferenceManager::optionChanged, this, &DisplayOptionWidget::updateUI );
65 
66  updateUI();
67 
68  //connect(gridAButton, &QToolButton::clicked, pScriArea, &ScribbleArea::toggleGridA);
69  //connect(multiLayerOnionSkinButton, &QToolButton::clicked, pScriArea, &ScribbleArea::toggleMultiLayerOnionSkin);
70 }
71 
72 void DisplayOptionWidget::updateUI()
73 {
74  PreferenceManager* prefs = editor()->preference();
75 
76  SignalBlocker b( ui->thinLinesButton );
77  ui->thinLinesButton->setChecked( prefs->isOn( SETTING::INVISIBLE_LINES ) );
78 
79  SignalBlocker b2( ui->outLinesButton );
80  ui->outLinesButton->setChecked( prefs->isOn( SETTING::OUTLINES ) );
81 
82  SignalBlocker b3( ui->onionPrevButton );
83  ui->onionPrevButton->setChecked( prefs->isOn( SETTING::PREV_ONION ) );
84 
85  SignalBlocker b4( ui->onionNextButton );
86  ui->onionNextButton->setChecked( prefs->isOn( SETTING::NEXT_ONION ) );
87 
88  SignalBlocker b5( ui->onionBlueButton );
89  ui->onionBlueButton->setChecked( prefs->isOn( SETTING::ONION_BLUE ) );
90 
91  SignalBlocker b6( ui->onionRedButton );
92  ui->onionRedButton->setChecked( prefs->isOn( SETTING::ONION_RED ) );
93 
94  SignalBlocker b7( ui->mirrorButton );
95  ui->mirrorButton->setChecked( prefs->isOn( SETTING::MIRROR_H ) );
96 
97  SignalBlocker b8( ui->mirrorVButton );
98  ui->mirrorVButton->setChecked( prefs->isOn( SETTING::MIRROR_V ) );
99 }
100 
101 
102 void DisplayOptionWidget::onionPrevButtonClicked( bool isOn )
103 {
104  PreferenceManager* prefs = editor()->preference();
105  prefs->set( SETTING::PREV_ONION, isOn );
106 }
107 
108 void DisplayOptionWidget::onionNextButtonClicked( bool isOn )
109 {
110  PreferenceManager* prefs = editor()->preference();
111  prefs->set( SETTING::NEXT_ONION, isOn );
112 }
113 
114 void DisplayOptionWidget::onionBlueButtonClicked( bool isOn )
115 {
116  PreferenceManager* prefs = editor()->preference();
117  prefs->set( SETTING::ONION_BLUE, isOn );
118 }
119 
120 void DisplayOptionWidget::onionRedButtonClicked( bool isOn )
121 {
122  PreferenceManager* prefs = editor()->preference();
123  prefs->set( SETTING::ONION_RED, isOn );
124 }
Definition: editor.h:45