Subversion Repositories Scribus

Rev

Rev 2185 | Rev 2229 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
710 cbradney 1
#include <qgroupbox.h>
2
#include <qtoolbutton.h>
3
#include <qlayout.h>
4
#include <qtooltip.h>
5
 
167 Franz 6
#include "styleselect.h"
7
#include "styleselect.moc"
8
 
9
extern QPixmap loadIcon(QString nam);
10
 
11
StyleSelect::StyleSelect(QWidget* parent) : QWidget(parent, "StyleSelect")
12
{
710 cbradney 13
        ssLayout = new QHBoxLayout( this, 0, 0, "ssLayout");
167 Franz 14
 
2188 fschmid 15
        buttonGroup3 = new QGroupBox( this, "buttonGroup" );
16
        buttonGroup3->setFrameShape( QGroupBox::NoFrame );
17
        buttonGroup3->setTitle("");
18
        buttonGroup3->setColumnLayout(0, Qt::Vertical );
19
        buttonGroup3->layout()->setSpacing( 0 );
20
        buttonGroup3->layout()->setMargin( 0 );
21
        buttonGroup3Layout = new QHBoxLayout( buttonGroup3->layout() );
22
        buttonGroup3Layout->setAlignment( Qt::AlignTop );
23
        underlineButton = new QToolButton( buttonGroup3, "underlineButton" );
710 cbradney 24
        underlineButton->setText( "" );
2185 fschmid 25
        underlineButton->setMaximumSize( QSize( 22, 22 ) );
26
        underlineButton->setPixmap(loadIcon("Unter.xpm"));
27
        underlineButton->setToggleButton( true );
2188 fschmid 28
        buttonGroup3Layout->addWidget( underlineButton );
29
        underlineWordButton = new QToolButton( buttonGroup3, "underlineButton" );
30
        underlineWordButton->setText( "" );
31
        underlineWordButton->setMaximumSize( QSize( 22, 22 ) );
32
        underlineWordButton->setPixmap(loadIcon("wordsOnly.png"));
33
        underlineWordButton->setToggleButton( true );
34
        buttonGroup3Layout->addWidget( underlineWordButton );
35
        ssLayout->addWidget( buttonGroup3 );
167 Franz 36
 
2185 fschmid 37
        buttonGroup = new QGroupBox( this, "buttonGroup" );
38
        buttonGroup->setFrameShape( QGroupBox::NoFrame );
39
        buttonGroup->setTitle("");
40
        buttonGroup->setColumnLayout(0, Qt::Vertical );
41
        buttonGroup->layout()->setSpacing( 0 );
42
        buttonGroup->layout()->setMargin( 0 );
43
        buttonGroupLayout = new QHBoxLayout( buttonGroup->layout() );
44
        buttonGroupLayout->setAlignment( Qt::AlignTop );
45
        subscriptButton = new QToolButton( buttonGroup, "subscriptButton" );
710 cbradney 46
        subscriptButton->setText( "" );
2185 fschmid 47
        subscriptButton->setMaximumSize( QSize( 22, 22 ) );
48
        subscriptButton->setPixmap(loadIcon("Tief.xpm"));
49
        subscriptButton->setToggleButton( true );
50
        buttonGroupLayout->addWidget( subscriptButton );
51
        superscriptButton = new QToolButton( buttonGroup, "superscriptButton" );
710 cbradney 52
        superscriptButton->setText( "" );
2185 fschmid 53
        superscriptButton->setMaximumSize( QSize( 22, 22 ) );
54
        superscriptButton->setPixmap(loadIcon("Hoch.xpm"));
55
        superscriptButton->setToggleButton( true );
56
        buttonGroupLayout->addWidget( superscriptButton );
57
        ssLayout->addWidget( buttonGroup );
167 Franz 58
 
2185 fschmid 59
        buttonGroup2 = new QGroupBox( this, "buttonGroup" );
60
        buttonGroup2->setFrameShape( QGroupBox::NoFrame );
61
        buttonGroup2->setTitle("");
62
        buttonGroup2->setColumnLayout(0, Qt::Vertical );
63
        buttonGroup2->layout()->setSpacing( 0 );
64
        buttonGroup2->layout()->setMargin( 0 );
65
        buttonGroup2Layout = new QHBoxLayout( buttonGroup2->layout() );
66
        buttonGroup2Layout->setAlignment( Qt::AlignTop );
67
        allcapsButton = new QToolButton( buttonGroup2, "allcapsButton" );
68
        allcapsButton->setMaximumSize( QSize( 22, 22 ) );
69
        allcapsButton->setText("");
70
        allcapsButton->setPixmap(loadIcon("AllCaps.png"));
71
        allcapsButton->setToggleButton( true );
72
        buttonGroup2Layout->addWidget( allcapsButton );
73
        smallcapsButton = new QToolButton( buttonGroup2, "smallcapsButton" );
74
        smallcapsButton->setMaximumSize( QSize( 22, 22 ) );
75
        smallcapsButton->setText("");
76
        smallcapsButton->setPixmap(loadIcon("Kapital.xpm"));
77
        smallcapsButton->setToggleButton( true );
78
        buttonGroup2Layout->addWidget( smallcapsButton );
79
        ssLayout->addWidget( buttonGroup2 );
80
 
81
        strikeoutButton = new QToolButton( this, "strikeoutButton" );
710 cbradney 82
        strikeoutButton->setText( "" );
2185 fschmid 83
        strikeoutButton->setMaximumSize( QSize( 22, 22 ) );
84
        strikeoutButton->setPixmap(loadIcon("Strike.xpm"));
85
        strikeoutButton->setToggleButton( true );
86
        ssLayout->addWidget( strikeoutButton );
167 Franz 87
 
2185 fschmid 88
        outlineButton = new QToolButton( this, "outlineButton" );
710 cbradney 89
        outlineButton->setText( "" );
2185 fschmid 90
        outlineButton->setMaximumSize( QSize( 22, 22 ) );
91
        outlineButton->setPixmap(loadIcon("outlined.png"));
92
        outlineButton->setToggleButton( true );
93
        ssLayout->addWidget( outlineButton );
710 cbradney 94
 
2185 fschmid 95
        QToolTip::add( underlineButton, tr( "Underline" ) );
2188 fschmid 96
        QToolTip::add( underlineWordButton, tr( "Underline Words only" ) );
2185 fschmid 97
        QToolTip::add( allcapsButton, tr( "All Caps" ) );
98
        QToolTip::add( smallcapsButton, tr( "Small Caps" ) );
99
        QToolTip::add( subscriptButton, tr( "Subscript" ) );
100
        QToolTip::add( superscriptButton, tr( "Superscript" ) );
101
        QToolTip::add( strikeoutButton, tr( "Strike Out" ) );
102
        QToolTip::add( outlineButton, tr( "Outline" ) );
710 cbradney 103
 
2185 fschmid 104
        connect(allcapsButton, SIGNAL(clicked()), this, SLOT(setTypeStyle()));
105
        connect(smallcapsButton, SIGNAL(clicked()), this, SLOT(setTypeStyle()));
106
        connect(underlineButton, SIGNAL(clicked()), this, SLOT(setTypeStyle()));
2188 fschmid 107
        connect(underlineWordButton, SIGNAL(clicked()), this, SLOT(setTypeStyle()));
2185 fschmid 108
        connect(subscriptButton, SIGNAL(clicked()), this, SLOT(setTypeStyle()));
109
        connect(strikeoutButton, SIGNAL(clicked()), this, SLOT(setTypeStyle()));
110
        connect(superscriptButton, SIGNAL(clicked()), this, SLOT(setTypeStyle()));
111
        connect(outlineButton, SIGNAL(clicked()), this, SLOT(setTypeStyle()));
710 cbradney 112
 
2185 fschmid 113
        resize(minimumSizeHint());
173 Franz 114
}
167 Franz 115
 
116
void StyleSelect::setStyle(int s)
117
{
710 cbradney 118
        superscriptButton->setOn(false);
119
        subscriptButton->setOn(false);
120
        strikeoutButton->setOn(false);
121
        underlineButton->setOn(false);
2188 fschmid 122
        underlineWordButton->setOn(false);
2185 fschmid 123
        allcapsButton->setOn(false);
710 cbradney 124
        smallcapsButton->setOn(false);
125
        outlineButton->setOn(false);
167 Franz 126
        if (s & 1)
710 cbradney 127
                superscriptButton->setOn(true);
167 Franz 128
        if (s & 2)
710 cbradney 129
                subscriptButton->setOn(true);
167 Franz 130
        if (s & 4)
710 cbradney 131
                outlineButton->setOn(true);
167 Franz 132
        if (s & 8)
710 cbradney 133
                underlineButton->setOn(true);
167 Franz 134
        if (s & 16)
710 cbradney 135
                strikeoutButton->setOn(true);
2185 fschmid 136
        if (s & 32)
137
                allcapsButton->setOn(true);
167 Franz 138
        if (s & 64)
710 cbradney 139
                smallcapsButton->setOn(true);
2188 fschmid 140
        if (s & 512)
141
                underlineWordButton->setOn(true);
167 Franz 142
}
143
 
144
int StyleSelect::getStyle()
145
{
146
        int ret = 0;
710 cbradney 147
        if (superscriptButton->isOn())
167 Franz 148
                ret |= 1;
710 cbradney 149
        if (subscriptButton->isOn())
167 Franz 150
                ret |= 2;
710 cbradney 151
        if (outlineButton->isOn())
167 Franz 152
                ret |= 4;
710 cbradney 153
        if (underlineButton->isOn())
167 Franz 154
                ret |= 8;
710 cbradney 155
        if (strikeoutButton->isOn())
167 Franz 156
                ret |= 16;
2185 fschmid 157
        if (allcapsButton->isOn())
158
                ret |= 32;
710 cbradney 159
        if (smallcapsButton->isOn())
167 Franz 160
                ret |= 64;
2188 fschmid 161
        if (underlineWordButton->isOn())
162
                ret |= 512;
167 Franz 163
        return ret;
164
}
165
 
166
void StyleSelect::setTypeStyle()
167
{
710 cbradney 168
        if (superscriptButton == sender())
169
                subscriptButton->setOn(false);
170
        if (subscriptButton == sender())
171
                superscriptButton->setOn(false);
2185 fschmid 172
        if (allcapsButton == sender())
173
                smallcapsButton->setOn(false);
174
        if (smallcapsButton == sender())
175
                allcapsButton->setOn(false);
2188 fschmid 176
        if (underlineWordButton == sender())
177
                underlineButton->setOn(false);
178
        if (underlineButton == sender())
179
                underlineWordButton->setOn(false);
174 Franz 180
        emit State(getStyle());
167 Franz 181
}
182