-rw-r--r-- | library/lnkproperties.cpp | 4 |
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 | |||
@@ -188,162 +188,166 @@ void LnkProperties::setupLocations() | |||
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 | ||
210 | void LnkProperties::duplicateLnk() | 210 | void 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 | ||
226 | bool LnkProperties::moveLnk() | 226 | bool 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 | ||
241 | void LnkProperties::beamLnk() | 241 | void 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 | ||
250 | bool LnkProperties::copyFile( DocLnk &newdoc ) | 250 | bool 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 | ||
282 | void LnkProperties::done(int ok) | 282 | void 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 | ||