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-06-25 04:11:11 +08:00
|
|
|
#include <QFont>
|
2014-07-05 00:49:19 +08:00
|
|
|
#include <QClipboard>
|
|
|
|
#include <QApplication>
|
2014-06-25 04:11:11 +08:00
|
|
|
|
|
|
|
SettingsForm::SettingsForm()
|
|
|
|
: QObject()
|
|
|
|
{
|
|
|
|
main = new QWidget(), head = new QWidget();
|
2014-07-17 06:43:30 +08:00
|
|
|
hboxcont1 = new QWidget(), hboxcont2 = new QWidget();
|
2014-06-25 04:11:11 +08:00
|
|
|
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-17 06:43:30 +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-07-17 06:43:30 +08:00
|
|
|
|
|
|
|
profilesLabel.setText(tr("Available profiles:", "Labels the profile selection box"));
|
|
|
|
populateProfiles();
|
|
|
|
loadConf.setText(tr("Load profile", "button to load selected profile"));
|
|
|
|
exportConf.setText(tr("Export profile", "button to save selected profile elsewhere"));
|
|
|
|
delConf.setText(tr("Delete profile", "button to delete selected profile from disk"));
|
|
|
|
delConf.setToolTip(tr("This is useful to remain safe on public computers", "describes the delete profile button"));
|
|
|
|
//delConf.setWhatsThis(tr("This is useful to remain safe on public computers", "describes the delete profile button"));
|
|
|
|
importConf.setText(tr("Import profile", "button to locate a profile"));
|
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-06-25 04:11:11 +08:00
|
|
|
main->setLayout(&layout);
|
2014-07-17 06:43:30 +08:00
|
|
|
//layout.addWidget(&nameLabel);
|
|
|
|
//layout.addWidget(&name);
|
|
|
|
//layout.addWidget(&statusTextLabel);
|
|
|
|
//layout.addWidget(&statusText);
|
2014-06-25 04:11:11 +08:00
|
|
|
layout.addWidget(&idLabel);
|
|
|
|
layout.addWidget(&id);
|
2014-07-17 06:43:30 +08:00
|
|
|
cbox.addWidget(&profilesLabel);
|
|
|
|
cbox.addWidget(&profiles);
|
|
|
|
hboxcont1->setLayout(&cbox);
|
|
|
|
layout.addWidget(hboxcont1);
|
|
|
|
buttons.addWidget(&loadConf);
|
|
|
|
buttons.addWidget(&exportConf);
|
|
|
|
buttons.addWidget(&delConf);
|
|
|
|
hboxcont2->setLayout(&buttons);
|
|
|
|
layout.addWidget(hboxcont2);
|
2014-07-17 06:46:51 +08:00
|
|
|
layout.addWidget(&importConf);
|
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-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-06-25 04:11:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SettingsForm::~SettingsForm()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-07-17 06:43:30 +08:00
|
|
|
void SettingsForm::populateProfiles()
|
|
|
|
{
|
|
|
|
QDir dir(Settings::getSettingsDirPath());
|
|
|
|
dir.setFilter(QDir::Files | QDir::NoDotAndDotDot);
|
|
|
|
dir.setNameFilters(QStringList("*.tox"));
|
|
|
|
for(QFileInfo file : dir.entryInfoList()) {
|
|
|
|
profiles.addItem(file.completeBaseName());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-25 04:11:11 +08:00
|
|
|
void SettingsForm::setFriendAddress(const QString& friendAddress)
|
|
|
|
{
|
|
|
|
id.setText(friendAddress);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsForm::show(Ui::Widget &ui)
|
|
|
|
{
|
2014-07-17 06:43:30 +08:00
|
|
|
//name.setText(ui.nameLabel->text());
|
|
|
|
//statusText.setText(ui.statusLabel->text());
|
2014-06-25 04:11:11 +08:00
|
|
|
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());
|
|
|
|
}
|