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

removed settingsform, removed selfcamview from widget

This commit is contained in:
Marcel 2014-09-12 15:32:15 +02:00
parent 04657d2c1d
commit c3a8cd01f3
5 changed files with 1 additions and 252 deletions

View File

@ -79,7 +79,6 @@ win32 {
HEADERS += widget/form/addfriendform.h \
widget/form/chatform.h \
widget/form/groupchatform.h \
widget/form/settingsform.h \
widget/form/filesform.h \
widget/tool/chattextedit.h \
widget/tool/friendrequestdialog.h \
@ -116,7 +115,6 @@ SOURCES += \
widget/form/addfriendform.cpp \
widget/form/chatform.cpp \
widget/form/groupchatform.cpp \
widget/form/settingsform.cpp \
widget/form/filesform.cpp \
widget/tool/chattextedit.cpp \
widget/tool/friendrequestdialog.cpp \

View File

@ -1,142 +0,0 @@
/*
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.
*/
#include "settingsform.h"
#include "widget/widget.h"
#include "settings.h"
#include "smileypack.h"
#include "ui_mainwindow.h"
#include <QFont>
#include <QClipboard>
#include <QApplication>
#include <QFileDialog>
#include <QDir>
SettingsForm::SettingsForm()
: QObject()
{
main = new QWidget(), head = new QWidget();
QFont bold, small;
bold.setBold(true);
small.setPixelSize(13);
small.setKerning(false);
headLabel.setText(tr("User Settings","\"Headline\" of the window"));
headLabel.setFont(bold);
nameLabel.setText(tr("Name","Username/nick"));
statusTextLabel.setText(tr("Status","Status message"));
idLabel.setText("Tox ID " + tr("(click here to copy)", "Click on this text to copy TID to clipboard"));
id.setFont(small);
id.setTextInteractionFlags(Qt::TextSelectableByMouse);
id.setReadOnly(true);
id.setFrameStyle(QFrame::NoFrame);
id.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
id.setFixedHeight(id.document()->size().height()*2);
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"));
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"));
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()));
main->setLayout(&layout);
layout.addWidget(&nameLabel);
layout.addWidget(&name);
layout.addWidget(&statusTextLabel);
layout.addWidget(&statusText);
layout.addWidget(&idLabel);
layout.addWidget(&id);
layout.addWidget(&videoTest);
layout.addWidget(&enableIPv6);
layout.addWidget(&useTranslations);
layout.addWidget(&makeToxPortable);
layout.addWidget(&smileyPackLabel);
layout.addWidget(&smileyPackBrowser);
layout.addStretch();
head->setLayout(&headLayout);
headLayout.addWidget(&headLabel);
connect(&videoTest, SIGNAL(clicked()), this, SLOT(onTestVideoClicked()));
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(&idLabel, SIGNAL(clicked()), this, SLOT(copyIdClicked()));
connect(&smileyPackBrowser, SIGNAL(currentIndexChanged(int)), this, SLOT(onSmileyBrowserIndexChanged(int)));
}
SettingsForm::~SettingsForm()
{
}
void SettingsForm::setFriendAddress(const QString& friendAddress)
{
QString txt{friendAddress};
txt.insert(38,'\n');
id.setText(txt);
}
void SettingsForm::show(Ui::MainWindow &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();
}
void SettingsForm::onEnableIPv6Updated()
{
Settings::getInstance().setEnableIPv6(enableIPv6.isChecked());
}
void SettingsForm::copyIdClicked()
{
id.selectAll();
QString txt = id.toPlainText();
txt.replace('\n',"");
QApplication::clipboard()->setText(txt);
}
void SettingsForm::onUseTranslationUpdated()
{
Settings::getInstance().setUseTranslations(useTranslations.isChecked());
}
void SettingsForm::onMakeToxPortableUpdated()
{
Settings::getInstance().setMakeToxPortable(makeToxPortable.isChecked());
}
void SettingsForm::onSmileyBrowserIndexChanged(int index)
{
QString filename = smileyPackBrowser.itemData(index).toString();
Settings::getInstance().setSmileyPack(filename);
}

View File

@ -1,67 +0,0 @@
/*
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.
*/
#ifndef SETTINGSFORM_H
#define SETTINGSFORM_H
#include <QVBoxLayout>
#include <QLabel>
#include <QLineEdit>
#include <QObject>
#include <QCheckBox>
#include <QPushButton>
#include <QTextEdit>
#include <QComboBox>
#include "widget/croppinglabel.h"
namespace Ui {class MainWindow;}
class QString;
class SettingsForm : public QObject
{
Q_OBJECT
public:
SettingsForm();
~SettingsForm();
void show(Ui::MainWindow &ui);
public slots:
void setFriendAddress(const QString& friendAddress);
private slots:
void onTestVideoClicked();
void onEnableIPv6Updated();
void onUseTranslationUpdated();
void onMakeToxPortableUpdated();
void onSmileyBrowserIndexChanged(int index);
void copyIdClicked();
private:
QLabel headLabel, nameLabel, statusTextLabel, smileyPackLabel;
QTextEdit id;
CroppingLabel idLabel;
QPushButton videoTest;
QCheckBox enableIPv6, useTranslations, makeToxPortable;
QVBoxLayout layout, headLayout;
QWidget *main, *head;
QComboBox smileyPackBrowser;
public:
QLineEdit name, statusText;
};
#endif // SETTINGSFORM_H

View File

@ -155,7 +155,6 @@ Widget::Widget(QWidget *parent)
ui->statusButton->style()->polish(ui->statusButton);
camera = new Camera;
camview = new SelfCamView(camera);
// Disable some widgets until we're connected to the DHT
ui->statusButton->setEnabled(false);
@ -179,7 +178,6 @@ Widget::Widget(QWidget *parent)
connect(core, &Core::statusSet, this, &Widget::onStatusSet);
connect(core, &Core::usernameSet, this, &Widget::setUsername);
connect(core, &Core::statusMessageSet, this, &Widget::setStatusMessage);
connect(core, &Core::friendAddressGenerated, &settingsForm, &SettingsForm::setFriendAddress);
connect(core, SIGNAL(fileDownloadFinished(const QString&)), &filesForm, SLOT(onFileDownloadComplete(const QString&)));
connect(core, SIGNAL(fileUploadFinished(const QString&)), &filesForm, SLOT(onFileUploadComplete(const QString&)));
connect(core, &Core::friendAdded, this, &Widget::addFriend);
@ -210,8 +208,6 @@ Widget::Widget(QWidget *parent)
connect(setStatusOnline, SIGNAL(triggered()), this, SLOT(setStatusOnline()));
connect(setStatusAway, SIGNAL(triggered()), this, SLOT(setStatusAway()));
connect(setStatusBusy, SIGNAL(triggered()), this, SLOT(setStatusBusy()));
connect(&settingsForm.name, SIGNAL(editingFinished()), this, SLOT(onUsernameChanged()));
connect(&settingsForm.statusText, SIGNAL(editingFinished()), this, SLOT(onStatusMessageChanged()));
connect(&friendForm, SIGNAL(friendRequested(QString,QString)), this, SIGNAL(friendRequested(QString,QString)));
coreThread->start();
@ -228,7 +224,6 @@ Widget::~Widget()
if (!coreThread->isFinished())
coreThread->terminate();
delete core;
delete camview;
hideMainForms();
@ -338,9 +333,7 @@ void Widget::onTransferClicked()
void Widget::onSettingsClicked()
{
hideMainForms();
settingsForm.show(*ui);
activeChatroomWidget = nullptr;
}
void Widget::hideMainForms()
@ -357,20 +350,10 @@ void Widget::hideMainForms()
}
}
void Widget::onUsernameChanged()
{
const QString newUsername = settingsForm.name.text();
ui->nameLabel->setText(newUsername);
ui->nameLabel->setToolTip(newUsername); // for overlength names
settingsForm.name.setText(newUsername);
core->setUsername(newUsername);
}
void Widget::onUsernameChanged(const QString& newUsername, const QString& oldUsername)
{
ui->nameLabel->setText(oldUsername); // restore old username until Core tells us to set it
ui->nameLabel->setToolTip(oldUsername); // for overlength names
settingsForm.name.setText(oldUsername);
core->setUsername(newUsername);
}
@ -378,23 +361,12 @@ void Widget::setUsername(const QString& username)
{
ui->nameLabel->setText(username);
ui->nameLabel->setToolTip(username); // for overlength names
settingsForm.name.setText(username);
}
void Widget::onStatusMessageChanged()
{
const QString newStatusMessage = settingsForm.statusText.text();
ui->statusLabel->setText(newStatusMessage);
ui->statusLabel->setToolTip(newStatusMessage); // for overlength messsages
settingsForm.statusText.setText(newStatusMessage);
core->setStatusMessage(newStatusMessage);
}
void Widget::onStatusMessageChanged(const QString& newStatusMessage, const QString& oldStatusMessage)
{
ui->statusLabel->setText(oldStatusMessage); // restore old status message until Core tells us to set it
ui->statusLabel->setToolTip(oldStatusMessage); // for overlength messsages
settingsForm.statusText.setText(oldStatusMessage);
core->setStatusMessage(newStatusMessage);
}
@ -402,7 +374,6 @@ void Widget::setStatusMessage(const QString &statusMessage)
{
ui->statusLabel->setText(statusMessage);
ui->statusLabel->setToolTip(statusMessage); // for overlength messsages
settingsForm.statusText.setText(statusMessage);
}
void Widget::addFriend(int friendId, const QString &userId)
@ -677,11 +648,6 @@ Group *Widget::createGroup(int groupId)
return newgroup;
}
void Widget::showTestCamview()
{
camview->show();
}
void Widget::onEmptyGroupCreated(int groupId)
{
createGroup(groupId);

View File

@ -19,7 +19,6 @@
#include <QMainWindow>
#include "widget/form/addfriendform.h"
#include "widget/form/settingsform.h"
#include "widget/form/filesform.h"
#include "corestructs.h"
@ -54,7 +53,6 @@ public:
QThread* getCoreThread();
Camera* getCamera();
static Widget* getInstance();
void showTestCamview();
void newMessageAlert();
bool isFriendWidgetCurActiveWidget(Friend* f);
bool getIsWindowMinimized();
@ -83,8 +81,6 @@ private slots:
void onFailedToStartCore();
void onUsernameChanged(const QString& newUsername, const QString& oldUsername);
void onStatusMessageChanged(const QString& newStatusMessage, const QString& oldStatusMessage);
void onUsernameChanged();
void onStatusMessageChanged();
void setUsername(const QString& username);
void setStatusMessage(const QString &statusMessage);
void addFriend(int friendId, const QString& userId);
@ -137,12 +133,10 @@ private:
Core* core;
QThread* coreThread;
AddFriendForm friendForm;
SettingsForm settingsForm;
FilesForm filesForm;
static Widget* instance;
GenericChatroomWidget* activeChatroomWidget;
FriendListWidget* contactListWidget;
SelfCamView* camview;
Camera* camera;
bool notify(QObject *receiver, QEvent *event);
bool eventFilter(QObject *, QEvent *event);