-rw-r--r-- | library/lnkproperties.cpp | 48 |
1 files changed, 21 insertions, 27 deletions
diff --git a/library/lnkproperties.cpp b/library/lnkproperties.cpp index c020328..983c677 100644 --- a/library/lnkproperties.cpp +++ b/library/lnkproperties.cpp | |||
@@ -1,16 +1,16 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
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 |
@@ -20,74 +20,77 @@ | |||
20 | 20 | ||
21 | // WARNING: Do *NOT* define this yourself. The SL5xxx from SHARP does NOT | 21 | // WARNING: Do *NOT* define this yourself. The SL5xxx from SHARP does NOT |
22 | // have this class. | 22 | // have this class. |
23 | #define QTOPIA_INTERNAL_FSLP | 23 | #define QTOPIA_INTERNAL_FSLP |
24 | #include "lnkproperties.h" | 24 | #include "lnkproperties.h" |
25 | #include "lnkproperties.h" | 25 | #include "lnkproperties.h" |
26 | #include "lnkpropertiesbase_p.h" | 26 | #include "lnkpropertiesbase_p.h" |
27 | #include "ir.h" | 27 | #include "ir.h" |
28 | 28 | ||
29 | #include <qpe/applnk.h> | 29 | #include <qpe/applnk.h> |
30 | #include <qpe/global.h> | 30 | #include <qpe/global.h> |
31 | #include <qpe/categorywidget.h> | 31 | #include <qpe/categorywidget.h> |
32 | #ifdef QWS | ||
32 | #include <qpe/qcopenvelope_qws.h> | 33 | #include <qpe/qcopenvelope_qws.h> |
34 | #endif | ||
33 | #include <qpe/filemanager.h> | 35 | #include <qpe/filemanager.h> |
34 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
35 | #include <qpe/storage.h> | 37 | #include <qpe/storage.h> |
36 | #include <qpe/qpemessagebox.h> | 38 | #include <qpe/qpemessagebox.h> |
37 | 39 | ||
38 | #include <qlineedit.h> | 40 | #include <qlineedit.h> |
39 | #include <qtoolbutton.h> | 41 | #include <qtoolbutton.h> |
40 | #include <qpushbutton.h> | 42 | #include <qpushbutton.h> |
41 | #include <qgroupbox.h> | 43 | #include <qgroupbox.h> |
42 | #include <qcheckbox.h> | 44 | #include <qcheckbox.h> |
43 | #include <qlabel.h> | 45 | #include <qlabel.h> |
44 | #include <qlayout.h> | 46 | #include <qlayout.h> |
45 | #include <qfile.h> | 47 | #include <qfile.h> |
46 | #include <qfileinfo.h> | 48 | #include <qfileinfo.h> |
47 | #include <qmessagebox.h> | 49 | #include <qmessagebox.h> |
48 | #include <qsize.h> | 50 | #include <qsize.h> |
49 | #include <qcombobox.h> | 51 | #include <qcombobox.h> |
50 | #include <qregexp.h> | 52 | #include <qregexp.h> |
51 | 53 | ||
52 | #include <stdlib.h> | 54 | #include <stdlib.h> |
53 | 55 | ||
54 | LnkProperties::LnkProperties( AppLnk* l, QWidget* parent ) | 56 | LnkProperties::LnkProperties( AppLnk* l, QWidget* parent ) |
55 | : QDialog( parent, 0, TRUE ), lnk(l), fileSize( 0 ) | 57 | : QDialog( parent, 0, TRUE ), lnk(l), fileSize( 0 ) |
56 | { | 58 | { |
59 | setCaption( tr("Properties") ); | ||
60 | |||
57 | QVBoxLayout *vbox = new QVBoxLayout( this ); | 61 | QVBoxLayout *vbox = new QVBoxLayout( this ); |
58 | d = new LnkPropertiesBase( this ); | 62 | d = new LnkPropertiesBase( this ); |
59 | vbox->add( d ); | 63 | vbox->add( d ); |
60 | 64 | ||
61 | d->docname->setText(l->name()); | 65 | d->docname->setText(l->name()); |
62 | QString inf; | 66 | QString inf; |
63 | if ( l->type().isEmpty() ) { | 67 | if ( l->type().isEmpty() ) { |
64 | d->type->hide(); | 68 | d->type->hide(); |
65 | d->typeLabel->hide(); | 69 | d->typeLabel->hide(); |
66 | } else { | 70 | } else { |
67 | d->type->setText( l->type() ); | 71 | d->type->setText( l->type() ); |
68 | } | 72 | } |
69 | 73 | ||
70 | if ( l->comment().isEmpty() ) { | 74 | if ( l->comment().isEmpty() ) { |
71 | d->comment->hide(); | 75 | d->comment->hide(); |
72 | d->commentLabel->hide(); | 76 | d->commentLabel->hide(); |
73 | } else { | 77 | } else { |
74 | d->comment->setText( l->comment() ); | 78 | d->comment->setText( l->comment() ); |
75 | } | 79 | } |
76 | 80 | ||
77 | connect(d->beam,SIGNAL(clicked()),this,SLOT(beamLnk())); | 81 | connect(d->beam,SIGNAL(clicked()),this,SLOT(beamLnk())); |
78 | if ( lnk->type().contains('/') ) { // A document? (#### better predicate needed) | 82 | if ( lnk->type().contains('/') ) { // A document? (#### better predicate needed) |
79 | connect(d->unlink,SIGNAL(clicked()),this,SLOT(unlinkLnk())); | 83 | connect(d->unlink,SIGNAL(clicked()),this,SLOT(unlinkLnk())); |
80 | connect(d->duplicate,SIGNAL(clicked()),this,SLOT(duplicateLnk())); | 84 | connect(d->duplicate,SIGNAL(clicked()),this,SLOT(duplicateLnk())); |
81 | connect(d->delicon,SIGNAL(clicked()),this,SLOT(unlinkIcon())); | ||
82 | 85 | ||
83 | d->docname->setReadOnly( FALSE ); | 86 | d->docname->setReadOnly( FALSE ); |
84 | d->preload->hide(); | 87 | d->preload->hide(); |
85 | d->spacer->hide(); | 88 | d->spacer->hide(); |
86 | 89 | ||
87 | // ### THIS MUST GO, FIX WIERD BUG in QLAYOUT | 90 | // ### THIS MUST GO, FIX WIERD BUG in QLAYOUT |
88 | d->categoryEdit->kludge(); | 91 | d->categoryEdit->kludge(); |
89 | 92 | ||
90 | d->categoryEdit->setCategories( lnk->categories(), | 93 | d->categoryEdit->setCategories( lnk->categories(), |
91 | "Document View", | 94 | "Document View", |
92 | tr("Document View") ); | 95 | tr("Document View") ); |
93 | setupLocations(); | 96 | setupLocations(); |
@@ -108,84 +111,69 @@ LnkProperties::LnkProperties( AppLnk* l, QWidget* parent ) | |||
108 | if ( l->property("CanFastload") == "0" ) | 111 | if ( l->property("CanFastload") == "0" ) |
109 | d->preload->hide(); | 112 | d->preload->hide(); |
110 | 113 | ||
111 | Config cfg("Launcher"); | 114 | Config cfg("Launcher"); |
112 | cfg.setGroup("Preload"); | 115 | cfg.setGroup("Preload"); |
113 | QStringList apps = cfg.readListEntry("Apps",','); | 116 | QStringList apps = cfg.readListEntry("Apps",','); |
114 | d->preload->setChecked( apps.contains(l->exec()) ); | 117 | d->preload->setChecked( apps.contains(l->exec()) ); |
115 | if ( Global::isBuiltinCommand(lnk->exec()) ) | 118 | if ( Global::isBuiltinCommand(lnk->exec()) ) |
116 | d->preload->hide(); // builtins are always fast | 119 | d->preload->hide(); // builtins are always fast |
117 | 120 | ||
118 | currentLocation = 0; // apps not movable (yet) | 121 | currentLocation = 0; // apps not movable (yet) |
119 | } | 122 | } |
120 | setCaption( l->file()); | ||
121 | } | 123 | } |
122 | 124 | ||
123 | LnkProperties::~LnkProperties() | 125 | LnkProperties::~LnkProperties() |
124 | { | 126 | { |
125 | } | 127 | } |
126 | 128 | ||
127 | void LnkProperties::unlinkLnk() | 129 | void LnkProperties::unlinkLnk() |
128 | { | 130 | { |
129 | if ( QPEMessageBox::confirmDelete( this, tr("Delete"), lnk->name() ) ) { | 131 | if ( QPEMessageBox::confirmDelete( this, tr("Delete"), lnk->name() ) ) { |
130 | if ( QFile::exists(lnk->file()) ) | ||
131 | lnk->removeFiles(); | 132 | lnk->removeFiles(); |
132 | else | ||
133 | QMessageBox::warning( this, tr("Delete"), tr("File does not exist.") ); | ||
134 | if ( QFile::exists(lnk->file()) ) { | 133 | if ( QFile::exists(lnk->file()) ) { |
135 | QMessageBox::warning( this, tr("Delete"), tr("File deletion failed.") ); | 134 | QMessageBox::warning( this, tr("Delete"), tr("File deletion failed.") ); |
136 | } else { | 135 | } else { |
137 | reject(); | 136 | reject(); |
138 | } | 137 | } |
139 | } | 138 | } |
140 | } | 139 | } |
141 | 140 | ||
142 | |||
143 | /* | ||
144 | * remove only the link from documents, not also the file | ||
145 | */ | ||
146 | void LnkProperties::unlinkIcon() | ||
147 | { | ||
148 | if ( QPEMessageBox::confirmDelete( this, tr("Delete Icon and leave file"), lnk->name() ) ) { | ||
149 | lnk->removeLinkFile(); | ||
150 | if ( QFile::exists(lnk->linkFile()) ) { | ||
151 | QMessageBox::warning( this, tr("Delete"), tr("Icon deletion failed.") ); | ||
152 | } else { | ||
153 | reject(); | ||
154 | } | ||
155 | } | ||
156 | } | ||
157 | |||
158 | void LnkProperties::setupLocations() | 141 | void LnkProperties::setupLocations() |
159 | { | 142 | { |
160 | QFileInfo fi( lnk->file() ); | 143 | QFileInfo fi( lnk->file() ); |
161 | fileSize = fi.size(); | 144 | fileSize = fi.size(); |
162 | StorageInfo storage; | 145 | StorageInfo storage; |
163 | const QList<FileSystem> &fs = storage.fileSystems(); | 146 | const QList<FileSystem> &fs = storage.fileSystems(); |
164 | QListIterator<FileSystem> it ( fs ); | 147 | QListIterator<FileSystem> it ( fs ); |
165 | QString s; | 148 | QString s; |
166 | QString homeDir = getenv("HOME"); | 149 | QString homeDir = getenv("HOME"); |
167 | QString hardDiskHome; | 150 | QString hardDiskHome; |
168 | QString hardDiskPath; | 151 | QString hardDiskPath; |
169 | int index = 0; | 152 | int index = 0; |
170 | currentLocation = -1; | 153 | currentLocation = -1; |
171 | for ( ; it.current(); ++it ) { | 154 | for ( ; it.current(); ++it ) { |
172 | // we add 10k to the file size so we are sure we can also save the desktop file | 155 | // we add 10k to the file size so we are sure we can also save the desktop file |
173 | if ( (*it)->availBlocks() * (*it)->blockSize() > fileSize + 10000 ) { | 156 | if ( (ulong)(*it)->availBlocks() * (ulong)(*it)->blockSize() > (ulong)fileSize + 10000 ) { |
174 | if ( (*it)->isRemovable() || | 157 | if ( (*it)->isRemovable() || |
175 | (*it)->disk() == "/dev/mtdblock1" || | 158 | (*it)->disk() == "/dev/mtdblock1" || |
176 | (*it)->disk() == "/dev/mtdblock/1" || (*it)->disk().left(13) == "/dev/mtdblock" || | 159 | (*it)->disk() == "/dev/mtdblock/1" || |
177 | (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs" ) { | 160 | (*it)->disk().left(13) == "/dev/mtdblock" || |
161 | (*it)->disk() == "/dev/mtdblock6" || | ||
162 | (*it)->disk() == "tmpfs" ) { | ||
178 | d->locationCombo->insertItem( (*it)->name(), index ); | 163 | d->locationCombo->insertItem( (*it)->name(), index ); |
179 | locations.append( ((*it)->isRemovable() || (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs" ? (*it)->path() : homeDir) ); | 164 | locations.append( ( ((*it)->isRemovable() || |
165 | (*it)->disk() == "/dev/mtdblock6" || | ||
166 | (*it)->disk() == "tmpfs" ) | ||
167 | ? (*it)->path() : homeDir) ); | ||
180 | if ( lnk->file().contains( (*it)->path() ) ) { | 168 | if ( lnk->file().contains( (*it)->path() ) ) { |
181 | d->locationCombo->setCurrentItem( index ); | 169 | d->locationCombo->setCurrentItem( index ); |
182 | currentLocation = index; | 170 | currentLocation = index; |
183 | } | 171 | } |
184 | index++; | 172 | index++; |
185 | } else if ( (*it)->name().contains( tr("Hard Disk") ) && | 173 | } else if ( (*it)->name().contains( tr("Hard Disk") ) && |
186 | homeDir.contains( (*it)->path() ) && | 174 | homeDir.contains( (*it)->path() ) && |
187 | (*it)->path().length() > hardDiskHome.length() ) { | 175 | (*it)->path().length() > hardDiskHome.length() ) { |
188 | hardDiskHome = (*it)->name(); | 176 | hardDiskHome = (*it)->name(); |
189 | hardDiskPath = (*it)->path(); | 177 | hardDiskPath = (*it)->path(); |
190 | } | 178 | } |
191 | } | 179 | } |
@@ -226,24 +214,26 @@ bool LnkProperties::moveLnk() | |||
226 | return FALSE; | 214 | return FALSE; |
227 | } | 215 | } |
228 | // remove old lnk | 216 | // remove old lnk |
229 | lnk->removeFiles(); | 217 | lnk->removeFiles(); |
230 | 218 | ||
231 | return TRUE; | 219 | return TRUE; |
232 | } | 220 | } |
233 | 221 | ||
234 | void LnkProperties::beamLnk() | 222 | void LnkProperties::beamLnk() |
235 | { | 223 | { |
236 | Ir ir; | 224 | Ir ir; |
237 | DocLnk doc( *((DocLnk *)lnk) ); | 225 | DocLnk doc( *((DocLnk *)lnk) ); |
226 | doc.setName(d->docname->text()); | ||
227 | reject(); | ||
238 | ir.send( doc, doc.comment() ); | 228 | ir.send( doc, doc.comment() ); |
239 | } | 229 | } |
240 | 230 | ||
241 | bool LnkProperties::copyFile( DocLnk &newdoc ) | 231 | bool LnkProperties::copyFile( DocLnk &newdoc ) |
242 | { | 232 | { |
243 | const char *linkExtn = ".desktop"; | 233 | const char *linkExtn = ".desktop"; |
244 | QString fileExtn; | 234 | QString fileExtn; |
245 | int extnPos = lnk->file().findRev( '.' ); | 235 | int extnPos = lnk->file().findRev( '.' ); |
246 | if ( extnPos > 0 ) | 236 | if ( extnPos > 0 ) |
247 | fileExtn = lnk->file().mid( extnPos ); | 237 | fileExtn = lnk->file().mid( extnPos ); |
248 | 238 | ||
249 | QString safename = newdoc.name(); | 239 | QString safename = newdoc.name(); |
@@ -290,26 +280,30 @@ void LnkProperties::done(int ok) | |||
290 | } else if ( changed ) { | 280 | } else if ( changed ) { |
291 | lnk->writeLink(); | 281 | lnk->writeLink(); |
292 | } | 282 | } |
293 | 283 | ||
294 | if ( !d->preload->isHidden() ) { | 284 | if ( !d->preload->isHidden() ) { |
295 | Config cfg("Launcher"); | 285 | Config cfg("Launcher"); |
296 | cfg.setGroup("Preload"); | 286 | cfg.setGroup("Preload"); |
297 | QStringList apps = cfg.readListEntry("Apps",','); | 287 | QStringList apps = cfg.readListEntry("Apps",','); |
298 | QString exe = lnk->exec(); | 288 | QString exe = lnk->exec(); |
299 | if ( apps.contains(exe) != d->preload->isChecked() ) { | 289 | if ( apps.contains(exe) != d->preload->isChecked() ) { |
300 | if ( d->preload->isChecked() ) { | 290 | if ( d->preload->isChecked() ) { |
301 | apps.append(exe); | 291 | apps.append(exe); |
292 | #ifndef QT_NO_COP | ||
302 | QCopEnvelope e("QPE/Application/"+exe.local8Bit(), | 293 | QCopEnvelope e("QPE/Application/"+exe.local8Bit(), |
303 | "enablePreload()"); | 294 | "enablePreload()"); |
295 | #endif | ||
304 | } else { | 296 | } else { |
305 | apps.remove(exe); | 297 | apps.remove(exe); |
298 | #ifndef QT_NO_COP | ||
306 | QCopEnvelope e("QPE/Application/"+exe.local8Bit(), | 299 | QCopEnvelope e("QPE/Application/"+exe.local8Bit(), |
307 | "quitIfInvisible()"); | 300 | "quitIfInvisible()"); |
301 | #endif | ||
308 | } | 302 | } |
309 | cfg.writeEntry("Apps",apps,','); | 303 | cfg.writeEntry("Apps",apps,','); |
310 | } | 304 | } |
311 | } | 305 | } |
312 | } | 306 | } |
313 | QDialog::done( ok ); | 307 | QDialog::done( ok ); |
314 | } | 308 | } |
315 | 309 | ||