Commit 5e909017 authored by Andreas Traczyk's avatar Andreas Traczyk

settings: refactor

- fixes programmatic slot triggering
- overhauls ui
- standardizes layouts
- fixes file path elide
- adds win10 style toggle switches
- fixes toggle state comparisons
- fixes registry settings
- fixes minimize on close function
- fixes navigate to settings from tray icon
- removes blocking calls to stopPreview
- enhances system notifications
- fixes codec selection
- fixes photobooth in settings
- fixes avatar cropping and scaling

Change-Id: I1fb7669e3cd5dc1c23743ccfe0b54c3e6ac5078b
parent 5b3a7eb1
......@@ -69,7 +69,7 @@ QVariant AccountListModel::data(const QModelIndex &index, int role) const
return QVariant(Utils::toUnderlyingValue<lrc::api::account::Status>(accountInfo.status));
case Role::Picture:
case Qt::DecorationRole:
return PixbufManipulator::accountPhoto(accountInfo);
return Utils::accountPhoto(accountInfo);
case Role::ID:
return QVariant(QString::fromStdString(accountInfo.id));
}
......
/***************************************************************************
* Copyright (C) 2019-2019 by Savoir-faire Linux *
* Copyright (C) 2019 by Savoir-faire Linux *
* Author: Isa Nanic <isa.nanic@savoirfairelinux.com> *
* Author: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com> *
* *
* 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 *
......@@ -20,11 +21,11 @@
#include <QFileDialog>
#include "api/newcodecmodel.h"
#include "lrcinstance.h"
#include "utils.h"
#include "api/newcodecmodel.h"
AdvancedSettingsWidget::AdvancedSettingsWidget(QWidget* parent)
:QWidget(parent),
ui(new Ui::AdvancedSettingsWidget)
......@@ -73,9 +74,28 @@ AdvancedSettingsWidget::AdvancedSettingsWidget(QWidget* parent)
connect(ui->audioDownPushButton, &QPushButton::clicked, this, &AdvancedSettingsWidget::decreaseAudioCodecPriority);
connect(ui->audioUpPushButton, &QPushButton::clicked, this, &AdvancedSettingsWidget::increaseAudioCodecPriority);
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);
});
connect(ui->videoDownPushButton, &QPushButton::clicked, this, &AdvancedSettingsWidget::decreaseVideoCodecPriority);
connect(ui->videoUpPushButton, &QPushButton::clicked, this, &AdvancedSettingsWidget::increaseVideoCodecPriority);
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);
});
}
AdvancedSettingsWidget::~AdvancedSettingsWidget()
......@@ -311,11 +331,8 @@ AdvancedSettingsWidget::updateAudioCodecs()
for (auto it = audioCodecList.begin(); it != audioCodecList.end(); ++it, ++i) {
QListWidgetItem* audioItem = new QListWidgetItem(ui->audioListWidget);
audioItem->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
Qt::CheckState state;
it->enabled ? state = Qt::Checked : state = Qt::Unchecked;
audioItem->setCheckState(state);
audioItem->setData(Qt::DisplayRole, QString::fromStdString(it->name) + "\n" + QString::fromStdString(it->samplerate)
+ " Hz");
audioItem->setCheckState(it->enabled ? Qt::Checked : Qt::Unchecked);
audioItem->setData(Qt::DisplayRole, QString::fromStdString(it->name) + " " + QString::fromStdString(it->samplerate) + " Hz");
ui->audioListWidget->addItem(audioItem);
}
......@@ -325,21 +342,15 @@ 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) {
if (it->name.length()) { // [temporary fix]
QListWidgetItem* videoItem = new QListWidgetItem(ui->videoListWidget);
videoItem->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
Qt::CheckState state;
it->enabled ? state = Qt::Checked : state = Qt::Unchecked;
videoItem->setCheckState(state);
videoItem->setData(Qt::DisplayRole, QString::fromStdString(it->name) + "\n");
ui->audioListWidget->addItem(videoItem);
}
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);
}
}
......@@ -374,7 +385,9 @@ AdvancedSettingsWidget::decreaseAudioCodecPriority()
advance(it, selectedRow);
LRCInstance::getCurrentAccountInfo().codecModel->decreasePriority(it->id, false);
updateAudioCodecs();
// swap current item down
Utils::swapQListWidgetItems(ui->audioListWidget, true);
}
void
......@@ -386,7 +399,9 @@ AdvancedSettingsWidget::increaseAudioCodecPriority()
advance(it, selectedRow);
LRCInstance::getCurrentAccountInfo().codecModel->increasePriority(it->id, false);
updateAudioCodecs();
// swap current item up
Utils::swapQListWidgetItems(ui->audioListWidget, false);
}
void
......@@ -398,7 +413,9 @@ AdvancedSettingsWidget::decreaseVideoCodecPriority()
advance(it, selectedRow);
LRCInstance::getCurrentAccountInfo().codecModel->decreasePriority(it->id, true);
updateVideoCodecs();
// swap current item down
Utils::swapQListWidgetItems(ui->videoListWidget, true);
}
void
......@@ -410,7 +427,9 @@ AdvancedSettingsWidget::increaseVideoCodecPriority()
advance(it, selectedRow);
LRCInstance::getCurrentAccountInfo().codecModel->increasePriority(it->id, true);
updateVideoCodecs();
// swap current item up
Utils::swapQListWidgetItems(ui->videoListWidget, false);
}
void
......
This diff is collapsed.
This diff is collapsed.
/***************************************************************************
* Copyright (C) 2019-2019 by Savoir-faire Linux *
* Author: Isa Nanic <isa.nanic@savoirfairelinux.com>
* Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com>
* Author: Isa Nanic <isa.nanic@savoirfairelinux.com> *
* Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com> *
* *
* 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 *
......@@ -19,16 +19,14 @@
#pragma once
#include <QWidget>
#include <QListWidgetItem>
#include <QWidget>
namespace Ui
{
namespace Ui {
class AdvancedSIPSettingsWidget;
}
class AdvancedSIPSettingsWidget : public QWidget
{
class AdvancedSIPSettingsWidget : public QWidget {
Q_OBJECT
AdvancedSIPSettingsWidget(const AdvancedSIPSettingsWidget& cpy);
......@@ -74,5 +72,4 @@ private slots:
void increaseVideoCodecPriority();
void setVideoState(int state);
};
\ No newline at end of file
};
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>BannedContactsWidget</class>
<widget class="QWidget" name="BannedContactsWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>712</width>
<height>544</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,2">
<property name="sizeConstraint">
<enum>QLayout::SetNoConstraint</enum>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QListView" name="bannedList">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Banned contacts list</string>
</property>
</widget>
</item>
<item>
<widget class="QStackedWidget" name="debanStack">
<property name="currentIndex">
<number>1</number>
</property>
<widget class="QWidget" name="cleanPage"/>
<widget class="QWidget" name="debanPage">
<layout class="QVBoxLayout" name="verticalLayout" stretch="1,0,0,0,1">
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item alignment="Qt::AlignHCenter|Qt::AlignVCenter">
<widget class="QLabel" name="bannedIdLabel">
<property name="text">
<string>Banned ID</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QPushButton" name="debanButton">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>265</width>
<height>30</height>
</size>
</property>
<property name="toolTip">
<string>Deban contact button</string>
</property>
<property name="text">
<string>Deban contact, and add to contact list</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
/***************************************************************************
* Copyright (C) 2019 by Savoir-faire Linux *
* Author: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com> *
* *
* 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/>. *
**************************************************************************/
#include "ui_banneditemwidget.h"
#include "banneditemwidget.h"
#include "lrcinstance.h"
#include "utils.h"
BannedItemWidget::BannedItemWidget(const QString& name,
const QString& id,
QWidget* parent)
: QWidget(parent),
ui(new Ui::BannedItemWidget)
{
ui->setupUi(this);
ui->labelContactName->setText(name);
ui->labelContactId->setText(id);
auto avatarImage = Utils::fallbackAvatar(QSize(48, 48), id, name);
ui->labelContactAvatar->setPixmap(QPixmap::fromImage(avatarImage));
ui->btnReAddContact->setToolTip(QObject::tr("Add as contact"));
connect(ui->btnReAddContact, &QPushButton::clicked, this,
[this]() {
emit btnReAddContactClicked();
});
}
BannedItemWidget::~BannedItemWidget()
{
disconnect(this);
delete ui;
}
QSize
BannedItemWidget::sizeHint() const
{
return QSize();
}
\ No newline at end of file
/***************************************************************************
* Copyright (C) 2017-2019 by Savoir-faire Linux *
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
* Copyright (C) 2019 by Savoir-faire Linux *
* Author: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com> *
* *
* 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 *
......@@ -18,22 +18,27 @@
#pragma once
#include <QDialog>
#include <QWidget>
namespace Ui {
class PhotoBoothDialog;
class BannedItemWidget;
}
class PhotoBoothDialog : public QDialog
class BannedItemWidget : public QWidget
{
Q_OBJECT
public:
explicit PhotoBoothDialog(QWidget* parent = 0);
~PhotoBoothDialog();
QString& getOutputFileName() { return fileName_;}
explicit BannedItemWidget(const QString& name,
const QString& id,
QWidget* parent = 0);
~BannedItemWidget();
QSize sizeHint() const override;
private:
Ui::PhotoBoothDialog* ui;
QString fileName_;
};
Ui::BannedItemWidget* ui;
signals:
void btnReAddContactClicked() const;
};
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>BannedItemWidget</class>
<widget class="QWidget" name="BannedItemWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>449</width>
<height>69</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>7</number>
</property>
<property name="topMargin">
<number>7</number>
</property>
<property name="rightMargin">
<number>7</number>
</property>
<property name="bottomMargin">
<number>7</number>
</property>
<item>
<widget class="QLabel" name="labelContactAvatar">
<property name="minimumSize">
<size>
<width>48</width>
<height>48</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>48</width>
<height>48</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>8</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>7</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="labelContactName">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>name</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelContactId">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>30</height>
</size>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>id</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QPushButton" name="btnReAddContact">
<property name="minimumSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="ressources.qrc">
<normaloff>:/images/icons/ic_person_add_black_24dp_2x.png</normaloff>:/images/icons/ic_person_add_black_24dp_2x.png</iconset>
</property>
<property name="iconSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>8</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources>
<include location="ressources.qrc"/>
</resources>
<connections/>
</ui>
......@@ -72,7 +72,7 @@ CallWidget::CallWidget(QWidget* parent) :
videoRenderer_ = nullptr;
QSettings settings;
QSettings settings("jami.net", "Jami");
// select last used account if stored in registry
auto accountList = LRCInstance::accountModel().getAccountList();
......@@ -139,7 +139,7 @@ CallWidget::CallWidget(QWidget* parent) :
[this](int pos, int index) {
Q_UNUSED(index);
Q_UNUSED(pos);
QSettings settings;
QSettings settings("jami.net", "Jami");
settings.setValue(SettingsKey::mainSplitterState, ui->mainActivitySplitter->saveState());
});
......@@ -289,8 +289,8 @@ CallWidget::onIncomingMessage(const std::string& convUid,
}
auto bestName = Utils::bestNameForConversation(*conversation, *convModel);
Utils::showSystemNotification(this,
QString(tr("Message incoming from %1"))
.arg(QString::fromStdString(bestName)));
QString::fromStdString(bestName),
QString::fromStdString(interaction.body));
}
updateConversationsFilterWidget();
if (convUid != LRCInstance::getSelectedConvUid()) {
......
......@@ -67,14 +67,14 @@
<item>
<widget class="QWidget" name="sidePanelLayoutWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>320</width>
<width>380</width>
<height>0</height>
</size>
</property>
......@@ -84,6 +84,12 @@
<height>16777215</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout_12" stretch="0,0">
<property name="spacing">
<number>0</number>
......@@ -1992,7 +1998,7 @@ Copy and share it with your friends!
</spacer>
</item>
<item>
<widget class="MessageWebView" name="messageView">
<widget class="MessageWebView" name="messageView" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
......@@ -2005,6 +2011,9 @@ Copy and share it with your friends!
<height>16777215</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">b</string>
</property>
</widget>
</item>
<item>
......
......@@ -188,7 +188,7 @@ ConversationItemDelegate::paintConversationItem(QPainter* painter,
QRect rectName1(rect.left() + leftMargin,
rect.top() + topMargin,
rect.width() - leftMargin - infoTextWidth_ - infoTextWidthModifier - 4,
rect.width() - leftMargin - infoTextWidth_ - infoTextWidthModifier - 8,
rect.height() / 2 - 2);
QRect rectName2(rectName1.left(),
......@@ -204,7 +204,7 @@ ConversationItemDelegate::paintConversationItem(QPainter* painter,
QRect rectInfo2(rectInfo1.left(),
rectInfo1.top() + rectInfo1.height() - infoText2HeightModifier,
rectInfo1.width(),
rectInfo1.height() - bottomMargin + infoText2HeightModifier);
rectInfo1.height() - bottomMargin + infoText2HeightModifier + 4);
QFontMetrics fontMetrics(font);
......
......@@ -42,7 +42,7 @@ private:
constexpr static int dy_ = 6;
constexpr static int dx_ = 12;
constexpr static int fontSize_ = 11;
constexpr static int infoTextWidth_ = 144;
constexpr static int infoTextWidth_ = 176;
mutable std::map<int, bool> highlightMap_;
};
......@@ -114,7 +114,7 @@ $CopyDir = $OutDir + "\ringtones"
New-Item -ItemType directory -Path $CopyDir -Force
$RingtonePath = "$ClientDir\..\daemon\ringtones"
write-host "copying ringtones..."
Get-ChildItem -Path $RingtonePath -Include *.ul, *.wav, *.ogg -Recurse | ForEach-Object {
Get-ChildItem -Path $RingtonePath -Include *.ul, *.ogg, *.wav, *.opus -Recurse | ForEach-Object {
write-host "copying ringtone: " $_.FullName " => " $CopyDir
Copy-Item -Path $_.FullName -Destination $CopyDir -Force Recurse
}
......
......@@ -38,6 +38,7 @@ DeleteAccountDialog::DeleteAccountDialog(QWidget *parent) :
connect(ui->btnDeleteCancel, &QPushButton::clicked, this, &DeleteAccountDialog::on_deleteCancelBtn_clicked);
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
setFixedSize(size());
}
DeleteAccountDialog::~DeleteAccountDialog()
......
......@@ -16,9 +16,7 @@
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
**************************************************************************/
#ifndef DELETEACCOUNTDIALOG_H
#define DELETEACCOUNTDIALOG_H
#pragma once
#include <QDialog>
......@@ -42,6 +40,4 @@ signals: