blob: 67e93886f31d11ac4202a79a04283c444d854214 [file] [log] [blame]
Edric Milaret627500d2015-03-27 16:41:40 -04001/***************************************************************************
Anthony Léonard2fde81d2017-04-17 10:06:55 -04002 * Copyright (C) 2015-2017 by Savoir-faire Linux *
Edric Milaret627500d2015-03-27 16:41:40 -04003 * Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
Olivier SOLDANO47aa97f2017-04-04 10:40:00 -04004 * Author: Anthony Léonard <anthony.leonard@savoirfairelinux.com> *
5 * Author: Olivier Soldano <olivier.soldano@savoirfairelinux.com> *
Edric Milaret627500d2015-03-27 16:41:40 -04006 * *
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 3 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
19 **************************************************************************/
20
21#include "configurationwidget.h"
22#include "ui_configurationwidget.h"
23
Edric Milaret1eece872015-06-10 13:37:51 -040024#include <QMessageBox>
Edric Milaretfd5a1f22016-02-05 15:30:00 -050025#include <QDir>
26#include <QStandardPaths>
27#include <QFileDialog>
Nicolas Jager74fe46f2016-02-29 14:55:09 -050028#include <QPropertyAnimation>
Edric Milaretce0ea472016-04-12 10:16:56 -040029#include <QtConcurrent/QtConcurrent>
Edric Milaret1eece872015-06-10 13:37:51 -040030
Edric Milaret627500d2015-03-27 16:41:40 -040031#include "video/devicemodel.h"
32#include "video/channel.h"
33#include "video/resolution.h"
34#include "video/rate.h"
Edric Milaret4bba46d2015-04-29 16:33:38 -040035#include "video/previewmanager.h"
Edric Milaret627500d2015-03-27 16:41:40 -040036
Edric Milaret47c40eb2016-03-14 15:06:22 -040037#include "audio/settings.h"
38#include "audio/outputdevicemodel.h"
39#include "audio/inputdevicemodel.h"
40
Edric Milaretfd5a1f22016-02-05 15:30:00 -050041#include "media/recordingmodel.h"
42
Edric Milaret3e6aefe2015-06-05 16:07:26 -040043#include "accountserializationadapter.h"
Edric Milaretb25af972015-06-17 16:55:45 -040044#include "accountstatedelegate.h"
45#include "settingskey.h"
Edric Milaret79d3f682015-12-09 12:32:52 -050046#include "utils.h"
Edric Milaret25236d92016-03-28 09:40:58 -040047#include "photoboothdialog.h"
Edric Milaret57467842016-08-30 13:06:11 -040048#include "wizarddialog.h"
Edric Milaret3e6aefe2015-06-05 16:07:26 -040049
Edric Milaret627500d2015-03-27 16:41:40 -040050#include "accountmodel.h"
51#include "protocolmodel.h"
52#include "accountdetails.h"
Edric Milaret3aeae3a2015-06-01 17:31:54 -040053#include "callmodel.h"
Edric Milaret1eece872015-06-10 13:37:51 -040054#include "ringtonemodel.h"
55#include "categorizedhistorymodel.h"
Edric Milaret25236d92016-03-28 09:40:58 -040056#include "profilemodel.h"
57#include "profile.h"
58#include "person.h"
Edric Milaret627500d2015-03-27 16:41:40 -040059
Edric Milaret79d3f682015-12-09 12:32:52 -050060#include "winsparkle.h"
Edric Milaret627500d2015-03-27 16:41:40 -040061
Olivier SOLDANO9b7e80d2017-05-04 16:06:01 -040062#include "deleteaccountdialog.h"
63
Edric Milaret627500d2015-03-27 16:41:40 -040064ConfigurationWidget::ConfigurationWidget(QWidget *parent) :
Nicolas Jager74fe46f2016-02-29 14:55:09 -050065 NavWidget(parent),
Edric Milaret627500d2015-03-27 16:41:40 -040066 ui(new Ui::ConfigurationWidget),
Edric Milareta3e47282015-10-23 15:20:30 -040067 accountModel_(&AccountModel::instance()),
68 deviceModel_(&Video::DeviceModel::instance()),
Edric Milaret627500d2015-03-27 16:41:40 -040069 accountDetails_(new AccountDetails())
70{
71 ui->setupUi(this);
72
Nicolas Jager74fe46f2016-02-29 14:55:09 -050073 connect(ui->exitSettingsButton, &QPushButton::clicked, this, [=]() {
74 if (CallModel::instance().getActiveCalls().size() == 0
75 && Video::PreviewManager::instance().isPreviewing()) {
76 Video::PreviewManager::instance().stopPreview();
77 }
78 accountModel_->save();
79 accountDetails_->save();
80 });
81
Nicolas Jager74fe46f2016-02-29 14:55:09 -050082 connect(ui->exitSettingsButton, &QPushButton::clicked, this, [=]() {
83 emit NavigationRequested(ScreenEnum::CallScreen);
84 });
85
Edric Milaret627500d2015-03-27 16:41:40 -040086 ui->accountView->setModel(accountModel_);
Edric Milaret01f23842015-06-22 14:46:01 -040087 accountStateDelegate_ = new AccountStateDelegate();
88 ui->accountView->setItemDelegate(accountStateDelegate_);
Edric Milaret627500d2015-03-27 16:41:40 -040089
Olivier SOLDANO9b7e80d2017-05-04 16:06:01 -040090 // connect delete button to popup trigger
91 connect(ui->deleteAccountBtn, &QPushButton::clicked, [=](){
92 auto idx = ui->accountView->currentIndex();
93 DeleteAccountDialog dialog(idx);
94 dialog.exec();
95 });
96
Edric Milaret627500d2015-03-27 16:41:40 -040097 isLoading_ = true;
98 ui->deviceBox->setModel(deviceModel_);
Edric Milaret94b4aab2015-05-08 12:10:44 -040099 connect(deviceModel_, SIGNAL(currentIndexChanged(int)),
100 this, SLOT(deviceIndexChanged(int)));
Edric Milaret627500d2015-03-27 16:41:40 -0400101
Olivier SOLDANO957911a2017-05-25 11:52:43 -0400102 if (ui->deviceBox->count() > 0){
103 ui->deviceBox->setCurrentIndex(0);
104 }
105
106 // accounts
Edric Milaretf8048cf2016-05-13 10:21:08 -0400107 AccountModel::instance().selectionModel()->clear();
Edric Milaretce0ea472016-04-12 10:16:56 -0400108 ui->accountView->setSelectionModel(AccountModel::instance().selectionModel());
Edric Milaret627500d2015-03-27 16:41:40 -0400109 connect(ui->accountView->selectionModel(),
Edric Milaret3aeae3a2015-06-01 17:31:54 -0400110 SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
111 this, SLOT(accountSelected(QItemSelection)));
Edric Milaret627500d2015-03-27 16:41:40 -0400112
113 ui->accountView->setCurrentIndex(accountModel_->index(0));
114 ui->accountDetailLayout->addWidget(accountDetails_);
Edric Milaret627500d2015-03-27 16:41:40 -0400115 ui->accountTypeBox->setModel(accountModel_->protocolModel());
Olivier SOLDANOadc81f02016-11-07 15:22:34 -0500116 ui->accountTypeBox->setCurrentIndex(ui->accountTypeBox->findText("RING"));
Edric Milaret4bba46d2015-04-29 16:33:38 -0400117 ui->startupBox->setChecked(Utils::CheckStartupLink());
Edric Milaret1eece872015-06-10 13:37:51 -0400118
Edric Milaretb25af972015-06-17 16:55:45 -0400119 ui->historyDaySettingsSpinBox->setValue(
Edric Milareta3e47282015-10-23 15:20:30 -0400120 CategorizedHistoryModel::instance().historyLimit());
Edric Milaretb25af972015-06-17 16:55:45 -0400121 ui->closeOrMinCheckBox->setChecked(settings_.value(
122 SettingsKey::closeOrMinimized).toBool());
Edric Milaret568a0e52016-09-02 16:26:58 -0400123 ui->notificationCheckBox->setChecked(settings_.value(
124 SettingsKey::enableNotifications).toBool());
Nicolas Jager74fe46f2016-02-29 14:55:09 -0500125 connect(ui->stackedWidget, &QStackedWidget::currentChanged, [](int index) {
Edric Milaretfb5fc5c2015-09-24 14:32:49 -0400126 if (index == 1
Edric Milareta3e47282015-10-23 15:20:30 -0400127 && CallModel::instance().getActiveCalls().size() == 0) {
128 Video::PreviewManager::instance().startPreview();
Edric Milaretfb5fc5c2015-09-24 14:32:49 -0400129 } else {
Edric Milareta3e47282015-10-23 15:20:30 -0400130 if (CallModel::instance().getActiveCalls().size() == 0
131 && Video::PreviewManager::instance().isPreviewing()) {
132 Video::PreviewManager::instance().stopPreview();
Edric Milaretfb5fc5c2015-09-24 14:32:49 -0400133 }
134 }
135 });
Edric Milaret0b7fe5d2016-01-27 11:12:43 -0500136
137 ui->videoView->setIsFullPreview(true);
Edric Milaretfd5a1f22016-02-05 15:30:00 -0500138
Andreas Traczyke86fb3c2018-08-02 17:38:34 -0400139 auto recordPath = media::RecordingModel::instance().recordPath();
Edric Milaretfd5a1f22016-02-05 15:30:00 -0500140 if (recordPath.isEmpty()) {
141 recordPath = QDir::toNativeSeparators(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation));
Andreas Traczyke86fb3c2018-08-02 17:38:34 -0400142 media::RecordingModel::instance().setRecordPath(recordPath);
Edric Milaretfd5a1f22016-02-05 15:30:00 -0500143 }
Andreas Traczyke86fb3c2018-08-02 17:38:34 -0400144 ui->recordPath->setText(media::RecordingModel::instance().recordPath());
Edric Milaretfd5a1f22016-02-05 15:30:00 -0500145
Andreas Traczyke86fb3c2018-08-02 17:38:34 -0400146 ui->alwaysRecordCheckBox->setChecked(media::RecordingModel::instance().isAlwaysRecording());
Edric Milaretfd5a1f22016-02-05 15:30:00 -0500147 connect(ui->alwaysRecordCheckBox, &QCheckBox::clicked, [](bool checked){
Andreas Traczyke86fb3c2018-08-02 17:38:34 -0400148 media::RecordingModel::instance().setAlwaysRecording(checked);
Edric Milaretfd5a1f22016-02-05 15:30:00 -0500149 });
150
Nicolas Jager74fe46f2016-02-29 14:55:09 -0500151 connect(ui->generalTabButton, &QPushButton::toggled, [=] (bool toggled) {
152 if (toggled) {
153 ui->stackedWidget->setCurrentWidget(ui->generalPage);
154 ui->videoTabButton->setChecked(false);
155 ui->accountTabButton->setChecked(false);
156 }
157 });
158
159 connect(ui->videoTabButton, &QPushButton::toggled, [=] (bool toggled) {
160 if (toggled) {
161 ui->stackedWidget->setCurrentWidget(ui->videoPage);
162 ui->accountTabButton->setChecked(false);
163 ui->generalTabButton->setChecked(false);
164 }
165 });
166
167 connect(ui->accountTabButton, &QPushButton::toggled, [=] (bool toggled) {
168 if (toggled) {
169 ui->stackedWidget->setCurrentWidget(ui->accountPage);
170 ui->videoTabButton->setChecked(false);
171 ui->generalTabButton->setChecked(false);
172 }
173 });
174
175 ui->generalTabButton->setChecked(true);
176
Olivier SOLDANO957911a2017-05-25 11:52:43 -0400177 // Audio settings
Edric Milaret47c40eb2016-03-14 15:06:22 -0400178 auto inputModel = Audio::Settings::instance().inputDeviceModel();
179 auto outputModel = Audio::Settings::instance().outputDeviceModel();
180
181 ui->outputComboBox->setModel(outputModel);
182 ui->inputComboBox->setModel(inputModel);
Olivier SOLDANO957911a2017-05-25 11:52:43 -0400183 if(ui->outputComboBox->count() > 0) {
184 ui->outputComboBox->setCurrentIndex(0);
185 }
186 if (ui->inputComboBox->count() > 0){
187 ui->inputComboBox->setCurrentIndex(0);
188 }
189
Edric Milaret47c40eb2016-03-14 15:06:22 -0400190 connect(ui->outputComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(outputIndexChanged(int)));
191 connect(ui->inputComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(inputIndexChanged(int)));
192
Olivier SOLDANO957911a2017-05-25 11:52:43 -0400193 // profile
Edric Milaret25236d92016-03-28 09:40:58 -0400194 auto profile = ProfileModel::instance().selectedProfile();
195 ui->avatarButton->setIcon(QPixmap::fromImage(Utils::getCirclePhoto(profile->person()->photo().value<QImage>(), ui->avatarButton->width())));
196 ui->profileNameEdit->setText(profile->person()->formattedName());
Olivier SOLDANO16c11f32016-10-28 11:57:48 -0400197
198 //temporary fix hiding imports buttons
199 ui->exportButton->hide();
Olivier SOLDANO257e0682016-11-09 13:59:04 -0500200
201 ui->intervalUpdateCheckSpinBox->setEnabled(true);
Edric Milaret627500d2015-03-27 16:41:40 -0400202}
203
Edric Milaretef9b85b2016-02-05 11:47:10 -0500204void ConfigurationWidget::showPreview()
205{
Nicolas Jager74fe46f2016-02-29 14:55:09 -0500206 if (ui->stackedWidget->currentIndex() == 1
Edric Milaretef9b85b2016-02-05 11:47:10 -0500207 && CallModel::instance().getActiveCalls().size() == 0) {
208 ui->previewUnavailable->hide();
209 ui->videoView->show();
210 Video::PreviewManager::instance().startPreview();
211 } else {
212 ui->previewUnavailable->show();
213 ui->videoView->hide();
214 }
215}
216
Edric Milaretfb5fc5c2015-09-24 14:32:49 -0400217void
Edric Milaretf8048cf2016-05-13 10:21:08 -0400218ConfigurationWidget::showEvent(QShowEvent *event)
219{
Edric Milaret79d3f682015-12-09 12:32:52 -0500220 if (win_sparkle_get_automatic_check_for_updates()) {
221 ui->autoUpdateCheckBox->setChecked(true);
222 }
223 ui->intervalUpdateCheckSpinBox->setValue(win_sparkle_get_update_check_interval() / 86400);
Edric Milaretfb5fc5c2015-09-24 14:32:49 -0400224 QWidget::showEvent(event);
Edric Milaretef9b85b2016-02-05 11:47:10 -0500225 showPreview();
Edric Milaretfb5fc5c2015-09-24 14:32:49 -0400226}
227
Edric Milaret627500d2015-03-27 16:41:40 -0400228ConfigurationWidget::~ConfigurationWidget()
229{
230 delete ui;
Edric Milaret01f23842015-06-22 14:46:01 -0400231 delete accountStateDelegate_;
Edric Milaret627500d2015-03-27 16:41:40 -0400232}
233
234void
Edric Milaretf8048cf2016-05-13 10:21:08 -0400235ConfigurationWidget::deviceIndexChanged(int index)
236{
Edric Milaret94b4aab2015-05-08 12:10:44 -0400237 ui->deviceBox->setCurrentIndex(index);
238}
239
240void
Edric Milaret627500d2015-03-27 16:41:40 -0400241ConfigurationWidget::on_deviceBox_currentIndexChanged(int index)
242{
243 if (index < 0)
244 return;
245
246 if (!isLoading_)
247 deviceModel_->setActive(index);
248
249 auto device = deviceModel_->activeDevice();
250
251 ui->sizeBox->clear();
252
253 isLoading_ = true;
254 if (device->channelList().size() > 0) {
255 for (auto resolution : device->channelList()[0]->validResolutions()) {
256 ui->sizeBox->addItem(resolution->name());
257 }
258 }
259 ui->sizeBox->setCurrentIndex(
260 device->channelList()[0]->activeResolution()->relativeIndex());
261 isLoading_ = false;
262}
263
264void
265ConfigurationWidget::on_sizeBox_currentIndexChanged(int index)
266{
267 auto device = deviceModel_->activeDevice();
268
Edric Milaret627500d2015-03-27 16:41:40 -0400269 if (index < 0)
270 return;
271 if (!isLoading_)
272 device->channelList()[0]->setActiveResolution(
273 device->channelList()[0]->validResolutions()[index]);
Edric Milaret627500d2015-03-27 16:41:40 -0400274}
275
276void
Edric Milaretf8048cf2016-05-13 10:21:08 -0400277ConfigurationWidget::accountSelected(QItemSelection itemSel)
278{
279 if (itemSel.size())
280 accountDetails_->show();
281 else
282 accountDetails_->hide();
Edric Milaret3e6aefe2015-06-05 16:07:26 -0400283
Edric Milaretf8048cf2016-05-13 10:21:08 -0400284 if (accountConnection_)
285 disconnect(accountConnection_);
286
Edric Milaret3e6aefe2015-06-05 16:07:26 -0400287 auto account = accountModel_->getAccountByModelIndex(
288 ui->accountView->currentIndex());
289 accountDetails_->setAccount(account);
Edric Milaretf8048cf2016-05-13 10:21:08 -0400290 if (account) {
Edric Milaretce0ea472016-04-12 10:16:56 -0400291 AccountSerializationAdapter adapter(account, accountDetails_);
Edric Milaretf8048cf2016-05-13 10:21:08 -0400292 accountConnection_= connect(account,
293 SIGNAL(propertyChanged(Account*,QString,QString,QString)),
294 this,
295 SLOT(accountPropertyChanged(Account*,QString,QString,QString)));
296 }
297}
298
299void
300ConfigurationWidget::accountPropertyChanged(Account* a,
301 const QString& name,
302 const QString& newVal,
303 const QString& oldVal)
304{
305 Q_UNUSED(name)
306 Q_UNUSED(newVal)
307 Q_UNUSED(oldVal)
308 accountDetails_->setAccount(a);
309 AccountSerializationAdapter adapter(a, accountDetails_);
Edric Milaret627500d2015-03-27 16:41:40 -0400310}
311
312void
Edric Milaret627500d2015-03-27 16:41:40 -0400313ConfigurationWidget::on_addAccountButton_clicked()
314{
Edric Milaret57467842016-08-30 13:06:11 -0400315 auto type = ui->accountTypeBox->model()->index(ui->accountTypeBox->currentIndex(), 0);
316 if (type.data() == "RING") {
317 WizardDialog dlg(WizardDialog::NEW_ACCOUNT);
318 dlg.exec();
319 } else {
320 auto account = accountModel_->add(tr("New Account"), type);
321 account->setRingtonePath(Utils::GetRingtonePath());
322 accountModel_->save();
323 }
Edric Milaret627500d2015-03-27 16:41:40 -0400324}
Edric Milaret4bba46d2015-04-29 16:33:38 -0400325
Edric Milaret3aeae3a2015-06-01 17:31:54 -0400326void
327ConfigurationWidget::on_startupBox_toggled(bool checked)
Edric Milaret4bba46d2015-04-29 16:33:38 -0400328{
329 if (checked)
330 Utils::CreateStartupLink();
331 else
332 Utils::DeleteStartupLink();
333}
Edric Milaret3aeae3a2015-06-01 17:31:54 -0400334
335void
Edric Milaret1eece872015-06-10 13:37:51 -0400336ConfigurationWidget::on_clearHistoryButton_clicked()
337{
338 QMessageBox confirmationDialog;
339
Edric Milaret53ac6e52015-09-14 13:37:06 -0400340 confirmationDialog.setText(tr("Are you sure you want to clear all your history?"));
Edric Milaret1eece872015-06-10 13:37:51 -0400341 confirmationDialog.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
342 auto ret = confirmationDialog.exec();
343
344 if (ret == QMessageBox::Ok)
Edric Milareta3e47282015-10-23 15:20:30 -0400345 CategorizedHistoryModel::instance().clearAllCollections();
Edric Milaret1eece872015-06-10 13:37:51 -0400346}
347
348void
349ConfigurationWidget::on_historyDaySettingsSpinBox_valueChanged(int limit)
350{
Edric Milareta3e47282015-10-23 15:20:30 -0400351 if (CategorizedHistoryModel::instance().historyLimit() != limit)
352 CategorizedHistoryModel::instance().setHistoryLimit(limit);
Edric Milaret1eece872015-06-10 13:37:51 -0400353}
Edric Milaretb25af972015-06-17 16:55:45 -0400354
355void
356ConfigurationWidget::on_closeOrMinCheckBox_toggled(bool checked)
357{
358 settings_.setValue(SettingsKey::closeOrMinimized, checked);
359}
Edric Milaret79d3f682015-12-09 12:32:52 -0500360
361void
362ConfigurationWidget::on_checkUpdateButton_clicked()
363{
Edric Milaret79d3f682015-12-09 12:32:52 -0500364 win_sparkle_check_update_with_ui();
Edric Milaret79d3f682015-12-09 12:32:52 -0500365}
366
367void
368ConfigurationWidget::on_autoUpdateCheckBox_toggled(bool checked)
369{
Edric Milaret79d3f682015-12-09 12:32:52 -0500370 win_sparkle_set_automatic_check_for_updates(checked);
Edric Milaret79d3f682015-12-09 12:32:52 -0500371}
372
373void
374ConfigurationWidget::on_intervalUpdateCheckSpinBox_valueChanged(int arg1)
375{
Edric Milaret79d3f682015-12-09 12:32:52 -0500376 win_sparkle_set_update_check_interval(arg1 * 86400);
Edric Milaret79d3f682015-12-09 12:32:52 -0500377}
Edric Milaretef9b85b2016-02-05 11:47:10 -0500378
379void
Nicolas Jager74fe46f2016-02-29 14:55:09 -0500380ConfigurationWidget::on_stackedWidget_currentChanged(int index)
Edric Milaretef9b85b2016-02-05 11:47:10 -0500381{
382 Q_UNUSED(index)
383 showPreview();
384}
Edric Milaretfd5a1f22016-02-05 15:30:00 -0500385
386void
387ConfigurationWidget::on_recordPath_clicked()
388{
389 QString dir = QFileDialog::getExistingDirectory(this, tr("Choose Directory"),
Andreas Traczyke86fb3c2018-08-02 17:38:34 -0400390 media::RecordingModel::instance().recordPath(),
Edric Milaretfd5a1f22016-02-05 15:30:00 -0500391 QFileDialog::ShowDirsOnly
392 | QFileDialog::DontResolveSymlinks);
393 if (not dir.isEmpty()) {
Andreas Traczyke86fb3c2018-08-02 17:38:34 -0400394 media::RecordingModel::instance().setRecordPath(dir);
Edric Milaretfd5a1f22016-02-05 15:30:00 -0500395 ui->recordPath->setText(dir);
396 }
397}
Edric Milaret47c40eb2016-03-14 15:06:22 -0400398
399void
400ConfigurationWidget::outputIndexChanged(int index)
401{
402 auto outputModel = Audio::Settings::instance().outputDeviceModel();
403 outputModel->selectionModel()->setCurrentIndex(outputModel->index(index), QItemSelectionModel::ClearAndSelect);
404}
405
406void
407ConfigurationWidget::inputIndexChanged(int index)
408{
409 auto inputModel = Audio::Settings::instance().inputDeviceModel();
410 inputModel->selectionModel()->setCurrentIndex(inputModel->index(index), QItemSelectionModel::ClearAndSelect);
411}
Edric Milaretce0ea472016-04-12 10:16:56 -0400412
413void
Edric Milaretce0ea472016-04-12 10:16:56 -0400414ConfigurationWidget::on_exportButton_clicked()
415{
Olivier SOLDANO1cd96172017-09-22 16:57:22 -0400416 /*
417 PathPasswordDialog dlg(true);
Edric Milaretce0ea472016-04-12 10:16:56 -0400418 if (dlg.exec() == QDialog::Accepted) {
419 auto func = [](QString path, QString password)
420 {
421 AccountModel::instance().exportAccounts(
422 {AccountModel::instance().selectedAccount()->id()},
423 path,
424 password);
425 };
426 QtConcurrent::run(func, dlg.path_, dlg.password_);
427 }
Olivier SOLDANO1cd96172017-09-22 16:57:22 -0400428 */
Edric Milaretce0ea472016-04-12 10:16:56 -0400429}
Edric Milaret25236d92016-03-28 09:40:58 -0400430
Olivier SOLDANO1cd96172017-09-22 16:57:22 -0400431
Edric Milaret25236d92016-03-28 09:40:58 -0400432void
433ConfigurationWidget::on_avatarButton_clicked()
434{
435 PhotoBoothDialog dlg;
436 dlg.exec();
437 if (dlg.result() == QDialog::Accepted) {
Olivier SOLDANO30ac2c72017-08-04 09:14:47 -0400438 auto image = QImage(dlg.getOutputFileName());
Edric Milaret25236d92016-03-28 09:40:58 -0400439 auto avatar = image.scaled(100, 100, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
440 ProfileModel::instance().selectedProfile()->person()->setPhoto(avatar);
441 ProfileModel::instance().selectedProfile()->save();
442 ui->avatarButton->setIcon(QPixmap::fromImage(Utils::getCirclePhoto(avatar, ui->avatarButton->width())));
443 }
444}
445
446void
447ConfigurationWidget::on_profileNameEdit_textEdited(const QString& name)
448{
449 ProfileModel::instance().selectedProfile()->person()->setFormattedName(name);
450 ProfileModel::instance().selectedProfile()->save();
451}
Edric Milaret568a0e52016-09-02 16:26:58 -0400452
453void
454ConfigurationWidget::on_notificationCheckBox_toggled(bool checked)
455{
456 settings_.setValue(SettingsKey::enableNotifications, checked);
457}