From 863c46c73d1a2fc677f9142ba8d7a2e8dc659c2a Mon Sep 17 00:00:00 2001 From: TriKriSta Date: Sun, 4 Feb 2018 16:17:55 +0200 Subject: [PATCH] feat: add form for search --- CMakeLists.txt | 2 + res.qrc | 2 + src/widget/chatformheader.cpp | 11 ++++ src/widget/chatformheader.h | 1 + src/widget/form/chatform.cpp | 9 +++- src/widget/form/genericchatform.cpp | 4 ++ src/widget/form/genericchatform.h | 2 + src/widget/searchform.cpp | 28 ++++++++++ src/widget/searchform.h | 21 ++++++++ ui/chatForm/buttons.css | 19 +++++++ ui/chatForm/searchDownButton.svg | 82 +++++++++++++++++++++++++++++ ui/chatForm/searchUpButton.svg | 82 +++++++++++++++++++++++++++++ 12 files changed, 262 insertions(+), 1 deletion(-) create mode 100644 src/widget/searchform.cpp create mode 100644 src/widget/searchform.h create mode 100644 ui/chatForm/searchDownButton.svg create mode 100644 ui/chatForm/searchUpButton.svg diff --git a/CMakeLists.txt b/CMakeLists.txt index ef2ba42d0..37ee8aca9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -341,6 +341,8 @@ set(${PROJECT_NAME}_SOURCES src/widget/emoticonswidget.h src/widget/flowlayout.cpp src/widget/flowlayout.h + src/widget/searchform.cpp + src/widget/searchform.h src/widget/form/addfriendform.cpp src/widget/form/addfriendform.h src/widget/form/chatform.cpp diff --git a/res.qrc b/res.qrc index 934829e45..d68c3caf7 100644 --- a/res.qrc +++ b/res.qrc @@ -96,5 +96,7 @@ ui/contentDialog/contentDialog.css ui/tooliconsZone/tooliconsZone.css ui/chatForm/searchButton.svg + ui/chatForm/searchDownButton.svg + ui/chatForm/searchUpButton.svg diff --git a/src/widget/chatformheader.cpp b/src/widget/chatformheader.cpp index 09c3b1644..508df880a 100644 --- a/src/widget/chatformheader.cpp +++ b/src/widget/chatformheader.cpp @@ -281,6 +281,17 @@ void ChatFormHeader::updateMuteVolButton(bool active, bool outputMuted) updateButtonsView(); } +void ChatFormHeader::updateSearchButton(bool active) +{ + if (active) { + searchState = ToolButtonState::On; + } else { + searchState = ToolButtonState::Off; + } + + updateButtonsView(); +} + void ChatFormHeader::setAvatar(const QPixmap &img) { avatar->setPixmap(img); diff --git a/src/widget/chatformheader.h b/src/widget/chatformheader.h index 0ab7f9200..8fbc0d125 100644 --- a/src/widget/chatformheader.h +++ b/src/widget/chatformheader.h @@ -67,6 +67,7 @@ public: void updateCallButtons(bool online, bool audio, bool video = false); void updateMuteMicButton(bool active, bool inputMuted); void updateMuteVolButton(bool active, bool outputMuted); + void updateSearchButton(bool active); void setAvatar(const QPixmap& img); QSize getAvatarSize() const; diff --git a/src/widget/form/chatform.cpp b/src/widget/form/chatform.cpp index 4b23d4748..226217705 100644 --- a/src/widget/form/chatform.cpp +++ b/src/widget/form/chatform.cpp @@ -41,6 +41,7 @@ #include "src/widget/tool/screenshotgrabber.h" #include "src/widget/translator.h" #include "src/widget/widget.h" +#include "src/widget/searchform.h" #include #include @@ -491,7 +492,13 @@ void ChatForm::onVolMuteToggle() void ChatForm::onSearchTrigered() { - + if (searchForm->maximumHeight() == 0) { + searchForm->setMaximumHeight(50); + headWidget->updateSearchButton(true); + } else { + searchForm->setMaximumHeight(0); + headWidget->updateSearchButton(false); + } } void ChatForm::onFileSendFailed(uint32_t friendId, const QString& fname) diff --git a/src/widget/form/genericchatform.cpp b/src/widget/form/genericchatform.cpp index bc079c431..b5a018b2e 100644 --- a/src/widget/form/genericchatform.cpp +++ b/src/widget/form/genericchatform.cpp @@ -39,6 +39,7 @@ #include "src/widget/tool/flyoutoverlaywidget.h" #include "src/widget/translator.h" #include "src/widget/widget.h" +#include "src/widget/searchform.h" #include #include @@ -135,8 +136,10 @@ GenericChatForm::GenericChatForm(QWidget* parent) { curRow = 0; headWidget = new ChatFormHeader(); + searchForm = new SearchForm(); chatWidget = new ChatLog(this); chatWidget->setBusyNotification(ChatMessage::createBusyNotification()); + searchForm->setMaximumHeight(0); // settings const Settings& s = Settings::getInstance(); @@ -190,6 +193,7 @@ GenericChatForm::GenericChatForm(QWidget* parent) mainFootLayout->setSpacing(0); QVBoxLayout* contentLayout = new QVBoxLayout(contentWidget); + contentLayout->addWidget(searchForm); contentLayout->addWidget(chatWidget); contentLayout->addLayout(mainFootLayout); diff --git a/src/widget/form/genericchatform.h b/src/widget/form/genericchatform.h index a3f34d795..d9eb2307b 100644 --- a/src/widget/form/genericchatform.h +++ b/src/widget/form/genericchatform.h @@ -40,6 +40,7 @@ class CroppingLabel; class FlyoutOverlayWidget; class GenericNetCamView; class MaskablePixmapWidget; +class SearchForm; class Widget; class QLabel; @@ -151,6 +152,7 @@ protected: ChatFormHeader* headWidget; + SearchForm *searchForm; ChatLog* chatWidget; ChatTextEdit* msgEdit; FlyoutOverlayWidget* fileFlyout; diff --git a/src/widget/searchform.cpp b/src/widget/searchform.cpp new file mode 100644 index 000000000..79be2701a --- /dev/null +++ b/src/widget/searchform.cpp @@ -0,0 +1,28 @@ +#include "searchform.h" +#include "src/widget/style.h" +#include +#include +#include + +SearchForm::SearchForm(QWidget *parent) : QWidget(parent) +{ + QHBoxLayout *layout = new QHBoxLayout(); + searchLine = new QLineEdit(); + upButton = new QPushButton(); + upButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); + upButton->setObjectName("searchUpButton"); + upButton->setProperty("state", "green"); + upButton->setStyleSheet(Style::getStylesheet(QStringLiteral(":/ui/chatForm/buttons.css"))); + + downButton = new QPushButton(); + downButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); + downButton->setObjectName("searchDownButton"); + downButton->setProperty("state", "green"); + downButton->setStyleSheet(Style::getStylesheet(QStringLiteral(":/ui/chatForm/buttons.css"))); + + layout->addWidget(searchLine); + layout->addWidget(upButton); + layout->addWidget(downButton); + + setLayout(layout); +} diff --git a/src/widget/searchform.h b/src/widget/searchform.h new file mode 100644 index 000000000..7aedfa4b7 --- /dev/null +++ b/src/widget/searchform.h @@ -0,0 +1,21 @@ +#ifndef SEARCHFORM_H +#define SEARCHFORM_H + +#include + +class QPushButton; +class QLineEdit; + +class SearchForm final : public QWidget +{ + Q_OBJECT +public: + explicit SearchForm(QWidget *parent = nullptr); + +private: + QPushButton* upButton; + QPushButton* downButton; + QLineEdit* searchLine; +}; + +#endif // SEARCHFORM_H diff --git a/ui/chatForm/buttons.css b/ui/chatForm/buttons.css index 11f19b32c..759ae87fb 100644 --- a/ui/chatForm/buttons.css +++ b/ui/chatForm/buttons.css @@ -75,6 +75,25 @@ QAbstractButton#searchButton height: 40px; } +/* SearchLine */ + + +QAbstractButton#searchUpButton +{ + background-image: url(":/ui/chatForm/searchUpButton.svg"); + border-radius: 5px; + width: 35px; + height: 35px; +} + +QAbstractButton#searchDownButton +{ + background-image: url(":/ui/chatForm/searchDownButton.svg"); + border-radius: 5px; + width: 35px; + height: 35px; +} + /* Common */ QAbstractButton diff --git a/ui/chatForm/searchDownButton.svg b/ui/chatForm/searchDownButton.svg new file mode 100644 index 000000000..e99f985c5 --- /dev/null +++ b/ui/chatForm/searchDownButton.svg @@ -0,0 +1,82 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + diff --git a/ui/chatForm/searchUpButton.svg b/ui/chatForm/searchUpButton.svg new file mode 100644 index 000000000..20fdf3732 --- /dev/null +++ b/ui/chatForm/searchUpButton.svg @@ -0,0 +1,82 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + +