~ubuntu-branches/ubuntu/edgy/psi/edgy

« back to all changes in this revision

Viewing changes to src/options/opt_appearance.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Lucas Nussbaum
  • Date: 2006-03-28 11:11:02 UTC
  • mfrom: (2.1.2 etch)
  • Revision ID: james.westby@ubuntu.com-20060328111102-v1diqpbwqr4yijoy
Tags: 0.10-2build1
Manual sync from Debian. No Ubuntu-specific changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#include "opt_appearance.h"
 
2
#include "opt_iconset.h"
2
3
#include "common.h"
3
4
#include "iconwidget.h"
4
5
 
5
6
#include <qwhatsthis.h>
6
7
#include <qcheckbox.h>
 
8
#include <qslider.h>
 
9
#include <qlabel.h>
7
10
#include <qcombobox.h>
8
11
#include <qbuttongroup.h>
9
12
#include <qradiobutton.h>
14
17
#include <qlineedit.h>
15
18
 
16
19
#include "opt_appearance-ui.h"
 
20
#include "opt_appearance_misc-ui.h"
17
21
 
18
22
//----------------------------------------------------------------------------
19
23
// FontLabel
47
51
        return QSize(QLineEdit::sizeHint().width(), m_defaultHeight);
48
52
}
49
53
 
 
54
 
50
55
//----------------------------------------------------------------------------
51
56
// OptionsTabAppearance
52
57
//----------------------------------------------------------------------------
53
 
 
54
 
OptionsTabAppearance::OptionsTabAppearance(QObject *parent)
55
 
: OptionsTab(parent, "appearance", "", tr("Appearance"), tr("Psi's Appearance"), "psi/ok")
 
58
OptionsTabAppearance::OptionsTabAppearance(QObject *parent) : MetaOptionsTab(parent, "appearance", "", tr("Appearance"), tr("Psi's Appearance"), "psi/appearance")
 
59
{    
 
60
        addTab( new OptionsTabAppearanceGeneral(this) );
 
61
        addTab( new OptionsTabIconsetEmoticons(this) );
 
62
        addTab( new OptionsTabIconsetRoster(this) );
 
63
        addTab( new OptionsTabIconsetSystem(this) );
 
64
        addTab( new OptionsTabAppearanceMisc(this) );
 
65
}
 
66
 
 
67
//----------------------------------------------------------------------------
 
68
// OptionsTabAppearanceMisc
 
69
//----------------------------------------------------------------------------
 
70
 
 
71
OptionsTabAppearanceMisc::OptionsTabAppearanceMisc(QObject *parent)
 
72
: OptionsTab(parent, "appearance_misc", "", tr("Misc."), tr("Miscellaneous Settings"))
 
73
{
 
74
        w = 0;
 
75
        o = new Options;
 
76
}
 
77
 
 
78
OptionsTabAppearanceMisc::~OptionsTabAppearanceMisc()
 
79
{
 
80
        delete o;
 
81
}
 
82
 
 
83
QWidget *OptionsTabAppearanceMisc::widget()
 
84
{
 
85
        if ( w )
 
86
                return 0;
 
87
 
 
88
        w = new OptAppearanceMiscUI();
 
89
 
 
90
#if defined(Q_WS_X11) || (QT_VERSION < 0x030300)
 
91
        OptAppearanceMiscUI *d = (OptAppearanceMiscUI *)w;
 
92
        d->gb_opacity->hide();
 
93
#endif
 
94
 
 
95
        return w;
 
96
}
 
97
 
 
98
void OptionsTabAppearanceMisc::applyOptions(Options *opt)
 
99
{
 
100
        if ( !w )
 
101
                return;
 
102
 
 
103
        OptAppearanceMiscUI *d = (OptAppearanceMiscUI *)w;
 
104
 
 
105
        opt->clNewHeadings = d->ck_newHeadings->isChecked();    
 
106
        opt->outlineHeadings = d->ck_outlineHeadings->isChecked();      
 
107
        opt->rosterOpacity = d->sl_rosterop->value();
 
108
        opt->chatOpacity = d->sl_chatdlgop->value();
 
109
}
 
110
 
 
111
void OptionsTabAppearanceMisc::restoreOptions(const Options *opt)
 
112
{
 
113
        if ( !w )
 
114
                return;
 
115
 
 
116
        OptAppearanceMiscUI *d = (OptAppearanceMiscUI *)w;
 
117
 
 
118
        d->ck_newHeadings->setChecked( opt->clNewHeadings );
 
119
        d->ck_outlineHeadings->setChecked( opt->outlineHeadings );
 
120
        
 
121
        d->sl_rosterop->setValue( opt->rosterOpacity );
 
122
        d->sl_chatdlgop->setValue( opt->chatOpacity );
 
123
}
 
124
 
 
125
void OptionsTabAppearanceMisc::setData(PsiCon *, QWidget *parentDialog)
 
126
{
 
127
        parentWidget = parentDialog;
 
128
}
 
129
 
 
130
//----------------------------------------------------------------------------
 
131
// OptionsTabAppearanceGeneral: Fonts & Colours
 
132
//----------------------------------------------------------------------------
 
133
 
 
134
OptionsTabAppearanceGeneral::OptionsTabAppearanceGeneral(QObject *parent)
 
135
: OptionsTab(parent, "appearance_general", "", tr("Fonts && Colors"), tr("Fonts && Color Settings"))
56
136
{
57
137
        w = 0;
58
138
        bg_font = 0;
60
140
        o = new Options;
61
141
}
62
142
 
63
 
OptionsTabAppearance::~OptionsTabAppearance()
 
143
OptionsTabAppearanceGeneral::~OptionsTabAppearanceGeneral()
64
144
{
65
145
        if ( bg_font )
66
146
                delete bg_font;
83
163
        return pix;
84
164
}
85
165
 
86
 
QWidget *OptionsTabAppearance::widget()
 
166
QWidget *OptionsTabAppearanceGeneral::widget()
87
167
{
88
168
        if ( w )
89
169
                return 0;
123
203
        bg_color->insert(d->pb_cOffline, 1);
124
204
        bg_color->insert(d->pb_cAway, 2);
125
205
        bg_color->insert(d->pb_cDND, 3);
126
 
        bg_color->insert(d->pb_cGroupFore, 4);
127
 
        bg_color->insert(d->pb_cGroupBack, 5);
128
 
        bg_color->insert(d->pb_cListBack, 6);
129
 
        bg_color->insert(d->pb_cAnimFront, 7);
130
 
        bg_color->insert(d->pb_cAnimBack, 8);
 
206
        bg_color->insert(d->pb_cProfileFore, 4);
 
207
        bg_color->insert(d->pb_cProfileBack, 5);
 
208
        bg_color->insert(d->pb_cGroupFore, 6);
 
209
        bg_color->insert(d->pb_cGroupBack, 7);
 
210
        bg_color->insert(d->pb_cListBack, 8);
 
211
        bg_color->insert(d->pb_cAnimFront, 9);
 
212
        bg_color->insert(d->pb_cAnimBack, 10);
131
213
        connect(bg_color, SIGNAL(clicked(int)), SLOT(chooseColor(int)));
132
214
 
133
215
        QString s = tr("Specifies the text color for a contact name in the main window when that user is \"%1\".");
139
221
                s.arg(tr("away")));
140
222
        QWhatsThis::add(d->pb_cDND,
141
223
                s.arg(tr("do not disturb")));
 
224
        QWhatsThis::add(d->pb_cProfileBack,
 
225
                tr("Specifies the background color for an account name in the main window."));
142
226
        QWhatsThis::add(d->pb_cGroupBack,
143
227
                tr("Specifies the background color for a group name in the main window."));
144
228
        QWhatsThis::add(d->pb_cListBack,
155
239
        return w;
156
240
}
157
241
 
158
 
void OptionsTabAppearance::applyOptions(Options *opt)
 
242
void OptionsTabAppearanceGeneral::applyOptions(Options *opt)
159
243
{
160
244
        if ( !w )
161
245
                return;
167
251
        for (n = 0; n < 4; ++n)
168
252
                opt->font[n] = le_font[n]->fontName();
169
253
 
170
 
        for (n = 0; n < 9; ++n)
 
254
        for (n = 0; n < 11; ++n)
171
255
                opt->color[n] = o->color[n];
172
256
}
173
257
 
174
 
void OptionsTabAppearance::restoreOptions(const Options *opt)
 
258
void OptionsTabAppearanceGeneral::restoreOptions(const Options *opt)
175
259
{
176
260
        if ( !w )
177
261
                return;
183
267
        for (n = 0; n < 4; ++n)
184
268
                le_font[n]->setFont(opt->font[n]);
185
269
 
186
 
        for (n = 0; n < 9; ++n) {
 
270
        for (n = 0; n < 11; ++n) {
187
271
                o->color[n] = opt->color[n];
188
272
                ((QPushButton *)bg_color->find(n))->setPixmap(name2color(opt->color[n].name()));
189
273
        }
190
274
}
191
275
 
192
 
void OptionsTabAppearance::setData(PsiCon *, QWidget *parentDialog)
 
276
void OptionsTabAppearanceGeneral::setData(PsiCon *, QWidget *parentDialog)
193
277
{
194
278
        parentWidget = parentDialog;
195
279
}
196
280
 
197
 
void OptionsTabAppearance::chooseFont(int x)
 
281
void OptionsTabAppearanceGeneral::chooseFont(int x)
198
282
{
199
283
        bool ok;
200
284
        QFont font;
207
291
                emit dataChanged();
208
292
}
209
293
 
210
 
void OptionsTabAppearance::chooseColor(int x)
 
294
void OptionsTabAppearanceGeneral::chooseColor(int x)
211
295
{
212
296
        QColor c = o->color[x];
213
297