File: illustrationdialog.cpp

package info (click to toggle)
tipp10 3.3.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,984 kB
  • sloc: cpp: 8,343; xml: 70; ansic: 60; makefile: 11
file content (185 lines) | stat: -rw-r--r-- 6,086 bytes parent folder | download | duplicates (2)
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
/*
Copyright (c) 2006-2009, Tom Thielicke IT Solutions

SPDX-License-Identifier: GPL-2.0-only
*/

/****************************************************************
**
** Implementation of the IllustrationDialog class
** File name: illustrationdialog.cpp
**
****************************************************************/

#include <QCoreApplication>
#include <QHBoxLayout>
#include <QIcon>
#include <QPalette>
#include <QSettings>
#include <QVBoxLayout>

#include "illustrationdialog.h"

IllustrationDialog::IllustrationDialog(QWidget* parent)
    : QDialog(parent)
{

    setWindowFlags(windowFlags() ^ Qt::WindowContextHelpButtonHint);

    setWindowTitle(tr("Introduction"));

    createContent();

    createButtons();

    // Set the layout of all widgets created above
    createLayout();

    buttonStart->setFocus();

    resize(570, 400);
}

void IllustrationDialog::createContent()
{

    QString content;

    content = ""
              "<div "
              "style=\"margin-top:12px;margin-left:12px;margin-bottom:12px;"
              "margin-right:12px;font-size:12px;\">"
              "<div style=\"margin-top:16px;\">"
              "<center>"
              "&nbsp;<br><img src=\":/img/logo.svg\">"
              "</center>"
              "</div>"
              "<div style=\"margin-top:20px;\">"
              "<center>"
              "<b>"
        + tr("Welcome to TIPP10")
        + "</b>"
          "</center>"
          "</div>"
          "<div style=\"margin-top:16px;\">"
        + tr("TIPP10 is a free touch typing tutor for Windows, Mac OS and "
             "Linux. The ingenious thing about the software is its "
             "intelligence feature. Characters that are mistyped are repeated "
             "more frequently. Touch typing has never been so easy to learn.")
        + "</div>"
          "<div style=\"margin-top:17px;\">"
          "<b>"
        + tr("Tips for using the 10 finger system")
        + "</b>"
          "</div>"
          "<div style=\"margin-top:10px;\">"
        + tr("1. First place your fingers in the home position (this is "
             "displayed at the beginning of each lesson). The fingers return "
             "to the home row after each key is pressed.")
        + "</div>"
          "<div style=\"margin-top:16px;\">"
          "<img src=\":/img/"
        + tr("en")
        + "_illustration.svg\">"
          "</div>"
          "<div style=\"margin-top:16px;\">"
        + tr("2. Make sure your posture is straight and avoid looking at the "
             "keyboard. Your eyes should be directed toward the monitor at "
             "all times.")
        + "</div>"
          "<div style=\"margin-top:10px;\">"
        + tr("3. Bring your arms to the side of your body and relax your "
             "shoulders. Your upper arm and lower arm should be at a right "
             "angle. Do not rest your wrists and remain in an upright "
             "position.")
        + "</div>"
          "<div style=\"margin-top:10px;\">"
        + tr("4. Try to remain relaxed during the typing lessons.")
        + "</div>"
          "<div style=\"margin-top:10px;\">"
        + tr("5. Try to keep typing errors to a minimum. It is much less "
             "efficient to type fast if you are making a lot of mistakes.")
        + "</div>"
          "<div style=\"margin-top:10px;\">"
        + tr("6. Once you have begun touch typing you have to avoid reverting "
             "back to the way you used to type (even if you are in a hurry).")
        + "</div>"
          "<div style=\"margin-top:26px;\">"
        + tr("If you need assistance with using the software use the help "
             "function.")
        + "</div>"
          "<div style=\"margin-top:34px;\">"
          "<img src=\":/img/tt_logo.png\">"
          "</div>"
          "<div style=\"margin-top:10px;\">"
          "&copy; Tom Thielicke IT Solutions<br>"
          "<a "
          "href=\"http://www.thielicke.org\">http://www.thielicke.org</"
          "a><br><br>"
        + tr("All rights reserved.")
        + "<br>&nbsp;"
          "</div>"
          "</div>";

    illustrationContent = new QTextBrowser();
    illustrationContent->setHtml(content);
    illustrationContent->setOpenExternalLinks(true);
}

void IllustrationDialog::createButtons()
{
    // Buttons
    buttonStart = new QPushButton(this);
    buttonStart->setText(tr("&Launch TIPP10"));
    buttonStart->setDefault(true);
    // Widget connections
    connect(buttonStart, &QPushButton::clicked, this,
        &IllustrationDialog::clickStart);
    showDialogCheck = new QCheckBox(tr("Do&n't show me this window again"));
}

void IllustrationDialog::createLayout()
{
    // Button layout horizontal
    QHBoxLayout* layoutHorizontal = new QHBoxLayout;
    layoutHorizontal->addSpacing(1);
    layoutHorizontal->addWidget(illustrationContent, 1);
    layoutHorizontal->addSpacing(1);
    // Button layout horizontal
    QHBoxLayout* buttonLayoutHorizontal = new QHBoxLayout;
    buttonLayoutHorizontal->addStretch(1);
    buttonLayoutHorizontal->addWidget(showDialogCheck);
    buttonLayoutHorizontal->addSpacing(8);
    buttonLayoutHorizontal->addWidget(buttonStart);
    // Full layout of all widgets vertical
    QVBoxLayout* mainLayout = new QVBoxLayout;
    mainLayout->addLayout(layoutHorizontal);
    mainLayout->addSpacing(1);
    mainLayout->addLayout(buttonLayoutHorizontal);
    mainLayout->setSpacing(15);
    // Pass layout to parent widget (this)
    this->setLayout(mainLayout);
}

void IllustrationDialog::clickStart()
{
    writeSettings();
    accept();
}

void IllustrationDialog::writeSettings()
{
// Saves settings of the widget
// (uses the default constructor of QSettings, passing
// the application and company name see main function)
#if APP_PORTABLE
    QSettings settings(
        QCoreApplication::applicationDirPath() + "/portable/settings.ini",
        QSettings::IniFormat);
#else
    QSettings settings;
#endif
    settings.beginGroup("main");
    settings.setValue("check_illustration", !showDialogCheck->isChecked());
    settings.endGroup();
}