summaryrefslogtreecommitdiff
authorsandman <sandman>2002-10-09 23:01:34 (UTC)
committer sandman <sandman>2002-10-09 23:01:34 (UTC)
commitd624bf47913f76c881f28c6498cec4ad3c007a9b (patch) (unidiff)
treef86e449f8f5153580bead802c9c6f73dd76c3a11
parentecd41d0df770747bb07de5fa3e920adb164affbe (diff)
downloadopie-d624bf47913f76c881f28c6498cec4ad3c007a9b.zip
opie-d624bf47913f76c881f28c6498cec4ad3c007a9b.tar.gz
opie-d624bf47913f76c881f28c6498cec4ad3c007a9b.tar.bz2
Opening documents via the document tab now starts the corresponding app
with the right rotation setting. Filemanager/AdvanceFM doesn't work -- need to investigate this further.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/lnkproperties.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/library/lnkproperties.cpp b/library/lnkproperties.cpp
index 745ee2c..0b50bae 100644
--- a/library/lnkproperties.cpp
+++ b/library/lnkproperties.cpp
@@ -1,87 +1,88 @@
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 "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/qpeapplication.h> 29#include <qpe/qpeapplication.h>
30#include <qpe/applnk.h> 30#include <qpe/applnk.h>
31#include <qpe/global.h> 31#include <qpe/global.h>
32#include <qpe/categorywidget.h> 32#include <qpe/categorywidget.h>
33#ifdef QWS 33#ifdef QWS
34#include <qpe/qcopenvelope_qws.h> 34#include <qpe/qcopenvelope_qws.h>
35#endif 35#endif
36#include <qpe/filemanager.h> 36#include <qpe/filemanager.h>
37#include <qpe/config.h> 37#include <qpe/config.h>
38#include <qpe/storage.h> 38#include <qpe/storage.h>
39#include <qpe/qpemessagebox.h> 39#include <qpe/qpemessagebox.h>
40#include <qpe/mimetype.h>
40 41
41#include <qlineedit.h> 42#include <qlineedit.h>
42#include <qtoolbutton.h> 43#include <qtoolbutton.h>
43#include <qpushbutton.h> 44#include <qpushbutton.h>
44#include <qgroupbox.h> 45#include <qgroupbox.h>
45#include <qcheckbox.h> 46#include <qcheckbox.h>
46#include <qlabel.h> 47#include <qlabel.h>
47#include <qlayout.h> 48#include <qlayout.h>
48#include <qfile.h> 49#include <qfile.h>
49#include <qfileinfo.h> 50#include <qfileinfo.h>
50#include <qmessagebox.h> 51#include <qmessagebox.h>
51#include <qsize.h> 52#include <qsize.h>
52#include <qcombobox.h> 53#include <qcombobox.h>
53#include <qregexp.h> 54#include <qregexp.h>
54#include <qbuttongroup.h> 55#include <qbuttongroup.h>
55 56
56#include <stdlib.h> 57#include <stdlib.h>
57 58
58LnkProperties::LnkProperties( AppLnk* l, QWidget* parent ) 59LnkProperties::LnkProperties( AppLnk* l, QWidget* parent )
59 : QDialog( parent, 0, TRUE ), lnk(l), fileSize( 0 ) 60 : QDialog( parent, 0, TRUE ), lnk(l), fileSize( 0 )
60{ 61{
61 setCaption( tr("Properties") ); 62 setCaption( tr("Properties") );
62 63
63 QVBoxLayout *vbox = new QVBoxLayout( this ); 64 QVBoxLayout *vbox = new QVBoxLayout( this );
64 d = new LnkPropertiesBase( this ); 65 d = new LnkPropertiesBase( this );
65 vbox->add( d ); 66 vbox->add( d );
66 67
67 d->docname->setText(l->name()); 68 d->docname->setText(l->name());
68 QString inf; 69 QString inf;
69 if ( l->type().isEmpty() ) { 70 if ( l->type().isEmpty() ) {
70 d->type->hide(); 71 d->type->hide();
71 d->typeLabel->hide(); 72 d->typeLabel->hide();
72 } else { 73 } else {
73 d->type->setText( l->type() ); 74 d->type->setText( l->type() );
74 } 75 }
75 76
76 if ( l->comment().isEmpty() ) { 77 if ( l->comment().isEmpty() ) {
77 d->comment->hide(); 78 d->comment->hide();
78 d->commentLabel->hide(); 79 d->commentLabel->hide();
79 } else { 80 } else {
80 d->comment->setText( l->comment() ); 81 d->comment->setText( l->comment() );
81 } 82 }
82 83
83 connect(d->beam,SIGNAL(clicked()),this,SLOT(beamLnk())); 84 connect(d->beam,SIGNAL(clicked()),this,SLOT(beamLnk()));
84 if ( lnk->type().contains('/') ) { // A document? (#### better predicate needed) 85 if ( lnk->type().contains('/') ) { // A document? (#### better predicate needed)
85 connect(d->unlink,SIGNAL(clicked()),this,SLOT(unlinkLnk())); 86 connect(d->unlink,SIGNAL(clicked()),this,SLOT(unlinkLnk()));
86 connect(d->duplicate,SIGNAL(clicked()),this,SLOT(duplicateLnk())); 87 connect(d->duplicate,SIGNAL(clicked()),this,SLOT(duplicateLnk()));
87 88
@@ -230,107 +231,112 @@ bool LnkProperties::moveLnk()
230 return TRUE; 231 return TRUE;
231} 232}
232 233
233void LnkProperties::beamLnk() 234void LnkProperties::beamLnk()
234{ 235{
235 Ir ir; 236 Ir ir;
236 DocLnk doc( *((DocLnk *)lnk) ); 237 DocLnk doc( *((DocLnk *)lnk) );
237 doc.setName(d->docname->text()); 238 doc.setName(d->docname->text());
238 reject(); 239 reject();
239 ir.send( doc, doc.comment() ); 240 ir.send( doc, doc.comment() );
240} 241}
241 242
242bool LnkProperties::copyFile( DocLnk &newdoc ) 243bool LnkProperties::copyFile( DocLnk &newdoc )
243{ 244{
244 const char *linkExtn = ".desktop"; 245 const char *linkExtn = ".desktop";
245 QString fileExtn; 246 QString fileExtn;
246 int extnPos = lnk->file().findRev( '.' ); 247 int extnPos = lnk->file().findRev( '.' );
247 if ( extnPos > 0 ) 248 if ( extnPos > 0 )
248 fileExtn = lnk->file().mid( extnPos ); 249 fileExtn = lnk->file().mid( extnPos );
249 250
250 QString safename = newdoc.name(); 251 QString safename = newdoc.name();
251 safename.replace(QRegExp("/"),"_"); 252 safename.replace(QRegExp("/"),"_");
252 253
253 QString fn = locations[ d->locationCombo->currentItem() ] 254 QString fn = locations[ d->locationCombo->currentItem() ]
254 + "/Documents/" + newdoc.type() + "/" + safename; 255 + "/Documents/" + newdoc.type() + "/" + safename;
255 if ( QFile::exists(fn + fileExtn) || QFile::exists(fn + linkExtn) ) { 256 if ( QFile::exists(fn + fileExtn) || QFile::exists(fn + linkExtn) ) {
256 int n=1; 257 int n=1;
257 QString nn = fn + "_" + QString::number(n); 258 QString nn = fn + "_" + QString::number(n);
258 while ( QFile::exists(nn+fileExtn) || QFile::exists(nn+linkExtn) ) { 259 while ( QFile::exists(nn+fileExtn) || QFile::exists(nn+linkExtn) ) {
259 n++; 260 n++;
260 nn = fn + "_" + QString::number(n); 261 nn = fn + "_" + QString::number(n);
261 } 262 }
262 fn = nn; 263 fn = nn;
263 } 264 }
264 newdoc.setFile( fn + fileExtn ); 265 newdoc.setFile( fn + fileExtn );
265 newdoc.setLinkFile( fn + linkExtn ); 266 newdoc.setLinkFile( fn + linkExtn );
266 267
267 // Copy file 268 // Copy file
268 FileManager fm; 269 FileManager fm;
269 if ( !fm.copyFile( *lnk, newdoc ) ) 270 if ( !fm.copyFile( *lnk, newdoc ) )
270 return FALSE; 271 return FALSE;
271 return TRUE; 272 return TRUE;
272} 273}
273 274
274void LnkProperties::done(int ok) 275void LnkProperties::done(int ok)
275{ 276{
276 if ( ok ) { 277 if ( ok ) {
277 bool changed=FALSE; 278 bool changed=FALSE;
279 bool reloadMime=FALSE;
280
278 if ( lnk->name() != d->docname->text() ) { 281 if ( lnk->name() != d->docname->text() ) {
279 lnk->setName(d->docname->text()); 282 lnk->setName(d->docname->text());
280 changed=TRUE; 283 changed=TRUE;
281 } 284 }
282 if ( d->categoryEdit->isVisible() ) { 285 if ( d->categoryEdit->isVisible() ) {
283 QArray<int> tmp = d->categoryEdit->newCategories(); 286 QArray<int> tmp = d->categoryEdit->newCategories();
284 if ( lnk->categories() != tmp ) { 287 if ( lnk->categories() != tmp ) {
285 lnk->setCategories( tmp ); 288 lnk->setCategories( tmp );
286 changed = TRUE; 289 changed = TRUE;
287 } 290 }
288 } 291 }
289 if ( !d->rotate->isHidden()) { 292 if ( !d->rotate->isHidden()) {
290 QString newrot; 293 QString newrot;
291 294
292 if ( d->rotate->isChecked() ) { 295 if ( d->rotate->isChecked() ) {
293 int rot=0; 296 int rot=0;
294 for(; rot<4; rot++) { 297 for(; rot<4; rot++) {
295 if (d->rotateButtons->find(rot)->isOn()) 298 if (d->rotateButtons->find(rot)->isOn())
296 break; 299 break;
297 } 300 }
298 newrot = QString::number((rot*90)%360); 301 newrot = QString::number((rot*90)%360);
299 } 302 }
300 if ( newrot != lnk->rotation() ) { 303 if ( newrot != lnk->rotation() ) {
301 lnk-> setRotation(newrot); 304 lnk-> setRotation(newrot);
302 changed = TRUE; 305 changed = TRUE;
306 reloadMime = TRUE;
303 } 307 }
304 } 308 }
305 if ( d->preload->isHidden() && d->locationCombo->currentItem() != currentLocation ) { 309 if ( d->preload->isHidden() && d->locationCombo->currentItem() != currentLocation ) {
306 moveLnk(); 310 moveLnk();
307 } else if ( changed ) { 311 } else if ( changed ) {
308 lnk->writeLink(); 312 lnk->writeLink();
309 } 313 }
310 314
311 if ( !d->preload->isHidden() ) { 315 if ( !d->preload->isHidden() ) {
312 Config cfg("Launcher"); 316 Config cfg("Launcher");
313 cfg.setGroup("Preload"); 317 cfg.setGroup("Preload");
314 QStringList apps = cfg.readListEntry("Apps",','); 318 QStringList apps = cfg.readListEntry("Apps",',');
315 QString exe = lnk->exec(); 319 QString exe = lnk->exec();
316 if ( apps.contains(exe) != d->preload->isChecked() ) { 320 if ( apps.contains(exe) != d->preload->isChecked() ) {
317 if ( d->preload->isChecked() ) { 321 if ( d->preload->isChecked() ) {
318 apps.append(exe); 322 apps.append(exe);
319#ifndef QT_NO_COP 323#ifndef QT_NO_COP
320 QCopEnvelope e("QPE/Application/"+exe.local8Bit(), 324 QCopEnvelope e("QPE/Application/"+exe.local8Bit(),
321 "enablePreload()"); 325 "enablePreload()");
322#endif 326#endif
323 } else { 327 } else {
324 apps.remove(exe); 328 apps.remove(exe);
325#ifndef QT_NO_COP 329#ifndef QT_NO_COP
326 QCopEnvelope e("QPE/Application/"+exe.local8Bit(), 330 QCopEnvelope e("QPE/Application/"+exe.local8Bit(),
327 "quitIfInvisible()"); 331 "quitIfInvisible()");
328#endif 332#endif
329 } 333 }
330 cfg.writeEntry("Apps",apps,','); 334 cfg.writeEntry("Apps",apps,',');
331 } 335 }
332 } 336 }
337 if ( reloadMime )
338 MimeType::updateApplications ( );
333 } 339 }
334 QDialog::done( ok ); 340 QDialog::done( ok );
335} 341}
336 342