Skip to content

Commit

Permalink
Minor improvements to view
Browse files Browse the repository at this point in the history
When an item is hovered, colour changes to grey.
Change cursor to HandPointer in treeview
Open book description when item is clicked
Increase description box width
  • Loading branch information
juuz0 authored and kelson42 committed Jul 3, 2023
1 parent 9bc321f commit d660415
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
12 changes: 8 additions & 4 deletions resources/css/_contentManager.css
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
QTreeView::branch:open:has-children {
image: url(:/icons/caret-down-solid.svg);
margin: 7px;
padding: 6px;
}

QTreeView::branch:closed:has-children {
image: url(:/icons/caret-right-solid.svg);
margin: 7px;
padding: 7px;
}

QTreeView::item:has-children {
Expand All @@ -18,6 +18,10 @@ QTreeView {
border: none;
}

QTreeView::item:hover {
background-color: #eaecf0;
}

QHeaderView::section {
color: #666666;
background-color: #fff;
Expand All @@ -38,12 +42,12 @@ QHeaderView::section:checked

QHeaderView::down-arrow {
image: url(:/icons/caret-down-solid.svg);
margin: 5px;
padding: 5px;
}

QHeaderView::up-arrow {
image: url(:/icons/caret-up-solid.svg);
margin: 5px;
padding: 5px;
}

QMenu {
Expand Down
5 changes: 4 additions & 1 deletion src/contentmanagerdelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,10 @@ void ContentManagerDelegate::paint(QPainter *painter, const QStyleOptionViewItem
QStyleOptionViewItem eOpt = option;
if (index.data(Qt::UserRole+1) != QVariant()) {
// additional info role
QStyledItemDelegate::paint(painter, option, index);
QRect nRect = r;
auto viewWidth = KiwixApp::instance()->getContentManager()->getView()->getView()->width();
nRect.setWidth(viewWidth);
painter->drawText(nRect, Qt::AlignLeft | Qt::AlignVCenter, index.data(Qt::UserRole+1).toString());
return;
}
if (index.column() == 5) {
Expand Down
12 changes: 12 additions & 0 deletions src/contentmanagerview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ ContentManagerView::ContentManagerView(QWidget *parent)
QString styleSheet = QString(file.readAll());
mp_ui->m_view->setStyleSheet(styleSheet);
mp_ui->m_view->setContextMenuPolicy(Qt::CustomContextMenu);
mp_ui->m_view->setCursor(Qt::PointingHandCursor);

auto searcher = mp_ui->searcher;
searcher->setPlaceholderText(gt("search-files"));
Expand All @@ -25,6 +26,17 @@ ContentManagerView::ContentManagerView(QWidget *parent)
connect(searcher, &QLineEdit::textChanged, [searcher](){
KiwixApp::instance()->getContentManager()->setSearch(searcher->text());
});
connect(mp_ui->m_view, &QTreeView::clicked, [=](QModelIndex index) {
if (index.column() == (mp_ui->m_view->model()->columnCount() - 1))
return;

auto zeroColIndex = index.siblingAtColumn(0);
if (mp_ui->m_view->isExpanded(zeroColIndex)) {
mp_ui->m_view->collapse(zeroColIndex);
} else {
mp_ui->m_view->expand(zeroColIndex);
}
});
}

ContentManagerView::~ContentManagerView()
Expand Down

0 comments on commit d660415

Please sign in to comment.