summaryrefslogtreecommitdiffstats
path: root/kitchensync/src/aboutpage.cpp
blob: 1590338c26ef43811660d9b604041dd91128d394 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/*
    This file is part of KitchenSync.

    Copyright (c) 2005 Tobias Koenig <[email protected]>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#include <tqfile.h>
#include <tqlayout.h>

#include <kaboutdata.h>
#include <kapplication.h>
#include <kdebug.h>
#include <khtml_part.h>
#include <khtmlview.h>
#include <kiconloader.h>
#include <klocale.h>
#include <krun.h>
#include <kstandarddirs.h>

#include "aboutpage.h"

static TQString readFile( const TQString &fileName )
{
  TQFile file( fileName );
  if ( !file.open( IO_ReadOnly ) ) {
    kdDebug() << "Unable to open file '" << fileName << "'" << endl;
    return TQCString();
  }

  TQString content = TQString::fromUtf8( file.readAll() );

  file.close();

  return content;
}

AboutPage::AboutPage( TQWidget *tqparent )
  : TQWidget( tqparent, "AboutPage" )
{
  TQVBoxLayout *tqlayout = new TQVBoxLayout( this );

  TQString location = locate( "data", "kitchensync/about/main.html" );
  TQString content = readFile( location );
  content = content.tqarg( locate( "data", "libkdepim/about/kde_infopage.css" ) );
  if ( kapp->reverseLayout() )
    content = content.tqarg( "@import \"%1\";" ).tqarg( locate( "data", "libkdepim/about/kde_infopage_rtl.css" ) );
  else
    content = content.tqarg( "" );

  KHTMLPart *part = new KHTMLPart( this );
  tqlayout->addWidget( part->view() );

  part->begin( KURL( location ) );

  TQString appName( i18n( "KDE KitchenSync" ) );
  TQString catchPhrase( i18n( "Get Synchronized!" ) );
  TQString quickDescription( i18n( "The KDE Synchronization Tool" ) );

  part->write( content.tqarg( TQFont().pointSize() + 2 ).tqarg( appName )
              .tqarg( catchPhrase ).tqarg( quickDescription ).tqarg( htmlText() ) );
  part->end();

  connect( part->browserExtension(),
           TQT_SIGNAL( openURLRequest( const KURL&, const KParts::URLArgs& ) ),
           TQT_SLOT( handleUrl( const KURL& ) ) );

  connect( part->browserExtension(),
           TQT_SIGNAL( createNewWindow( const KURL&, const KParts::URLArgs& ) ),
           TQT_SLOT( handleUrl( const KURL& ) ) );
}

void AboutPage::handleUrl( const KURL &url )
{
  if ( url.protocol() == "exec" ) {
    if ( url.path() == "/addGroup" )
      emit addGroup();
  } else
    new KRun( url, this );
}

TQString AboutPage::htmlText() const
{
  KIconLoader *iconloader = KGlobal::iconLoader();
  int iconSize = iconloader->currentSize( KIcon::Desktop );

  TQString handbook_icon_path = iconloader->iconPath( "contents2",  KIcon::Desktop );
  TQString html_icon_path = iconloader->iconPath( "html",  KIcon::Desktop );
  TQString wizard_icon_path = iconloader->iconPath( "wizard",  KIcon::Desktop );

  TQString info = i18n( "<h2 style='text-align:center; margin-top: 0px;'>Welcome to KitchenSync %1</h2>"
      "<p>%1</p>"
      "<table align=\"center\">"
      "<tr><td><a href=\"%1\"><img width=\"%1\" height=\"%1\" src=\"%1\" /></a></td>"
      "<td><a href=\"%1\">%1</a><br><span id=\"subtext\"><nobr>%1</td></tr>"
      "<tr><td><a href=\"%1\"><img width=\"%1\" height=\"%1\" src=\"%1\" /></a></td>"
      "<td><a href=\"%1\">%1</a><br><span id=\"subtext\"><nobr>%1</td></tr>"
      "<tr><td><a href=\"%1\"><img width=\"%1\" height=\"%1\" src=\"%1\" /></a></td>"
      "<td><a href=\"%1\">%1</a><br><span id=\"subtext\"><nobr>%1</td></tr>"
      "</table>" )
      .tqarg( kapp->aboutData()->version() )
      .tqarg( i18n( "KitchenSync synchronizes your e-mail, addressbook, calendar, to-do list and more." ) )
      .tqarg( "help:/kitchensync" )
      .tqarg( iconSize )
      .tqarg( iconSize )
      .tqarg( handbook_icon_path )
      .tqarg( "help:/kitchensync" )
      .tqarg( i18n( "Read Manual" ) )
      .tqarg( i18n( "Learn more about KitchenSync and its components" ) )
      .tqarg( "http://pim.kde.org" )
      .tqarg( iconSize )
      .tqarg( iconSize )
      .tqarg( html_icon_path )
      .tqarg( "http://pim.kde.org" )
      .tqarg( i18n( "Visit KitchenSync Website" ) )
      .tqarg( i18n( "Access online resources and tutorials" ) )
      .tqarg( "exec:/addGroup" )
      .tqarg( iconSize )
      .tqarg( iconSize )
      .tqarg( wizard_icon_path )
      .tqarg( "exec:/addGroup" )
      .tqarg( i18n( "Add Synchronization Group" ) )
      .tqarg( i18n( "Create group of tqdevices for synchronization" ) );

  return info;
}

#include "aboutpage.moc"