mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
base refactoring
This commit is contained in:
parent
8d9d53b9e9
commit
8fa9457305
5
qtox.pro
5
qtox.pro
|
@ -26,7 +26,10 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
|||
TARGET = qtox
|
||||
TEMPLATE = app
|
||||
FORMS += \
|
||||
mainwindow.ui
|
||||
mainwindow.ui \
|
||||
widget/form/settings/generalsettings.ui \
|
||||
widget/form/settings/avsettings.ui \
|
||||
widget/form/settings/identitysettings.ui
|
||||
CONFIG += c++11
|
||||
|
||||
TRANSLATIONS = translations/de.ts \
|
||||
|
|
|
@ -16,41 +16,35 @@
|
|||
|
||||
#include "avform.h"
|
||||
#include "widget/camera.h"
|
||||
#include "ui_avsettings.h"
|
||||
|
||||
AVForm::AVForm(Camera* cam)
|
||||
AVForm::AVForm(Camera* cam) :
|
||||
GenericForm(tr("Audio/Video settings"), QPixmap(":/img/settings/av.png"))
|
||||
{
|
||||
icon.setPixmap(QPixmap(":/img/settings/av.png").scaledToHeight(headLayout.sizeHint().height(), Qt::SmoothTransformation));
|
||||
label.setText(tr("Audio/Video settings"));
|
||||
|
||||
QGroupBox *group = new QGroupBox(tr("Video Settings"));
|
||||
bodyUI = new Ui::AVSettings;
|
||||
bodyUI->setupUi(this);
|
||||
|
||||
camView = new SelfCamView(cam);
|
||||
camView = new SelfCamView(cam, this);
|
||||
bodyUI->videoGroup->layout()->addWidget(camView);
|
||||
camView->hide(); // hide by default
|
||||
testVideo = new QPushButton(tr("Show video preview","On a button"));
|
||||
connect(testVideo, &QPushButton::clicked, this, &AVForm::onTestVideoPressed);
|
||||
|
||||
videoLayout = new QVBoxLayout();
|
||||
videoLayout->addWidget(testVideo);
|
||||
videoLayout->addWidget(camView);
|
||||
//videoGroup->setLayout(videoLayout); // strangely enough, this causes a segfault....
|
||||
|
||||
layout.addWidget(group);
|
||||
layout.addStretch(1);
|
||||
connect(bodyUI->testVideoBtn, &QPushButton::clicked, this, &AVForm::onTestVideoPressed);
|
||||
}
|
||||
|
||||
AVForm::~AVForm()
|
||||
{
|
||||
delete bodyUI;
|
||||
}
|
||||
|
||||
void AVForm::showTestVideo()
|
||||
{
|
||||
testVideo->setText(tr("Hide video preview","On a button"));
|
||||
bodyUI->testVideoBtn->setText(tr("Hide video preview","On a button"));
|
||||
camView->show();
|
||||
}
|
||||
|
||||
void AVForm::closeTestVideo()
|
||||
{
|
||||
testVideo->setText(tr("Show video preview","On a button"));
|
||||
bodyUI->testVideoBtn->setText(tr("Show video preview","On a button"));
|
||||
camView->close();
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,11 @@
|
|||
#include <QGroupBox>
|
||||
#include <QVBoxLayout>
|
||||
#include <QPushButton>
|
||||
|
||||
namespace Ui {
|
||||
class AVSettings;
|
||||
}
|
||||
|
||||
class Camera;
|
||||
|
||||
class AVForm : public GenericForm
|
||||
|
@ -33,10 +38,10 @@ public:
|
|||
|
||||
private slots:
|
||||
void onTestVideoPressed();
|
||||
|
||||
private:
|
||||
QGroupBox* videoGroup;
|
||||
QVBoxLayout* videoLayout;
|
||||
QPushButton* testVideo;
|
||||
Ui::AVSettings *bodyUI;
|
||||
|
||||
SelfCamView* camView;
|
||||
|
||||
void showTestVideo();
|
||||
|
|
50
widget/form/settings/avsettings.ui
Normal file
50
widget/form/settings/avsettings.ui
Normal file
|
@ -0,0 +1,50 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>AVSettings</class>
|
||||
<widget class="QWidget" name="AVSettings">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="videoGroup">
|
||||
<property name="title">
|
||||
<string>Video settings</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QPushButton" name="testVideoBtn">
|
||||
<property name="text">
|
||||
<string>Show video preview</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<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>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -14,65 +14,57 @@
|
|||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#include "ui_generalsettings.h"
|
||||
#include "generalform.h"
|
||||
#include "widget/form/settingswidget.h"
|
||||
#include "widget/widget.h"
|
||||
#include "misc/settings.h"
|
||||
#include "misc/smileypack.h"
|
||||
|
||||
GeneralForm::GeneralForm()
|
||||
GeneralForm::GeneralForm() :
|
||||
GenericForm(tr("General Settings"), QPixmap(":/img/settings/general.png"))
|
||||
{
|
||||
icon.setPixmap(QPixmap(":/img/settings/general.png").scaledToHeight(headLayout.sizeHint().height(), Qt::SmoothTransformation));
|
||||
label.setText(tr("General Settings"));
|
||||
|
||||
enableIPv6.setText(tr("Enable IPv6 (recommended)","Text on a checkbox to enable IPv6"));
|
||||
enableIPv6.setChecked(Settings::getInstance().getEnableIPv6());
|
||||
useTranslations.setText(tr("Use translations","Text on a checkbox to enable translations"));
|
||||
useTranslations.setChecked(Settings::getInstance().getUseTranslations());
|
||||
makeToxPortable.setText(tr("Make Tox portable","Text on a checkbox to make qTox a portable application"));
|
||||
makeToxPortable.setChecked(Settings::getInstance().getMakeToxPortable());
|
||||
makeToxPortable.setToolTip(tr("Save settings to the working directory instead of the usual conf dir","describes makeToxPortable checkbox"));
|
||||
bodyUI = new Ui::GeneralSettings;
|
||||
bodyUI->setupUi(this);
|
||||
|
||||
bodyUI->cbEnableIPv6->setChecked(Settings::getInstance().getEnableIPv6());
|
||||
bodyUI->cbUseTranslations->setChecked(Settings::getInstance().getUseTranslations());
|
||||
bodyUI->cbMakeToxPortable->setChecked(Settings::getInstance().getMakeToxPortable());
|
||||
|
||||
smileyPackLabel.setText(tr("Smiley Pack", "Text on smiley pack label"));
|
||||
for (auto entry : SmileyPack::listSmileyPacks())
|
||||
smileyPackBrowser.addItem(entry.first, entry.second);
|
||||
smileyPackBrowser.setCurrentIndex(smileyPackBrowser.findData(Settings::getInstance().getSmileyPack()));
|
||||
{
|
||||
bodyUI->smileyPackBrowser->addItem(entry.first, entry.second);
|
||||
}
|
||||
bodyUI->smileyPackBrowser->setCurrentIndex(bodyUI->smileyPackBrowser->findData(Settings::getInstance().getSmileyPack()));
|
||||
|
||||
headLayout.addWidget(&label);
|
||||
layout.addWidget(&enableIPv6);
|
||||
layout.addWidget(&useTranslations);
|
||||
layout.addWidget(&makeToxPortable);
|
||||
layout.addWidget(&smileyPackLabel);
|
||||
layout.addWidget(&smileyPackBrowser);
|
||||
layout.addStretch();
|
||||
|
||||
connect(&enableIPv6, SIGNAL(stateChanged(int)), this, SLOT(onEnableIPv6Updated()));
|
||||
connect(&useTranslations, SIGNAL(stateChanged(int)), this, SLOT(onUseTranslationUpdated()));
|
||||
connect(&makeToxPortable, SIGNAL(stateChanged(int)), this, SLOT(onMakeToxPortableUpdated()));
|
||||
connect(&smileyPackBrowser, SIGNAL(currentIndexChanged(int)), this, SLOT(onSmileyBrowserIndexChanged(int)));
|
||||
connect(bodyUI->cbEnableIPv6, SIGNAL(stateChanged(int)), this, SLOT(onEnableIPv6Updated()));
|
||||
connect(bodyUI->cbUseTranslations, SIGNAL(stateChanged(int)), this, SLOT(onUseTranslationUpdated()));
|
||||
connect(bodyUI->cbMakeToxPortable, SIGNAL(stateChanged(int)), this, SLOT(onMakeToxPortableUpdated()));
|
||||
connect(bodyUI->smileyPackBrowser, SIGNAL(currentIndexChanged(int)), this, SLOT(onSmileyBrowserIndexChanged(int)));
|
||||
}
|
||||
|
||||
GeneralForm::~GeneralForm()
|
||||
{
|
||||
delete bodyUI;
|
||||
}
|
||||
|
||||
void GeneralForm::onEnableIPv6Updated()
|
||||
{
|
||||
Settings::getInstance().setEnableIPv6(enableIPv6.isChecked());
|
||||
Settings::getInstance().setEnableIPv6(bodyUI->cbEnableIPv6->isChecked());
|
||||
}
|
||||
|
||||
void GeneralForm::onUseTranslationUpdated()
|
||||
{
|
||||
Settings::getInstance().setUseTranslations(useTranslations.isChecked());
|
||||
Settings::getInstance().setUseTranslations(bodyUI->cbUseTranslations->isChecked());
|
||||
}
|
||||
|
||||
void GeneralForm::onMakeToxPortableUpdated()
|
||||
{
|
||||
Settings::getInstance().setMakeToxPortable(makeToxPortable.isChecked());
|
||||
Settings::getInstance().setMakeToxPortable(bodyUI->cbMakeToxPortable->isChecked());
|
||||
}
|
||||
|
||||
void GeneralForm::onSmileyBrowserIndexChanged(int index)
|
||||
{
|
||||
QString filename = smileyPackBrowser.itemData(index).toString();
|
||||
QString filename = bodyUI->smileyPackBrowser->itemData(index).toString();
|
||||
Settings::getInstance().setSmileyPack(filename);
|
||||
}
|
||||
|
|
|
@ -21,6 +21,10 @@
|
|||
#include <QComboBox>
|
||||
#include <QCheckBox>
|
||||
|
||||
namespace Ui {
|
||||
class GeneralSettings;
|
||||
}
|
||||
|
||||
class GeneralForm : public GenericForm
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -35,9 +39,7 @@ private slots:
|
|||
void onSmileyBrowserIndexChanged(int index);
|
||||
|
||||
private:
|
||||
QCheckBox enableIPv6, useTranslations, makeToxPortable;
|
||||
QLabel label, smileyPackLabel;
|
||||
QComboBox smileyPackBrowser;
|
||||
Ui::GeneralSettings *bodyUI;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -17,37 +17,30 @@
|
|||
#ifndef GENERICFORM_H
|
||||
#define GENERICFORM_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QVBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QWidget>
|
||||
#include "widget/form/settingswidget.h"
|
||||
|
||||
class GenericForm : public QObject
|
||||
class GenericForm : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
GenericForm()
|
||||
{
|
||||
head.setLayout(&headLayout);
|
||||
headLayout.addWidget(&icon);
|
||||
headLayout.addWidget(&label);
|
||||
body.setLayout(&layout);
|
||||
}
|
||||
~GenericForm() {};
|
||||
GenericForm(const QString &name, const QPixmap &icon) : formName(name), formIcon(icon) {;}
|
||||
~GenericForm() {;}
|
||||
|
||||
virtual void show(SettingsWidget& sw)
|
||||
{
|
||||
sw.body->layout()->addWidget(&body);
|
||||
body.show();
|
||||
sw.head->layout()->addWidget(&head);
|
||||
head.show();
|
||||
// sw.body->layout()->addWidget(&body);
|
||||
// body.show();
|
||||
// sw.head->layout()->addWidget(&head);
|
||||
// head.show();
|
||||
}
|
||||
|
||||
QString getFormName() {return formName;}
|
||||
QPixmap getFormIcon() {return formIcon;}
|
||||
|
||||
protected:
|
||||
QVBoxLayout layout;
|
||||
QHBoxLayout headLayout;
|
||||
QLabel label, icon;
|
||||
QWidget head, body;
|
||||
QString formName;
|
||||
QPixmap formIcon;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#include "ui_identitysettings.h"
|
||||
#include "identityform.h"
|
||||
#include "widget/form/settingswidget.h"
|
||||
#include "widget/croppinglabel.h"
|
||||
|
@ -23,34 +24,18 @@
|
|||
#include <QApplication>
|
||||
#include <QClipboard>
|
||||
|
||||
IdentityForm::IdentityForm()
|
||||
IdentityForm::IdentityForm() :
|
||||
GenericForm(tr("Your identity"), QPixmap(":/img/settings/identity.png"))
|
||||
{
|
||||
icon.setPixmap(QPixmap(":/img/settings/identity.png").scaledToHeight(headLayout.sizeHint().height(), Qt::SmoothTransformation));
|
||||
label.setText(tr("Your identity"));
|
||||
bodyUI = new Ui::IdentitySettings;
|
||||
bodyUI->setupUi(this);
|
||||
|
||||
// public
|
||||
publicGroup = new QGroupBox(tr("Public Information"));
|
||||
userNameLabel = new QLabel(tr("Name","Username/nick"));
|
||||
userName = new QLineEdit();
|
||||
|
||||
statusMessageLabel = new QLabel(tr("Status","Status message"));
|
||||
statusMessage = new QLineEdit();
|
||||
|
||||
vLayout = new QVBoxLayout();
|
||||
vLayout->addWidget(userNameLabel);
|
||||
vLayout->addWidget(userName);
|
||||
vLayout->addWidget(statusMessageLabel);
|
||||
vLayout->addWidget(statusMessage);
|
||||
publicGroup->setLayout(vLayout);
|
||||
|
||||
// tox
|
||||
toxGroup = new QGroupBox(tr("Tox ID"));
|
||||
toxIdLabel = new CroppingLabel();
|
||||
toxIdLabel->setText(tr("Your Tox ID (click to copy)"));
|
||||
toxId = new ClickableTE();
|
||||
QFont small;
|
||||
small.setPixelSize(13);
|
||||
small.setKerning(false);
|
||||
|
||||
toxId->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||
toxId->setReadOnly(true);
|
||||
toxId->setFrameStyle(QFrame::NoFrame);
|
||||
|
@ -58,20 +43,12 @@ IdentityForm::IdentityForm()
|
|||
toxId->setFixedHeight(toxId->document()->size().height()*2);
|
||||
toxId->setFont(small);
|
||||
|
||||
QVBoxLayout* toxLayout = new QVBoxLayout();
|
||||
toxLayout->addWidget(toxIdLabel);
|
||||
toxLayout->addWidget(toxId);
|
||||
toxGroup->setLayout(toxLayout);
|
||||
bodyUI->toxGroup->layout()->addWidget(toxId);
|
||||
|
||||
layout.setSpacing(30);
|
||||
layout.addWidget(publicGroup);
|
||||
layout.addWidget(toxGroup);
|
||||
layout.addStretch(1);
|
||||
|
||||
connect(toxIdLabel, SIGNAL(clicked()), this, SLOT(copyIdClicked()));
|
||||
connect(bodyUI->toxIdLabel, SIGNAL(clicked()), this, SLOT(copyIdClicked()));
|
||||
connect(toxId, SIGNAL(clicked()), this, SLOT(copyIdClicked()));
|
||||
connect(userName, SIGNAL(editingFinished()), this, SLOT(onUserNameEdited()));
|
||||
connect(statusMessage, SIGNAL(editingFinished()), this, SLOT(onStatusMessageEdited()));
|
||||
connect(bodyUI->userName, SIGNAL(editingFinished()), this, SLOT(onUserNameEdited()));
|
||||
connect(bodyUI->statusMessage, SIGNAL(editingFinished()), this, SLOT(onStatusMessageEdited()));
|
||||
}
|
||||
|
||||
IdentityForm::~IdentityForm()
|
||||
|
@ -88,18 +65,28 @@ void IdentityForm::copyIdClicked()
|
|||
|
||||
void IdentityForm::onUserNameEdited()
|
||||
{
|
||||
emit userNameChanged(userName->text());
|
||||
emit userNameChanged(bodyUI->userName->text());
|
||||
}
|
||||
|
||||
void IdentityForm::onStatusMessageEdited()
|
||||
{
|
||||
emit statusMessageChanged(statusMessage->text());
|
||||
emit statusMessageChanged(bodyUI->statusMessage->text());
|
||||
}
|
||||
|
||||
void IdentityForm::show(SettingsWidget& sw)
|
||||
{
|
||||
userName->setText(Core::getInstance()->getUsername());
|
||||
statusMessage->setText(Core::getInstance()->getStatusMessage());
|
||||
bodyUI->userName->setText(Core::getInstance()->getUsername());
|
||||
bodyUI->statusMessage->setText(Core::getInstance()->getStatusMessage());
|
||||
toxId->setText(Core::getInstance()->getSelfId().toString());
|
||||
GenericForm::show(sw);
|
||||
}
|
||||
|
||||
void IdentityForm::setUserName(const QString &name)
|
||||
{
|
||||
bodyUI->userName->setText(name);
|
||||
}
|
||||
|
||||
void IdentityForm::setStatusMessage(const QString &msg)
|
||||
{
|
||||
bodyUI->statusMessage->setText(msg);
|
||||
}
|
||||
|
|
|
@ -21,8 +21,14 @@
|
|||
#include <QGroupBox>
|
||||
#include <QTextEdit>
|
||||
#include <QLineEdit>
|
||||
#include <QLabel>
|
||||
|
||||
class CroppingLabel;
|
||||
|
||||
namespace Ui {
|
||||
class IdentitySettings;
|
||||
}
|
||||
|
||||
class ClickableTE : public QTextEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -41,7 +47,8 @@ public:
|
|||
IdentityForm();
|
||||
~IdentityForm();
|
||||
|
||||
QLineEdit* userName, * statusMessage;
|
||||
void setUserName(const QString &name);
|
||||
void setStatusMessage(const QString &msg);
|
||||
|
||||
void show(SettingsWidget& sw);
|
||||
|
||||
|
@ -55,11 +62,9 @@ private slots:
|
|||
void onStatusMessageEdited();
|
||||
|
||||
private:
|
||||
QGroupBox* toxGroup, * publicGroup;
|
||||
Ui::IdentitySettings* bodyUI;
|
||||
|
||||
ClickableTE* toxId;
|
||||
QLabel* userNameLabel, * statusMessageLabel;
|
||||
CroppingLabel* toxIdLabel;
|
||||
QVBoxLayout* vLayout, * toxLayout;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -17,10 +17,9 @@
|
|||
#include "privacyform.h"
|
||||
#include "widget/form/settingswidget.h"
|
||||
|
||||
PrivacyForm::PrivacyForm()
|
||||
PrivacyForm::PrivacyForm() :
|
||||
GenericForm(tr("Privacy settings"), QPixmap(":/img/settings/privacy.png"))
|
||||
{
|
||||
icon.setPixmap(QPixmap(":/img/settings/privacy.png").scaledToHeight(headLayout.sizeHint().height(), Qt::SmoothTransformation));
|
||||
label.setText(tr("Privacy settings"));
|
||||
}
|
||||
|
||||
PrivacyForm::~PrivacyForm()
|
||||
|
|
|
@ -22,37 +22,30 @@
|
|||
#include "widget/form/settings/identityform.h"
|
||||
#include "widget/form/settings/privacyform.h"
|
||||
#include "widget/form/settings/avform.h"
|
||||
#include <QTabWidget>
|
||||
|
||||
SettingsWidget::SettingsWidget(Camera* cam)
|
||||
: QWidget()
|
||||
SettingsWidget::SettingsWidget(Camera* cam, QWidget* parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
generalForm = new GeneralForm();
|
||||
identityForm = new IdentityForm();
|
||||
privacyForm = new PrivacyForm();
|
||||
avForm = new AVForm(cam);
|
||||
|
||||
main = new QWidget();
|
||||
body = new QWidget();
|
||||
head = new QWidget();
|
||||
foot = new QWidget();
|
||||
|
||||
head->setLayout(new QVBoxLayout());
|
||||
body->setLayout(new QVBoxLayout());
|
||||
|
||||
prepButtons();
|
||||
foot->setLayout(iconsLayout);
|
||||
mainLayout = new QVBoxLayout();
|
||||
mainLayout->addWidget(body);
|
||||
mainLayout->addWidget(foot);
|
||||
// something something foot size
|
||||
main->setLayout(mainLayout);
|
||||
|
||||
connect(generalButton, &QPushButton::clicked, this, &SettingsWidget::onGeneralClicked);
|
||||
connect(identityButton, &QPushButton::clicked, this, &SettingsWidget::onIdentityClicked);
|
||||
connect(privacyButton, &QPushButton::clicked, this, &SettingsWidget::onPrivacyClicked);
|
||||
connect(avButton, &QPushButton::clicked, this, &SettingsWidget::onAVClicked);
|
||||
|
||||
active = generalForm;
|
||||
|
||||
QVBoxLayout *bodyLayout = new QVBoxLayout();
|
||||
body->setLayout(bodyLayout);
|
||||
|
||||
QTabWidget *settingsTabs = new QTabWidget();
|
||||
bodyLayout->addWidget(settingsTabs);
|
||||
|
||||
GeneralForm *gfrm = new GeneralForm;
|
||||
ifrm = new IdentityForm;
|
||||
PrivacyForm *pfrm = new PrivacyForm;
|
||||
AVForm *avfrm = new AVForm(cam);
|
||||
|
||||
GenericForm *cfgForms[] = {gfrm, ifrm, pfrm, avfrm};
|
||||
for (auto cfgForm : cfgForms)
|
||||
{
|
||||
settingsTabs->addTab(cfgForm, cfgForm->getFormIcon(), cfgForm->getFormName());
|
||||
}
|
||||
}
|
||||
|
||||
SettingsWidget::~SettingsWidget()
|
||||
|
@ -61,173 +54,8 @@ SettingsWidget::~SettingsWidget()
|
|||
|
||||
void SettingsWidget::show(Ui::MainWindow& ui)
|
||||
{
|
||||
active->show(*this);
|
||||
ui.mainContent->layout()->addWidget(main);
|
||||
ui.mainContent->layout()->addWidget(body);
|
||||
ui.mainHead->layout()->addWidget(head);
|
||||
main->show();
|
||||
body->show();
|
||||
head->show();
|
||||
}
|
||||
|
||||
void SettingsWidget::onGeneralClicked()
|
||||
{
|
||||
hideSettingsForms();
|
||||
active = generalForm;
|
||||
generalForm->show(*this);
|
||||
}
|
||||
|
||||
void SettingsWidget::onIdentityClicked()
|
||||
{
|
||||
hideSettingsForms();
|
||||
active = identityForm;
|
||||
identityForm->show(*this);
|
||||
}
|
||||
|
||||
void SettingsWidget::onPrivacyClicked()
|
||||
{
|
||||
hideSettingsForms();
|
||||
active = privacyForm;
|
||||
privacyForm->show(*this);
|
||||
}
|
||||
|
||||
void SettingsWidget::onAVClicked()
|
||||
{
|
||||
hideSettingsForms();
|
||||
active = avForm;
|
||||
avForm->show(*this);
|
||||
}
|
||||
|
||||
void SettingsWidget::hideSettingsForms()
|
||||
{
|
||||
QLayoutItem *item;
|
||||
while ((item = head->layout()->takeAt(0)) != 0)
|
||||
item->widget()->hide();
|
||||
while ((item = body->layout()->takeAt(0)) != 0)
|
||||
item->widget()->hide();
|
||||
}
|
||||
|
||||
void SettingsWidget::prepButtons()
|
||||
{
|
||||
// this crap is copied from ui_mainwindow.h... there's no easy way around
|
||||
// just straight up copying it like this... oh well
|
||||
// the layout/icons obviously need to be improved, but it's a working model,
|
||||
// not a pretty one
|
||||
QSizePolicy sizePolicy3(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
sizePolicy3.setHorizontalStretch(0);
|
||||
sizePolicy3.setVerticalStretch(0);
|
||||
foot->setObjectName(QStringLiteral("foot"));
|
||||
foot->setEnabled(true);
|
||||
foot->setSizePolicy(sizePolicy3);
|
||||
QPalette palette5;
|
||||
QBrush brush(QColor(255, 255, 255, 255));
|
||||
brush.setStyle(Qt::SolidPattern);
|
||||
QBrush brush1(QColor(28, 28, 28, 255));
|
||||
brush1.setStyle(Qt::SolidPattern);
|
||||
QBrush brush2(QColor(42, 42, 42, 255));
|
||||
brush2.setStyle(Qt::SolidPattern);
|
||||
QBrush brush3(QColor(35, 35, 35, 255));
|
||||
brush3.setStyle(Qt::SolidPattern);
|
||||
QBrush brush4(QColor(14, 14, 14, 255));
|
||||
brush4.setStyle(Qt::SolidPattern);
|
||||
QBrush brush5(QColor(18, 18, 18, 255));
|
||||
brush5.setStyle(Qt::SolidPattern);
|
||||
QBrush brush6(QColor(0, 0, 0, 255));
|
||||
brush6.setStyle(Qt::SolidPattern);
|
||||
QBrush brush7(QColor(255, 255, 220, 255));
|
||||
brush7.setStyle(Qt::SolidPattern);
|
||||
palette5.setBrush(QPalette::Active, QPalette::WindowText, brush);
|
||||
palette5.setBrush(QPalette::Active, QPalette::Button, brush1);
|
||||
palette5.setBrush(QPalette::Active, QPalette::Light, brush2);
|
||||
palette5.setBrush(QPalette::Active, QPalette::Midlight, brush3);
|
||||
palette5.setBrush(QPalette::Active, QPalette::Dark, brush4);
|
||||
palette5.setBrush(QPalette::Active, QPalette::Mid, brush5);
|
||||
palette5.setBrush(QPalette::Active, QPalette::Text, brush);
|
||||
palette5.setBrush(QPalette::Active, QPalette::BrightText, brush);
|
||||
palette5.setBrush(QPalette::Active, QPalette::ButtonText, brush);
|
||||
palette5.setBrush(QPalette::Active, QPalette::Base, brush6);
|
||||
palette5.setBrush(QPalette::Active, QPalette::Window, brush1);
|
||||
palette5.setBrush(QPalette::Active, QPalette::Shadow, brush6);
|
||||
palette5.setBrush(QPalette::Active, QPalette::AlternateBase, brush4);
|
||||
palette5.setBrush(QPalette::Active, QPalette::ToolTipBase, brush7);
|
||||
palette5.setBrush(QPalette::Active, QPalette::ToolTipText, brush6);
|
||||
palette5.setBrush(QPalette::Inactive, QPalette::WindowText, brush);
|
||||
palette5.setBrush(QPalette::Inactive, QPalette::Button, brush1);
|
||||
palette5.setBrush(QPalette::Inactive, QPalette::Light, brush2);
|
||||
palette5.setBrush(QPalette::Inactive, QPalette::Midlight, brush3);
|
||||
palette5.setBrush(QPalette::Inactive, QPalette::Dark, brush4);
|
||||
palette5.setBrush(QPalette::Inactive, QPalette::Mid, brush5);
|
||||
palette5.setBrush(QPalette::Inactive, QPalette::Text, brush);
|
||||
palette5.setBrush(QPalette::Inactive, QPalette::BrightText, brush);
|
||||
palette5.setBrush(QPalette::Inactive, QPalette::ButtonText, brush);
|
||||
palette5.setBrush(QPalette::Inactive, QPalette::Base, brush6);
|
||||
palette5.setBrush(QPalette::Inactive, QPalette::Window, brush1);
|
||||
palette5.setBrush(QPalette::Inactive, QPalette::Shadow, brush6);
|
||||
palette5.setBrush(QPalette::Inactive, QPalette::AlternateBase, brush4);
|
||||
palette5.setBrush(QPalette::Inactive, QPalette::ToolTipBase, brush7);
|
||||
palette5.setBrush(QPalette::Inactive, QPalette::ToolTipText, brush6);
|
||||
palette5.setBrush(QPalette::Disabled, QPalette::WindowText, brush4);
|
||||
palette5.setBrush(QPalette::Disabled, QPalette::Button, brush1);
|
||||
palette5.setBrush(QPalette::Disabled, QPalette::Light, brush2);
|
||||
palette5.setBrush(QPalette::Disabled, QPalette::Midlight, brush3);
|
||||
palette5.setBrush(QPalette::Disabled, QPalette::Dark, brush4);
|
||||
palette5.setBrush(QPalette::Disabled, QPalette::Mid, brush5);
|
||||
palette5.setBrush(QPalette::Disabled, QPalette::Text, brush4);
|
||||
palette5.setBrush(QPalette::Disabled, QPalette::BrightText, brush);
|
||||
palette5.setBrush(QPalette::Disabled, QPalette::ButtonText, brush4);
|
||||
palette5.setBrush(QPalette::Disabled, QPalette::Base, brush1);
|
||||
palette5.setBrush(QPalette::Disabled, QPalette::Window, brush1);
|
||||
palette5.setBrush(QPalette::Disabled, QPalette::Shadow, brush6);
|
||||
palette5.setBrush(QPalette::Disabled, QPalette::AlternateBase, brush1);
|
||||
palette5.setBrush(QPalette::Disabled, QPalette::ToolTipBase, brush7);
|
||||
palette5.setBrush(QPalette::Disabled, QPalette::ToolTipText, brush6);
|
||||
foot->setPalette(palette5);
|
||||
foot->setAutoFillBackground(true);
|
||||
|
||||
iconsLayout = new QHBoxLayout(foot);
|
||||
iconsLayout->setSpacing(0);
|
||||
iconsLayout->setObjectName(QStringLiteral("iconsLayout"));
|
||||
iconsLayout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
generalButton = new QPushButton(foot);
|
||||
generalButton->setObjectName(QStringLiteral("generalButton"));
|
||||
generalButton->setMinimumSize(QSize(55, 35));
|
||||
generalButton->setMaximumSize(QSize(55, 35));
|
||||
generalButton->setFocusPolicy(Qt::NoFocus);
|
||||
QIcon icon1;
|
||||
icon1.addFile(QStringLiteral(":/img/add.png"), QSize(), QIcon::Normal, QIcon::Off);
|
||||
generalButton->setIcon(icon1);
|
||||
generalButton->setFlat(true);
|
||||
iconsLayout->addWidget(generalButton);
|
||||
|
||||
identityButton = new QPushButton(foot);
|
||||
identityButton->setObjectName(QStringLiteral("identityButton"));
|
||||
identityButton->setMinimumSize(QSize(55, 35));
|
||||
identityButton->setMaximumSize(QSize(55, 35));
|
||||
identityButton->setFocusPolicy(Qt::NoFocus);
|
||||
QIcon icon2;
|
||||
icon2.addFile(QStringLiteral(":/img/group.png"), QSize(), QIcon::Normal, QIcon::Off);
|
||||
identityButton->setIcon(icon2);
|
||||
identityButton->setFlat(true);
|
||||
iconsLayout->addWidget(identityButton);
|
||||
|
||||
privacyButton = new QPushButton(foot);
|
||||
privacyButton->setObjectName(QStringLiteral("privacyButton"));
|
||||
privacyButton->setMinimumSize(QSize(55, 35));
|
||||
privacyButton->setMaximumSize(QSize(55, 35));
|
||||
privacyButton->setFocusPolicy(Qt::NoFocus);
|
||||
QIcon icon3;
|
||||
icon3.addFile(QStringLiteral(":/img/transfer.png"), QSize(), QIcon::Normal, QIcon::Off);
|
||||
privacyButton->setIcon(icon3);
|
||||
privacyButton->setFlat(true);
|
||||
iconsLayout->addWidget(privacyButton);
|
||||
|
||||
avButton = new QPushButton(foot);
|
||||
avButton->setObjectName(QStringLiteral("avButton"));
|
||||
avButton->setMinimumSize(QSize(55, 35));
|
||||
avButton->setMaximumSize(QSize(55, 35));
|
||||
avButton->setFocusPolicy(Qt::NoFocus);
|
||||
QIcon icon4;
|
||||
icon4.addFile(QStringLiteral(":/img/settings.png"), QSize(), QIcon::Normal, QIcon::Off);
|
||||
avButton->setIcon(icon4);
|
||||
avButton->setFlat(true);
|
||||
iconsLayout->addWidget(avButton);
|
||||
}
|
||||
|
|
|
@ -25,47 +25,22 @@ class GeneralForm;
|
|||
class IdentityForm;
|
||||
class PrivacyForm;
|
||||
class AVForm;
|
||||
namespace Ui {class MainWindow;};
|
||||
|
||||
namespace Ui {class MainWindow;}
|
||||
|
||||
class SettingsWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SettingsWidget(Camera* cam);
|
||||
SettingsWidget(Camera* cam, QWidget* parent = nullptr);
|
||||
~SettingsWidget();
|
||||
|
||||
void show(Ui::MainWindow &ui);
|
||||
|
||||
QWidget *head, *body; // keep the others private
|
||||
GenericForm* active;
|
||||
GeneralForm* generalForm;
|
||||
IdentityForm* identityForm;
|
||||
PrivacyForm* privacyForm;
|
||||
AVForm* avForm;
|
||||
|
||||
public slots:
|
||||
//void setFriendAddress(const QString& friendAddress);
|
||||
|
||||
private slots:
|
||||
void onGeneralClicked();
|
||||
void onIdentityClicked();
|
||||
void onPrivacyClicked();
|
||||
void onAVClicked();
|
||||
IdentityForm *getIdentityForm() {return ifrm;}
|
||||
|
||||
private:
|
||||
QWidget *main, *foot;
|
||||
// main consists of body+foot for Ui::MainWindow
|
||||
QVBoxLayout *mainLayout;
|
||||
|
||||
void hideSettingsForms();
|
||||
|
||||
// the code pertaining to the icons is mostly copied from ui_mainwindow.h
|
||||
QHBoxLayout *iconsLayout;
|
||||
QPushButton *generalButton;
|
||||
QPushButton *identityButton;
|
||||
QPushButton *privacyButton;
|
||||
QPushButton *avButton;
|
||||
void prepButtons(); // just so I can move the crap to the bottom of the file
|
||||
QWidget *head, *body; // keep the others private
|
||||
IdentityForm *ifrm;
|
||||
};
|
||||
|
||||
#endif // SETTINGSWIDGET_H
|
||||
|
|
|
@ -218,9 +218,9 @@ Widget::Widget(QWidget *parent)
|
|||
connect(ui->nameLabel, SIGNAL(textChanged(QString,QString)), this, SLOT(onUsernameChanged(QString,QString)));
|
||||
connect(ui->statusLabel, SIGNAL(textChanged(QString,QString)), this, SLOT(onStatusMessageChanged(QString,QString)));
|
||||
connect(profilePicture, SIGNAL(clicked()), this, SLOT(onAvatarClicked()));
|
||||
connect(settingsWidget->identityForm, &IdentityForm::userNameChanged, core, &Core::setUsername);
|
||||
connect(settingsWidget->identityForm, &IdentityForm::statusMessageChanged, core, &Core::setStatusMessage);
|
||||
connect(setStatusOnline, SIGNAL(triggered()), this, SLOT(setStatusOnline()));
|
||||
// connect(settingsWidget->getIdentityForm(), &IdentityForm::userNameChanged, Core::getInstance(), &Core::setUsername);
|
||||
// connect(settingsWidget->getIdentityForm(), &IdentityForm::statusMessageChanged, Core::getInstance(), &Core::setStatusMessage);
|
||||
connect(setStatusAway, SIGNAL(triggered()), this, SLOT(setStatusAway()));
|
||||
connect(setStatusBusy, SIGNAL(triggered()), this, SLOT(setStatusBusy()));
|
||||
connect(&friendForm, SIGNAL(friendRequested(QString,QString)), this, SIGNAL(friendRequested(QString,QString)));
|
||||
|
@ -428,7 +428,7 @@ void Widget::setUsername(const QString& username)
|
|||
{
|
||||
ui->nameLabel->setText(username);
|
||||
ui->nameLabel->setToolTip(username); // for overlength names
|
||||
settingsWidget->identityForm->userName->setText(username);
|
||||
settingsWidget->getIdentityForm()->setUserName(username);
|
||||
}
|
||||
|
||||
void Widget::onStatusMessageChanged(const QString& newStatusMessage, const QString& oldStatusMessage)
|
||||
|
@ -442,7 +442,7 @@ void Widget::setStatusMessage(const QString &statusMessage)
|
|||
{
|
||||
ui->statusLabel->setText(statusMessage);
|
||||
ui->statusLabel->setToolTip(statusMessage); // for overlength messsages
|
||||
settingsWidget->identityForm->statusMessage->setText(statusMessage);
|
||||
settingsWidget->getIdentityForm()->setStatusMessage(statusMessage);
|
||||
}
|
||||
|
||||
void Widget::addFriend(int friendId, const QString &userId)
|
||||
|
|
Loading…
Reference in New Issue
Block a user