-
-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed Whiteouts of Book Descriptions on Hover #1115
Fixed Whiteouts of Book Descriptions on Hover #1115
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whiteouts of book description have not been fixed - on the contrary, the name column was included in that undesirable behaviour.
On another note, this PR fixes several issues. Please extract each fix in a commit of its own.
@veloman-yunkan I can't seem to reproduce what you mean in both 5.15.2 and 6.2.4. @kelson42 does this fix work on your build? |
@ShaopengLin In the future, please develop your PR in a feature branch in our repo (not in your fork). I didn't had the time to test your branch which somehow seems to be difficult to reconciliate with my (this repo) revision log. |
I will try installing 5.12 a bit later and see if I can reproduce it. Will need to download it eventually since it seems compilation issues will continue to present themselves in the future (e.g. #1116) :). |
Cannot seem to reproduce it either in 5.12. Will just wait for a response. |
I double checked that it was not a result of an incorrect build: Screencast.from.05-29-2024.05.44.02.PM.webmI am using Ubuntu 22.04. |
@ShaopengLin I have been able to reproduce this problem (with both Qt6 and Qt6) but I hard a had time. It's important to:
|
f3cd032
to
f7a71f2
Compare
Confirmed fixed in all Qt5 and Qt6. The reason it isn't working is the press on the specific drop-down button will not count as a clicked event, thus our handler for the fix isn't called. |
src/contentmanagerdelegate.cpp
Outdated
if (lastColumnClicked) | ||
/* The description row does not constitute as part of the open button. */ | ||
if (lastColumnClicked && !index.parent().isValid()) | ||
handleLastColumnClicked(index, e, option); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed this same problem slightly differently in my so far WIP PR #1118. Do you think that an early return may have undesirable effects?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Users previously can open the book by middle clicking on the description section. An early return would then disable this feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@veloman-yunkan I believe fixing this your commit makes more sense. Your can do that check anytime after the middle button click check.
f7a71f2
to
2d62484
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! The PR is so much better this way. Let's make it close to ideal and we will merge.
src/contentmanagerdelegate.cpp
Outdated
if (index.parent().isValid()) | ||
{ | ||
auto view = KiwixApp::instance()->getContentManager()->getView()->getView(); | ||
|
||
/* Get the Rectangle from start of column1 to end of column 5. */ | ||
QRect r = view->visualRect(index.parent().siblingAtColumn(1)); | ||
QRect lastColRect = view->visualRect(index.parent().siblingAtColumn(5)); | ||
r.setWidth(lastColRect.x() + lastColRect.width() - r.x()); | ||
|
||
/* Based on the rectangle and text, find the best fitting size. */ | ||
QFontMetrics fm(option.font); | ||
QSize textRectSize = fm | ||
.boundingRect(r, | ||
Qt::AlignLeft | Qt::AlignVCenter | Qt::TextWordWrap, | ||
index.data().toString()) | ||
.size(); | ||
|
||
if (textRectSize.height() < 70) | ||
textRectSize.setHeight(70); | ||
return textRectSize; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2d62484
to
db53bb2
Compare
src/contentmanagerdelegate.cpp
Outdated
if (index.parent().isValid()) | ||
{ | ||
auto header = KiwixApp::instance()->getContentManager()->getView()->getView()->header(); | ||
|
||
/* Get the Rectangle from start of column1 to end of column 5. This is a | ||
slight underestimate of the actual width, but it means we will produce | ||
a proper height upper bound from boundingRect and the painting process | ||
will span the width regardless of what we return in sizeHint. | ||
*/ | ||
QRect descRect(0, 0, header->length() - header->sectionSize(0), 0); | ||
|
||
/* Based on the rectangle and text, find the best fitting size. */ | ||
QFontMetrics fm(option.font); | ||
const QString text = index.data().toString(); | ||
const auto format = Qt::AlignLeft | Qt::AlignVCenter | Qt::TextWordWrap; | ||
const QRect textRect = fm.boundingRect(descRect, format, text); | ||
QSize textSize = textRect.size(); | ||
|
||
if (textSize.height() < 70) | ||
textSize.setHeight(70); | ||
return textSize; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still doesn't work correctly
Screencast.from.06-07-2024.01.55.59.PM.webm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you have to account for some padding
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm either the header length or the boundingRect function is being inaccurate between systems. I will try to find an appropriate width for the height calculation.
db53bb2
to
21df619
Compare
if (index.isValid() && index.parent().isValid()) { | ||
if (isDescriptionIndex(index)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does isDescriptionIndex()
handle an invalid index correctly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, if the index is invalid, index.parent() will be invalid as well. Consequently, they have the same effect.
21df619
to
aea74f6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
The branch must be rebased and the a conflict resolved. Then we will merge.
Handler is now a slot function instead of a lambda.
index.parent().isValid replaced with static function isDescriptionNode.
Clicking and hovering the description dropdown of zim no longer whites out. Replaced manual drawing with default handling as it is no longer necessary.
The description row height fits the text context when expanded.
Already expanded description row will now adjust with respect to any window size changes to fit the content.
aea74f6
to
fa2d425
Compare
Fix #1112
Changes: