summaryrefslogtreecommitdiff
path: root/library/lnkproperties.cpp
Unidiff
Diffstat (limited to 'library/lnkproperties.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/lnkproperties.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/library/lnkproperties.cpp b/library/lnkproperties.cpp
index 0661423..865f590 100644
--- a/library/lnkproperties.cpp
+++ b/library/lnkproperties.cpp
@@ -1,256 +1,259 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the 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
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
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 "lnkpropertiesbase_p.h" 24#include "lnkpropertiesbase_p.h"
25#include "lnkproperties.h" 25#include "lnkproperties.h"
26#include "ir.h" 26#include "ir.h"
27 27
28#include <qpe/qpeapplication.h> 28#include <qpe/qpeapplication.h>
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#include <qpe/qcopenvelope_qws.h> 32#include <qpe/qcopenvelope_qws.h>
33#include <qpe/filemanager.h> 33#include <qpe/filemanager.h>
34#include <qpe/config.h> 34#include <qpe/config.h>
35#include <qpe/storage.h> 35#include <qpe/storage.h>
36#include <qpe/qpemessagebox.h> 36#include <qpe/qpemessagebox.h>
37#include <qpe/mimetype.h> 37#include <qpe/mimetype.h>
38 38
39#include <qlineedit.h> 39#include <qlineedit.h>
40#include <qtoolbutton.h> 40#include <qtoolbutton.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qgroupbox.h> 42#include <qgroupbox.h>
43#include <qcheckbox.h> 43#include <qcheckbox.h>
44#include <qlabel.h> 44#include <qlabel.h>
45#include <qlayout.h> 45#include <qlayout.h>
46#include <qfile.h> 46#include <qfile.h>
47#include <qfileinfo.h> 47#include <qfileinfo.h>
48#include <qmessagebox.h> 48#include <qmessagebox.h>
49#include <qsize.h> 49#include <qsize.h>
50#include <qcombobox.h> 50#include <qcombobox.h>
51#include <qregexp.h> 51#include <qregexp.h>
52#include <qbuttongroup.h> 52#include <qbuttongroup.h>
53 53
54#include <stdlib.h> 54#include <stdlib.h>
55 55
56LnkProperties::LnkProperties( AppLnk* l, QWidget* parent ) 56LnkProperties::LnkProperties( AppLnk* l, QWidget* parent )
57 : QDialog( parent, 0, TRUE ), lnk(l), fileSize( 0 ) 57 : QDialog( parent, 0, TRUE ), lnk(l), fileSize( 0 )
58{ 58{
59 setCaption( tr("Properties") ); 59 setCaption( tr("Properties") );
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() )
130 d->arguments->setText( l->property( "Arguments" ) );
131
129 Config cfg("Launcher"); 132 Config cfg("Launcher");
130 cfg.setGroup("Preload"); 133 cfg.setGroup("Preload");
131 QStringList apps = cfg.readListEntry("Apps",','); 134 QStringList apps = cfg.readListEntry("Apps",',');
132 d->preload->setChecked( apps.contains(l->exec()) ); 135 d->preload->setChecked( apps.contains(l->exec()) );
133 if ( Global::isBuiltinCommand(lnk->exec()) ) 136 if ( Global::isBuiltinCommand(lnk->exec()) )
134 d->preload->hide(); // builtins are always fast 137 d->preload->hide(); // builtins are always fast
135 138
136 currentLocation = 0; // apps not movable (yet) 139 currentLocation = 0; // apps not movable (yet)
137 } 140 }
138} 141}
139 142
140LnkProperties::~LnkProperties() 143LnkProperties::~LnkProperties()
141{ 144{
142} 145}
143 146
144void LnkProperties::unlinkLnk() 147void LnkProperties::unlinkLnk()
145{ 148{
146 if ( QPEMessageBox::confirmDelete( this, tr("Delete"), lnk->name() ) ) { 149 if ( QPEMessageBox::confirmDelete( this, tr("Delete"), lnk->name() ) ) {
147 lnk->removeFiles(); 150 lnk->removeFiles();
148 if ( QFile::exists(lnk->file()) ) { 151 if ( QFile::exists(lnk->file()) ) {
149 QMessageBox::warning( this, tr("Delete"), tr("File deletion failed.") ); 152 QMessageBox::warning( this, tr("Delete"), tr("File deletion failed.") );
150 } else { 153 } else {
151 reject(); 154 reject();
152 } 155 }
153 } 156 }
154} 157}
155 158
156void LnkProperties::setupLocations() 159void LnkProperties::setupLocations()
157{ 160{
158 QFileInfo fi( lnk->file() ); 161 QFileInfo fi( lnk->file() );
159 fileSize = fi.size(); 162 fileSize = fi.size();
160 StorageInfo storage; 163 StorageInfo storage;
161 const QList<FileSystem> &fs = storage.fileSystems(); 164 const QList<FileSystem> &fs = storage.fileSystems();
162 QListIterator<FileSystem> it ( fs ); 165 QListIterator<FileSystem> it ( fs );
163 QString s; 166 QString s;
164 QString homeDir = getenv("HOME"); 167 QString homeDir = getenv("HOME");
165 QString hardDiskHome; 168 QString hardDiskHome;
166 QString hardDiskPath; 169 QString hardDiskPath;
167 int index = 0; 170 int index = 0;
168 currentLocation = -1; 171 currentLocation = -1;
169 for ( ; it.current(); ++it ) { 172 for ( ; it.current(); ++it ) {
170 // 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
171 if ( (ulong)(*it)->availBlocks() * (ulong)(*it)->blockSize() > (ulong)fileSize + 10000 ) { 174 if ( (ulong)(*it)->availBlocks() * (ulong)(*it)->blockSize() > (ulong)fileSize + 10000 ) {
172 if ( (*it)->isRemovable() || 175 if ( (*it)->isRemovable() ||
173 (*it)->disk() == "/dev/mtdblock1" || 176 (*it)->disk() == "/dev/mtdblock1" ||
174 (*it)->disk() == "/dev/mtdblock/1" || 177 (*it)->disk() == "/dev/mtdblock/1" ||
175 (*it)->disk().left(13) == "/dev/mtdblock" || 178 (*it)->disk().left(13) == "/dev/mtdblock" ||
176 (*it)->disk() == "/dev/mtdblock6" || 179 (*it)->disk() == "/dev/mtdblock6" ||
177 (*it )->disk() == "/dev/root" || 180 (*it )->disk() == "/dev/root" ||
178 (*it)->disk() == "tmpfs" ) { 181 (*it)->disk() == "tmpfs" ) {
179 d->locationCombo->insertItem( (*it)->name(), index ); 182 d->locationCombo->insertItem( (*it)->name(), index );
180 locations.append( ( ((*it)->isRemovable() || 183 locations.append( ( ((*it)->isRemovable() ||
181 (*it)->disk() == "/dev/mtdblock6" || 184 (*it)->disk() == "/dev/mtdblock6" ||
182 (*it)->disk() == "tmpfs" ) 185 (*it)->disk() == "tmpfs" )
183 ? (*it)->path() : homeDir) ); 186 ? (*it)->path() : homeDir) );
184 if ( lnk->file().contains( (*it)->path() ) ) { 187 if ( lnk->file().contains( (*it)->path() ) ) {
185 d->locationCombo->setCurrentItem( index ); 188 d->locationCombo->setCurrentItem( index );
186 currentLocation = index; 189 currentLocation = index;
187 } 190 }
188 index++; 191 index++;
189 } else if ( (*it)->name().contains( tr("Hard Disk") ) && 192 } else if ( (*it)->name().contains( tr("Hard Disk") ) &&
190 homeDir.contains( (*it)->path() ) && 193 homeDir.contains( (*it)->path() ) &&
191 (*it)->path().length() > hardDiskHome.length() ) { 194 (*it)->path().length() > hardDiskHome.length() ) {
192 hardDiskHome = (*it)->name(); 195 hardDiskHome = (*it)->name();
193 hardDiskPath = (*it)->path(); 196 hardDiskPath = (*it)->path();
194 } 197 }
195 } 198 }
196 } 199 }
197 if ( !hardDiskHome.isEmpty() ) { 200 if ( !hardDiskHome.isEmpty() ) {
198 d->locationCombo->insertItem( hardDiskHome ); 201 d->locationCombo->insertItem( hardDiskHome );
199 locations.append( hardDiskPath ); 202 locations.append( hardDiskPath );
200 if ( currentLocation == -1 ) { // assume it's the hard disk 203 if ( currentLocation == -1 ) { // assume it's the hard disk
201 d->locationCombo->setCurrentItem( index ); 204 d->locationCombo->setCurrentItem( index );
202 currentLocation = index; 205 currentLocation = index;
203 } 206 }
204 } 207 }
205} 208}
206 209
207void LnkProperties::duplicateLnk() 210void LnkProperties::duplicateLnk()
208{ 211{
209 // The duplicate takes the new properties. 212 // The duplicate takes the new properties.
210 DocLnk newdoc( *((DocLnk *)lnk) ); 213 DocLnk newdoc( *((DocLnk *)lnk) );
211 if ( d->docname->text() == lnk->name() ) 214 if ( d->docname->text() == lnk->name() )
212 newdoc.setName(tr("Copy of ")+d->docname->text()); 215 newdoc.setName(tr("Copy of ")+d->docname->text());
213 else 216 else
214 newdoc.setName(d->docname->text()); 217 newdoc.setName(d->docname->text());
215 218
216 if ( !copyFile( newdoc ) ) { 219 if ( !copyFile( newdoc ) ) {
217 QMessageBox::warning( this, tr("Duplicate"), tr("File copy failed.") ); 220 QMessageBox::warning( this, tr("Duplicate"), tr("File copy failed.") );
218 return; 221 return;
219 } 222 }
220 reject(); 223 reject();
221} 224}
222 225
223bool LnkProperties::moveLnk() 226bool LnkProperties::moveLnk()
224{ 227{
225 DocLnk newdoc( *((DocLnk *)lnk) ); 228 DocLnk newdoc( *((DocLnk *)lnk) );
226 newdoc.setName(d->docname->text()); 229 newdoc.setName(d->docname->text());
227 230
228 if ( !copyFile( newdoc ) ) { 231 if ( !copyFile( newdoc ) ) {
229 QMessageBox::warning( this, tr("Details"), tr("Moving Document failed.") ); 232 QMessageBox::warning( this, tr("Details"), tr("Moving Document failed.") );
230 return FALSE; 233 return FALSE;
231 } 234 }
232 // remove old lnk 235 // remove old lnk
233 lnk->removeFiles(); 236 lnk->removeFiles();
234 237
235 return TRUE; 238 return TRUE;
236} 239}
237 240
238void LnkProperties::beamLnk() 241void LnkProperties::beamLnk()
239{ 242{
240 Ir ir; 243 Ir ir;
241 DocLnk doc( *((DocLnk *)lnk) ); 244 DocLnk doc( *((DocLnk *)lnk) );
242 doc.setName(d->docname->text()); 245 doc.setName(d->docname->text());
243 reject(); 246 reject();
244 ir.send( doc, doc.comment() ); 247 ir.send( doc, doc.comment() );
245} 248}
246 249
247bool LnkProperties::copyFile( DocLnk &newdoc ) 250bool LnkProperties::copyFile( DocLnk &newdoc )
248{ 251{
249 const char *linkExtn = ".desktop"; 252 const char *linkExtn = ".desktop";
250 QString fileExtn; 253 QString fileExtn;
251 int extnPos = lnk->file().findRev( '.' ); 254 int extnPos = lnk->file().findRev( '.' );
252 if ( extnPos > 0 ) 255 if ( extnPos > 0 )
253 fileExtn = lnk->file().mid( extnPos ); 256 fileExtn = lnk->file().mid( extnPos );
254 257
255 QString safename = newdoc.name(); 258 QString safename = newdoc.name();
256 safename.replace(QRegExp("/"),"_"); 259 safename.replace(QRegExp("/"),"_");