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
|
//
// C++ Implementation: FontDialog
//
// Description:
//
//
// Author: Andras Mantia <amantia@kdewebdev.org>, (C) 2008
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "fontdialog.h"
#include "kommanderplugin.h"
#include "specials.h"
#include <tdefontdialog.h>
#include <kiconloader.h>
#include <tdelocale.h>
enum Functions {
FirstFunction = 139,
SetFont,
Family,
PointSize,
Bold,
Italic,
LastFunction
};
FontDialog::FontDialog(TQWidget *parent, const char *name)
: TQLabel(parent, name), KommanderWidget(TQT_TQOBJECT(this))
{
TQStringList states;
states << "default";
setStates(states);
setDisplayStates(states);
if (KommanderWidget::inEditor)
{
setPixmap(TDEGlobal::iconLoader()->loadIcon("tdefontcombo", TDEIcon::NoGroup, TDEIcon::SizeMedium));
setFrameStyle(TQFrame::Box | TQFrame::Plain);
setLineWidth(1);
setFixedSize(pixmap()->size());
}
else
setHidden(true);
KommanderPlugin::setDefaultGroup(Group::DCOP);
KommanderPlugin::registerFunction(SetFont, "setFont(TQString widget, TQString family, int pointSize, bool bold, bool italic)",
i18n("Sets the default font for the dialog, by specifying the family, the size and other style options."), 2, 5);
KommanderPlugin::registerFunction(Family, "family(TQString widget)",
i18n("Returns the font family."), 1);
KommanderPlugin::registerFunction(PointSize, "pointSize(TQString widget)",
i18n("Returns the font size in point."), 1);
KommanderPlugin::registerFunction(Bold, "bold(TQString widget)",
i18n("Returns true, if the font is bold."), 1);
KommanderPlugin::registerFunction(Italic, "italic(TQString widget)",
i18n("Returns true, if the font is italic."), 1);
}
FontDialog::~FontDialog()
{
}
TQString FontDialog::currentState() const
{
return TQString("default");
}
bool FontDialog::isKommanderWidget() const
{
return true;
}
TQStringList FontDialog::associatedText() const
{
return KommanderWidget::associatedText();
}
void FontDialog::setAssociatedText(const TQStringList& a_at)
{
KommanderWidget::setAssociatedText(a_at);
}
void FontDialog::setWidgetText(const TQString& a_text)
{
KommanderWidget::setAssociatedText(a_text);
}
void FontDialog::setPopulationText(const TQString& a_text)
{
KommanderWidget::setPopulationText(a_text);
}
TQString FontDialog::populationText() const
{
return KommanderWidget::populationText();
}
void FontDialog::populate()
{
setAssociatedText(KommanderWidget::evalAssociatedText( populationText()));
}
bool FontDialog::isFunctionSupported(int f)
{
return (f > FirstFunction && f < LastFunction) || f == DCOP::execute;
}
TQString FontDialog::handleDCOP(int function, const TQStringList& args)
{
switch (function) {
case SetFont:
{
m_font.setFamily(args[0]);
if (args[1].isEmpty())
m_font.setPointSize(12);
else
m_font.setPointSize(args[1].toInt());
m_font.setBold(args[2] == "1" || args[2].upper() == "TRUE");
m_font.setItalic(args[3] == "1" || args[3].upper() == "TRUE");
break;
}
case Family:
{
return m_font.family();
break;
}
case PointSize:
{
return TQString::number(m_font.pointSize());
break;
}
case Bold:
{
return m_font.bold() ? "1" : "0";
}
case Italic:
{
return m_font.italic() ? "1" : "0";
}
case DCOP::execute:
{
int result = TDEFontDialog::getFont( m_font );
if ( result == TDEFontDialog::Accepted )
{
return m_font.toString();
}
break;
}
default:
return KommanderWidget::handleDCOP(function, args);
}
return TQString();
}
#include "fontdialog.moc"
|