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

Feature/start with last opened tabs #55

Merged

Conversation

PoisonousJohn
Copy link
Contributor

@PoisonousJohn PoisonousJohn commented May 3, 2017

  • 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

@PoisonousJohn
Copy link
Contributor Author

This is for #50

@timsueberkrueb
Copy link
Collaborator

@JohnPoison thank you! I will hopefully be able to look into it tomorrow (or on Friday).

@PoisonousJohn
Copy link
Contributor Author

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

@timsueberkrueb
Copy link
Collaborator

@JohnPoison That would be cool :) If we have to use WebChannels, we should merge feature/qtwebengine first. But couldn't we just get the scroll position by running some JavaScript in the page as we do for theme color support?

@PoisonousJohn
Copy link
Contributor Author

@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

@timsueberkrueb
Copy link
Collaborator

@JohnPoison I see, that's right. We could also use WebChannels for theme color handling then.

@timsueberkrueb
Copy link
Collaborator

feature/qtwebengine was merged with develop (including the travis fix). You'll probably want to rebase your work on develop. Thanks!

@PoisonousJohn PoisonousJohn force-pushed the feature/start_with_last_opened_tabs branch from dd8fecd to 27c617f Compare May 8, 2017 18:56
@PoisonousJohn
Copy link
Contributor Author

Lol, it seems i've messed up with git. Will fix it 10th of May.

@PoisonousJohn PoisonousJohn force-pushed the feature/start_with_last_opened_tabs branch 2 times, most recently from 5177adb to a88b184 Compare May 10, 2017 11:47
@PoisonousJohn
Copy link
Contributor Author

@tim-sueberkrueb rebase done.

Copy link
Collaborator

@timsueberkrueb timsueberkrueb left a 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"
Copy link
Collaborator

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" }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please use qsTr() now

* $END_LICENSE$
*/

#include "Session.h"
Copy link
Collaborator

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".

@timsueberkrueb
Copy link
Collaborator

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.
What do you think?

@ShalokShalom
Copy link

Completely agree. +1

Just think about cases with 20-40 tabs open and more..

@timsueberkrueb
Copy link
Collaborator

timsueberkrueb commented Sep 30, 2017

Another problem with this I haven't thought of yet is multi window support.

@PoisonousJohn PoisonousJohn force-pushed the feature/start_with_last_opened_tabs branch 2 times, most recently from ecd37d8 to b2f5836 Compare March 14, 2018 09:19
@PoisonousJohn
Copy link
Contributor Author

Rebased on develop.
Added lazy loading of the tabs.

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.

Copy link
Collaborator

@timsueberkrueb timsueberkrueb left a 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.

{
for (var i = 0; i < tabContentView.pages.count; ++i)
{
var tabPage = tabContentView.pages.get(i).item;
Copy link
Collaborator

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) {

background: background
});
function completeTabsRestore()
{
Copy link
Collaborator

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() {

);
break;
if (!loadContent)
{
Copy link
Collaborator

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.

}
else
{
Copy link
Collaborator

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()
{
Copy link
Collaborator

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)
{
Copy link
Collaborator

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.


m_activeTab = std::max(m_tabs.count() - 1, 0);
if (root.find("activeTab") != root.end())
{
Copy link
Collaborator

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-

Copy link
Contributor Author

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# :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

No problem, thanks! :)

Q_PROPERTY(int activeTab READ getActiveTab)

int getActiveTab() { return m_activeTab; }
signals:
Copy link
Collaborator

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure

Copy link
Collaborator

@timsueberkrueb timsueberkrueb left a 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


float TabState::readingProgress() const
{
return m_readingProgress;
Copy link
Collaborator

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, sure

tabObject["url"] = tab->url().toString();
tabObject["title"] = tab->title();
tabObject["icon"] = tab->iconUrl().toString().replace("image://favicon/","");
tabObject["readingProgress"] = 0.f;
Copy link
Collaborator

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?

Copy link
Contributor Author

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?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yep, let's :)

@PoisonousJohn
Copy link
Contributor Author

Thinking about it, couldn't we merge LazyWebContent and WebContent? I'm thinking about making WebContent just contain the loader wrapping the WebEngineView and getting an additional lazy property to toggle default or lazy loading.

I have thought about it, and even tried, but something went wrong. Let me try again.
Then it should fix problems with the settings page as well

@PoisonousJohn
Copy link
Contributor Author

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

I almost sure that I have fixed it. It seems I've lost the change during problems with rebase. Let me fix it again

@ShalokShalom
Copy link

Oh rebase ^-^

@ShalokShalom
Copy link

@PoisonousJohn
Copy link
Contributor Author

This iteration looks more appropriate. liri-settings bug is fixed as well

@timsueberkrueb
Copy link
Collaborator

Awesome, thank you! Will check it out a bit later today!

Copy link
Collaborator

@timsueberkrueb timsueberkrueb left a 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!

@@ -59,6 +55,15 @@ Item {
property var contentItem
property int tabType

function tryCreateContent() {
console.log("Try create content");
Copy link
Collaborator

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?

@@ -42,6 +42,11 @@ Session::Session(QObject *parent)

void Session::save(TabsModel* tabs)
{
if (!QDir(Paths::DataLocation).exists()) {
qDebug() << "DataLocation path doesn't exist.";
Copy link
Collaborator

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".


return true;
}

onActiveTabChanged: {
console.log("onActiveTabChanged");
Copy link
Collaborator

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?

{
QVariantList tabs;
for (TabState* state : m_tabs)
{
Copy link
Collaborator

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
Copy link
Collaborator

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.

Copy link
Contributor Author

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, all right.

if (contentItem || !loadContent || tab !== activeTab)
return;

console.log("Creating content");
Copy link
Collaborator

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?

tabObject["url"] = tab->url().toString();
tabObject["title"] = tab->title();
tabObject["icon"] = tab->iconUrl().toString().replace("image://favicon/","");
tabObject["readingProgress"] = 0.f;
Copy link
Collaborator

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?

@PoisonousJohn
Copy link
Contributor Author

We also probably want to prevent saving the icon url for liri://
I would leave it as is for consistency, since it works fine. I don't want to check url for "liri://".

@@ -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")
Copy link
Contributor Author

@PoisonousJohn PoisonousJohn Mar 16, 2018

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.

Copy link
Collaborator

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" }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use qsTr()

@timsueberkrueb
Copy link
Collaborator

Looking good otherwise!

@PoisonousJohn
Copy link
Contributor Author

@tim-sueberkrueb I believe everything is ok now :)

@timsueberkrueb
Copy link
Collaborator

@PoisonousJohn I think you need to remove replace("https", "http") :)

@PoisonousJohn
Copy link
Contributor Author

@tim-sueberkrueb yeah, sure, I forgot about that, still didn't test it in a "Empty" project

@PoisonousJohn
Copy link
Contributor Author

@tim-sueberkrueb done

@timsueberkrueb
Copy link
Collaborator

@PoisonousJohn do you have any preference on merging the PR? Should I squash your commits?

@timsueberkrueb timsueberkrueb merged commit 2c13e35 into lirios:develop Mar 21, 2018
@timsueberkrueb
Copy link
Collaborator

Thank you @PoisonousJohn!

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.

3 participants