kpresenter

KPrPictureProperty.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2005 Thorsten Zachmann <zachmann@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#include "KPrPictureProperty.h"
21
22#include "picturepropertyui.h"
23#include "KPrPicturePreview.h"
24
25#include <knuminput.h>
26#include <tqradiobutton.h>
27#include <tqcheckbox.h>
28#include <tqlayout.h>
29
30KPrPictureProperty::KPrPictureProperty( TQWidget *parent, const char *name, const TQPixmap &pixmap,
31 KPrPictureSettingCmd::PictureSettings pictureSettings )
32: TQWidget( parent, name )
33, m_pictureSettings( pictureSettings )
34{
35 TQVBoxLayout *layout = new TQVBoxLayout( this );
36 layout->addWidget( m_ui = new PicturePropertyUI( this ) );
37
38 connect( m_ui->depth0, TQ_SIGNAL( clicked() ), m_ui->picturePreview, TQ_SLOT( slotPictureDepth0() ) );
39 connect( m_ui->depth1, TQ_SIGNAL( clicked() ), m_ui->picturePreview, TQ_SLOT( slotPictureDepth1() ) );
40 connect( m_ui->depth8, TQ_SIGNAL( clicked() ), m_ui->picturePreview, TQ_SLOT( slotPictureDepth8() ) );
41 connect( m_ui->depth16, TQ_SIGNAL( clicked() ), m_ui->picturePreview, TQ_SLOT( slotPictureDepth16() ) );
42 connect( m_ui->depth32, TQ_SIGNAL( clicked() ), m_ui->picturePreview, TQ_SLOT( slotPictureDepth32() ) );
43
44 connect( m_ui->swapRGB, TQ_SIGNAL( toggled( bool ) ), m_ui->picturePreview, TQ_SLOT( slotSwapRGBPicture( bool ) ) );
45
46 connect( m_ui->grayscale, TQ_SIGNAL( toggled( bool ) ), m_ui->picturePreview, TQ_SLOT( slotGrayscalPicture( bool ) ) );
47
48 connect( m_ui->brightnessInput, TQ_SIGNAL( valueChanged( int ) ), m_ui->picturePreview, TQ_SLOT( slotBrightValue( int ) ) );
49
50 m_ui->picturePreview->setPicturePixmap( pixmap );
51
52 slotReset();
53}
54
55
56KPrPictureProperty::~KPrPictureProperty()
57{
58}
59
60
61int KPrPictureProperty::getPicturePropertyChange() const
62{
63 int flags = 0;
64
65 KPrPictureSettingCmd::PictureSettings pictureSettings = getPictureSettings();
66
67 if ( pictureSettings.depth != m_pictureSettings.depth )
68 flags |= KPrPictureSettingCmd::Depth;
69
70 if ( pictureSettings.swapRGB != m_pictureSettings.swapRGB )
71 flags |= KPrPictureSettingCmd::SwapRGB;
72
73 if ( pictureSettings.grayscal != m_pictureSettings.grayscal )
74 flags |= KPrPictureSettingCmd::Grayscal;
75
76 if ( pictureSettings.bright != m_pictureSettings.bright )
77 flags |= KPrPictureSettingCmd::Bright;
78
79 return flags;
80}
81
82
83KPrPictureSettingCmd::PictureSettings KPrPictureProperty::getPictureSettings() const
84{
85 KPrPictureSettingCmd::PictureSettings pictureSettings;
86 pictureSettings.mirrorType = m_pictureSettings.mirrorType;
87 pictureSettings.depth = m_ui->picturePreview->getDepth();
88 pictureSettings.swapRGB = m_ui->swapRGB->isOn();
89 pictureSettings.grayscal = m_ui->grayscale->isOn();
90 pictureSettings.bright = m_ui->brightnessInput->value();
91 return pictureSettings;
92}
93
94
95void KPrPictureProperty::apply()
96{
97 int flags = getPicturePropertyChange();
98
99 KPrPictureSettingCmd::PictureSettings pictureSettings = getPictureSettings();
100
101 if ( flags & KPrPictureSettingCmd::Depth )
102 m_pictureSettings.depth = pictureSettings.depth;
103
104 if ( flags & KPrPictureSettingCmd::SwapRGB )
105 m_pictureSettings.swapRGB = pictureSettings.swapRGB;
106
107 if ( flags & KPrPictureSettingCmd::Grayscal )
108 m_pictureSettings.grayscal = pictureSettings.grayscal;
109
110 if ( flags & KPrPictureSettingCmd::Bright )
111 m_pictureSettings.bright = pictureSettings.bright;
112}
113
114
115void KPrPictureProperty::slotReset()
116{
117 m_ui->depth0->setChecked( m_pictureSettings.depth == 0 );
118 m_ui->depth1->setChecked( m_pictureSettings.depth == 1 );
119 m_ui->depth8->setChecked( m_pictureSettings.depth == 8 );
120 m_ui->depth16->setChecked( m_pictureSettings.depth == 16 );
121 m_ui->depth32->setChecked( m_pictureSettings.depth == 32 );
122 m_ui->picturePreview->setDepth( m_pictureSettings.depth );
123
124 m_ui->swapRGB->setChecked( m_pictureSettings.swapRGB );
125 m_ui->grayscale->setChecked( m_pictureSettings.grayscal );
126
127 m_ui->brightnessInput->setValue( m_pictureSettings.bright );
128}
129
130
131#include "KPrPictureProperty.moc"