kitchensync

aboutpage.cpp
1/*
2 This file is part of KitchenSync.
3
4 Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19*/
20
21#include <tqfile.h>
22#include <tqlayout.h>
23
24#include <tdeaboutdata.h>
25#include <tdeapplication.h>
26#include <kdebug.h>
27#include <tdehtml_part.h>
28#include <tdehtmlview.h>
29#include <kiconloader.h>
30#include <tdelocale.h>
31#include <krun.h>
32#include <kstandarddirs.h>
33
34#include "aboutpage.h"
35
36static TQString readFile( const TQString &fileName )
37{
38 TQFile file( fileName );
39 if ( !file.open( IO_ReadOnly ) ) {
40 kdDebug() << "Unable to open file '" << fileName << "'" << endl;
41 return TQCString();
42 }
43
44 TQString content = TQString::fromUtf8( file.readAll() );
45
46 file.close();
47
48 return content;
49}
50
51AboutPage::AboutPage( TQWidget *parent )
52 : TQWidget( parent, "AboutPage" )
53{
54 TQVBoxLayout *layout = new TQVBoxLayout( this );
55
56 TQString location = locate( "data", "kitchensync/about/main.html" );
57 TQString content = readFile( location );
58 content = content.arg( locate( "data", "libtdepim/about/kde_infopage.css" ) );
59 if ( kapp->reverseLayout() )
60 content = content.arg( "@import \"%1\";" ).arg( locate( "data", "libtdepim/about/kde_infopage_rtl.css" ) );
61 else
62 content = content.arg( "" );
63
64 TDEHTMLPart *part = new TDEHTMLPart( this );
65 layout->addWidget( part->view() );
66
67 part->begin( KURL( location ) );
68
69 TQString appName( i18n( "TDE KitchenSync" ) );
70 TQString catchPhrase( i18n( "Get Synchronized!" ) );
71 TQString quickDescription( i18n( "The TDE Synchronization Tool" ) );
72
73 part->write( content.arg( TQFont().pointSize() + 2 ).arg( appName )
74 .arg( catchPhrase ).arg( quickDescription ).arg( htmlText() ) );
75 part->end();
76
77 connect( part->browserExtension(),
78 TQT_SIGNAL( openURLRequest( const KURL&, const KParts::URLArgs& ) ),
79 TQT_SLOT( handleUrl( const KURL& ) ) );
80
81 connect( part->browserExtension(),
82 TQT_SIGNAL( createNewWindow( const KURL&, const KParts::URLArgs& ) ),
83 TQT_SLOT( handleUrl( const KURL& ) ) );
84}
85
86void AboutPage::handleUrl( const KURL &url )
87{
88 if ( url.protocol() == "exec" ) {
89 if ( url.path() == "/addGroup" )
90 emit addGroup();
91 } else
92 new KRun( url, this );
93}
94
95TQString AboutPage::htmlText() const
96{
97 TDEIconLoader *iconloader = TDEGlobal::iconLoader();
98 int iconSize = iconloader->currentSize( TDEIcon::Desktop );
99
100 TQString handbook_icon_path = iconloader->iconPath( "contents2", TDEIcon::Desktop );
101 TQString html_icon_path = iconloader->iconPath( "text-html", TDEIcon::Desktop );
102 TQString wizard_icon_path = iconloader->iconPath( "wizard", TDEIcon::Desktop );
103
104 TQString info = i18n( "<h2 style='text-align:center; margin-top: 0px;'>Welcome to KitchenSync %1</h2>"
105 "<p>%1</p>"
106 "<table align=\"center\">"
107 "<tr><td><a href=\"%1\"><img width=\"%1\" height=\"%1\" src=\"%1\" /></a></td>"
108 "<td><a href=\"%1\">%1</a><br><span id=\"subtext\"><nobr>%1</td></tr>"
109 "<tr><td><a href=\"%1\"><img width=\"%1\" height=\"%1\" src=\"%1\" /></a></td>"
110 "<td><a href=\"%1\">%1</a><br><span id=\"subtext\"><nobr>%1</td></tr>"
111 "<tr><td><a href=\"%1\"><img width=\"%1\" height=\"%1\" src=\"%1\" /></a></td>"
112 "<td><a href=\"%1\">%1</a><br><span id=\"subtext\"><nobr>%1</td></tr>"
113 "</table>" )
114 .arg( kapp->aboutData()->version() )
115 .arg( i18n( "KitchenSync synchronizes your e-mail, addressbook, calendar, to-do list and more." ) )
116 .arg( "help:/kitchensync" )
117 .arg( iconSize )
118 .arg( iconSize )
119 .arg( handbook_icon_path )
120 .arg( "help:/kitchensync" )
121 .arg( i18n( "Read Manual" ) )
122 .arg( i18n( "Learn more about KitchenSync and its components" ) )
123 .arg( "http://pim.kde.org" )
124 .arg( iconSize )
125 .arg( iconSize )
126 .arg( html_icon_path )
127 .arg( "http://pim.kde.org" )
128 .arg( i18n( "Visit KitchenSync Website" ) )
129 .arg( i18n( "Access online resources and tutorials" ) )
130 .arg( "exec:/addGroup" )
131 .arg( iconSize )
132 .arg( iconSize )
133 .arg( wizard_icon_path )
134 .arg( "exec:/addGroup" )
135 .arg( i18n( "Add Synchronization Group" ) )
136 .arg( i18n( "Create group of devices for synchronization" ) );
137
138 return info;
139}
140
141#include "aboutpage.moc"