summaryrefslogtreecommitdiff
path: root/core/apps/textedit/fontDialog.cpp
Unidiff
Diffstat (limited to 'core/apps/textedit/fontDialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/fontDialog.cpp237
1 files changed, 0 insertions, 237 deletions
diff --git a/core/apps/textedit/fontDialog.cpp b/core/apps/textedit/fontDialog.cpp
deleted file mode 100644
index 5cdf538..0000000
--- a/core/apps/textedit/fontDialog.cpp
+++ b/dev/null
@@ -1,237 +0,0 @@
1/****************************************************************************
2** Created: Sun Jan 27 11:03:24 2002 fileDialog.cpp
3copyright 2002 by L.J. Potter ljp@llornkcor.com
4
5** This file may be distributed and/or modified under the terms of the
6** GNU General Public License version 2 as published by the Free Software
7** Foundation and appearing in the file LICENSE.GPL included in the
8** packaging of this file.
9**
10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
12**
13****************************************************************************/
14#include "fontDialog.h"
15
16#include <qpe/fontdatabase.h>
17#include <qpe/config.h>
18
19#include <qstringlist.h>
20#include <qfontinfo.h>
21#include <qvaluelist.h>
22#include <qpe/qpeapplication.h>
23
24#include <qgroupbox.h>
25#include <qlabel.h>
26#include <qlistbox.h>
27#include <qmultilineedit.h>
28#include <qpushbutton.h>
29#include <qlayout.h>
30#include <qvariant.h>
31#include <qtooltip.h>
32#include <qwhatsthis.h>
33
34FontDialog::FontDialog( QWidget * parent, const char* name , bool modal, WFlags fl )
35 :QDialog /*QWidget*/( parent, name , modal, fl )
36{
37 if ( !name )
38 setName( tr("FontDialog") );
39 setCaption( tr( "Font Dialog" ) );
40 FontTextLabel4 = new QLabel( this, "TextLabel4" );
41 FontTextLabel4->setGeometry( QRect( 145, 100, 30, 19 /*192, 0, 43, 19*/ ) );
42 FontTextLabel4->setText( tr( "Size" ) );
43
44 FamilyGroup = new QGroupBox( this, "FamilyGroup" );
45 FamilyGroup->setGeometry( QRect( 5, 5, 115, 135 /*0, 6, 185, 131 */) );
46 FamilyGroup->setTitle( tr( "Font" ) );
47
48 familyListBox = new QListBox( FamilyGroup, "familyListBox" );
49 familyListBox->setGeometry( QRect( 5, 20, 100, 105 /* 6, 18, 170, 105 */) );
50
51 GroupBox2 = new QGroupBox( this, "GroupBox2" );
52 GroupBox2->setGeometry( QRect( 120, 5, 100, 90/* 0, 138, 170, 90*/ ) );
53 GroupBox2->setTitle( tr( "Font Style" ) );
54
55 styleListBox = new QListBox( GroupBox2, "styleListBox" );
56 styleListBox->setGeometry( QRect( 5, 20, 90, 60 /*10, 20, 150, 61*/ ) );
57
58 sizeListBox = new QListBox( this, "sizeListBox" );
59 sizeListBox->setGeometry( QRect( 180, 100, 40, 60 /* 192, 24, 40, 108 */) );
60
61 MultiLineEdit1 = new QMultiLineEdit( this, "MultiLineEdit1" );
62 MultiLineEdit1->setGeometry( QRect( 5, 165, 215, 45 /* 6, 234, 222, 55*/ ) );
63 MultiLineEdit1->setText( tr( "The Quick Brown Fox Jumps Over The Lazy Dog" ) );
64 MultiLineEdit1->setWordWrap(QMultiLineEdit::WidgetWidth);
65
66 connect( familyListBox,SIGNAL( highlighted( const QString &)),SLOT( familyListBoxSlot(const QString &) ));
67 connect( styleListBox,SIGNAL( highlighted( const QString &)),SLOT( styleListBoxSlot(const QString &) ));
68 connect( sizeListBox,SIGNAL( highlighted( const QString &)),SLOT( sizeListBoxSlot(const QString &) ));
69
70 populateLists();
71// MultiLineEdit1
72// connect();
73// move(5,15);
74 showMaximized();
75}
76
77FontDialog::~FontDialog()
78{
79}
80
81void FontDialog::familyListBoxSlot(const QString & text)
82{
83 int styleInt=styleListBox->currentItem();
84 int sizeInt=sizeListBox->currentItem();
85
86 styleListBox->clear();
87 sizeListBox->clear();
88 family= text;
89// qDebug(family);
90 QStringList styles = fdb.styles( family ); // string list of styles of our current font family
91 styleListBox->insertStringList( styles);
92 QString dstyle;// = "\t" + style + " (";
93 QValueList<int> smoothies = fdb.smoothSizes( family, styleListBox->text(0) );
94 for ( QValueList<int>::Iterator points = smoothies.begin(); points != smoothies.end(); ++points ) {
95 dstyle = QString::number( *points );
96 sizeListBox ->insertItem( dstyle.left( dstyle.length() - 1 ));
97 }
98 if(styleInt == -1 || styleInt > styleListBox->count() )
99 styleListBox->setCurrentItem(0);
100 else
101 styleListBox->setCurrentItem(styleInt);
102
103 if(sizeInt == -1 || sizeInt > sizeListBox->count())
104 sizeListBox->setCurrentItem(0);
105 else
106 sizeListBox->setCurrentItem(sizeInt);
107
108 changeText();
109}
110
111void FontDialog::styleListBoxSlot(const QString &text)
112{
113 changeText();
114}
115
116void FontDialog::sizeListBoxSlot(const QString & text)
117{
118 changeText();
119}
120
121void FontDialog::populateLists()
122{
123// QFont defaultFont=MultiLineEdit1->font();
124// QFont defaultFont=Lview->font();
125// QFontInfo fontInfo(defaultFont);
126 Config config("TextEdit");
127 config.setGroup("Font");
128 QString familyStr = config.readEntry("Family", "fixed");
129 QString styleStr = config.readEntry("Style", "Regular");
130 QString sizeStr = config.readEntry("Size", "10");
131 QString charSetStr = config.readEntry("CharSet", "iso10646-1" );
132 bool ok;
133 int i_size=sizeStr.toInt(&ok,10);
134 selectedFont = fdb.font(familyStr,styleStr,i_size,charSetStr);
135// defaultFont.setItalic(TRUE);
136 families = fdb.families();
137 for ( QStringList::Iterator f = families.begin(); f != families.end();++f ) {
138 QString family = *f;
139// if(family == defaultFont.family())
140// qDebug(family);
141 familyListBox->insertItem( family);
142
143 if( familyListBox->text(0) == family) {
144 QStringList styles = fdb.styles( family ); // string list of styles of our current font family
145 styleListBox->insertStringList( styles);
146 for ( QStringList::Iterator s = styles.begin(); s != styles.end();++s ) { // for each font style
147 style = *s;
148 QString dstyle;// = "\t" + style + " (";
149 if(styleListBox->text(0) == style) {
150 QValueList<int> smoothies = fdb.smoothSizes( family, style );
151 for ( QValueList<int>::Iterator points = smoothies.begin(); points != smoothies.end(); ++points ) {
152 dstyle = QString::number( *points ) + " ";
153
154 sizeListBox ->insertItem( dstyle.left( dstyle.length() - 1 ));
155 }
156 dstyle = dstyle.left( dstyle.length() - 1 ) + ")";
157 }
158 } // styles
159 }
160 }
161 for(int i=0;i < familyListBox->count();i++) {
162 if( familyListBox->text(i) == familyStr)
163 familyListBox->setSelected( i, TRUE);
164 }
165
166 for(int i=0;i < styleListBox->count();i++) {
167 if( styleListBox->text(i) == styleStr)
168 styleListBox->setSelected( i, TRUE);
169 }
170
171 for(int i=0;i < sizeListBox->count();i++) {
172 if( sizeListBox->text(i) == sizeStr)
173 sizeListBox->setSelected( i, TRUE);
174 }
175 changeText();
176}
177
178void FontDialog::clearListBoxes() {
179 familyListBox->clear();
180 sizeListBox->clear();
181 styleListBox->clear();
182}
183
184void FontDialog::changeText()
185{
186 if( familyListBox->currentItem() == -1)
187 family= familyListBox->text(0);
188 else {
189 family = familyListBox->currentText();
190 }
191// qDebug("Font family is "+family);
192 if( styleListBox->currentItem() == -1)
193 style=styleListBox->text(0);
194 else {
195 style = styleListBox->currentText();
196 }
197// qDebug("font style is "+style);
198 if( sizeListBox->currentItem() == -1 )
199 size= sizeListBox->text(0);
200 else {
201 size = sizeListBox->currentText();
202 }
203
204// qDebug("Font size is "+size);
205 bool ok;
206 int i_size= size.toInt(&ok,10);
207 QStringList charSetList= fdb.charSets(family);
208// QStringList styles = fdb.styles( family ); // string list of styles of our current font family
209 QString charSet;
210 for ( QStringList::Iterator s = charSetList.begin(); s != charSetList.end();++s ) { // for each font style
211 charSet = *s;
212// qDebug(charSet);
213 }
214 selectedFont = fdb.font(family,style,i_size,charSet);
215 QFontInfo fontInfo( selectedFont);
216// if(fontInfo.italic() ) qDebug("italic");
217 selectedFont.setWeight(fontInfo.weight() );
218// qDebug("Style are "+style+" %d ",fontInfo.weight());
219 Config cfg("TextEdit");
220 cfg.setGroup("Font");
221 cfg.writeEntry("Family",family);
222 cfg.writeEntry("Style",style);
223 cfg.writeEntry("Size",size);
224 cfg.writeEntry("CharSet",charSet);
225
226 if(style.find("Italic",0,TRUE) != -1) {
227 selectedFont = fdb.font(family,"Regular",i_size,charSet);
228 selectedFont.setItalic(TRUE); //ya right
229 cfg.writeEntry("Italic","TRUE");
230// qDebug("Style is "+styleListBox->currentText());
231 } else
232 cfg.writeEntry("Italic","FALSE");
233 changedFonts=TRUE;
234 MultiLineEdit1->setFont( selectedFont);
235 MultiLineEdit1->update();
236}
237