Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Eeems committed Feb 10, 2023
1 parent 6516719 commit 3da3981
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 17 deletions.
62 changes: 51 additions & 11 deletions applications/web-browser/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ ApplicationWindow {
width: screenGeometry.width
height: screenGeometry.height
title: page.url
property string home: "https://eink.link"
FontLoader { id: iconFont; source: "/font/icomoon.ttf" }
Component.onCompleted: {
controller.startup();
page.open("https://eink.link");
page.load(window.home);
}
header: Rectangle {
color: "black"
Expand All @@ -26,34 +27,59 @@ ApplicationWindow {
anchors.right: parent.right
Label {
text: "⬅️"
color: "white"
color: enabled ? "white" : "black"
topPadding: 5
bottomPadding: 5
leftPadding: 10
rightPadding: 10
enabled: !page.loading && page.history.length
MouseArea {
enabled: parent.enabled
anchors.fill: parent
onClicked: page.back()
}
}
Item { Layout.fillWidth: true }
Label {
text: ""
color: enabled ? "white" : "black"
topPadding: 5
bottomPadding: 5
leftPadding: 10
rightPadding: 10
enabled: !page.loading && page._history.length
MouseArea {
enabled: parent.enabled
anchors.fill: parent
onClicked: page.next()
}
}
TextInput {
id: input
color: "white"
color: enabled ? "white" : "grey"
text: "about:blank"
onFocusChanged: keyboard.visible = focus;
clip: true
Layout.fillWidth: true
onFocusChanged: keyboard.visible = focus
readOnly: page.loading
onAccepted: {
page.open(text);
focus = false;
}
}
Item { Layout.fillWidth: true }
CustomMenu {
visible: stateController.state === "loaded"
BetterMenu {
title: ""
title: qsTr("");
font: iconFont.name
width: 310
MenuItem {
text: "Go Home"
onClicked: page.open(window.home);
}
MenuItem {
text: "Exit"
onClicked: Qt.quit();
}
}
}
}
Expand All @@ -73,28 +99,42 @@ ApplicationWindow {
Keys.enabled: true
textFormat: Text.RichText
wrapMode: Text.Wrap
property bool loading: false
property string url: "about:blank"
property var history: []
property var _history: []
function open(url){
history.push(this.url);
_history = [];
load(url);
}
function back(url){
function back(){
if(!history.length){
input.text = url = "about:blank"
text = "";
return;
}
load(history.pop());
var url = history.pop()
_history.push(url);
load(url);
}
function next(){
if(!_history.length){
return;
}
var url = _history.pop();
history.push(url);
load(url);
}
function load(url){
loading = true;
input.text = "Loading...";
var req = new XMLHttpRequest();
req.onreadystatechange = function(){
if(req.readyState === XMLHttpRequest.DONE){
input.text = page.url = url;
page.y = 100;
page.text = "<link type='stylesheet' href='page.css'/>" + JS.replace_all_rel_by_abs(url, req.responseText);
console.log("Loaded: " + url);
loading = false;
}
};
req.onerror = function(e){
Expand Down
6 changes: 1 addition & 5 deletions applications/web-browser/web-browser.pro
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
QT += gui
QT += quick
QT += dbus
QT += webkitwidgets

CONFIG += c++11
CONFIG += qml_debug
Expand Down Expand Up @@ -39,10 +39,6 @@ splash.files += ../../assets/opt/usr/share/icons/oxide/702x702/splash/web.png
splash.path = /opt/usr/share/icons/oxide/702x702/splash
INSTALLS += splash

DBUS_INTERFACES += ../../interfaces/dbusservice.xml
DBUS_INTERFACES += ../../interfaces/screenapi.xml
DBUS_INTERFACES += ../../interfaces/screenshot.xml

INCLUDEPATH += ../../shared
HEADERS += \
../../shared/dbussettings.h \
Expand Down
2 changes: 1 addition & 1 deletion applications/web-browser/widgets/KeyboardKey.qml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Item {
property bool repeatOnHold: true
property int holdInterval: 100
property int key: 0
property string value: null
property string value: ""
property int size: 1
property int basesize: 90
property int fontsize: 8
Expand Down

0 comments on commit 3da3981

Please sign in to comment.