summaryrefslogtreecommitdiff
path: root/library/lnkproperties.cpp
Unidiff
Diffstat (limited to 'library/lnkproperties.cpp') (more/less context) (show whitespace changes)
-rw-r--r--library/lnkproperties.cpp48
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,10 +1,10 @@
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**
@@ -26,13 +26,15 @@
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>
@@ -51,12 +53,14 @@
51 53
52#include <stdlib.h> 54#include <stdlib.h>
53 55
54LnkProperties::LnkProperties( AppLnk* l, QWidget* parent ) 56LnkProperties::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;
@@ -75,13 +79,12 @@ LnkProperties::LnkProperties( AppLnk* l, QWidget* parent )
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
@@ -114,50 +117,30 @@ LnkProperties::LnkProperties( AppLnk* l, QWidget* parent )
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
123LnkProperties::~LnkProperties() 125LnkProperties::~LnkProperties()
124{ 126{
125} 127}
126 128
127void LnkProperties::unlinkLnk() 129void 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 */
146void 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
158void LnkProperties::setupLocations() 141void 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();
@@ -167,19 +150,24 @@ void LnkProperties::setupLocations()
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") ) &&
@@ -232,12 +220,14 @@ bool LnkProperties::moveLnk()
232} 220}
233 221
234void LnkProperties::beamLnk() 222void 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
241bool LnkProperties::copyFile( DocLnk &newdoc ) 231bool LnkProperties::copyFile( DocLnk &newdoc )
242{ 232{
243 const char *linkExtn = ".desktop"; 233 const char *linkExtn = ".desktop";
@@ -296,18 +286,22 @@ void LnkProperties::done(int ok)
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 );