3 Copyright (C) 2008 jlh (jlh at gmx dot ch)
5 This program is free software; you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published by the
7 Free Software Foundation; either version 2 of the License, version 3 of
8 the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 The GNU General Public License version 2 is included with the source of
20 this program under the file name COPYING. You can also get a copy on
24 #include <QHBoxLayout>
25 #include <QVBoxLayout>
26 #include <QPushButton>
29 #include <QApplication>
36 #include "preferences.h"
37 #include "smartwidgets.h"
39 // ---- IconDialogBase
41 IconDialogBase::IconDialogBase(const QString
&title
, QStyle::StandardPixmap pixmap
) {
42 setWindowTitle(QString(PROGRAM_NAME
" - ") + title
);
43 setAttribute(Qt::WA_DeleteOnClose
);
45 QVBoxLayout
*mainvbox
= new QVBoxLayout(this);
46 mainvbox
->setSizeConstraint(QLayout::SetFixedSize
);
48 QHBoxLayout
*bighbox
= new QHBoxLayout
;
49 hbox
= new QHBoxLayout
;
51 mainvbox
->addLayout(bighbox
, 1);
52 mainvbox
->addLayout(hbox
);
55 int iconSize
= QApplication::style()->pixelMetric(QStyle::PM_MessageBoxIconSize
);
56 QIcon icon
= QApplication::style()->standardIcon(pixmap
);
57 QLabel
*iconLabel
= new QLabel
;
58 iconLabel
->setPixmap(icon
.pixmap(iconSize
, iconSize
));
59 bighbox
->addWidget(iconLabel
, 0, Qt::AlignTop
);
61 bighbox
->addSpacing(iconSize
/ 3);
63 vbox
= new QVBoxLayout
;
64 bighbox
->addLayout(vbox
, 1);
67 // ---- RecordConfirmationDialog ----
69 RecordConfirmationDialog::RecordConfirmationDialog(const QString
&sn
, const QString
&displayName
) :
70 IconDialogBase("Recording confirmation", QStyle::SP_MessageBoxQuestion
),
73 QLabel
*label
= new QLabel(QString(PROGRAM_NAME
" has started recording the call with <b>%1</b> (%2).<br>"
74 "Do you wish to continue recording or shall it stop and delete the file?").arg(skypeName
, displayName
));
75 vbox
->addWidget(label
);
79 remember
= new QCheckBox(QString("&Automatically perform this action on the next call with %1").arg(skypeName
));
80 remember
->setEnabled(false);
81 widgets
.append(remember
);
82 vbox
->addWidget(remember
);
86 QPushButton
*button
= new QPushButton("&Continue recording");
87 button
->setEnabled(false);
88 button
->setDefault(true);
89 button
->setMinimumWidth(180);
90 widgets
.append(button
);
91 connect(button
, SIGNAL(clicked()), this, SLOT(yesClicked()));
92 hbox
->addWidget(button
);
94 button
= new QPushButton("&Stop recording and delete");
95 button
->setEnabled(false);
96 button
->setMinimumWidth(180);
97 widgets
.append(button
);
98 connect(button
, SIGNAL(clicked()), this, SLOT(noClicked()));
99 hbox
->addWidget(button
);
103 connect(this, SIGNAL(rejected()), this, SIGNAL(no()));
104 QTimer::singleShot(1000, this, SLOT(enableWidgets()));
111 void RecordConfirmationDialog::yesClicked() {
113 if (remember
->isChecked())
114 preferences
.setPerCallerPreference(skypeName
, 2);
118 void RecordConfirmationDialog::noClicked() {
120 if (remember
->isChecked())
121 preferences
.setPerCallerPreference(skypeName
, 0);
125 void RecordConfirmationDialog::enableWidgets() {
126 for (int i
= 0; i
< widgets
.size(); i
++)
127 widgets
.at(i
)->setEnabled(true);
130 // ---- LegalInformationDialog ----
132 LegalInformationDialog::LegalInformationDialog() :
133 IconDialogBase("Legal information", QStyle::SP_MessageBoxInformation
)
135 QLabel
*label
= new QLabel("Please make sure that recording this call is legal and that all involved parties\nagree with it.");
136 vbox
->addWidget(label
);
138 QWidget
*additionalInfo
= new QWidget
;
139 additionalInfo
->hide();
140 QVBoxLayout
*additionalInfoLayout
= new QVBoxLayout(additionalInfo
);
141 additionalInfoLayout
->setMargin(0);
143 additionalInfoLayout
->addSpacing(10);
146 "<p>The legality of recording calls depends on whether the involved parties agree<br>"
147 "with it and on the laws that apply to their geographic locations. Here is a<br>"
148 "simple rule of thumb:</p>"
150 "<p>If all involved parties have been asked for permission to record a call and<br>"
151 "agree with the intended use or storage of the resulting file, then recording a<br>"
152 "call is probably legal.</p>"
154 "<p>If not all involved parties have been asked for permission, or if they don't<br>"
155 "explicitely agree with it, or if the resulting file is used for purposes other than<br>"
156 "what has been agreed upon, then it's probably illegal to record calls.</p>"
158 "<p>For more serious legal advice, consult a lawyer. For more information, you can<br>"
159 "search the internet for '<a href='http://www.google.com/search?q=call+recording+legal'>call recording legal</a>'.</p>"
161 label
->setTextInteractionFlags(Qt::TextSelectableByMouse
| Qt::LinksAccessibleByMouse
);
162 label
->setTextFormat(Qt::RichText
);
163 label
->setOpenExternalLinks(true);
164 additionalInfoLayout
->addWidget(label
);
166 additionalInfoLayout
->addSpacing(10);
168 QWidget
*checkBox
= new SmartCheckBox("Do not show this information again", preferences
.get(Pref::SuppressLegalInformation
));
169 additionalInfoLayout
->addWidget(checkBox
);
171 vbox
->addWidget(additionalInfo
);
173 QPushButton
*button
= new QPushButton("More information >>");
174 connect(button
, SIGNAL(clicked()), button
, SLOT(hide()));
175 connect(button
, SIGNAL(clicked()), additionalInfo
, SLOT(show()));
176 vbox
->addWidget(button
, 0, Qt::AlignLeft
);
178 button
= new QPushButton("&OK");
179 button
->setDefault(true);
180 connect(button
, SIGNAL(clicked()), this, SLOT(close()));
181 hbox
->addWidget(button
, 0, Qt::AlignHCenter
);
186 // ---- AboutDialog ----
188 AboutDialog::AboutDialog() {
189 setWindowTitle(PROGRAM_NAME
" - About");
190 setAttribute(Qt::WA_DeleteOnClose
);
192 QVBoxLayout
*vbox
= new QVBoxLayout(this);
193 vbox
->setSizeConstraint(QLayout::SetFixedSize
);
195 QHBoxLayout
*hbox
= new QHBoxLayout
;
196 vbox
->addLayout(hbox
);
199 "<p><font face='Arial' size='20'><b>Skype Call Recorder</b></font></p>"
201 "<p>Copyright © 2008 jlh (<a href='mailto:jlh@gmx.ch'>jlh@gmx.ch</a>)<br>"
203 "Website: <a href='%2'>%3</a></p>";
204 str
= str
.arg(recorderVersion
).arg(websiteURL
).arg(websiteURL
);
205 QLabel
*label
= new QLabel(str
);
206 label
->setTextInteractionFlags(Qt::TextSelectableByMouse
| Qt::LinksAccessibleByMouse
);
207 label
->setTextFormat(Qt::RichText
);
208 label
->setOpenExternalLinks(true);
209 hbox
->addWidget(label
, 1, Qt::AlignTop
);
212 label
->setPixmap(QPixmap(":/icon.png").scaled(QSize(80, 80), Qt::KeepAspectRatio
, Qt::SmoothTransformation
));
213 hbox
->addWidget(label
, 0, Qt::AlignTop
);
217 "<p>This program is free software; you can redistribute it and/or modify it under<br>"
218 "the terms of the GNU General Public License as published by the <a href='http://www.fsf.org/'>Free<br>"
219 "Software Foundation</a>; either <a href='http://www.gnu.org/licenses/old-licenses/gpl-2.0.html'>version 2 of the License</a>, "
220 "<a href='http://www.gnu.org/licenses/gpl.html'>version 3 of the<br>"
221 "License</a>, or (at your option) any later version.</p>"
223 "<p>This program is distributed in the hope that it will be useful, but WITHOUT<br>"
224 "ANY WARRANTY; without even the implied warranty of MERCHANTABILITY<br>"
225 "or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public<br>"
226 "License for more details.</p>"
228 "<p>This product uses the Skype API but is not endorsed, certified or otherwise<br>"
229 "approved in any way by Skype.</p>"
231 "<p><small>Git commit: %1<br>"
232 "Build date: %2</small></p>";
233 str
= str
.arg(recorderCommit
, recorderDate
);
234 label
= new QLabel(str
);
235 label
->setTextInteractionFlags(Qt::TextSelectableByMouse
| Qt::LinksAccessibleByMouse
);
236 label
->setTextFormat(Qt::RichText
);
237 label
->setOpenExternalLinks(true);
238 vbox
->addWidget(label
);
240 QPushButton
*button
= new QPushButton("&Close");
241 connect(button
, SIGNAL(clicked()), this, SLOT(close()));
242 vbox
->addWidget(button
);
247 // ---- FirstRunDialog
249 FirstRunDialog::FirstRunDialog() :
250 IconDialogBase("Information", QStyle::SP_MessageBoxInformation
)
252 QLabel
*label
= new QLabel(
253 "<p>Welcome to Skype Call Recorder!</p>"
255 "<p>Please note that Skype Call Recorder does not have a main window.<br>"
256 "Instead, it hides itself in the system tray, from where you can open<br>"
257 "the preferences dialog, start or stop recording your Skype calls, or<br>"
258 "access previously recorded calls.</p>"
260 "<p>Thank you for using Skype Call Recorder!</p>"
262 label
->setTextFormat(Qt::RichText
);
263 vbox
->addWidget(label
);
265 QWidget
*checkBox
= new SmartCheckBox("Do not show this information again", preferences
.get(Pref::SuppressFirstRunInformation
));
266 vbox
->addWidget(checkBox
);
268 QPushButton
*button
= new QPushButton("&OK");
269 button
->setDefault(true);
270 connect(button
, SIGNAL(clicked()), this, SLOT(close()));
271 hbox
->addWidget(button
, 0, Qt::AlignHCenter
);
276 // ---- NoSystemTrayDialog ----
278 NoSystemTrayDialog::NoSystemTrayDialog() :
279 IconDialogBase("Missing system tray", QStyle::SP_MessageBoxQuestion
)
281 QLabel
*label
= new QLabel(
282 PROGRAM_NAME
" could not detect a system tray. The system tray is the main point\n"
283 "of interaction with Skype Call Recorder. Do you wish to use a small main window instead?"
285 vbox
->addWidget(label
);
287 QPushButton
*button
= new QPushButton("Yes, &always from now on");
288 connect(button
, SIGNAL(clicked()), this, SLOT(buttonAlways()));
289 hbox
->addWidget(button
);
291 button
= new QPushButton("&Yes, this time");
292 button
->setDefault(true);
293 connect(button
, SIGNAL(clicked()), this, SLOT(buttonYes()));
294 hbox
->addWidget(button
);
296 button
= new QPushButton("&Quit");
297 connect(button
, SIGNAL(clicked()), this, SLOT(buttonDoQuit()));
298 hbox
->addWidget(button
);
303 void NoSystemTrayDialog::buttonAlways() {
304 emit
useWindowedModeAlways();
308 void NoSystemTrayDialog::buttonYes() {
309 emit
useWindowedModeNow();
313 void NoSystemTrayDialog::buttonDoQuit() {
320 MainWindow::MainWindow(QWidget
*parent
) : QWidget(parent
) {
321 setWindowTitle(PROGRAM_NAME
);
322 setAttribute(Qt::WA_DeleteOnClose
);
324 QVBoxLayout
*vbox
= new QVBoxLayout(this);
325 vbox
->setSizeConstraint(QLayout::SetFixedSize
);
326 button
= new QPushButton(QIcon(":/icon.png"), "Menu");
327 vbox
->addWidget(button
);
329 connect(button
, SIGNAL(clicked()), this, SIGNAL(activate()));
334 void MainWindow::setColor(bool color
) {
335 button
->setIcon(QIcon(color
? ":/icon.png" : ":/icongray.png"));