aboutpage.cpp
00001 /* 00002 This file is part of KitchenSync. 00003 00004 Copyright (c) 2005 Tobias Koenig <tokoe@kde.org> 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #include <tqfile.h> 00022 #include <tqlayout.h> 00023 00024 #include <kaboutdata.h> 00025 #include <kapplication.h> 00026 #include <kdebug.h> 00027 #include <khtml_part.h> 00028 #include <khtmlview.h> 00029 #include <kiconloader.h> 00030 #include <klocale.h> 00031 #include <krun.h> 00032 #include <kstandarddirs.h> 00033 00034 #include "aboutpage.h" 00035 00036 static TQString readFile( const TQString &fileName ) 00037 { 00038 TQFile file( fileName ); 00039 if ( !file.open( IO_ReadOnly ) ) { 00040 kdDebug() << "Unable to open file '" << fileName << "'" << endl; 00041 return TQCString(); 00042 } 00043 00044 TQString content = TQString::fromUtf8( file.readAll() ); 00045 00046 file.close(); 00047 00048 return content; 00049 } 00050 00051 AboutPage::AboutPage( TQWidget *parent ) 00052 : TQWidget( parent, "AboutPage" ) 00053 { 00054 TQVBoxLayout *layout = new TQVBoxLayout( this ); 00055 00056 TQString location = locate( "data", "kitchensync/about/main.html" ); 00057 TQString content = readFile( location ); 00058 content = content.arg( locate( "data", "libkdepim/about/kde_infopage.css" ) ); 00059 if ( kapp->reverseLayout() ) 00060 content = content.arg( "@import \"%1\";" ).arg( locate( "data", "libkdepim/about/kde_infopage_rtl.css" ) ); 00061 else 00062 content = content.arg( "" ); 00063 00064 KHTMLPart *part = new KHTMLPart( this ); 00065 layout->addWidget( part->view() ); 00066 00067 part->begin( KURL( location ) ); 00068 00069 TQString appName( i18n( "KDE KitchenSync" ) ); 00070 TQString catchPhrase( i18n( "Get Synchronized!" ) ); 00071 TQString quickDescription( i18n( "The KDE Synchronization Tool" ) ); 00072 00073 part->write( content.arg( TQFont().pointSize() + 2 ).arg( appName ) 00074 .arg( catchPhrase ).arg( quickDescription ).arg( htmlText() ) ); 00075 part->end(); 00076 00077 connect( part->browserExtension(), 00078 TQT_SIGNAL( openURLRequest( const KURL&, const KParts::URLArgs& ) ), 00079 TQT_SLOT( handleUrl( const KURL& ) ) ); 00080 00081 connect( part->browserExtension(), 00082 TQT_SIGNAL( createNewWindow( const KURL&, const KParts::URLArgs& ) ), 00083 TQT_SLOT( handleUrl( const KURL& ) ) ); 00084 } 00085 00086 void AboutPage::handleUrl( const KURL &url ) 00087 { 00088 if ( url.protocol() == "exec" ) { 00089 if ( url.path() == "/addGroup" ) 00090 emit addGroup(); 00091 } else 00092 new KRun( url, this ); 00093 } 00094 00095 TQString AboutPage::htmlText() const 00096 { 00097 KIconLoader *iconloader = KGlobal::iconLoader(); 00098 int iconSize = iconloader->currentSize( KIcon::Desktop ); 00099 00100 TQString handbook_icon_path = iconloader->iconPath( "contents2", KIcon::Desktop ); 00101 TQString html_icon_path = iconloader->iconPath( "html", KIcon::Desktop ); 00102 TQString wizard_icon_path = iconloader->iconPath( "wizard", KIcon::Desktop ); 00103 00104 TQString info = i18n( "<h2 style='text-align:center; margin-top: 0px;'>Welcome to KitchenSync %1</h2>" 00105 "<p>%1</p>" 00106 "<table align=\"center\">" 00107 "<tr><td><a href=\"%1\"><img width=\"%1\" height=\"%1\" src=\"%1\" /></a></td>" 00108 "<td><a href=\"%1\">%1</a><br><span id=\"subtext\"><nobr>%1</td></tr>" 00109 "<tr><td><a href=\"%1\"><img width=\"%1\" height=\"%1\" src=\"%1\" /></a></td>" 00110 "<td><a href=\"%1\">%1</a><br><span id=\"subtext\"><nobr>%1</td></tr>" 00111 "<tr><td><a href=\"%1\"><img width=\"%1\" height=\"%1\" src=\"%1\" /></a></td>" 00112 "<td><a href=\"%1\">%1</a><br><span id=\"subtext\"><nobr>%1</td></tr>" 00113 "</table>" ) 00114 .arg( kapp->aboutData()->version() ) 00115 .arg( i18n( "KitchenSync synchronizes your e-mail, addressbook, calendar, to-do list and more." ) ) 00116 .arg( "help:/kitchensync" ) 00117 .arg( iconSize ) 00118 .arg( iconSize ) 00119 .arg( handbook_icon_path ) 00120 .arg( "help:/kitchensync" ) 00121 .arg( i18n( "Read Manual" ) ) 00122 .arg( i18n( "Learn more about KitchenSync and its components" ) ) 00123 .arg( "http://pim.kde.org" ) 00124 .arg( iconSize ) 00125 .arg( iconSize ) 00126 .arg( html_icon_path ) 00127 .arg( "http://pim.kde.org" ) 00128 .arg( i18n( "Visit KitchenSync Website" ) ) 00129 .arg( i18n( "Access online resources and tutorials" ) ) 00130 .arg( "exec:/addGroup" ) 00131 .arg( iconSize ) 00132 .arg( iconSize ) 00133 .arg( wizard_icon_path ) 00134 .arg( "exec:/addGroup" ) 00135 .arg( i18n( "Add Synchronization Group" ) ) 00136 .arg( i18n( "Create group of devices for synchronization" ) ); 00137 00138 return info; 00139 } 00140 00141 #include "aboutpage.moc"