-
-
Notifications
You must be signed in to change notification settings - Fork 32
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
Feature/start with last opened tabs #55
Feature/start with last opened tabs #55
Conversation
PoisonousJohn
commented
May 3, 2017
•
edited
Loading
edited
- Added "Continue where you left off" setting to the settings page.
- Added "Session" entity to save session-related data to separate file
- Added list of tab states to session.
- Implemented restoration of tabs when opening first browser window
This is for #50 |
@JohnPoison thank you! I will hopefully be able to look into it tomorrow (or on Friday). |
Also I'm currently looking into saving tab's scrolling progress upon exit. It seems that for this task we'll have to use WebChannel. Also this will give us more flexible way to communicate QML <--> WebPage content |
@JohnPoison That would be cool :) If we have to use WebChannels, we should merge |
@tim-sueberkrueb sure we can. But isn't that lot easier to modify property of a js object, instead of messing with runJavaScript callbacks? Besides it's not so easy to use runJavaScript callback, since I'm saving sesison data on window close. So I should block closing until callback returns. I see that web channel can give us a handy way to communicate with web page content. Well, we can even do this in a separate PR |
@JohnPoison I see, that's right. We could also use WebChannels for theme color handling then. |
|
dd8fecd
to
27c617f
Compare
Lol, it seems i've messed up with git. Will fix it 10th of May. |
5177adb
to
a88b184
Compare
@tim-sueberkrueb rebase done. |
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.
Hey, I'm so sorry that I forgot about this PR ._.
Can you rebase it on develop
?
Looks good otherwise 👍
We might want to rethink settings (in general) though (but that's something for v0.5.0 ;)).
@@ -61,11 +61,35 @@ TabContent { | |||
} | |||
|
|||
TitleLabel { | |||
text: "Start" | |||
text: "Startup" |
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.
Please use qsTr()
now
} | ||
|
||
Column { | ||
Label { text: "Start new window with" } |
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.
Please use qsTr()
now
src/core/session/session.cpp
Outdated
* $END_LICENSE$ | ||
*/ | ||
|
||
#include "Session.h" |
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 think that's "session.h"
.
I think one thing to consider is whether it would be better if restored tabs would only load on demand (e.g. when the user activates them) as it is the case in Firefox. That would prevent long loading times when many tabs are stored. |
Completely agree. +1 Just think about cases with 20-40 tabs open and more.. |
Another problem with this I haven't thought of yet is multi window support. |
ecd37d8
to
b2f5836
Compare
Rebased on develop. Regarding multi-window support, right now the session is being saved for the last closed window. I think if we need multi-window support, it should be done as a separate issue. |
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.
Thanks a lot for getting back to this!
Looking good, will check it out and test myself asap.
src/ui/tabview/TabController.qml
Outdated
{ | ||
for (var i = 0; i < tabContentView.pages.count; ++i) | ||
{ | ||
var tabPage = tabContentView.pages.get(i).item; |
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.
Let's stay consistent with the rest of the JavaScript code and keep the opening curly brace in the same line ;)
for (var i = 0; i < tabContentView.pages.count; ++i) {
src/ui/tabview/TabController.qml
Outdated
background: background | ||
}); | ||
function completeTabsRestore() | ||
{ |
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.
Let's keep the opening curly brace in the same line for consistency ;)
function completeTabsRestore() {
src/ui/tabview/TabPage.qml
Outdated
); | ||
break; | ||
if (!loadContent) | ||
{ |
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.
Let's keep the opening curly brace in the same line for consistency.
src/ui/tabview/TabPage.qml
Outdated
} | ||
else | ||
{ |
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.
Let's keep the opening curly brace in the same line for consistency.
id: lazyCreateConnection | ||
|
||
function tryCreateContent() | ||
{ |
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.
Let's keep the opening curly brace in the same line for consistency.
return; | ||
|
||
if (parentTabPage.loadContent) | ||
{ |
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.
Let's keep the opening curly brace in the same line for consistency.
src/core/session/session.cpp
Outdated
|
||
m_activeTab = std::max(m_tabs.count() - 1, 0); | ||
if (root.find("activeTab") != root.end()) | ||
{ |
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.
Let's keep the opening curly brace in the same line for consistency-
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.
sorry for that braces, my old habit from c# :)
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.
No problem, thanks! :)
src/core/session/session.h
Outdated
Q_PROPERTY(int activeTab READ getActiveTab) | ||
|
||
int getActiveTab() { return m_activeTab; } | ||
signals: |
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.
We can remove the signals
and public slots
sections as they are not used.
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.
sure
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.
Looks like the data directory (/home/tim/.local/share/liri-browser
in my case) is not being created:
Couldn't open session file for write!
We should make sure the directory gets created, see https://github.com/lirios/browser/blob/develop/src/core/settings/settings.cpp#L40
src/core/session/tabstate.cpp
Outdated
|
||
float TabState::readingProgress() const | ||
{ | ||
return m_readingProgress; |
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.
Should we remove readingProgress while it's not being used, yet?
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, sure
src/core/session/session.cpp
Outdated
tabObject["url"] = tab->url().toString(); | ||
tabObject["title"] = tab->title(); | ||
tabObject["icon"] = tab->iconUrl().toString().replace("image://favicon/",""); | ||
tabObject["readingProgress"] = 0.f; |
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.
The JSON fields for settings are currently all snake_case
. I do prefer camelCase
though. We can change the settings schema to use camelCase
(which shouldn't be a problem right now as we don't have a release yet).
Any objections?
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.
No objections. Should I leave it like that for now?
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, let's :)
I have thought about it, and even tried, but something went wrong. Let me try again. |
I almost sure that I have fixed it. It seems I've lost the change during problems with rebase. Let me fix it again |
Oh rebase ^-^ |
This iteration looks more appropriate. liri-settings bug is fixed as well |
Awesome, thank you! Will check it out a bit later today! |
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.
Works great now, thank you! One thing I noticed is that you store the icon url but the icons will only show up when the tab fully loads. We either should make the icons load or drop the property.
We also probably want to prevent saving the icon url for liri://
tabs:
"icon": "qrc:/liri.io/imports/Fluid/Controls/icons/action/settings.svg",
It also looks like the icon information gets lost when I restart the browser, tabs get restored but I don't activate them and restart the browser again:
"icon": ""
Besides of that, looking good!
src/ui/tabview/TabPage.qml
Outdated
@@ -59,6 +55,15 @@ Item { | |||
property var contentItem | |||
property int tabType | |||
|
|||
function tryCreateContent() { | |||
console.log("Try create content"); |
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.
Do you want to keep this logging?
src/core/session/session.cpp
Outdated
@@ -42,6 +42,11 @@ Session::Session(QObject *parent) | |||
|
|||
void Session::save(TabsModel* tabs) | |||
{ | |||
if (!QDir(Paths::DataLocation).exists()) { | |||
qDebug() << "DataLocation path doesn't exist."; |
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.
Let's make this a bit more human-friendly, like "App data path doesn't exist".
src/ui/tabview/TabPage.qml
Outdated
|
||
return true; | ||
} | ||
|
||
onActiveTabChanged: { | ||
console.log("onActiveTabChanged"); |
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.
Can we remove this debug statement?
src/core/session/session.cpp
Outdated
{ | ||
QVariantList tabs; | ||
for (TabState* state : m_tabs) | ||
{ |
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.
Found another curly brace :)
@@ -27,11 +27,16 @@ import ".." | |||
Item { | |||
id: tabPage | |||
|
|||
// binding. should be set from outside |
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.
Is this comment still relevant? I don't understand what it means.
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.
It's relevant. It means that activeTab property itself doesn't do anything. It should be a functions assigned by another component. This function should return an activeTab. I did this to avoid dependency on TabController
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.
Ah, all right.
src/ui/tabview/TabPage.qml
Outdated
if (contentItem || !loadContent || tab !== activeTab) | ||
return; | ||
|
||
console.log("Creating content"); |
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.
Do we need this debug statement?
src/core/session/session.cpp
Outdated
tabObject["url"] = tab->url().toString(); | ||
tabObject["title"] = tab->title(); | ||
tabObject["icon"] = tab->iconUrl().toString().replace("image://favicon/",""); | ||
tabObject["readingProgress"] = 0.f; |
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.
readingProgress
can be removed here, right?
|
src/ui/window/BrowserWindow.qml
Outdated
@@ -502,7 +502,7 @@ ApplicationWindow { | |||
'loadContent': false, | |||
'url': restoreTabs[i].url, | |||
'title': restoreTabs[i].title, | |||
'iconUrl': restoreTabs[i].iconUrl | |||
'iconUrl': restoreTabs[i].icon.replace("https", "http") |
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 bothers me. Right now QML Image is not able to load images via https, showing SSL error in console. Yet browser works fine with SSL. Don't know how to fix it, so it's a hack right now.
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.
Interesting, I cannot reproduce this issue here on Ubuntu 17.10 with Qt 5.10.1.
Label { | ||
text: qsTr("Start url") | ||
Column { | ||
Label { text: "Start new window with" } |
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.
Use qsTr()
Looking good otherwise! |
@tim-sueberkrueb I believe everything is ok now :) |
@PoisonousJohn I think you need to remove |
@tim-sueberkrueb yeah, sure, I forgot about that, still didn't test it in a "Empty" project |
@tim-sueberkrueb done |
@PoisonousJohn do you have any preference on merging the PR? Should I squash your commits? |
Thank you @PoisonousJohn! |