From 4c89233656ef46a30858d80ba6c93b06a20f4369 Mon Sep 17 00:00:00 2001 From: dubslow Date: Sat, 13 Sep 2014 00:55:21 -0500 Subject: [PATCH 01/22] first thing's first, gotta placate the ocd --- mainwindow.ui | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mainwindow.ui b/mainwindow.ui index 7f9cd12c5..20e8269cf 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -3124,13 +3124,13 @@ QSplitter:handle{ 0 - 60 + 57 16777215 - 60 + 57 From 55437df210aaad12710bfe60e81731b0c158be7f Mon Sep 17 00:00:00 2001 From: dubslow Date: Sat, 13 Sep 2014 03:32:24 -0500 Subject: [PATCH 02/22] initial new settings widget, subforms not started also "filing" some files under misc --- core.cpp | 6 +- main.cpp | 2 +- cdata.cpp => misc/cdata.cpp | 0 cdata.h => misc/cdata.h | 0 cstring.cpp => misc/cstring.cpp | 0 cstring.h => misc/cstring.h | 0 settings.cpp => misc/settings.cpp | 0 settings.h => misc/settings.h | 0 smileypack.cpp => misc/smileypack.cpp | 0 smileypack.h => misc/smileypack.h | 0 style.cpp => misc/style.cpp | 0 style.h => misc/style.h | 0 qtox.pro | 24 +-- widget/emoticonswidget.cpp | 4 +- widget/form/genericchatform.cpp | 6 +- widget/form/settingsform.cpp | 142 --------------- widget/form/settingswidget.cpp | 164 ++++++++++++++++++ .../form/{settingsform.h => settingswidget.h} | 35 ++-- widget/groupwidget.cpp | 2 +- widget/tool/chataction.cpp | 2 +- widget/widget.cpp | 32 +--- widget/widget.h | 6 +- 22 files changed, 208 insertions(+), 217 deletions(-) rename cdata.cpp => misc/cdata.cpp (100%) rename cdata.h => misc/cdata.h (100%) rename cstring.cpp => misc/cstring.cpp (100%) rename cstring.h => misc/cstring.h (100%) rename settings.cpp => misc/settings.cpp (100%) rename settings.h => misc/settings.h (100%) rename smileypack.cpp => misc/smileypack.cpp (100%) rename smileypack.h => misc/smileypack.h (100%) rename style.cpp => misc/style.cpp (100%) rename style.h => misc/style.h (100%) delete mode 100644 widget/form/settingsform.cpp create mode 100644 widget/form/settingswidget.cpp rename widget/form/{settingsform.h => settingswidget.h} (60%) diff --git a/core.cpp b/core.cpp index 876301a63..4b081000a 100644 --- a/core.cpp +++ b/core.cpp @@ -15,9 +15,9 @@ */ #include "core.h" -#include "cdata.h" -#include "cstring.h" -#include "settings.h" +#include "misc/cdata.h" +#include "misc/cstring.h" +#include "misc/settings.h" #include "widget/widget.h" #include diff --git a/main.cpp b/main.cpp index 1cdac827e..8e981baa5 100644 --- a/main.cpp +++ b/main.cpp @@ -15,7 +15,7 @@ */ #include "widget/widget.h" -#include "settings.h" +#include "misc/settings.h" #include #include #include diff --git a/cdata.cpp b/misc/cdata.cpp similarity index 100% rename from cdata.cpp rename to misc/cdata.cpp diff --git a/cdata.h b/misc/cdata.h similarity index 100% rename from cdata.h rename to misc/cdata.h diff --git a/cstring.cpp b/misc/cstring.cpp similarity index 100% rename from cstring.cpp rename to misc/cstring.cpp diff --git a/cstring.h b/misc/cstring.h similarity index 100% rename from cstring.h rename to misc/cstring.h diff --git a/settings.cpp b/misc/settings.cpp similarity index 100% rename from settings.cpp rename to misc/settings.cpp diff --git a/settings.h b/misc/settings.h similarity index 100% rename from settings.h rename to misc/settings.h diff --git a/smileypack.cpp b/misc/smileypack.cpp similarity index 100% rename from smileypack.cpp rename to misc/smileypack.cpp diff --git a/smileypack.h b/misc/smileypack.h similarity index 100% rename from smileypack.h rename to misc/smileypack.h diff --git a/style.cpp b/misc/style.cpp similarity index 100% rename from style.cpp rename to misc/style.cpp diff --git a/style.h b/misc/style.h similarity index 100% rename from style.h rename to misc/style.h diff --git a/qtox.pro b/qtox.pro index 7b52d779c..ce7762e79 100644 --- a/qtox.pro +++ b/qtox.pro @@ -79,7 +79,7 @@ win32 { HEADERS += widget/form/addfriendform.h \ widget/form/chatform.h \ widget/form/groupchatform.h \ - widget/form/settingsform.h \ + widget/form/settingswidget.h \ widget/form/filesform.h \ widget/tool/chattextedit.h \ widget/tool/friendrequestdialog.h \ @@ -89,17 +89,17 @@ HEADERS += widget/form/addfriendform.h \ friend.h \ group.h \ grouplist.h \ - settings.h \ + misc/settings.h \ core.h \ friendlist.h \ - cdata.h \ - cstring.h \ + misc/cdata.h \ + misc/cstring.h \ widget/selfcamview.h \ widget/camera.h \ widget/netcamview.h \ - smileypack.h \ + misc/smileypack.h \ widget/emoticonswidget.h \ - style.h \ + misc/style.h \ widget/adjustingscrollarea.h \ widget/croppinglabel.h \ widget/friendlistwidget.h \ @@ -116,7 +116,7 @@ SOURCES += \ widget/form/addfriendform.cpp \ widget/form/chatform.cpp \ widget/form/groupchatform.cpp \ - widget/form/settingsform.cpp \ + widget/form/settingswidget.cpp \ widget/form/filesform.cpp \ widget/tool/chattextedit.cpp \ widget/tool/friendrequestdialog.cpp \ @@ -129,15 +129,15 @@ SOURCES += \ group.cpp \ grouplist.cpp \ main.cpp \ - settings.cpp \ - cdata.cpp \ - cstring.cpp \ + misc/settings.cpp \ + misc/cdata.cpp \ + misc/cstring.cpp \ widget/selfcamview.cpp \ widget/camera.cpp \ widget/netcamview.cpp \ - smileypack.cpp \ + misc/smileypack.cpp \ widget/emoticonswidget.cpp \ - style.cpp \ + misc/style.cpp \ widget/adjustingscrollarea.cpp \ widget/croppinglabel.cpp \ widget/friendlistwidget.cpp \ diff --git a/widget/emoticonswidget.cpp b/widget/emoticonswidget.cpp index bab7abe8d..b0ffb6028 100644 --- a/widget/emoticonswidget.cpp +++ b/widget/emoticonswidget.cpp @@ -15,8 +15,8 @@ */ #include "emoticonswidget.h" -#include "smileypack.h" -#include "style.h" +#include "misc/smileypack.h" +#include "misc/style.h" #include #include diff --git a/widget/form/genericchatform.cpp b/widget/form/genericchatform.cpp index f5681f1c6..2aff5d2a7 100644 --- a/widget/form/genericchatform.cpp +++ b/widget/form/genericchatform.cpp @@ -17,11 +17,11 @@ #include "genericchatform.h" #include "ui_mainwindow.h" #include -#include "smileypack.h" +#include "misc/smileypack.h" #include "widget/emoticonswidget.h" -#include "style.h" +#include "misc/style.h" #include "widget/widget.h" -#include "settings.h" +#include "misc/settings.h" #include "widget/tool/chataction.h" #include "widget/chatareawidget.h" #include "widget/tool/chattextedit.h" diff --git a/widget/form/settingsform.cpp b/widget/form/settingsform.cpp deleted file mode 100644 index 3d4a213da..000000000 --- a/widget/form/settingsform.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/* - 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 "settingsform.h" -#include "widget/widget.h" -#include "settings.h" -#include "smileypack.h" -#include "ui_mainwindow.h" -#include -#include -#include -#include -#include - -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); -} diff --git a/widget/form/settingswidget.cpp b/widget/form/settingswidget.cpp new file mode 100644 index 000000000..6e2778de8 --- /dev/null +++ b/widget/form/settingswidget.cpp @@ -0,0 +1,164 @@ +/* + 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 "settingswidget.h" +#include "widget/widget.h" +#include "ui_mainwindow.h" + +SettingsWidget::SettingsWidget() + : QObject() +{ + main = new QWidget(); + // this crap is copied from ui_mainwindow.h... there's no easy way around + // just straight up copying it like this... oh well + // the layout/icons obviously need to be improved, but it's a working model, + // not a pretty one + QSizePolicy sizePolicy3(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); + sizePolicy3.setHorizontalStretch(0); + sizePolicy3.setVerticalStretch(0); + head = new QWidget(); + head->setObjectName(QStringLiteral("head")); + head->setEnabled(true); + sizePolicy3.setHeightForWidth(head->sizePolicy().hasHeightForWidth()); + head->setSizePolicy(sizePolicy3); + QPalette palette5; + QBrush brush(QColor(255, 255, 255, 255)); + brush.setStyle(Qt::SolidPattern); + QBrush brush1(QColor(28, 28, 28, 255)); + brush1.setStyle(Qt::SolidPattern); + QBrush brush2(QColor(42, 42, 42, 255)); + brush2.setStyle(Qt::SolidPattern); + QBrush brush3(QColor(35, 35, 35, 255)); + brush3.setStyle(Qt::SolidPattern); + QBrush brush4(QColor(14, 14, 14, 255)); + brush4.setStyle(Qt::SolidPattern); + QBrush brush5(QColor(18, 18, 18, 255)); + brush5.setStyle(Qt::SolidPattern); + QBrush brush6(QColor(0, 0, 0, 255)); + brush6.setStyle(Qt::SolidPattern); + QBrush brush7(QColor(255, 255, 220, 255)); + brush7.setStyle(Qt::SolidPattern); + palette5.setBrush(QPalette::Active, QPalette::WindowText, brush); + palette5.setBrush(QPalette::Active, QPalette::Button, brush1); + palette5.setBrush(QPalette::Active, QPalette::Light, brush2); + palette5.setBrush(QPalette::Active, QPalette::Midlight, brush3); + palette5.setBrush(QPalette::Active, QPalette::Dark, brush4); + palette5.setBrush(QPalette::Active, QPalette::Mid, brush5); + palette5.setBrush(QPalette::Active, QPalette::Text, brush); + palette5.setBrush(QPalette::Active, QPalette::BrightText, brush); + palette5.setBrush(QPalette::Active, QPalette::ButtonText, brush); + palette5.setBrush(QPalette::Active, QPalette::Base, brush6); + palette5.setBrush(QPalette::Active, QPalette::Window, brush1); + palette5.setBrush(QPalette::Active, QPalette::Shadow, brush6); + palette5.setBrush(QPalette::Active, QPalette::AlternateBase, brush4); + palette5.setBrush(QPalette::Active, QPalette::ToolTipBase, brush7); + palette5.setBrush(QPalette::Active, QPalette::ToolTipText, brush6); + palette5.setBrush(QPalette::Inactive, QPalette::WindowText, brush); + palette5.setBrush(QPalette::Inactive, QPalette::Button, brush1); + palette5.setBrush(QPalette::Inactive, QPalette::Light, brush2); + palette5.setBrush(QPalette::Inactive, QPalette::Midlight, brush3); + palette5.setBrush(QPalette::Inactive, QPalette::Dark, brush4); + palette5.setBrush(QPalette::Inactive, QPalette::Mid, brush5); + palette5.setBrush(QPalette::Inactive, QPalette::Text, brush); + palette5.setBrush(QPalette::Inactive, QPalette::BrightText, brush); + palette5.setBrush(QPalette::Inactive, QPalette::ButtonText, brush); + palette5.setBrush(QPalette::Inactive, QPalette::Base, brush6); + palette5.setBrush(QPalette::Inactive, QPalette::Window, brush1); + palette5.setBrush(QPalette::Inactive, QPalette::Shadow, brush6); + palette5.setBrush(QPalette::Inactive, QPalette::AlternateBase, brush4); + palette5.setBrush(QPalette::Inactive, QPalette::ToolTipBase, brush7); + palette5.setBrush(QPalette::Inactive, QPalette::ToolTipText, brush6); + palette5.setBrush(QPalette::Disabled, QPalette::WindowText, brush4); + palette5.setBrush(QPalette::Disabled, QPalette::Button, brush1); + palette5.setBrush(QPalette::Disabled, QPalette::Light, brush2); + palette5.setBrush(QPalette::Disabled, QPalette::Midlight, brush3); + palette5.setBrush(QPalette::Disabled, QPalette::Dark, brush4); + palette5.setBrush(QPalette::Disabled, QPalette::Mid, brush5); + palette5.setBrush(QPalette::Disabled, QPalette::Text, brush4); + palette5.setBrush(QPalette::Disabled, QPalette::BrightText, brush); + palette5.setBrush(QPalette::Disabled, QPalette::ButtonText, brush4); + palette5.setBrush(QPalette::Disabled, QPalette::Base, brush1); + palette5.setBrush(QPalette::Disabled, QPalette::Window, brush1); + palette5.setBrush(QPalette::Disabled, QPalette::Shadow, brush6); + palette5.setBrush(QPalette::Disabled, QPalette::AlternateBase, brush1); + palette5.setBrush(QPalette::Disabled, QPalette::ToolTipBase, brush7); + palette5.setBrush(QPalette::Disabled, QPalette::ToolTipText, brush6); + head->setPalette(palette5); + head->setAutoFillBackground(true); + iconsLayout = new QHBoxLayout(head); + iconsLayout->setSpacing(0); + iconsLayout->setObjectName(QStringLiteral("iconsLayout")); + iconsLayout->setContentsMargins(0, 0, 0, 0); + + generalButton = new QPushButton(head); + generalButton->setObjectName(QStringLiteral("generalButton")); + generalButton->setMinimumSize(QSize(55, 35)); + generalButton->setMaximumSize(QSize(55, 35)); + generalButton->setFocusPolicy(Qt::NoFocus); + QIcon icon1; + icon1.addFile(QStringLiteral(":/img/add.png"), QSize(), QIcon::Normal, QIcon::Off); + generalButton->setIcon(icon1); + generalButton->setFlat(true); + iconsLayout->addWidget(generalButton); + + identityButton = new QPushButton(head); + identityButton->setObjectName(QStringLiteral("identityButton")); + identityButton->setMinimumSize(QSize(55, 35)); + identityButton->setMaximumSize(QSize(55, 35)); + identityButton->setFocusPolicy(Qt::NoFocus); + QIcon icon2; + icon2.addFile(QStringLiteral(":/img/group.png"), QSize(), QIcon::Normal, QIcon::Off); + identityButton->setIcon(icon2); + identityButton->setFlat(true); + iconsLayout->addWidget(identityButton); + + privacyButton = new QPushButton(head); + privacyButton->setObjectName(QStringLiteral("privacyButton")); + privacyButton->setMinimumSize(QSize(55, 35)); + privacyButton->setMaximumSize(QSize(55, 35)); + privacyButton->setFocusPolicy(Qt::NoFocus); + QIcon icon3; + icon3.addFile(QStringLiteral(":/img/transfer.png"), QSize(), QIcon::Normal, QIcon::Off); + privacyButton->setIcon(icon3); + privacyButton->setFlat(true); + iconsLayout->addWidget(privacyButton); + + avButton = new QPushButton(head); + avButton->setObjectName(QStringLiteral("avButton")); + avButton->setMinimumSize(QSize(55, 35)); + avButton->setMaximumSize(QSize(55, 35)); + avButton->setFocusPolicy(Qt::NoFocus); + QIcon icon4; + icon4.addFile(QStringLiteral(":/img/settings.png"), QSize(), QIcon::Normal, QIcon::Off); + avButton->setIcon(icon4); + avButton->setFlat(true); + iconsLayout->addWidget(avButton); + + head->setLayout(iconsLayout); + +} + +SettingsWidget::~SettingsWidget() +{ +} + +void SettingsWidget::show(Ui::MainWindow& ui) +{ + ui.mainContent->layout()->addWidget(main); + ui.mainHead->layout()->addWidget(head); + main->show(); + head->show(); +} diff --git a/widget/form/settingsform.h b/widget/form/settingswidget.h similarity index 60% rename from widget/form/settingsform.h rename to widget/form/settingswidget.h index a081d01fb..a1cee909f 100644 --- a/widget/form/settingsform.h +++ b/widget/form/settingswidget.h @@ -14,8 +14,8 @@ See the COPYING file for more details. */ -#ifndef SETTINGSFORM_H -#define SETTINGSFORM_H +#ifndef SETTINGSWIDGET_H +#define SETTINGSWIDGET_H #include #include @@ -31,37 +31,32 @@ namespace Ui {class MainWindow;} class QString; -class SettingsForm : public QObject +class SettingsWidget : public QObject { Q_OBJECT public: - SettingsForm(); - ~SettingsForm(); + SettingsWidget(); + ~SettingsWidget(); void show(Ui::MainWindow &ui); public slots: - void setFriendAddress(const QString& friendAddress); + //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; + // 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 + // ... public: - QLineEdit name, statusText; }; #endif // SETTINGSFORM_H diff --git a/widget/groupwidget.cpp b/widget/groupwidget.cpp index b8c1cbcc0..0c02db3d2 100644 --- a/widget/groupwidget.cpp +++ b/widget/groupwidget.cpp @@ -17,7 +17,7 @@ #include "groupwidget.h" #include "grouplist.h" #include "group.h" -#include "settings.h" +#include "misc/settings.h" #include "widget/form/groupchatform.h" #include #include diff --git a/widget/tool/chataction.cpp b/widget/tool/chataction.cpp index 0847abdda..dacde43ee 100644 --- a/widget/tool/chataction.cpp +++ b/widget/tool/chataction.cpp @@ -15,7 +15,7 @@ */ #include "chataction.h" -#include "smileypack.h" +#include "misc/smileypack.h" #include #include #include "filetransferinstance.h" diff --git a/widget/widget.cpp b/widget/widget.cpp index abe14460a..29aef03be 100644 --- a/widget/widget.cpp +++ b/widget/widget.cpp @@ -17,7 +17,7 @@ #include "widget.h" #include "ui_mainwindow.h" #include "core.h" -#include "settings.h" +#include "misc/settings.h" #include "friend.h" #include "friendlist.h" #include "widget/tool/friendrequestdialog.h" @@ -26,7 +26,7 @@ #include "group.h" #include "widget/groupwidget.h" #include "widget/form/groupchatform.h" -#include "style.h" +#include "misc/style.h" #include "selfcamview.h" #include "widget/friendlistwidget.h" #include "camera.h" @@ -179,7 +179,7 @@ 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, &Core::friendAddressGenerated, &settingsWidget, &SettingsWidget::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 +210,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(); @@ -339,7 +337,7 @@ void Widget::onTransferClicked() void Widget::onSettingsClicked() { hideMainForms(); - settingsForm.show(*ui); + settingsWidget.show(*ui); activeChatroomWidget = nullptr; } @@ -357,20 +355,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 +366,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 +379,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) diff --git a/widget/widget.h b/widget/widget.h index 1fbecb412..ec054863c 100644 --- a/widget/widget.h +++ b/widget/widget.h @@ -19,7 +19,7 @@ #include #include "widget/form/addfriendform.h" -#include "widget/form/settingsform.h" +#include "widget/form/settingswidget.h" #include "widget/form/filesform.h" #include "corestructs.h" @@ -83,8 +83,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,7 +135,7 @@ private: Core* core; QThread* coreThread; AddFriendForm friendForm; - SettingsForm settingsForm; + SettingsWidget settingsWidget; FilesForm filesForm; static Widget* instance; GenericChatroomWidget* activeChatroomWidget; From 741824c019604a919f958bf9443055b7c099c085 Mon Sep 17 00:00:00 2001 From: bill Date: Sun, 14 Sep 2014 13:42:27 -0500 Subject: [PATCH 03/22] move buttons to bottom --- widget/form/settingswidget.cpp | 66 +++++++++++++++++++--------------- widget/form/settingswidget.h | 20 +++++------ 2 files changed, 48 insertions(+), 38 deletions(-) diff --git a/widget/form/settingswidget.cpp b/widget/form/settingswidget.cpp index 6e2778de8..fcbd2a981 100644 --- a/widget/form/settingswidget.cpp +++ b/widget/form/settingswidget.cpp @@ -19,9 +19,35 @@ #include "ui_mainwindow.h" SettingsWidget::SettingsWidget() - : QObject() + : QWidget() { + _main = new QWidget(); main = new QWidget(); + head = new QWidget(); + foot = new QWidget(); + prepButtons(); + foot->setLayout(iconsLayout); + _mainLayout = new QVBoxLayout(_main); + _mainLayout->addWidget(main); + _mainLayout->addWidget(foot); + // something something foot size + _main->setLayout(_mainLayout); +} + +SettingsWidget::~SettingsWidget() +{ +} + +void SettingsWidget::show(Ui::MainWindow& ui) +{ + ui.mainContent->layout()->addWidget(_main); + ui.mainHead->layout()->addWidget(head); + _main->show(); + head->show(); +} + +void SettingsWidget::prepButtons() +{ // this crap is copied from ui_mainwindow.h... there's no easy way around // just straight up copying it like this... oh well // the layout/icons obviously need to be improved, but it's a working model, @@ -29,11 +55,9 @@ SettingsWidget::SettingsWidget() QSizePolicy sizePolicy3(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); sizePolicy3.setHorizontalStretch(0); sizePolicy3.setVerticalStretch(0); - head = new QWidget(); - head->setObjectName(QStringLiteral("head")); - head->setEnabled(true); - sizePolicy3.setHeightForWidth(head->sizePolicy().hasHeightForWidth()); - head->setSizePolicy(sizePolicy3); + foot->setObjectName(QStringLiteral("foot")); + foot->setEnabled(true); + foot->setSizePolicy(sizePolicy3); QPalette palette5; QBrush brush(QColor(255, 255, 255, 255)); brush.setStyle(Qt::SolidPattern); @@ -96,14 +120,15 @@ SettingsWidget::SettingsWidget() palette5.setBrush(QPalette::Disabled, QPalette::AlternateBase, brush1); palette5.setBrush(QPalette::Disabled, QPalette::ToolTipBase, brush7); palette5.setBrush(QPalette::Disabled, QPalette::ToolTipText, brush6); - head->setPalette(palette5); - head->setAutoFillBackground(true); - iconsLayout = new QHBoxLayout(head); + foot->setPalette(palette5); + foot->setAutoFillBackground(true); + + iconsLayout = new QHBoxLayout(foot); iconsLayout->setSpacing(0); iconsLayout->setObjectName(QStringLiteral("iconsLayout")); iconsLayout->setContentsMargins(0, 0, 0, 0); - generalButton = new QPushButton(head); + generalButton = new QPushButton(foot); generalButton->setObjectName(QStringLiteral("generalButton")); generalButton->setMinimumSize(QSize(55, 35)); generalButton->setMaximumSize(QSize(55, 35)); @@ -114,7 +139,7 @@ SettingsWidget::SettingsWidget() generalButton->setFlat(true); iconsLayout->addWidget(generalButton); - identityButton = new QPushButton(head); + identityButton = new QPushButton(foot); identityButton->setObjectName(QStringLiteral("identityButton")); identityButton->setMinimumSize(QSize(55, 35)); identityButton->setMaximumSize(QSize(55, 35)); @@ -125,7 +150,7 @@ SettingsWidget::SettingsWidget() identityButton->setFlat(true); iconsLayout->addWidget(identityButton); - privacyButton = new QPushButton(head); + privacyButton = new QPushButton(foot); privacyButton->setObjectName(QStringLiteral("privacyButton")); privacyButton->setMinimumSize(QSize(55, 35)); privacyButton->setMaximumSize(QSize(55, 35)); @@ -136,7 +161,7 @@ SettingsWidget::SettingsWidget() privacyButton->setFlat(true); iconsLayout->addWidget(privacyButton); - avButton = new QPushButton(head); + avButton = new QPushButton(foot); avButton->setObjectName(QStringLiteral("avButton")); avButton->setMinimumSize(QSize(55, 35)); avButton->setMaximumSize(QSize(55, 35)); @@ -146,19 +171,4 @@ SettingsWidget::SettingsWidget() avButton->setIcon(icon4); avButton->setFlat(true); iconsLayout->addWidget(avButton); - - head->setLayout(iconsLayout); - -} - -SettingsWidget::~SettingsWidget() -{ -} - -void SettingsWidget::show(Ui::MainWindow& ui) -{ - ui.mainContent->layout()->addWidget(main); - ui.mainHead->layout()->addWidget(head); - main->show(); - head->show(); } diff --git a/widget/form/settingswidget.h b/widget/form/settingswidget.h index a1cee909f..c901ce906 100644 --- a/widget/form/settingswidget.h +++ b/widget/form/settingswidget.h @@ -17,21 +17,15 @@ #ifndef SETTINGSWIDGET_H #define SETTINGSWIDGET_H -#include -#include -#include -#include -#include +#include #include -#include -#include - +#include #include "widget/croppinglabel.h" namespace Ui {class MainWindow;} class QString; -class SettingsWidget : public QObject +class SettingsWidget : public QWidget { Q_OBJECT public: @@ -46,7 +40,9 @@ public slots: private slots: private: - QWidget *main, *head; + QWidget *_main, *main, *head, *foot; + // _main consists of main+foot + QVBoxLayout *_mainLayout; // the code pertaining to the icons is mostly copied from ui_mainwindow.h QHBoxLayout *iconsLayout; QPushButton *generalButton; @@ -56,6 +52,10 @@ private: // now the actual pages and stuff // ... + + + + void prepButtons(); // just so I can move the crap to the bottom of the file public: }; From aa801f9615ecb052129c512861c42c69de4f6a86 Mon Sep 17 00:00:00 2001 From: bill Date: Mon, 15 Sep 2014 05:45:59 -0500 Subject: [PATCH 04/22] new settings infrastructure done, though there's a double free or something in ~Widget() --- qtox.pro | 9 ++++ widget/form/settings/avform.cpp | 26 ++++++++++ widget/form/settings/avform.h | 33 ++++++++++++ widget/form/settings/generalform.cpp | 46 ++++++++++++++++ widget/form/settings/generalform.h | 41 +++++++++++++++ widget/form/settings/genericsettings.h | 46 ++++++++++++++++ widget/form/settings/identityform.cpp | 38 ++++++++++++++ widget/form/settings/identityform.h | 34 ++++++++++++ widget/form/settings/privacyform.cpp | 27 ++++++++++ widget/form/settings/privacyform.h | 33 ++++++++++++ widget/form/settingswidget.cpp | 72 +++++++++++++++++++++++--- widget/form/settingswidget.h | 41 +++++++++------ 12 files changed, 423 insertions(+), 23 deletions(-) create mode 100644 widget/form/settings/avform.cpp create mode 100644 widget/form/settings/avform.h create mode 100644 widget/form/settings/generalform.cpp create mode 100644 widget/form/settings/generalform.h create mode 100644 widget/form/settings/genericsettings.h create mode 100644 widget/form/settings/identityform.cpp create mode 100644 widget/form/settings/identityform.h create mode 100644 widget/form/settings/privacyform.cpp create mode 100644 widget/form/settings/privacyform.h 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 From 5dc41282156f0d83c03f314c937d7688aeb1ca53 Mon Sep 17 00:00:00 2001 From: dubslow Date: Mon, 15 Sep 2014 08:31:42 -0500 Subject: [PATCH 05/22] cosmetics --- widget/form/settings/avform.cpp | 2 ++ widget/form/settings/generalform.cpp | 2 ++ widget/form/settings/genericsettings.h | 8 +++++++- widget/form/settings/identityform.cpp | 2 ++ widget/form/settings/privacyform.cpp | 2 ++ widget/form/settingswidget.cpp | 2 +- 6 files changed, 16 insertions(+), 2 deletions(-) diff --git a/widget/form/settings/avform.cpp b/widget/form/settings/avform.cpp index 347a1cfbb..5c0b38da3 100644 --- a/widget/form/settings/avform.cpp +++ b/widget/form/settings/avform.cpp @@ -19,6 +19,8 @@ AVForm::AVForm() { prep(); + icon.addFile(":/img/settings/av.png"); + label.setText(tr("Audio/Video settings")); } AVForm::~AVForm() diff --git a/widget/form/settings/generalform.cpp b/widget/form/settings/generalform.cpp index 050d4f7eb..a9810c1ae 100644 --- a/widget/form/settings/generalform.cpp +++ b/widget/form/settings/generalform.cpp @@ -20,6 +20,8 @@ GeneralForm::GeneralForm() { prep(); + icon.addFile(":/img/settings/general.png"); + label.setText(tr("General settings")); group = new QGroupBox(tr("General Settings")); enableIPv6 = new QCheckBox(); enableIPv6->setText(tr("Enable IPv6 (recommended)","Text on a checkbox to enable IPv6")); diff --git a/widget/form/settings/genericsettings.h b/widget/form/settings/genericsettings.h index 9353d21df..94f8fe90f 100644 --- a/widget/form/settings/genericsettings.h +++ b/widget/form/settings/genericsettings.h @@ -34,13 +34,19 @@ public: } protected: - QVBoxLayout layout, headLayout; + QVBoxLayout layout; + QHBoxLayout headLayout; + QIcon icon; + QLabel label; QWidget head, body; void prep() // call in subclass constructor { head.setLayout(&headLayout); + headLayout.addWidget(&icon); + headLayout.addWidget(&label); body.setLayout(&layout); } + }; #endif diff --git a/widget/form/settings/identityform.cpp b/widget/form/settings/identityform.cpp index dbd5574c5..ac89257a9 100644 --- a/widget/form/settings/identityform.cpp +++ b/widget/form/settings/identityform.cpp @@ -22,6 +22,8 @@ IdentityForm::IdentityForm() { prep(); + icon.addFile(":/img/settings/identity.png"); + label.setText(tr("Your identity")); toxGroup = new QGroupBox(tr("Tox ID")); QLabel* toxIdLabel = new QLabel(tr("Your Tox ID")); QLineEdit* toxID = new QLineEdit(); diff --git a/widget/form/settings/privacyform.cpp b/widget/form/settings/privacyform.cpp index 856f64954..ef7c54c4b 100644 --- a/widget/form/settings/privacyform.cpp +++ b/widget/form/settings/privacyform.cpp @@ -20,6 +20,8 @@ PrivacyForm::PrivacyForm() { prep(); + icon.addFile(":/img/settings/privacy.png"); + label.setText(tr("Privacy settings")); } PrivacyForm::~PrivacyForm() diff --git a/widget/form/settingswidget.cpp b/widget/form/settingswidget.cpp index 3a13c1cdb..9b5dc7856 100644 --- a/widget/form/settingswidget.cpp +++ b/widget/form/settingswidget.cpp @@ -110,7 +110,7 @@ void SettingsWidget::prepButtons() // just straight up copying it like this... oh well // the layout/icons obviously need to be improved, but it's a working model, // not a pretty one - QSizePolicy sizePolicy3(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); + QSizePolicy sizePolicy3(QSizePolicy::Fixed, QSizePolicy::Fixed); sizePolicy3.setHorizontalStretch(0); sizePolicy3.setVerticalStretch(0); foot->setObjectName(QStringLiteral("foot")); From b56739264985d35b0fbb1201e67cf954a5ccf638 Mon Sep 17 00:00:00 2001 From: Marcel Date: Fri, 12 Sep 2014 15:50:39 +0200 Subject: [PATCH 06/22] added images --- img/settings/av.png | Bin 0 -> 6360 bytes img/settings/general.png | Bin 0 -> 2902 bytes img/settings/identity.png | Bin 0 -> 4771 bytes img/settings/privacy.png | Bin 0 -> 1883 bytes res.qrc | 4 ++++ 5 files changed, 4 insertions(+) create mode 100644 img/settings/av.png create mode 100644 img/settings/general.png create mode 100644 img/settings/identity.png create mode 100644 img/settings/privacy.png diff --git a/img/settings/av.png b/img/settings/av.png new file mode 100644 index 0000000000000000000000000000000000000000..f96f88ea84299b2428780a15d29ae37db6601c90 GIT binary patch literal 6360 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 A^8f$< literal 0 HcmV?d00001 diff --git a/img/settings/identity.png b/img/settings/identity.png new file mode 100644 index 0000000000000000000000000000000000000000..806bb525efc2ea73d087891152331199cf543f99 GIT binary patch literal 4771 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 literal 0 HcmV?d00001 diff --git a/img/settings/privacy.png b/img/settings/privacy.png new file mode 100644 index 0000000000000000000000000000000000000000..763478290b8b0592c3f155013ad7d4f4637608d1 GIT binary patch literal 1883 zcmV-h2c-CkP)gtR(J>n?~InQFIz8Zp$*KF3uN*QzsEcO+*L2 zVsvxPDEeXVbMj$R=K|s@i$dni#++G1%<$~a5JaK4vQi3dub1wFHSvXNOYd!Z;rzd~ z_c_mVpZ@N1&ON8+UVw^xFDhcjDpmk^#SmvO+S+WVD3HKm zYy_}Q!Vu#PaR#rg%~nmvkf+0#0pRr0&Mhh`sv|Km@lVrWQGR+?hrBca%_03oNgM|SAEX#HuJalk>baeC`KPCyj*q}fjR))U=>FMdE zNl8gvy>*3}54JLMf2cq_OCnyMlD0hP@mC6-l?0yZT zM>!mhp=VB?87zjc&aTdZk)ChF1L1jIyX&J}3wfRoxk@@59R>;{M0vel#jRVnUf5W) zaZ)ILTrQW=X0s(zARn((jj^>8+2_L!~1HL5QY6M3UR>)-PMStf;1@Cbl>2 zD~?yB$steK00DsZ_V(fLE_(Ol{8jl=?RNWsK-<;S)Wp`;*Qd)N$4FXS3~FbHN~N+7 z89L-z{Gj+I(_oWz?6|QvoE=V;Uaxo0nLDT9LED*GGvB{ne|_qc{1J{Q`V|m!irD~Q z1%TH8j0B*QB2Gp|#;5!C@B8Wg=MC#OOgehx=&Ih_aRc}pKskUC!jXUbOqXR&F~1Ig z1F#9e^HRZ3C=}gu-=2H<{^!k`Hjh8{!?6{;bf@#3>m~r4F9-Qoh%b>J!x1a_+2jjn z&Ys!pa5$KyOP0?1F;c@|7{;^vlih2ps;bPD zXDeqpoz5Xr+*bfdAso3QS0LK}6o#YJS(g1z5QHe6=d}`tDkdB$lIs`}mVVba6MrTQ zFeJ}OY9OP~_atdf10+6qNtd;wqN1Gf@$vQAf!a2uQYmyeI$~Q|T1HD;DQYC;QMZQpiYr_(*OTg2gTFhw5}rB_x~z7wV{Ojd)s=+9+DM@P5q*tuhqCChUANp>es zoE);gVEvY^uC7?I&q2yry;5cukT-8--ma&?002vt<#yi6yj{NegKQ)#AS04TT+CUV zLjtwWS)4;gB#*dAfk>pZw6qK1XhVSnsEHFNHin}O1rnfQV`JUnXhVSnsLPix$A_a0 z1rngnojW%!9Bn9&09AXXc1G=$T3rzKy4owXGbj*=#Phs1cX@7JApfV^?e+n=%X9PO zHd~k5#1PHR&0{Q?mcr_)YNJ1!>Z)p^CDT&a+}u1yZu!X$2mrKNTSsr*vNgM|uI{n! ztFEq2w{^?b>{e^*XgTI4yS1#ixVY>2tMfm5bZ5z<`u@A`llFYFXNk>b6MeZ{%C#(6 z0ZD!~`NH8NhY#rW`n!SH+wJxNv)`JXd*h!QFUtjpY`QFy$#k`>ysRWp7yzKx>+hD8 zmz9`IrmJ)e5m5}oxQn+JAL#8vpT*mY4=@blra(keYHI5F$x|lxdZ)+aDU4WWrS7uI`{1}+E@vQn0d({s7#+Tx literal 0 HcmV?d00001 diff --git a/res.qrc b/res.qrc index cbf038a58..6a121b0ad 100644 --- a/res.qrc +++ b/res.qrc @@ -135,5 +135,9 @@ ui/fileTransferInstance/emptyRGreenFileButton.png ui/fileTransferInstance/emptyRRedFileButton.png audio/notification.pcm + img/settings/general.png + img/settings/identity.png + img/settings/privacy.png + img/settings/av.png From d971d7e6477741b9a7859f793a49c317cf5ec545 Mon Sep 17 00:00:00 2001 From: dubslow Date: Mon, 15 Sep 2014 08:48:17 -0500 Subject: [PATCH 07/22] scaling still isn't quite right... --- widget/form/settings/avform.cpp | 2 +- widget/form/settings/generalform.cpp | 2 +- widget/form/settings/genericsettings.h | 4 ++-- widget/form/settings/identityform.cpp | 2 +- widget/form/settings/privacyform.cpp | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/widget/form/settings/avform.cpp b/widget/form/settings/avform.cpp index 5c0b38da3..e0b0773f9 100644 --- a/widget/form/settings/avform.cpp +++ b/widget/form/settings/avform.cpp @@ -19,7 +19,7 @@ AVForm::AVForm() { prep(); - icon.addFile(":/img/settings/av.png"); + icon.setPixmap(QPixmap(":/img/settings/av.png").scaledToHeight(headLayout.sizeHint().height(), Qt::SmoothTransformation)); label.setText(tr("Audio/Video settings")); } diff --git a/widget/form/settings/generalform.cpp b/widget/form/settings/generalform.cpp index a9810c1ae..7a6734383 100644 --- a/widget/form/settings/generalform.cpp +++ b/widget/form/settings/generalform.cpp @@ -20,7 +20,7 @@ GeneralForm::GeneralForm() { prep(); - icon.addFile(":/img/settings/general.png"); + icon.setPixmap(QPixmap(":/img/settings/general.png").scaledToHeight(headLayout.sizeHint().height(), Qt::SmoothTransformation)); label.setText(tr("General settings")); group = new QGroupBox(tr("General Settings")); enableIPv6 = new QCheckBox(); diff --git a/widget/form/settings/genericsettings.h b/widget/form/settings/genericsettings.h index 94f8fe90f..760d39cb0 100644 --- a/widget/form/settings/genericsettings.h +++ b/widget/form/settings/genericsettings.h @@ -19,6 +19,7 @@ #include #include +#include #include "widget/form/settingswidget.h" class GenericForm : public QObject @@ -36,8 +37,7 @@ public: protected: QVBoxLayout layout; QHBoxLayout headLayout; - QIcon icon; - QLabel label; + QLabel label, icon; QWidget head, body; void prep() // call in subclass constructor { diff --git a/widget/form/settings/identityform.cpp b/widget/form/settings/identityform.cpp index ac89257a9..696b2141a 100644 --- a/widget/form/settings/identityform.cpp +++ b/widget/form/settings/identityform.cpp @@ -22,7 +22,7 @@ IdentityForm::IdentityForm() { prep(); - icon.addFile(":/img/settings/identity.png"); + icon.setPixmap(QPixmap(":/img/settings/identity.png").scaledToHeight(headLayout.sizeHint().height(), Qt::SmoothTransformation)); label.setText(tr("Your identity")); toxGroup = new QGroupBox(tr("Tox ID")); QLabel* toxIdLabel = new QLabel(tr("Your Tox ID")); diff --git a/widget/form/settings/privacyform.cpp b/widget/form/settings/privacyform.cpp index ef7c54c4b..e1f737975 100644 --- a/widget/form/settings/privacyform.cpp +++ b/widget/form/settings/privacyform.cpp @@ -20,7 +20,7 @@ PrivacyForm::PrivacyForm() { prep(); - icon.addFile(":/img/settings/privacy.png"); + icon.setPixmap(QPixmap(":/img/settings/privacy.png").scaledToHeight(headLayout.sizeHint().height(), Qt::SmoothTransformation)); label.setText(tr("Privacy settings")); } From 59869b4a8771b3ddf14f789a67a544660bfdbf2a Mon Sep 17 00:00:00 2001 From: dubslow Date: Sat, 13 Sep 2014 00:55:21 -0500 Subject: [PATCH 08/22] first thing's first, gotta placate the ocd --- mainwindow.ui | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mainwindow.ui b/mainwindow.ui index 7f9cd12c5..20e8269cf 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -3124,13 +3124,13 @@ QSplitter:handle{ 0 - 60 + 57 16777215 - 60 + 57 From e4e36dc946027b603fcb60ff3791e7d6a6625907 Mon Sep 17 00:00:00 2001 From: dubslow Date: Sat, 13 Sep 2014 03:32:24 -0500 Subject: [PATCH 09/22] initial new settings widget, subforms not started also "filing" some files under misc --- core.cpp | 6 +- main.cpp | 2 +- cdata.cpp => misc/cdata.cpp | 0 cdata.h => misc/cdata.h | 0 cstring.cpp => misc/cstring.cpp | 0 cstring.h => misc/cstring.h | 0 settings.cpp => misc/settings.cpp | 0 settings.h => misc/settings.h | 0 smileypack.cpp => misc/smileypack.cpp | 0 smileypack.h => misc/smileypack.h | 0 style.cpp => misc/style.cpp | 0 style.h => misc/style.h | 0 qtox.pro | 28 ++--- widget/emoticonswidget.cpp | 4 +- widget/form/genericchatform.cpp | 6 +- widget/form/settingswidget.cpp | 164 ++++++++++++++++++++++++++ widget/form/settingswidget.h | 62 ++++++++++ widget/groupwidget.cpp | 2 +- widget/tool/chataction.cpp | 2 +- widget/widget.cpp | 11 +- widget/widget.h | 4 +- 21 files changed, 258 insertions(+), 33 deletions(-) rename cdata.cpp => misc/cdata.cpp (100%) rename cdata.h => misc/cdata.h (100%) rename cstring.cpp => misc/cstring.cpp (100%) rename cstring.h => misc/cstring.h (100%) rename settings.cpp => misc/settings.cpp (100%) rename settings.h => misc/settings.h (100%) rename smileypack.cpp => misc/smileypack.cpp (100%) rename smileypack.h => misc/smileypack.h (100%) rename style.cpp => misc/style.cpp (100%) rename style.h => misc/style.h (100%) create mode 100644 widget/form/settingswidget.cpp create mode 100644 widget/form/settingswidget.h diff --git a/core.cpp b/core.cpp index fe1e3187b..81d022588 100644 --- a/core.cpp +++ b/core.cpp @@ -15,9 +15,9 @@ */ #include "core.h" -#include "cdata.h" -#include "cstring.h" -#include "settings.h" +#include "misc/cdata.h" +#include "misc/cstring.h" +#include "misc/settings.h" #include "widget/widget.h" #include diff --git a/main.cpp b/main.cpp index 1cdac827e..8e981baa5 100644 --- a/main.cpp +++ b/main.cpp @@ -15,7 +15,7 @@ */ #include "widget/widget.h" -#include "settings.h" +#include "misc/settings.h" #include #include #include diff --git a/cdata.cpp b/misc/cdata.cpp similarity index 100% rename from cdata.cpp rename to misc/cdata.cpp diff --git a/cdata.h b/misc/cdata.h similarity index 100% rename from cdata.h rename to misc/cdata.h diff --git a/cstring.cpp b/misc/cstring.cpp similarity index 100% rename from cstring.cpp rename to misc/cstring.cpp diff --git a/cstring.h b/misc/cstring.h similarity index 100% rename from cstring.h rename to misc/cstring.h diff --git a/settings.cpp b/misc/settings.cpp similarity index 100% rename from settings.cpp rename to misc/settings.cpp diff --git a/settings.h b/misc/settings.h similarity index 100% rename from settings.h rename to misc/settings.h diff --git a/smileypack.cpp b/misc/smileypack.cpp similarity index 100% rename from smileypack.cpp rename to misc/smileypack.cpp diff --git a/smileypack.h b/misc/smileypack.h similarity index 100% rename from smileypack.h rename to misc/smileypack.h diff --git a/style.cpp b/misc/style.cpp similarity index 100% rename from style.cpp rename to misc/style.cpp diff --git a/style.h b/misc/style.h similarity index 100% rename from style.h rename to misc/style.h diff --git a/qtox.pro b/qtox.pro index 250d3abc8..9112e95c0 100644 --- a/qtox.pro +++ b/qtox.pro @@ -81,6 +81,7 @@ win32 { HEADERS += widget/form/addfriendform.h \ widget/form/chatform.h \ widget/form/groupchatform.h \ + widget/form/settingswidget.h \ widget/form/filesform.h \ widget/tool/chattextedit.h \ widget/tool/friendrequestdialog.h \ @@ -90,17 +91,17 @@ HEADERS += widget/form/addfriendform.h \ friend.h \ group.h \ grouplist.h \ - settings.h \ + misc/settings.h \ core.h \ friendlist.h \ - cdata.h \ - cstring.h \ + misc/cdata.h \ + misc/cstring.h \ widget/selfcamview.h \ widget/camera.h \ widget/netcamview.h \ - smileypack.h \ + misc/smileypack.h \ widget/emoticonswidget.h \ - style.h \ + misc/style.h \ widget/adjustingscrollarea.h \ widget/croppinglabel.h \ widget/friendlistwidget.h \ @@ -111,13 +112,13 @@ HEADERS += widget/form/addfriendform.h \ filetransferinstance.h \ corestructs.h \ coredefines.h \ - coreav.h \ - widget/settingsdialog.h + coreav.h SOURCES += \ widget/form/addfriendform.cpp \ widget/form/chatform.cpp \ widget/form/groupchatform.cpp \ + widget/form/settingswidget.cpp \ widget/form/filesform.cpp \ widget/tool/chattextedit.cpp \ widget/tool/friendrequestdialog.cpp \ @@ -130,15 +131,15 @@ SOURCES += \ group.cpp \ grouplist.cpp \ main.cpp \ - settings.cpp \ - cdata.cpp \ - cstring.cpp \ + misc/settings.cpp \ + misc/cdata.cpp \ + misc/cstring.cpp \ widget/selfcamview.cpp \ widget/camera.cpp \ widget/netcamview.cpp \ - smileypack.cpp \ + misc/smileypack.cpp \ widget/emoticonswidget.cpp \ - style.cpp \ + misc/style.cpp \ widget/adjustingscrollarea.cpp \ widget/croppinglabel.cpp \ widget/friendlistwidget.cpp \ @@ -148,5 +149,4 @@ SOURCES += \ widget/tool/chataction.cpp \ widget/chatareawidget.cpp \ filetransferinstance.cpp \ - corestructs.cpp \ - widget/settingsdialog.cpp + corestructs.cpp diff --git a/widget/emoticonswidget.cpp b/widget/emoticonswidget.cpp index bab7abe8d..b0ffb6028 100644 --- a/widget/emoticonswidget.cpp +++ b/widget/emoticonswidget.cpp @@ -15,8 +15,8 @@ */ #include "emoticonswidget.h" -#include "smileypack.h" -#include "style.h" +#include "misc/smileypack.h" +#include "misc/style.h" #include #include diff --git a/widget/form/genericchatform.cpp b/widget/form/genericchatform.cpp index f5681f1c6..2aff5d2a7 100644 --- a/widget/form/genericchatform.cpp +++ b/widget/form/genericchatform.cpp @@ -17,11 +17,11 @@ #include "genericchatform.h" #include "ui_mainwindow.h" #include -#include "smileypack.h" +#include "misc/smileypack.h" #include "widget/emoticonswidget.h" -#include "style.h" +#include "misc/style.h" #include "widget/widget.h" -#include "settings.h" +#include "misc/settings.h" #include "widget/tool/chataction.h" #include "widget/chatareawidget.h" #include "widget/tool/chattextedit.h" diff --git a/widget/form/settingswidget.cpp b/widget/form/settingswidget.cpp new file mode 100644 index 000000000..6e2778de8 --- /dev/null +++ b/widget/form/settingswidget.cpp @@ -0,0 +1,164 @@ +/* + 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 "settingswidget.h" +#include "widget/widget.h" +#include "ui_mainwindow.h" + +SettingsWidget::SettingsWidget() + : QObject() +{ + main = new QWidget(); + // this crap is copied from ui_mainwindow.h... there's no easy way around + // just straight up copying it like this... oh well + // the layout/icons obviously need to be improved, but it's a working model, + // not a pretty one + QSizePolicy sizePolicy3(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); + sizePolicy3.setHorizontalStretch(0); + sizePolicy3.setVerticalStretch(0); + head = new QWidget(); + head->setObjectName(QStringLiteral("head")); + head->setEnabled(true); + sizePolicy3.setHeightForWidth(head->sizePolicy().hasHeightForWidth()); + head->setSizePolicy(sizePolicy3); + QPalette palette5; + QBrush brush(QColor(255, 255, 255, 255)); + brush.setStyle(Qt::SolidPattern); + QBrush brush1(QColor(28, 28, 28, 255)); + brush1.setStyle(Qt::SolidPattern); + QBrush brush2(QColor(42, 42, 42, 255)); + brush2.setStyle(Qt::SolidPattern); + QBrush brush3(QColor(35, 35, 35, 255)); + brush3.setStyle(Qt::SolidPattern); + QBrush brush4(QColor(14, 14, 14, 255)); + brush4.setStyle(Qt::SolidPattern); + QBrush brush5(QColor(18, 18, 18, 255)); + brush5.setStyle(Qt::SolidPattern); + QBrush brush6(QColor(0, 0, 0, 255)); + brush6.setStyle(Qt::SolidPattern); + QBrush brush7(QColor(255, 255, 220, 255)); + brush7.setStyle(Qt::SolidPattern); + palette5.setBrush(QPalette::Active, QPalette::WindowText, brush); + palette5.setBrush(QPalette::Active, QPalette::Button, brush1); + palette5.setBrush(QPalette::Active, QPalette::Light, brush2); + palette5.setBrush(QPalette::Active, QPalette::Midlight, brush3); + palette5.setBrush(QPalette::Active, QPalette::Dark, brush4); + palette5.setBrush(QPalette::Active, QPalette::Mid, brush5); + palette5.setBrush(QPalette::Active, QPalette::Text, brush); + palette5.setBrush(QPalette::Active, QPalette::BrightText, brush); + palette5.setBrush(QPalette::Active, QPalette::ButtonText, brush); + palette5.setBrush(QPalette::Active, QPalette::Base, brush6); + palette5.setBrush(QPalette::Active, QPalette::Window, brush1); + palette5.setBrush(QPalette::Active, QPalette::Shadow, brush6); + palette5.setBrush(QPalette::Active, QPalette::AlternateBase, brush4); + palette5.setBrush(QPalette::Active, QPalette::ToolTipBase, brush7); + palette5.setBrush(QPalette::Active, QPalette::ToolTipText, brush6); + palette5.setBrush(QPalette::Inactive, QPalette::WindowText, brush); + palette5.setBrush(QPalette::Inactive, QPalette::Button, brush1); + palette5.setBrush(QPalette::Inactive, QPalette::Light, brush2); + palette5.setBrush(QPalette::Inactive, QPalette::Midlight, brush3); + palette5.setBrush(QPalette::Inactive, QPalette::Dark, brush4); + palette5.setBrush(QPalette::Inactive, QPalette::Mid, brush5); + palette5.setBrush(QPalette::Inactive, QPalette::Text, brush); + palette5.setBrush(QPalette::Inactive, QPalette::BrightText, brush); + palette5.setBrush(QPalette::Inactive, QPalette::ButtonText, brush); + palette5.setBrush(QPalette::Inactive, QPalette::Base, brush6); + palette5.setBrush(QPalette::Inactive, QPalette::Window, brush1); + palette5.setBrush(QPalette::Inactive, QPalette::Shadow, brush6); + palette5.setBrush(QPalette::Inactive, QPalette::AlternateBase, brush4); + palette5.setBrush(QPalette::Inactive, QPalette::ToolTipBase, brush7); + palette5.setBrush(QPalette::Inactive, QPalette::ToolTipText, brush6); + palette5.setBrush(QPalette::Disabled, QPalette::WindowText, brush4); + palette5.setBrush(QPalette::Disabled, QPalette::Button, brush1); + palette5.setBrush(QPalette::Disabled, QPalette::Light, brush2); + palette5.setBrush(QPalette::Disabled, QPalette::Midlight, brush3); + palette5.setBrush(QPalette::Disabled, QPalette::Dark, brush4); + palette5.setBrush(QPalette::Disabled, QPalette::Mid, brush5); + palette5.setBrush(QPalette::Disabled, QPalette::Text, brush4); + palette5.setBrush(QPalette::Disabled, QPalette::BrightText, brush); + palette5.setBrush(QPalette::Disabled, QPalette::ButtonText, brush4); + palette5.setBrush(QPalette::Disabled, QPalette::Base, brush1); + palette5.setBrush(QPalette::Disabled, QPalette::Window, brush1); + palette5.setBrush(QPalette::Disabled, QPalette::Shadow, brush6); + palette5.setBrush(QPalette::Disabled, QPalette::AlternateBase, brush1); + palette5.setBrush(QPalette::Disabled, QPalette::ToolTipBase, brush7); + palette5.setBrush(QPalette::Disabled, QPalette::ToolTipText, brush6); + head->setPalette(palette5); + head->setAutoFillBackground(true); + iconsLayout = new QHBoxLayout(head); + iconsLayout->setSpacing(0); + iconsLayout->setObjectName(QStringLiteral("iconsLayout")); + iconsLayout->setContentsMargins(0, 0, 0, 0); + + generalButton = new QPushButton(head); + generalButton->setObjectName(QStringLiteral("generalButton")); + generalButton->setMinimumSize(QSize(55, 35)); + generalButton->setMaximumSize(QSize(55, 35)); + generalButton->setFocusPolicy(Qt::NoFocus); + QIcon icon1; + icon1.addFile(QStringLiteral(":/img/add.png"), QSize(), QIcon::Normal, QIcon::Off); + generalButton->setIcon(icon1); + generalButton->setFlat(true); + iconsLayout->addWidget(generalButton); + + identityButton = new QPushButton(head); + identityButton->setObjectName(QStringLiteral("identityButton")); + identityButton->setMinimumSize(QSize(55, 35)); + identityButton->setMaximumSize(QSize(55, 35)); + identityButton->setFocusPolicy(Qt::NoFocus); + QIcon icon2; + icon2.addFile(QStringLiteral(":/img/group.png"), QSize(), QIcon::Normal, QIcon::Off); + identityButton->setIcon(icon2); + identityButton->setFlat(true); + iconsLayout->addWidget(identityButton); + + privacyButton = new QPushButton(head); + privacyButton->setObjectName(QStringLiteral("privacyButton")); + privacyButton->setMinimumSize(QSize(55, 35)); + privacyButton->setMaximumSize(QSize(55, 35)); + privacyButton->setFocusPolicy(Qt::NoFocus); + QIcon icon3; + icon3.addFile(QStringLiteral(":/img/transfer.png"), QSize(), QIcon::Normal, QIcon::Off); + privacyButton->setIcon(icon3); + privacyButton->setFlat(true); + iconsLayout->addWidget(privacyButton); + + avButton = new QPushButton(head); + avButton->setObjectName(QStringLiteral("avButton")); + avButton->setMinimumSize(QSize(55, 35)); + avButton->setMaximumSize(QSize(55, 35)); + avButton->setFocusPolicy(Qt::NoFocus); + QIcon icon4; + icon4.addFile(QStringLiteral(":/img/settings.png"), QSize(), QIcon::Normal, QIcon::Off); + avButton->setIcon(icon4); + avButton->setFlat(true); + iconsLayout->addWidget(avButton); + + head->setLayout(iconsLayout); + +} + +SettingsWidget::~SettingsWidget() +{ +} + +void SettingsWidget::show(Ui::MainWindow& ui) +{ + ui.mainContent->layout()->addWidget(main); + ui.mainHead->layout()->addWidget(head); + main->show(); + head->show(); +} diff --git a/widget/form/settingswidget.h b/widget/form/settingswidget.h new file mode 100644 index 000000000..a1cee909f --- /dev/null +++ b/widget/form/settingswidget.h @@ -0,0 +1,62 @@ +/* + 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 SETTINGSWIDGET_H +#define SETTINGSWIDGET_H + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "widget/croppinglabel.h" + +namespace Ui {class MainWindow;} +class QString; + +class SettingsWidget : public QObject +{ + Q_OBJECT +public: + SettingsWidget(); + ~SettingsWidget(); + + void show(Ui::MainWindow &ui); + +public slots: + //void setFriendAddress(const QString& friendAddress); + +private slots: + +private: + QWidget *main, *head; + // 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 + // ... +public: +}; + +#endif // SETTINGSFORM_H diff --git a/widget/groupwidget.cpp b/widget/groupwidget.cpp index b8c1cbcc0..0c02db3d2 100644 --- a/widget/groupwidget.cpp +++ b/widget/groupwidget.cpp @@ -17,7 +17,7 @@ #include "groupwidget.h" #include "grouplist.h" #include "group.h" -#include "settings.h" +#include "misc/settings.h" #include "widget/form/groupchatform.h" #include #include diff --git a/widget/tool/chataction.cpp b/widget/tool/chataction.cpp index bcd1f1080..c05fd36b9 100644 --- a/widget/tool/chataction.cpp +++ b/widget/tool/chataction.cpp @@ -15,7 +15,7 @@ */ #include "chataction.h" -#include "smileypack.h" +#include "misc/smileypack.h" #include #include #include "filetransferinstance.h" diff --git a/widget/widget.cpp b/widget/widget.cpp index 36b2c33c1..f1472bcd6 100644 --- a/widget/widget.cpp +++ b/widget/widget.cpp @@ -17,7 +17,7 @@ #include "widget.h" #include "ui_mainwindow.h" #include "core.h" -#include "settings.h" +#include "misc/settings.h" #include "friend.h" #include "friendlist.h" #include "widget/tool/friendrequestdialog.h" @@ -26,12 +26,11 @@ #include "group.h" #include "widget/groupwidget.h" #include "widget/form/groupchatform.h" -#include "style.h" +#include "misc/style.h" #include "selfcamview.h" #include "widget/friendlistwidget.h" #include "camera.h" #include "widget/form/chatform.h" -#include "widget/settingsdialog.h" #include #include #include @@ -156,7 +155,6 @@ Widget::Widget(QWidget *parent) ui->statusButton->style()->polish(ui->statusButton); camera = new Camera; - settingsDialog = new SettingsDialog(this); // Disable some widgets until we're connected to the DHT ui->statusButton->setEnabled(false); @@ -335,8 +333,9 @@ void Widget::onTransferClicked() void Widget::onSettingsClicked() { - settingsDialog->readConfig(); - settingsDialog->show(); + hideMainForms(); + settingsWidget.show(*ui); + activeChatroomWidget = nullptr; } void Widget::hideMainForms() diff --git a/widget/widget.h b/widget/widget.h index 035ea2ae0..9512f00e9 100644 --- a/widget/widget.h +++ b/widget/widget.h @@ -19,6 +19,7 @@ #include #include "widget/form/addfriendform.h" +#include "widget/form/settingswidget.h" #include "widget/form/filesform.h" #include "corestructs.h" @@ -37,7 +38,6 @@ class QMenu; class Core; class Camera; class FriendListWidget; -class SettingsDialog; class Widget : public QMainWindow { @@ -134,8 +134,8 @@ private: Core* core; QThread* coreThread; AddFriendForm friendForm; + SettingsWidget settingsWidget; FilesForm filesForm; - SettingsDialog* settingsDialog; static Widget* instance; GenericChatroomWidget* activeChatroomWidget; FriendListWidget* contactListWidget; From e55f15725ec9558bdca588c8a2cfe80f40fef5b7 Mon Sep 17 00:00:00 2001 From: bill Date: Sun, 14 Sep 2014 13:42:27 -0500 Subject: [PATCH 10/22] move buttons to bottom --- widget/form/settingswidget.cpp | 66 +++++++++++++++++++--------------- widget/form/settingswidget.h | 20 +++++------ 2 files changed, 48 insertions(+), 38 deletions(-) diff --git a/widget/form/settingswidget.cpp b/widget/form/settingswidget.cpp index 6e2778de8..fcbd2a981 100644 --- a/widget/form/settingswidget.cpp +++ b/widget/form/settingswidget.cpp @@ -19,9 +19,35 @@ #include "ui_mainwindow.h" SettingsWidget::SettingsWidget() - : QObject() + : QWidget() { + _main = new QWidget(); main = new QWidget(); + head = new QWidget(); + foot = new QWidget(); + prepButtons(); + foot->setLayout(iconsLayout); + _mainLayout = new QVBoxLayout(_main); + _mainLayout->addWidget(main); + _mainLayout->addWidget(foot); + // something something foot size + _main->setLayout(_mainLayout); +} + +SettingsWidget::~SettingsWidget() +{ +} + +void SettingsWidget::show(Ui::MainWindow& ui) +{ + ui.mainContent->layout()->addWidget(_main); + ui.mainHead->layout()->addWidget(head); + _main->show(); + head->show(); +} + +void SettingsWidget::prepButtons() +{ // this crap is copied from ui_mainwindow.h... there's no easy way around // just straight up copying it like this... oh well // the layout/icons obviously need to be improved, but it's a working model, @@ -29,11 +55,9 @@ SettingsWidget::SettingsWidget() QSizePolicy sizePolicy3(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); sizePolicy3.setHorizontalStretch(0); sizePolicy3.setVerticalStretch(0); - head = new QWidget(); - head->setObjectName(QStringLiteral("head")); - head->setEnabled(true); - sizePolicy3.setHeightForWidth(head->sizePolicy().hasHeightForWidth()); - head->setSizePolicy(sizePolicy3); + foot->setObjectName(QStringLiteral("foot")); + foot->setEnabled(true); + foot->setSizePolicy(sizePolicy3); QPalette palette5; QBrush brush(QColor(255, 255, 255, 255)); brush.setStyle(Qt::SolidPattern); @@ -96,14 +120,15 @@ SettingsWidget::SettingsWidget() palette5.setBrush(QPalette::Disabled, QPalette::AlternateBase, brush1); palette5.setBrush(QPalette::Disabled, QPalette::ToolTipBase, brush7); palette5.setBrush(QPalette::Disabled, QPalette::ToolTipText, brush6); - head->setPalette(palette5); - head->setAutoFillBackground(true); - iconsLayout = new QHBoxLayout(head); + foot->setPalette(palette5); + foot->setAutoFillBackground(true); + + iconsLayout = new QHBoxLayout(foot); iconsLayout->setSpacing(0); iconsLayout->setObjectName(QStringLiteral("iconsLayout")); iconsLayout->setContentsMargins(0, 0, 0, 0); - generalButton = new QPushButton(head); + generalButton = new QPushButton(foot); generalButton->setObjectName(QStringLiteral("generalButton")); generalButton->setMinimumSize(QSize(55, 35)); generalButton->setMaximumSize(QSize(55, 35)); @@ -114,7 +139,7 @@ SettingsWidget::SettingsWidget() generalButton->setFlat(true); iconsLayout->addWidget(generalButton); - identityButton = new QPushButton(head); + identityButton = new QPushButton(foot); identityButton->setObjectName(QStringLiteral("identityButton")); identityButton->setMinimumSize(QSize(55, 35)); identityButton->setMaximumSize(QSize(55, 35)); @@ -125,7 +150,7 @@ SettingsWidget::SettingsWidget() identityButton->setFlat(true); iconsLayout->addWidget(identityButton); - privacyButton = new QPushButton(head); + privacyButton = new QPushButton(foot); privacyButton->setObjectName(QStringLiteral("privacyButton")); privacyButton->setMinimumSize(QSize(55, 35)); privacyButton->setMaximumSize(QSize(55, 35)); @@ -136,7 +161,7 @@ SettingsWidget::SettingsWidget() privacyButton->setFlat(true); iconsLayout->addWidget(privacyButton); - avButton = new QPushButton(head); + avButton = new QPushButton(foot); avButton->setObjectName(QStringLiteral("avButton")); avButton->setMinimumSize(QSize(55, 35)); avButton->setMaximumSize(QSize(55, 35)); @@ -146,19 +171,4 @@ SettingsWidget::SettingsWidget() avButton->setIcon(icon4); avButton->setFlat(true); iconsLayout->addWidget(avButton); - - head->setLayout(iconsLayout); - -} - -SettingsWidget::~SettingsWidget() -{ -} - -void SettingsWidget::show(Ui::MainWindow& ui) -{ - ui.mainContent->layout()->addWidget(main); - ui.mainHead->layout()->addWidget(head); - main->show(); - head->show(); } diff --git a/widget/form/settingswidget.h b/widget/form/settingswidget.h index a1cee909f..c901ce906 100644 --- a/widget/form/settingswidget.h +++ b/widget/form/settingswidget.h @@ -17,21 +17,15 @@ #ifndef SETTINGSWIDGET_H #define SETTINGSWIDGET_H -#include -#include -#include -#include -#include +#include #include -#include -#include - +#include #include "widget/croppinglabel.h" namespace Ui {class MainWindow;} class QString; -class SettingsWidget : public QObject +class SettingsWidget : public QWidget { Q_OBJECT public: @@ -46,7 +40,9 @@ public slots: private slots: private: - QWidget *main, *head; + QWidget *_main, *main, *head, *foot; + // _main consists of main+foot + QVBoxLayout *_mainLayout; // the code pertaining to the icons is mostly copied from ui_mainwindow.h QHBoxLayout *iconsLayout; QPushButton *generalButton; @@ -56,6 +52,10 @@ private: // now the actual pages and stuff // ... + + + + void prepButtons(); // just so I can move the crap to the bottom of the file public: }; From 5ec79fc26080eae03350877686336d1caba223a2 Mon Sep 17 00:00:00 2001 From: bill Date: Mon, 15 Sep 2014 05:45:59 -0500 Subject: [PATCH 11/22] new settings infrastructure done, though there's a double free or something in ~Widget() --- qtox.pro | 9 ++++ widget/form/settings/avform.cpp | 26 ++++++++++ widget/form/settings/avform.h | 33 ++++++++++++ widget/form/settings/generalform.cpp | 46 ++++++++++++++++ widget/form/settings/generalform.h | 41 +++++++++++++++ widget/form/settings/genericsettings.h | 46 ++++++++++++++++ widget/form/settings/identityform.cpp | 38 ++++++++++++++ widget/form/settings/identityform.h | 34 ++++++++++++ widget/form/settings/privacyform.cpp | 27 ++++++++++ widget/form/settings/privacyform.h | 33 ++++++++++++ widget/form/settingswidget.cpp | 72 +++++++++++++++++++++++--- widget/form/settingswidget.h | 41 +++++++++------ 12 files changed, 423 insertions(+), 23 deletions(-) create mode 100644 widget/form/settings/avform.cpp create mode 100644 widget/form/settings/avform.h create mode 100644 widget/form/settings/generalform.cpp create mode 100644 widget/form/settings/generalform.h create mode 100644 widget/form/settings/genericsettings.h create mode 100644 widget/form/settings/identityform.cpp create mode 100644 widget/form/settings/identityform.h create mode 100644 widget/form/settings/privacyform.cpp create mode 100644 widget/form/settings/privacyform.h diff --git a/qtox.pro b/qtox.pro index 9112e95c0..5c550cd1f 100644 --- a/qtox.pro +++ b/qtox.pro @@ -82,6 +82,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 \ @@ -119,6 +124,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 From 575862f25f1b0f5b18ff4c2698c572a590d26277 Mon Sep 17 00:00:00 2001 From: dubslow Date: Mon, 15 Sep 2014 08:31:42 -0500 Subject: [PATCH 12/22] cosmetics --- widget/form/settings/avform.cpp | 2 ++ widget/form/settings/generalform.cpp | 2 ++ widget/form/settings/genericsettings.h | 8 +++++++- widget/form/settings/identityform.cpp | 2 ++ widget/form/settings/privacyform.cpp | 2 ++ widget/form/settingswidget.cpp | 2 +- 6 files changed, 16 insertions(+), 2 deletions(-) diff --git a/widget/form/settings/avform.cpp b/widget/form/settings/avform.cpp index 347a1cfbb..5c0b38da3 100644 --- a/widget/form/settings/avform.cpp +++ b/widget/form/settings/avform.cpp @@ -19,6 +19,8 @@ AVForm::AVForm() { prep(); + icon.addFile(":/img/settings/av.png"); + label.setText(tr("Audio/Video settings")); } AVForm::~AVForm() diff --git a/widget/form/settings/generalform.cpp b/widget/form/settings/generalform.cpp index 050d4f7eb..a9810c1ae 100644 --- a/widget/form/settings/generalform.cpp +++ b/widget/form/settings/generalform.cpp @@ -20,6 +20,8 @@ GeneralForm::GeneralForm() { prep(); + icon.addFile(":/img/settings/general.png"); + label.setText(tr("General settings")); group = new QGroupBox(tr("General Settings")); enableIPv6 = new QCheckBox(); enableIPv6->setText(tr("Enable IPv6 (recommended)","Text on a checkbox to enable IPv6")); diff --git a/widget/form/settings/genericsettings.h b/widget/form/settings/genericsettings.h index 9353d21df..94f8fe90f 100644 --- a/widget/form/settings/genericsettings.h +++ b/widget/form/settings/genericsettings.h @@ -34,13 +34,19 @@ public: } protected: - QVBoxLayout layout, headLayout; + QVBoxLayout layout; + QHBoxLayout headLayout; + QIcon icon; + QLabel label; QWidget head, body; void prep() // call in subclass constructor { head.setLayout(&headLayout); + headLayout.addWidget(&icon); + headLayout.addWidget(&label); body.setLayout(&layout); } + }; #endif diff --git a/widget/form/settings/identityform.cpp b/widget/form/settings/identityform.cpp index dbd5574c5..ac89257a9 100644 --- a/widget/form/settings/identityform.cpp +++ b/widget/form/settings/identityform.cpp @@ -22,6 +22,8 @@ IdentityForm::IdentityForm() { prep(); + icon.addFile(":/img/settings/identity.png"); + label.setText(tr("Your identity")); toxGroup = new QGroupBox(tr("Tox ID")); QLabel* toxIdLabel = new QLabel(tr("Your Tox ID")); QLineEdit* toxID = new QLineEdit(); diff --git a/widget/form/settings/privacyform.cpp b/widget/form/settings/privacyform.cpp index 856f64954..ef7c54c4b 100644 --- a/widget/form/settings/privacyform.cpp +++ b/widget/form/settings/privacyform.cpp @@ -20,6 +20,8 @@ PrivacyForm::PrivacyForm() { prep(); + icon.addFile(":/img/settings/privacy.png"); + label.setText(tr("Privacy settings")); } PrivacyForm::~PrivacyForm() diff --git a/widget/form/settingswidget.cpp b/widget/form/settingswidget.cpp index 3a13c1cdb..9b5dc7856 100644 --- a/widget/form/settingswidget.cpp +++ b/widget/form/settingswidget.cpp @@ -110,7 +110,7 @@ void SettingsWidget::prepButtons() // just straight up copying it like this... oh well // the layout/icons obviously need to be improved, but it's a working model, // not a pretty one - QSizePolicy sizePolicy3(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); + QSizePolicy sizePolicy3(QSizePolicy::Fixed, QSizePolicy::Fixed); sizePolicy3.setHorizontalStretch(0); sizePolicy3.setVerticalStretch(0); foot->setObjectName(QStringLiteral("foot")); From 9d36833a8ba0aea01bd0d615ff1e19cf2b62b81a Mon Sep 17 00:00:00 2001 From: dubslow Date: Mon, 15 Sep 2014 08:48:17 -0500 Subject: [PATCH 13/22] scaling still isn't quite right... --- widget/form/settings/avform.cpp | 2 +- widget/form/settings/generalform.cpp | 2 +- widget/form/settings/genericsettings.h | 4 ++-- widget/form/settings/identityform.cpp | 2 +- widget/form/settings/privacyform.cpp | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/widget/form/settings/avform.cpp b/widget/form/settings/avform.cpp index 5c0b38da3..e0b0773f9 100644 --- a/widget/form/settings/avform.cpp +++ b/widget/form/settings/avform.cpp @@ -19,7 +19,7 @@ AVForm::AVForm() { prep(); - icon.addFile(":/img/settings/av.png"); + icon.setPixmap(QPixmap(":/img/settings/av.png").scaledToHeight(headLayout.sizeHint().height(), Qt::SmoothTransformation)); label.setText(tr("Audio/Video settings")); } diff --git a/widget/form/settings/generalform.cpp b/widget/form/settings/generalform.cpp index a9810c1ae..7a6734383 100644 --- a/widget/form/settings/generalform.cpp +++ b/widget/form/settings/generalform.cpp @@ -20,7 +20,7 @@ GeneralForm::GeneralForm() { prep(); - icon.addFile(":/img/settings/general.png"); + icon.setPixmap(QPixmap(":/img/settings/general.png").scaledToHeight(headLayout.sizeHint().height(), Qt::SmoothTransformation)); label.setText(tr("General settings")); group = new QGroupBox(tr("General Settings")); enableIPv6 = new QCheckBox(); diff --git a/widget/form/settings/genericsettings.h b/widget/form/settings/genericsettings.h index 94f8fe90f..760d39cb0 100644 --- a/widget/form/settings/genericsettings.h +++ b/widget/form/settings/genericsettings.h @@ -19,6 +19,7 @@ #include #include +#include #include "widget/form/settingswidget.h" class GenericForm : public QObject @@ -36,8 +37,7 @@ public: protected: QVBoxLayout layout; QHBoxLayout headLayout; - QIcon icon; - QLabel label; + QLabel label, icon; QWidget head, body; void prep() // call in subclass constructor { diff --git a/widget/form/settings/identityform.cpp b/widget/form/settings/identityform.cpp index ac89257a9..696b2141a 100644 --- a/widget/form/settings/identityform.cpp +++ b/widget/form/settings/identityform.cpp @@ -22,7 +22,7 @@ IdentityForm::IdentityForm() { prep(); - icon.addFile(":/img/settings/identity.png"); + icon.setPixmap(QPixmap(":/img/settings/identity.png").scaledToHeight(headLayout.sizeHint().height(), Qt::SmoothTransformation)); label.setText(tr("Your identity")); toxGroup = new QGroupBox(tr("Tox ID")); QLabel* toxIdLabel = new QLabel(tr("Your Tox ID")); diff --git a/widget/form/settings/privacyform.cpp b/widget/form/settings/privacyform.cpp index ef7c54c4b..e1f737975 100644 --- a/widget/form/settings/privacyform.cpp +++ b/widget/form/settings/privacyform.cpp @@ -20,7 +20,7 @@ PrivacyForm::PrivacyForm() { prep(); - icon.addFile(":/img/settings/privacy.png"); + icon.setPixmap(QPixmap(":/img/settings/privacy.png").scaledToHeight(headLayout.sizeHint().height(), Qt::SmoothTransformation)); label.setText(tr("Privacy settings")); } From 35128e5048b2e05e0dca790d743c3249ee9e7e23 Mon Sep 17 00:00:00 2001 From: dubslow Date: Tue, 16 Sep 2014 12:13:21 -0500 Subject: [PATCH 14/22] cleanup --- widget/settingsdialog.cpp | 380 -------------------------------------- widget/settingsdialog.h | 64 ------- 2 files changed, 444 deletions(-) delete mode 100644 widget/settingsdialog.cpp delete mode 100644 widget/settingsdialog.h diff --git a/widget/settingsdialog.cpp b/widget/settingsdialog.cpp deleted file mode 100644 index d81973286..000000000 --- a/widget/settingsdialog.cpp +++ /dev/null @@ -1,380 +0,0 @@ -#include "settingsdialog.h" -#include "settings.h" -#include "widget.h" -#include "camera.h" -#include "selfcamview.h" -#include "core.h" -#include "smileypack.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -// ======================================= -// settings pages -//======================================== -class GeneralPage : public QWidget -{ - Q_OBJECT -public: - GeneralPage(QWidget *parent = 0) : - QWidget(parent) - { - QGroupBox *group = new QGroupBox(tr("General Settings"), this); - - enableIPv6 = new QCheckBox(this); - enableIPv6->setText(tr("Enable IPv6 (recommended)","Text on a checkbox to enable IPv6")); - useTranslations = new QCheckBox(this); - useTranslations->setText(tr("Use translations","Text on a checkbox to enable translations")); - makeToxPortable = new QCheckBox(this); - 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); - - // theme - QGroupBox* themeGroup = new QGroupBox(tr("Theme")); - QLabel* smileyLabel = new QLabel(tr("Smiley Pack")); - smileyPack = new QComboBox(this); - - auto smileyPacks = SmileyPack::listSmileyPacks(); - for(auto pack : smileyPacks) - smileyPack->addItem(QString("%1 (%2)").arg(pack.first).arg(pack.second), pack.second); - - QVBoxLayout* themeLayout = new QVBoxLayout(); - themeLayout->addWidget(smileyLabel); - themeLayout->addWidget(smileyPack); - themeGroup->setLayout(themeLayout); - - QVBoxLayout *mainLayout = new QVBoxLayout(); - mainLayout->addWidget(group); - mainLayout->addWidget(themeGroup); - mainLayout->addStretch(1); - setLayout(mainLayout); - } - - QCheckBox* enableIPv6; - QCheckBox* useTranslations; - QCheckBox* makeToxPortable; - QComboBox* smileyPack; -}; - -class IdentityPage : public QWidget -{ - Q_OBJECT -public: - IdentityPage(QWidget* parent = 0) : - QWidget(parent) - { - // public - QGroupBox *publicGroup = new QGroupBox(tr("Public Information"), this); - QLabel* userNameLabel = new QLabel(tr("Name","Username/nick"), this); - userName = new QLineEdit(this); - QLabel* statusMessageLabel = new QLabel(tr("Status","Status message"), this); - statusMessage = new QLineEdit(this); - QVBoxLayout *vLayout = new QVBoxLayout(); - vLayout->addWidget(userNameLabel); - vLayout->addWidget(userName); - vLayout->addWidget(statusMessageLabel); - vLayout->addWidget(statusMessage); - publicGroup->setLayout(vLayout); - - // tox - QGroupBox* toxGroup = new QGroupBox(tr("Tox ID"), this); - QLabel* toxIdLabel = new QLabel(tr("Your Tox ID"), this); - toxID = new QLineEdit(this); - toxID->setReadOnly(true); - QVBoxLayout* toxLayout = new QVBoxLayout(); - toxLayout->addWidget(toxIdLabel); - toxLayout->addWidget(toxID); - toxGroup->setLayout(toxLayout); - - QVBoxLayout *mainLayout = new QVBoxLayout(); - mainLayout->setSpacing(30); - mainLayout->addWidget(publicGroup); - mainLayout->addWidget(toxGroup); - mainLayout->addStretch(1); - setLayout(mainLayout); - } - - QLineEdit* userName; - QLineEdit* statusMessage; - QLineEdit* toxID; -}; - -class PrivacyPage : public QWidget -{ -public: - PrivacyPage(QWidget* parent = 0) : - QWidget(parent) - {} -}; - -class AVPage : public QWidget -{ - Q_OBJECT -public: - AVPage(SettingsDialog* parent = 0) : - QWidget(parent) - { - QGroupBox *group = new QGroupBox(tr("Video Settings"), this); - - camView = new SelfCamView(parent->getWidget()->getCamera()); - camView->hide(); // hide by default - testVideo = new QPushButton(tr("Show video preview","On a button")); - connect(testVideo, SIGNAL(clicked()), this, SLOT(onTestVideoPressed())); - - QVBoxLayout *vLayout = new QVBoxLayout(); - vLayout->addWidget(testVideo); - vLayout->addWidget(camView); - group->setLayout(vLayout); - - QVBoxLayout *mainLayout = new QVBoxLayout(); - mainLayout->addWidget(group); - mainLayout->addStretch(1); - setLayout(mainLayout); - } - - ~AVPage() - { - delete camView; - } - - void showTestVideo() - { - testVideo->setText(tr("Hide video preview","On a button")); - camView->show(); - } - - void closeTestVideo() - { - testVideo->setText(tr("Show video preview","On a button")); - camView->close(); - } - - QPushButton* testVideo; - SelfCamView* camView; - -public slots: - void onTestVideoPressed() - { - if (camView->isVisible()) { - closeTestVideo(); - } else { - showTestVideo(); - } - } -}; - -// allows Q_OBJECT macro inside cpp -#include "settingsdialog.moc" - - - -// ======================================= -// settings dialog -//======================================== -SettingsDialog::SettingsDialog(Widget *parent) : - QDialog(parent), - widget(parent) -{ - createPages(); - createButtons(); - createConnections(); - createLayout(); - setWindowTitle(tr("qTox – Settings")); -} - -void SettingsDialog::createPages() -{ - generalPage = new GeneralPage(this); - identityPage = new IdentityPage(this); - privacyPage = new PrivacyPage(this); - avPage = new AVPage(this); - - contentsWidget = new QListWidget; - contentsWidget->setViewMode(QListView::IconMode); - contentsWidget->setIconSize(QSize(100, 73)); - contentsWidget->setMovement(QListView::Static); - contentsWidget->setMaximumWidth(110); - contentsWidget->setMinimumWidth(110); - contentsWidget->setSpacing(0); - contentsWidget->setFlow(QListView::TopToBottom); - - pagesWidget = new QStackedWidget; - pagesWidget->addWidget(generalPage); - pagesWidget->addWidget(identityPage); - pagesWidget->addWidget(privacyPage); - pagesWidget->addWidget(avPage); - - QListWidgetItem *generalButton = new QListWidgetItem(contentsWidget); - generalButton->setIcon(QIcon(":/img/settings/general.png")); - generalButton->setText(tr("General")); - generalButton->setTextAlignment(Qt::AlignHCenter); - generalButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - - QListWidgetItem *identity = new QListWidgetItem(contentsWidget); - identity->setIcon(QIcon(":/img/settings/identity.png")); - identity->setText(tr("Identity")); - identity->setTextAlignment(Qt::AlignHCenter); - identity->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - - QListWidgetItem *privacy = new QListWidgetItem(contentsWidget); - privacy->setIcon(QIcon(":/img/settings/privacy.png")); - privacy->setText(tr("Privacy")); - privacy->setTextAlignment(Qt::AlignHCenter); - privacy->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - - QListWidgetItem *av = new QListWidgetItem(contentsWidget); - av->setIcon(QIcon(":/img/settings/av.png")); - av->setText(tr("Audio/Video")); - av->setTextAlignment(Qt::AlignHCenter); - av->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - - contentsWidget->setCurrentRow(0); -} - -void SettingsDialog::createButtons() -{ - okButton = new QPushButton(tr("Ok"), this); - cancelButton = new QPushButton(tr("Cancel"), this); - applyButton = new QPushButton(tr("Apply"), this); -} - -void SettingsDialog::createConnections() -{ - connect(okButton, SIGNAL(clicked()), this, SLOT(okPressed())); - connect(cancelButton, SIGNAL(clicked()), this, SLOT(close())); - connect(applyButton, SIGNAL(clicked()), this, SLOT(applyPressed())); - connect( - contentsWidget, - SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), - this, - SLOT(changePage(QListWidgetItem*,QListWidgetItem*)) - ); -} - -void SettingsDialog::createLayout() -{ - setMinimumSize(800, 500); - - QHBoxLayout *buttonsLayout = new QHBoxLayout(); - buttonsLayout->addStretch(1); - buttonsLayout->addWidget(okButton); - buttonsLayout->addWidget(cancelButton); - buttonsLayout->addWidget(applyButton); - - QHBoxLayout *hLayout = new QHBoxLayout(); - hLayout->addWidget(contentsWidget); - hLayout->addWidget(pagesWidget, 1); - - QVBoxLayout *mainLayout = new QVBoxLayout(); - mainLayout->addLayout(hLayout); - mainLayout->addLayout(buttonsLayout); - setLayout(mainLayout); -} - -void SettingsDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous) -{ - if (!current) { - current = previous; - } - pagesWidget->setCurrentIndex(contentsWidget->row(current)); -} - -void SettingsDialog::okPressed() -{ - writeConfig(); - close(); -} - -void SettingsDialog::cancelPressed() -{ - close(); -} - -void SettingsDialog::applyPressed() -{ - writeConfig(); -} - -void SettingsDialog::readConfig() -{ - Settings& settings = Settings::getInstance(); - Core* core = widget->getCore(); - - generalPage->enableIPv6->setChecked(settings.getEnableIPv6()); - generalPage->useTranslations->setChecked(settings.getUseTranslations()); - generalPage->makeToxPortable->setChecked(settings.getMakeToxPortable()); - - identityPage->userName->setText(core->getUsername()); - identityPage->statusMessage->setText(core->getStatusMessage()); - identityPage->toxID->setText(core->getSelfId().toString()); -} - -void SettingsDialog::writeConfig() -{ - Settings& settings = Settings::getInstance(); - Core* core = widget->getCore(); - - - // only save settings if something changed - bool saveSettings = false; - if (settings.getEnableIPv6() != generalPage->enableIPv6->isChecked()) { - settings.setEnableIPv6(generalPage->enableIPv6->isChecked()); - saveSettings = true; - } - - if (settings.getUseTranslations() != generalPage->useTranslations->isChecked()) { - settings.setUseTranslations(generalPage->useTranslations->isChecked()); - saveSettings = true; - } - - if (settings.getMakeToxPortable() != generalPage->makeToxPortable->isChecked()) { - settings.setMakeToxPortable(generalPage->makeToxPortable->isChecked()); - saveSettings = true; - } - - if (settings.getSmileyPack() != generalPage->smileyPack->currentData().toString()) { - settings.setSmileyPack(generalPage->smileyPack->currentData().toString()); - saveSettings = true; - } - - if (saveSettings) { - settings.save(); - } - - - // changing core settings will automatically save them - QString userName = identityPage->userName->text(); - if (core->getUsername() != userName) { - core->setUsername(userName); - } - - QString statusMessage = identityPage->statusMessage->text(); - if (core->getStatusMessage() != statusMessage) { - core->setStatusMessage(statusMessage); - } -} - -Widget* SettingsDialog::getWidget() -{ - return widget; -} - -void SettingsDialog::closeEvent(QCloseEvent* e){ - avPage->closeTestVideo(); - QDialog::closeEvent(e); -} diff --git a/widget/settingsdialog.h b/widget/settingsdialog.h deleted file mode 100644 index 55575b447..000000000 --- a/widget/settingsdialog.h +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef SETTINGSDIALOG_H -#define SETTINGSDIALOG_H - -#include -#include - -class Widget; -class SelfCamView; -class Camera; -class GeneralPage; -class IdentityPage; -class PrivacyPage; -class AVPage; - -class QListWidget; -class QListWidgetItem; -class QStackedWidget; -class QPushButton; -class QCheckBox; -class QLineEdit; - -// ======================================= -// settings dialog -//======================================== -class SettingsDialog : public QDialog -{ - Q_OBJECT -public: - explicit SettingsDialog(Widget *parent); - - void readConfig(); - void writeConfig(); - Widget* getWidget(); - void closeEvent(QCloseEvent *); - -public slots: - void changePage(QListWidgetItem *current, QListWidgetItem *previous); - void okPressed(); - void cancelPressed(); - void applyPressed(); - -private: - void createPages(); - void createButtons(); - void createConnections(); - void createLayout(); - - Widget* widget; - - // pages - GeneralPage* generalPage; - IdentityPage* identityPage; - PrivacyPage* privacyPage; - AVPage* avPage; - QListWidget* contentsWidget; - QStackedWidget* pagesWidget; - - // buttons - QPushButton* okButton; - QPushButton* cancelButton; - QPushButton* applyButton; -}; - -#endif // SETTINGSDIALOG_H From da8f83943dd81106ab72e25f731acf44cba29016 Mon Sep 17 00:00:00 2001 From: "Tux3 / Mlkj / !Lev.uXFMLA" Date: Sun, 28 Sep 2014 10:56:02 +0200 Subject: [PATCH 15/22] Compat with toxcore --- core.cpp | 8 ++++---- core.h | 6 +++--- widget/widget.cpp | 4 ++-- widget/widget.h | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/core.cpp b/core.cpp index 81d022588..da1d24b70 100644 --- a/core.cpp +++ b/core.cpp @@ -279,10 +279,10 @@ void Core::onAction(Tox*/* tox*/, int friendId, const uint8_t *cMessage, uint16_ emit static_cast(core)->actionReceived(friendId, CString::toString(cMessage, cMessageSize)); } -void Core::onGroupInvite(Tox*, int friendnumber, const uint8_t *group_public_key, void *core) +void Core::onGroupInvite(Tox*, int friendnumber, const uint8_t *group_public_key, uint16_t length,void *core) { qDebug() << QString("Core: Group invite by %1").arg(friendnumber); - emit static_cast(core)->groupInviteReceived(friendnumber, group_public_key); + emit static_cast(core)->groupInviteReceived(friendnumber, group_public_key,length); } void Core::onGroupMessage(Tox*, int groupnumber, int friendgroupnumber, const uint8_t * message, uint16_t length, void *core) @@ -1005,10 +1005,10 @@ QList Core::getGroupPeerNames(int groupId) const return names; } -int Core::joinGroupchat(int32_t friendnumber, const uint8_t* friend_group_public_key) const +int Core::joinGroupchat(int32_t friendnumber, const uint8_t* friend_group_public_key,uint16_t length) const { qDebug() << QString("Trying to join groupchat invite by friend %1").arg(friendnumber); - return tox_join_groupchat(tox, friendnumber, friend_group_public_key); + return tox_join_groupchat(tox, friendnumber, friend_group_public_key,length); } void Core::quitGroupChat(int groupId) const diff --git a/core.h b/core.h index 13d051017..129b0cf8f 100644 --- a/core.h +++ b/core.h @@ -41,7 +41,7 @@ public: QString getGroupPeerName(int groupId, int peerId) const; QList getGroupPeerNames(int groupId) const; QString getFriendAddress(int friendNumber) const; - int joinGroupchat(int32_t friendnumber, const uint8_t* friend_group_public_key) const; + int joinGroupchat(int32_t friendnumber, const uint8_t* friend_group_public_key,uint16_t length) const; void quitGroupChat(int groupId) const; void dispatchVideoFrame(vpx_image img) const; @@ -115,7 +115,7 @@ signals: void friendLastSeenChanged(int friendId, const QDateTime& dateTime); void emptyGroupCreated(int groupnumber); - void groupInviteReceived(int friendnumber, const uint8_t *group_public_key); + void groupInviteReceived(int friendnumber, const uint8_t *group_public_key,uint16_t length); void groupMessageReceived(int groupnumber, int friendgroupnumber, const QString& message); void groupNamelistChanged(int groupnumber, int peernumber, uint8_t change); @@ -170,7 +170,7 @@ private: static void onUserStatusChanged(Tox* tox, int friendId, uint8_t userstatus, void* core); static void onConnectionStatusChanged(Tox* tox, int friendId, uint8_t status, void* core); static void onAction(Tox* tox, int friendId, const uint8_t* cMessage, uint16_t cMessageSize, void* core); - static void onGroupInvite(Tox *tox, int friendnumber, const uint8_t *group_public_key, void *userdata); + static void onGroupInvite(Tox *tox, int friendnumber, const uint8_t *group_public_key, uint16_t length,void *userdata); static void onGroupMessage(Tox *tox, int groupnumber, int friendgroupnumber, const uint8_t * message, uint16_t length, void *userdata); static void onGroupNamelistChange(Tox *tox, int groupnumber, int peernumber, uint8_t change, void *userdata); static void onFileSendRequestCallback(Tox *tox, int32_t friendnumber, uint8_t filenumber, uint64_t filesize, diff --git a/widget/widget.cpp b/widget/widget.cpp index 62e362f00..a0d5049b3 100644 --- a/widget/widget.cpp +++ b/widget/widget.cpp @@ -558,9 +558,9 @@ void Widget::copyFriendIdToClipboard(int friendId) } } -void Widget::onGroupInviteReceived(int32_t friendId, const uint8_t* publicKey) +void Widget::onGroupInviteReceived(int32_t friendId, const uint8_t* publicKey,uint16_t length) { - int groupId = core->joinGroupchat(friendId, publicKey); + int groupId = core->joinGroupchat(friendId, publicKey,length); if (groupId == -1) { qWarning() << "Widget::onGroupInviteReceived: Unable to accept invitation"; diff --git a/widget/widget.h b/widget/widget.h index 9512f00e9..e94435fbb 100644 --- a/widget/widget.h +++ b/widget/widget.h @@ -95,7 +95,7 @@ private slots: void onFriendMessageReceived(int friendId, const QString& message); void onFriendRequestReceived(const QString& userId, const QString& message); void onEmptyGroupCreated(int groupId); - void onGroupInviteReceived(int32_t friendId, const uint8_t *publicKey); + void onGroupInviteReceived(int32_t friendId, const uint8_t *publicKey,uint16_t length); void onGroupMessageReceived(int groupnumber, int friendgroupnumber, const QString& message); void onGroupNamelistChanged(int groupnumber, int peernumber, uint8_t change); void removeFriend(int friendId); From 8212a3dad0bd28008d46b4df0aa7326218dc67d0 Mon Sep 17 00:00:00 2001 From: dubslow Date: Tue, 30 Sep 2014 04:44:27 -0500 Subject: [PATCH 16/22] Added all current settings except cam test, which segfaults on init... --- widget/form/settings/avform.cpp | 39 +++++++++++++- widget/form/settings/avform.h | 16 +++++- widget/form/settings/generalform.cpp | 66 ++++++++++++++++------- widget/form/settings/generalform.h | 18 ++++--- widget/form/settings/genericsettings.h | 17 +++--- widget/form/settings/identityform.cpp | 75 ++++++++++++++++++++++++-- widget/form/settings/identityform.h | 33 +++++++++++- widget/form/settings/privacyform.cpp | 1 - widget/form/settingswidget.cpp | 5 +- widget/form/settingswidget.h | 16 +++--- widget/widget.cpp | 12 +++-- widget/widget.h | 3 +- 12 files changed, 243 insertions(+), 58 deletions(-) diff --git a/widget/form/settings/avform.cpp b/widget/form/settings/avform.cpp index e0b0773f9..3a4c86f0a 100644 --- a/widget/form/settings/avform.cpp +++ b/widget/form/settings/avform.cpp @@ -15,14 +15,49 @@ */ #include "avform.h" +#include "widget/camera.h" -AVForm::AVForm() +AVForm::AVForm(Camera* cam) { - prep(); icon.setPixmap(QPixmap(":/img/settings/av.png").scaledToHeight(headLayout.sizeHint().height(), Qt::SmoothTransformation)); label.setText(tr("Audio/Video settings")); + + QGroupBox *group = new QGroupBox(tr("Video Settings")); + + camView = new SelfCamView(cam); + camView->hide(); // hide by default + testVideo = new QPushButton(tr("Show video preview","On a button")); + connect(testVideo, &QPushButton::clicked, this, &AVForm::onTestVideoPressed); + + videoLayout = new QVBoxLayout(); + videoLayout->addWidget(testVideo); + videoLayout->addWidget(camView); + //videoGroup->setLayout(videoLayout); // strangely enough, this causes a segfault.... + + layout.addWidget(group); + layout.addStretch(1); } AVForm::~AVForm() { } + +void AVForm::showTestVideo() +{ + testVideo->setText(tr("Hide video preview","On a button")); + camView->show(); +} + +void AVForm::closeTestVideo() +{ + testVideo->setText(tr("Show video preview","On a button")); + camView->close(); +} + +void AVForm::onTestVideoPressed() +{ + if (camView->isVisible()) + closeTestVideo(); + else + showTestVideo(); +} diff --git a/widget/form/settings/avform.h b/widget/form/settings/avform.h index e214e133e..be7c97dae 100644 --- a/widget/form/settings/avform.h +++ b/widget/form/settings/avform.h @@ -18,16 +18,30 @@ #define AVFORM_H #include "genericsettings.h" +#include "widget/selfcamview.h" +#include +#include +#include +class Camera; class AVForm : public GenericForm { Q_OBJECT public: - AVForm(); + AVForm(Camera* cam); ~AVForm(); +private slots: + void onTestVideoPressed(); private: + QGroupBox* videoGroup; + QVBoxLayout* videoLayout; + QPushButton* testVideo; + SelfCamView* camView; + void showTestVideo(); + void closeTestVideo(); + }; #endif diff --git a/widget/form/settings/generalform.cpp b/widget/form/settings/generalform.cpp index 7a6734383..1c7ed8bff 100644 --- a/widget/form/settings/generalform.cpp +++ b/widget/form/settings/generalform.cpp @@ -16,33 +16,63 @@ #include "generalform.h" #include "widget/form/settingswidget.h" +#include "widget/widget.h" +#include "misc/settings.h" +#include "misc/smileypack.h" GeneralForm::GeneralForm() { - prep(); icon.setPixmap(QPixmap(":/img/settings/general.png").scaledToHeight(headLayout.sizeHint().height(), Qt::SmoothTransformation)); - label.setText(tr("General settings")); - 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")); + 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())); + headLayout.addWidget(&label); - layout.addWidget(group); + layout.addWidget(&enableIPv6); + layout.addWidget(&useTranslations); + layout.addWidget(&makeToxPortable); + layout.addWidget(&smileyPackLabel); + layout.addWidget(&smileyPackBrowser); + layout.addStretch(); + + 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(&smileyPackBrowser, SIGNAL(currentIndexChanged(int)), this, SLOT(onSmileyBrowserIndexChanged(int))); } GeneralForm::~GeneralForm() { } + +void GeneralForm::onEnableIPv6Updated() +{ + Settings::getInstance().setEnableIPv6(enableIPv6.isChecked()); +} + +void GeneralForm::onUseTranslationUpdated() +{ + Settings::getInstance().setUseTranslations(useTranslations.isChecked()); +} + +void GeneralForm::onMakeToxPortableUpdated() +{ + Settings::getInstance().setMakeToxPortable(makeToxPortable.isChecked()); +} + +void GeneralForm::onSmileyBrowserIndexChanged(int index) +{ + QString filename = smileyPackBrowser.itemData(index).toString(); + Settings::getInstance().setSmileyPack(filename); +} diff --git a/widget/form/settings/generalform.h b/widget/form/settings/generalform.h index c484a436d..b33b7ffcb 100644 --- a/widget/form/settings/generalform.h +++ b/widget/form/settings/generalform.h @@ -18,10 +18,8 @@ #define GENERALFORM_H #include "genericsettings.h" -#include +#include #include -#include - class GeneralForm : public GenericForm { @@ -30,12 +28,16 @@ public: GeneralForm(); ~GeneralForm(); +private slots: + void onEnableIPv6Updated(); + void onUseTranslationUpdated(); + void onMakeToxPortableUpdated(); + void onSmileyBrowserIndexChanged(int index); + private: - QGroupBox *group; - QCheckBox* enableIPv6; - QCheckBox* useTranslations; - QCheckBox* makeToxPortable; - QLabel label; + QCheckBox enableIPv6, useTranslations, makeToxPortable; + QLabel label, smileyPackLabel; + QComboBox smileyPackBrowser; }; #endif diff --git a/widget/form/settings/genericsettings.h b/widget/form/settings/genericsettings.h index 760d39cb0..8d6d4e9bb 100644 --- a/widget/form/settings/genericsettings.h +++ b/widget/form/settings/genericsettings.h @@ -26,6 +26,15 @@ class GenericForm : public QObject { Q_OBJECT public: + GenericForm() + { + head.setLayout(&headLayout); + headLayout.addWidget(&icon); + headLayout.addWidget(&label); + body.setLayout(&layout); + } + ~GenericForm() {}; + virtual void show(SettingsWidget& sw) { sw.body->layout()->addWidget(&body); @@ -39,14 +48,6 @@ protected: QHBoxLayout headLayout; QLabel label, icon; QWidget head, body; - void prep() // call in subclass constructor - { - head.setLayout(&headLayout); - headLayout.addWidget(&icon); - headLayout.addWidget(&label); - body.setLayout(&layout); - } - }; #endif diff --git a/widget/form/settings/identityform.cpp b/widget/form/settings/identityform.cpp index 696b2141a..57a69a759 100644 --- a/widget/form/settings/identityform.cpp +++ b/widget/form/settings/identityform.cpp @@ -16,25 +16,90 @@ #include "identityform.h" #include "widget/form/settingswidget.h" +#include "widget/croppinglabel.h" +#include "core.h" #include #include +#include +#include IdentityForm::IdentityForm() { - prep(); icon.setPixmap(QPixmap(":/img/settings/identity.png").scaledToHeight(headLayout.sizeHint().height(), Qt::SmoothTransformation)); label.setText(tr("Your identity")); + + // public + publicGroup = new QGroupBox(tr("Public Information")); + userNameLabel = new QLabel(tr("Name","Username/nick")); + userName = new QLineEdit(); + + statusMessageLabel = new QLabel(tr("Status","Status message")); + statusMessage = new QLineEdit(); + + vLayout = new QVBoxLayout(); + vLayout->addWidget(userNameLabel); + vLayout->addWidget(userName); + vLayout->addWidget(statusMessageLabel); + vLayout->addWidget(statusMessage); + publicGroup->setLayout(vLayout); + + // tox toxGroup = new QGroupBox(tr("Tox ID")); - QLabel* toxIdLabel = new QLabel(tr("Your Tox ID")); - QLineEdit* toxID = new QLineEdit(); - toxID->setReadOnly(true); + toxIdLabel = new CroppingLabel(); + toxIdLabel->setText(tr("Your Tox ID (click to copy)")); + toxId = new ClickableTE(); + QFont small; + small.setPixelSize(13); + small.setKerning(false); + toxId->setTextInteractionFlags(Qt::TextSelectableByMouse); + toxId->setReadOnly(true); + toxId->setFrameStyle(QFrame::NoFrame); + toxId->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + toxId->setFixedHeight(toxId->document()->size().height()*2); + toxId->setFont(small); + QVBoxLayout* toxLayout = new QVBoxLayout(); toxLayout->addWidget(toxIdLabel); - toxLayout->addWidget(toxID); + toxLayout->addWidget(toxId); toxGroup->setLayout(toxLayout); + + layout.setSpacing(30); + layout.addWidget(publicGroup); layout.addWidget(toxGroup); + layout.addStretch(1); + + connect(toxIdLabel, SIGNAL(clicked()), this, SLOT(copyIdClicked())); + connect(toxId, SIGNAL(clicked()), this, SLOT(copyIdClicked())); + connect(userName, SIGNAL(editingFinished()), this, SLOT(onUserNameEdited())); + connect(statusMessage, SIGNAL(editingFinished()), this, SLOT(onStatusMessageEdited())); } IdentityForm::~IdentityForm() { } + +void IdentityForm::copyIdClicked() +{ + toxId->selectAll(); + QString txt = toxId->toPlainText(); + txt.replace('\n',""); + QApplication::clipboard()->setText(txt); +} + +void IdentityForm::onUserNameEdited() +{ + emit userNameChanged(userName->text()); +} + +void IdentityForm::onStatusMessageEdited() +{ + emit statusMessageChanged(statusMessage->text()); +} + +void IdentityForm::show(SettingsWidget& sw) +{ + userName->setText(Core::getInstance()->getUsername()); + statusMessage->setText(Core::getInstance()->getStatusMessage()); + toxId->setText(Core::getInstance()->getSelfId().toString()); + GenericForm::show(sw); +} diff --git a/widget/form/settings/identityform.h b/widget/form/settings/identityform.h index dc616d75e..8e80e0aaf 100644 --- a/widget/form/settings/identityform.h +++ b/widget/form/settings/identityform.h @@ -19,6 +19,20 @@ #include "genericsettings.h" #include +#include +#include +class CroppingLabel; + +class ClickableTE : public QTextEdit +{ + Q_OBJECT +public: + +signals: + void clicked(); +protected: + void mouseReleaseEvent(QMouseEvent*) {emit clicked();} +}; class IdentityForm : public GenericForm { @@ -27,8 +41,25 @@ public: IdentityForm(); ~IdentityForm(); + QLineEdit* userName, * statusMessage; + + void show(SettingsWidget& sw); + +signals: + void userNameChanged(QString); + void statusMessageChanged(QString); + +private slots: + void copyIdClicked(); + void onUserNameEdited(); + void onStatusMessageEdited(); + private: - QGroupBox* toxGroup; + QGroupBox* toxGroup, * publicGroup; + ClickableTE* toxId; + QLabel* userNameLabel, * statusMessageLabel; + CroppingLabel* toxIdLabel; + QVBoxLayout* vLayout, * toxLayout; }; #endif diff --git a/widget/form/settings/privacyform.cpp b/widget/form/settings/privacyform.cpp index e1f737975..683bdff4b 100644 --- a/widget/form/settings/privacyform.cpp +++ b/widget/form/settings/privacyform.cpp @@ -19,7 +19,6 @@ PrivacyForm::PrivacyForm() { - prep(); icon.setPixmap(QPixmap(":/img/settings/privacy.png").scaledToHeight(headLayout.sizeHint().height(), Qt::SmoothTransformation)); label.setText(tr("Privacy settings")); } diff --git a/widget/form/settingswidget.cpp b/widget/form/settingswidget.cpp index 9b5dc7856..dddce56e0 100644 --- a/widget/form/settingswidget.cpp +++ b/widget/form/settingswidget.cpp @@ -17,18 +17,19 @@ #include "settingswidget.h" #include "widget/widget.h" #include "ui_mainwindow.h" +#include "widget/camera.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() +SettingsWidget::SettingsWidget(Camera* cam) : QWidget() { generalForm = new GeneralForm(); identityForm = new IdentityForm(); privacyForm = new PrivacyForm(); - avForm = new AVForm(); + avForm = new AVForm(cam); main = new QWidget(); body = new QWidget(); diff --git a/widget/form/settingswidget.h b/widget/form/settingswidget.h index 6ee45f90d..b24f7ffb6 100644 --- a/widget/form/settingswidget.h +++ b/widget/form/settingswidget.h @@ -19,6 +19,7 @@ #include #include +class Camera; class GenericForm; class GeneralForm; class IdentityForm; @@ -30,12 +31,17 @@ class SettingsWidget : public QWidget { Q_OBJECT public: - SettingsWidget(); + SettingsWidget(Camera* cam); ~SettingsWidget(); void show(Ui::MainWindow &ui); QWidget *head, *body; // keep the others private + GenericForm* active; + GeneralForm* generalForm; + IdentityForm* identityForm; + PrivacyForm* privacyForm; + AVForm* avForm; public slots: //void setFriendAddress(const QString& friendAddress); @@ -51,14 +57,8 @@ private: // 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; diff --git a/widget/widget.cpp b/widget/widget.cpp index a0d5049b3..517fc70ad 100644 --- a/widget/widget.cpp +++ b/widget/widget.cpp @@ -156,6 +156,8 @@ Widget::Widget(QWidget *parent) camera = new Camera; + settingsWidget = new SettingsWidget(camera); + // Disable some widgets until we're connected to the DHT ui->statusButton->setEnabled(false); @@ -206,6 +208,8 @@ Widget::Widget(QWidget *parent) connect(ui->settingsButton, SIGNAL(clicked()), this, SLOT(onSettingsClicked())); connect(ui->nameLabel, SIGNAL(textChanged(QString,QString)), this, SLOT(onUsernameChanged(QString,QString))); connect(ui->statusLabel, SIGNAL(textChanged(QString,QString)), this, SLOT(onStatusMessageChanged(QString,QString))); + connect(settingsWidget->identityForm, &IdentityForm::userNameChanged, core, &Core::setUsername); + connect(settingsWidget->identityForm, &IdentityForm::statusMessageChanged, core, &Core::setStatusMessage); connect(setStatusOnline, SIGNAL(triggered()), this, SLOT(setStatusOnline())); connect(setStatusAway, SIGNAL(triggered()), this, SLOT(setStatusAway())); connect(setStatusBusy, SIGNAL(triggered()), this, SLOT(setStatusBusy())); @@ -219,12 +223,12 @@ Widget::Widget(QWidget *parent) Widget::~Widget() { core->saveConfiguration(); - instance = nullptr; coreThread->exit(); coreThread->wait(500); // In case of deadlock (can happen with QtAudio/PA bugs) if (!coreThread->isFinished()) coreThread->terminate(); delete core; + delete settingsWidget; hideMainForms(); @@ -235,6 +239,7 @@ Widget::~Widget() delete g; GroupList::groupList.clear(); delete ui; + instance = nullptr; } Widget* Widget::getInstance() @@ -335,7 +340,7 @@ void Widget::onTransferClicked() void Widget::onSettingsClicked() { hideMainForms(); - settingsWidget.show(*ui); + settingsWidget->show(*ui); activeChatroomWidget = nullptr; } @@ -364,6 +369,7 @@ void Widget::setUsername(const QString& username) { ui->nameLabel->setText(username); ui->nameLabel->setToolTip(username); // for overlength names + settingsWidget->identityForm->userName->setText(username); } void Widget::onStatusMessageChanged(const QString& newStatusMessage, const QString& oldStatusMessage) @@ -377,11 +383,11 @@ void Widget::setStatusMessage(const QString &statusMessage) { ui->statusLabel->setText(statusMessage); ui->statusLabel->setToolTip(statusMessage); // for overlength messsages + settingsWidget->identityForm->statusMessage->setText(statusMessage); } void Widget::addFriend(int friendId, const QString &userId) { - qDebug() << "Widget: Adding friend with id "+userId; Friend* newfriend = FriendList::addFriend(friendId, userId); QLayout* layout = contactListWidget->getFriendLayout(Status::Offline); diff --git a/widget/widget.h b/widget/widget.h index e94435fbb..26fecb84d 100644 --- a/widget/widget.h +++ b/widget/widget.h @@ -20,6 +20,7 @@ #include #include "widget/form/addfriendform.h" #include "widget/form/settingswidget.h" +#include "widget/form/settings/identityform.h" #include "widget/form/filesform.h" #include "corestructs.h" @@ -134,7 +135,7 @@ private: Core* core; QThread* coreThread; AddFriendForm friendForm; - SettingsWidget settingsWidget; + SettingsWidget* settingsWidget; FilesForm filesForm; static Widget* instance; GenericChatroomWidget* activeChatroomWidget; From e3580fc416dd5ed298899016ba6759e320c4e264 Mon Sep 17 00:00:00 2001 From: dubslow Date: Tue, 30 Sep 2014 05:02:49 -0500 Subject: [PATCH 17/22] one frickin stinkin merge error --- qtox.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qtox.pro b/qtox.pro index ad0d839c2..68ab4db73 100644 --- a/qtox.pro +++ b/qtox.pro @@ -164,7 +164,7 @@ SOURCES += \ widget/tool/chatactions/chataction.cpp \ widget/chatareawidget.cpp \ filetransferinstance.cpp \ - corestructs.cpp + corestructs.cpp \ widget/tool/chatactions/messageaction.cpp \ widget/tool/chatactions/filetransferaction.cpp \ widget/tool/chatactions/systemmessageaction.cpp \ From 8d9d53b9e9380275ecbdbaa5b85252bdd71c878f Mon Sep 17 00:00:00 2001 From: dubslow Date: Tue, 30 Sep 2014 05:12:17 -0500 Subject: [PATCH 18/22] fix double free --- widget/form/settingswidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/widget/form/settingswidget.cpp b/widget/form/settingswidget.cpp index dddce56e0..f82e1a689 100644 --- a/widget/form/settingswidget.cpp +++ b/widget/form/settingswidget.cpp @@ -41,7 +41,7 @@ SettingsWidget::SettingsWidget(Camera* cam) prepButtons(); foot->setLayout(iconsLayout); - mainLayout = new QVBoxLayout(main); + mainLayout = new QVBoxLayout(); mainLayout->addWidget(body); mainLayout->addWidget(foot); // something something foot size From 8fa9457305d55a21ddd034dc569c0053162cd31f Mon Sep 17 00:00:00 2001 From: apprb Date: Mon, 6 Oct 2014 01:17:01 +0900 Subject: [PATCH 19/22] base refactoring --- qtox.pro | 5 +- widget/form/settings/avform.cpp | 28 ++-- widget/form/settings/avform.h | 11 +- widget/form/settings/avsettings.ui | 50 ++++++ widget/form/settings/generalform.cpp | 52 +++--- widget/form/settings/generalform.h | 8 +- widget/form/settings/genericsettings.h | 33 ++-- widget/form/settings/identityform.cpp | 61 +++---- widget/form/settings/identityform.h | 15 +- widget/form/settings/privacyform.cpp | 5 +- widget/form/settingswidget.cpp | 216 +++---------------------- widget/form/settingswidget.h | 37 +---- widget/widget.cpp | 8 +- 13 files changed, 181 insertions(+), 348 deletions(-) create mode 100644 widget/form/settings/avsettings.ui diff --git a/qtox.pro b/qtox.pro index 68ab4db73..11dec4a7c 100644 --- a/qtox.pro +++ b/qtox.pro @@ -26,7 +26,10 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = qtox TEMPLATE = app FORMS += \ - mainwindow.ui + mainwindow.ui \ + widget/form/settings/generalsettings.ui \ + widget/form/settings/avsettings.ui \ + widget/form/settings/identitysettings.ui CONFIG += c++11 TRANSLATIONS = translations/de.ts \ diff --git a/widget/form/settings/avform.cpp b/widget/form/settings/avform.cpp index 3a4c86f0a..4b7afef25 100644 --- a/widget/form/settings/avform.cpp +++ b/widget/form/settings/avform.cpp @@ -16,41 +16,35 @@ #include "avform.h" #include "widget/camera.h" +#include "ui_avsettings.h" -AVForm::AVForm(Camera* cam) +AVForm::AVForm(Camera* cam) : + GenericForm(tr("Audio/Video settings"), QPixmap(":/img/settings/av.png")) { - icon.setPixmap(QPixmap(":/img/settings/av.png").scaledToHeight(headLayout.sizeHint().height(), Qt::SmoothTransformation)); - label.setText(tr("Audio/Video settings")); - - QGroupBox *group = new QGroupBox(tr("Video Settings")); + bodyUI = new Ui::AVSettings; + bodyUI->setupUi(this); - camView = new SelfCamView(cam); + camView = new SelfCamView(cam, this); + bodyUI->videoGroup->layout()->addWidget(camView); camView->hide(); // hide by default - testVideo = new QPushButton(tr("Show video preview","On a button")); - connect(testVideo, &QPushButton::clicked, this, &AVForm::onTestVideoPressed); - videoLayout = new QVBoxLayout(); - videoLayout->addWidget(testVideo); - videoLayout->addWidget(camView); - //videoGroup->setLayout(videoLayout); // strangely enough, this causes a segfault.... - - layout.addWidget(group); - layout.addStretch(1); + connect(bodyUI->testVideoBtn, &QPushButton::clicked, this, &AVForm::onTestVideoPressed); } AVForm::~AVForm() { + delete bodyUI; } void AVForm::showTestVideo() { - testVideo->setText(tr("Hide video preview","On a button")); + bodyUI->testVideoBtn->setText(tr("Hide video preview","On a button")); camView->show(); } void AVForm::closeTestVideo() { - testVideo->setText(tr("Show video preview","On a button")); + bodyUI->testVideoBtn->setText(tr("Show video preview","On a button")); camView->close(); } diff --git a/widget/form/settings/avform.h b/widget/form/settings/avform.h index be7c97dae..e75f742da 100644 --- a/widget/form/settings/avform.h +++ b/widget/form/settings/avform.h @@ -22,6 +22,11 @@ #include #include #include + +namespace Ui { +class AVSettings; +} + class Camera; class AVForm : public GenericForm @@ -33,10 +38,10 @@ public: private slots: void onTestVideoPressed(); + private: - QGroupBox* videoGroup; - QVBoxLayout* videoLayout; - QPushButton* testVideo; + Ui::AVSettings *bodyUI; + SelfCamView* camView; void showTestVideo(); diff --git a/widget/form/settings/avsettings.ui b/widget/form/settings/avsettings.ui new file mode 100644 index 000000000..77fbb18b4 --- /dev/null +++ b/widget/form/settings/avsettings.ui @@ -0,0 +1,50 @@ + + + AVSettings + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + + Video settings + + + + + + Show video preview + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + diff --git a/widget/form/settings/generalform.cpp b/widget/form/settings/generalform.cpp index 1c7ed8bff..c816f4225 100644 --- a/widget/form/settings/generalform.cpp +++ b/widget/form/settings/generalform.cpp @@ -14,65 +14,57 @@ See the COPYING file for more details. */ +#include "ui_generalsettings.h" #include "generalform.h" #include "widget/form/settingswidget.h" #include "widget/widget.h" #include "misc/settings.h" #include "misc/smileypack.h" -GeneralForm::GeneralForm() +GeneralForm::GeneralForm() : + GenericForm(tr("General Settings"), QPixmap(":/img/settings/general.png")) { - icon.setPixmap(QPixmap(":/img/settings/general.png").scaledToHeight(headLayout.sizeHint().height(), Qt::SmoothTransformation)); - label.setText(tr("General Settings")); - - 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")); + bodyUI = new Ui::GeneralSettings; + bodyUI->setupUi(this); + + bodyUI->cbEnableIPv6->setChecked(Settings::getInstance().getEnableIPv6()); + bodyUI->cbUseTranslations->setChecked(Settings::getInstance().getUseTranslations()); + bodyUI->cbMakeToxPortable->setChecked(Settings::getInstance().getMakeToxPortable()); - 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())); + { + bodyUI->smileyPackBrowser->addItem(entry.first, entry.second); + } + bodyUI->smileyPackBrowser->setCurrentIndex(bodyUI->smileyPackBrowser->findData(Settings::getInstance().getSmileyPack())); - headLayout.addWidget(&label); - layout.addWidget(&enableIPv6); - layout.addWidget(&useTranslations); - layout.addWidget(&makeToxPortable); - layout.addWidget(&smileyPackLabel); - layout.addWidget(&smileyPackBrowser); - layout.addStretch(); - - 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(&smileyPackBrowser, SIGNAL(currentIndexChanged(int)), this, SLOT(onSmileyBrowserIndexChanged(int))); + connect(bodyUI->cbEnableIPv6, SIGNAL(stateChanged(int)), this, SLOT(onEnableIPv6Updated())); + connect(bodyUI->cbUseTranslations, SIGNAL(stateChanged(int)), this, SLOT(onUseTranslationUpdated())); + connect(bodyUI->cbMakeToxPortable, SIGNAL(stateChanged(int)), this, SLOT(onMakeToxPortableUpdated())); + connect(bodyUI->smileyPackBrowser, SIGNAL(currentIndexChanged(int)), this, SLOT(onSmileyBrowserIndexChanged(int))); } GeneralForm::~GeneralForm() { + delete bodyUI; } void GeneralForm::onEnableIPv6Updated() { - Settings::getInstance().setEnableIPv6(enableIPv6.isChecked()); + Settings::getInstance().setEnableIPv6(bodyUI->cbEnableIPv6->isChecked()); } void GeneralForm::onUseTranslationUpdated() { - Settings::getInstance().setUseTranslations(useTranslations.isChecked()); + Settings::getInstance().setUseTranslations(bodyUI->cbUseTranslations->isChecked()); } void GeneralForm::onMakeToxPortableUpdated() { - Settings::getInstance().setMakeToxPortable(makeToxPortable.isChecked()); + Settings::getInstance().setMakeToxPortable(bodyUI->cbMakeToxPortable->isChecked()); } void GeneralForm::onSmileyBrowserIndexChanged(int index) { - QString filename = smileyPackBrowser.itemData(index).toString(); + QString filename = bodyUI->smileyPackBrowser->itemData(index).toString(); Settings::getInstance().setSmileyPack(filename); } diff --git a/widget/form/settings/generalform.h b/widget/form/settings/generalform.h index b33b7ffcb..5d5fd6efe 100644 --- a/widget/form/settings/generalform.h +++ b/widget/form/settings/generalform.h @@ -21,6 +21,10 @@ #include #include +namespace Ui { +class GeneralSettings; +} + class GeneralForm : public GenericForm { Q_OBJECT @@ -35,9 +39,7 @@ private slots: void onSmileyBrowserIndexChanged(int index); private: - QCheckBox enableIPv6, useTranslations, makeToxPortable; - QLabel label, smileyPackLabel; - QComboBox smileyPackBrowser; + Ui::GeneralSettings *bodyUI; }; #endif diff --git a/widget/form/settings/genericsettings.h b/widget/form/settings/genericsettings.h index 8d6d4e9bb..e3852ee28 100644 --- a/widget/form/settings/genericsettings.h +++ b/widget/form/settings/genericsettings.h @@ -17,37 +17,30 @@ #ifndef GENERICFORM_H #define GENERICFORM_H -#include -#include -#include +#include #include "widget/form/settingswidget.h" -class GenericForm : public QObject +class GenericForm : public QWidget { Q_OBJECT public: - GenericForm() - { - head.setLayout(&headLayout); - headLayout.addWidget(&icon); - headLayout.addWidget(&label); - body.setLayout(&layout); - } - ~GenericForm() {}; + GenericForm(const QString &name, const QPixmap &icon) : formName(name), formIcon(icon) {;} + ~GenericForm() {;} virtual void show(SettingsWidget& sw) { - sw.body->layout()->addWidget(&body); - body.show(); - sw.head->layout()->addWidget(&head); - head.show(); +// sw.body->layout()->addWidget(&body); +// body.show(); +// sw.head->layout()->addWidget(&head); +// head.show(); } + QString getFormName() {return formName;} + QPixmap getFormIcon() {return formIcon;} + protected: - QVBoxLayout layout; - QHBoxLayout headLayout; - QLabel label, icon; - QWidget head, body; + QString formName; + QPixmap formIcon; }; #endif diff --git a/widget/form/settings/identityform.cpp b/widget/form/settings/identityform.cpp index 57a69a759..bfc231c33 100644 --- a/widget/form/settings/identityform.cpp +++ b/widget/form/settings/identityform.cpp @@ -14,6 +14,7 @@ See the COPYING file for more details. */ +#include "ui_identitysettings.h" #include "identityform.h" #include "widget/form/settingswidget.h" #include "widget/croppinglabel.h" @@ -23,34 +24,18 @@ #include #include -IdentityForm::IdentityForm() +IdentityForm::IdentityForm() : + GenericForm(tr("Your identity"), QPixmap(":/img/settings/identity.png")) { - icon.setPixmap(QPixmap(":/img/settings/identity.png").scaledToHeight(headLayout.sizeHint().height(), Qt::SmoothTransformation)); - label.setText(tr("Your identity")); + bodyUI = new Ui::IdentitySettings; + bodyUI->setupUi(this); - // public - publicGroup = new QGroupBox(tr("Public Information")); - userNameLabel = new QLabel(tr("Name","Username/nick")); - userName = new QLineEdit(); - - statusMessageLabel = new QLabel(tr("Status","Status message")); - statusMessage = new QLineEdit(); - - vLayout = new QVBoxLayout(); - vLayout->addWidget(userNameLabel); - vLayout->addWidget(userName); - vLayout->addWidget(statusMessageLabel); - vLayout->addWidget(statusMessage); - publicGroup->setLayout(vLayout); - // tox - toxGroup = new QGroupBox(tr("Tox ID")); - toxIdLabel = new CroppingLabel(); - toxIdLabel->setText(tr("Your Tox ID (click to copy)")); toxId = new ClickableTE(); QFont small; small.setPixelSize(13); small.setKerning(false); + toxId->setTextInteractionFlags(Qt::TextSelectableByMouse); toxId->setReadOnly(true); toxId->setFrameStyle(QFrame::NoFrame); @@ -58,20 +43,12 @@ IdentityForm::IdentityForm() toxId->setFixedHeight(toxId->document()->size().height()*2); toxId->setFont(small); - QVBoxLayout* toxLayout = new QVBoxLayout(); - toxLayout->addWidget(toxIdLabel); - toxLayout->addWidget(toxId); - toxGroup->setLayout(toxLayout); + bodyUI->toxGroup->layout()->addWidget(toxId); - layout.setSpacing(30); - layout.addWidget(publicGroup); - layout.addWidget(toxGroup); - layout.addStretch(1); - - connect(toxIdLabel, SIGNAL(clicked()), this, SLOT(copyIdClicked())); + connect(bodyUI->toxIdLabel, SIGNAL(clicked()), this, SLOT(copyIdClicked())); connect(toxId, SIGNAL(clicked()), this, SLOT(copyIdClicked())); - connect(userName, SIGNAL(editingFinished()), this, SLOT(onUserNameEdited())); - connect(statusMessage, SIGNAL(editingFinished()), this, SLOT(onStatusMessageEdited())); + connect(bodyUI->userName, SIGNAL(editingFinished()), this, SLOT(onUserNameEdited())); + connect(bodyUI->statusMessage, SIGNAL(editingFinished()), this, SLOT(onStatusMessageEdited())); } IdentityForm::~IdentityForm() @@ -88,18 +65,28 @@ void IdentityForm::copyIdClicked() void IdentityForm::onUserNameEdited() { - emit userNameChanged(userName->text()); + emit userNameChanged(bodyUI->userName->text()); } void IdentityForm::onStatusMessageEdited() { - emit statusMessageChanged(statusMessage->text()); + emit statusMessageChanged(bodyUI->statusMessage->text()); } void IdentityForm::show(SettingsWidget& sw) { - userName->setText(Core::getInstance()->getUsername()); - statusMessage->setText(Core::getInstance()->getStatusMessage()); + bodyUI->userName->setText(Core::getInstance()->getUsername()); + bodyUI->statusMessage->setText(Core::getInstance()->getStatusMessage()); toxId->setText(Core::getInstance()->getSelfId().toString()); GenericForm::show(sw); } + +void IdentityForm::setUserName(const QString &name) +{ + bodyUI->userName->setText(name); +} + +void IdentityForm::setStatusMessage(const QString &msg) +{ + bodyUI->statusMessage->setText(msg); +} diff --git a/widget/form/settings/identityform.h b/widget/form/settings/identityform.h index 8e80e0aaf..0cacb4dc7 100644 --- a/widget/form/settings/identityform.h +++ b/widget/form/settings/identityform.h @@ -21,8 +21,14 @@ #include #include #include +#include + class CroppingLabel; +namespace Ui { +class IdentitySettings; +} + class ClickableTE : public QTextEdit { Q_OBJECT @@ -41,7 +47,8 @@ public: IdentityForm(); ~IdentityForm(); - QLineEdit* userName, * statusMessage; + void setUserName(const QString &name); + void setStatusMessage(const QString &msg); void show(SettingsWidget& sw); @@ -55,11 +62,9 @@ private slots: void onStatusMessageEdited(); private: - QGroupBox* toxGroup, * publicGroup; + Ui::IdentitySettings* bodyUI; + ClickableTE* toxId; - QLabel* userNameLabel, * statusMessageLabel; - CroppingLabel* toxIdLabel; - QVBoxLayout* vLayout, * toxLayout; }; #endif diff --git a/widget/form/settings/privacyform.cpp b/widget/form/settings/privacyform.cpp index 683bdff4b..c51dc0878 100644 --- a/widget/form/settings/privacyform.cpp +++ b/widget/form/settings/privacyform.cpp @@ -17,10 +17,9 @@ #include "privacyform.h" #include "widget/form/settingswidget.h" -PrivacyForm::PrivacyForm() +PrivacyForm::PrivacyForm() : + GenericForm(tr("Privacy settings"), QPixmap(":/img/settings/privacy.png")) { - icon.setPixmap(QPixmap(":/img/settings/privacy.png").scaledToHeight(headLayout.sizeHint().height(), Qt::SmoothTransformation)); - label.setText(tr("Privacy settings")); } PrivacyForm::~PrivacyForm() diff --git a/widget/form/settingswidget.cpp b/widget/form/settingswidget.cpp index f82e1a689..047c5aaac 100644 --- a/widget/form/settingswidget.cpp +++ b/widget/form/settingswidget.cpp @@ -22,37 +22,30 @@ #include "widget/form/settings/identityform.h" #include "widget/form/settings/privacyform.h" #include "widget/form/settings/avform.h" +#include -SettingsWidget::SettingsWidget(Camera* cam) - : QWidget() +SettingsWidget::SettingsWidget(Camera* cam, QWidget* parent) + : QWidget(parent) { - generalForm = new GeneralForm(); - identityForm = new IdentityForm(); - privacyForm = new PrivacyForm(); - avForm = new AVForm(cam); - - 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(); - mainLayout->addWidget(body); - mainLayout->addWidget(foot); - // something something foot size - 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; + + QVBoxLayout *bodyLayout = new QVBoxLayout(); + body->setLayout(bodyLayout); + + QTabWidget *settingsTabs = new QTabWidget(); + bodyLayout->addWidget(settingsTabs); + + GeneralForm *gfrm = new GeneralForm; + ifrm = new IdentityForm; + PrivacyForm *pfrm = new PrivacyForm; + AVForm *avfrm = new AVForm(cam); + + GenericForm *cfgForms[] = {gfrm, ifrm, pfrm, avfrm}; + for (auto cfgForm : cfgForms) + { + settingsTabs->addTab(cfgForm, cfgForm->getFormIcon(), cfgForm->getFormName()); + } } SettingsWidget::~SettingsWidget() @@ -61,173 +54,8 @@ SettingsWidget::~SettingsWidget() void SettingsWidget::show(Ui::MainWindow& ui) { - active->show(*this); - ui.mainContent->layout()->addWidget(main); + ui.mainContent->layout()->addWidget(body); ui.mainHead->layout()->addWidget(head); - main->show(); + body->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 - // just straight up copying it like this... oh well - // the layout/icons obviously need to be improved, but it's a working model, - // not a pretty one - QSizePolicy sizePolicy3(QSizePolicy::Fixed, QSizePolicy::Fixed); - sizePolicy3.setHorizontalStretch(0); - sizePolicy3.setVerticalStretch(0); - foot->setObjectName(QStringLiteral("foot")); - foot->setEnabled(true); - foot->setSizePolicy(sizePolicy3); - QPalette palette5; - QBrush brush(QColor(255, 255, 255, 255)); - brush.setStyle(Qt::SolidPattern); - QBrush brush1(QColor(28, 28, 28, 255)); - brush1.setStyle(Qt::SolidPattern); - QBrush brush2(QColor(42, 42, 42, 255)); - brush2.setStyle(Qt::SolidPattern); - QBrush brush3(QColor(35, 35, 35, 255)); - brush3.setStyle(Qt::SolidPattern); - QBrush brush4(QColor(14, 14, 14, 255)); - brush4.setStyle(Qt::SolidPattern); - QBrush brush5(QColor(18, 18, 18, 255)); - brush5.setStyle(Qt::SolidPattern); - QBrush brush6(QColor(0, 0, 0, 255)); - brush6.setStyle(Qt::SolidPattern); - QBrush brush7(QColor(255, 255, 220, 255)); - brush7.setStyle(Qt::SolidPattern); - palette5.setBrush(QPalette::Active, QPalette::WindowText, brush); - palette5.setBrush(QPalette::Active, QPalette::Button, brush1); - palette5.setBrush(QPalette::Active, QPalette::Light, brush2); - palette5.setBrush(QPalette::Active, QPalette::Midlight, brush3); - palette5.setBrush(QPalette::Active, QPalette::Dark, brush4); - palette5.setBrush(QPalette::Active, QPalette::Mid, brush5); - palette5.setBrush(QPalette::Active, QPalette::Text, brush); - palette5.setBrush(QPalette::Active, QPalette::BrightText, brush); - palette5.setBrush(QPalette::Active, QPalette::ButtonText, brush); - palette5.setBrush(QPalette::Active, QPalette::Base, brush6); - palette5.setBrush(QPalette::Active, QPalette::Window, brush1); - palette5.setBrush(QPalette::Active, QPalette::Shadow, brush6); - palette5.setBrush(QPalette::Active, QPalette::AlternateBase, brush4); - palette5.setBrush(QPalette::Active, QPalette::ToolTipBase, brush7); - palette5.setBrush(QPalette::Active, QPalette::ToolTipText, brush6); - palette5.setBrush(QPalette::Inactive, QPalette::WindowText, brush); - palette5.setBrush(QPalette::Inactive, QPalette::Button, brush1); - palette5.setBrush(QPalette::Inactive, QPalette::Light, brush2); - palette5.setBrush(QPalette::Inactive, QPalette::Midlight, brush3); - palette5.setBrush(QPalette::Inactive, QPalette::Dark, brush4); - palette5.setBrush(QPalette::Inactive, QPalette::Mid, brush5); - palette5.setBrush(QPalette::Inactive, QPalette::Text, brush); - palette5.setBrush(QPalette::Inactive, QPalette::BrightText, brush); - palette5.setBrush(QPalette::Inactive, QPalette::ButtonText, brush); - palette5.setBrush(QPalette::Inactive, QPalette::Base, brush6); - palette5.setBrush(QPalette::Inactive, QPalette::Window, brush1); - palette5.setBrush(QPalette::Inactive, QPalette::Shadow, brush6); - palette5.setBrush(QPalette::Inactive, QPalette::AlternateBase, brush4); - palette5.setBrush(QPalette::Inactive, QPalette::ToolTipBase, brush7); - palette5.setBrush(QPalette::Inactive, QPalette::ToolTipText, brush6); - palette5.setBrush(QPalette::Disabled, QPalette::WindowText, brush4); - palette5.setBrush(QPalette::Disabled, QPalette::Button, brush1); - palette5.setBrush(QPalette::Disabled, QPalette::Light, brush2); - palette5.setBrush(QPalette::Disabled, QPalette::Midlight, brush3); - palette5.setBrush(QPalette::Disabled, QPalette::Dark, brush4); - palette5.setBrush(QPalette::Disabled, QPalette::Mid, brush5); - palette5.setBrush(QPalette::Disabled, QPalette::Text, brush4); - palette5.setBrush(QPalette::Disabled, QPalette::BrightText, brush); - palette5.setBrush(QPalette::Disabled, QPalette::ButtonText, brush4); - palette5.setBrush(QPalette::Disabled, QPalette::Base, brush1); - palette5.setBrush(QPalette::Disabled, QPalette::Window, brush1); - palette5.setBrush(QPalette::Disabled, QPalette::Shadow, brush6); - palette5.setBrush(QPalette::Disabled, QPalette::AlternateBase, brush1); - palette5.setBrush(QPalette::Disabled, QPalette::ToolTipBase, brush7); - palette5.setBrush(QPalette::Disabled, QPalette::ToolTipText, brush6); - foot->setPalette(palette5); - foot->setAutoFillBackground(true); - - iconsLayout = new QHBoxLayout(foot); - iconsLayout->setSpacing(0); - iconsLayout->setObjectName(QStringLiteral("iconsLayout")); - iconsLayout->setContentsMargins(0, 0, 0, 0); - - generalButton = new QPushButton(foot); - generalButton->setObjectName(QStringLiteral("generalButton")); - generalButton->setMinimumSize(QSize(55, 35)); - generalButton->setMaximumSize(QSize(55, 35)); - generalButton->setFocusPolicy(Qt::NoFocus); - QIcon icon1; - icon1.addFile(QStringLiteral(":/img/add.png"), QSize(), QIcon::Normal, QIcon::Off); - generalButton->setIcon(icon1); - generalButton->setFlat(true); - iconsLayout->addWidget(generalButton); - - identityButton = new QPushButton(foot); - identityButton->setObjectName(QStringLiteral("identityButton")); - identityButton->setMinimumSize(QSize(55, 35)); - identityButton->setMaximumSize(QSize(55, 35)); - identityButton->setFocusPolicy(Qt::NoFocus); - QIcon icon2; - icon2.addFile(QStringLiteral(":/img/group.png"), QSize(), QIcon::Normal, QIcon::Off); - identityButton->setIcon(icon2); - identityButton->setFlat(true); - iconsLayout->addWidget(identityButton); - - privacyButton = new QPushButton(foot); - privacyButton->setObjectName(QStringLiteral("privacyButton")); - privacyButton->setMinimumSize(QSize(55, 35)); - privacyButton->setMaximumSize(QSize(55, 35)); - privacyButton->setFocusPolicy(Qt::NoFocus); - QIcon icon3; - icon3.addFile(QStringLiteral(":/img/transfer.png"), QSize(), QIcon::Normal, QIcon::Off); - privacyButton->setIcon(icon3); - privacyButton->setFlat(true); - iconsLayout->addWidget(privacyButton); - - avButton = new QPushButton(foot); - avButton->setObjectName(QStringLiteral("avButton")); - avButton->setMinimumSize(QSize(55, 35)); - avButton->setMaximumSize(QSize(55, 35)); - avButton->setFocusPolicy(Qt::NoFocus); - QIcon icon4; - icon4.addFile(QStringLiteral(":/img/settings.png"), QSize(), QIcon::Normal, QIcon::Off); - avButton->setIcon(icon4); - avButton->setFlat(true); - iconsLayout->addWidget(avButton); -} diff --git a/widget/form/settingswidget.h b/widget/form/settingswidget.h index b24f7ffb6..552af5104 100644 --- a/widget/form/settingswidget.h +++ b/widget/form/settingswidget.h @@ -25,47 +25,22 @@ class GeneralForm; class IdentityForm; class PrivacyForm; class AVForm; -namespace Ui {class MainWindow;}; + +namespace Ui {class MainWindow;} class SettingsWidget : public QWidget { Q_OBJECT public: - SettingsWidget(Camera* cam); + SettingsWidget(Camera* cam, QWidget* parent = nullptr); ~SettingsWidget(); void show(Ui::MainWindow &ui); - - QWidget *head, *body; // keep the others private - GenericForm* active; - GeneralForm* generalForm; - IdentityForm* identityForm; - PrivacyForm* privacyForm; - AVForm* avForm; - -public slots: - //void setFriendAddress(const QString& friendAddress); - -private slots: - void onGeneralClicked(); - void onIdentityClicked(); - void onPrivacyClicked(); - void onAVClicked(); + IdentityForm *getIdentityForm() {return ifrm;} private: - QWidget *main, *foot; - // main consists of body+foot for Ui::MainWindow - QVBoxLayout *mainLayout; - - 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; - void prepButtons(); // just so I can move the crap to the bottom of the file + QWidget *head, *body; // keep the others private + IdentityForm *ifrm; }; #endif // SETTINGSWIDGET_H diff --git a/widget/widget.cpp b/widget/widget.cpp index a6730ec44..46e3e5d09 100644 --- a/widget/widget.cpp +++ b/widget/widget.cpp @@ -218,9 +218,9 @@ Widget::Widget(QWidget *parent) connect(ui->nameLabel, SIGNAL(textChanged(QString,QString)), this, SLOT(onUsernameChanged(QString,QString))); connect(ui->statusLabel, SIGNAL(textChanged(QString,QString)), this, SLOT(onStatusMessageChanged(QString,QString))); connect(profilePicture, SIGNAL(clicked()), this, SLOT(onAvatarClicked())); - connect(settingsWidget->identityForm, &IdentityForm::userNameChanged, core, &Core::setUsername); - connect(settingsWidget->identityForm, &IdentityForm::statusMessageChanged, core, &Core::setStatusMessage); connect(setStatusOnline, SIGNAL(triggered()), this, SLOT(setStatusOnline())); +// connect(settingsWidget->getIdentityForm(), &IdentityForm::userNameChanged, Core::getInstance(), &Core::setUsername); +// connect(settingsWidget->getIdentityForm(), &IdentityForm::statusMessageChanged, Core::getInstance(), &Core::setStatusMessage); connect(setStatusAway, SIGNAL(triggered()), this, SLOT(setStatusAway())); connect(setStatusBusy, SIGNAL(triggered()), this, SLOT(setStatusBusy())); connect(&friendForm, SIGNAL(friendRequested(QString,QString)), this, SIGNAL(friendRequested(QString,QString))); @@ -428,7 +428,7 @@ void Widget::setUsername(const QString& username) { ui->nameLabel->setText(username); ui->nameLabel->setToolTip(username); // for overlength names - settingsWidget->identityForm->userName->setText(username); + settingsWidget->getIdentityForm()->setUserName(username); } void Widget::onStatusMessageChanged(const QString& newStatusMessage, const QString& oldStatusMessage) @@ -442,7 +442,7 @@ void Widget::setStatusMessage(const QString &statusMessage) { ui->statusLabel->setText(statusMessage); ui->statusLabel->setToolTip(statusMessage); // for overlength messsages - settingsWidget->identityForm->statusMessage->setText(statusMessage); + settingsWidget->getIdentityForm()->setStatusMessage(statusMessage); } void Widget::addFriend(int friendId, const QString &userId) From 0c2bf63b1aaf0294b7777e7ad78a76a43298f236 Mon Sep 17 00:00:00 2001 From: apprb Date: Mon, 6 Oct 2014 01:17:20 +0900 Subject: [PATCH 20/22] add missed files --- widget/form/settings/generalsettings.ui | 81 ++++++++++++++++++++++ widget/form/settings/identitysettings.ui | 86 ++++++++++++++++++++++++ 2 files changed, 167 insertions(+) create mode 100644 widget/form/settings/generalsettings.ui create mode 100644 widget/form/settings/identitysettings.ui diff --git a/widget/form/settings/generalsettings.ui b/widget/form/settings/generalsettings.ui new file mode 100644 index 000000000..ca01dbc5b --- /dev/null +++ b/widget/form/settings/generalsettings.ui @@ -0,0 +1,81 @@ + + + GeneralSettings + + + + 0 + 0 + 527 + 367 + + + + Form + + + + 15 + + + 15 + + + 15 + + + + + Enable IPv6 (recommended) + + + + + + + Use translations + + + + + + + Save settings to the working directory instead of the usual conf dir + + + Make Tox portable + + + + + + + + + Smiley Pack + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + diff --git a/widget/form/settings/identitysettings.ui b/widget/form/settings/identitysettings.ui new file mode 100644 index 000000000..d27300155 --- /dev/null +++ b/widget/form/settings/identitysettings.ui @@ -0,0 +1,86 @@ + + + IdentitySettings + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + + Public Information + + + + + + Name + + + + + + + + + + Status + + + + + + + + + + + + + Tox ID + + + + + + Your Tox ID (click to copy) + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + CroppingLabel + QLabel +
widget/croppinglabel.h
+
+
+ + +
From 866f986d04e7605b79a0b282e302f47d082bc1f0 Mon Sep 17 00:00:00 2001 From: apprb Date: Mon, 6 Oct 2014 01:30:31 +0900 Subject: [PATCH 21/22] small fixes --- widget/form/settings/genericsettings.h | 9 +-------- widget/form/settings/identityform.cpp | 10 ++++------ widget/form/settings/identityform.h | 2 +- widget/form/settingswidget.cpp | 9 ++++++++- widget/form/settingswidget.h | 5 +++++ 5 files changed, 19 insertions(+), 16 deletions(-) diff --git a/widget/form/settings/genericsettings.h b/widget/form/settings/genericsettings.h index e3852ee28..e79ec7b06 100644 --- a/widget/form/settings/genericsettings.h +++ b/widget/form/settings/genericsettings.h @@ -27,14 +27,7 @@ public: GenericForm(const QString &name, const QPixmap &icon) : formName(name), formIcon(icon) {;} ~GenericForm() {;} - virtual void show(SettingsWidget& sw) - { -// sw.body->layout()->addWidget(&body); -// body.show(); -// sw.head->layout()->addWidget(&head); -// head.show(); - } - + virtual void updateContent() {;} QString getFormName() {return formName;} QPixmap getFormIcon() {return formIcon;} diff --git a/widget/form/settings/identityform.cpp b/widget/form/settings/identityform.cpp index bfc231c33..c2dac21b0 100644 --- a/widget/form/settings/identityform.cpp +++ b/widget/form/settings/identityform.cpp @@ -14,6 +14,7 @@ See the COPYING file for more details. */ +#include "core.h" #include "ui_identitysettings.h" #include "identityform.h" #include "widget/form/settingswidget.h" @@ -65,20 +66,17 @@ void IdentityForm::copyIdClicked() void IdentityForm::onUserNameEdited() { - emit userNameChanged(bodyUI->userName->text()); + Core::getInstance()->setUsername(bodyUI->userName->text()); } void IdentityForm::onStatusMessageEdited() { - emit statusMessageChanged(bodyUI->statusMessage->text()); + Core::getInstance()->setStatusMessage(bodyUI->statusMessage->text()); } -void IdentityForm::show(SettingsWidget& sw) +void IdentityForm::updateContent() { - bodyUI->userName->setText(Core::getInstance()->getUsername()); - bodyUI->statusMessage->setText(Core::getInstance()->getStatusMessage()); toxId->setText(Core::getInstance()->getSelfId().toString()); - GenericForm::show(sw); } void IdentityForm::setUserName(const QString &name) diff --git a/widget/form/settings/identityform.h b/widget/form/settings/identityform.h index 0cacb4dc7..c5505e6ea 100644 --- a/widget/form/settings/identityform.h +++ b/widget/form/settings/identityform.h @@ -50,7 +50,7 @@ public: void setUserName(const QString &name); void setStatusMessage(const QString &msg); - void show(SettingsWidget& sw); + virtual void updateContent(); signals: void userNameChanged(QString); diff --git a/widget/form/settingswidget.cpp b/widget/form/settingswidget.cpp index 047c5aaac..b4d208f61 100644 --- a/widget/form/settingswidget.cpp +++ b/widget/form/settingswidget.cpp @@ -33,7 +33,7 @@ SettingsWidget::SettingsWidget(Camera* cam, QWidget* parent) QVBoxLayout *bodyLayout = new QVBoxLayout(); body->setLayout(bodyLayout); - QTabWidget *settingsTabs = new QTabWidget(); + settingsTabs = new QTabWidget(); bodyLayout->addWidget(settingsTabs); GeneralForm *gfrm = new GeneralForm; @@ -46,6 +46,8 @@ SettingsWidget::SettingsWidget(Camera* cam, QWidget* parent) { settingsTabs->addTab(cfgForm, cfgForm->getFormIcon(), cfgForm->getFormName()); } + + connect(settingsTabs, SIGNAL(currentChanged(int)), this, SLOT(onTabChanged(int))); } SettingsWidget::~SettingsWidget() @@ -59,3 +61,8 @@ void SettingsWidget::show(Ui::MainWindow& ui) body->show(); head->show(); } + +void SettingsWidget::onTabChanged(int index) +{ + static_cast(this->settingsTabs->widget(index))->updateContent(); +} diff --git a/widget/form/settingswidget.h b/widget/form/settingswidget.h index 552af5104..713eddde8 100644 --- a/widget/form/settingswidget.h +++ b/widget/form/settingswidget.h @@ -25,6 +25,7 @@ class GeneralForm; class IdentityForm; class PrivacyForm; class AVForm; +class QTabWidget; namespace Ui {class MainWindow;} @@ -38,9 +39,13 @@ public: void show(Ui::MainWindow &ui); IdentityForm *getIdentityForm() {return ifrm;} +private slots: + void onTabChanged(int); + private: QWidget *head, *body; // keep the others private IdentityForm *ifrm; + QTabWidget *settingsTabs; }; #endif // SETTINGSWIDGET_H From 35aeca5dd05ea50aa17207821cd5b59f5766e87e Mon Sep 17 00:00:00 2001 From: apprb Date: Mon, 6 Oct 2014 03:02:12 +0900 Subject: [PATCH 22/22] cosmetic fixes --- widget/form/settings/generalsettings.ui | 74 +++++++++++++++---------- widget/form/settings/identityform.cpp | 10 ++-- widget/form/settings/identityform.h | 2 +- widget/form/settingswidget.cpp | 42 +++++++++++--- widget/form/settingswidget.h | 8 ++- 5 files changed, 89 insertions(+), 47 deletions(-) diff --git a/widget/form/settings/generalsettings.ui b/widget/form/settings/generalsettings.ui index ca01dbc5b..902d41039 100644 --- a/widget/form/settings/generalsettings.ui +++ b/widget/form/settings/generalsettings.ui @@ -24,43 +24,57 @@ 15
- - - Enable IPv6 (recommended) + + + General Settings + + + + + Enable IPv6 (recommended) + + + + + + + Use translations + + + + + + + Save settings to the working directory instead of the usual conf dir + + + Make Tox portable + + + + - - - Use translations + + + Theme + + + + + Smiley Pack + + + + + + + - - - - Save settings to the working directory instead of the usual conf dir - - - Make Tox portable - - - - - - - - - Smiley Pack - - - - - - - - diff --git a/widget/form/settings/identityform.cpp b/widget/form/settings/identityform.cpp index c2dac21b0..5aff0e513 100644 --- a/widget/form/settings/identityform.cpp +++ b/widget/form/settings/identityform.cpp @@ -37,11 +37,11 @@ IdentityForm::IdentityForm() : small.setPixelSize(13); small.setKerning(false); - toxId->setTextInteractionFlags(Qt::TextSelectableByMouse); +// toxId->setTextInteractionFlags(Qt::TextSelectableByMouse); toxId->setReadOnly(true); - toxId->setFrameStyle(QFrame::NoFrame); - toxId->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - toxId->setFixedHeight(toxId->document()->size().height()*2); +// toxId->setFrameStyle(QFrame::NoFrame); +// toxId->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); +// toxId->setFixedHeight(toxId->document()->size().height()*2); toxId->setFont(small); bodyUI->toxGroup->layout()->addWidget(toxId); @@ -59,7 +59,7 @@ IdentityForm::~IdentityForm() void IdentityForm::copyIdClicked() { toxId->selectAll(); - QString txt = toxId->toPlainText(); + QString txt = toxId->text(); txt.replace('\n',""); QApplication::clipboard()->setText(txt); } diff --git a/widget/form/settings/identityform.h b/widget/form/settings/identityform.h index c5505e6ea..2a4b07a77 100644 --- a/widget/form/settings/identityform.h +++ b/widget/form/settings/identityform.h @@ -29,7 +29,7 @@ namespace Ui { class IdentitySettings; } -class ClickableTE : public QTextEdit +class ClickableTE : public QLineEdit { Q_OBJECT public: diff --git a/widget/form/settingswidget.cpp b/widget/form/settingswidget.cpp index b4d208f61..434513004 100644 --- a/widget/form/settingswidget.cpp +++ b/widget/form/settingswidget.cpp @@ -22,19 +22,35 @@ #include "widget/form/settings/identityform.h" #include "widget/form/settings/privacyform.h" #include "widget/form/settings/avform.h" -#include +#include +#include SettingsWidget::SettingsWidget(Camera* cam, QWidget* parent) : QWidget(parent) { - body = new QWidget(); - head = new QWidget(); - + body = new QWidget(this); QVBoxLayout *bodyLayout = new QVBoxLayout(); body->setLayout(bodyLayout); - settingsTabs = new QTabWidget(); - bodyLayout->addWidget(settingsTabs); + head = new QWidget(this); + QHBoxLayout *headLayout = new QHBoxLayout(); + head->setLayout(headLayout); + + imgLabel = new QLabel(); + headLayout->addWidget(imgLabel); + + nameLabel = new QLabel(); + QFont bold; + bold.setBold(true); + nameLabel->setFont(bold); + headLayout->addWidget(nameLabel); + headLayout->addStretch(1); + + settingsWidgets = new QStackedWidget; + bodyLayout->addWidget(settingsWidgets); + + tabBar = new QTabBar; + bodyLayout->addWidget(tabBar); GeneralForm *gfrm = new GeneralForm; ifrm = new IdentityForm; @@ -44,10 +60,13 @@ SettingsWidget::SettingsWidget(Camera* cam, QWidget* parent) GenericForm *cfgForms[] = {gfrm, ifrm, pfrm, avfrm}; for (auto cfgForm : cfgForms) { - settingsTabs->addTab(cfgForm, cfgForm->getFormIcon(), cfgForm->getFormName()); + tabBar->addTab(cfgForm->getFormIcon(), ""); + settingsWidgets->addWidget(cfgForm); } + tabBar->setIconSize(QSize(20, 20)); + tabBar->setShape(QTabBar::RoundedSouth); - connect(settingsTabs, SIGNAL(currentChanged(int)), this, SLOT(onTabChanged(int))); + connect(tabBar, SIGNAL(currentChanged(int)), this, SLOT(onTabChanged(int))); } SettingsWidget::~SettingsWidget() @@ -60,9 +79,14 @@ void SettingsWidget::show(Ui::MainWindow& ui) ui.mainHead->layout()->addWidget(head); body->show(); head->show(); + onTabChanged(tabBar->currentIndex()); } void SettingsWidget::onTabChanged(int index) { - static_cast(this->settingsTabs->widget(index))->updateContent(); + this->settingsWidgets->setCurrentIndex(index); + GenericForm *currentWidget = static_cast(this->settingsWidgets->widget(index)); + currentWidget->updateContent(); + nameLabel->setText(currentWidget->getFormName()); + imgLabel->setPixmap(currentWidget->getFormIcon().scaledToHeight(40, Qt::SmoothTransformation)); } diff --git a/widget/form/settingswidget.h b/widget/form/settingswidget.h index 713eddde8..431e52c1c 100644 --- a/widget/form/settingswidget.h +++ b/widget/form/settingswidget.h @@ -25,7 +25,9 @@ class GeneralForm; class IdentityForm; class PrivacyForm; class AVForm; -class QTabWidget; +class QTabBar; +class QStackedWidget; +class QLabel; namespace Ui {class MainWindow;} @@ -45,7 +47,9 @@ private slots: private: QWidget *head, *body; // keep the others private IdentityForm *ifrm; - QTabWidget *settingsTabs; + QStackedWidget *settingsWidgets; + QTabBar *tabBar; + QLabel *nameLabel, *imgLabel; }; #endif // SETTINGSWIDGET_H