Commit b81281e5 authored by Andreas Traczyk's avatar Andreas Traczyk Committed by Sébastien Blin

settings: inject settings widget dynamically into nav stack

Change-Id: Ifc07bff44ff3811971941751ef610ba2f9b12f24
Reviewed-by: Sébastien Blin's avatarSébastien Blin <sebastien.blin@savoirfairelinux.com>
parent 31fccce3
......@@ -193,7 +193,8 @@ CallWidget::CallWidget(QWidget* parent) :
// chat view
ui->messageView->buildView();
emit setLeftSizeWidget(ui->currentAccountComboBox->width());
// hide the call stack
ui->callStackWidget->hide();
}
CallWidget::~CallWidget()
......@@ -202,6 +203,12 @@ CallWidget::~CallWidget()
delete menu_;
}
int
CallWidget::getLeftPanelWidth()
{
return ui->currentAccountComboBox->width();
}
void
CallWidget::onIncomingMessage(const std::string& convUid,
uint64_t interactionId,
......@@ -510,7 +517,6 @@ CallWidget::invitationsButtonClicked()
void
CallWidget::settingsButtonClicked()
{
emit setLeftSizeWidget(ui->currentAccountComboBox->width());
emit NavigationRequested(ScreenEnum::SetttingsScreen);
}
......
......@@ -64,8 +64,7 @@ public:
explicit CallWidget(QWidget* parent = 0);
~CallWidget();
signals:
void setLeftSizeWidget(int size);
int getLeftPanelWidth();
public slots:
void on_ringContactLineEdit_returnPressed();
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1250</width>
<height>729</height>
<width>1230</width>
<height>657</height>
</rect>
</property>
<property name="sizePolicy">
......@@ -332,6 +332,12 @@
</property>
<item>
<widget class="SmartListView" name="smartList">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="autoScrollMargin">
<number>16</number>
</property>
......@@ -430,6 +436,12 @@
<number>0</number>
</property>
<widget class="QWidget" name="welcomePage">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout_15">
<property name="spacing">
<number>0</number>
......@@ -488,7 +500,7 @@
<item>
<widget class="QLabel" name="ringLogo">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
......@@ -519,39 +531,73 @@
</property>
</widget>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="descLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>Jami is free software for universal communication which respects the freedoms and privacy of its users.</string>
<item>
<layout class="QGridLayout" name="gridLayout_3">
<property name="leftMargin">
<number>10</number>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
<property name="topMargin">
<number>0</number>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
<property name="rightMargin">
<number>10</number>
</property>
<property name="wordWrap">
<bool>true</bool>
<property name="spacing">
<number>0</number>
</property>
</widget>
<item row="0" column="0">
<widget class="QLabel" name="descLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>400</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>400</width>
<height>16777215</height>
</size>
</property>
<property name="baseSize">
<size>
<width>400</width>
<height>0</height>
</size>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>Jami is free software for universal communication which respects the freedoms and privacy of its users.</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item alignment="Qt::AlignHCenter|Qt::AlignVCenter">
<item>
<widget class="QLabel" name="thisIsYourLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Minimum">
......@@ -561,7 +607,7 @@
</property>
<property name="minimumSize">
<size>
<width>400</width>
<width>0</width>
<height>50</height>
</size>
</property>
......@@ -827,14 +873,23 @@ Copy and share it with your friends!
</property>
</spacer>
</item>
<item alignment="Qt::AlignHCenter">
<item>
<widget class="QLabel" name="qrLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">color: #aeaeae</string>
</property>
<property name="text">
<string>Error while generating QR Code</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
......@@ -897,7 +952,7 @@ Copy and share it with your friends!
</sizepolicy>
</property>
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="videoPage">
<property name="sizePolicy">
......
......@@ -39,7 +39,6 @@
#include "utils.h"
#include "wizarddialog.h"
#include "version.h"
#include "settingswidget.h"
MainWindow::MainWindow(QWidget* parent) :
QMainWindow(parent),
......@@ -50,27 +49,22 @@ MainWindow::MainWindow(QWidget* parent) :
connect(ui->wizardwidget, &WizardWidget::NavigationRequested,
[this](ScreenEnum scr) {
Utils::setStackWidget(ui->navStack, ui->navStack->widget(scr));
int index = scr;
if (scr == ScreenEnum::SetttingsScreen) {
index = addSettingsWidget();
}
Utils::setStackWidget(ui->navStack, ui->navStack->widget(index));
});
connect(ui->callwidget, &CallWidget::NavigationRequested,
[this](ScreenEnum scr) {
Utils::setStackWidget(ui->navStack, ui->navStack->widget(scr));
});
connect(ui->settingswidget, &SettingsWidget::NavigationRequested,
[this](ScreenEnum scr) {
Utils::setStackWidget(ui->navStack, ui->navStack->widget(scr));
if (scr == ScreenEnum::CallScreen) {
ui->callwidget->update();
[this](ScreenEnum scr) {
int index = scr;
if (scr == ScreenEnum::SetttingsScreen) {
index = addSettingsWidget();
}
Utils::setStackWidget(ui->navStack, ui->navStack->widget(index));
});
connect(ui->callwidget, &CallWidget::setLeftSizeWidget, [=](int size) {
ui->settingswidget->updateSettings(size);
}
);
QIcon icon(":images/jami.png");
this->setWindowIcon(icon);
......@@ -80,13 +74,24 @@ MainWindow::MainWindow(QWidget* parent) :
QMenu* menu = new QMenu();
auto configAction = new QAction(tr("Configuration"), this);
auto configAction = new QAction(tr("Settings"), this);
connect(configAction, &QAction::triggered,
[this]() {
if (auto settingsWidget = getSettingsWidget()) {
Utils::setStackWidget(ui->navStack, settingsWidget);
} else {
auto index = addSettingsWidget();
Utils::setStackWidget(ui->navStack, ui->navStack->widget(index));
}
setWindowState(Qt::WindowActive);
});
menu->addAction(configAction);
auto exitAction = new QAction(tr("Exit"), this);
connect(exitAction, &QAction::triggered, [this](){
QCoreApplication::exit();
});
connect(exitAction, &QAction::triggered,
[this]() {
QCoreApplication::exit();
});
menu->addAction(exitAction);
sysIcon.setContextMenu(menu);
......@@ -154,6 +159,41 @@ MainWindow::~MainWindow()
delete ui;
}
int
MainWindow::addSettingsWidget()
{
int index = -1;
if (ui->navStack->count() < ScreenEnum::SetttingsScreen + 1) {
auto settingsWidget = new SettingsWidget(this);
settingsWidget->updateSettings(ui->callwidget->getLeftPanelWidth());
index = ui->navStack->addWidget(settingsWidget);
connect(settingsWidget, &SettingsWidget::NavigationRequested,
[this](ScreenEnum scr) {
Utils::setStackWidget(ui->navStack, ui->navStack->widget(scr));
removeSettingsWidget();
if (scr == ScreenEnum::CallScreen) {
ui->callwidget->update();
}
});
}
return index;
}
void
MainWindow::removeSettingsWidget()
{
if (auto settingsWidget = getSettingsWidget()) {
ui->navStack->removeWidget(settingsWidget);
settingsWidget->deleteLater();
}
}
SettingsWidget*
MainWindow::getSettingsWidget()
{
return qobject_cast<SettingsWidget*>(ui->navStack->widget(ScreenEnum::SetttingsScreen));
}
void
MainWindow::onRingEvent(const QString& uri)
{
......@@ -223,7 +263,12 @@ MainWindow::createThumbBar()
settings->setIcon(icon);
settings->setDismissOnClick(true);
connect(settings, &QWinThumbnailToolButton::clicked, [this]() {
Utils::setStackWidget(ui->navStack, ui->settingswidget);
if (auto settingsWidget = getSettingsWidget()) {
Utils::setStackWidget(ui->navStack, settingsWidget);
} else {
auto index = addSettingsWidget();
Utils::setStackWidget(ui->navStack, ui->navStack->widget(index));
}
});
thumbbar->addButton(settings);
......
......@@ -25,6 +25,7 @@
#include <QNetworkConfigurationManager>
#include "navwidget.h"
#include "settingswidget.h"
// LRC
#include "call.h"
......@@ -65,6 +66,9 @@ private:
~MainWindow();
void readSettingsFromRegistry();
void removeSettingsWidget();
int addSettingsWidget();
SettingsWidget* getSettingsWidget();
Ui::MainWindow* ui;
QNetworkConfigurationManager netManager_;
......
......@@ -465,7 +465,6 @@
<widget class="QStackedWidget" name="navStack">
<widget class="WizardWidget" name="wizardwidget"/>
<widget class="CallWidget" name="callwidget"/>
<widget class="SettingsWidget" name="settingswidget"/>
</widget>
</item>
</layout>
......@@ -485,11 +484,6 @@
<header>wizardwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>SettingsWidget</class>
<extends>QWidget</extends>
<header>settingswidget.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="ressources.qrc"/>
......
......@@ -67,7 +67,7 @@
SettingsWidget::SettingsWidget(QWidget* parent)
: NavWidget(parent),
ui(new Ui::SettingsWidget),
scrollArea_(new QScrollArea),
scrollArea_(new QScrollArea(this)),
deviceModel_(&Video::DeviceModel::instance()),
gif(new QMovie(":/images/ajax-loader.gif"))
{
......@@ -148,8 +148,6 @@ SettingsWidget::leaveSettingsSlot()
SettingsWidget::~SettingsWidget()
{
delete advancedSettingsWidget_;
delete scrollArea_;
delete ui;
}
......@@ -276,7 +274,7 @@ SettingsWidget::toggleAdvancedSettings()
}
else { // will show advanced settings next
ui->advancedAccountSettingsPButton->setIcon(QPixmap(":/images/icons/round-arrow_drop_up-24px.svg"));
advancedSettingsWidget_ = new AdvancedSettingsWidget(ui->scrollAreaWidgetContents);
advancedSettingsWidget_ = new AdvancedSettingsWidget(this);
advancedSettingsWidget_->setMaximumWidth(ui->scrollAreaWidgetContents->width() - 10);
ui->currentAccountSettingsScrollLayout->addWidget(advancedSettingsWidget_);
ui->advancedSettingsOffsetLabel->show();
......
......@@ -1039,8 +1039,8 @@ QPushButton:pressed {background: rgb(230,230, 230); border: 0px; border-radius:
<rect>
<x>0</x>
<y>0</y>
<width>642</width>
<height>883</height>
<width>649</width>
<height>908</height>
</rect>
</property>
<property name="styleSheet">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment