Move pruning of Call objects to own function
[skype-call-recorder.git] / callgui.cpp
blob69f0e36b3719f651327e413b9dea8e6c4c3bf6d0
1 /*
2 Skype Call Recorder
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
21 http://www.fsf.org/
24 #include <QHBoxLayout>
25 #include <QVBoxLayout>
26 #include <QPushButton>
27 #include <QCheckBox>
28 #include <QLabel>
29 #include <QApplication>
30 #include <QStyle>
31 #include <QIcon>
32 #include <QTimer>
34 #include "callgui.h"
35 #include "common.h"
36 #include "preferences.h"
38 // ---- RecordConfirmationDialog ----
40 RecordConfirmationDialog::RecordConfirmationDialog(const QString &sn, const QString &displayName) :
41 skypeName(sn)
43 setWindowTitle(PROGRAM_NAME);
44 setAttribute(Qt::WA_DeleteOnClose);
46 QHBoxLayout *bighbox = new QHBoxLayout(this);
47 bighbox->setSizeConstraint(QLayout::SetFixedSize);
49 // get standard icon
50 int iconSize = QApplication::style()->pixelMetric(QStyle::PM_MessageBoxIconSize);
51 QIcon icon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxQuestion);
52 QLabel *iconLabel = new QLabel;
53 iconLabel->setPixmap(icon.pixmap(iconSize, iconSize));
54 bighbox->addWidget(iconLabel, 0, Qt::AlignTop);
56 bighbox->addSpacing(10);
58 QVBoxLayout *vbox = new QVBoxLayout;
59 bighbox->addLayout(vbox);
61 QLabel *label = new QLabel(QString(PROGRAM_NAME " has started recording the call with <b>%1</b> (%2).<br>"
62 "Do you wish to continue recording or shall it stop and delete the file?").arg(skypeName, displayName));
63 vbox->addWidget(label);
65 vbox->addSpacing(10);
67 remember = new QCheckBox(QString("&Automatically perform this action on the next call with %1").arg(skypeName));
68 remember->setEnabled(false);
69 widgets.append(remember);
70 vbox->addWidget(remember);
72 QHBoxLayout *hbox = new QHBoxLayout;
74 QPushButton *button = new QPushButton("&Continue recording");
75 button->setEnabled(false);
76 button->setDefault(true);
77 widgets.append(button);
78 connect(button, SIGNAL(clicked()), this, SLOT(yesClicked()));
79 hbox->addWidget(button);
81 button = new QPushButton("&Stop recording and delete");
82 button->setEnabled(false);
83 widgets.append(button);
84 connect(button, SIGNAL(clicked()), this, SLOT(noClicked()));
85 hbox->addWidget(button);
87 vbox->addLayout(hbox);
89 connect(this, SIGNAL(rejected()), this, SIGNAL(no()));
90 QTimer::singleShot(1000, this, SLOT(enableWidgets()));
92 show();
93 raise();
94 activateWindow();
97 void RecordConfirmationDialog::yesClicked() {
98 emit yes();
99 if (remember->isChecked())
100 preferences.setPerCallerPreference(skypeName, 2);
101 accept();
104 void RecordConfirmationDialog::noClicked() {
105 emit no();
106 if (remember->isChecked())
107 preferences.setPerCallerPreference(skypeName, 0);
108 accept();
111 void RecordConfirmationDialog::enableWidgets() {
112 for (int i = 0; i < widgets.size(); i++)
113 widgets.at(i)->setEnabled(true);