advancedsettingswidget.cpp 19.9 KB
Newer Older
1
/***************************************************************************
Andreas Traczyk's avatar
Andreas Traczyk committed
2
 * Copyright (C) 2019 by Savoir-faire Linux                                *
3
 * Author: Isa Nanic <isa.nanic@savoirfairelinux.com>                      *
Andreas Traczyk's avatar
Andreas Traczyk committed
4
 * Author: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com>          *
5 6 7 8 9 10 11 12 13 14 15 16 17 18
 *                                                                         *
 * This program 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/>.   *
 **************************************************************************/
19 20 21
#include "advancedsettingswidget.h"
#include "ui_advancedsettingswidget.h"

22 23
#include <QFileDialog>

24 25
#include "lrcinstance.h"
#include "utils.h"
26

Andreas Traczyk's avatar
Andreas Traczyk committed
27 28
#include "api/newcodecmodel.h"

29 30 31 32 33 34 35 36
AdvancedSettingsWidget::AdvancedSettingsWidget(QWidget* parent)
    :QWidget(parent),
    ui(new Ui::AdvancedSettingsWidget)
{
    ui->setupUi(this);

///////////////////////////////////////////////////////////////////////////////
    // call settings
37 38 39
    connect(ui->checkBoxUntrusted, &QAbstractButton::clicked, this, &AdvancedSettingsWidget::setCallsUntrusted);
    connect(ui->checkBoxCustomRingtone, &QAbstractButton::clicked, this, &AdvancedSettingsWidget::setEnableRingtone);
    connect(ui->checkBoxAutoAnswer, &QAbstractButton::clicked, this, &AdvancedSettingsWidget::setAutoAnswerCalls);
40
    connect(ui->btnRingtone, &QPushButton::clicked, this, &AdvancedSettingsWidget::openFileCustomRingtone);
41
    connect(ui->checkBoxCustomRingtone, &QAbstractButton::clicked, [this](int state) { ui->btnRingtone->setEnabled((bool)state); });
42 43

    // name server
44
    connect(ui->lineEditNameServer, &QLineEdit::editingFinished, this, &AdvancedSettingsWidget::setNameServer);
45 46

    // openDHT config
47
    connect(ui->checkBoxEnableProxy, &QAbstractButton::clicked, this, &AdvancedSettingsWidget::setEnableProxy);
48

49 50
    connect(ui->lineEditProxy, &QLineEdit::editingFinished, this, &AdvancedSettingsWidget::setProxyAddress);
    connect(ui->lineEditBootstrap, &QLineEdit::editingFinished, this, &AdvancedSettingsWidget::setBootstrapAddress);
51 52 53 54 55 56 57

    // security
    connect(ui->btnCACert, &QPushButton::clicked, this, &AdvancedSettingsWidget::openFileCACert);
    connect(ui->btnUserCert, &QPushButton::clicked, this, &AdvancedSettingsWidget::openFileUserCert);
    connect(ui->btnPrivateKey, &QPushButton::clicked, this, &AdvancedSettingsWidget::openFilePrivateKey);

    // connectivity
58 59 60
    connect(ui->checkBoxUPnP, &QAbstractButton::clicked, this, &AdvancedSettingsWidget::setUseUPnP);
    connect(ui->checkBoxTurnEnable, &QAbstractButton::clicked, this, &AdvancedSettingsWidget::setUseTURN);
    connect(ui->checkBoxSTUNEnable, &QAbstractButton::clicked, this, &AdvancedSettingsWidget::setUseSTUN);
61

62 63 64 65
    connect(ui->lineEditTurnAddress, &QLineEdit::editingFinished, this, &AdvancedSettingsWidget::setTURNAddress);
    connect(ui->lineEditTurnUsername, &QLineEdit::editingFinished, this, &AdvancedSettingsWidget::setTURNUsername);
    connect(ui->lineEditTurnPassword, &QLineEdit::editingFinished, this, &AdvancedSettingsWidget::setTURNPassword);
    connect(ui->lineEditSTUNAddress, &QLineEdit::editingFinished, this, &AdvancedSettingsWidget::setSTUNAddress);
66 67 68 69 70

    // codecs
    connect(ui->audioListWidget, &QListWidget::itemChanged, this, &AdvancedSettingsWidget::audioCodecsStateChange);
    connect(ui->videoListWidget, &QListWidget::itemChanged, this, &AdvancedSettingsWidget::videoCodecsStateChange);

71
    connect(ui->videoCheckBox, &QAbstractButton::clicked, this, &AdvancedSettingsWidget::setVideoState);
72 73 74 75 76

    // codec priority setting
    connect(ui->audioDownPushButton, &QPushButton::clicked, this, &AdvancedSettingsWidget::decreaseAudioCodecPriority);
    connect(ui->audioUpPushButton, &QPushButton::clicked, this, &AdvancedSettingsWidget::increaseAudioCodecPriority);

Andreas Traczyk's avatar
Andreas Traczyk committed
77 78 79 80 81 82 83 84 85 86
    ui->audioDownPushButton->setEnabled(false);
    ui->audioUpPushButton->setEnabled(false);

    connect(ui->audioListWidget, &QListWidget::itemSelectionChanged,
        [this] {
            bool enabled = ui->audioListWidget->selectedItems().size();
            ui->audioDownPushButton->setEnabled(enabled);
            ui->audioUpPushButton->setEnabled(enabled);
        });

87 88 89
    connect(ui->videoDownPushButton, &QPushButton::clicked, this, &AdvancedSettingsWidget::decreaseVideoCodecPriority);
    connect(ui->videoUpPushButton, &QPushButton::clicked, this, &AdvancedSettingsWidget::increaseVideoCodecPriority);

Andreas Traczyk's avatar
Andreas Traczyk committed
90 91 92 93 94 95 96 97 98
    ui->videoDownPushButton->setEnabled(false);
    ui->videoUpPushButton->setEnabled(false);

    connect(ui->videoListWidget, &QListWidget::itemSelectionChanged,
        [this] {
            bool enabled = ui->videoListWidget->selectedItems().size();
            ui->videoDownPushButton->setEnabled(enabled);
            ui->videoUpPushButton->setEnabled(enabled);
        });
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
}

AdvancedSettingsWidget::~AdvancedSettingsWidget()
{
    delete ui;
}

void
AdvancedSettingsWidget::updateAdvancedSettings()
{
    auto config = LRCInstance::getCurrAccConfig();
    //Call Settings
    ui->checkBoxUntrusted->setChecked(config.allowIncoming);
    ui->checkBoxAutoAnswer->setChecked(config.autoAnswer);
    ui->checkBoxCustomRingtone->setChecked(config.Ringtone.ringtoneEnabled);

    // Name Server
    ui->lineEditNameServer->setText(QString::fromStdString(config.RingNS.uri));

    //OpenDHT Config
    ui->checkBoxEnableProxy->setChecked(config.proxyEnabled);
    ui->lineEditProxy->setText(QString::fromStdString(config.proxyServer));
    ui->lineEditBootstrap->setText(QString::fromStdString(config.hostname));

    // Security
124 125 126
    ui->btnCACert->setText(QFileInfo(QString::fromStdString(LRCInstance::getCurrAccConfig().TLS.certificateListFile)).fileName());
    ui->btnUserCert->setText(QFileInfo(QString::fromStdString(LRCInstance::getCurrAccConfig().TLS.certificateFile)).fileName());
    ui->btnPrivateKey->setText(QFileInfo(QString::fromStdString(LRCInstance::getCurrAccConfig().TLS.privateKeyFile)).fileName());
127 128 129 130 131 132

    // Connectivity
    ui->checkBoxUPnP->setChecked(config.upnpEnabled);
    ui->checkBoxTurnEnable->setChecked(config.TURN.enable);
    ui->lineEditTurnAddress->setText(QString::fromStdString(config.TURN.server));
    ui->lineEditTurnUsername->setText(QString::fromStdString(config.TURN.username));
133
    ui->lineEditTurnPassword->setText(QString::fromStdString(config.TURN.password));
134 135 136 137 138
    ui->checkBoxSTUNEnable->setChecked(config.STUN.enable);
    ui->lineEditSTUNAddress->setText(QString::fromStdString(config.STUN.server));

    // codecs
    ui->videoCheckBox->setChecked(config.Video.videoEnabled);
139 140
    disconnect(ui->audioListWidget, &QListWidget::itemChanged, this, &AdvancedSettingsWidget::audioCodecsStateChange);
    disconnect(ui->videoListWidget, &QListWidget::itemChanged, this, &AdvancedSettingsWidget::videoCodecsStateChange);
141 142
    updateAudioCodecs();
    updateVideoCodecs();
143 144
    connect(ui->audioListWidget, &QListWidget::itemChanged, this, &AdvancedSettingsWidget::audioCodecsStateChange);
    connect(ui->videoListWidget, &QListWidget::itemChanged, this, &AdvancedSettingsWidget::videoCodecsStateChange);
145 146 147 148 149

    ui->btnRingtone->setEnabled(LRCInstance::getCurrAccConfig().Ringtone.ringtoneEnabled);
    ui->btnRingtone->setText(QFileInfo(QString::fromStdString(LRCInstance::getCurrAccConfig().Ringtone.ringtonePath)).fileName());
    ui->lineEditProxy->setEnabled(LRCInstance::getCurrAccConfig().proxyEnabled);
    ui->lineEditSTUNAddress->setEnabled(LRCInstance::getCurrAccConfig().STUN.enable);
150 151 152 153 154 155 156 157
}

// call settings
void
AdvancedSettingsWidget::setCallsUntrusted(bool state)
{
    auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId());
    confProps.allowIncoming = state;
158
    LRCInstance::accountModel().setAccountConfig(LRCInstance::getCurrAccId(), confProps);
159 160 161 162 163 164
}
void
AdvancedSettingsWidget::setAutoAnswerCalls(bool state)
{
    auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId());
    confProps.autoAnswer = state;
165
    LRCInstance::accountModel().setAccountConfig(LRCInstance::getCurrAccId(), confProps);
166 167 168 169 170 171
}
void
AdvancedSettingsWidget::setEnableRingtone(bool state)
{
    auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId());
    confProps.Ringtone.ringtoneEnabled = state;
172
    LRCInstance::accountModel().setAccountConfig(LRCInstance::getCurrAccId(), confProps);
173 174 175 176 177 178
}

void
AdvancedSettingsWidget::openFileCustomRingtone()
{
    QString fileUrl;
179 180
    auto oldPath = QString::fromStdString(LRCInstance::getCurrAccConfig().Ringtone.ringtonePath);
    auto openPath = oldPath.isEmpty() ? QDir::currentPath() + QString("/ringtones/") : QFileInfo(oldPath).absolutePath();
181
    fileUrl = QFileDialog::getOpenFileName(this, QString("Select a new ringtone"), openPath, tr("Audio Files") + " (*.wav *.ogg *.opus *.mp3 *.aiff *.wma)");
182 183 184
    if (!fileUrl.isEmpty()) {
        auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId());
        confProps.Ringtone.ringtonePath = fileUrl.toStdString();
185
        LRCInstance::accountModel().setAccountConfig(LRCInstance::getCurrAccId(), confProps);
186
        ui->btnRingtone->setText(QFileInfo(fileUrl).fileName());
187
    } else if (oldPath.isEmpty()) {
188 189 190 191 192 193
        ui->btnRingtone->setText(tr("Add a custom ringtone"));
    }
}

// name server
void
194
AdvancedSettingsWidget::setNameServer()
195
{
196
    auto text = ui->lineEditNameServer->text();
197
    auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId());
198
    confProps.RingNS.uri = text.toStdString();
199
    LRCInstance::accountModel().setAccountConfig(LRCInstance::getCurrAccId(), confProps);
200 201 202 203 204 205 206 207
}

// openDHT config
void
AdvancedSettingsWidget::setEnableProxy(bool state)
{
    auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId());
    confProps.proxyEnabled = state;
208
    LRCInstance::accountModel().setAccountConfig(LRCInstance::getCurrAccId(), confProps);
209 210 211 212

    state ? ui->lineEditProxy->setEnabled(true) : ui->lineEditProxy->setEnabled(false);
}
void
213
AdvancedSettingsWidget::setProxyAddress()
214
{
215
    auto text = ui->lineEditProxy->text();
216
    auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId());
217
    confProps.proxyServer = text.toStdString();
218
    LRCInstance::accountModel().setAccountConfig(LRCInstance::getCurrAccId(), confProps);
219 220
}
void
221
AdvancedSettingsWidget::setBootstrapAddress()
222
{
223
    auto text = ui->lineEditBootstrap->text();
224
    auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId());
225
    confProps.hostname = text.toStdString();
226
    LRCInstance::accountModel().setAccountConfig(LRCInstance::getCurrAccId(), confProps);
227 228 229 230 231 232 233 234 235 236
}

// security

// connectivity
void
AdvancedSettingsWidget::setUseUPnP(bool state)
{
    auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId());
    confProps.upnpEnabled = state;
237
    LRCInstance::accountModel().setAccountConfig(LRCInstance::getCurrAccId(), confProps);
238 239 240 241 242 243
}
void
AdvancedSettingsWidget::setUseTURN(bool state)
{
    auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId());
    confProps.TURN.enable = state;
244
    LRCInstance::accountModel().setAccountConfig(LRCInstance::getCurrAccId(), confProps);
245 246 247 248 249 250
}
void
AdvancedSettingsWidget::setUseSTUN(bool state)
{
    auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId());
    confProps.STUN.enable = state;
251
    LRCInstance::accountModel().setAccountConfig(LRCInstance::getCurrAccId(), confProps);
252 253 254 255 256

    state ? ui->lineEditSTUNAddress->setEnabled(true) : ui->lineEditSTUNAddress->setEnabled(false);
}

void
257
AdvancedSettingsWidget::setTURNAddress()
258
{
259
    auto text = ui->lineEditTurnAddress->text();
260
    auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId());
261
    confProps.TURN.server = text.toStdString();
262
    LRCInstance::accountModel().setAccountConfig(LRCInstance::getCurrAccId(), confProps);
263 264
}
void
265
AdvancedSettingsWidget::setTURNUsername()
266
{
267
    auto text = ui->lineEditTurnUsername->text();
268
    auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId());
269
    confProps.TURN.username = text.toStdString();
270
    LRCInstance::accountModel().setAccountConfig(LRCInstance::getCurrAccId(), confProps);
271 272
}
void
273
AdvancedSettingsWidget::setTURNPassword()
274
{
275
    auto text = ui->lineEditTurnPassword->text();
276
    auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId());
277
    confProps.TURN.password = text.toStdString();
278
    LRCInstance::accountModel().setAccountConfig(LRCInstance::getCurrAccId(), confProps);
279 280
}
void
281
AdvancedSettingsWidget::setSTUNAddress()
282
{
283
    auto text = ui->lineEditSTUNAddress->text();
284
    auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId());
285
    confProps.STUN.server = text.toStdString();
286
    LRCInstance::accountModel().setAccountConfig(LRCInstance::getCurrAccId(), confProps);
287 288 289 290 291 292 293 294 295 296 297
}

void
AdvancedSettingsWidget::openFileCACert()
{
    QString fileUrl;
    fileUrl = QFileDialog::getOpenFileName(this, QString("Select a CA certificate"), QDir::homePath()
        + QString("/.local/share/ring/") + QString::fromStdString(LRCInstance::getCurrentAccountInfo().id));
    if (!fileUrl.isEmpty()) {
        auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId());
        confProps.TLS.certificateListFile = fileUrl.toStdString();
298
        LRCInstance::accountModel().setAccountConfig(LRCInstance::getCurrAccId(), confProps);
299
    }
300
    ui->btnCACert->setText(QFileInfo(QString::fromStdString(LRCInstance::getCurrAccConfig().TLS.certificateListFile)).fileName());
301 302 303 304 305 306 307 308 309 310 311
}

void
AdvancedSettingsWidget::openFileUserCert()
{
    QString fileUrl;
    fileUrl = QFileDialog::getOpenFileName(this, QString("Select a user certificate"), QDir::homePath()
        + QString("/.local/share/ring/") + QString::fromStdString(LRCInstance::getCurrentAccountInfo().id));
    if (!fileUrl.isEmpty()) {
        auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId());
        confProps.TLS.certificateFile = fileUrl.toStdString();
312
        LRCInstance::accountModel().setAccountConfig(LRCInstance::getCurrAccId(), confProps);
313
    }
314
    ui->btnUserCert->setText(QFileInfo(QString::fromStdString(LRCInstance::getCurrAccConfig().TLS.certificateFile)).fileName());
315 316 317 318 319 320 321 322 323 324 325
}

void
AdvancedSettingsWidget::openFilePrivateKey()
{
    QString fileUrl;
    fileUrl = QFileDialog::getOpenFileName(this, QString("Select a private key"), QDir::homePath()
        + QString("/.local/share/ring/") + QString::fromStdString(LRCInstance::getCurrentAccountInfo().id));
    if (!fileUrl.isEmpty()) {
        auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId());
        confProps.TLS.privateKeyFile = fileUrl.toStdString();
326
        LRCInstance::accountModel().setAccountConfig(LRCInstance::getCurrAccId(), confProps);
327
    }
328
    ui->btnPrivateKey->setText(QFileInfo(QString::fromStdString(LRCInstance::getCurrAccConfig().TLS.privateKeyFile)).fileName());
329 330 331 332 333 334 335 336 337 338 339 340
}

void
AdvancedSettingsWidget::updateAudioCodecs()
{
    ui->audioListWidget->clear();

    auto audioCodecList = LRCInstance::getCurrentAccountInfo().codecModel->getAudioCodecs();
    int i = 0;
    for (auto it = audioCodecList.begin(); it != audioCodecList.end(); ++it, ++i) {
        QListWidgetItem* audioItem = new QListWidgetItem(ui->audioListWidget);
        audioItem->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
Andreas Traczyk's avatar
Andreas Traczyk committed
341 342
        audioItem->setCheckState(it->enabled ? Qt::Checked : Qt::Unchecked);
        audioItem->setData(Qt::DisplayRole, QString::fromStdString(it->name) + " " + QString::fromStdString(it->samplerate) + " Hz");
343 344 345 346 347 348 349 350 351 352 353 354

        ui->audioListWidget->addItem(audioItem);
    }
}

void
AdvancedSettingsWidget::updateVideoCodecs()
{
    ui->videoListWidget->clear();
    auto videoCodecList = LRCInstance::getCurrentAccountInfo().codecModel->getVideoCodecs();
    int i = 0;
    for (auto it = videoCodecList.begin(); it != videoCodecList.end(); ++it, ++i) {
Andreas Traczyk's avatar
Andreas Traczyk committed
355 356 357 358 359 360
        if (!it->name.length()) { continue; } // temporary fix for empty codec entries
        QListWidgetItem* videoItem = new QListWidgetItem(ui->videoListWidget);
        videoItem->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
        videoItem->setCheckState(it->enabled ? Qt::Checked : Qt::Unchecked);
        videoItem->setData(Qt::DisplayRole, QString::fromStdString(it->name));
        ui->audioListWidget->addItem(videoItem);
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394
    }
}

void
AdvancedSettingsWidget::audioCodecsStateChange(QListWidgetItem* item)
{
    auto audioCodecList = LRCInstance::getCurrentAccountInfo().codecModel->getAudioCodecs();
    auto it = audioCodecList.begin();

    std::advance(it, ui->audioListWidget->row(item));

    LRCInstance::getCurrentAccountInfo().codecModel->enable(it->id, !(it->enabled));
}

void
AdvancedSettingsWidget::videoCodecsStateChange(QListWidgetItem* item)
{
    auto videoCodecList = LRCInstance::getCurrentAccountInfo().codecModel->getVideoCodecs();
    auto it = videoCodecList.begin();

    std::advance(it, ui->videoListWidget->row(item));

    LRCInstance::getCurrentAccountInfo().codecModel->enable(it->id, !(it->enabled));
}

void
AdvancedSettingsWidget::decreaseAudioCodecPriority()
{
    int selectedRow = ui->audioListWidget->row(ui->audioListWidget->selectedItems().at(0));
    auto audioCodecList = LRCInstance::getCurrentAccountInfo().codecModel->getAudioCodecs();
    auto it = audioCodecList.begin();

    advance(it, selectedRow);
    LRCInstance::getCurrentAccountInfo().codecModel->decreasePriority(it->id, false);
Andreas Traczyk's avatar
Andreas Traczyk committed
395 396 397

    // swap current item down
    Utils::swapQListWidgetItems(ui->audioListWidget, true);
398 399 400 401 402 403 404 405 406 407 408
}

void
AdvancedSettingsWidget::increaseAudioCodecPriority()
{
    int selectedRow = ui->audioListWidget->row(ui->audioListWidget->selectedItems().at(0));
    auto audioCodecList = LRCInstance::getCurrentAccountInfo().codecModel->getAudioCodecs();
    auto it = audioCodecList.begin();

    advance(it, selectedRow);
    LRCInstance::getCurrentAccountInfo().codecModel->increasePriority(it->id, false);
Andreas Traczyk's avatar
Andreas Traczyk committed
409 410 411

    // swap current item up
    Utils::swapQListWidgetItems(ui->audioListWidget, false);
412 413 414 415 416 417 418 419 420 421 422
}

void
AdvancedSettingsWidget::decreaseVideoCodecPriority()
{
    int selectedRow = ui->videoListWidget->row(ui->videoListWidget->selectedItems().at(0));
    auto videoCodecList = LRCInstance::getCurrentAccountInfo().codecModel->getVideoCodecs();
    auto it = videoCodecList.begin();

    advance(it, selectedRow);
    LRCInstance::getCurrentAccountInfo().codecModel->decreasePriority(it->id, true);
Andreas Traczyk's avatar
Andreas Traczyk committed
423 424 425

    // swap current item down
    Utils::swapQListWidgetItems(ui->videoListWidget, true);
426 427 428 429 430 431 432 433 434 435 436
}

void
AdvancedSettingsWidget::increaseVideoCodecPriority()
{
    int selectedRow = ui->videoListWidget->row(ui->videoListWidget->selectedItems().at(0));
    auto videoCodecList = LRCInstance::getCurrentAccountInfo().codecModel->getVideoCodecs();
    auto it = videoCodecList.begin();

    advance(it, selectedRow);
    LRCInstance::getCurrentAccountInfo().codecModel->increasePriority(it->id, true);
Andreas Traczyk's avatar
Andreas Traczyk committed
437 438 439

    // swap current item up
    Utils::swapQListWidgetItems(ui->videoListWidget, false);
440 441 442 443 444 445 446
}

void
AdvancedSettingsWidget::setVideoState(int state)
{
    auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId());
    confProps.Video.videoEnabled = (bool)state;
447 448
    LRCInstance::accountModel().setAccountConfig(LRCInstance::getCurrAccId(), confProps);
}