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

feat: create widget for search settings

This commit is contained in:
TriKriSta 2018-06-16 13:41:31 +03:00
parent 535ffb5c4d
commit 87b340f4a1
10 changed files with 368 additions and 10 deletions

View File

@ -102,6 +102,7 @@ qt5_wrap_ui(${PROJECT_NAME}_FORMS
src/widget/form/loadhistorydialog.ui src/widget/form/loadhistorydialog.ui
src/widget/form/profileform.ui src/widget/form/profileform.ui
src/widget/form/removefrienddialog.ui src/widget/form/removefrienddialog.ui
src/widget/form/searchsettingsform.ui
src/widget/form/setpassworddialog.ui src/widget/form/setpassworddialog.ui
src/widget/form/settings/aboutsettings.ui src/widget/form/settings/aboutsettings.ui
src/widget/form/settings/advancedsettings.ui src/widget/form/settings/advancedsettings.ui
@ -368,6 +369,8 @@ set(${PROJECT_NAME}_SOURCES
src/widget/form/loadhistorydialog.h src/widget/form/loadhistorydialog.h
src/widget/form/profileform.cpp src/widget/form/profileform.cpp
src/widget/form/profileform.h src/widget/form/profileform.h
src/widget/form/searchsettingsform.cpp
src/widget/form/searchsettingsform.h
src/widget/form/setpassworddialog.cpp src/widget/form/setpassworddialog.cpp
src/widget/form/setpassworddialog.h src/widget/form/setpassworddialog.h
src/widget/form/settings/aboutform.cpp src/widget/form/settings/aboutform.cpp

View File

@ -68,6 +68,7 @@
<file>ui/chatForm/screenshotButton.svg</file> <file>ui/chatForm/screenshotButton.svg</file>
<file>ui/chatForm/searchDownButton.svg</file> <file>ui/chatForm/searchDownButton.svg</file>
<file>ui/chatForm/searchHideButton.svg</file> <file>ui/chatForm/searchHideButton.svg</file>
<file>ui/chatForm/searchSettingsButton.svg</file>
<file>ui/chatForm/searchUpButton.svg</file> <file>ui/chatForm/searchUpButton.svg</file>
<file>ui/chatForm/sendButton.svg</file> <file>ui/chatForm/sendButton.svg</file>
<file>ui/chatForm/exitFullScreenButton.svg</file> <file>ui/chatForm/exitFullScreenButton.svg</file>

View File

@ -0,0 +1,73 @@
#include "searchsettingsform.h"
#include "ui_searchsettingsform.h"
#include "src/widget/style.h"
SearchSettingsForm::SearchSettingsForm(QWidget *parent) :
QWidget(parent),
ui(new Ui::SearchSettingsForm)
{
ui->setupUi(this);
ui->choiceDateButton->setEnabled(false);
ui->startDateLabel->setEnabled(false);
ui->choiceDateButton->setAttribute(Qt::WA_LayoutUsesWidgetRect);
ui->choiceDateButton->setObjectName("choiceDateButton");
ui->choiceDateButton->setStyleSheet(Style::getStylesheet(QStringLiteral(":/ui/chatForm/buttons.css")));
ui->startDateLabel->setStyleSheet("QLabel{color: #ddd;}");
connect(ui->startSearchComboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this, &SearchSettingsForm::onStartSearchSelected);
connect(ui->registerCheckBox, &QCheckBox::clicked, this, &SearchSettingsForm::onRegisterClicked);
connect(ui->wordsOnlyCheckBox, &QCheckBox::clicked, this, &SearchSettingsForm::onWordsOnlyClicked);
connect(ui->regularCheckBox, &QCheckBox::clicked, this, &SearchSettingsForm::onRegularClicked);
}
SearchSettingsForm::~SearchSettingsForm()
{
delete ui;
}
void SearchSettingsForm::onStartSearchSelected(const int index)
{
if (index > 1) {
ui->choiceDateButton->setEnabled(true);
ui->startDateLabel->setEnabled(true);
ui->choiceDateButton->setProperty("state", "green");
ui->choiceDateButton->setStyleSheet(Style::getStylesheet(QStringLiteral(":/ui/chatForm/buttons.css")));
ui->startDateLabel->setStyleSheet("QLabel{color: #000;}");
} else {
ui->choiceDateButton->setEnabled(false);
ui->startDateLabel->setEnabled(false);
ui->choiceDateButton->setProperty("state", "");
ui->choiceDateButton->setStyleSheet(Style::getStylesheet(QStringLiteral(":/ui/chatForm/buttons.css")));
ui->startDateLabel->setStyleSheet("QLabel{color: #ddd;}");
}
}
void SearchSettingsForm::onRegisterClicked(const bool checked)
{
if (checked) {
ui->regularCheckBox->setChecked(false);
}
}
void SearchSettingsForm::onWordsOnlyClicked(const bool checked)
{
if (checked) {
ui->regularCheckBox->setChecked(false);
}
}
void SearchSettingsForm::onRegularClicked(const bool checked)
{
if (checked) {
ui->registerCheckBox->setChecked(false);
ui->wordsOnlyCheckBox->setChecked(false);
}
}

View File

@ -0,0 +1,28 @@
#ifndef SEARCHSETTINGSFORM_H
#define SEARCHSETTINGSFORM_H
#include <QWidget>
namespace Ui {
class SearchSettingsForm;
}
class SearchSettingsForm : public QWidget
{
Q_OBJECT
public:
explicit SearchSettingsForm(QWidget *parent = nullptr);
~SearchSettingsForm();
private:
Ui::SearchSettingsForm *ui;
private slots:
void onStartSearchSelected(const int index);
void onRegisterClicked(const bool checked);
void onWordsOnlyClicked(const bool checked);
void onRegularClicked(const bool checked);
};
#endif // SEARCHSETTINGSFORM_H

View File

@ -0,0 +1,152 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SearchSettingsForm</class>
<widget class="QWidget" name="SearchSettingsForm">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>473</width>
<height>78</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="Line" name="line_2">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Start searching:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="startSearchComboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>with the end</string>
</property>
</item>
<item>
<property name="text">
<string>with the first</string>
</property>
</item>
<item>
<property name="text">
<string>after date</string>
</property>
</item>
<item>
<property name="text">
<string>before date</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QLabel" name="startDateLabel">
<property name="text">
<string>00.00.0000</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="choiceDateButton">
<property name="text">
<string>Choice</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="registerCheckBox">
<property name="text">
<string>Case sensitive</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="wordsOnlyCheckBox">
<property name="text">
<string>Whole words only</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="regularCheckBox">
<property name="text">
<string>Use regular expressions</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="3" column="0">
<widget class="Line" name="line">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -18,25 +18,37 @@
*/ */
#include "searchform.h" #include "searchform.h"
#include "form/searchsettingsform.h"
#include "src/widget/style.h" #include "src/widget/style.h"
#include <QVBoxLayout>
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QPushButton> #include <QPushButton>
#include <QKeyEvent> #include <QKeyEvent>
SearchForm::SearchForm(QWidget* parent) : QWidget(parent) SearchForm::SearchForm(QWidget* parent) : QWidget(parent)
{ {
QHBoxLayout *layout = new QHBoxLayout(); QVBoxLayout* layout = new QVBoxLayout();
QHBoxLayout* layoutNavigation = new QHBoxLayout();
searchLine = new LineEdit(); searchLine = new LineEdit();
settings = new SearchSettingsForm();
settings->setVisible(false);
isActiveSettings = false;
settingsButton = createButton("searchSettingsButton", "green");
upButton = createButton("searchUpButton", "green"); upButton = createButton("searchUpButton", "green");
downButton = createButton("searchDownButton", "green"); downButton = createButton("searchDownButton", "green");
hideButton = createButton("searchHideButton", "red"); hideButton = createButton("searchHideButton", "red");
layout->setMargin(0); layoutNavigation->setMargin(0);
layout->addWidget(searchLine); layoutNavigation->addWidget(settingsButton);
layout->addWidget(upButton); layoutNavigation->addWidget(searchLine);
layout->addWidget(downButton); layoutNavigation->addWidget(upButton);
layout->addWidget(hideButton); layoutNavigation->addWidget(downButton);
layoutNavigation->addWidget(hideButton);
layout->addLayout(layoutNavigation);
layout->addWidget(settings);
setLayout(layout); setLayout(layout);
@ -48,6 +60,7 @@ SearchForm::SearchForm(QWidget* parent) : QWidget(parent)
connect(upButton, &QPushButton::clicked, this, &SearchForm::clickedUp); connect(upButton, &QPushButton::clicked, this, &SearchForm::clickedUp);
connect(downButton, &QPushButton::clicked, this, &SearchForm::clickedDown); connect(downButton, &QPushButton::clicked, this, &SearchForm::clickedDown);
connect(hideButton, &QPushButton::clicked, this, &SearchForm::clickedHide); connect(hideButton, &QPushButton::clicked, this, &SearchForm::clickedHide);
connect(settingsButton, &QPushButton::clicked, this, &SearchForm::clickedSearch);
} }
void SearchForm::removeSearchPhrase() void SearchForm::removeSearchPhrase()
@ -109,6 +122,20 @@ void SearchForm::clickedHide()
emit visibleChanged(); emit visibleChanged();
} }
void SearchForm::clickedSearch()
{
isActiveSettings = !isActiveSettings;
settings->setVisible(isActiveSettings);
if (isActiveSettings) {
settingsButton->setProperty("state", "red");
} else {
settingsButton->setProperty("state", "green");
}
settingsButton->setStyleSheet(Style::getStylesheet(QStringLiteral(":/ui/chatForm/buttons.css")));
settingsButton->update();
}
LineEdit::LineEdit(QWidget* parent) : QLineEdit(parent) LineEdit::LineEdit(QWidget* parent) : QLineEdit(parent)
{ {
} }

View File

@ -25,6 +25,7 @@
class QPushButton; class QPushButton;
class LineEdit; class LineEdit;
class SearchSettingsForm;
class SearchForm final : public QWidget class SearchForm final : public QWidget
{ {
@ -43,18 +44,23 @@ private:
// TODO: Merge with 'createButton' from chatformheader.cpp // TODO: Merge with 'createButton' from chatformheader.cpp
QPushButton* createButton(const QString& name, const QString& state); QPushButton* createButton(const QString& name, const QString& state);
QPushButton* settingsButton;
QPushButton* upButton; QPushButton* upButton;
QPushButton* downButton; QPushButton* downButton;
QPushButton* hideButton; QPushButton* hideButton;
LineEdit* searchLine; LineEdit* searchLine;
SearchSettingsForm* settings;
QString searchPhrase; QString searchPhrase;
bool isActiveSettings;
private slots: private slots:
void changedSearchPhrase(const QString& text); void changedSearchPhrase(const QString& text);
void clickedUp(); void clickedUp();
void clickedDown(); void clickedDown();
void clickedHide(); void clickedHide();
void clickedSearch();
signals: signals:
void searchInBegin(const QString& phrase); void searchInBegin(const QString& phrase);

View File

@ -69,6 +69,14 @@ QAbstractButton#callButton
/* SearchLine */ /* SearchLine */
QAbstractButton#searchSettingsButton
{
background-image: url(":/ui/chatForm/searchSettingsButton.svg");
border-radius: 5px;
width: 35px;
height: 35px;
}
QAbstractButton#searchHideButton QAbstractButton#searchHideButton
{ {
background-image: url(":/ui/chatForm/searchHideButton.svg"); background-image: url(":/ui/chatForm/searchHideButton.svg");
@ -77,7 +85,6 @@ QAbstractButton#searchHideButton
height: 35px; height: 35px;
} }
QAbstractButton#searchUpButton QAbstractButton#searchUpButton
{ {
background-image: url(":/ui/chatForm/searchUpButton.svg"); background-image: url(":/ui/chatForm/searchUpButton.svg");
@ -94,6 +101,14 @@ QAbstractButton#searchDownButton
height: 35px; height: 35px;
} }
QAbstractButton#choiceDateButton
{
border-radius: 5px;
width: 55px;
height: 25px;
color: #fff
}
/* Common */ /* Common */
QAbstractButton QAbstractButton

View File

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="22.608538"
height="22.608543"
viewBox="0 0 22.608539 22.608543"
enable-background="new 0 0 15.615 15.616"
xml:space="preserve"
sodipodi:docname="searchSettingsButton.svg"
inkscape:version="0.92.2 2405546, 2018-03-11"
version="1.1"
id="svg6"><metadata
id="metadata9"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
id="defs7" /><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1169"
inkscape:window-height="745"
id="namedview5"
showgrid="false"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:zoom="15.112705"
inkscape:cx="7.8074999"
inkscape:cy="16.211526"
inkscape:window-x="0"
inkscape:window-y="36"
inkscape:window-maximized="0"
inkscape:current-layer="svg6" />
<path
d="m 22.608538,10.183688 c 0,-0.2852152 -0.236003,-0.5183051 -0.518335,-0.5183051 h -0.955599 c -0.288127,0 -0.589284,-0.2229595 -0.668919,-0.4994838 L 19.168392,6.1371404 C 19.030843,5.889577 19.075722,5.5218341 19.27698,5.3162508 l 0.645756,-0.6442642 c 0.202706,-0.2026848 0.202706,-0.5313344 0,-0.7340239 L 18.369167,2.3830454 c -0.20125,-0.2026859 -0.531372,-0.2026859 -0.738417,0 L 16.931428,3.0837706 C 16.725832,3.2893579 16.353724,3.3443717 16.100349,3.2140707 L 13.46522,2.1571936 C 13.190124,2.0804606 12.96136,1.782216 12.96136,1.4941079 V 0.5168576 C 12.96136,0.2345406 12.728252,0 12.445917,0 H 10.24515 C 9.9599197,0 9.7253655,0.234541 9.7253655,0.5168576 v 0.9772503 c 0,0.2881081 -0.2258667,0.5877995 -0.4980661,0.6732181 L 6.1722829,3.4746724 C 5.9261437,3.61801 5.5612809,3.5702314 5.3571307,3.3704474 l -0.68774,-0.6862637 c -0.1998076,-0.2012533 -0.5313693,-0.2012533 -0.7326241,0 L 2.3817512,4.2405479 c -0.2041499,0.2026848 -0.2041499,0.5313342 0,0.7340239 L 3.1274059,5.7259702 C 3.334452,5.928655 3.3894712,6.299293 3.2562666,6.5512046 L 2.2166937,9.1644505 C 2.1399568,9.4409884 1.8416947,9.6653821 1.5535678,9.6653821 H 0.5168907 C 0.23165972,9.6653796 0,9.8984739 0,10.183688 v 2.199178 c 0,0.286676 0.23165972,0.521202 0.5168907,0.521202 h 1.0366771 c 0.2881267,0 0.5892847,0.222956 0.6718131,0.498035 l 1.2770241,3.005592 c 0.1462352,0.247564 0.094112,0.615306 -0.1042469,0.816548 l -0.7152493,0.713756 c -0.2012548,0.202687 -0.2012548,0.531334 0,0.734023 l 1.5579114,1.554919 c 0.2026997,0.202688 0.5328173,0.202688 0.7311763,0 l 0.7644767,-0.760086 c 0.2041494,-0.202688 0.5704624,-0.256266 0.8252873,-0.120157 l 2.6655348,1.062673 c 0.2722005,0.07961 0.4980661,0.379319 0.4980661,0.663083 v 1.016336 c 0,0.286639 0.2345578,0.519753 0.5197836,0.519753 h 2.200768 c 0.282338,0 0.515445,-0.233097 0.515445,-0.519753 v -1.016343 c 0,-0.283773 0.225867,-0.583454 0.50386,-0.667427 l 2.981172,-1.265359 c 0.249035,-0.140437 0.611003,-0.09123 0.816601,0.108604 l 0.673261,0.677563 c 0.201254,0.20125 0.532818,0.20125 0.734071,0 l 1.557911,-1.557812 c 0.20125,-0.20125 0.20125,-0.532783 0,-0.732578 l -0.719592,-0.71667 c -0.19836,-0.202686 -0.254825,-0.573319 -0.118728,-0.825236 l 1.080113,-2.688527 c 0.0753,-0.275072 0.376445,-0.499484 0.664574,-0.502381 h 0.955595 c 0.282339,0 0.518336,-0.233089 0.518336,-0.518305 z m -11.303545,4.815317 c -2.0429492,0 -3.694972,-1.654813 -3.694972,-3.696183 0,-2.0413696 1.6520228,-3.694736 3.694972,-3.694736 2.040053,0 3.697868,1.6533664 3.697868,3.694736 0,2.04137 -1.657815,3.696183 -3.697868,3.696183 z"
id="path2"
inkscape:connector-curvature="0"
style="fill:#ffffff;stroke-width:1.44782674" />
</svg>

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

@ -14,7 +14,7 @@
viewBox="0 0 7.0183304 4.1245209" viewBox="0 0 7.0183304 4.1245209"
version="1.1" version="1.1"
id="svg8" id="svg8"
inkscape:version="0.92.2 5c3e80d, 2017-08-06" inkscape:version="0.92.2 2405546, 2018-03-11"
sodipodi:docname="searchUpButton.svg"> sodipodi:docname="searchUpButton.svg">
<defs <defs
id="defs2" /> id="defs2" />
@ -38,7 +38,7 @@
inkscape:window-width="1920" inkscape:window-width="1920"
inkscape:window-height="1015" inkscape:window-height="1015"
inkscape:window-x="0" inkscape:window-x="0"
inkscape:window-y="876" inkscape:window-y="36"
inkscape:window-maximized="1" /> inkscape:window-maximized="1" />
<metadata <metadata
id="metadata5"> id="metadata5">
@ -48,7 +48,7 @@
<dc:format>image/svg+xml</dc:format> <dc:format>image/svg+xml</dc:format>
<dc:type <dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title> <dc:title />
</cc:Work> </cc:Work>
</rdf:RDF> </rdf:RDF>
</metadata> </metadata>

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB