Skip to content
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

Improved UI for Reading List Bar and Table of Contents #1256

Merged
merged 2 commits into from
Dec 12, 2024

Conversation

heropj
Copy link
Contributor

@heropj heropj commented Nov 23, 2024

fix #1247

Changes:

  • Standardized UI for Reading List Bar and Table of Contents.

Screenshot 2024-11-23 195403
Screenshot 2024-11-23 195416

@kelson42
Copy link
Collaborator

@heropj Thank you for your PR. I have rebased it on latest main branch and we will review it.

Copy link
Collaborator

@ShaopengLin ShaopengLin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@heropj Please first remove the superfluous changes before we move to a formal review. The changes to some files like the icons may be due to your formatter? It is important to keep commit footprint at a minimum, as it makes it difficult for reviewers to navigate your changes.

@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
<height>300</height>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes in this file are unnecessary.

@@ -94,7 +92,7 @@ void TableOfContentBar::setupTree(const QJsonObject& headers)
if (headerUrl != currentUrl)
return;

m_url = headerUrl;
m_url = headerUrl;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove trailing space.

@@ -9,10 +9,8 @@ TableOfContentBar::TableOfContentBar(QWidget *parent) :
ui(new Ui::tableofcontentbar)
{
ui->setupUi(this);
ui->titleLabel->setFont(QFont("Selawik", 18, QFont::Weight::Medium));
// ui->titleLabel->setFont(QFont("Selawik", 18 , QFont::Weight::Medium));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not leave commented out code without explanation.

#readinglistbar QLabel {
/* General Style Improvements */
#readinglistbar, #tableofcontentbar {
/* background-color: #F9F9F9; */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not leave commented out code without reasoning

@heropj
Copy link
Contributor Author

heropj commented Nov 27, 2024

@ShaopengLin Sorry for the inconvenience caused by the superfluous changes. In my latest commit I have ensured no such changes are present. I’ve addressed other changes also as per your suggestion.

@ShaopengLin
Copy link
Collaborator

ShaopengLin commented Nov 27, 2024

@heropj There are still 46 files changed. Please only leave those which are relevant.

@heropj
Copy link
Contributor Author

heropj commented Nov 27, 2024

@ShaopengLin Got it..I have removed the commits which caused those unnecessary changes and have made a fresh commit with relevant changes only.

Copy link
Collaborator

@ShaopengLin ShaopengLin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@heropj The issue wants you to match ReadingList to the behaviour and look of the TOC, and we should not change the TOC. There are reasons for the design of TOC to be like this so please do not change it and focus on the 3 points I mentioned in the Issue.

SInce there are only a few UI changes, I will first focus on the UI. Once that's up-to-par (Kelson might also grill you similar to how he did to me :) later ), I can review the coding part.

@heropj
Copy link
Contributor Author

heropj commented Nov 30, 2024

@ShaopengLin Thank you for the feedback, I will undo changes in TOC and make RL ui similar to it.

@heropj heropj force-pushed the ui/tr branch 2 times, most recently from 02957cf to efc5e9e Compare December 1, 2024 07:24
@heropj
Copy link
Contributor Author

heropj commented Dec 1, 2024

@ShaopengLin
Screenshot 2024-12-01 123045
Screenshot 2024-12-01 123058

@@ -197,6 +197,7 @@ void MainWindow::tableOfContentToggled(bool state)
if (state) {
checkActionNoSignal(KiwixApp::ToggleReadingListAction, false);
mp_ui->sideBar->setCurrentWidget(mp_ui->tableofcontentbar);
mp_ui->sideBar->setStyleSheet("background-color: white;");
Copy link
Collaborator

@ShaopengLin ShaopengLin Dec 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bug. If the state has not changed, the stylesheet won't change. Like image below.

You should be able to change the background color like TOC without specifically setting the stylesheet on sideBar, try to investigate the CSS changes before doing ad-hoc changes like this.

Screenshot from 2024-12-02 14-44-11

@@ -15,6 +15,16 @@ ReadingListBar::ReadingListBar(QWidget *parent) :
ui(new Ui::readinglistbar)
{
ui->setupUi(this);

//to remove gap between RL components
if (layout()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this check necessary? I don't see setLayout() calls later so this state won't change.

@ShaopengLin
Copy link
Collaborator

ShaopengLin commented Dec 3, 2024

@heropj The change LGTM, but do change the commit message to be more generalized and meaningful.

@veloman-yunkan @kelson42 The UI and code look ok to me. Please have a round of review for any further suggestions.

Copy link
Collaborator

@ShaopengLin ShaopengLin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the following

@@ -197,7 +197,6 @@ void MainWindow::tableOfContentToggled(bool state)
if (state) {
checkActionNoSignal(KiwixApp::ToggleReadingListAction, false);
mp_ui->sideBar->setCurrentWidget(mp_ui->tableofcontentbar);
mp_ui->sideBar->setStyleSheet("background-color: white;");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change shouldn't be there in the first place. Do not let things like this appear in the commit history.

ui(new Ui::readinglistbar)
{
ui->setupUi(this);

//to remove gap between RL components
if (layout()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

@ShaopengLin
Copy link
Collaborator

@heropj We want the commit message to be both concise and informative.

final fix of RL

is not informative on the changes you did.

The second commit is way too long and thus not concise.

@heropj
Copy link
Contributor Author

heropj commented Dec 6, 2024

@ShaopengLin done😢😅

@kelson42
Copy link
Collaborator

kelson42 commented Dec 7, 2024

@heropj @ShaopengLin Thank you very much. I will review this PR from a user perspective this week-end and I hope @veloman-yunkan can do the same from the code perspective.

ui(new Ui::readinglistbar)
{
ui->setupUi(this);
ui->titleLabel->setFont(QFont("Selawik", 18, QFont::Weight::Medium));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the font set in C++ code? Can't it be controlled via CSS?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it can be set via CSS but TOC also had font set in cpp code in tableofcontentbar.cpp... so to maintain code consistency i added this line here in readinglistbar.cpp.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ShaopengLin Any reason the fonts in TOC sidebar are controlled from C++ rather than CSS?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If possible I am ok with doing this in CSS. Its just my personal preference to control font in Qt, as I remember some widgets doesn't support CSS fonts.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello.. I just checked it's working via CSS, so should i do it in CSS??

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, please

@@ -37,7 +40,6 @@ ReadingListBar::ReadingListBar(QWidget *parent) :
auto importAction = app->getAction(KiwixApp::ImportReadingListAction);
connect(exportAction, &QAction::triggered, this, &ReadingListBar::onExport);
connect(importAction, &QAction::triggered, this, &ReadingListBar::onImport);
ui->label->setText(gt("reading-list-title"));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this was replaced with ui->titleLabel->setText(gt("reading-list")); (and moved to the beginning of the constructor body). The new name of the label data member makes more sense, however it's not clear why the i18n text string id was changed from "reading-list-title" to "reading-list".

But checking resources/i18n/qqq.json and resources/i18n/en.json raises another question - do we really need both those strings? One of them is used as the tooltip for the reading list button and the other as the heading of the reading list bar. In English translation file the difference between them is only in capitalization, while their descriptions in qqq.json are identical. We should either drop one of them, or describe them differently in qqq.json.

@ShaopengLin @kelson42

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello! thank you for reviewing.. the reason i changed it from "reading-list-title" to "reading-list" is to maintain consistency with code present in tableofcontentbar.cpp😅 and since it worked i didn't got into checking the difference it might cause...but now that you have investigated about these strings, let me know how we should proceed further...drop one of them or change their description.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kelson42 Will you please provide your feedback to my comment above?

Copy link
Collaborator

@kelson42 kelson42 Dec 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@veloman-yunkan Nomstrong opinion, but if I have to choose I would say that having two strings seems wrong.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@heropj Then let's get rid of the "reading-list-title" and use "reading-list" instead. But I think that its capitalization must be changed to title case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@veloman-yunkan Do i need to remove "reading-list-title" from all translation files?? or just from qqq.json and en.json??

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only qqq.json and en.json must be updated.

Copy link
Collaborator

@kelson42 kelson42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM from a user perspective

Copy link
Collaborator

@veloman-yunkan veloman-yunkan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The final result looks good to me, but the commit history falls a little short of what I expect from a good code evolution history. The main problem is that the second commit combines two unrelated changes and rather reflects the review process than a logical and clean series of steps of arriving at the agreed state. Please rewrite the commit history of this PR as follows:

  1. Dropping of the "reading-list-title" entry from translated strings (C++ code using the removed entry must be updated accordingly, each commit must be self-consistent).
  2. Restyling of the Reading List sidebar (rest of the changes).

@kelson42 kelson42 merged commit 74111c8 into kiwix:main Dec 12, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make ReadingList UI Consistent
4 participants