1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00
qTox/widget/form/settingsform.cpp

94 lines
2.9 KiB
C++
Raw Normal View History

2014-06-25 04:11:11 +08:00
#include "settingsform.h"
#include "widget/widget.h"
2014-07-02 06:47:06 +08:00
#include "settings.h"
2014-06-25 04:11:11 +08:00
#include <QFont>
#include <QClipboard>
#include <QApplication>
2014-06-25 04:11:11 +08:00
SettingsForm::SettingsForm()
: QObject()
{
main = new QWidget(), head = new QWidget();
QFont bold, small;
bold.setBold(true);
small.setPixelSize(13);
2014-07-04 03:42:23 +08:00
headLabel.setText(tr("User Settings","\"Headline\" of the window"));
2014-06-25 04:11:11 +08:00
headLabel.setFont(bold);
2014-07-04 03:42:23 +08:00
nameLabel.setText(tr("Name","Username/nick"));
statusTextLabel.setText(tr("Status","Status message"));
2014-07-06 17:51:01 +08:00
idLabel.setText("Tox ID " + tr("(click here to copy)", "Click on this text to copy TID to clipboard"));
2014-06-25 04:11:11 +08:00
id.setFont(small);
id.setTextInteractionFlags(Qt::TextSelectableByMouse);
id.setReadOnly(true);
id.setFrameStyle(QFrame::NoFrame);
2014-07-05 01:22:43 +08:00
id.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
id.setFixedHeight(id.document()->size().height());
2014-06-25 04:11:11 +08:00
2014-07-04 03:42:23 +08:00
videoTest.setText(tr("Test video","Text on a button to test the video/webcam"));
enableIPv6.setText(tr("Enable IPv6 (recommended)","Text on a checkbox to enable IPv6"));
2014-07-02 06:47:06 +08:00
enableIPv6.setChecked(Settings::getInstance().getEnableIPv6());
2014-07-05 01:22:43 +08:00
useTranslations.setText(tr("Use translations","Text on a checkbox to enable translations"));
useTranslations.setChecked(Settings::getInstance().getUseTranslations());
2014-06-25 04:11:11 +08:00
main->setLayout(&layout);
layout.addWidget(&nameLabel);
layout.addWidget(&name);
layout.addWidget(&statusTextLabel);
layout.addWidget(&statusText);
layout.addWidget(&idLabel);
layout.addWidget(&id);
layout.addWidget(&videoTest);
2014-07-02 06:47:06 +08:00
layout.addWidget(&enableIPv6);
2014-07-05 01:22:43 +08:00
layout.addWidget(&useTranslations);
2014-06-25 04:11:11 +08:00
layout.addStretch();
head->setLayout(&headLayout);
headLayout.addWidget(&headLabel);
connect(&videoTest, SIGNAL(clicked()), this, SLOT(onTestVideoClicked()));
2014-07-02 06:47:06 +08:00
connect(&enableIPv6, SIGNAL(stateChanged(int)), this, SLOT(onEnableIPv6Updated()));
2014-07-06 17:51:01 +08:00
connect(&useTranslations, SIGNAL(stateChanged(int)), this, SLOT(onUseTranslationUpdated()));
connect(&idLabel, SIGNAL(clicked()), this, SLOT(copyIdClicked()));
2014-06-25 04:11:11 +08:00
}
SettingsForm::~SettingsForm()
{
}
void SettingsForm::setFriendAddress(const QString& friendAddress)
{
id.setText(friendAddress);
}
void SettingsForm::show(Ui::Widget &ui)
{
name.setText(ui.nameLabel->text());
statusText.setText(ui.statusLabel->text());
ui.mainContent->layout()->addWidget(main);
ui.mainHead->layout()->addWidget(head);
main->show();
head->show();
}
void SettingsForm::onTestVideoClicked()
{
Widget::getInstance()->showTestCamview();
}
2014-07-02 06:47:06 +08:00
void SettingsForm::onEnableIPv6Updated()
{
Settings::getInstance().setEnableIPv6(enableIPv6.isChecked());
}
void SettingsForm::copyIdClicked()
{
id.selectAll();;
QApplication::clipboard()->setText(id.toPlainText());
}
2014-07-05 01:22:43 +08:00
void SettingsForm::onUseTranslationUpdated()
{
Settings::getInstance().setUseTranslations(useTranslations.isChecked());
}