Browse Source

feat: remove search button and add line in context menu

reviewable/pr4955/r2
TriKriSta 8 years ago
parent
commit
8bb80c770c
  1. 2
      res.qrc
  2. 29
      src/widget/chatformheader.cpp
  3. 4
      src/widget/chatformheader.h
  4. 24
      src/widget/form/chatform.cpp
  5. 2
      src/widget/form/chatform.h
  6. 18
      src/widget/form/genericchatform.cpp
  7. 2
      src/widget/form/genericchatform.h
  8. 25
      src/widget/searchform.cpp
  9. 8
      src/widget/searchform.h
  10. 12
      ui/chatForm/buttons.css
  11. 55
      ui/chatForm/hideButton.svg

2
res.qrc

@ -95,8 +95,8 @@ @@ -95,8 +95,8 @@
<file>img/caps_lock.svg</file>
<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>
<file>ui/chatForm/hideButton.svg</file>
</qresource>
</RCC>

29
src/widget/chatformheader.cpp

@ -76,12 +76,6 @@ const QString MIC_TOOL_TIP[] = { @@ -76,12 +76,6 @@ const QString MIC_TOOL_TIP[] = {
ChatFormHeader::tr("Mute microphone"),
};
const QString SEARCH_TOOL_TIP[] = {
ChatFormHeader::tr("Search in text"),
ChatFormHeader::tr("Unmute search"),
ChatFormHeader::tr("Mute search"),
};
template <class T, class Fun>
QPushButton* createButton(const QString& name, T* self, Fun onClickSlot)
{
@ -117,7 +111,6 @@ ChatFormHeader::ChatFormHeader(QWidget* parent) @@ -117,7 +111,6 @@ ChatFormHeader::ChatFormHeader(QWidget* parent)
, videoState{CallButtonState::Disabled}
, volState{ToolButtonState::Disabled}
, micState{ToolButtonState::Disabled}
, searchState{ToolButtonState::Off}
{
QHBoxLayout* headLayout = new QHBoxLayout();
avatar = new MaskablePixmapWidget(this, AVATAR_SIZE, ":/img/avatar_mask.svg");
@ -139,7 +132,6 @@ ChatFormHeader::ChatFormHeader(QWidget* parent) @@ -139,7 +132,6 @@ ChatFormHeader::ChatFormHeader(QWidget* parent)
volButton = createButton("volButton", this, &ChatFormHeader::volMuteToggle);
callButton = createButton("callButton", this, &ChatFormHeader::callTriggered);
videoButton = createButton("videoButton", this, &ChatFormHeader::videoCallTriggered);
searchButton = createButton("searchButton", this, &ChatFormHeader::searchTriggered);
QVBoxLayout* micButtonsLayout = new QVBoxLayout();
micButtonsLayout->setSpacing(MIC_BUTTONS_LAYOUT_SPACING);
@ -147,10 +139,9 @@ ChatFormHeader::ChatFormHeader(QWidget* parent) @@ -147,10 +139,9 @@ ChatFormHeader::ChatFormHeader(QWidget* parent)
micButtonsLayout->addWidget(volButton, Qt::AlignTop | Qt::AlignRight);
QGridLayout* buttonsLayout = new QGridLayout();
buttonsLayout->addWidget(searchButton, 0, 0, 2, 1, Qt::AlignTop);
buttonsLayout->addLayout(micButtonsLayout, 0, 1, 2, 1, Qt::AlignTop | Qt::AlignRight);
buttonsLayout->addWidget(callButton, 0, 2, 2, 1, Qt::AlignTop);
buttonsLayout->addWidget(videoButton, 0, 3, 2, 1, Qt::AlignTop);
buttonsLayout->addLayout(micButtonsLayout, 0, 0, 2, 1, Qt::AlignTop | Qt::AlignRight);
buttonsLayout->addWidget(callButton, 0, 1, 2, 1, Qt::AlignTop);
buttonsLayout->addWidget(videoButton, 0, 2, 2, 1, Qt::AlignTop);
buttonsLayout->setVerticalSpacing(0);
buttonsLayout->setHorizontalSpacing(BUTTONS_LAYOUT_HOR_SPACING);
@ -180,7 +171,6 @@ void ChatFormHeader::setMode(ChatFormHeader::Mode mode) @@ -180,7 +171,6 @@ void ChatFormHeader::setMode(ChatFormHeader::Mode mode)
videoButton->hide();
volButton->hide();
micButton->hide();
searchButton->hide();
}
}
@ -190,7 +180,6 @@ void ChatFormHeader::retranslateUi() @@ -190,7 +180,6 @@ void ChatFormHeader::retranslateUi()
setStateToolTip(videoButton, videoState, VIDEO_TOOL_TIP);
setStateToolTip(micButton, micState, MIC_TOOL_TIP);
setStateToolTip(volButton, volState, VOL_TOOL_TIP);
setStateToolTip(searchButton, searchState, SEARCH_TOOL_TIP);
}
void ChatFormHeader::updateButtonsView()
@ -199,7 +188,6 @@ void ChatFormHeader::updateButtonsView() @@ -199,7 +188,6 @@ void ChatFormHeader::updateButtonsView()
setStateName(videoButton, videoState);
setStateName(micButton, micState);
setStateName(volButton, volState);
setStateName(searchButton, searchState);
retranslateUi();
Style::repolish(this);
}
@ -281,17 +269,6 @@ void ChatFormHeader::updateMuteVolButton(bool active, bool outputMuted) @@ -281,17 +269,6 @@ 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);

4
src/widget/chatformheader.h

@ -67,7 +67,6 @@ public: @@ -67,7 +67,6 @@ 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;
@ -82,7 +81,6 @@ signals: @@ -82,7 +81,6 @@ signals:
void videoCallTriggered();
void micMuteToggle();
void volMuteToggle();
void searchTriggered();
void nameChanged(const QString& name);
@ -104,13 +102,11 @@ private: @@ -104,13 +102,11 @@ private:
QPushButton* videoButton;
QPushButton* volButton;
QPushButton* micButton;
QPushButton* searchButton;
CallButtonState callState;
CallButtonState videoState;
ToolButtonState volState;
ToolButtonState micState;
ToolButtonState searchState;
std::unique_ptr<CallConfirmWidget> callConfirm;
};

24
src/widget/form/chatform.cpp

@ -178,11 +178,11 @@ ChatForm::ChatForm(Friend* chatFriend, History* history) @@ -178,11 +178,11 @@ ChatForm::ChatForm(Friend* chatFriend, History* history)
connect(headWidget, &ChatFormHeader::videoCallTriggered, this, &ChatForm::onVideoCallTriggered);
connect(headWidget, &ChatFormHeader::micMuteToggle, this, &ChatForm::onMicMuteToggle);
connect(headWidget, &ChatFormHeader::volMuteToggle, this, &ChatForm::onVolMuteToggle);
connect(headWidget, &ChatFormHeader::searchTriggered, this, &ChatForm::onSearchTrigered);
connect(searchForm, &SearchForm::searchInBegin, this, &ChatForm::earchInBegin);
connect(searchForm, &SearchForm::searchInBegin, this, &ChatForm::searchInBegin);
connect(searchForm, &SearchForm::searchUp, this, &ChatForm::onSearchUp);
connect(searchForm, &SearchForm::searchDown, this, &ChatForm::onSearchDown);
connect(searchForm, &SearchForm::visibleChanged, this, &ChatForm::onSearchTrigered);
connect(msgEdit, &ChatTextEdit::enterPressed, this, &ChatForm::onSendTriggered);
connect(msgEdit, &ChatTextEdit::textChanged, this, &ChatForm::onTextEditChanged);
@ -498,21 +498,17 @@ void ChatForm::onVolMuteToggle() @@ -498,21 +498,17 @@ void ChatForm::onVolMuteToggle()
void ChatForm::onSearchTrigered()
{
if (searchForm->maximumHeight() == 0) {
searchForm->setMaximumHeight(50);
headWidget->updateSearchButton(true);
searchPoint = QPoint(1, -1);
searchAfterLoadHistory = false;
} else {
searchForm->setMaximumHeight(0);
if (searchForm->isHidden()) {
searchForm->removeSearchPhrase();
headWidget->updateSearchButton(false);
desibleSearchText();
} else {
searchPoint = QPoint(1, -1);
searchAfterLoadHistory = false;
}
}
void ChatForm::earchInBegin(const QString &phrase)
void ChatForm::searchInBegin(const QString &phrase)
{
desibleSearchText();
@ -609,8 +605,12 @@ void ChatForm::onSearchDown(const QString &phrase) @@ -609,8 +605,12 @@ void ChatForm::onSearchDown(const QString &phrase)
}
QVector<ChatLine::Ptr> lines = chatWidget->getLines();
int numLines = lines.size();
if (lines.isEmpty()) {
return;
}
int numLines = lines.size();
int startLine = numLines - searchPoint.x();
for (int i = startLine; i < numLines; ++i) {

2
src/widget/form/chatform.h

@ -89,7 +89,7 @@ private slots: @@ -89,7 +89,7 @@ private slots:
void onVolMuteToggle();
void onSearchTrigered();
void earchInBegin(const QString& phrase);
void searchInBegin(const QString& phrase);
void onSearchUp(const QString& phrase);
void onSearchDown(const QString& phrase);
void onContinueSearch();

18
src/widget/form/genericchatform.cpp

@ -139,7 +139,7 @@ GenericChatForm::GenericChatForm(QWidget* parent) @@ -139,7 +139,7 @@ GenericChatForm::GenericChatForm(QWidget* parent)
searchForm = new SearchForm();
chatWidget = new ChatLog(this);
chatWidget->setBusyNotification(ChatMessage::createBusyNotification());
searchForm->setMaximumHeight(0);
searchForm->hide();
// settings
const Settings& s = Settings::getInstance();
@ -202,6 +202,12 @@ GenericChatForm::GenericChatForm(QWidget* parent) @@ -202,6 +202,12 @@ GenericChatForm::GenericChatForm(QWidget* parent)
addAction(quoteAction);
menu.addSeparator();
searchAction = menu.addAction(QIcon(), QString(), this, SLOT(searchFormShow()),
QKeySequence(Qt::CTRL + Qt::Key_F));
addAction(searchAction);
menu.addSeparator();
menu.addActions(chatWidget->actions());
menu.addSeparator();
@ -297,7 +303,7 @@ void GenericChatForm::showEvent(QShowEvent*) @@ -297,7 +303,7 @@ void GenericChatForm::showEvent(QShowEvent*)
bool GenericChatForm::event(QEvent* e)
{
// If the user accidentally starts typing outside of the msgEdit, focus it automatically
if (searchForm->maximumHeight() == 0) {
if (searchForm->isHidden()) {
if (e->type() == QEvent::KeyRelease && !msgEdit->hasFocus()) {
QKeyEvent* ke = static_cast<QKeyEvent*>(e);
if ((ke->modifiers() == Qt::NoModifier || ke->modifiers() == Qt::ShiftModifier)
@ -668,6 +674,13 @@ void GenericChatForm::copyLink() @@ -668,6 +674,13 @@ void GenericChatForm::copyLink()
QApplication::clipboard()->setText(linkText);
}
void GenericChatForm::searchFormShow()
{
if (searchForm->isHidden()) {
searchForm->show();
}
}
void GenericChatForm::retranslateUi()
{
sendButton->setToolTip(tr("Send message"));
@ -678,6 +691,7 @@ void GenericChatForm::retranslateUi() @@ -678,6 +691,7 @@ void GenericChatForm::retranslateUi()
clearAction->setText(tr("Clear displayed messages"));
quoteAction->setText(tr("Quote selected text"));
copyLinkAction->setText(tr("Copy link address"));
searchAction->setText(tr("Search in text"));
}
void GenericChatForm::showNetcam()

2
src/widget/form/genericchatform.h

@ -103,6 +103,7 @@ protected slots: @@ -103,6 +103,7 @@ protected slots:
void onSplitterMoved(int pos, int index);
void quoteSelectedText();
void copyLink();
void searchFormShow();
private:
void retranslateUi();
@ -134,6 +135,7 @@ protected: @@ -134,6 +135,7 @@ protected:
QAction* clearAction;
QAction* quoteAction;
QAction* copyLinkAction;
QAction* searchAction;
ToxPk previousId;

25
src/widget/searchform.cpp

@ -39,15 +39,24 @@ SearchForm::SearchForm(QWidget *parent) : QWidget(parent) @@ -39,15 +39,24 @@ SearchForm::SearchForm(QWidget *parent) : QWidget(parent)
downButton->setProperty("state", "green");
downButton->setStyleSheet(Style::getStylesheet(QStringLiteral(":/ui/chatForm/buttons.css")));
hideButton = new QPushButton();
hideButton->setAttribute(Qt::WA_LayoutUsesWidgetRect);
hideButton->setObjectName("hideButton");
hideButton->setProperty("state", "red");
hideButton->setStyleSheet(Style::getStylesheet(QStringLiteral(":/ui/chatForm/buttons.css")));
layout->setMargin(0);
layout->addWidget(searchLine);
layout->addWidget(upButton);
layout->addWidget(downButton);
layout->addWidget(hideButton);
setLayout(layout);
connect(searchLine, &QLineEdit::textChanged, this, &SearchForm::changedSearchPhrare);
connect(searchLine, &QLineEdit::textChanged, this, &SearchForm::changedSearchPhrase);
connect(upButton, &QPushButton::clicked, this, &SearchForm::clickedUp);
connect(downButton, &QPushButton::clicked, this, &SearchForm::clickedDown);
connect(hideButton, &QPushButton::clicked, this, &SearchForm::clickedHide);
}
void SearchForm::removeSearchPhrase()
@ -60,7 +69,13 @@ QString SearchForm::getSearchPhrase() const @@ -60,7 +69,13 @@ QString SearchForm::getSearchPhrase() const
return searchPhrase;
}
void SearchForm::changedSearchPhrare(const QString &text)
void SearchForm::showEvent(QShowEvent *event)
{
QWidget::showEvent(event);
emit visibleChanged();
}
void SearchForm::changedSearchPhrase(const QString &text)
{
searchPhrase = text;
emit searchInBegin(searchPhrase);
@ -75,3 +90,9 @@ void SearchForm::clickedDown() @@ -75,3 +90,9 @@ void SearchForm::clickedDown()
{
emit searchDown(searchPhrase);
}
void SearchForm::clickedHide()
{
hide();
emit visibleChanged();
}

8
src/widget/searchform.h

@ -36,19 +36,25 @@ public: @@ -36,19 +36,25 @@ public:
private:
QPushButton* upButton;
QPushButton* downButton;
QPushButton* hideButton;
QLineEdit* searchLine;
QString searchPhrase;
protected:
virtual void showEvent(QShowEvent *event);
private slots:
void changedSearchPhrare(const QString &text);
void changedSearchPhrase(const QString &text);
void clickedUp();
void clickedDown();
void clickedHide();
signals:
void searchInBegin(const QString &);
void searchUp(const QString &);
void searchDown(const QString &);
void visibleChanged();
};
#endif // SEARCHFORM_H

12
ui/chatForm/buttons.css

@ -67,16 +67,16 @@ QAbstractButton#callButton @@ -67,16 +67,16 @@ QAbstractButton#callButton
height: 40px;
}
QAbstractButton#searchButton
/* SearchLine */
QAbstractButton#hideButton
{
background-image: url(":/ui/chatForm/searchButton.svg");
background-image: url(":/ui/chatForm/hideButton.svg");
border-radius: 5px;
width: 50px;
height: 40px;
width: 35px;
height: 35px;
}
/* SearchLine */
QAbstractButton#searchUpButton
{

55
ui/chatForm/searchButton.svg → ui/chatForm/hideButton.svg

@ -9,13 +9,13 @@ @@ -9,13 +9,13 @@
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="8.5557709mm"
height="5.0002112mm"
viewBox="0 0 8.555771 5.0002106"
width="5.5071211mm"
height="5.5071211mm"
viewBox="0 0 5.5071209 5.5071212"
version="1.1"
id="svg8"
inkscape:version="0.92.2 5c3e80d, 2017-08-06"
sodipodi:docname="searchButton.svg">
sodipodi:docname="hideButton.svg">
<defs
id="defs2" />
<sodipodi:namedview
@ -25,9 +25,9 @@ @@ -25,9 +25,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="22.4"
inkscape:cx="21.984681"
inkscape:cy="2.8941014"
inkscape:zoom="2.8"
inkscape:cx="186.40227"
inkscape:cy="-38.76831"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="false"
@ -39,12 +39,7 @@ @@ -39,12 +39,7 @@
inkscape:window-height="1015"
inkscape:window-x="0"
inkscape:window-y="876"
inkscape:window-maximized="1"
showguides="false">
<inkscape:grid
type="xygrid"
id="grid40" />
</sodipodi:namedview>
inkscape:window-maximized="1" />
<metadata
id="metadata5">
<rdf:RDF>
@ -61,26 +56,26 @@ @@ -61,26 +56,26 @@
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(340.51327,202.78083)">
transform="translate(59.891963,-41.449704)">
<g
id="g38"
transform="translate(-6.0476191,-0.34254092)"
id="g30"
transform="matrix(0.42362466,0.42362466,-0.42362466,0.42362466,-22.854056,42.277356)"
style="fill:#ffffff">
<path
id="path12"
transform="matrix(0.26458333,0,0,0.26458333,-340.91,-203.00001)"
d="m 47.244141,2.1230469 a 9.4488189,9.4488189 0 0 0 -9.449219,9.4492191 9.4488189,9.4488189 0 0 0 9.449219,9.449218 9.4488189,9.4488189 0 0 0 9.449218,-9.449218 9.4488189,9.4488189 0 0 0 -9.449218,-9.4492191 z m 0,3.4023437 a 6.0472442,6.0472442 0 0 1 6.046875,6.0468754 6.0472442,6.0472442 0 0 1 -6.046875,6.046875 6.0472442,6.0472442 0 0 1 -6.046875,-6.046875 6.0472442,6.0472442 0 0 1 6.046875,-6.0468754 z"
style="fill:#ffffff;stroke-width:1.0102793"
inkscape:connector-curvature="0" />
<rect
ry="0.64999998"
transform="rotate(-15)"
y="-278.625"
x="-271.75787"
height="1.3"
width="4.5002789"
id="rect32"
style="fill:#ffffff;stroke-width:0.26111853" />
y="41.988605"
x="-43.942345"
height="1.5"
width="11.5"
id="rect11"
style="fill:#ffffff;stroke-width:0.26458332" />
<rect
transform="rotate(-90)"
y="-38.942345"
x="-48.488605"
height="1.5"
width="11.500001"
id="rect11-3"
style="fill:#ffffff;stroke-width:0.26458332" />
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Loading…
Cancel
Save