-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathquickHelp.cpp
More file actions
183 lines (161 loc) · 9.17 KB
/
Copy pathquickHelp.cpp
File metadata and controls
183 lines (161 loc) · 9.17 KB
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
//
// Copyright 2010, 2011 Tom Klein.
//
// This file is part of cstitch.
//
// cstitch 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 3 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, see <http://www.gnu.org/licenses/>.
//
#include "quickHelp.h"
#include <QtCore/QDebug>
#include <QtWidgets/QLabel>
#include <QtWidgets/QHBoxLayout>
#include <QtWidgets/QVBoxLayout>
#include <QtWidgets/QPushButton>
#include <QCloseEvent>
#include "imageUtility.h"
#include "helpBrowser.h"
quickHelp* quickHelp::window_ = NULL;
void quickHelp::loadQuickHelp(helpMode mode, QWidget* parent) {
if (window_ && window_->mode_ == mode) {
::showAndRaise(window_);
return;
}
if (window_) {
// closeEvent sets window_ to null if it's already been closed
window_->close();
}
window_ = new quickHelp(parent);
window_->setAttribute(Qt::WA_DeleteOnClose);
window_->setWindowTitle(tr("Quick Help"));
window_->loadModeHelp(mode);
window_->show();
}
void quickHelp::closeCurrentWindow() {
if (window_) {
window_->close();
}
}
quickHelp::quickHelp(QWidget* parent)
: QDialog(parent), mode_(helpMode::H_INVALID),
iconLabel_(new QLabel(this)), titleLabel_(new QLabel(this)),
textLabel_(new QLabel(this)), moreHelpLabel_(new QLabel(this)),
titleLayout_(new QHBoxLayout), layout_(new QVBoxLayout),
closeButton_(new QPushButton(tr("Close"), this)) {
// Qt geometry management, oh how I hate thee...
iconLabel_->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
// setFrameStyle + setStyleSheet is broken until 4.5...
textLabel_->setStyleSheet("QLabel { background-color : white; border: 1px solid black; }");
//textLabel_->setFrameStyle(QFrame::Box | QFrame::Plain);
textLabel_->setWordWrap(true);
textLabel_->setTextFormat(Qt::RichText);
textLabel_->setTextInteractionFlags(Qt::TextSelectableByMouse);
textLabel_->setMargin(2);
connect(closeButton_, SIGNAL(clicked()),
this, SLOT(processClose()));
moreHelpLabel_->setTextFormat(Qt::RichText);
moreHelpLabel_->setText(tr("Use the <i>Help</i> menu at any time to display this Quick Help window or to<br/>"
"turn automatic display of Quick Help windows on/off.<br/>"
"<a href=\"url\">Load the full documentation for this stage</a>"));
connect(moreHelpLabel_, SIGNAL(linkActivated(const QString& )),
this, SLOT(moreHelpActivated(const QString& )));
setLayout(layout_);
titleLayout_->addWidget(iconLabel_);
titleLayout_->addWidget(titleLabel_, 0, Qt::AlignLeft);
layout_->addLayout(titleLayout_);
layout_->addWidget(textLabel_);
layout_->addWidget(moreHelpLabel_);
layout_->addWidget(closeButton_, 0, Qt::AlignRight);
}
void quickHelp::loadModeHelp(helpMode mode) {
mode_ = mode;
QString pixmap;
QString title;
QString helpText;
switch (mode.value()) {
case(helpMode::H_COLOR_CHOOSER):
pixmap = ":colorChooser.png";
title = tr("<h1>Stage 1 of 4: Choose your pattern colors</h1>");
helpText = tr("In stage 1 you load an image and choose the colors you want to appear in your final pattern.<br/>"
"Click the <img src=\":openImage.png\"> icon on the toolbar to open an image.<br/>"
"In the default \"Num Colors to DMC\" mode, you can choose colors from the image (which will be converted to DMC) "
"and/or you can have the program choose a set number of DMC colors for you."
"<ul>"
"<li>To choose colors manually, click on a color on your image - the closest DMC color to the color you click will be added to the list.</li>"
"<li>To set the number of DMC colors the program will choose, use the number box to the right of \"Num Colors to DMC\" on the toolbar.</li>"
"</ul>"
"When you click the \"Choose colors\" button the program will generate its colors and a new image using those colors will be displayed in Stage 2.<br/><br/>"
"You can return to this stage at any time to choose different colors by clicking on the <img src=\":colorChooser.png\"> icon on the toolbar.");
break;
case(helpMode::H_COLOR_COMPARE):
pixmap = ":colorCompare.png";
title = tr("<h1>Stage 2 of 4: Compare color choices</h1>");
helpText = tr("Use this stage to compare images generated by Stage 1 with each other and with the original image. "
"Set the images being shown on the left and right side by choosing images from the <i>Left Image</i> and <i>Right Image</i> menus. "
"(If you've only generated one image from Stage 1 so far then the only image to compare with will be the original image - "
"recall that you can always return to Stage 1 to generate new images using the <img src=\":colorChooser.png\"> icon on the toolbar.)<br/><br/>"
"It's not essential that your image at this stage look exactly like the original; what you're aiming for is enough colors to distinguish "
"most of the main features in your image (you'll be able to add in small details by hand in Stage 3).<br/><br/>"
"Once you're happy with an image, click on it to select it. Then set the square dimension, which is the size of squares to be created on your "
"image that will become cross stitch squares on your final pattern. "
"The choice of square size along with the type of cross stitch fabric you use will determine "
"the size of your finished cross stitch product. Click on the dimension computer icon <img src=\":dims.png\"> on the toolbar to "
"figure out which square size you need.<br/><br/>"
"When you click the \"Square\" button the program will generate a \"squared\" image based on your colors and the square dimension, which will then "
"be displayed in stage 3.<br/><br/>"
"You can return to this stage at any time to choose a different square size by clicking on the <img src=\":colorCompare.png\"> icon on the toolbar.");
break;
case(helpMode::H_SQUARE):
pixmap = ":square.png";
title = tr("<h1>Stage 3 of 4: Compare and edit square images</h1>");
helpText = tr("Use Stage 3 to compare images (just as in stage 2) and to edit square images.<br/><br/>"
"You can use the editing tools to change colors, freehand draw, fill regions, and redetail areas - "
"for detailed directions open the full documentation using the link below, "
"but if this is your first time through you may want to just skip editing for now and move on to Stage 4.<br/><br/>"
"When you're ready to move on, select an image by clicking on it (make sure the tool is set to <i>Select</i>, which is the default), "
"and then click the \"Pattern\" button, which will replace colors with pattern symbols and display the result in Stage 4.<br/><br/>"
"You can return to this stage at any time by clicking on the <img src=\":square.png\"> icon on the toolbar.");
break;
case(helpMode::H_PATTERN):
pixmap = ":pattern.png";
title = tr("<h1>Stage 4 of 4: Set symbol size and create a pdf pattern</h1>");
helpText = tr("In this final stage you can change the symbols to appear in your final pattern and then create a pdf pattern.<br/><br/>"
"To change a symbol, either click on it in the image or right click on it in the symbol list and choose \"Change symbol\". "
"The image needs to be large in order to be able to read the symbols, so you may want to use the preview image in the upper right corner "
"in order to locate yourself on the image - just click and/or drag on the preview image to move the symbol view around. "
"You can also right click on the main image to switch back and forth between the symbol view and the square view in order to help get your bearings.<br/><br/>"
"Once you're happy with the symbols, click the \"To pdf\" button and choose a pdf filename to save your final pattern.<br/><br/>"
"You can return to this stage at any time by clicking on the <img src=\":pattern.png\"> icon on the toolbar.<br/><br/>"
"Congratulations! If you'd like to do more, a good place to start would be to return to Stage 3 and read the full documentation on "
"how to use the editing tools. Humans are still better at some things than computers, and artistry is one of them, "
"so that part is up to you! If you do so, you should also learn about how to save and restore your work as a project, information which can be "
"found under the <i>Overview</i> section of the full documentation.");
break;
default:
qWarning() << "Quick help mode undefined:" << mode.value();
}
iconLabel_->setPixmap(QPixmap(pixmap));
titleLabel_->setText(title);
textLabel_->setText(helpText);
}
void quickHelp::moreHelpActivated(const QString& ) {
close();
helpBrowser::loadHelp(mode_);
}
void quickHelp::processClose() {
close();
}
void quickHelp::closeEvent(QCloseEvent* event) {
event->accept();
window_ = NULL;
}