-
-
Notifications
You must be signed in to change notification settings - Fork 115
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
Fix #186: Introduced Tab Restoration on Restart #1048
Fix #186: Introduced Tab Restoration on Restart #1048
Conversation
@ShaopengLin Thank you very much for PR. I will check from a user perspective. One thing which should probably be changed is creating a dedicated settings to manage this behaviour (not in favour of popup at start). |
Like an option for either restoring automatucally or have a pop-up for it? For automatic restoration it would be good to have a short-small notification about it as well. |
Yes, a basic boolean setting "Restore tabs at start". I will lokk how FF and Chrome exactly work... |
Just found we have a settingsmanager.cpp. Will move code over there to refactor a commit. |
2a7f6ca
to
b1911ed
Compare
I confirm, we should have a "Open previous tabs at startup" checkbox in the settings. Per default unchecked. |
I think currently I set it as default checked, simple change. Will wait for reviewer comment and change in a batch. |
@ShaopengLin Option not visible in the settings, |
Weird. I will test it using Qt6 as well. I was still developing on the Qt5 build. Might be some differences in building UI? |
@ShaopengLin Sorry, me doing a wrong manipulation. Seems to work fine... but setting wording is NOK. SHould be "Open previous tabs at startup" |
Is there a way for me to update i18n for the text? |
@ShaopengLin You should put only the string in English |
@kelson42 I just put it like this? |
I will update this PR after merge of #1057 and on resolution of the comments: comment on text translation and comment on session |
fd80447
to
3f986b8
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.
I am a little concerned with the new calls to Kiwix::instance()
, but I think that I'd rather address it separately in a dedicated design improvement PR.
Apart from fixing the issues outlined in the review comments, please split this PR in two commits:
- Add unconditional reopening of tabs from previous session;
- Introduce a setting that controls that behaviour.
@veloman-yunkan Could you tag me when you start the refactoring work? I am a GSOC student so seeing practical design patterns being applied is great learning for me as well. I am guessing something like dependency injection or complete functions. |
34edb31
to
2fae684
Compare
@@ -166,12 +166,13 @@ QWebEngineView* WebView::createWindow(QWebEnginePage::WebWindowType type) | |||
|
|||
void WebView::onUrlChanged(const QUrl& url) { | |||
auto zimId = getZimIdFromUrl(url); | |||
auto app = KiwixApp::instance(); | |||
app->saveListOfOpenTabs(); |
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 replaced the previous call on webpage.cpp
as I found that was a bad choice. No need for the acceptNavigationRequest
. onUrlChanged is indeed called on in-page URL navigations.
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.
In case the number of new comments makes you think that I am not happy with the progress you will be wrong. The fact is that we are much closer to having this PR merged and I am just paying attention to more mundane details. 😉
src/kiwixapp.cpp
Outdated
|
||
/* Place session file in our global library path */ | ||
QDir dir(m_libraryDirectory); | ||
this->mp_session = new QSettings(dir.filePath("user.session"), |
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.
IMHO, we better name kiwix-desktop
's session file kiwix-desktop.session
. @kelson42 Do you agree?
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.
Made the modification just in case.
void SettingsView::init(int zoomPercent, const QString &downloadDir, const QString &monitorDir, const bool moveToTrash) | ||
void SettingsView::init(int zoomPercent, const QString &downloadDir, | ||
const QString &monitorDir, const bool moveToTrash, | ||
bool reopentab) |
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 is comment for myself. The trend of the parameter list of SettingsView::init()
growing over time is obvious, but the need for that function is not. For a slightly different design the initialization of SettingsView
could be performed via the existing update mechanism via signal-slot connections.
🤝 I will. Can't promise that your expectations for design patterns will be met since I am mostly refactoring based on my sense of aesthetics, but if you notice in the resulting code anything familiar from your computer science study I will be glad to learn its name 😄 |
2fae684
to
e66cfeb
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.
Question to @kelson42 and @mgautierfr - in the current implementation the list of open tabs is saved every time it changes even if the "reopen-tabs" setting is disabled. Is that ok?
e66cfeb
to
9430e3f
Compare
9430e3f
to
f133b70
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 (but note my so far unanswered question in the previous review).
We may want to save (and restore) also the which tab is the current one. |
Actually no, it is not a 'simple' task and it would be better to have some discussion on the behaviors. I will open an issue once this is merged. |
@ShaopengLin Thank you very much for this PR. Please don't forget to open the ticket like agreed. Merging... |
f133b70
to
01a6698
Compare
The change in #1048 prevented opening of blank tab and urls that are no longer valid. Now, we will need to open them as well, as we will need the exact number of tabs to reopen in order to correctly restore current tab index.
The change in #1048 prevented opening of blank tab and urls that are no longer valid. Now, we will need to open them as well, as we will need the exact number of tabs to reopen in order to correctly restore current tab index.
Changes:
Pop-up to prompt users whether they want to restore the tabs. If not, start a new session.Added a checkbox in settings for users to toggle whether they want tab restoration or not.Fix-up Changes:
Fix #186