diff --git a/qtox.pro b/qtox.pro index ce7762e79..7399e260f 100644 --- a/qtox.pro +++ b/qtox.pro @@ -80,6 +80,11 @@ HEADERS += widget/form/addfriendform.h \ widget/form/chatform.h \ widget/form/groupchatform.h \ widget/form/settingswidget.h \ + widget/form/settings/genericsettings.h \ + widget/form/settings/generalform.h \ + widget/form/settings/identityform.h \ + widget/form/settings/privacyform.h \ + widget/form/settings/avform.h \ widget/form/filesform.h \ widget/tool/chattextedit.h \ widget/tool/friendrequestdialog.h \ @@ -117,6 +122,10 @@ SOURCES += \ widget/form/chatform.cpp \ widget/form/groupchatform.cpp \ widget/form/settingswidget.cpp \ + widget/form/settings/generalform.cpp \ + widget/form/settings/identityform.cpp \ + widget/form/settings/privacyform.cpp \ + widget/form/settings/avform.cpp \ widget/form/filesform.cpp \ widget/tool/chattextedit.cpp \ widget/tool/friendrequestdialog.cpp \ diff --git a/widget/form/settings/avform.cpp b/widget/form/settings/avform.cpp new file mode 100644 index 000000000..347a1cfbb --- /dev/null +++ b/widget/form/settings/avform.cpp @@ -0,0 +1,26 @@ +/* + Copyright (C) 2014 by Project Tox + + 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 "avform.h" + +AVForm::AVForm() +{ + prep(); +} + +AVForm::~AVForm() +{ +} diff --git a/widget/form/settings/avform.h b/widget/form/settings/avform.h new file mode 100644 index 000000000..e214e133e --- /dev/null +++ b/widget/form/settings/avform.h @@ -0,0 +1,33 @@ +/* + Copyright (C) 2014 by Project Tox + + 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 AVFORM_H +#define AVFORM_H + +#include "genericsettings.h" + +class AVForm : public GenericForm +{ + Q_OBJECT +public: + AVForm(); + ~AVForm(); + +private: + +}; + +#endif diff --git a/widget/form/settings/generalform.cpp b/widget/form/settings/generalform.cpp new file mode 100644 index 000000000..050d4f7eb --- /dev/null +++ b/widget/form/settings/generalform.cpp @@ -0,0 +1,46 @@ +/* + Copyright (C) 2014 by Project Tox + + 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 "generalform.h" +#include "widget/form/settingswidget.h" + +GeneralForm::GeneralForm() +{ + prep(); + group = new QGroupBox(tr("General Settings")); + enableIPv6 = new QCheckBox(); + enableIPv6->setText(tr("Enable IPv6 (recommended)","Text on a checkbox to enable IPv6")); + useTranslations = new QCheckBox(); + useTranslations->setText(tr("Use translations","Text on a checkbox to enable translations")); + makeToxPortable = new QCheckBox(); + makeToxPortable->setText(tr("Make Tox portable","Text on a checkbox to make qTox a portable application")); + makeToxPortable->setToolTip(tr("Save settings to the working directory instead of the usual conf dir","describes makeToxPortable checkbox")); + + QVBoxLayout *vLayout = new QVBoxLayout(); + vLayout->addWidget(enableIPv6); + vLayout->addWidget(useTranslations); + vLayout->addWidget(makeToxPortable); + group->setLayout(vLayout); + + label.setText(tr("General Settings")); + + headLayout.addWidget(&label); + layout.addWidget(group); +} + +GeneralForm::~GeneralForm() +{ +} diff --git a/widget/form/settings/generalform.h b/widget/form/settings/generalform.h new file mode 100644 index 000000000..c484a436d --- /dev/null +++ b/widget/form/settings/generalform.h @@ -0,0 +1,41 @@ +/* + Copyright (C) 2014 by Project Tox + + 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 GENERALFORM_H +#define GENERALFORM_H + +#include "genericsettings.h" +#include +#include +#include + + +class GeneralForm : public GenericForm +{ + Q_OBJECT +public: + GeneralForm(); + ~GeneralForm(); + +private: + QGroupBox *group; + QCheckBox* enableIPv6; + QCheckBox* useTranslations; + QCheckBox* makeToxPortable; + QLabel label; +}; + +#endif diff --git a/widget/form/settings/genericsettings.h b/widget/form/settings/genericsettings.h new file mode 100644 index 000000000..9353d21df --- /dev/null +++ b/widget/form/settings/genericsettings.h @@ -0,0 +1,46 @@ +/* + Copyright (C) 2014 by Project Tox + + 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 GENERICFORM_H +#define GENERICFORM_H + +#include +#include +#include "widget/form/settingswidget.h" + +class GenericForm : public QObject +{ + Q_OBJECT +public: + virtual void show(SettingsWidget& sw) + { + sw.body->layout()->addWidget(&body); + body.show(); + sw.head->layout()->addWidget(&head); + head.show(); + } + +protected: + QVBoxLayout layout, headLayout; + QWidget head, body; + void prep() // call in subclass constructor + { + head.setLayout(&headLayout); + body.setLayout(&layout); + } +}; + +#endif diff --git a/widget/form/settings/identityform.cpp b/widget/form/settings/identityform.cpp new file mode 100644 index 000000000..dbd5574c5 --- /dev/null +++ b/widget/form/settings/identityform.cpp @@ -0,0 +1,38 @@ +/* + Copyright (C) 2014 by Project Tox + + 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 "identityform.h" +#include "widget/form/settingswidget.h" +#include +#include + +IdentityForm::IdentityForm() +{ + prep(); + toxGroup = new QGroupBox(tr("Tox ID")); + QLabel* toxIdLabel = new QLabel(tr("Your Tox ID")); + QLineEdit* toxID = new QLineEdit(); + toxID->setReadOnly(true); + QVBoxLayout* toxLayout = new QVBoxLayout(); + toxLayout->addWidget(toxIdLabel); + toxLayout->addWidget(toxID); + toxGroup->setLayout(toxLayout); + layout.addWidget(toxGroup); +} + +IdentityForm::~IdentityForm() +{ +} diff --git a/widget/form/settings/identityform.h b/widget/form/settings/identityform.h new file mode 100644 index 000000000..dc616d75e --- /dev/null +++ b/widget/form/settings/identityform.h @@ -0,0 +1,34 @@ +/* + Copyright (C) 2014 by Project Tox + + 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 IDENTITYFORM_H +#define IDENTITYFORM_H + +#include "genericsettings.h" +#include + +class IdentityForm : public GenericForm +{ + Q_OBJECT +public: + IdentityForm(); + ~IdentityForm(); + +private: + QGroupBox* toxGroup; +}; + +#endif diff --git a/widget/form/settings/privacyform.cpp b/widget/form/settings/privacyform.cpp new file mode 100644 index 000000000..856f64954 --- /dev/null +++ b/widget/form/settings/privacyform.cpp @@ -0,0 +1,27 @@ +/* + Copyright (C) 2014 by Project Tox + + 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 "privacyform.h" +#include "widget/form/settingswidget.h" + +PrivacyForm::PrivacyForm() +{ + prep(); +} + +PrivacyForm::~PrivacyForm() +{ +} diff --git a/widget/form/settings/privacyform.h b/widget/form/settings/privacyform.h new file mode 100644 index 000000000..ae1e61956 --- /dev/null +++ b/widget/form/settings/privacyform.h @@ -0,0 +1,33 @@ +/* + Copyright (C) 2014 by Project Tox + + 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 PRIVACYFORM_H +#define PRIVACYFORM_H + +#include "genericsettings.h" + +class PrivacyForm : public GenericForm +{ + Q_OBJECT +public: + PrivacyForm(); + ~PrivacyForm(); + +private: + +}; + +#endif diff --git a/widget/form/settingswidget.cpp b/widget/form/settingswidget.cpp index fcbd2a981..3a13c1cdb 100644 --- a/widget/form/settingswidget.cpp +++ b/widget/form/settingswidget.cpp @@ -17,21 +17,41 @@ #include "settingswidget.h" #include "widget/widget.h" #include "ui_mainwindow.h" +#include "widget/form/settings/generalform.h" +#include "widget/form/settings/identityform.h" +#include "widget/form/settings/privacyform.h" +#include "widget/form/settings/avform.h" SettingsWidget::SettingsWidget() : QWidget() { - _main = new QWidget(); + generalForm = new GeneralForm(); + identityForm = new IdentityForm(); + privacyForm = new PrivacyForm(); + avForm = new AVForm(); + 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(_main); - _mainLayout->addWidget(main); - _mainLayout->addWidget(foot); + mainLayout = new QVBoxLayout(main); + mainLayout->addWidget(body); + mainLayout->addWidget(foot); // something something foot size - _main->setLayout(_mainLayout); + 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; } SettingsWidget::~SettingsWidget() @@ -40,12 +60,50 @@ SettingsWidget::~SettingsWidget() void SettingsWidget::show(Ui::MainWindow& ui) { - ui.mainContent->layout()->addWidget(_main); + active->show(*this); + ui.mainContent->layout()->addWidget(main); ui.mainHead->layout()->addWidget(head); - _main->show(); + main->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 diff --git a/widget/form/settingswidget.h b/widget/form/settingswidget.h index c901ce906..6ee45f90d 100644 --- a/widget/form/settingswidget.h +++ b/widget/form/settingswidget.h @@ -19,11 +19,12 @@ #include #include -#include -#include "widget/croppinglabel.h" - -namespace Ui {class MainWindow;} -class QString; +class GenericForm; +class GeneralForm; +class IdentityForm; +class PrivacyForm; +class AVForm; +namespace Ui {class MainWindow;}; class SettingsWidget : public QWidget { @@ -33,30 +34,38 @@ public: ~SettingsWidget(); void show(Ui::MainWindow &ui); + + QWidget *head, *body; // keep the others private public slots: //void setFriendAddress(const QString& friendAddress); private slots: + void onGeneralClicked(); + void onIdentityClicked(); + void onPrivacyClicked(); + void onAVClicked(); private: - QWidget *_main, *main, *head, *foot; - // _main consists of main+foot - QVBoxLayout *_mainLayout; + QWidget *main, *foot; + // main consists of body+foot for Ui::MainWindow + QVBoxLayout *mainLayout; + + GenericForm* active; + GeneralForm* generalForm; + IdentityForm* identityForm; + PrivacyForm* privacyForm; + AVForm* avForm; + 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; - - // now the actual pages and stuff - // ... - - - void prepButtons(); // just so I can move the crap to the bottom of the file -public: }; -#endif // SETTINGSFORM_H +#endif // SETTINGSWIDGET_H