File: HelpItem.cpp

package info (click to toggle)
fotowall 0.9-8
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 4,280 kB
  • sloc: cpp: 23,275; makefile: 51; sh: 25
file content (99 lines) | stat: -rw-r--r-- 4,609 bytes parent folder | download | duplicates (3)
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
/***************************************************************************
 *                                                                         *
 *   This file is part of the Fotowall project,                            *
 *       http://www.enricoros.com/opensource/fotowall                      *
 *                                                                         *
 *   Copyright (C) 2007-2009 by Enrico Ros <enrico.ros@gmail.com>          *
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 ***************************************************************************/

#include "HelpItem.h"
#if defined(USE_QTWEBKIT)
#include "Shared/BrowserItem.h"
#else
#include <QGraphicsTextItem>
#endif
#include <QCoreApplication>
#include <QLocale>
#include <QGraphicsSceneMouseEvent>
#include <QPainter>
#include <QString>
#include "Frames/FrameFactory.h"

HelpItem::HelpItem(QGraphicsItem * parent)
    : AbstractDisposeable(parent, true)
    , m_frame(FrameFactory::createFrame(0x1001 /*HARDCODED*/))
{
    QString introduction = tr(
        "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n"
        "<html><!--head><meta name=\"qrichtext\" content=\"1\" /></head-->\n"
        "<body style=\"font-family:'Sans Serif';\">\n"
        "   <span style='font-size: 26px; font-weight: normal; color: #FF0000;'>\n"
        "      <img src=':/data/action-remove.png'>\n"
        "        Welcome\n"
        "      <img src=':/data/action-remove.png'>\n"
        "   </span>\n"
        "   <br />\n"
        "   <div style='font-size: 16px; font-weight: normal;'>\n"
        "      <b>Playing</b> with <b>Fotowall</b> is easy\n"
        "   </div>\n"
        "   <ul>\n"
        "      <li><img src=':/data/action-add.png'><b> add contents</b> using the <i><span style='background-color: rgb(255, 226, 0);'>ADD NEW</span></i> buttons or <i><span style='background-color: rgb(255, 226, 0);'>drop them</span></i></li>\n"
        "      <li><img src=':/data/action-move.png'><b> move contents around </b> and <b><img src=':/data/action-rotate.png'> rotate them</b> <span style='background-color: rgb(255, 226, 0);'>by <i>dragging the corners</i></span></li>\n"
        "      <li><img src=':/data/action-configure.png'><i> <span style='background-color: rgb(255, 226, 0);'>right click on the objects</span></i> or <i><span style='background-color: rgb(255, 226, 0);'>use the top bar</span></i> to <b>modify properties</b></li>\n"
        "      <li><span style='background-color: rgb(255, 226, 0);'><i>double click any content</i></span> to <b>open the editor</b> or set it as <b>background</b></li>\n"
        "      <li>...and we'll let you discover the rest!</li>\n"
        "   </ul>\n"
        "   <div><font color='#2B2B2B'><b>\n"
        "      Please make sure to share your best work with your friends ;-)\n"
        "   </b></font></div>\n"
        "   <br/>\n"
        "   <div><font color='#616161' style='font-size: 11px; font-weight: normal;'>\n"
        "      Fotowall is LGPL, by Enrico Ros <enrico.ros@gmail.com>, 2009\n"
        "   </font></div>\n"
        "</body>\n"
        "</html>"
    );
#if defined(USE_QTWEBKIT)
    // show fancy help in internal browser
#error WebKit was completely disabled, to only have 1 version of the HTML to translate...
    //BrowserItem * bi = new BrowserItem(this);
    //bi->setGeometry(...);
    //bi->write(introduction);
    //bi->setReadOnly(true);
#else
    // create an item to display it
    QGraphicsTextItem * ti = new QGraphicsTextItem(this);
    ti->setHtml(introduction);
    ti->setPos(boundingRect().adjusted(12, 12, -12, -12).topLeft());
    ti->setTextInteractionFlags(Qt::NoTextInteraction);
#endif
}

HelpItem::~HelpItem()
{
    delete m_frame;
}

QRectF HelpItem::boundingRect() const
{
    QRectF r = childrenBoundingRect ().adjusted(-12, -12, 12, 12);
    r.moveCenter(QPointF());
    return r;
}

void HelpItem::paint(QPainter * painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/)
{
    if (m_frame)
        m_frame->drawFrame(painter, boundingRect().toRect(), false, false);
}

void HelpItem::mousePressEvent(QGraphicsSceneMouseEvent * /*event*/)
{
    emit closeMe();
}