summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2004-03-08 17:00:43 (UTC)
committer mickeyl <mickeyl>2004-03-08 17:00:43 (UTC)
commit5c0d3f0db722ad2b81bdab1a2a06d45c198ed975 (patch) (unidiff)
tree327faa51dd84d8d032c83157b841efc34d847f56
parentbad368ebceecc3dd976e8eb206c773b5df6d11ef (diff)
downloadopie-5c0d3f0db722ad2b81bdab1a2a06d45c198ed975.zip
opie-5c0d3f0db722ad2b81bdab1a2a06d45c198ed975.tar.gz
opie-5c0d3f0db722ad2b81bdab1a2a06d45c198ed975.tar.bz2
save UI changes to argument list back to .desktop file ;)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/lnkproperties.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/library/lnkproperties.cpp b/library/lnkproperties.cpp
index 865f590..f0f0bba 100644
--- a/library/lnkproperties.cpp
+++ b/library/lnkproperties.cpp
@@ -60,290 +60,294 @@ LnkProperties::LnkProperties( AppLnk* l, QWidget* parent )
60 60
61 QVBoxLayout *vbox = new QVBoxLayout( this ); 61 QVBoxLayout *vbox = new QVBoxLayout( this );
62 d = new LnkPropertiesBase( this ); 62 d = new LnkPropertiesBase( this );
63 vbox->add( d ); 63 vbox->add( d );
64 64
65 // hide custom rotation feature for now, need a new implementation to fit quicklauch, 65 // hide custom rotation feature for now, need a new implementation to fit quicklauch,
66 // is confusing for the user and doubtable useful since life rotation 66 // is confusing for the user and doubtable useful since life rotation
67 d->rotate->hide(); 67 d->rotate->hide();
68 d->rotateButtons->hide(); 68 d->rotateButtons->hide();
69 69
70 d->docname->setText(l->name()); 70 d->docname->setText(l->name());
71 QString inf; 71 QString inf;
72 if ( l->type().isEmpty() ) { 72 if ( l->type().isEmpty() ) {
73 d->type->hide(); 73 d->type->hide();
74 d->typeLabel->hide(); 74 d->typeLabel->hide();
75 } else { 75 } else {
76 d->type->setText( l->type() ); 76 d->type->setText( l->type() );
77 } 77 }
78 78
79 if ( l->comment().isEmpty() ) { 79 if ( l->comment().isEmpty() ) {
80 d->comment->hide(); 80 d->comment->hide();
81 d->commentLabel->hide(); 81 d->commentLabel->hide();
82 } else { 82 } else {
83 d->comment->setText( l->comment() ); 83 d->comment->setText( l->comment() );
84 } 84 }
85 85
86 connect(d->beam,SIGNAL(clicked()),this,SLOT(beamLnk())); 86 connect(d->beam,SIGNAL(clicked()),this,SLOT(beamLnk()));
87 if ( lnk->type().contains('/') ) { // A document? (#### better predicate needed) 87 if ( lnk->type().contains('/') ) { // A document? (#### better predicate needed)
88 connect(d->unlink,SIGNAL(clicked()),this,SLOT(unlinkLnk())); 88 connect(d->unlink,SIGNAL(clicked()),this,SLOT(unlinkLnk()));
89 connect(d->duplicate,SIGNAL(clicked()),this,SLOT(duplicateLnk())); 89 connect(d->duplicate,SIGNAL(clicked()),this,SLOT(duplicateLnk()));
90 90
91 d->docname->setReadOnly( FALSE ); 91 d->docname->setReadOnly( FALSE );
92 d->preload->hide(); 92 d->preload->hide();
93 d->rotate->hide(); 93 d->rotate->hide();
94 d->rotateButtons->hide(); 94 d->rotateButtons->hide();
95 d->labelspacer->hide(); 95 d->labelspacer->hide();
96 96
97 // ### THIS MUST GO, FIX WIERD BUG in QLAYOUT 97 // ### THIS MUST GO, FIX WIERD BUG in QLAYOUT
98 d->categoryEdit->kludge(); 98 d->categoryEdit->kludge();
99 99
100 d->categoryEdit->setCategories( lnk->categories(), 100 d->categoryEdit->setCategories( lnk->categories(),
101 "Document View", 101 "Document View",
102 tr("Document View") ); 102 tr("Document View") );
103 setupLocations(); 103 setupLocations();
104 } else { 104 } else {
105 d->unlink->hide(); 105 d->unlink->hide();
106 d->duplicate->hide(); 106 d->duplicate->hide();
107 d->beam->hide(); 107 d->beam->hide();
108 d->hline->hide(); 108 d->hline->hide();
109 d->locationLabel->hide(); 109 d->locationLabel->hide();
110 d->locationCombo->hide(); 110 d->locationCombo->hide();
111 111
112 // Can't edit categories, since the app .desktop files are global, 112 // Can't edit categories, since the app .desktop files are global,
113 // possibly read-only. 113 // possibly read-only.
114 d->categoryEdit->hide(); 114 d->categoryEdit->hide();
115 115
116 d->docname->setReadOnly( TRUE ); 116 d->docname->setReadOnly( TRUE );
117 117
118 if ( l->property("CanFastload") == "0" ) 118 if ( l->property("CanFastload") == "0" )
119 d->preload->hide(); 119 d->preload->hide();
120 if ( !l->property("Rotation"). isEmpty ()) { 120 if ( !l->property("Rotation"). isEmpty ()) {
121 d->rotate->setChecked ( true ); 121 d->rotate->setChecked ( true );
122 //don't use rotate buttons for now (see comment above) 122 //don't use rotate buttons for now (see comment above)
123 //d->rotateButtons->setButton((l->rotation().toInt()%360)/90); 123 //d->rotateButtons->setButton((l->rotation().toInt()%360)/90);
124 } 124 }
125 else { 125 else {
126 d->rotateButtons->setEnabled(false); 126 d->rotateButtons->setEnabled(false);
127 } 127 }
128 128
129 if ( !l->property( "Arguments" ).isEmpty() ) 129 if ( !l->property( "Arguments" ).isEmpty() )
130 d->arguments->setText( l->property( "Arguments" ) ); 130 d->arguments->setText( l->property( "Arguments" ) );
131 131
132 Config cfg("Launcher"); 132 Config cfg("Launcher");
133 cfg.setGroup("Preload"); 133 cfg.setGroup("Preload");
134 QStringList apps = cfg.readListEntry("Apps",','); 134 QStringList apps = cfg.readListEntry("Apps",',');
135 d->preload->setChecked( apps.contains(l->exec()) ); 135 d->preload->setChecked( apps.contains(l->exec()) );
136 if ( Global::isBuiltinCommand(lnk->exec()) ) 136 if ( Global::isBuiltinCommand(lnk->exec()) )
137 d->preload->hide(); // builtins are always fast 137 d->preload->hide(); // builtins are always fast
138 138
139 currentLocation = 0; // apps not movable (yet) 139 currentLocation = 0; // apps not movable (yet)
140 } 140 }
141} 141}
142 142
143LnkProperties::~LnkProperties() 143LnkProperties::~LnkProperties()
144{ 144{
145} 145}
146 146
147void LnkProperties::unlinkLnk() 147void LnkProperties::unlinkLnk()
148{ 148{
149 if ( QPEMessageBox::confirmDelete( this, tr("Delete"), lnk->name() ) ) { 149 if ( QPEMessageBox::confirmDelete( this, tr("Delete"), lnk->name() ) ) {
150 lnk->removeFiles(); 150 lnk->removeFiles();
151 if ( QFile::exists(lnk->file()) ) { 151 if ( QFile::exists(lnk->file()) ) {
152 QMessageBox::warning( this, tr("Delete"), tr("File deletion failed.") ); 152 QMessageBox::warning( this, tr("Delete"), tr("File deletion failed.") );
153 } else { 153 } else {
154 reject(); 154 reject();
155 } 155 }
156 } 156 }
157} 157}
158 158
159void LnkProperties::setupLocations() 159void LnkProperties::setupLocations()
160{ 160{
161 QFileInfo fi( lnk->file() ); 161 QFileInfo fi( lnk->file() );
162 fileSize = fi.size(); 162 fileSize = fi.size();
163 StorageInfo storage; 163 StorageInfo storage;
164 const QList<FileSystem> &fs = storage.fileSystems(); 164 const QList<FileSystem> &fs = storage.fileSystems();
165 QListIterator<FileSystem> it ( fs ); 165 QListIterator<FileSystem> it ( fs );
166 QString s; 166 QString s;
167 QString homeDir = getenv("HOME"); 167 QString homeDir = getenv("HOME");
168 QString hardDiskHome; 168 QString hardDiskHome;
169 QString hardDiskPath; 169 QString hardDiskPath;
170 int index = 0; 170 int index = 0;
171 currentLocation = -1; 171 currentLocation = -1;
172 for ( ; it.current(); ++it ) { 172 for ( ; it.current(); ++it ) {
173 // we add 10k to the file size so we are sure we can also save the desktop file 173 // we add 10k to the file size so we are sure we can also save the desktop file
174 if ( (ulong)(*it)->availBlocks() * (ulong)(*it)->blockSize() > (ulong)fileSize + 10000 ) { 174 if ( (ulong)(*it)->availBlocks() * (ulong)(*it)->blockSize() > (ulong)fileSize + 10000 ) {
175 if ( (*it)->isRemovable() || 175 if ( (*it)->isRemovable() ||
176 (*it)->disk() == "/dev/mtdblock1" || 176 (*it)->disk() == "/dev/mtdblock1" ||
177 (*it)->disk() == "/dev/mtdblock/1" || 177 (*it)->disk() == "/dev/mtdblock/1" ||
178 (*it)->disk().left(13) == "/dev/mtdblock" || 178 (*it)->disk().left(13) == "/dev/mtdblock" ||
179 (*it)->disk() == "/dev/mtdblock6" || 179 (*it)->disk() == "/dev/mtdblock6" ||
180 (*it )->disk() == "/dev/root" || 180 (*it )->disk() == "/dev/root" ||
181 (*it)->disk() == "tmpfs" ) { 181 (*it)->disk() == "tmpfs" ) {
182 d->locationCombo->insertItem( (*it)->name(), index ); 182 d->locationCombo->insertItem( (*it)->name(), index );
183 locations.append( ( ((*it)->isRemovable() || 183 locations.append( ( ((*it)->isRemovable() ||
184 (*it)->disk() == "/dev/mtdblock6" || 184 (*it)->disk() == "/dev/mtdblock6" ||
185 (*it)->disk() == "tmpfs" ) 185 (*it)->disk() == "tmpfs" )
186 ? (*it)->path() : homeDir) ); 186 ? (*it)->path() : homeDir) );
187 if ( lnk->file().contains( (*it)->path() ) ) { 187 if ( lnk->file().contains( (*it)->path() ) ) {
188 d->locationCombo->setCurrentItem( index ); 188 d->locationCombo->setCurrentItem( index );
189 currentLocation = index; 189 currentLocation = index;
190 } 190 }
191 index++; 191 index++;
192 } else if ( (*it)->name().contains( tr("Hard Disk") ) && 192 } else if ( (*it)->name().contains( tr("Hard Disk") ) &&
193 homeDir.contains( (*it)->path() ) && 193 homeDir.contains( (*it)->path() ) &&
194 (*it)->path().length() > hardDiskHome.length() ) { 194 (*it)->path().length() > hardDiskHome.length() ) {
195 hardDiskHome = (*it)->name(); 195 hardDiskHome = (*it)->name();
196 hardDiskPath = (*it)->path(); 196 hardDiskPath = (*it)->path();
197 } 197 }
198 } 198 }
199 } 199 }
200 if ( !hardDiskHome.isEmpty() ) { 200 if ( !hardDiskHome.isEmpty() ) {
201 d->locationCombo->insertItem( hardDiskHome ); 201 d->locationCombo->insertItem( hardDiskHome );
202 locations.append( hardDiskPath ); 202 locations.append( hardDiskPath );
203 if ( currentLocation == -1 ) { // assume it's the hard disk 203 if ( currentLocation == -1 ) { // assume it's the hard disk
204 d->locationCombo->setCurrentItem( index ); 204 d->locationCombo->setCurrentItem( index );
205 currentLocation = index; 205 currentLocation = index;
206 } 206 }
207 } 207 }
208} 208}
209 209
210void LnkProperties::duplicateLnk() 210void LnkProperties::duplicateLnk()
211{ 211{
212 // The duplicate takes the new properties. 212 // The duplicate takes the new properties.
213 DocLnk newdoc( *((DocLnk *)lnk) ); 213 DocLnk newdoc( *((DocLnk *)lnk) );
214 if ( d->docname->text() == lnk->name() ) 214 if ( d->docname->text() == lnk->name() )
215 newdoc.setName(tr("Copy of ")+d->docname->text()); 215 newdoc.setName(tr("Copy of ")+d->docname->text());
216 else 216 else
217 newdoc.setName(d->docname->text()); 217 newdoc.setName(d->docname->text());
218 218
219 if ( !copyFile( newdoc ) ) { 219 if ( !copyFile( newdoc ) ) {
220 QMessageBox::warning( this, tr("Duplicate"), tr("File copy failed.") ); 220 QMessageBox::warning( this, tr("Duplicate"), tr("File copy failed.") );
221 return; 221 return;
222 } 222 }
223 reject(); 223 reject();
224} 224}
225 225
226bool LnkProperties::moveLnk() 226bool LnkProperties::moveLnk()
227{ 227{
228 DocLnk newdoc( *((DocLnk *)lnk) ); 228 DocLnk newdoc( *((DocLnk *)lnk) );
229 newdoc.setName(d->docname->text()); 229 newdoc.setName(d->docname->text());
230 230
231 if ( !copyFile( newdoc ) ) { 231 if ( !copyFile( newdoc ) ) {
232 QMessageBox::warning( this, tr("Details"), tr("Moving Document failed.") ); 232 QMessageBox::warning( this, tr("Details"), tr("Moving Document failed.") );
233 return FALSE; 233 return FALSE;
234 } 234 }
235 // remove old lnk 235 // remove old lnk
236 lnk->removeFiles(); 236 lnk->removeFiles();
237 237
238 return TRUE; 238 return TRUE;
239} 239}
240 240
241void LnkProperties::beamLnk() 241void LnkProperties::beamLnk()
242{ 242{
243 Ir ir; 243 Ir ir;
244 DocLnk doc( *((DocLnk *)lnk) ); 244 DocLnk doc( *((DocLnk *)lnk) );
245 doc.setName(d->docname->text()); 245 doc.setName(d->docname->text());
246 reject(); 246 reject();
247 ir.send( doc, doc.comment() ); 247 ir.send( doc, doc.comment() );
248} 248}
249 249
250bool LnkProperties::copyFile( DocLnk &newdoc ) 250bool LnkProperties::copyFile( DocLnk &newdoc )
251{ 251{
252 const char *linkExtn = ".desktop"; 252 const char *linkExtn = ".desktop";
253 QString fileExtn; 253 QString fileExtn;
254 int extnPos = lnk->file().findRev( '.' ); 254 int extnPos = lnk->file().findRev( '.' );
255 if ( extnPos > 0 ) 255 if ( extnPos > 0 )
256 fileExtn = lnk->file().mid( extnPos ); 256 fileExtn = lnk->file().mid( extnPos );
257 257
258 QString safename = newdoc.name(); 258 QString safename = newdoc.name();
259 safename.replace(QRegExp("/"),"_"); 259 safename.replace(QRegExp("/"),"_");
260 260
261 QString fn = locations[ d->locationCombo->currentItem() ] 261 QString fn = locations[ d->locationCombo->currentItem() ]
262 + "/Documents/" + newdoc.type() + "/" + safename; 262 + "/Documents/" + newdoc.type() + "/" + safename;
263 if ( QFile::exists(fn + fileExtn) || QFile::exists(fn + linkExtn) ) { 263 if ( QFile::exists(fn + fileExtn) || QFile::exists(fn + linkExtn) ) {
264 int n=1; 264 int n=1;
265 QString nn = fn + "_" + QString::number(n); 265 QString nn = fn + "_" + QString::number(n);
266 while ( QFile::exists(nn+fileExtn) || QFile::exists(nn+linkExtn) ) { 266 while ( QFile::exists(nn+fileExtn) || QFile::exists(nn+linkExtn) ) {
267 n++; 267 n++;
268 nn = fn + "_" + QString::number(n); 268 nn = fn + "_" + QString::number(n);
269 } 269 }
270 fn = nn; 270 fn = nn;
271 } 271 }
272 newdoc.setFile( fn + fileExtn ); 272 newdoc.setFile( fn + fileExtn );
273 newdoc.setLinkFile( fn + linkExtn ); 273 newdoc.setLinkFile( fn + linkExtn );
274 274
275 // Copy file 275 // Copy file
276 FileManager fm; 276 FileManager fm;
277 if ( !fm.copyFile( *lnk, newdoc ) ) 277 if ( !fm.copyFile( *lnk, newdoc ) )
278 return FALSE; 278 return FALSE;
279 return TRUE; 279 return TRUE;
280} 280}
281 281
282void LnkProperties::done(int ok) 282void LnkProperties::done(int ok)
283{ 283{
284 if ( ok ) { 284 if ( ok ) {
285 bool changed=FALSE; 285 bool changed=FALSE;
286 bool reloadMime=FALSE; 286 bool reloadMime=FALSE;
287 287
288 if ( lnk->name() != d->docname->text() ) { 288 if ( lnk->name() != d->docname->text() ) {
289 lnk->setName(d->docname->text()); 289 lnk->setName(d->docname->text());
290 changed=TRUE; 290 changed=TRUE;
291 } 291 }
292 if ( d->categoryEdit->isVisible() ) { 292 if ( d->categoryEdit->isVisible() ) {
293 QArray<int> tmp = d->categoryEdit->newCategories(); 293 QArray<int> tmp = d->categoryEdit->newCategories();
294 if ( lnk->categories() != tmp ) { 294 if ( lnk->categories() != tmp ) {
295 lnk->setCategories( tmp ); 295 lnk->setCategories( tmp );
296 changed = TRUE; 296 changed = TRUE;
297 } 297 }
298 } 298 }
299 if ( !d->rotate->isHidden()) { 299 if ( !d->rotate->isHidden()) {
300 QString newrot; 300 QString newrot;
301 301
302 if ( d->rotate->isChecked() ) { 302 if ( d->rotate->isChecked() ) {
303 int rot=0; 303 int rot=0;
304 for(; rot<4; rot++) { 304 for(; rot<4; rot++) {
305 if (d->rotateButtons->find(rot)->isOn()) 305 if (d->rotateButtons->find(rot)->isOn())
306 break; 306 break;
307 } 307 }
308 newrot = QString::number((rot*90)%360); 308 newrot = QString::number((rot*90)%360);
309 } 309 }
310 if ( newrot != lnk->rotation() ) { 310 if ( newrot != lnk->rotation() ) {
311 lnk-> setRotation(newrot); 311 lnk-> setRotation(newrot);
312 changed = TRUE; 312 changed = TRUE;
313 reloadMime = TRUE; 313 reloadMime = TRUE;
314 } 314 }
315 } 315 }
316 if ( d->arguments->text() != lnk->property( "Arguments" ) ) {
317 lnk->setProperty( "Arguments", d->arguments->text() );
318 changed = TRUE;
319 }
316 if ( d->preload->isHidden() && d->locationCombo->currentItem() != currentLocation ) { 320 if ( d->preload->isHidden() && d->locationCombo->currentItem() != currentLocation ) {
317 moveLnk(); 321 moveLnk();
318 } else if ( changed ) { 322 } else if ( changed ) {
319 lnk->writeLink(); 323 lnk->writeLink();
320 } 324 }
321 325
322 if ( !d->preload->isHidden() ) { 326 if ( !d->preload->isHidden() ) {
323 Config cfg("Launcher"); 327 Config cfg("Launcher");
324 cfg.setGroup("Preload"); 328 cfg.setGroup("Preload");
325 QStringList apps = cfg.readListEntry("Apps",','); 329 QStringList apps = cfg.readListEntry("Apps",',');
326 QString exe = lnk->exec(); 330 QString exe = lnk->exec();
327 if ( apps.contains(exe) != d->preload->isChecked() ) { 331 if ( apps.contains(exe) != d->preload->isChecked() ) {
328 if ( d->preload->isChecked() ) { 332 if ( d->preload->isChecked() ) {
329 apps.append(exe); 333 apps.append(exe);
330#ifndef QT_NO_COP 334#ifndef QT_NO_COP
331 QCopEnvelope e("QPE/Application/"+exe.local8Bit(), 335 QCopEnvelope e("QPE/Application/"+exe.local8Bit(),
332 "enablePreload()"); 336 "enablePreload()");
333#endif 337#endif
334 } else { 338 } else {
335 apps.remove(exe); 339 apps.remove(exe);
336#ifndef QT_NO_COP 340#ifndef QT_NO_COP
337 QCopEnvelope e("QPE/Application/"+exe.local8Bit(), 341 QCopEnvelope e("QPE/Application/"+exe.local8Bit(),
338 "quitIfInvisible()"); 342 "quitIfInvisible()");
339#endif 343#endif
340 } 344 }
341 cfg.writeEntry("Apps",apps,','); 345 cfg.writeEntry("Apps",apps,',');
342 } 346 }
343 } 347 }
344 if ( reloadMime ) 348 if ( reloadMime )
345 MimeType::updateApplications ( ); 349 MimeType::updateApplications ( );
346 } 350 }
347 QDialog::done( ok ); 351 QDialog::done( ok );
348} 352}
349 353