Commit 6e4a39ad authored by Isa's avatar Isa Committed by Andreas Traczyk

new lrc: refactor settings page, ui overhaul

Change-Id: I7eac9e025a3c1281b0ba98515dc77f65c36fc178
Reviewed-by: Andreas Traczyk's avatarAndreas Traczyk <andreas.traczyk@savoirfairelinux.com>
parent a1f7021a
......@@ -80,11 +80,11 @@ SOURCES += main.cpp\
invitebuttonswidget.cpp \
wizardwidget.cpp \
currentaccountcombobox.cpp \
conversationfilterbutton.cpp \
messagewebpage.cpp \
messagewebview.cpp \
webchathelpers.cpp \
animationhelpers.cpp
animationhelpers.cpp \
settingsitemwidget.cpp
HEADERS += mainwindow.h \
callwidget.h \
......@@ -128,11 +128,11 @@ HEADERS += mainwindow.h \
invitebuttonswidget.h \
wizardwidget.h \
currentaccountcombobox.h \
conversationfilterbutton.h \
messagewebpage.h \
messagewebview.h \
webchathelpers.h \
animationhelpers.h
animationhelpers.h \
settingsitemwidget.h
contains(DEFINES, URI_PROTOCOL) {
......
......@@ -157,7 +157,7 @@ AccountDetails::setAccount(Account* currentAccount) {
if (not currentAccount_->tlsPrivateKey().isEmpty())
ui->lrcfg_tlsPrivateKeyCertificate->setText(currentAccount_->tlsPrivateKey());
#if defined(Q_OS_WIN) && !defined(_MSC_VER)
#if defined(Q_OS_WIN) && !defined(_MSC_VER)
certMap_[ui->lrcfg_tlsCaListCertificate->objectName()] = &currentAccount_->setTlsCaListCertificate;
certMap_[ui->lrcfg_tlsCertificate->objectName()] = &currentAccount_->setTlsCertificate;
certMap_[ui->lrcfg_tlsPrivateKeyCertificate->objectName()] = &currentAccount_->setTlsPrivateKey;
......
This diff is collapsed.
/***************************************************************************
* Copyright (C) 2018 by Savoir-faire Linux *
* Author: Isa Nanic <isa.nanic@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/>. *
**************************************************************************/
#pragma once
#include <QWidget>
#include <QListWidgetItem>
namespace Ui {
class AdvancedSettingsWidget;
}
class AdvancedSettingsWidget : public QWidget {
Q_OBJECT
AdvancedSettingsWidget(const AdvancedSettingsWidget& cpy);
public:
AdvancedSettingsWidget(QWidget* parent = nullptr);
~AdvancedSettingsWidget();
private:
Ui::AdvancedSettingsWidget* ui;
void updateAdvancedSettings();
private slots:
// call settings
void setCallsUntrusted(bool state);
void setAutoAnswerCalls(bool state);
void setEnableRingtone(bool state);
void openFileCustomRingtone();
// name server
void setNameServer(const QString& name);
// openDHT config
void setEnableProxy(bool state);
void setProxyAddress(const QString& name);
void setBootstrapAddress(const QString& name);
// security
void openFileCACert();
void openFileUserCert();
void openFilePrivateKey();
// connectivity
void setUseUPnP(bool state);
void setUseTURN(bool state);
void setUseSTUN(bool state);
void setTURNAddress(const QString& name);
void setTURNUsername(const QString& name);
void setTURNPsswd(const QString& name);
void setSTUNAddress(const QString& name);
// codecs
void updateAudioCodecs();
void updateVideoCodecs();
void audioCodecsStateChange(QListWidgetItem* item = nullptr);
void videoCodecsStateChange(QListWidgetItem* item = nullptr);
void decreaseAudioCodecPriority();
void increaseAudioCodecPriority();
void decreaseVideoCodecPriority();
void increaseVideoCodecPriority();
void setVideoState(int state);
};
\ No newline at end of file
This diff is collapsed.
/**************************************************************************
* Copyright (C) 2018 by Savoir-faire Linux *
* Author: Isa Nanic <isa.nanic@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 <https://www.gnu.org/licenses/>. *
**************************************************************************/
#include "avatargraphicsview.h"
AvatarGraphicsView::AvatarGraphicsView(QWidget* parent)
: QGraphicsView(parent)
{
setDragMode(QGraphicsView::ScrollHandDrag);
}
void
AvatarGraphicsView::wheelEvent(QWheelEvent* event)
{
QPoint numSteps = event->angleDelta() / (8*15);
if (!numSteps.isNull()) {
zoomImage(numSteps);
}
event->accept();
}
void
AvatarGraphicsView::zoomImage(const QPoint& steps)
{
steps.y() == 1 ? scale(zoomIncrement_, zoomIncrement_) : scale(1 / zoomIncrement_, 1 / zoomIncrement_);
}
void
AvatarGraphicsView::paintEvent(QPaintEvent* e)
{
QGraphicsView::paintEvent(e);
QPainter painter(viewport());
QPainterPath square;
QPainterPath circle;
square.addRect(0, 0, width(), height());
circle.addEllipse(QPoint(width() / 2 - 0.5, height() / 2 - 0.5), circleSize_ + 1, circleSize_ + 1);
painter.setOpacity(0.3);
painter.fillPath(square.subtracted(circle), QBrush(QColor(Qt::black)));
}
\ No newline at end of file
/**************************************************************************
* Copyright (C) 2018 by Savoir-faire Linux *
* Author: Isa Nanic <isa.nanic@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 <https://www.gnu.org/licenses/>. *
**************************************************************************/
#pragma once
#include <QGraphicsView>
#include <QWheelEvent>
#include <QDragMoveEvent>
class AvatarGraphicsView : public QGraphicsView
{
Q_OBJECT
AvatarGraphicsView(const AvatarGraphicsView& cpy);
public:
AvatarGraphicsView(QWidget* parent = nullptr);
inline void setAvatarSize(int size) { circleSize_ = size; };
private:
void wheelEvent(QWheelEvent* event);
void zoomImage(const QPoint& steps);
void paintEvent(QPaintEvent* e);
const qreal zoomIncrement_ = 1.03;
int circleSize_ = 130;
};
\ No newline at end of file
/***************************************************************************
* Copyright (C) 2018 by Savoir-faire Linux *
* Author: Isa Nanic <isa.nanic@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 "bannedlistmodel.h"
#include "lrcinstance.h"
BannedListModel::BannedListModel(QObject *parent)
: QAbstractListModel(parent)
{
}
int
BannedListModel::rowCount(const QModelIndex &index) const
{
if (!index.isValid()) {
return LRCInstance::accountModel().getAccountList().size(); // count
}
return 0; // A valid QModelIndex returns 0 as no entry has sub-elements
}
bool
BannedListModel::setData(const QModelIndex& index, const QVariant& value, int role)
{
return 1;
}
\ No newline at end of file
/***************************************************************************
* Copyright (C) 2018 by Savoir-faire Linux *
* Author: Isa Nanic <isa.nanic@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/>. *
***************************************************************************/
#pragma once
#include <QAbstractListModel>
class BannedListModel : public QAbstractListModel
{
Q_OBJECT
BannedListModel(const BannedListModel& cpy);
public:
explicit BannedListModel(QObject *parent = nullptr);
int rowCount(const QModelIndex &index = QModelIndex()) const override;
bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
};
......@@ -193,6 +193,8 @@ CallWidget::CallWidget(QWidget* parent) :
// chat view
ui->messageView->buildView();
emit setLeftSizeWidget(ui->currentAccountComboBox->width());
}
CallWidget::~CallWidget()
......@@ -439,7 +441,7 @@ CallWidget::imageForConv(const std::string& convUid)
const std::string&
CallWidget::selectedAccountId()
{
return LRCInstance::getSelectedAccountId();
return LRCInstance::getCurrAccId();
}
const std::string&
......@@ -502,6 +504,7 @@ CallWidget::invitationsButtonClicked()
void
CallWidget::settingsButtonClicked()
{
emit setLeftSizeWidget(ui->currentAccountComboBox->width());
emit NavigationRequested(ScreenEnum::ConfScreen);
}
......@@ -727,7 +730,7 @@ CallWidget::showIMOutOfCall(const QModelIndex& nodeIdx)
QString contactURI = nodeIdx.data(static_cast<int>(SmartListModel::Role::URI)).toString();
bool isContact = false;
auto selectedAccountId = LRCInstance::getSelectedAccountId();
auto selectedAccountId = LRCInstance::getCurrAccId();
auto& accountInfo = LRCInstance::accountModel().getAccountInfo(selectedAccountId);
bool isRINGAccount = accountInfo.profileInfo.type == lrc::api::profile::Type::RING;
try {
......@@ -1062,10 +1065,17 @@ CallWidget::updateSmartList()
SLOT(smartListSelectionChanged(QItemSelection, QItemSelection)));
}
void
CallWidget::updateComboBox()
{
ui->currentAccountComboBox->updateComboBoxDisplay();
}
void
CallWidget::update()
{
updateSmartList();
updateConversationsFilterWidget();
updateComboBox();
connectConversationModel();
}
......@@ -64,6 +64,9 @@ public:
explicit CallWidget(QWidget* parent = 0);
~CallWidget();
signals:
void setLeftSizeWidget(int size);
public slots:
void on_ringContactLineEdit_returnPressed();
......@@ -125,6 +128,7 @@ private:
void setConversationFilter(const QString& filter);
void setConversationFilter(lrc::api::profile::Type filter);
void updateConversationsFilterWidget();
void updateComboBox();
const std::string& selectedAccountId();
const std::string& selectedConvUid();
......
......@@ -440,6 +440,32 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<property name="spacing">
<number>0</number>
</property>
<property name="topMargin">
<number>7</number>
</property>
<property name="rightMargin">
<number>7</number>
</property>
<item>
<spacer name="horizontalSpacer_11">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
......
......@@ -84,15 +84,15 @@ ConfigurationWidget::ConfigurationWidget(QWidget *parent) :
accountStateDelegate_ = new AccountStateDelegate();
ui->accountView->setItemDelegate(accountStateDelegate_);
// connect delete button to popup trigger
connect(ui->deleteAccountBtn, &QPushButton::clicked, [=](){
auto idx = ui->accountView->currentIndex();
DeleteAccountDialog dialog(idx);
dialog.exec();
if (!LRCInstance::accountModel().getAccountList().size()) {
emit NavigationRequested(ScreenEnum::WizardScreen);
}
});
//// connect delete button to popup trigger
//connect(ui->deleteAccountBtn, &QPushButton::clicked, [=](){
// auto idx = ui->accountView->currentIndex();
// DeleteAccountDialog dialog(idx);
// dialog.exec();
// if (!LRCInstance::accountModel().getAccountList().size()) {
// emit NavigationRequested(ScreenEnum::WizardScreen);
// }
//});
isLoading_ = true;
ui->deviceBox->setModel(deviceModel_);
......
......@@ -209,7 +209,7 @@
<bool>true</bool>
</property>
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="generalPage">
<layout class="QHBoxLayout" name="verticalLayout_2">
......
......@@ -187,7 +187,7 @@ ConversationItemDelegate::paintRingConversationItem(QPainter* painter,
QFontMetrics fontMetrics(font);
// The name is displayed at the avatar's right
QString nameStr = index.data(static_cast<int>(SmartListModel::Role::DisplayName)).value<QString>();;
QString nameStr = index.data(static_cast<int>(SmartListModel::Role::DisplayName)).value<QString>();
if (!nameStr.isNull()) {
font.setItalic(false);
font.setBold(true);
......
......@@ -64,6 +64,8 @@ $FilesToCopy = @(
"$QtDir\bin\Qt5Widgets.dll",
"$QtDir\bin\Qt5WinExtras.dll",
"$QtDir\bin\Qt5Xml.dll",
"$QtDir\bin\Qt5Multimedia.dll",
"$QtDir\bin\Qt5MultimediaWidgets.dll",
"$QtDir\bin\QtWebEngineProcess.exe",
"$QtDir\resources\qtwebengine_resources.pak",
"$QtDir\resources\icudtl.dat"
......
......@@ -59,8 +59,7 @@ CurrentAccountComboBox::CurrentAccountComboBox(QWidget* parent)
}
});
gearPixmap_.load(":/images/icons/round-settings-24px.svg");
gearLabel_.setPixmap(gearPixmap_);
gearLabel_.setPixmap(QPixmap(":/images/icons/round-settings-24px.svg"));
gearLabel_.setParent(this);
gearLabel_.setStyleSheet("background: transparent;");
setupSettingsButton();
......@@ -134,16 +133,17 @@ CurrentAccountComboBox::paintEvent(QPaintEvent* e)
}
}
void CurrentAccountComboBox::resizeEvent(QResizeEvent * event)
void CurrentAccountComboBox::resizeEvent(QResizeEvent* event)
{
Q_UNUSED(event);
setupSettingsButton();
}
void
CurrentAccountComboBox::setupSettingsButton()
{
gearPoint_.setX(this->width() - gearSize_ - 4 * gearBorder_);
gearPoint_.setY(this->height() / 2 - gearLabel_.height() / 2 - 2 * gearBorder_);
gearPoint_.setX(this->width() - gearSize_ - 4 * gearBorder_ + 2);
gearPoint_.setY(this->height() / 2 - gearLabel_.height() / 2 - 2 * gearBorder_ + 4.5);
gearLabel_.setGeometry(gearPoint_.x() - 3, gearPoint_.y(),
gearSize_ + 2 * gearBorder_, gearSize_ + 2 * gearBorder_);
gearLabel_.setMargin(gearBorder_);
......@@ -209,7 +209,6 @@ CurrentAccountComboBox::hidePopup()
gearLabel_.show();
popupPresent = false;
QComboBox::hidePopup();
}
void
......@@ -217,4 +216,10 @@ CurrentAccountComboBox::leaveEvent(QEvent* event)
{
gearLabel_.setStyleSheet("background: transparent;");
QComboBox::leaveEvent(event);
}
\ No newline at end of file
}
void
CurrentAccountComboBox::updateComboBoxDisplay()
{
importLabelPhoto(LRCInstance::getCurrentAccountIndex());
}
......@@ -36,6 +36,7 @@ public:
~CurrentAccountComboBox();
void accountListUpdate();
void setCurrentIndex(int index);
void updateComboBoxDisplay();
signals:
void settingsButtonClicked();
......@@ -64,6 +65,5 @@ private:
bool popupPresent = false;
QPoint gearPoint_;
QPixmap gearPixmap_;
QLabel gearLabel_;
};
\ No newline at end of file
};
/***************************************************************************
* Copyright (C) 2015-2017 by Savoir-faire Linux *
* Copyright (C) 2015-2018 by Savoir-faire Linux *
* Author: Olivier Soldano <olivier.soldano@savoirfairelinux.com> *
* Author: Isa Nanic <isa.nanic@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,26 +20,22 @@
#include "deleteaccountdialog.h"
#include "ui_deleteaccountdialog.h"
// LRC
#include "accountmodel.h"
#include "itemdataroles.h"
#include "account.h"
#include "lrcinstance.h"
#include "utils.h"
DeleteAccountDialog::DeleteAccountDialog(const QModelIndex & idx, QWidget *parent) :
DeleteAccountDialog::DeleteAccountDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::DeleteAccountDialog),
index_(idx)
ui(new Ui::DeleteAccountDialog)
{
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
ui->setupUi(this);
ui->accountAliasLabel->setText(AccountModel::instance().data(index_, Qt::DisplayRole).toString());
auto ac = AccountModel::instance().getAccountByModelIndex(index_);
if (ac->protocol() == Account::Protocol::RING){
ui->accountIdLabel->setAlignment(Qt::AlignCenter);
ui->accountIdLabel->setText((ac->registeredName().isEmpty())? ac->username(): ac->registeredName() + "\n" + ac->username());
if (LRCInstance::getCurrentAccountInfo().profileInfo.type == lrc::api::profile::Type::RING){
ui->labelBestId->setText(QString::fromStdString(Utils::bestNameForAccount(LRCInstance::getCurrentAccountInfo())));
ui->labelAccountHash->setText(QString::fromStdString(LRCInstance::getCurrentAccountInfo().profileInfo.uri));
} else {
ui->warningLabel->hide();
ui->labelWarning->hide();
}
connect(ui->btnDeleteAccept, &QPushButton::clicked, this, &DeleteAccountDialog::on_deleteAcceptBtn_clicked);
connect(ui->btnDeleteCancel, &QPushButton::clicked, this, &DeleteAccountDialog::on_deleteCancelBtn_clicked);
}
DeleteAccountDialog::~DeleteAccountDialog()
......@@ -46,15 +43,15 @@ DeleteAccountDialog::~DeleteAccountDialog()
delete ui;
}
void DeleteAccountDialog::on_deleteCancelBtn_clicked()
void
DeleteAccountDialog::on_deleteCancelBtn_clicked()
{
close();
done(0);
}
void DeleteAccountDialog::on_deleteAcceptBtn_clicked()
void
DeleteAccountDialog::on_deleteAcceptBtn_clicked()
{
auto account = AccountModel::instance().getAccountByModelIndex(index_);
AccountModel::instance().remove(account);
AccountModel::instance().save();
close();
}
LRCInstance::editableAccountModel()->removeAccount(LRCInstance::getCurrAccId());
done(0);
}
\ No newline at end of file
/***************************************************************************
* Copyright (C) 2015-2017 by Savoir-faire Linux *
* Copyright (C) 2015-2018 by Savoir-faire Linux *
* Author: Olivier Soldano <olivier.soldano@savoirfairelinux.com> *
* Author: Isa Nanic <isa.nanic@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,7 +21,6 @@
#define DELETEACCOUNTDIALOG_H
#include <QDialog>
#include <QModelIndex>
namespace Ui {
class DeleteAccountDialog;
......@@ -31,20 +31,17 @@ class DeleteAccountDialog : public QDialog
Q_OBJECT
public:
DeleteAccountDialog(const QModelIndex & idx, QWidget *parent = 0);
DeleteAccountDialog(QWidget *parent = nullptr);
~DeleteAccountDialog();
signals:
void deleteAcceptClicked();
private slots:
void on_deleteCancelBtn_clicked();
void on_deleteAcceptBtn_clicked();
signals:
void deleteAcceptClicked();
private:
Ui::DeleteAccountDialog *ui;
QModelIndex index_;
};
#endif // DELETEACCOUNTDIALOG_H
......@@ -2,6 +2,9 @@
<ui version="4.0">
<class>DeleteAccountDialog</class>
<widget class="QDialog" name="DeleteAccountDialog">
<property name="windowModality">
<enum>Qt::ApplicationModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
......@@ -10,67 +13,126 @@
<height>240</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>400</width>
<height>240</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>400</width>
<height>240</height>
</size>
</property>
<property name="windowTitle">
<string>Ring - account deletion</string>
<string>Account deletion</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout" stretch="3,3,1,1,1,0,3,0">
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<property name="styleSheet">
<string notr="true">background: white;</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout" stretch="3,1,1,0,0,0,0,0">
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="labelDeletion">
<property name="maximumSize">
<size>
<width>20</width>
<width>16777215</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="deletionLabel1">
<property name="font">
<font>
<pointsize>8</pointsize>
</font>
</property>
<property name="text">
<string>Do you really want to delete account ?</string>
<string>Do you really want to delete the following account?</string>
</property>
</widget>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="accountAliasLabel">
<widget class="QLabel" name="labelBestId">