Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
feat: add form for search
Browse files Browse the repository at this point in the history
  • Loading branch information
TriKriSta committed Feb 10, 2018
1 parent 47d9da9 commit 863c46c
Show file tree
Hide file tree
Showing 12 changed files with 262 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions res.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,7 @@
<file>ui/contentDialog/contentDialog.css</file>
<file>ui/tooliconsZone/tooliconsZone.css</file>
<file>ui/chatForm/searchButton.svg</file>
<file>ui/chatForm/searchDownButton.svg</file>
<file>ui/chatForm/searchUpButton.svg</file>
</qresource>
</RCC>
11 changes: 11 additions & 0 deletions src/widget/chatformheader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/widget/chatformheader.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class ChatFormHeader : public QWidget
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;
Expand Down
9 changes: 8 additions & 1 deletion src/widget/form/chatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <QClipboard>
#include <QFileDialog>
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions src/widget/form/genericchatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <QClipboard>
#include <QFileDialog>
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);

Expand Down
2 changes: 2 additions & 0 deletions src/widget/form/genericchatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class CroppingLabel;
class FlyoutOverlayWidget;
class GenericNetCamView;
class MaskablePixmapWidget;
class SearchForm;
class Widget;

class QLabel;
Expand Down Expand Up @@ -151,6 +152,7 @@ protected slots:

ChatFormHeader* headWidget;

SearchForm *searchForm;
ChatLog* chatWidget;
ChatTextEdit* msgEdit;
FlyoutOverlayWidget* fileFlyout;
Expand Down
28 changes: 28 additions & 0 deletions src/widget/searchform.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include "searchform.h"
#include "src/widget/style.h"
#include <QHBoxLayout>
#include <QLineEdit>
#include <QPushButton>

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);
}
21 changes: 21 additions & 0 deletions src/widget/searchform.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef SEARCHFORM_H
#define SEARCHFORM_H

#include <QWidget>

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
19 changes: 19 additions & 0 deletions ui/chatForm/buttons.css
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
82 changes: 82 additions & 0 deletions ui/chatForm/searchDownButton.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
82 changes: 82 additions & 0 deletions ui/chatForm/searchUpButton.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 863c46c

Please sign in to comment.