~ubuntu-branches/ubuntu/intrepid/digikam/intrepid

« back to all changes in this revision

Viewing changes to digikam/digikam/welcomepageview.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Mark Purcell
  • Date: 2008-07-17 20:25:39 UTC
  • mfrom: (1.3.2 upstream) (37 hardy)
  • mto: This revision was merged to the branch mainline in revision 39.
  • Revision ID: james.westby@ubuntu.com-20080717202539-1bw3w3nrsso7yj4z
* New upstream release
  - digiKam 0.9.4 Release Plan (KDE3) ~ 13 July 08 (Closes: #490144)
* DEB_CONFIGURE_EXTRA_FLAGS := --without-included-sqlite3
* Debhelper compatibility level V7
* Install pixmaps in debian/*.install
* Add debian/digikam.lintian-overrides

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ============================================================
 
2
 *
 
3
 * This file is a part of digiKam project
 
4
 * http://www.digikam.org
 
5
 * 
 
6
 * Date        : 2006-12-20
 
7
 * Description : a widget to display a welcome page 
 
8
 *               on root album.
 
9
 * 
 
10
 * Copyright (C) 2006-2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
 
11
 *
 
12
 * This program is free software; you can redistribute it
 
13
 * and/or modify it under the terms of the GNU General
 
14
 * Public License as published by the Free Software Foundation;
 
15
 * either version 2, or (at your option)
 
16
 * any later version.
 
17
 * 
 
18
 * This program is distributed in the hope that it will be useful,
 
19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
21
 * GNU General Public License for more details.
 
22
 *
 
23
 * ============================================================ */
 
24
 
 
25
// Qt includes. 
 
26
 
 
27
#include <qwidget.h>
 
28
#include <qfile.h>
 
29
#include <qfileinfo.h>
 
30
 
 
31
// KDE includes.
 
32
 
 
33
#include <klocale.h>
 
34
#include <kcursor.h>
 
35
#include <khtml_part.h>
 
36
#include <khtmlview.h>
 
37
#include <kapplication.h>
 
38
#include <kurl.h>
 
39
#include <kstandarddirs.h>
 
40
 
 
41
// Local includes.
 
42
 
 
43
#include "version.h"
 
44
#include "welcomepageview.h"
 
45
#include "welcomepageview.moc"
 
46
 
 
47
namespace Digikam
 
48
{
 
49
 
 
50
WelcomePageView::WelcomePageView(QWidget* parent)
 
51
               : KHTMLPart(parent)
 
52
{
 
53
    widget()->setFocusPolicy(QWidget::WheelFocus);
 
54
    // Let's better be paranoid and disable plugins (it defaults to enabled):
 
55
    setPluginsEnabled(false);
 
56
    setJScriptEnabled(false); // just make this explicit.
 
57
    setJavaEnabled(false);    // just make this explicit.
 
58
    setMetaRefreshEnabled(false);
 
59
    setURLCursor(KCursor::handCursor());
 
60
 
 
61
    QString fontSize         = QString::number(12);
 
62
    QString appTitle         = i18n("digiKam");
 
63
    QString catchPhrase      = QString();      // Not enough space for a catch phrase at default window size.
 
64
    QString quickDescription = i18n("A Photo Management Application for KDE");
 
65
    QString locationHtml     = locate("data", "digikam/about/main.html");
 
66
    QString locationCss      = locate("data", "digikam/about/kde_infopage.css");
 
67
    QString locationRtl      = locate("data", "digikam/about/kde_infopage_rtl.css" );
 
68
    QString rtl              = kapp->reverseLayout() ? QString("@import \"%1\";" ).arg(locationRtl)
 
69
                                                     : QString();
 
70
 
 
71
    begin(KURL(locationHtml));
 
72
 
 
73
    QString content = fileToString(locationHtml);
 
74
    content         = content.arg(locationCss)        // %1
 
75
                             .arg(rtl)                // %2
 
76
                             .arg(fontSize)           // %3
 
77
                             .arg(appTitle)           // %4
 
78
                             .arg(catchPhrase)        // %5
 
79
                             .arg(quickDescription)   // %6
 
80
                             .arg(infoPage());        // %7
 
81
 
 
82
    write(content);
 
83
    end();
 
84
    show();
 
85
 
 
86
    connect(browserExtension(), SIGNAL(openURLRequest(const KURL &, const KParts::URLArgs &)),
 
87
            this, SLOT(slotUrlOpen(const KURL &)));
 
88
}
 
89
 
 
90
WelcomePageView::~WelcomePageView()
 
91
{
 
92
}
 
93
 
 
94
void WelcomePageView::slotUrlOpen(const KURL &url)
 
95
{
 
96
    KApplication::kApplication()->invokeBrowser(url.url());
 
97
}
 
98
 
 
99
QString WelcomePageView::infoPage()
 
100
{
 
101
    QString info =
 
102
        i18n(
 
103
        "%1: digiKam version; " 
 
104
        "%2: help:// URL; "
 
105
        "%3: homepage URL; "
 
106
        "%4: prior digiKam version; " 
 
107
        "%5: prior KDE version; "
 
108
        "%6: generated list of new features; "
 
109
        "%7: First-time user text (only shown on first start); "
 
110
        "%8: generated list of important changes; "
 
111
        "--- end of comment ---",
 
112
        "<h2 style='margin-top: 0px;'>Welcome to digiKam %1</h2><p>"
 
113
        "digiKam is a photo management program for the K Desktop Environment. "
 
114
        "It is designed to import, organize, and export your digital photographs on your computer."
 
115
        "</p><p>You are currently in the Album view mode of digiKam. The Albums are the real "
 
116
        "containers where your files are stored, they are identical with the folders "
 
117
        "on disk.</p>\n<ul><li>"
 
118
        "digiKam has many powerful features which are described in the "
 
119
        "<a href=\"%2\">documentation</a></li>\n"
 
120
        "<li>The <a href=\"%3\">digiKam homepage</A> provides information about "
 
121
        "new versions of digiKam</li></ul>\n"
 
122
        "%8\n<p>" // important changes
 
123
        "Some of the new features in this release of digiKam include "
 
124
        "(compared to digiKam %4):</p>\n"
 
125
        "<ul>\n%5</ul>\n"
 
126
        "%6\n"
 
127
        "<p>We hope that you will enjoy digiKam.</p>\n"
 
128
        "<p>Thank you,</p>\n"
 
129
        "<p style='margin-bottom: 0px'>&nbsp; &nbsp; The digiKam Team</p>")
 
130
        .arg(digikam_version)            // current digiKam version
 
131
        .arg("help:/digikam/index.html") // digiKam help:// URL
 
132
        .arg("http://www.digikam.org")   // digiKam homepage URL
 
133
        .arg("0.8.2");                   // previous digiKam release.
 
134
 
 
135
    QStringList newFeatures;
 
136
    newFeatures << i18n("16-bit/color/pixel image support");
 
137
    newFeatures << i18n("Full color management support");
 
138
    newFeatures << i18n("Native JPEG-2000 support");
 
139
    newFeatures << i18n("Makernote and IPTC metadata support");
 
140
    newFeatures << i18n("Photograph geolocation");
 
141
    newFeatures << i18n("Extensive Sidebars");
 
142
    newFeatures << i18n("Advanced RAW image decoding settings");
 
143
    newFeatures << i18n("Fast RAW preview");
 
144
    newFeatures << i18n("RAW Metadata support");
 
145
    newFeatures << i18n("New advanced camera download options");
 
146
    newFeatures << i18n("New advanced tag management");
 
147
    newFeatures << i18n("New zooming/panning support in preview mode");
 
148
    newFeatures << i18n("New Light Table provides easy comparison for similar images");
 
149
    newFeatures << i18n("Camera Interface used as generic import tool");
 
150
    newFeatures << i18n("New text, mime-type, and rating filters to search contents on icon view");
 
151
    newFeatures << i18n("New options to easy navigate between albums, tags and collections");
 
152
    newFeatures << i18n("New options to recursively show the contents of sub-folders");
 
153
    newFeatures << i18n("New text filter to search contents on folder views");
 
154
    newFeatures << i18n("New options to count of items on all folder views");
 
155
    newFeatures << i18n("New tool to perform dates search around whole albums collection: Time-Line");
 
156
 
 
157
    QString featureItems;
 
158
    for ( uint i = 0 ; i < newFeatures.count() ; i++ )
 
159
        featureItems += i18n("<li>%1</li>\n").arg( newFeatures[i] );
 
160
    
 
161
    info = info.arg( featureItems );
 
162
    
 
163
    // Add first-time user text (only shown on first start).
 
164
    info = info.arg( QString() ); 
 
165
 
 
166
    // Generated list of important changes    
 
167
    info = info.arg( QString() ); 
 
168
    
 
169
    return info;
 
170
}
 
171
 
 
172
QCString WelcomePageView::fileToString(const QString &aFileName)
 
173
{
 
174
    QCString result;
 
175
    QFileInfo info(aFileName);
 
176
    unsigned int readLen;
 
177
    unsigned int len = info.size();
 
178
    QFile file(aFileName);
 
179
    
 
180
    if (aFileName.isEmpty() || len <= 0 || 
 
181
        !info.exists() || info.isDir() || !info.isReadable() ||
 
182
        !file.open(IO_Raw|IO_ReadOnly)) 
 
183
        return QCString();
 
184
    
 
185
    result.resize(len + 2);
 
186
    readLen = file.readBlock(result.data(), len);
 
187
    if (1 && result[len-1]!='\n')
 
188
    {
 
189
        result[len++] = '\n';
 
190
        readLen++;
 
191
    }
 
192
    result[len] = '\0';
 
193
    
 
194
    if (readLen < len)
 
195
        return QCString();
 
196
    
 
197
    return result;
 
198
}
 
199
 
 
200
}  // namespace Digikam