1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
|
/* This file is part of the KDE project
Copyright (C) 2005 Thomas Zander <[email protected]>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; version 2.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include <tqtoolbutton.h>
#include <tqslider.h>
#include <tqgroupbox.h>
#include <tqlayout.h>
#include <tqbuttongroup.h>
#include <tqobject.h>
#include <tqevent.h>
#include <kiconloader.h>
#include <kdebug.h>
#include <tdelocale.h>
#include <knuminput.h>
#include "KPrRotationDialogImpl.h"
#include "rotationpropertyui.h"
#include "KPrTextPreview.h"
KPrRotationDialogImpl::KPrRotationDialogImpl( TQWidget *parent, const char* name )
: KDialogBase( parent, name, true, i18n( "Rotation"), Ok|Cancel|Apply, Ok, true )
, m_dialog( new RotationPropertyUI( this, name ) )
{
noSignals = false;
m_preview = new KPrTextPreview( m_dialog->previewPanel );
TQHBoxLayout *lay = new TQHBoxLayout( m_dialog->previewPanel, m_dialog->previewPanel->lineWidth(), 0 );
lay->addWidget( m_preview );
TQHBoxLayout *hbox = new TQHBoxLayout(m_dialog->angleFrame);
m_angleGroup = new KPrCircleGroup(m_dialog->angleFrame);
hbox->addWidget(m_angleGroup);
// Draw the circle of checkboxes.
TQGridLayout *circleLayout = new TQGridLayout(m_angleGroup, 4, 5);
circleLayout->addItem(new TQSpacerItem ( 1, 1 , TQSizePolicy::MinimumExpanding ), 0, 0);
circleLayout->addItem(new TQSpacerItem ( 1, 1 , TQSizePolicy::MinimumExpanding ), 0, 5);
KPrCircleToggle *r0 = new KPrCircleToggle(m_angleGroup, "tm", 0);
KPrCircleToggle *r45 = new KPrCircleToggle(m_angleGroup, "tr", 45);
KPrCircleToggle *r90 = new KPrCircleToggle(m_angleGroup, "mr", 90);
KPrCircleToggle *r135 = new KPrCircleToggle(m_angleGroup, "br", 135);
KPrCircleToggle *r180 = new KPrCircleToggle(m_angleGroup, "bm", 180);
KPrCircleToggle *r225 = new KPrCircleToggle(m_angleGroup, "bl", -135);
KPrCircleToggle *r270 = new KPrCircleToggle(m_angleGroup, "ml", -90);
KPrCircleToggle *r315 = new KPrCircleToggle(m_angleGroup, "tl", -45);
circleLayout->addWidget(r0, 0, 2);
circleLayout->addWidget(r180, 2, 2);
circleLayout->addWidget(r45, 0, 3);
circleLayout->addWidget(r135, 2, 3);
circleLayout->addWidget(r315, 0, 1);
circleLayout->addWidget(r225, 2, 1);
circleLayout->addWidget(r90, 1, 3);
circleLayout->addWidget(r270, 1, 1);
connect( m_angleGroup, TQT_SIGNAL (clicked (int)),
this, TQT_SLOT( angleMode( int ) ) );
connect (m_dialog->angleSlider, TQT_SIGNAL( valueChanged (int ) ),
this, TQT_SLOT( angleMode( int ) ) );
connect (m_dialog->angleSpinbox, TQT_SIGNAL (valueChanged (double) ),
this, TQT_SLOT( angleChanged( double ) ) );
connect( this, TQT_SIGNAL( okClicked() ), this, TQT_SLOT( slotOk() ) );
setMainWidget( m_dialog );
}
void KPrRotationDialogImpl::slotOk()
{
emit apply();
accept();
}
void KPrRotationDialogImpl::setAngle( double angle )
{
if(noSignals) return;
noSignals = true;
int roundedAngle = (int) (angle + (angle >=0 ? 0.5:-0.5));
m_dialog->angleSlider->setValue( roundedAngle );
if(roundedAngle == -180)
roundedAngle = 180;
m_angleGroup->setAngle(roundedAngle);
m_dialog->angleSpinbox->setValue( angle );
m_preview->setAngle( angle );
noSignals = false;
}
double KPrRotationDialogImpl::angle()
{
return m_dialog->angleSpinbox->value();
}
void KPrRotationDialogImpl::angleChanged( double angle )
{
setAngle( angle );
}
void KPrRotationDialogImpl::angleMode( int angle )
{
setAngle( angle );
}
KPrCircleToggle::KPrCircleToggle( TQWidget *parent, const TQString &image, int id )
: TQLabel( parent )
{
TDEIconLoader il("kpresenter");
m_off = il.loadIcon("rotate/" + image, TDEIcon::NoGroup, 28);
m_on = il.loadIcon("rotate/" + image + "dn", TDEIcon::NoGroup, 28);
m_selected = false;
m_id = id;
setMouseTracking(true);
setPixmap( m_off );
KPrCircleGroup *cg = dynamic_cast<KPrCircleGroup*> (parent);
if(cg != 0)
cg->add(this);
}
void KPrCircleToggle::mousePressEvent ( TQMouseEvent * e ) {
if(e->button() != Qt:: LeftButton)
return;
setChecked(!m_selected);
}
void KPrCircleToggle::setChecked(bool on) {
if(on == m_selected) return;
m_selected = on;
setPixmap( m_selected?m_on:m_off );
emit clicked(m_id);
}
KPrCircleGroup::KPrCircleGroup(TQWidget *parent)
: TQFrame(parent), m_buttons()
{
noSignals=false;
}
void KPrCircleGroup::setAngle(int angle) {
noSignals = true;
KPrCircleToggle *button;
for ( button = m_buttons.first(); button; button = m_buttons.next() )
button->setChecked(angle == button->id());
noSignals = false;
}
void KPrCircleGroup::add(KPrCircleToggle *button) {
connect (button, TQT_SIGNAL(clicked (int)), this, TQT_SLOT (selectionChanged (int)) );
m_buttons.append(button);
}
void KPrCircleGroup::selectionChanged(int buttonId) {
if(noSignals)
return;
KPrCircleToggle *button;
for ( button = m_buttons.first(); button; button = m_buttons.next() )
button->setChecked(buttonId == button->id());
emit clicked(buttonId);
}
#include "KPrRotationDialogImpl.moc"
|