Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
feat(settings): Extracted user interface settings on new tab
Browse files Browse the repository at this point in the history
  • Loading branch information
Diadlo committed Aug 26, 2016
1 parent a963bcf commit fb4aa4c
Show file tree
Hide file tree
Showing 12 changed files with 1,322 additions and 1,097 deletions.
15 changes: 9 additions & 6 deletions qtox.pro
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ FORMS += \
src/widget/form/profileform.ui \
src/widget/form/loadhistorydialog.ui \
src/widget/form/setpassworddialog.ui \
src/widget/form/settings/aboutsettings.ui \
src/widget/form/settings/advancedsettings.ui \
src/widget/form/settings/avform.ui \
src/widget/form/settings/generalsettings.ui \
src/widget/form/settings/userinterfacesettings.ui \
src/widget/form/settings/privacysettings.ui \
src/widget/form/settings/avform.ui \
src/widget/form/settings/advancedsettings.ui \
src/widget/form/settings/aboutsettings.ui \
src/widget/form/removefrienddialog.ui \
src/widget/about/aboutuser.ui

Expand Down Expand Up @@ -360,7 +361,8 @@ HEADERS += \
src/widget/about/aboutuser.h \
src/widget/form/groupinviteform.h \
src/widget/tool/profileimporter.h \
src/widget/passwordedit.h
src/widget/passwordedit.h \
src/widget/form/settings/userinterfaceform.h

SOURCES += \
src/ipc.cpp \
Expand Down Expand Up @@ -423,11 +425,13 @@ SOURCES += \
src/video/groupnetcamview.cpp \
src/video/netcamview.cpp \
src/video/videosurface.cpp \
src/video/videomode.cpp \
src/widget/form/addfriendform.cpp \
src/widget/form/settingswidget.cpp \
src/widget/form/settings/generalform.cpp \
src/widget/form/settings/privacyform.cpp \
src/widget/form/settings/avform.cpp \
src/widget/form/settings/userinterfaceform.cpp \
src/widget/form/profileform.cpp \
src/widget/form/filesform.cpp \
src/widget/tool/chattextedit.cpp \
Expand Down Expand Up @@ -479,5 +483,4 @@ SOURCES += \
src/widget/about/aboutuser.cpp \
src/widget/form/groupinviteform.cpp \
src/widget/tool/profileimporter.cpp \
src/widget/passwordedit.cpp \
src/video/videomode.cpp
src/widget/passwordedit.cpp
81 changes: 71 additions & 10 deletions src/widget/form/settings/advancedform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,15 @@
#include "advancedform.h"
#include "ui_advancedsettings.h"

#include <src/core/recursivesignalblocker.h>
#include <QMessageBox>

#include "src/core/core.h"
#include "src/core/coreav.h"
#include "src/core/recursivesignalblocker.h"
#include "src/nexus.h"
#include "src/persistence/settings.h"
#include "src/persistence/db/plaindb.h"
#include "src/persistence/profile.h"
#include "src/widget/translator.h"

AdvancedForm::AdvancedForm()
Expand All @@ -34,15 +40,33 @@ AdvancedForm::AdvancedForm()
// block all child signals during initialization
const RecursiveSignalBlocker signalBlocker(this);

Settings &s = Settings::getInstance();
bodyUI->cbEnableIPv6->setChecked(s.getEnableIPv6());
bodyUI->cbMakeToxPortable->setChecked(Settings::getInstance().getMakeToxPortable());
bodyUI->cbEnableUDP->setChecked(!s.getForceTCP());
bodyUI->proxyAddr->setText(s.getProxyAddr());
int port = s.getProxyPort();
if (port != -1)
bodyUI->proxyPort->setValue(port);

bodyUI->proxyType->setCurrentIndex(static_cast<int>(s.getProxyType()));
onUseProxyUpdated();

// portable
connect(bodyUI->cbMakeToxPortable, &QCheckBox::stateChanged, this, &AdvancedForm::onMakeToxPortableUpdated);
connect(bodyUI->resetButton, SIGNAL(clicked()), this, SLOT(resetToDefault()));
connect(bodyUI->resetButton, &QPushButton::clicked, this, &AdvancedForm::resetToDefault);
//connection
void (QComboBox::* currentIndexChanged)(int) = &QComboBox::currentIndexChanged;
void (QSpinBox::* valueChanged)(int) = &QSpinBox::valueChanged;
connect(bodyUI->cbEnableIPv6, &QCheckBox::stateChanged, this, &AdvancedForm::onEnableIPv6Updated);
connect(bodyUI->cbEnableUDP, &QCheckBox::stateChanged, this, &AdvancedForm::onUDPUpdated);
connect(bodyUI->proxyType, currentIndexChanged, this, &AdvancedForm::onUseProxyUpdated);
connect(bodyUI->proxyAddr, &QLineEdit::editingFinished, this, &AdvancedForm::onProxyAddrEdited);
connect(bodyUI->proxyPort, valueChanged, this, &AdvancedForm::onProxyPortEdited);
connect(bodyUI->reconnectButton, &QPushButton::clicked, this, &AdvancedForm::onReconnectClicked);

for (QCheckBox *cb : findChildren<QCheckBox*>()) // this one is to allow scrolling on checkboxes
{
cb->installEventFilter(this);
}

Translator::registerHandler(std::bind(&AdvancedForm::retranslateUi, this), this);
}
Expand All @@ -62,18 +86,55 @@ void AdvancedForm::resetToDefault()
{
}

bool AdvancedForm::eventFilter(QObject *o, QEvent *e)
void AdvancedForm::onEnableIPv6Updated()
{
Settings::getInstance().setEnableIPv6(bodyUI->cbEnableIPv6->isChecked());
}

void AdvancedForm::onUDPUpdated()
{
Settings::getInstance().setForceTCP(!bodyUI->cbEnableUDP->isChecked());
}

void AdvancedForm::onProxyAddrEdited()
{
Settings::getInstance().setProxyAddr(bodyUI->proxyAddr->text());
}

void AdvancedForm::onProxyPortEdited(int port)
{
if (port <= 0)
port = -1;

Settings::getInstance().setProxyPort(port);
}

void AdvancedForm::onUseProxyUpdated()
{
if ((e->type() == QEvent::Wheel) &&
(qobject_cast<QAbstractSpinBox*>(o) || qobject_cast<QCheckBox*>(o)))
Settings::ProxyType proxytype =
static_cast<Settings::ProxyType>(bodyUI->proxyType->currentIndex());

bodyUI->proxyAddr->setEnabled(proxytype != Settings::ProxyType::ptNone);
bodyUI->proxyPort->setEnabled(proxytype != Settings::ProxyType::ptNone);
Settings::getInstance().setProxyType(proxytype);
}

void AdvancedForm::onReconnectClicked()
{
if (Core::getInstance()->getAv()->anyActiveCalls())
{
e->ignore();
return true;
QMessageBox::warning(this, tr("Call active", "popup title"),
tr("You can't disconnect while a call is active!", "popup text"));
return;
}
return QWidget::eventFilter(o, e);

emit Core::getInstance()->statusSet(Status::Offline);
Nexus::getProfile()->restartCore();
}

void AdvancedForm::retranslateUi()
{
int proxyType = bodyUI->proxyType->currentIndex();
bodyUI->retranslateUi(this);
bodyUI->proxyType->setCurrentIndex(proxyType);
}
11 changes: 8 additions & 3 deletions src/widget/form/settings/advancedform.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,17 @@ class AdvancedForm : public GenericForm
return tr("Advanced");
}

protected:
bool eventFilter(QObject *o, QEvent *e) final override;

private slots:
// Portable
void onMakeToxPortableUpdated();
void resetToDefault();
// Connection
void onEnableIPv6Updated();
void onUDPUpdated();
void onProxyAddrEdited();
void onProxyPortEdited(int port);
void onUseProxyUpdated();
void onReconnectClicked();

private:
void retranslateUi();
Expand Down
162 changes: 147 additions & 15 deletions src/widget/form/settings/advancedsettings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>418</width>
<height>476</height>
<width>505</width>
<height>565</height>
</rect>
</property>
<property name="windowTitle">
Expand All @@ -24,21 +24,11 @@
<rect>
<x>0</x>
<y>0</y>
<width>398</width>
<height>456</height>
<width>489</width>
<height>549</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="cbMakeToxPortable">
<property name="toolTip">
<string extracomment="describes makeToxPortable checkbox">Save settings to the working directory instead of the usual conf dir</string>
</property>
<property name="text">
<string>Make Tox portable</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="warningLabel">
<property name="text">
Expand All @@ -55,7 +45,149 @@
</property>
</widget>
</item>
<item alignment="Qt::AlignTop">
<item>
<widget class="QGroupBox" name="ProtableGroup">
<property name="title">
<string>Portable</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QCheckBox" name="cbMakeToxPortable">
<property name="toolTip">
<string extracomment="describes makeToxPortable checkbox">Save settings to the working directory instead of the usual conf dir</string>
</property>
<property name="text">
<string>Make Tox portable</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="connectionGroup">
<property name="title">
<string>Connection Settings</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<layout class="QVBoxLayout" name="verticalLayoutProxy">
<property name="topMargin">
<number>9</number>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QCheckBox" name="cbEnableIPv6">
<property name="text">
<string extracomment="Text on a checkbox to enable IPv6">Enable IPv6 (recommended)</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbEnableUDP">
<property name="toolTip">
<string extracomment="force tcp checkbox tooltip">Disabling this allows, e.g., toxing over Tor. It adds load to the Tox network however, so uncheck only when necessary.</string>
</property>
<property name="text">
<string extracomment="Text on checkbox to disable UDP">Enable UDP (recommended)</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="proxyLayout">
<item row="1" column="0">
<widget class="QLabel" name="proxyTypeLabel">
<property name="text">
<string>Proxy type:</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QSpinBox" name="proxyPort">
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>65535</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="proxyAddrLabel">
<property name="text">
<string extracomment="Text on proxy addr label">Address:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="proxyAddr"/>
</item>
<item row="2" column="2">
<widget class="QLabel" name="proxyPortLabel">
<property name="text">
<string extracomment="Text on proxy port label">Port:</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="3">
<widget class="QComboBox" name="proxyType">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>None</string>
</property>
</item>
<item>
<property name="text">
<string>SOCKS5</string>
</property>
</item>
<item>
<property name="text">
<string>HTTP</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="reconnectButton">
<property name="text">
<string comment="reconnect button">Reconnect</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QPushButton" name="resetButton">
<property name="text">
<string>Reset to default settings</string>
Expand Down
Loading

0 comments on commit fb4aa4c

Please sign in to comment.