Instead of a click button, the lists for genders and country searches
are hovering now
This commit is contained in:
60
src/app.cpp
60
src/app.cpp
@@ -539,7 +539,6 @@ Wt::WContainerWidget* App::createSmileyBar(Wt::WContainerWidget* parent, Wt::WLi
|
||||
}
|
||||
|
||||
Wt::WPushButton* App::createSendButton(Wt::WHBoxLayout* inputLayout, Wt::WLineEdit* inputLine) {
|
||||
setActivity();
|
||||
auto sendButton = inputLayout->addNew<Wt::WPushButton>("Send");
|
||||
auto sendMessageFunction = [=, this]() {
|
||||
sendMessage(inputLine);
|
||||
@@ -551,6 +550,7 @@ Wt::WPushButton* App::createSendButton(Wt::WHBoxLayout* inputLayout, Wt::WLineEd
|
||||
}
|
||||
|
||||
void App::sendMessage(Wt::WLineEdit *inputLine) {
|
||||
setActivity();
|
||||
auto utf8String = inputLine->valueText().trim().toUTF8();
|
||||
if (utf8String == "") {
|
||||
return;
|
||||
@@ -939,49 +939,46 @@ std::pair<Wt::WSpinBox*, Wt::WSpinBox*> App::setupSearchFields(Wt::WVBoxLayout *
|
||||
return {minAgeEdit, maxAgeEdit};
|
||||
}
|
||||
|
||||
std::pair<Wt::WPushButton*, Wt::WContainerWidget*> App::setupCountryDropDown(Wt::WVBoxLayout *contentLayout) {
|
||||
auto countryDropDown = std::make_unique<Wt::WContainerWidget>();
|
||||
countryDropDown->setInline(true);
|
||||
countryDropDown->setStyleClass("countries-drop-down");
|
||||
auto countryDropDownContainer = countryDropDown.get();
|
||||
auto countryOpenList = addSearchItemLine<Wt::WPushButton>(contentLayout, "Country", std::move(countryDropDown));
|
||||
countryDropDownContainer->hide();
|
||||
countryOpenList->clicked().connect([=]() { if (countryDropDownContainer->isHidden()) { countryDropDownContainer->show();} else { countryDropDownContainer->hide(); } });
|
||||
countryOpenList->setText("All");
|
||||
std::pair<Wt::WContainerWidget*, Wt::WContainerWidget*> App::setupCountryDropDown(Wt::WVBoxLayout *contentLayout) {
|
||||
auto countryOpenList = addSearchItemLine<Wt::WContainerWidget>(contentLayout, "Country");
|
||||
countryOpenList->addNew<Wt::WText>("All");
|
||||
countryOpenList->setStyleClass("selectBoxes-drop-down-trigger");
|
||||
auto countryDropDown = countryOpenList->addNew<Wt::WContainerWidget>();
|
||||
countryDropDown->setStyleClass("selectBoxes-dropdown");
|
||||
countryOpenList->setToolTip("Select the countries you'll search for");
|
||||
std::map<Wt::WString, Wt::WString> countries = server_.countries();
|
||||
addItem("All", countryDropDownContainer, countryOpenList, &searchFields.countries, true);
|
||||
addItem(country, countryDropDownContainer, countryOpenList, &searchFields.countries);
|
||||
addItem("All", countryDropDown, countryOpenList, &searchFields.countries, true);
|
||||
addItem(country, countryDropDown, countryOpenList, &searchFields.countries);
|
||||
for (const auto &itemCountry: countries) {
|
||||
if (itemCountry.first.toUTF8() != country) {
|
||||
addItem(itemCountry.first.toUTF8(), countryDropDownContainer, countryOpenList, &searchFields.countries);
|
||||
addItem(itemCountry.first.toUTF8(), countryDropDown, countryOpenList, &searchFields.countries);
|
||||
}
|
||||
}
|
||||
return {countryOpenList, countryDropDownContainer};
|
||||
return {countryOpenList, countryDropDown};
|
||||
}
|
||||
|
||||
std::pair<Wt::WPushButton*, Wt::WContainerWidget*> App::setupGendersDropDown(Wt::WVBoxLayout *contentLayout) {
|
||||
auto gendersDropDown = std::make_unique<Wt::WContainerWidget>();
|
||||
gendersDropDown->setInline(true);
|
||||
gendersDropDown->setStyleClass("countries-drop-down");
|
||||
auto gendersDropDownContainer = gendersDropDown.get();
|
||||
auto gendersOpenList = addSearchItemLine<Wt::WPushButton>(contentLayout, "Genders", std::move(gendersDropDown));
|
||||
gendersDropDownContainer->hide();
|
||||
gendersOpenList->clicked().connect([=]() { if (gendersDropDownContainer->isHidden()) { gendersDropDownContainer->show();} else { gendersDropDownContainer->hide(); } });
|
||||
gendersOpenList->setText("All");
|
||||
addItem("All", gendersDropDownContainer, gendersOpenList, &searchFields.gender, true);
|
||||
std::pair<Wt::WContainerWidget*, Wt::WContainerWidget*> App::setupGendersDropDown(Wt::WVBoxLayout *contentLayout) {
|
||||
auto gendersOpenList = addSearchItemLine<Wt::WContainerWidget>(contentLayout, "Genders");
|
||||
gendersOpenList->addNew<Wt::WText>("All");
|
||||
gendersOpenList->setStyleClass("selectBoxes-drop-down-trigger");
|
||||
auto gendersDropDown = gendersOpenList->addNew<Wt::WContainerWidget>();
|
||||
gendersDropDown->setStyleClass("selectBoxes-dropdown");
|
||||
gendersOpenList->setToolTip("Select the genders you'll search for");
|
||||
addItem("All", gendersDropDown, gendersOpenList, &searchFields.gender, true);
|
||||
std::map<Wt::WString, Wt::WString> swappedGenders;
|
||||
for (const auto& pair : genders_) {
|
||||
swappedGenders[pair.second] = pair.first;
|
||||
}
|
||||
for (const auto &itemGender: swappedGenders) {
|
||||
addItem(itemGender.first.toUTF8(), gendersDropDownContainer, gendersOpenList, &searchFields.gender);
|
||||
addItem(itemGender.first.toUTF8(), gendersDropDown, gendersOpenList, &searchFields.gender);
|
||||
}
|
||||
return {gendersOpenList, gendersDropDownContainer};
|
||||
return {gendersOpenList, gendersDropDown};
|
||||
}
|
||||
|
||||
void App::addItem(const std::string& country, Wt::WContainerWidget *dropDownContainer, Wt::WPushButton *openListButton, std::unordered_set<std::string> *saveItems, bool isSelected) {
|
||||
|
||||
void App::addItem(const std::string& country, Wt::WContainerWidget *dropDownContainer, Wt::WContainerWidget *container, std::unordered_set<std::string> *saveItems, bool isSelected) {
|
||||
auto menuItem = dropDownContainer->addNew<Wt::WCheckBox>(country);
|
||||
menuItem->changed().connect([=, this]() mutable { itemChanged(menuItem, dropDownContainer, openListButton, saveItems); });
|
||||
menuItem->changed().connect([=, this]() mutable { itemChanged(menuItem, dropDownContainer, container, saveItems); });
|
||||
menuItem->setInline(false);
|
||||
if (isSelected) {
|
||||
menuItem->setChecked();
|
||||
@@ -1145,7 +1142,7 @@ void App::showPartnerSites() {
|
||||
}
|
||||
}
|
||||
|
||||
void App::itemChanged(Wt::WCheckBox *item, Wt::WContainerWidget *dropDownContainer, Wt::WPushButton *openButton, std::unordered_set<std::string> *saveItems) {
|
||||
void App::itemChanged(Wt::WCheckBox *item, Wt::WContainerWidget *dropDownContainer, Wt::WContainerWidget *container, std::unordered_set<std::string> *saveItems) {
|
||||
saveItems->clear();
|
||||
bool unselect = (item->text() == "All" && item->isChecked());
|
||||
for (auto &widgetItem: dropDownContainer->children()) {
|
||||
@@ -1168,12 +1165,13 @@ void App::itemChanged(Wt::WCheckBox *item, Wt::WContainerWidget *dropDownContain
|
||||
for (const auto &selected: *saveItems) {
|
||||
result += (result.empty() ? "" : ", ") + selected;
|
||||
}
|
||||
openButton->setText(result);
|
||||
auto outputWidget = (Wt::WText*)container->children().at(0);
|
||||
outputWidget->setText(result);
|
||||
}
|
||||
|
||||
void App::restoreSearchFields(Wt::WContainerWidget *searchResultContainer, Wt::WLineEdit *userNameEdit, Wt::WSpinBox *minAgeEdit,
|
||||
Wt::WSpinBox *maxAgeEdit, Wt::WContainerWidget *countryDropDownContainer, Wt::WContainerWidget *gendersDropDownContainer,
|
||||
Wt::WPushButton *countryOpenList, Wt::WPushButton *gendersOpenList) {
|
||||
Wt::WContainerWidget *countryOpenList, Wt::WContainerWidget *gendersOpenList) {
|
||||
if (!searchFields.set) {
|
||||
searchFields = Search(searchResultContainer);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user