author | sandman <sandman> | 2002-10-01 21:01:04 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-10-01 21:01:04 (UTC) |
commit | 2987dafbdfa6602c5e165fe862546ea32f5fd3ca (patch) (unidiff) | |
tree | 0c3cae31e893a072c1167b27e9331b5d65c28763 /core/apps/textedit | |
parent | 609b04531d5a1caae189397922eb0068aa0e2634 (diff) | |
download | opie-2987dafbdfa6602c5e165fe862546ea32f5fd3ca.zip opie-2987dafbdfa6602c5e165fe862546ea32f5fd3ca.tar.gz opie-2987dafbdfa6602c5e165fe862546ea32f5fd3ca.tar.bz2 |
- replaced the custom font selector with OFontSelector
- fixed the broken Config handling (Font)
- various cleanups
-rw-r--r-- | core/apps/textedit/fontDialog.cpp | 237 | ||||
-rw-r--r-- | core/apps/textedit/fontDialog.h | 63 | ||||
-rw-r--r-- | core/apps/textedit/textedit.cpp | 124 | ||||
-rw-r--r-- | core/apps/textedit/textedit.pro | 4 |
4 files changed, 49 insertions, 379 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 | ||
3 | copyright 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 | |||
34 | FontDialog::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 | |||
77 | FontDialog::~FontDialog() | ||
78 | { | ||
79 | } | ||
80 | |||
81 | void 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 | |||
111 | void FontDialog::styleListBoxSlot(const QString &text) | ||
112 | { | ||
113 | changeText(); | ||
114 | } | ||
115 | |||
116 | void FontDialog::sizeListBoxSlot(const QString & text) | ||
117 | { | ||
118 | changeText(); | ||
119 | } | ||
120 | |||
121 | void 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 | |||
178 | void FontDialog::clearListBoxes() { | ||
179 | familyListBox->clear(); | ||
180 | sizeListBox->clear(); | ||
181 | styleListBox->clear(); | ||
182 | } | ||
183 | |||
184 | void 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 | |||
diff --git a/core/apps/textedit/fontDialog.h b/core/apps/textedit/fontDialog.h deleted file mode 100644 index ef930df..0000000 --- a/core/apps/textedit/fontDialog.h +++ b/dev/null | |||
@@ -1,63 +0,0 @@ | |||
1 | /**************************************************************************** | ||
2 | ** Created: Sun Jan 27 11:02:59 2002 fileDialog.h | ||
3 | copyright 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 | #ifndef FONTDIALOG_H | ||
15 | #define FONTDIALOG_H | ||
16 | |||
17 | #include <qvariant.h> | ||
18 | #include <qdialog.h> | ||
19 | #include <qpe/fontdatabase.h> | ||
20 | #include <qfont.h> | ||
21 | |||
22 | class QVBoxLayout; | ||
23 | class QHBoxLayout; | ||
24 | class QGridLayout; | ||
25 | class QLabel; | ||
26 | class QListBox; | ||
27 | class QListBoxItem; | ||
28 | class QPushButton; | ||
29 | class QGroupBox; | ||
30 | class QMultiLineEdit; | ||
31 | |||
32 | class FontDialog : public QDialog// QWidget | ||
33 | { | ||
34 | Q_OBJECT | ||
35 | |||
36 | public: | ||
37 | FontDialog( QWidget * parent = 0, const char* name = 0 , bool modal=FALSE, WFlags fl = 0 ); | ||
38 | ~FontDialog(); | ||
39 | |||
40 | QLabel *FontTextLabel4; | ||
41 | QGroupBox *FamilyGroup, *GroupBox2; | ||
42 | QListBox *familyListBox, *styleListBox, *sizeListBox; | ||
43 | QMultiLineEdit *MultiLineEdit1; | ||
44 | QPushButton *PushButtonOk,*PushButtonCancel; | ||
45 | QStringList families; | ||
46 | |||
47 | FontDatabase fdb; | ||
48 | QString family, style, size; | ||
49 | QFont selectedFont; | ||
50 | bool changedFonts; | ||
51 | void populateLists(); | ||
52 | void clearListBoxes(); | ||
53 | void changeText(); | ||
54 | protected slots: | ||
55 | |||
56 | void familyListBoxSlot(const QString &); | ||
57 | void styleListBoxSlot(const QString &); | ||
58 | void sizeListBoxSlot(const QString &); | ||
59 | |||
60 | |||
61 | }; | ||
62 | |||
63 | #endif // FONTDIALOG_H | ||
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index f6a869a..7b50a6c 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -17,28 +17,29 @@ | |||
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | // changes added by L. J. Potter Sun 02-17-2002 21:31:31 | 20 | // changes added by L. J. Potter Sun 02-17-2002 21:31:31 |
21 | /* | 21 | /* |
22 | useAdvancedfeatures = | 22 | useAdvancedfeatures = |
23 | 1) do not prompt on cancel, even if text is edited. | 23 | 1) do not prompt on cancel, even if text is edited. |
24 | 2) prompt user is .desktop file | 24 | 2) prompt user is .desktop file |
25 | 3) prompt user for File Permissions on saveAs | 25 | 3) prompt user for File Permissions on saveAs |
26 | */ | 26 | */ |
27 | #include "textedit.h" | 27 | #include "textedit.h" |
28 | #include "filePermissions.h" | 28 | #include "filePermissions.h" |
29 | #include "fontDialog.h" | 29 | //#include "fontDialog.h" |
30 | 30 | ||
31 | #include <opie/ofileselector.h> | 31 | #include <opie/ofileselector.h> |
32 | #include <opie/ofiledialog.h> | 32 | #include <opie/ofiledialog.h> |
33 | #include <opie/ofontselector.h> | ||
33 | 34 | ||
34 | #include <qpe/fontdatabase.h> | 35 | #include <qpe/fontdatabase.h> |
35 | #include <qpe/global.h> | 36 | #include <qpe/global.h> |
36 | #include <qpe/fileselector.h> | 37 | #include <qpe/fileselector.h> |
37 | #include <qpe/applnk.h> | 38 | #include <qpe/applnk.h> |
38 | #include <qpe/resource.h> | 39 | #include <qpe/resource.h> |
39 | #include <qpe/config.h> | 40 | #include <qpe/config.h> |
40 | #include <qpe/qpeapplication.h> | 41 | #include <qpe/qpeapplication.h> |
41 | #include <qpe/qpemenubar.h> | 42 | #include <qpe/qpemenubar.h> |
42 | #include <qpe/qpetoolbar.h> | 43 | #include <qpe/qpetoolbar.h> |
43 | #include <qpe/qcopenvelope_qws.h> | 44 | #include <qpe/qcopenvelope_qws.h> |
44 | 45 | ||
@@ -48,24 +49,25 @@ | |||
48 | #include <qaction.h> | 49 | #include <qaction.h> |
49 | #include <qcolordialog.h> | 50 | #include <qcolordialog.h> |
50 | #include <qfileinfo.h> | 51 | #include <qfileinfo.h> |
51 | #include <qlineedit.h> | 52 | #include <qlineedit.h> |
52 | #include <qmessagebox.h> | 53 | #include <qmessagebox.h> |
53 | #include <qobjectlist.h> | 54 | #include <qobjectlist.h> |
54 | #include <qpopupmenu.h> | 55 | #include <qpopupmenu.h> |
55 | #include <qspinbox.h> | 56 | #include <qspinbox.h> |
56 | #include <qtoolbutton.h> | 57 | #include <qtoolbutton.h> |
57 | #include <qwidgetstack.h> | 58 | #include <qwidgetstack.h> |
58 | #include <qcheckbox.h> | 59 | #include <qcheckbox.h> |
59 | #include <qcombo.h> | 60 | #include <qcombo.h> |
61 | #include <qlayout.h> | ||
60 | 62 | ||
61 | #include <unistd.h> | 63 | #include <unistd.h> |
62 | #include <sys/stat.h> | 64 | #include <sys/stat.h> |
63 | #include <stdlib.h> //getenv | 65 | #include <stdlib.h> //getenv |
64 | 66 | ||
65 | 67 | ||
66 | /* XPM */ | 68 | /* XPM */ |
67 | static char * filesave_xpm[] = { | 69 | static char * filesave_xpm[] = { |
68 | "16 16 78 1", | 70 | "16 16 78 1", |
69 | " c None", | 71 | " c None", |
70 | ". c #343434", | 72 | ". c #343434", |
71 | "+ c #A0A0A0", | 73 | "+ c #A0A0A0", |
@@ -303,87 +305,55 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
303 | #ifndef QT_NO_CLIPBOARD | 305 | #ifndef QT_NO_CLIPBOARD |
304 | a = new QAction( tr( "Insert Time and Date" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); | 306 | a = new QAction( tr( "Insert Time and Date" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); |
305 | connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) ); | 307 | connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) ); |
306 | a->addTo( edit ); | 308 | a->addTo( edit ); |
307 | #endif | 309 | #endif |
308 | 310 | ||
309 | a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); | 311 | a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); |
310 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); | 312 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); |
311 | edit->insertSeparator(); | 313 | edit->insertSeparator(); |
312 | a->addTo( bar ); | 314 | a->addTo( bar ); |
313 | a->addTo( edit ); | 315 | a->addTo( edit ); |
314 | 316 | ||
315 | int defsize; | ||
316 | bool defb, defi, wrap; | ||
317 | |||
318 | Config cfg("TextEdit"); | ||
319 | cfg.setGroup("View"); | ||
320 | defsize = cfg.readNumEntry("FontSize",10); | ||
321 | defb = cfg.readBoolEntry("Bold",FALSE); | ||
322 | defi = cfg.readBoolEntry("Italic",FALSE); | ||
323 | wrap = cfg.readBoolEntry("Wrap",TRUE); | ||
324 | 317 | ||
325 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); | 318 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); |
326 | connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); | 319 | connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); |
327 | zin->addTo( font ); | 320 | zin->addTo( font ); |
328 | 321 | ||
329 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); | 322 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); |
330 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); | 323 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); |
331 | zout->addTo( font ); | 324 | zout->addTo( font ); |
332 | 325 | ||
333 | font->insertSeparator(); | 326 | font->insertSeparator(); |
334 | 327 | ||
335 | #if 0 | ||
336 | QAction *ba = new QAction( tr("Bold"), QString::null, 0, this, 0 ); | ||
337 | connect( ba, SIGNAL( toggled(bool) ), this, SLOT( setBold(bool) ) ); | ||
338 | ba->setToggleAction(TRUE); | ||
339 | ba->addTo( font ); | ||
340 | |||
341 | QAction *ia = new QAction( tr("Italic"), QString::null, 0, this, 0 ); | ||
342 | connect( ia, SIGNAL( toggled(bool) ), this, SLOT( setItalic(bool) ) ); | ||
343 | ia->setToggleAction(TRUE); | ||
344 | ia->addTo( font ); | ||
345 | |||
346 | ba->setOn(defb); | ||
347 | ia->setOn(defi); | ||
348 | |||
349 | font->insertSeparator(); | ||
350 | #endif | ||
351 | |||
352 | QAction *wa = new QAction( tr("Wrap lines"), QString::null, 0, this, 0 ); | 328 | QAction *wa = new QAction( tr("Wrap lines"), QString::null, 0, this, 0 ); |
353 | connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) ); | 329 | connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) ); |
354 | wa->setToggleAction(TRUE); | 330 | wa->setToggleAction(TRUE); |
355 | wa->addTo( font ); | 331 | wa->addTo( font ); |
356 | 332 | ||
357 | font->insertSeparator(); | 333 | font->insertSeparator(); |
358 | font->insertItem(tr("Font"), this, SLOT(changeFont()) ); | 334 | font->insertItem(tr("Font"), this, SLOT(changeFont()) ); |
359 | 335 | ||
360 | font->insertSeparator(); | 336 | font->insertSeparator(); |
361 | 337 | ||
362 | nStart = new QAction( tr("Start with new file"), QString::null, 0, this, 0 ); | 338 | nStart = new QAction( tr("Start with new file"), QString::null, 0, this, 0 ); |
363 | connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) ); | 339 | connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) ); |
364 | nStart->setToggleAction(TRUE); | 340 | nStart->setToggleAction(TRUE); |
365 | nStart->addTo( font ); | 341 | nStart->addTo( font ); |
366 | 342 | ||
367 | nAdvanced = new QAction( tr("Advanced features"), QString::null, 0, this, 0 ); | 343 | nAdvanced = new QAction( tr("Advanced features"), QString::null, 0, this, 0 ); |
368 | connect( nAdvanced, SIGNAL( toggled(bool) ), this, SLOT( doAdvanced(bool) ) ); | 344 | connect( nAdvanced, SIGNAL( toggled(bool) ), this, SLOT( doAdvanced(bool) ) ); |
369 | nAdvanced->setToggleAction(TRUE); | 345 | nAdvanced->setToggleAction(TRUE); |
370 | nAdvanced->addTo( font ); | 346 | nAdvanced->addTo( font ); |
371 | 347 | ||
372 | if(cfg.readBoolEntry("AdvancedFeatures")) { | ||
373 | qDebug("using advanced features"); | ||
374 | useAdvancedFeatures = true; | ||
375 | nAdvanced->setOn(TRUE); | ||
376 | } else | ||
377 | useAdvancedFeatures = false; | ||
378 | 348 | ||
379 | font->insertSeparator(); | 349 | font->insertSeparator(); |
380 | 350 | ||
381 | font->insertItem(tr("About"), this, SLOT( doAbout()) ); | 351 | font->insertItem(tr("About"), this, SLOT( doAbout()) ); |
382 | 352 | ||
383 | mb->insertItem( tr( "File" ), file ); | 353 | mb->insertItem( tr( "File" ), file ); |
384 | mb->insertItem( tr( "Edit" ), edit ); | 354 | mb->insertItem( tr( "Edit" ), edit ); |
385 | mb->insertItem( tr( "View" ), font ); | 355 | mb->insertItem( tr( "View" ), font ); |
386 | 356 | ||
387 | searchBar = new QPEToolBar(this); | 357 | searchBar = new QPEToolBar(this); |
388 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); | 358 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); |
389 | 359 | ||
@@ -406,69 +376,81 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
406 | edit->insertSeparator(); | 376 | edit->insertSeparator(); |
407 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 377 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
408 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); | 378 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); |
409 | a->addTo( edit ); | 379 | a->addTo( edit ); |
410 | 380 | ||
411 | searchBar->hide(); | 381 | searchBar->hide(); |
412 | 382 | ||
413 | editor = new QpeEditor( this ); | 383 | editor = new QpeEditor( this ); |
414 | setCentralWidget( editor ); | 384 | setCentralWidget( editor ); |
415 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 385 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
416 | connect( editor, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) ); | 386 | connect( editor, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) ); |
417 | 387 | ||
418 | // resize( 200, 300 ); | 388 | Config cfg("TextEdit"); |
389 | |||
390 | cfg. setGroup ( "Font" ); | ||
419 | 391 | ||
420 | // setFontSize(defsize,TRUE); | 392 | QFont defaultFont = editor-> font ( ); |
421 | FontDatabase fdb; | ||
422 | QFont defaultFont=editor->font(); | ||
423 | QFontInfo fontInfo(defaultFont); | ||
424 | 393 | ||
425 | cfg.setGroup("Font"); | 394 | QString family = cfg. readEntry ( "Family", defaultFont. family ( )); |
426 | QString family = cfg.readEntry("Family", fontInfo.family()); | 395 | int size = cfg. readNumEntry ( "Size", defaultFont. pointSize ( )); |
427 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); | 396 | int weight = cfg. readNumEntry ( "Weight", defaultFont. weight ( )); |
428 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); | 397 | bool italic = cfg. readBoolEntry ( "Italic", defaultFont. italic ( )); |
429 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); | ||
430 | 398 | ||
431 | defaultFont = fdb.font(family,style,i_size,charSet); | 399 | defaultFont = QFont ( family, size, weight, italic ); |
432 | editor->setFont( defaultFont); | 400 | editor-> setFont ( defaultFont ); |
433 | 401 | ||
434 | wa->setOn(wrap); | ||
435 | updateCaption(); | 402 | updateCaption(); |
436 | 403 | ||
437 | cfg.setGroup("View"); | 404 | cfg.setGroup ( "View" ); |
405 | |||
406 | useAdvancedFeatures = cfg. readBoolEntry ( "AdvancedFeatures", false ); | ||
407 | |||
408 | if ( useAdvancedFeatures ) | ||
409 | nAdvanced-> setOn ( true ); | ||
410 | |||
411 | bool wrap = cfg. readBoolEntry ( "Wrap", true ); | ||
412 | wa-> setOn ( wrap ); | ||
413 | setWordWrap ( wrap ); | ||
414 | |||
438 | if(cfg.readEntry("startNew","TRUE") == "TRUE") { | 415 | if(cfg.readEntry("startNew","TRUE") == "TRUE") { |
439 | nStart->setOn(TRUE); | 416 | nStart->setOn(TRUE); |
440 | fileNew(); | 417 | fileNew(); |
441 | } else { | 418 | } else { |
442 | fileOpen(); | 419 | fileOpen(); |
443 | } | 420 | } |
444 | 421 | ||
445 | viewSelection = cfg.readNumEntry( "FileView", 0 ); | 422 | viewSelection = cfg.readNumEntry( "FileView", 0 ); |
446 | } | 423 | } |
447 | 424 | ||
448 | TextEdit::~TextEdit() { | 425 | TextEdit::~TextEdit() { |
449 | if( edited1 & !useAdvancedFeatures ) | 426 | if( edited1 & !useAdvancedFeatures ) |
450 | saveAs(); | 427 | saveAs(); |
451 | } | 428 | } |
452 | 429 | ||
453 | void TextEdit::cleanUp() { | 430 | void TextEdit::cleanUp() { |
454 | qDebug("cleanUp");// save(); | 431 | qDebug("cleanUp");// save(); |
455 | Config cfg("TextEdit"); | 432 | |
456 | cfg.setGroup("View"); | 433 | Config cfg ( "TextEdit" ); |
434 | cfg. setGroup ( "Font" ); | ||
457 | QFont f = editor->font(); | 435 | QFont f = editor->font(); |
458 | cfg.writeEntry("FontSize",f.pointSize()); | 436 | cfg. writeEntry ( "Family", f. family ( )); |
459 | cfg.writeEntry("Bold",f.bold()); | 437 | cfg. writeEntry ( "Size", f. pointSize ( )); |
460 | cfg.writeEntry("Italic",f.italic()); | 438 | cfg. writeEntry ( "Weight", f. weight ( )); |
461 | cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); | 439 | cfg. writeEntry ( "Italic", f. italic ( )); |
462 | cfg.writeEntry( "FileView", viewSelection ); | 440 | |
441 | cfg. setGroup ( "View" ); | ||
442 | cfg. writeEntry ( "Wrap", editor-> wordWrap ( ) == QMultiLineEdit::WidgetWidth ); | ||
443 | cfg. writeEntry ( "FileView", viewSelection ); | ||
444 | cfg. writeEntry ( "AdvancedFeatures", useAdvancedFeatures ); | ||
463 | } | 445 | } |
464 | 446 | ||
465 | 447 | ||
466 | void TextEdit::accept() { | 448 | void TextEdit::accept() { |
467 | if( edited1) | 449 | if( edited1) |
468 | saveAs(); | 450 | saveAs(); |
469 | exit(0); | 451 | exit(0); |
470 | } | 452 | } |
471 | 453 | ||
472 | void TextEdit::zoomIn() { | 454 | void TextEdit::zoomIn() { |
473 | setFontSize(editor->font().pointSize()+1,FALSE); | 455 | setFontSize(editor->font().pointSize()+1,FALSE); |
474 | } | 456 | } |
@@ -891,44 +873,35 @@ void TextEdit::setDocument(const QString& fileref) { | |||
891 | editor->setEdited(TRUE); | 873 | editor->setEdited(TRUE); |
892 | edited1=FALSE; | 874 | edited1=FALSE; |
893 | edited=TRUE; | 875 | edited=TRUE; |
894 | doSearchBar(); | 876 | doSearchBar(); |
895 | } | 877 | } |
896 | 878 | ||
897 | void TextEdit::closeEvent( QCloseEvent *e ) { | 879 | void TextEdit::closeEvent( QCloseEvent *e ) { |
898 | bFromDocView = FALSE; | 880 | bFromDocView = FALSE; |
899 | e->accept(); | 881 | e->accept(); |
900 | } | 882 | } |
901 | 883 | ||
902 | void TextEdit::changeFont() { | 884 | void TextEdit::changeFont() { |
903 | FontDatabase fdb; | 885 | QDialog *d = new QDialog ( this, "FontDialog", true ); |
904 | QFont defaultFont=editor->font(); | 886 | d-> setCaption ( tr( "Choose font" )); |
905 | QFontInfo fontInfo(defaultFont); | 887 | QBoxLayout *lay = new QVBoxLayout ( d ); |
906 | Config cfg("TextEdit"); | 888 | OFontSelector *ofs = new OFontSelector ( true, d ); |
907 | cfg.setGroup("Font"); | 889 | lay-> addWidget ( ofs ); |
908 | QString family = cfg.readEntry("Family", fontInfo.family()); | 890 | ofs-> setSelectedFont ( editor-> font ( )); |
909 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); | ||
910 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); | ||
911 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); | ||
912 | |||
913 | defaultFont = fdb.font(family,style,i_size,charSet); | ||
914 | |||
915 | FontDialog *fontDlg; | ||
916 | fontDlg=new FontDialog(this,tr("FontDialog"),TRUE); | ||
917 | 891 | ||
918 | fontDlg->exec(); | 892 | d-> showMaximized ( ); |
919 | 893 | if ( d-> exec ( ) == QDialog::Accepted ) | |
920 | QFont myFont=fontDlg->selectedFont; | 894 | editor-> setFont ( ofs-> selectedFont ( )); |
921 | editor->setFont( myFont); | 895 | delete d; |
922 | delete fontDlg; | ||
923 | 896 | ||
924 | } | 897 | } |
925 | 898 | ||
926 | void TextEdit::editDelete() { | 899 | void TextEdit::editDelete() { |
927 | switch ( QMessageBox::warning(this,tr("Text Editor"),tr("Do you really want<BR>to <B>delete</B> the current file\nfrom the disk?<BR>This is <B>irreversable!!</B>"),tr("Yes"),tr("No"),0,0,1) ) { | 900 | switch ( QMessageBox::warning(this,tr("Text Editor"),tr("Do you really want<BR>to <B>delete</B> the current file\nfrom the disk?<BR>This is <B>irreversable!!</B>"),tr("Yes"),tr("No"),0,0,1) ) { |
928 | case 0: | 901 | case 0: |
929 | if(doc) { | 902 | if(doc) { |
930 | doc->removeFiles(); | 903 | doc->removeFiles(); |
931 | clear(); | 904 | clear(); |
932 | setCaption( tr("Text Editor") ); | 905 | setCaption( tr("Text Editor") ); |
933 | } | 906 | } |
934 | break; | 907 | break; |
@@ -966,25 +939,22 @@ void TextEdit::receive(const QCString&msg, const QByteArray&) { | |||
966 | } | 939 | } |
967 | 940 | ||
968 | } | 941 | } |
969 | void TextEdit::doAbout() { | 942 | void TextEdit::doAbout() { |
970 | QMessageBox::about(0,tr("Text Edit"),tr("Text Edit is copyright<BR>" | 943 | QMessageBox::about(0,tr("Text Edit"),tr("Text Edit is copyright<BR>" |
971 | "2000 Trolltech AS, and<BR>" | 944 | "2000 Trolltech AS, and<BR>" |
972 | "2002 by <B>L. J. Potter <BR>llornkcor@handhelds.org</B><BR>" | 945 | "2002 by <B>L. J. Potter <BR>llornkcor@handhelds.org</B><BR>" |
973 | "and is licensed under the GPL")); | 946 | "and is licensed under the GPL")); |
974 | } | 947 | } |
975 | 948 | ||
976 | void TextEdit::doAdvanced(bool b) { | 949 | void TextEdit::doAdvanced(bool b) { |
977 | useAdvancedFeatures=b; | 950 | useAdvancedFeatures=b; |
978 | Config cfg("TextEdit"); | ||
979 | cfg.setGroup("View"); | ||
980 | cfg.writeEntry("AdvancedFeatures",b); | ||
981 | } | 951 | } |
982 | 952 | ||
983 | void TextEdit::editPasteTimeDate() { | 953 | void TextEdit::editPasteTimeDate() { |
984 | #ifndef QT_NO_CLIPBOARD | 954 | #ifndef QT_NO_CLIPBOARD |
985 | QClipboard *cb = QApplication::clipboard(); | 955 | QClipboard *cb = QApplication::clipboard(); |
986 | QDateTime dt = QDateTime::currentDateTime(); | 956 | QDateTime dt = QDateTime::currentDateTime(); |
987 | cb->setText( dt.toString()); | 957 | cb->setText( dt.toString()); |
988 | editor->paste(); | 958 | editor->paste(); |
989 | #endif | 959 | #endif |
990 | } | 960 | } |
diff --git a/core/apps/textedit/textedit.pro b/core/apps/textedit/textedit.pro index f6e6530..500abde 100644 --- a/core/apps/textedit/textedit.pro +++ b/core/apps/textedit/textedit.pro | |||
@@ -1,17 +1,17 @@ | |||
1 | TEMPLATE = app | 1 | TEMPLATE = app |
2 | CONFIG += qt warn_on release | 2 | CONFIG += qt warn_on release |
3 | DESTDIR = $(OPIEDIR)/bin | 3 | DESTDIR = $(OPIEDIR)/bin |
4 | HEADERS = textedit.h fontDialog.h filePermissions.h | 4 | HEADERS = textedit.h filePermissions.h |
5 | SOURCES = main.cpp textedit.cpp fontDialog.cpp filePermissions.cpp | 5 | SOURCES = main.cpp textedit.cpp filePermissions.cpp |
6 | INCLUDEPATH += $(OPIEDIR)/include | 6 | INCLUDEPATH += $(OPIEDIR)/include |
7 | DEPENDPATH += $(OPIEDIR)/include | 7 | DEPENDPATH += $(OPIEDIR)/include |
8 | LIBS += -lqpe -lopie | 8 | LIBS += -lqpe -lopie |
9 | TARGET = textedit | 9 | TARGET = textedit |
10 | 10 | ||
11 | TRANSLATIONS = ../../../i18n/de/textedit.ts \ | 11 | TRANSLATIONS = ../../../i18n/de/textedit.ts \ |
12 | ../../../i18n/en/textedit.ts \ | 12 | ../../../i18n/en/textedit.ts \ |
13 | ../../../i18n/es/textedit.ts \ | 13 | ../../../i18n/es/textedit.ts \ |
14 | ../../../i18n/fr/textedit.ts \ | 14 | ../../../i18n/fr/textedit.ts \ |
15 | ../../../i18n/hu/textedit.ts \ | 15 | ../../../i18n/hu/textedit.ts \ |
16 | ../../../i18n/ja/textedit.ts \ | 16 | ../../../i18n/ja/textedit.ts \ |
17 | ../../../i18n/ko/textedit.ts \ | 17 | ../../../i18n/ko/textedit.ts \ |