author | llornkcor <llornkcor> | 2002-02-24 07:39:56 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-02-24 07:39:56 (UTC) |
commit | f7be370d10a69cfe78b04687fe728b32d566083a (patch) (unidiff) | |
tree | 6e586d6543cfd3a60e9734b515642bd86fc052cd | |
parent | f1c800025cf759ca0d6257a42f548216d217b16b (diff) | |
download | opie-f7be370d10a69cfe78b04687fe728b32d566083a.zip opie-f7be370d10a69cfe78b04687fe728b32d566083a.tar.gz opie-f7be370d10a69cfe78b04687fe728b32d566083a.tar.bz2 |
added file permissions dialog
-rw-r--r-- | core/apps/textedit/filePermissions.cpp | 274 | ||||
-rw-r--r-- | core/apps/textedit/filePermissions.h | 56 | ||||
-rw-r--r-- | core/apps/textedit/fileSaver.cpp | 8 | ||||
-rw-r--r-- | core/apps/textedit/fileSaver.h | 2 | ||||
-rw-r--r-- | core/apps/textedit/opie-textedit.control | 2 | ||||
-rw-r--r-- | core/apps/textedit/textedit.cpp | 75 | ||||
-rw-r--r-- | core/apps/textedit/textedit.pro | 4 |
7 files changed, 387 insertions, 34 deletions
diff --git a/core/apps/textedit/filePermissions.cpp b/core/apps/textedit/filePermissions.cpp new file mode 100644 index 0000000..1938b84 --- a/dev/null +++ b/core/apps/textedit/filePermissions.cpp | |||
@@ -0,0 +1,274 @@ | |||
1 | /**************************************************************************** | ||
2 | ** copyright 2002 ljp ljp@llornkcor.com | ||
3 | ** Created: Sat Feb 23 19:44:40 2002 L.J. Potter | ||
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 "filePermissions.h" | ||
15 | |||
16 | #include <qfile.h> | ||
17 | #include <qfileinfo.h> | ||
18 | |||
19 | #include <qcheckbox.h> | ||
20 | #include <qlabel.h> | ||
21 | #include <qlineedit.h> | ||
22 | #include <qlayout.h> | ||
23 | #include <qvariant.h> | ||
24 | #include <qtooltip.h> | ||
25 | #include <qmessagebox.h> | ||
26 | |||
27 | #include <unistd.h> | ||
28 | #include <sys/stat.h> | ||
29 | #include <stdlib.h> | ||
30 | #include <sys/types.h> | ||
31 | #include <pwd.h> | ||
32 | #include <grp.h> | ||
33 | |||
34 | filePermissions::filePermissions( QWidget* parent, const char* name, bool modal, WFlags fl, const QString &fileName ) | ||
35 | : QDialog( parent, name, modal, fl ) | ||
36 | { | ||
37 | if ( !name ) | ||
38 | setName( "filePermissions" ); | ||
39 | qDebug("FilePermissions "+fileName); | ||
40 | resize( 236, 210 ); | ||
41 | setMaximumSize( QSize( 236, 210 ) ); | ||
42 | setCaption( tr( "Set File Permissions" ) ); | ||
43 | |||
44 | TextLabel1 = new QLabel( this, "TextLabel1" ); | ||
45 | TextLabel1->setGeometry( QRect( 25, 5, 175, 20 ) ); | ||
46 | TextLabel1->setText( tr( "Set file permissions for:" ) ); | ||
47 | |||
48 | LineEdit1 = new QLineEdit( this, "LineEdit1" ); | ||
49 | LineEdit1->setGeometry( QRect( 10, 25, 218, 22 ) ); | ||
50 | LineEdit1->setReadOnly(true); | ||
51 | |||
52 | TextLabel4 = new QLabel( this, "TextLabel4" ); | ||
53 | TextLabel4->setGeometry( QRect( 5, 85, 50, 15 ) ); | ||
54 | TextLabel4->setText( tr( "owner" ) ); | ||
55 | |||
56 | TextLabel4_2 = new QLabel( this, "TextLabel4_2" ); | ||
57 | TextLabel4_2->setGeometry( QRect( 5, 105, 50, 15 ) ); | ||
58 | TextLabel4_2->setText( tr( "group" ) ); | ||
59 | |||
60 | TextLabel4_3 = new QLabel( this, "TextLabel4_3" ); | ||
61 | TextLabel4_3->setGeometry( QRect( 5, 125, 50, 15 ) ); | ||
62 | TextLabel4_3->setText( tr( "others" ) ); | ||
63 | |||
64 | CheckBox1 = new QCheckBox( this, "CheckBox1" ); | ||
65 | CheckBox1->setGeometry( QRect( 75, 85, 20, 16 ) ); | ||
66 | connect(CheckBox1, SIGNAL(released()),this,SLOT(ownReadCheck())); | ||
67 | |||
68 | CheckBox1_2 = new QCheckBox( this, "CheckBox1_2" ); | ||
69 | CheckBox1_2->setGeometry( QRect( 135, 85, 20, 16 ) ); | ||
70 | connect(CheckBox1_2, SIGNAL(released()),this,SLOT(ownWriteCheck())); | ||
71 | |||
72 | CheckBox1_3 = new QCheckBox( this, "CheckBox1_3" ); | ||
73 | CheckBox1_3->setGeometry( QRect( 195, 85, 20, 16 ) ); | ||
74 | connect(CheckBox1_3, SIGNAL(released()),this,SLOT(ownExeCheck())); | ||
75 | |||
76 | CheckBox1_4 = new QCheckBox( this, "CheckBox1_4" ); | ||
77 | CheckBox1_4->setGeometry( QRect( 75, 105, 20, 16 ) ); | ||
78 | connect(CheckBox1_4, SIGNAL(released()),this,SLOT(grpReadCheck())); | ||
79 | |||
80 | CheckBox1_5 = new QCheckBox( this, "CheckBox1_5" ); | ||
81 | CheckBox1_5->setGeometry( QRect( 135, 105, 20, 16 ) ); | ||
82 | connect(CheckBox1_5, SIGNAL(released()),this,SLOT(grpWriteCheck())); | ||
83 | |||
84 | CheckBox1_6 = new QCheckBox( this, "CheckBox1_6" ); | ||
85 | CheckBox1_6->setGeometry( QRect( 195, 105, 20, 16 ) ); | ||
86 | connect(CheckBox1_6, SIGNAL(released()),this,SLOT(grpExeCheck())); | ||
87 | |||
88 | CheckBox1_7 = new QCheckBox( this, "CheckBox1_7" ); | ||
89 | CheckBox1_7->setGeometry( QRect( 75, 125, 16, 16 ) ); | ||
90 | connect(CheckBox1_7, SIGNAL(released()),this,SLOT(wrldReadCheck())); | ||
91 | |||
92 | CheckBox1_8 = new QCheckBox( this, "CheckBox1_8" ); | ||
93 | CheckBox1_8->setGeometry( QRect( 135, 125, 20, 16 ) ); | ||
94 | connect(CheckBox1_8, SIGNAL(released()),this,SLOT(wrldWriteCheck())); | ||
95 | |||
96 | CheckBox1_8_2 = new QCheckBox( this, "CheckBox1_8_2" ); | ||
97 | CheckBox1_8_2->setGeometry( QRect( 195, 125, 20, 16 ) ); | ||
98 | connect(CheckBox1_8_2, SIGNAL(released()),this,SLOT(wrldExeCheck())); | ||
99 | |||
100 | GroupLineEdit = new QLineEdit( this, "GroupLineEdit" ); | ||
101 | GroupLineEdit->setGeometry( QRect( 125, 155, 106, 22 ) ); | ||
102 | |||
103 | OwnerLineEdit = new QLineEdit( this, "OwnerLineEdit" ); | ||
104 | OwnerLineEdit->setGeometry( QRect( 10, 155, 106, 22 ) ); | ||
105 | |||
106 | TextLabel5 = new QLabel( this, "TextLabel5" ); | ||
107 | TextLabel5->setGeometry( QRect( 45, 180, 40, 16 ) ); | ||
108 | TextLabel5->setText( tr( "Owner" ) ); | ||
109 | |||
110 | TextLabel5_2 = new QLabel( this, "TextLabel5_2" ); | ||
111 | TextLabel5_2->setGeometry( QRect( 155, 180, 40, 16 ) ); | ||
112 | TextLabel5_2->setText( tr( "Group" ) ); | ||
113 | |||
114 | ModeLine = new QLineEdit( this, "TextLabelMode" ); | ||
115 | ModeLine->setGeometry( QRect( 10, 60, 40, 15 ) ); | ||
116 | |||
117 | TextLabel3_2 = new QLabel( this, "TextLabel3_2" ); | ||
118 | TextLabel3_2->setGeometry( QRect( 60, 55, 50, 20 ) ); | ||
119 | TextLabel3_2->setText( tr( "read" ) ); | ||
120 | TextLabel3_2->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); | ||
121 | |||
122 | TextLabel3_2_2 = new QLabel( this, "TextLabel3_2_2" ); | ||
123 | TextLabel3_2_2->setGeometry( QRect( 120, 55, 50, 20 ) ); | ||
124 | TextLabel3_2_2->setText( tr( "write" ) ); | ||
125 | TextLabel3_2_2->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); | ||
126 | |||
127 | TextLabel3 = new QLabel( this, "TextLabel3" ); | ||
128 | TextLabel3->setGeometry( QRect( 180, 55, 50, 20 ) ); | ||
129 | TextLabel3->setText( tr( "execute" ) ); | ||
130 | TextLabel3->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); | ||
131 | |||
132 | struct stat buf; | ||
133 | mode_t mode; | ||
134 | file = fileName; | ||
135 | QFileInfo fi(file); | ||
136 | |||
137 | LineEdit1->setText( file); | ||
138 | OwnerLineEdit->setText( fi.owner()); | ||
139 | GroupLineEdit->setText( fi.group()); | ||
140 | |||
141 | if( fi.permission( QFileInfo::ReadUser)) { CheckBox1->setChecked(true); } | ||
142 | if( fi.permission( QFileInfo::WriteUser)) { CheckBox1_2->setChecked(true); } | ||
143 | if( fi.permission( QFileInfo::ExeUser)) { CheckBox1_3->setChecked(true); } | ||
144 | |||
145 | if( fi.permission( QFileInfo::ReadGroup)) { CheckBox1_4->setChecked(true); } | ||
146 | if( fi.permission( QFileInfo::WriteGroup)) { CheckBox1_5->setChecked(true); } | ||
147 | if( fi.permission( QFileInfo::ExeGroup)) { CheckBox1_6->setChecked(true); } | ||
148 | |||
149 | if( fi.permission( QFileInfo::ReadOther)) { CheckBox1_7->setChecked(true); } | ||
150 | if( fi.permission( QFileInfo::WriteOther)) { CheckBox1_8->setChecked(true); } | ||
151 | if( fi.permission( QFileInfo::ExeOther)) { CheckBox1_8_2->setChecked(true); } | ||
152 | |||
153 | lstat(file.latin1(), &buf); | ||
154 | mode = buf.st_mode; | ||
155 | modeStr.sprintf("%#o", buf.st_mode & ~(S_IFMT) ); | ||
156 | ModeLine->setText(modeStr); | ||
157 | bool ok; | ||
158 | i_mode = modeStr.toInt(&ok,10); | ||
159 | |||
160 | } | ||
161 | |||
162 | /* | ||
163 | * Destroys the object and frees any allocated resources | ||
164 | */ | ||
165 | filePermissions::~filePermissions() | ||
166 | { | ||
167 | } | ||
168 | |||
169 | |||
170 | // might this be better as a callback routine??? | ||
171 | void filePermissions::ownReadCheck() { | ||
172 | if(CheckBox1->isChecked()) { i_mode +=400; } | ||
173 | else i_mode -=400; | ||
174 | modeStr.sprintf("0%d",i_mode); | ||
175 | ModeLine->setText( modeStr); | ||
176 | // 0400 | ||
177 | } | ||
178 | |||
179 | void filePermissions::ownWriteCheck() { | ||
180 | if(CheckBox1_2->isChecked()) { i_mode +=200; } | ||
181 | else i_mode -=200; | ||
182 | modeStr.sprintf("0%d",i_mode); | ||
183 | ModeLine->setText(modeStr); | ||
184 | // 0200 | ||
185 | } | ||
186 | |||
187 | void filePermissions::ownExeCheck() { | ||
188 | if(CheckBox1_3->isChecked()) { i_mode +=100; } | ||
189 | else i_mode -=100; | ||
190 | modeStr.sprintf("0%d",i_mode); | ||
191 | ModeLine->setText(modeStr); | ||
192 | // 0100 | ||
193 | } | ||
194 | |||
195 | void filePermissions::grpReadCheck() { | ||
196 | if(CheckBox1_4->isChecked()) { i_mode +=40; } | ||
197 | else i_mode -=40; | ||
198 | modeStr.sprintf("0%d",i_mode); | ||
199 | ModeLine->setText(modeStr); | ||
200 | // 0040 | ||
201 | } | ||
202 | |||
203 | void filePermissions::grpWriteCheck() { | ||
204 | if(CheckBox1_5->isChecked()) { i_mode +=20; } | ||
205 | else i_mode -=20; | ||
206 | modeStr.sprintf("0%d",i_mode); | ||
207 | ModeLine->setText(modeStr); | ||
208 | // 0020 | ||
209 | } | ||
210 | |||
211 | void filePermissions::grpExeCheck() { | ||
212 | if(CheckBox1_6->isChecked()) { i_mode +=10; } | ||
213 | else i_mode -=10; | ||
214 | modeStr.sprintf("0%d",i_mode); | ||
215 | ModeLine->setText(modeStr); | ||
216 | // 0010 | ||
217 | } | ||
218 | |||
219 | void filePermissions::wrldReadCheck() { | ||
220 | if(CheckBox1_7->isChecked()) { i_mode +=4; } | ||
221 | else i_mode -=4; | ||
222 | modeStr.sprintf("0%d",i_mode); | ||
223 | ModeLine->setText(modeStr); | ||
224 | // 0004 | ||
225 | } | ||
226 | |||
227 | void filePermissions::wrldWriteCheck() { | ||
228 | if(CheckBox1_8->isChecked()) { i_mode +=2; } | ||
229 | else i_mode -=2; | ||
230 | modeStr.sprintf("0%d",i_mode); | ||
231 | ModeLine->setText(modeStr); | ||
232 | // 0002 | ||
233 | } | ||
234 | |||
235 | void filePermissions::wrldExeCheck() { | ||
236 | if(CheckBox1_8_2->isChecked()) { i_mode +=1; } | ||
237 | else i_mode -=1; | ||
238 | modeStr.sprintf("0%d",i_mode); | ||
239 | ModeLine->setText(modeStr); | ||
240 | // 0001 | ||
241 | } | ||
242 | |||
243 | void filePermissions::accept() { | ||
244 | |||
245 | QFileInfo fi(file); | ||
246 | struct passwd *pwd=0; | ||
247 | struct group *grp=0; | ||
248 | pwd = getpwnam(OwnerLineEdit->text().latin1() ); | ||
249 | if(pwd == NULL) { | ||
250 | perror("getpwnam"); | ||
251 | QMessageBox::warning(this,"Warning","Error- no user"); | ||
252 | return; | ||
253 | } else { | ||
254 | grp = getgrnam(GroupLineEdit->text().latin1()); | ||
255 | if(grp==NULL) { | ||
256 | perror("getgrnam"); | ||
257 | QMessageBox::warning(this,"Warning","Error- no group"); | ||
258 | return; | ||
259 | } | ||
260 | if( chown( file.latin1(), pwd->pw_uid, grp->gr_gid) <0) { | ||
261 | perror("chown"); | ||
262 | QMessageBox::warning(this,"Warning","Error setting ownership or group"); | ||
263 | return; | ||
264 | } | ||
265 | bool ok; | ||
266 | uint moder = modeStr.toUInt(&ok,8); | ||
267 | if( chmod( file.latin1(), moder) < 0) { | ||
268 | perror("chmod"); | ||
269 | QMessageBox::warning(this,"Warning","Error setting mode"); | ||
270 | return; | ||
271 | } | ||
272 | } | ||
273 | close(); | ||
274 | } | ||
diff --git a/core/apps/textedit/filePermissions.h b/core/apps/textedit/filePermissions.h new file mode 100644 index 0000000..880304f --- a/dev/null +++ b/core/apps/textedit/filePermissions.h | |||
@@ -0,0 +1,56 @@ | |||
1 | /**************************************************************************** | ||
2 | ** copyright 2002 ljp ljp@llornkcor.com | ||
3 | ** Created: Sat Feb 23 19:44:17 2002 | ||
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 FILEPERMISSIONS_H | ||
15 | #define FILEPERMISSIONS_H | ||
16 | |||
17 | #include <qvariant.h> | ||
18 | #include <qdialog.h> | ||
19 | class QVBoxLayout; | ||
20 | class QHBoxLayout; | ||
21 | class QGridLayout; | ||
22 | class QCheckBox; | ||
23 | class QLabel; | ||
24 | class QLineEdit; | ||
25 | class QString; | ||
26 | |||
27 | class filePermissions : public QDialog | ||
28 | { | ||
29 | Q_OBJECT | ||
30 | |||
31 | public: | ||
32 | filePermissions( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 , const QString & fileName =""); | ||
33 | ~filePermissions(); | ||
34 | |||
35 | QLineEdit *LineEdit1, *ModeLine; | ||
36 | QLabel *TextLabel1, *TextLabel4, *TextLabel4_2, *TextLabel4_3, *TextLabel3_2_2, *TextLabel3_2, *TextLabel3, *TextLabel5_2, *TextLabel5; | ||
37 | QCheckBox*CheckBox1, *CheckBox1_3, *CheckBox1_2, *CheckBox1_4, *CheckBox1_5, *CheckBox1_6, *CheckBox1_7, *CheckBox1_8, *CheckBox1_8_2; | ||
38 | QLineEdit*GroupLineEdit, *OwnerLineEdit; | ||
39 | QString modeStr, file; | ||
40 | int i_mode; | ||
41 | private slots: | ||
42 | void ownReadCheck(); | ||
43 | void ownWriteCheck(); | ||
44 | void ownExeCheck(); | ||
45 | |||
46 | void grpReadCheck(); | ||
47 | void grpWriteCheck(); | ||
48 | void grpExeCheck(); | ||
49 | |||
50 | void wrldReadCheck(); | ||
51 | void wrldWriteCheck(); | ||
52 | void wrldExeCheck(); | ||
53 | void accept(); | ||
54 | }; | ||
55 | |||
56 | #endif // FILEPERMISSIONS_H | ||
diff --git a/core/apps/textedit/fileSaver.cpp b/core/apps/textedit/fileSaver.cpp index b813ed3..9e9e863 100644 --- a/core/apps/textedit/fileSaver.cpp +++ b/core/apps/textedit/fileSaver.cpp | |||
@@ -1,39 +1,40 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** copyright 2001 ljp ljp@llornkcor.com | 2 | ** copyright 2001 ljp ljp@llornkcor.com |
3 | ** Created: Fri Dec 14 08:16:46 2001 fileSaver.cpp | 3 | ** Created: Fri Dec 14 08:16:46 2001 fileSaver.cpp |
4 | ** | 4 | ** |
5 | ** This file may be distributed and/or modified under the terms of the | 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 | 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 | 7 | ** Foundation and appearing in the file LICENSE.GPL included in the |
8 | ** packaging of this file. | 8 | ** packaging of this file. |
9 | ** | 9 | ** |
10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 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. | 11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
12 | ** | 12 | ** |
13 | ****************************************************************************/ | 13 | ****************************************************************************/ |
14 | #include "fileSaver.h" | 14 | #include "fileSaver.h" |
15 | #include <qpe/config.h> | 15 | #include <qpe/config.h> |
16 | #include <qpe/qpeapplication.h> | 16 | #include <qpe/qpeapplication.h> |
17 | |||
18 | #include <qlistview.h> | 17 | #include <qlistview.h> |
19 | #include <qpushbutton.h> | 18 | #include <qpushbutton.h> |
20 | #include <qfile.h> | 19 | #include <qfile.h> |
21 | #include <qmessagebox.h> | 20 | #include <qmessagebox.h> |
22 | #include <unistd.h> | ||
23 | #include <qlineedit.h> | 21 | #include <qlineedit.h> |
22 | #include <qcheckbox.h> | ||
23 | |||
24 | #include <unistd.h> | ||
24 | 25 | ||
25 | fileSaver::fileSaver( QWidget* parent, const char* name, bool modal, WFlags fl , const QString currentFileName ) | 26 | fileSaver::fileSaver( QWidget* parent, const char* name, bool modal, WFlags fl , const QString currentFileName ) |
26 | : QDialog( parent, name, modal, fl ) | 27 | : QDialog( parent, name, modal, fl ) |
27 | { | 28 | { |
28 | if ( !name ) | 29 | if ( !name ) |
29 | setName( "fileSaver" ); | 30 | setName( "fileSaver" ); |
30 | resize( 236, 280 ); | 31 | resize( 236, 280 ); |
31 | setCaption(tr( "Save file" ) ); | 32 | setCaption(tr( "Save file" ) ); |
32 | QFileInfo fi(currentFileName); | 33 | QFileInfo fi(currentFileName); |
33 | QString tmpFileName=fi.fileName(); | 34 | QString tmpFileName=fi.fileName(); |
34 | // qDebug( tmpFileName); | 35 | // qDebug( tmpFileName); |
35 | 36 | ||
36 | dirLabel = new QLabel(this, "DirLabel"); | 37 | dirLabel = new QLabel(this, "DirLabel"); |
37 | dirLabel->setText(currentDir.canonicalPath()); | 38 | dirLabel->setText(currentDir.canonicalPath()); |
38 | dirLabel->setGeometry(10,4,230,30); | 39 | dirLabel->setGeometry(10,4,230,30); |
39 | 40 | ||
@@ -43,32 +44,35 @@ fileSaver::fileSaver( QWidget* parent, const char* name, bool modal, WFlags fl | |||
43 | ListView->setSorting( 2, FALSE); | 44 | ListView->setSorting( 2, FALSE); |
44 | ListView->addColumn( tr( "Size" ) ); | 45 | ListView->addColumn( tr( "Size" ) ); |
45 | ListView->setColumnWidth(1,59); | 46 | ListView->setColumnWidth(1,59); |
46 | ListView->setColumnWidthMode(0,QListView::Manual); | 47 | ListView->setColumnWidthMode(0,QListView::Manual); |
47 | ListView->setColumnAlignment(1,QListView::AlignRight); | 48 | ListView->setColumnAlignment(1,QListView::AlignRight); |
48 | // ListView->setMultiSelection(true); | 49 | // ListView->setMultiSelection(true); |
49 | // ListView->setSelectionMode(QListView::Extended); | 50 | // ListView->setSelectionMode(QListView::Extended); |
50 | 51 | ||
51 | ListView->setAllColumnsShowFocus( TRUE ); | 52 | ListView->setAllColumnsShowFocus( TRUE ); |
52 | ListView->setGeometry( QRect( 10, 35, 220, 160 ) ); | 53 | ListView->setGeometry( QRect( 10, 35, 220, 160 ) ); |
53 | 54 | ||
54 | fileEdit= new QLineEdit(this); | 55 | fileEdit= new QLineEdit(this); |
55 | fileEdit->setGeometry( QRect( 10, 200, 200, 22)); | 56 | fileEdit->setGeometry( QRect( 10, 200, 200, 22)); |
56 | 57 | ||
57 | fileEdit->setText( tmpFileName); | 58 | fileEdit->setText( tmpFileName); |
58 | 59 | ||
60 | filePermCheck = new QCheckBox( this, "SetFilePerms" ); | ||
61 | filePermCheck->setText("set file permissions"); | ||
62 | filePermCheck->setGeometry(10, 220, 150,22); | ||
59 | // signals and slots connections | 63 | // signals and slots connections |
60 | connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) ); | 64 | connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) ); |
61 | connect( ListView, SIGNAL(pressed( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); | 65 | connect( ListView, SIGNAL(pressed( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); |
62 | 66 | ||
63 | // tmpFileName=fi.FilePath(); | 67 | // tmpFileName=fi.FilePath(); |
64 | // qDebug( tmpFileName); | 68 | // qDebug( tmpFileName); |
65 | currentDir.setPath( QDir::currentDirPath() ); | 69 | currentDir.setPath( QDir::currentDirPath() ); |
66 | populateList(); | 70 | populateList(); |
67 | } | 71 | } |
68 | 72 | ||
69 | fileSaver::~fileSaver() | 73 | fileSaver::~fileSaver() |
70 | { | 74 | { |
71 | } | 75 | } |
72 | 76 | ||
73 | 77 | ||
74 | void fileSaver::populateList() | 78 | void fileSaver::populateList() |
diff --git a/core/apps/textedit/fileSaver.h b/core/apps/textedit/fileSaver.h index 4a38a65..ce4493e 100644 --- a/core/apps/textedit/fileSaver.h +++ b/core/apps/textedit/fileSaver.h | |||
@@ -18,51 +18,53 @@ copyright Sun 02-17-2002 22:28:48 L. J. Potter ljp@llornkcor.com | |||
18 | 18 | ||
19 | //#include <qvariant.h> | 19 | //#include <qvariant.h> |
20 | #include <qdialog.h> | 20 | #include <qdialog.h> |
21 | #include <qfile.h> | 21 | #include <qfile.h> |
22 | #include <qdir.h> | 22 | #include <qdir.h> |
23 | #include <qstringlist.h> | 23 | #include <qstringlist.h> |
24 | #include <qlabel.h> | 24 | #include <qlabel.h> |
25 | #include <qstring.h> | 25 | #include <qstring.h> |
26 | 26 | ||
27 | class QVBoxLayout; | 27 | class QVBoxLayout; |
28 | class QHBoxLayout; | 28 | class QHBoxLayout; |
29 | class QGridLayout; | 29 | class QGridLayout; |
30 | class QListView; | 30 | class QListView; |
31 | class QListViewItem; | 31 | class QListViewItem; |
32 | class QPushButton; | 32 | class QPushButton; |
33 | class QLineEdit; | 33 | class QLineEdit; |
34 | class QCheckBox; | ||
34 | 35 | ||
35 | class fileSaver : public QDialog | 36 | class fileSaver : public QDialog |
36 | { | 37 | { |
37 | Q_OBJECT | 38 | Q_OBJECT |
38 | 39 | ||
39 | public: | 40 | public: |
40 | void populateList(); | 41 | void populateList(); |
41 | fileSaver( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ,const QString filter=0); | 42 | fileSaver( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ,const QString filter=0); |
42 | ~fileSaver(); | 43 | ~fileSaver(); |
43 | QLineEdit *fileEdit; | 44 | QLineEdit *fileEdit; |
44 | 45 | ||
45 | QPushButton* buttonOk; | 46 | QPushButton* buttonOk; |
46 | QListView* ListView; | 47 | QListView* ListView; |
47 | QPushButton* buttonCancel; | 48 | QPushButton* buttonCancel; |
48 | QLabel *dirLabel; | 49 | QLabel *dirLabel; |
49 | QString selectedFileName, filterStr; | 50 | QString selectedFileName, filterStr; |
50 | QDir currentDir; | 51 | QDir currentDir; |
51 | QFile file; | 52 | QFile file; |
52 | QStringList fileList; | 53 | QStringList fileList; |
54 | QCheckBox *filePermCheck; | ||
53 | 55 | ||
54 | QListViewItem * item; | 56 | QListViewItem * item; |
55 | public slots: | 57 | public slots: |
56 | 58 | ||
57 | private: | 59 | private: |
58 | 60 | ||
59 | private slots: | 61 | private slots: |
60 | void accept(); | 62 | void accept(); |
61 | void upDir(); | 63 | void upDir(); |
62 | void listDoubleClicked(QListViewItem *); | 64 | void listDoubleClicked(QListViewItem *); |
63 | void listClicked(QListViewItem *); | 65 | void listClicked(QListViewItem *); |
64 | void closeEvent( QCloseEvent * ); | 66 | void closeEvent( QCloseEvent * ); |
65 | 67 | ||
66 | protected slots: | 68 | protected slots: |
67 | 69 | ||
68 | protected: | 70 | protected: |
diff --git a/core/apps/textedit/opie-textedit.control b/core/apps/textedit/opie-textedit.control index 4990466..55fc644 100644 --- a/core/apps/textedit/opie-textedit.control +++ b/core/apps/textedit/opie-textedit.control | |||
@@ -1,9 +1,9 @@ | |||
1 | Files: bin/textedit apps/Applications/textedit.desktop | 1 | Files: bin/textedit apps/Applications/textedit.desktop |
2 | Priority: optional | 2 | Priority: optional |
3 | Section: opie/applications | 3 | Section: opie/applications |
4 | Maintainer: Warwick Allison <warwick@trolltech.com> | 4 | Maintainer: Warwick Allison <warwick@trolltech.com> |
5 | Architecture: arm | 5 | Architecture: arm |
6 | Version: $QPE_VERSION-$SUB_VERSION | 6 | Version: $QPE_VERSION-$SUB_VERSION |
7 | Depends: opie-base ($QPE_VERSION) | 7 | Depends: opie-base ($QPE_VERSION) |
8 | Description: Text Editor | 8 | Description: Text Editor |
9 | The text editor for the Opie environment. | 9 | The (slightly enchanced) text editor for the Opie environment. |
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index c869dc9..515fcdc 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -9,57 +9,61 @@ | |||
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
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 | #include "textedit.h" | 22 | #include "textedit.h" |
23 | #include "fileBrowser.h" | 23 | #include "fileBrowser.h" |
24 | #include "fileSaver.h" | 24 | #include "fileSaver.h" |
25 | #include "filePermissions.h" | ||
25 | 26 | ||
26 | #include "fontDialog.h" | 27 | #include "fontDialog.h" |
27 | 28 | ||
28 | #include <qpe/fontdatabase.h> | 29 | #include <qpe/fontdatabase.h> |
29 | #include <qpe/global.h> | 30 | #include <qpe/global.h> |
30 | #include <qpe/fileselector.h> | 31 | #include <qpe/fileselector.h> |
31 | #include <qpe/applnk.h> | 32 | #include <qpe/applnk.h> |
32 | #include <qpe/resource.h> | 33 | #include <qpe/resource.h> |
33 | #include <qpe/config.h> | 34 | #include <qpe/config.h> |
34 | #include <qpe/qpeapplication.h> | 35 | #include <qpe/qpeapplication.h> |
35 | #include <qpe/qpemenubar.h> | 36 | #include <qpe/qpemenubar.h> |
36 | #include <qpe/qpetoolbar.h> | 37 | #include <qpe/qpetoolbar.h> |
37 | //#include <qpe/finddialog.h> | 38 | //#include <qpe/finddialog.h> |
38 | 39 | ||
39 | #include <qstringlist.h> | 40 | #include <qstringlist.h> |
40 | #include <qaction.h> | 41 | #include <qaction.h> |
41 | #include <qcolordialog.h> | 42 | #include <qcolordialog.h> |
42 | #include <qfileinfo.h> | 43 | #include <qfileinfo.h> |
43 | #include <qlineedit.h> | 44 | #include <qlineedit.h> |
44 | #include <qmessagebox.h> | 45 | #include <qmessagebox.h> |
45 | #include <qobjectlist.h> | 46 | #include <qobjectlist.h> |
46 | #include <qpopupmenu.h> | 47 | #include <qpopupmenu.h> |
47 | #include <qspinbox.h> | 48 | #include <qspinbox.h> |
48 | #include <qtoolbutton.h> | 49 | #include <qtoolbutton.h> |
49 | #include <qwidgetstack.h> | 50 | #include <qwidgetstack.h> |
51 | #include <qcheckbox.h> | ||
52 | #include <unistd.h> | ||
53 | #include <sys/stat.h> | ||
50 | 54 | ||
51 | #include <stdlib.h> //getenv | 55 | #include <stdlib.h> //getenv |
52 | /* XPM */ | 56 | /* XPM */ |
53 | static char * filesave_xpm[] = { | 57 | static char * filesave_xpm[] = { |
54 | "16 16 78 1", | 58 | "16 16 78 1", |
55 | " c None", | 59 | " c None", |
56 | ". c #343434", | 60 | ". c #343434", |
57 | "+ c #A0A0A0", | 61 | "+ c #A0A0A0", |
58 | "@ c #565656", | 62 | "@ c #565656", |
59 | "# c #9E9E9E", | 63 | "# c #9E9E9E", |
60 | "$ c #525252", | 64 | "$ c #525252", |
61 | "% c #929292", | 65 | "% c #929292", |
62 | "& c #676767", | 66 | "& c #676767", |
63 | "* c #848484", | 67 | "* c #848484", |
64 | "= c #666666", | 68 | "= c #666666", |
65 | "- c #D8D8D8", | 69 | "- c #D8D8D8", |
@@ -402,33 +406,33 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | |||
402 | QString family = cfg.readEntry("Family", fontInfo.family()); | 406 | QString family = cfg.readEntry("Family", fontInfo.family()); |
403 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); | 407 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); |
404 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); | 408 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); |
405 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); | 409 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); |
406 | 410 | ||
407 | defaultFont = fdb.font(family,style,i_size,charSet); | 411 | defaultFont = fdb.font(family,style,i_size,charSet); |
408 | editor->setFont( defaultFont); | 412 | editor->setFont( defaultFont); |
409 | 413 | ||
410 | wa->setOn(wrap); | 414 | wa->setOn(wrap); |
411 | updateCaption(); | 415 | updateCaption(); |
412 | 416 | ||
413 | fileNew(); | 417 | fileNew(); |
414 | } | 418 | } |
415 | 419 | ||
416 | TextEdit::~TextEdit() | 420 | TextEdit::~TextEdit() |
417 | { | 421 | { |
418 | // saveAs(); | 422 | // save(); |
419 | 423 | ||
420 | Config cfg("TextEdit"); | 424 | Config cfg("TextEdit"); |
421 | cfg.setGroup("View"); | 425 | cfg.setGroup("View"); |
422 | QFont f = editor->font(); | 426 | QFont f = editor->font(); |
423 | cfg.writeEntry("FontSize",f.pointSize()); | 427 | cfg.writeEntry("FontSize",f.pointSize()); |
424 | cfg.writeEntry("Bold",f.bold()); | 428 | cfg.writeEntry("Bold",f.bold()); |
425 | cfg.writeEntry("Italic",f.italic()); | 429 | cfg.writeEntry("Italic",f.italic()); |
426 | cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); | 430 | cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth); |
427 | } | 431 | } |
428 | 432 | ||
429 | void TextEdit::zoomIn() | 433 | void TextEdit::zoomIn() |
430 | { | 434 | { |
431 | setFontSize(editor->font().pointSize()+1,FALSE); | 435 | setFontSize(editor->font().pointSize()+1,FALSE); |
432 | } | 436 | } |
433 | 437 | ||
434 | void TextEdit::zoomOut() | 438 | void TextEdit::zoomOut() |
@@ -681,53 +685,58 @@ void TextEdit::showEditTools() | |||
681 | fileSelector->hide(); | 685 | fileSelector->hide(); |
682 | menu->show(); | 686 | menu->show(); |
683 | editBar->show(); | 687 | editBar->show(); |
684 | if ( searchVisible ) | 688 | if ( searchVisible ) |
685 | searchBar->show(); | 689 | searchBar->show(); |
686 | // updateCaption(); | 690 | // updateCaption(); |
687 | editorStack->raiseWidget( editor ); | 691 | editorStack->raiseWidget( editor ); |
688 | setWState (WState_Reserved1 ); | 692 | setWState (WState_Reserved1 ); |
689 | } | 693 | } |
690 | 694 | ||
691 | /*! | 695 | /*! |
692 | unprompted save */ | 696 | unprompted save */ |
693 | bool TextEdit::save() | 697 | bool TextEdit::save() |
694 | { | 698 | { |
695 | QString file = doc->file(); | 699 | QString file = doc->file(); |
696 | QString name= doc->name(); | 700 | QString name= doc->name(); |
701 | |||
697 | QString rt = editor->text(); | 702 | QString rt = editor->text(); |
698 | currentFileName= name ; | 703 | currentFileName= name ; |
699 | qDebug("saveFile "+currentFileName); | 704 | qDebug("saveFile "+currentFileName); |
700 | 705 | ||
706 | struct stat buf; | ||
707 | mode_t mode; | ||
708 | lstat(file.latin1(), &buf); | ||
709 | mode = buf.st_mode; | ||
710 | |||
701 | doc->setName( name); | 711 | doc->setName( name); |
702 | FileManager fm; | 712 | FileManager fm; |
703 | if ( !fm.saveFile( *doc, rt ) ) { | 713 | if ( !fm.saveFile( *doc, rt ) ) { |
704 | return false; | 714 | return false; |
705 | } | 715 | } |
706 | // if(doc) | ||
707 | // delete doc; | ||
708 | // doc = 0; | ||
709 | editor->setEdited( false ); | 716 | editor->setEdited( false ); |
717 | |||
718 | chmod( file.latin1(), mode); | ||
710 | return true; | 719 | return true; |
711 | } | 720 | } |
712 | 721 | ||
713 | /*! | 722 | /*! |
714 | prompted save */ | 723 | prompted save */ |
715 | bool TextEdit::saveAs() | 724 | bool TextEdit::saveAs() |
716 | { | 725 | { |
717 | qDebug("saveAsFile "+currentFileName); | 726 | // qDebug("saveAsFile "+currentFileName); |
718 | 727 | ||
719 | // case of nothing to save... /// there's always something to save | 728 | // case of nothing to save... /// there's always something to save |
720 | // if ( !doc )//|| !bFromDocView) | 729 | // if ( !doc )//|| !bFromDocView) |
721 | // { | 730 | // { |
722 | // qDebug("no doc"); | 731 | // qDebug("no doc"); |
723 | // return true; | 732 | // return true; |
724 | // } | 733 | // } |
725 | if ( !editor->edited() ) { | 734 | if ( !editor->edited() ) { |
726 | delete doc; | 735 | delete doc; |
727 | doc = 0; | 736 | doc = 0; |
728 | return true; | 737 | return true; |
729 | } | 738 | } |
730 | 739 | ||
731 | QString rt = editor->text(); | 740 | QString rt = editor->text(); |
732 | qDebug(currentFileName); | 741 | qDebug(currentFileName); |
733 | 742 | ||
@@ -740,65 +749,72 @@ bool TextEdit::saveAs() | |||
740 | if ( i > 0 ) | 749 | if ( i > 0 ) |
741 | docname = pt.left( i ); | 750 | docname = pt.left( i ); |
742 | // remove "." at the beginning | 751 | // remove "." at the beginning |
743 | while( docname.startsWith( "." ) ) | 752 | while( docname.startsWith( "." ) ) |
744 | docname = docname.mid( 1 ); | 753 | docname = docname.mid( 1 ); |
745 | docname.replace( QRegExp("/"), "_" ); | 754 | docname.replace( QRegExp("/"), "_" ); |
746 | // cut the length. filenames longer than that don't make sense and something goes wrong when they get too long. | 755 | // cut the length. filenames longer than that don't make sense and something goes wrong when they get too long. |
747 | if ( docname.length() > 40 ) | 756 | if ( docname.length() > 40 ) |
748 | docname = docname.left(40); | 757 | docname = docname.left(40); |
749 | if ( docname.isEmpty() ) | 758 | if ( docname.isEmpty() ) |
750 | docname = "Unnamed"; | 759 | docname = "Unnamed"; |
751 | doc->setName(docname); | 760 | doc->setName(docname); |
752 | currentFileName=docname; | 761 | currentFileName=docname; |
753 | } | 762 | } |
754 | } | 763 | } |
755 | 764 | ||
765 | |||
756 | fileSaveDlg=new fileSaver(this,"SaveFile",TRUE,0, currentFileName); | 766 | fileSaveDlg=new fileSaver(this,"SaveFile",TRUE,0, currentFileName); |
757 | qDebug("wanna save filename "+currentFileName); | 767 | qDebug("wanna save filename "+currentFileName); |
758 | fileSaveDlg->exec(); | 768 | fileSaveDlg->exec(); |
759 | if( fileSaveDlg->result() == 1 ) { | 769 | if( fileSaveDlg->result() == 1 ) { |
760 | QString fileNm=fileSaveDlg->selectedFileName; | 770 | QString fileNm=fileSaveDlg->selectedFileName; |
761 | qDebug("saving filename "+fileNm); | 771 | qDebug("saving filename "+fileNm); |
762 | QFileInfo fi(fileNm); | 772 | QFileInfo fi(fileNm); |
763 | currentFileName=fi.fileName(); | 773 | currentFileName=fi.fileName(); |
764 | if(doc) { | 774 | if(doc) { |
765 | qDebug("doclnk exists"); | 775 | qDebug("doclnk exists"); |
766 | // QString file = doc->file(); | 776 | // QString file = doc->file(); |
767 | // doc->removeFiles(); | 777 | // doc->removeFiles(); |
768 | delete doc; | 778 | delete doc; |
769 | DocLnk nf; | 779 | DocLnk nf; |
770 | nf.setType("text/plain"); | 780 | nf.setType("text/plain"); |
771 | nf.setFile( fileNm); | 781 | nf.setFile( fileNm); |
772 | doc = new DocLnk(nf); | 782 | doc = new DocLnk(nf); |
773 | // editor->setText(rt); | 783 | // editor->setText(rt); |
774 | qDebug("openFile doclnk "+currentFileName); | 784 | qDebug("openFile doclnk "+currentFileName); |
775 | } | 785 | doc->setName( currentFileName); |
776 | doc->setName( currentFileName); | 786 | updateCaption( currentFileName); |
777 | updateCaption( currentFileName); | 787 | |
778 | 788 | FileManager fm; | |
779 | FileManager fm; | 789 | if ( !fm.saveFile( *doc, rt ) ) { |
780 | if ( !fm.saveFile( *doc, rt ) ) { | 790 | return false; |
781 | return false; | 791 | } |
782 | } | 792 | if( fileSaveDlg->filePermCheck->isChecked() ) { |
783 | // delete doc; | 793 | filePermissions *filePerm; |
784 | // doc = 0; | 794 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)fileNm); |
785 | editor->setEdited( false ); | 795 | filePerm->exec(); |
796 | editor->setEdited( false ); | ||
797 | if( filePerm) | ||
798 | delete filePerm; | ||
799 | } | ||
800 | } | ||
786 | } | 801 | } |
802 | |||
787 | if(fileSaveDlg) | 803 | if(fileSaveDlg) |
788 | delete fileSaveDlg; | 804 | delete fileSaveDlg; |
789 | return true; | 805 | return true; |
790 | } | 806 | } |
791 | 807 | ||
792 | void TextEdit::clear() | 808 | void TextEdit::clear() |
793 | { | 809 | { |
794 | delete doc; | 810 | delete doc; |
795 | doc = 0; | 811 | doc = 0; |
796 | editor->clear(); | 812 | editor->clear(); |
797 | } | 813 | } |
798 | 814 | ||
799 | void TextEdit::updateCaption( const QString &name ) | 815 | void TextEdit::updateCaption( const QString &name ) |
800 | { | 816 | { |
801 | if ( !doc ) | 817 | if ( !doc ) |
802 | setCaption( tr("Text Editor") ); | 818 | setCaption( tr("Text Editor") ); |
803 | else { | 819 | else { |
804 | QString s = name; | 820 | QString s = name; |
@@ -822,32 +838,33 @@ void TextEdit::setDocument(const QString& fileref) | |||
822 | 838 | ||
823 | void TextEdit::closeEvent( QCloseEvent *e ) | 839 | void TextEdit::closeEvent( QCloseEvent *e ) |
824 | { | 840 | { |
825 | if ( editorStack->visibleWidget() == fileSelector && !bFromDocView ) { | 841 | if ( editorStack->visibleWidget() == fileSelector && !bFromDocView ) { |
826 | e->ignore(); | 842 | e->ignore(); |
827 | repaint(); | 843 | repaint(); |
828 | // fileRevert(); | 844 | // fileRevert(); |
829 | 845 | ||
830 | } else { | 846 | } else { |
831 | bFromDocView = FALSE; | 847 | bFromDocView = FALSE; |
832 | e->accept(); | 848 | e->accept(); |
833 | } | 849 | } |
834 | } | 850 | } |
835 | 851 | ||
836 | void TextEdit::accept() | 852 | void TextEdit::accept() |
837 | { | 853 | { |
854 | save(); | ||
838 | close(); | 855 | close(); |
839 | // fileOpen(); //godamn thats obnoxious! lemme out!!! | 856 | // fileOpen(); //godamn thats obnoxious! lemme out!!! |
840 | } | 857 | } |
841 | 858 | ||
842 | void TextEdit::changeFont() { | 859 | void TextEdit::changeFont() { |
843 | FontDatabase fdb; | 860 | FontDatabase fdb; |
844 | QFont defaultFont=editor->font(); | 861 | QFont defaultFont=editor->font(); |
845 | QFontInfo fontInfo(defaultFont); | 862 | QFontInfo fontInfo(defaultFont); |
846 | Config cfg("TextEdit"); | 863 | Config cfg("TextEdit"); |
847 | cfg.setGroup("Font"); | 864 | cfg.setGroup("Font"); |
848 | QString family = cfg.readEntry("Family", fontInfo.family()); | 865 | QString family = cfg.readEntry("Family", fontInfo.family()); |
849 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); | 866 | QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); |
850 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); | 867 | int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); |
851 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); | 868 | QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); |
852 | 869 | ||
853 | defaultFont = fdb.font(family,style,i_size,charSet); | 870 | defaultFont = fdb.font(family,style,i_size,charSet); |
diff --git a/core/apps/textedit/textedit.pro b/core/apps/textedit/textedit.pro index 9b1a841..2c25d43 100644 --- a/core/apps/textedit/textedit.pro +++ b/core/apps/textedit/textedit.pro | |||
@@ -1,16 +1,16 @@ | |||
1 | TEMPLATE = app | 1 | TEMPLATE = app |
2 | CONFIG += qt warn_on release | 2 | CONFIG += qt warn_on release |
3 | 3 | ||
4 | DESTDIR = $(OPIEDIR)/bin | 4 | DESTDIR = $(OPIEDIR)/bin |
5 | 5 | ||
6 | HEADERS = textedit.h fileBrowser.h fontDialog.h fileSaver.h | 6 | HEADERS = textedit.h fileBrowser.h fontDialog.h fileSaver.h filePermissions.h |
7 | 7 | ||
8 | SOURCES = main.cpp textedit.cpp fileBrowser.cpp fontDialog.cpp fileSaver.cpp | 8 | SOURCES = main.cpp textedit.cpp fileBrowser.cpp fontDialog.cpp fileSaver.cpp filePermissions.cpp |
9 | 9 | ||
10 | INCLUDEPATH += $(OPIEDIR)/include | 10 | INCLUDEPATH += $(OPIEDIR)/include |
11 | DEPENDPATH += $(OPIEDIR)/include | 11 | DEPENDPATH += $(OPIEDIR)/include |
12 | LIBS += -lqpe | 12 | LIBS += -lqpe |
13 | 13 | ||
14 | TARGET = textedit | 14 | TARGET = textedit |
15 | 15 | ||
16 | TRANSLATIONS = ../i18n/de/textedit.ts | 16 | TRANSLATIONS = ../i18n/de/textedit.ts |