2014-07-07 00:19:45 +08:00
|
|
|
/*
|
|
|
|
Copyright (C) 2014 by Project Tox <https://tox.im>
|
|
|
|
|
|
|
|
This file is part of qTox, a Qt-based graphical interface for Tox.
|
|
|
|
|
|
|
|
This program is libre software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the COPYING file for more details.
|
|
|
|
*/
|
|
|
|
|
2014-06-25 04:11:11 +08:00
|
|
|
#include "settingsform.h"
|
2014-06-30 05:41:47 +08:00
|
|
|
#include "widget/widget.h"
|
2014-07-02 06:47:06 +08:00
|
|
|
#include "settings.h"
|
2014-07-30 15:18:41 +08:00
|
|
|
#include "smileypack.h"
|
2014-06-25 04:11:11 +08:00
|
|
|
#include <QFont>
|
2014-07-05 00:49:19 +08:00
|
|
|
#include <QClipboard>
|
|
|
|
#include <QApplication>
|
2014-07-25 20:52:14 +08:00
|
|
|
#include <QFileDialog>
|
|
|
|
#include <QDir>
|
2014-06-25 04:11:11 +08:00
|
|
|
|
|
|
|
SettingsForm::SettingsForm()
|
|
|
|
: QObject()
|
|
|
|
{
|
|
|
|
main = new QWidget(), head = new QWidget();
|
|
|
|
QFont bold, small;
|
|
|
|
bold.setBold(true);
|
2014-07-05 00:49:19 +08:00
|
|
|
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);
|
2014-07-05 00:49:19 +08:00
|
|
|
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-07-13 04:58:58 +08:00
|
|
|
makeToxPortable.setText(tr("Make Tox portable","Text on a checkbox to make qTox a portable application"));
|
|
|
|
makeToxPortable.setChecked(Settings::getInstance().getMakeToxPortable());
|
2014-06-29 04:11:42 +08:00
|
|
|
|
2014-07-25 20:52:14 +08:00
|
|
|
smileyPackLabel.setText(tr("Smiley Pack", "Text on smiley pack label"));
|
2014-07-31 23:36:55 +08:00
|
|
|
for (auto entry : SmileyPack::listSmileyPacks("./smileys"))
|
|
|
|
smileyPackBrowser.addItem(entry.first, entry.second);
|
|
|
|
smileyPackBrowser.setCurrentIndex(smileyPackBrowser.findData(Settings::getInstance().getSmileyPack()));
|
2014-07-25 20:52:14 +08:00
|
|
|
|
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);
|
2014-06-29 04:11:42 +08:00
|
|
|
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-07-13 04:58:58 +08:00
|
|
|
layout.addWidget(&makeToxPortable);
|
2014-07-25 20:52:14 +08:00
|
|
|
layout.addWidget(&smileyPackLabel);
|
2014-07-30 15:18:41 +08:00
|
|
|
layout.addWidget(&smileyPackBrowser);
|
2014-06-25 04:11:11 +08:00
|
|
|
layout.addStretch();
|
|
|
|
|
|
|
|
head->setLayout(&headLayout);
|
|
|
|
headLayout.addWidget(&headLabel);
|
2014-06-29 04:11:42 +08:00
|
|
|
|
|
|
|
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()));
|
2014-07-13 04:58:58 +08:00
|
|
|
connect(&makeToxPortable, SIGNAL(stateChanged(int)), this, SLOT(onMakeToxPortableUpdated()));
|
2014-07-05 00:49:19 +08:00
|
|
|
connect(&idLabel, SIGNAL(clicked()), this, SLOT(copyIdClicked()));
|
2014-07-31 23:36:55 +08:00
|
|
|
connect(&smileyPackBrowser, SIGNAL(currentIndexChanged(int)), this, SLOT(onSmileyBrowserIndexChanged(int)));
|
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();
|
|
|
|
}
|
2014-06-29 04:11:42 +08:00
|
|
|
|
|
|
|
void SettingsForm::onTestVideoClicked()
|
|
|
|
{
|
2014-06-30 05:41:47 +08:00
|
|
|
Widget::getInstance()->showTestCamview();
|
2014-06-29 04:11:42 +08:00
|
|
|
}
|
2014-07-02 06:47:06 +08:00
|
|
|
|
|
|
|
void SettingsForm::onEnableIPv6Updated()
|
|
|
|
{
|
|
|
|
Settings::getInstance().setEnableIPv6(enableIPv6.isChecked());
|
|
|
|
}
|
2014-07-05 00:49:19 +08:00
|
|
|
|
|
|
|
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());
|
|
|
|
}
|
2014-07-13 04:58:58 +08:00
|
|
|
|
|
|
|
void SettingsForm::onMakeToxPortableUpdated()
|
|
|
|
{
|
|
|
|
Settings::getInstance().setMakeToxPortable(makeToxPortable.isChecked());
|
|
|
|
}
|
2014-07-25 20:52:14 +08:00
|
|
|
|
2014-07-31 23:36:55 +08:00
|
|
|
void SettingsForm::onSmileyBrowserIndexChanged(int index)
|
2014-07-25 20:52:14 +08:00
|
|
|
{
|
2014-07-31 23:36:55 +08:00
|
|
|
QString filename = smileyPackBrowser.itemData(index).toString();
|
2014-07-30 15:18:41 +08:00
|
|
|
Settings::getInstance().setSmileyPack(filename);
|
2014-07-25 20:52:14 +08:00
|
|
|
}
|