Skip to content

Commit

Permalink
Added Select All Button to MultiZim
Browse files Browse the repository at this point in the history
Disabled until true Multizim implemented.
  • Loading branch information
ShaopengLin committed Sep 9, 2024
1 parent 30e5520 commit ed182d2
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 4 deletions.
24 changes: 24 additions & 0 deletions resources/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,30 @@ SearchBar > QToolButton:hover {
border-radius: 3px;
}

#selectAllButton {
border: 1px solid transparent;
background-color: white;
font-size: 20px;
font-weight: bold;
padding: 3px;
}

#selectAllButton::indicator {
width: 20px;
height: 20px;
border: 2px solid black;
border-radius: 3px;
image: none;
}

#selectAllButton::indicator:checked {
image: url(:/icons/check-solid.svg);
}

#selectAllButton:disabled {
background-color: #ccc;
}

TopWidget QToolButton:pressed,
TopWidget QToolButton::hover {
border: 1px solid #3366CC;
Expand Down
3 changes: 2 additions & 1 deletion resources/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,5 +168,6 @@
"save-page-as": "Save As...",
"load-more": "Load More",
"kiwix-search": "Kiwix Search",
"multi-zim-search": "Multi-Zim Search"
"multi-zim-search": "Multi-Zim Search",
"select-all": "Select all"
}
3 changes: 2 additions & 1 deletion resources/i18n/qqq.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,5 +175,6 @@
"save-page-as": "Represents the action of saving the current tab content to a file chosen by the user.",
"load-more": "Represents the action to display more results. For exmaple, when we give search suggestion to user, the user can do load more to display more search suggestions.",
"kiwix-search": "Title text for a list of search results, which notes ot the user those are from Kiwix's Search Engine",
"multi-zim-search": "Represents the action of searching suggrestion results from one or more ZIM files in the library."
"multi-zim-search": "Represents the action of searching suggrestion results from one or more ZIM files in the library.",
"select-all": "Represents the action of selecting all ZIM in the library to be search targets for suggestions."
}
17 changes: 15 additions & 2 deletions src/searchbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,20 +293,33 @@ SearchBar::SearchBar(QWidget *parent) :
}

MultiZimButton::MultiZimButton(QWidget *parent)
: QToolButton(parent), mp_buttonList(nullptr)
: QToolButton(parent), mp_buttonList(nullptr), mp_selectAllButton(nullptr)
{
setMenu(new QMenu(this));
setPopupMode(QToolButton::InstantPopup);
setIcon(QIcon(":/icons/filter.svg"));
setToolTip(gt("multi-zim-search"));

mp_buttonList = new QListWidget(this);
mp_selectAllButton = new QCheckBox(gt("select-all"),this);
auto popupAction = new QWidgetAction(menu());
popupAction->setDefaultWidget(mp_buttonList);

QWidget *menuWidget = new QWidget;
menuWidget->setLayout(new QVBoxLayout);
menuWidget->layout()->setSpacing(0);
menuWidget->layout()->setContentsMargins(0, 0, 0, 0);
menuWidget->layout()->addWidget(mp_buttonList);
menuWidget->layout()->addWidget(mp_selectAllButton);
popupAction->setDefaultWidget(menuWidget);
menu()->addAction(popupAction);
mp_buttonList->setSelectionMode(QAbstractItemView::SingleSelection);
mp_buttonList->setFixedWidth(menu()->sizeHint().width());
mp_buttonList->setMinimumHeight(42 * 7);
mp_selectAllButton->setObjectName("selectAllButton");
mp_selectAllButton->setFixedHeight(42);

/* TODO: connect with list widget after multi-zim */
mp_selectAllButton->setDisabled(true);
}

QString MultiZimButton::getZimId() const
Expand Down
2 changes: 2 additions & 0 deletions src/searchbar.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "suggestionlistmodel.h"

class QListWidget;
class QCheckBox;

class BookmarkButton : public QToolButton {
Q_OBJECT
Expand Down Expand Up @@ -65,6 +66,7 @@ public slots:

private:
QListWidget* mp_buttonList;
QCheckBox* mp_selectAllButton;
QString m_zimId;
};

Expand Down

0 comments on commit ed182d2

Please sign in to comment.