mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
feat: add startButton in SearchForm
This commit is contained in:
parent
3b7ba02324
commit
8dd8347759
|
@ -80,9 +80,14 @@ void SearchSettingsForm::updateStartDateLabel()
|
|||
ui->startDateLabel->setText(startDate.toString("dd.MM.yyyy"));
|
||||
}
|
||||
|
||||
void SearchSettingsForm::setUpdate(const bool isUpdate)
|
||||
{
|
||||
this->isUpdate = isUpdate;
|
||||
emit updateSettings(isUpdate);
|
||||
}
|
||||
|
||||
void SearchSettingsForm::onStartSearchSelected(const int index)
|
||||
{
|
||||
isUpdate = true;
|
||||
if (index > 1) {
|
||||
ui->choiceDateButton->setEnabled(true);
|
||||
ui->startDateLabel->setEnabled(true);
|
||||
|
@ -106,32 +111,35 @@ void SearchSettingsForm::onStartSearchSelected(const int index)
|
|||
|
||||
ui->startDateLabel->setStyleSheet("QLabel{color: #ddd;}");
|
||||
}
|
||||
|
||||
setUpdate(true);
|
||||
}
|
||||
|
||||
void SearchSettingsForm::onRegisterClicked(const bool checked)
|
||||
{
|
||||
isUpdate = true;
|
||||
setUpdate(true);
|
||||
}
|
||||
|
||||
void SearchSettingsForm::onWordsOnlyClicked(const bool checked)
|
||||
{
|
||||
isUpdate = true;
|
||||
if (checked) {
|
||||
ui->regularRadioButton->setChecked(false);
|
||||
}
|
||||
|
||||
setUpdate(true);
|
||||
}
|
||||
|
||||
void SearchSettingsForm::onRegularClicked(const bool checked)
|
||||
{
|
||||
isUpdate = true;
|
||||
if (checked) {
|
||||
ui->wordsOnlyRadioButton->setChecked(false);
|
||||
}
|
||||
|
||||
setUpdate(true);
|
||||
}
|
||||
|
||||
void SearchSettingsForm::onChoiceDate()
|
||||
{
|
||||
isUpdate = true;
|
||||
LoadHistoryDialog dlg;
|
||||
dlg.setTitle(tr("Select Date Dialog"));
|
||||
dlg.setInfoLabel(tr("Select a date"));
|
||||
|
@ -139,4 +147,6 @@ void SearchSettingsForm::onChoiceDate()
|
|||
startDate = dlg.getFromDate().date();
|
||||
updateStartDateLabel();
|
||||
}
|
||||
|
||||
setUpdate(true);
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ private:
|
|||
bool isUpdate;
|
||||
|
||||
void updateStartDateLabel();
|
||||
void setUpdate(const bool isUpdate);
|
||||
|
||||
private slots:
|
||||
void onStartSearchSelected(const int index);
|
||||
|
@ -31,6 +32,9 @@ private slots:
|
|||
void onWordsOnlyClicked(const bool checked);
|
||||
void onRegularClicked(const bool checked);
|
||||
void onChoiceDate();
|
||||
|
||||
signals:
|
||||
void updateSettings(const bool isUpdate);
|
||||
};
|
||||
|
||||
#endif // SEARCHSETTINGSFORM_H
|
||||
|
|
|
@ -40,10 +40,13 @@ SearchForm::SearchForm(QWidget* parent) : QWidget(parent)
|
|||
upButton = createButton("searchUpButton", "green");
|
||||
downButton = createButton("searchDownButton", "green");
|
||||
hideButton = createButton("searchHideButton", "red");
|
||||
startButton = createButton("startButton", "green");
|
||||
startButton->setText(tr("Start"));
|
||||
|
||||
layoutNavigation->setMargin(0);
|
||||
layoutNavigation->addWidget(settingsButton);
|
||||
layoutNavigation->addWidget(searchLine);
|
||||
layoutNavigation->addWidget(startButton);
|
||||
layoutNavigation->addWidget(upButton);
|
||||
layoutNavigation->addWidget(downButton);
|
||||
layoutNavigation->addWidget(hideButton);
|
||||
|
@ -51,6 +54,8 @@ SearchForm::SearchForm(QWidget* parent) : QWidget(parent)
|
|||
layout->addLayout(layoutNavigation);
|
||||
layout->addWidget(settings);
|
||||
|
||||
startButton->setHidden(true);
|
||||
|
||||
setLayout(layout);
|
||||
|
||||
connect(searchLine, &LineEdit::textChanged, this, &SearchForm::changedSearchPhrase);
|
||||
|
@ -61,7 +66,10 @@ SearchForm::SearchForm(QWidget* parent) : QWidget(parent)
|
|||
connect(upButton, &QPushButton::clicked, this, &SearchForm::clickedUp);
|
||||
connect(downButton, &QPushButton::clicked, this, &SearchForm::clickedDown);
|
||||
connect(hideButton, &QPushButton::clicked, this, &SearchForm::clickedHide);
|
||||
connect(startButton, &QPushButton::clicked, this, &SearchForm::clickedStart);
|
||||
connect(settingsButton, &QPushButton::clicked, this, &SearchForm::clickedSearch);
|
||||
|
||||
connect(settings, &SearchSettingsForm::updateSettings, this, &SearchForm::changedButtons);
|
||||
}
|
||||
|
||||
void SearchForm::removeSearchPhrase()
|
||||
|
@ -108,6 +116,7 @@ QPushButton *SearchForm::createButton(const QString& name, const QString& state)
|
|||
|
||||
ParameterSearch SearchForm::getAndCheckParametrSearch()
|
||||
{
|
||||
if (isActiveSettings) {
|
||||
auto sendParam = settings->getParameterSearch();
|
||||
if (!isChangedPhrase && !sendParam.isUpdate) {
|
||||
sendParam.period = PeriodSearch::None;
|
||||
|
@ -117,34 +126,50 @@ ParameterSearch SearchForm::getAndCheckParametrSearch()
|
|||
parameter = sendParam;
|
||||
|
||||
return sendParam;
|
||||
}
|
||||
|
||||
return ParameterSearch();
|
||||
}
|
||||
|
||||
void SearchForm::changedSearchPhrase(const QString& text)
|
||||
{
|
||||
QString l = text.right(1);
|
||||
|
||||
if (searchPhrase == text) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!l.isEmpty() && l != " " && l[0].isSpace()) {
|
||||
searchLine->setText(searchPhrase);
|
||||
return;
|
||||
}
|
||||
|
||||
searchPhrase = text;
|
||||
isChangedPhrase = true;
|
||||
if (!isActiveSettings) {
|
||||
if (isActiveSettings) {
|
||||
if (startButton->isHidden()) {
|
||||
changedButtons(true);
|
||||
}
|
||||
} else {
|
||||
emit searchInBegin(searchPhrase, getAndCheckParametrSearch());
|
||||
}
|
||||
}
|
||||
|
||||
void SearchForm::clickedUp()
|
||||
{
|
||||
auto param = getAndCheckParametrSearch();
|
||||
if (param.period == PeriodSearch::None) {
|
||||
emit searchUp(searchPhrase, param);
|
||||
if (startButton->isHidden()) {
|
||||
emit searchUp(searchPhrase, getAndCheckParametrSearch());
|
||||
} else {
|
||||
emit searchInBegin(searchPhrase, param);
|
||||
clickedStart();
|
||||
}
|
||||
}
|
||||
|
||||
void SearchForm::clickedDown()
|
||||
{
|
||||
auto param = getAndCheckParametrSearch();
|
||||
if (param.period == PeriodSearch::None) {
|
||||
emit searchDown(searchPhrase, param);
|
||||
if (startButton->isHidden()) {
|
||||
emit searchDown(searchPhrase, getAndCheckParametrSearch());
|
||||
} else {
|
||||
emit searchInBegin(searchPhrase, param);
|
||||
clickedStart();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -154,6 +179,12 @@ void SearchForm::clickedHide()
|
|||
emit visibleChanged();
|
||||
}
|
||||
|
||||
void SearchForm::clickedStart()
|
||||
{
|
||||
changedButtons(false);
|
||||
emit searchInBegin(searchPhrase, getAndCheckParametrSearch());
|
||||
}
|
||||
|
||||
void SearchForm::clickedSearch()
|
||||
{
|
||||
isActiveSettings = !isActiveSettings;
|
||||
|
@ -163,11 +194,25 @@ void SearchForm::clickedSearch()
|
|||
settingsButton->setProperty("state", "red");
|
||||
} else {
|
||||
settingsButton->setProperty("state", "green");
|
||||
changedButtons(false);
|
||||
}
|
||||
settingsButton->setStyleSheet(Style::getStylesheet(QStringLiteral(":/ui/chatForm/buttons.css")));
|
||||
settingsButton->update();
|
||||
}
|
||||
|
||||
void SearchForm::changedButtons(const bool isUpdate)
|
||||
{
|
||||
if (isUpdate) {
|
||||
startButton->setHidden(false);
|
||||
upButton->setHidden(true);
|
||||
downButton->setHidden(true);
|
||||
} else {
|
||||
startButton->setHidden(true);
|
||||
upButton->setHidden(false);
|
||||
downButton->setHidden(false);
|
||||
}
|
||||
}
|
||||
|
||||
LineEdit::LineEdit(QWidget* parent) : QLineEdit(parent)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@ private:
|
|||
QPushButton* upButton;
|
||||
QPushButton* downButton;
|
||||
QPushButton* hideButton;
|
||||
QPushButton* startButton;
|
||||
LineEdit* searchLine;
|
||||
SearchSettingsForm* settings;
|
||||
|
||||
|
@ -65,7 +66,9 @@ private slots:
|
|||
void clickedUp();
|
||||
void clickedDown();
|
||||
void clickedHide();
|
||||
void clickedStart();
|
||||
void clickedSearch();
|
||||
void changedButtons(const bool isUpdate);
|
||||
|
||||
signals:
|
||||
void searchInBegin(const QString& phrase, const ParameterSearch& parameter);
|
||||
|
|
|
@ -26,6 +26,12 @@ struct ParameterSearch {
|
|||
QDate date;
|
||||
bool isUpdate;
|
||||
|
||||
ParameterSearch() {
|
||||
filter = FilterSearch::None;
|
||||
period = PeriodSearch::None;
|
||||
isUpdate = false;
|
||||
}
|
||||
|
||||
bool operator ==(const ParameterSearch& other) {
|
||||
if (this->filter != other.filter) {
|
||||
return false;
|
||||
|
|
|
@ -109,6 +109,14 @@ QAbstractButton#choiceDateButton
|
|||
color: #fff
|
||||
}
|
||||
|
||||
QAbstractButton#startButton
|
||||
{
|
||||
border-radius: 5px;
|
||||
width: 60px;
|
||||
height: 35px;
|
||||
color: #fff
|
||||
}
|
||||
|
||||
/* Common */
|
||||
|
||||
QAbstractButton
|
||||
|
|
Loading…
Reference in New Issue
Block a user