1 /*
2 Copyright (c) 2012-2020 Maarten Baert <maarten-baert@hotmail.com>
3
4 This file is part of SimpleScreenRecorder.
5
6 SimpleScreenRecorder is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 SimpleScreenRecorder is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with SimpleScreenRecorder. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include "PageWelcome.h"
21
22 #include "CommandLineOptions.h"
23 #include "Icons.h"
24 #include "MainWindow.h"
25
PageWelcome(MainWindow * main_window)26 PageWelcome::PageWelcome(MainWindow* main_window)
27 : QWidget(main_window->centralWidget()) {
28
29 m_main_window = main_window;
30
31 QScrollArea *scrollarea = new QScrollArea(this);
32 QWidget *scrollarea_contents = new QWidget(scrollarea);
33 scrollarea->setWidgetResizable(true);
34 scrollarea->setWidget(scrollarea_contents);
35 scrollarea->setFrameShape(QFrame::NoFrame);
36 {
37 QLabel *label_logo = new QLabel(scrollarea_contents);
38 label_logo->setPixmap(QPixmap(":/header.png"));
39 label_logo->setScaledContents(true);
40 QLabel *label_welcome = new QLabel(scrollarea_contents);
41 label_welcome->setText(tr("<p>Welcome to SimpleScreenRecorder!</p>\n\n"
42 "<p>Despite the name, this program actually has a lot of options. Don't worry though, there are really just two things that you "
43 "need to know. One, the default settings are usually fine. If you don't know what something does, just use the default. "
44 "Two, almost all settings have tooltips. Just hover the mouse over something to find out what it does.</p>\n\n"
45 "<p>For more information:<br>\n"
46 "%1</p>").arg("<a href=\"https://www.maartenbaert.be/simplescreenrecorder/\">https://www.maartenbaert.be/simplescreenrecorder/</a>"));
47 label_welcome->setWordWrap(true);
48 label_welcome->setTextFormat(Qt::RichText);
49 label_welcome->setTextInteractionFlags(Qt::TextBrowserInteraction);
50 label_welcome->setOpenExternalLinks(true);
51 QPushButton *button_about = new QPushButton(tr("About SimpleScreenRecorder"), scrollarea_contents);
52 m_checkbox_skip_page = new QCheckBox(tr("Skip this page next time"), scrollarea_contents);
53 m_checkbox_skip_page->setToolTip(tr("Go directly to the input page when the program is started."));
54
55 connect(button_about, SIGNAL(clicked()), this, SLOT(AboutDialog()));
56
57 QVBoxLayout *layout = new QVBoxLayout(scrollarea_contents);
58 //layout->setContentsMargins(0, 0, 0, 0);
59 {
60 QHBoxLayout *layout2 = new QHBoxLayout();
61 layout->addLayout(layout2);
62 layout2->addStretch();
63 layout2->addWidget(label_logo);
64 layout2->addStretch();
65 }
66 layout->addWidget(label_welcome);
67 {
68 QHBoxLayout *layout2 = new QHBoxLayout();
69 layout->addLayout(layout2);
70 layout2->addWidget(button_about);
71 layout2->addStretch();
72 }
73 layout->addWidget(m_checkbox_skip_page);
74 layout->addStretch();
75 }
76 QPushButton *button_continue = new QPushButton(g_icon_go_next, tr("Continue"), this);
77
78 connect(button_continue, SIGNAL(clicked()), m_main_window, SLOT(GoPageInput()));
79
80 QVBoxLayout *layout = new QVBoxLayout(this);
81 layout->setContentsMargins(0, 0, 0, 0);
82 layout->addWidget(scrollarea);
83 {
84 QHBoxLayout *layout2 = new QHBoxLayout();
85 layout->addLayout(layout2);
86 layout2->addSpacing(style()->pixelMetric(QStyle::PM_LayoutLeftMargin));
87 layout2->addWidget(button_continue);
88 layout2->addSpacing(style()->pixelMetric(QStyle::PM_LayoutRightMargin));
89 }
90 layout->addSpacing(style()->pixelMetric(QStyle::PM_LayoutBottomMargin));
91
92 }
93
94
LoadSettings(QSettings * settings)95 void PageWelcome::LoadSettings(QSettings* settings) {
96 SetSkipPage(settings->value("welcome/skip_page", false).toBool());
97 }
98
SaveSettings(QSettings * settings)99 void PageWelcome::SaveSettings(QSettings* settings) {
100 settings->setValue("welcome/skip_page", GetSkipPage());
101 }
102
AboutDialog()103 void PageWelcome::AboutDialog() {
104 DialogAbout dialog(this);
105 dialog.exec();
106 }
107
DialogAbout(PageWelcome * parent)108 DialogAbout::DialogAbout(PageWelcome* parent)
109 : QDialog(parent) {
110
111 setWindowTitle(tr("About SimpleScreenRecorder"));
112
113 QString html_about;
114 {
115 QFile file(":/about.htm");
116 if(file.open(QIODevice::ReadOnly | QIODevice::Text))
117 html_about = file.readAll();
118 }
119
120 html_about.replace("%MOREINFO%", tr("For more information:"));
121 html_about.replace("%SOURCECODE%", tr("The source code of this program can be found at:"));
122 html_about.replace("%USES%", tr("This program uses:"));
123 html_about.replace("%USES_QT%", tr("%1 for the graphical user interface").arg("<a href=\"https://qt-project.org/\">Qt</a>"));
124 html_about.replace("%USES_LIBAV_FFMPEG%", tr("%1 or %2 (depending on your distribution) for video/audio encoding").arg("<a href=\"http://libav.org/\">libav</a>").arg("<a href=\"http://ffmpeg.org/\">ffmpeg</a>"));
125 html_about.replace("%USES_ELFHACKS%", tr("%1 for hooking system functions for OpenGL recording").arg("<a href=\"https://github.com/nullkey/elfhacks\">elfhacks</a>"));
126 html_about.replace("%VERSION%", SSR_VERSION);
127 html_about.replace("%VERSIONINFO%", GetVersionInfo().replace("\n", "<br>\n"));
128
129 QTextBrowser *textbrowser = new QTextBrowser(this);
130 textbrowser->setHtml(html_about);
131 textbrowser->setOpenExternalLinks(true);
132 textbrowser->setMinimumSize(700, 500);
133
134 QPushButton *pushbutton_close = new QPushButton("Close", this);
135
136 connect(pushbutton_close, SIGNAL(clicked()), this, SLOT(accept()));
137
138 QVBoxLayout *layout = new QVBoxLayout(this);
139 layout->addWidget(textbrowser);
140 {
141 QHBoxLayout *layout2 = new QHBoxLayout();
142 layout->addLayout(layout2);
143 layout2->addStretch();
144 layout2->addWidget(pushbutton_close);
145 layout2->addStretch();
146 }
147
148 }
149