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