SettingsLog: fix TextArea layout, border, scrollbar

pull/2/head
xiphon 6 years ago
parent bac833c1dd
commit d2d4c21cde

@ -87,10 +87,17 @@ Window {
anchors.margins: 35 * scaleRatio anchors.margins: 35 * scaleRatio
spacing: 20 * scaleRatio spacing: 20 * scaleRatio
RowLayout { Item {
id: content
Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
Layout.fillWidth: true
Rectangle {
anchors.fill: parent
color: "transparent"
border.color: MoneroComponents.Style.inputBorderColorActive
border.width: 1
radius: 4
}
Flickable { Flickable {
id: flickable id: flickable
@ -101,20 +108,12 @@ Window {
textFormat: TextEdit.RichText textFormat: TextEdit.RichText
selectByMouse: true selectByMouse: true
selectByKeyboard: true selectByKeyboard: true
anchors.fill: parent font.family: MoneroComponents.Style.defaultFontColor
font.family: "Ariel"
font.pixelSize: 14 * scaleRatio font.pixelSize: 14 * scaleRatio
color: MoneroComponents.Style.defaultFontColor color: MoneroComponents.Style.defaultFontColor
selectionColor: MoneroComponents.Style.dimmedFontColor selectionColor: MoneroComponents.Style.dimmedFontColor
wrapMode: TextEdit.Wrap wrapMode: TextEdit.Wrap
readOnly: true readOnly: true
background: Rectangle {
color: "transparent"
anchors.fill: parent
border.color: Qt.rgba(255, 255, 255, 0.25);
border.width: 1
radius: 4
}
function logCommand(msg){ function logCommand(msg){
msg = log_color(msg, "lime"); msg = log_color(msg, "lime");
textArea.append(msg); textArea.append(msg);
@ -156,15 +155,7 @@ Window {
} }
} }
ScrollBar.vertical: ScrollBar { ScrollBar.vertical: ScrollBar {}
// TODO: scrollbar always visible is buggy.
// QT 5.9 introduces `policy: ScrollBar.AlwaysOn`
contentItem.opacity: 1
anchors.top: flickable.top
anchors.left: flickable.right
anchors.leftMargin: 10 * scaleRatio
anchors.bottom: flickable.bottom
}
} }
} }

@ -138,79 +138,76 @@ Rectangle {
text: qsTr("Daemon log") + translationManager.emptyString text: qsTr("Daemon log") + translationManager.emptyString
} }
Flickable { Item {
id: flickable Layout.fillHeight: true
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: 240 * scaleRatio Layout.preferredHeight: 240 * scaleRatio
TextArea.flickable: TextArea { Rectangle {
id : consoleArea
anchors.fill: parent anchors.fill: parent
color: MoneroComponents.Style.defaultFontColor color: "transparent"
selectionColor: MoneroComponents.Style.dimmedFontColor border.color: MoneroComponents.Style.inputBorderColorActive
textFormat: TextEdit.RichText border.width: 1
selectByMouse: true radius: 4
selectByKeyboard: true }
font.family: "Ariel"
font.pixelSize: 14 * scaleRatio
wrapMode: TextEdit.Wrap
readOnly: true
background: Rectangle {
color: "transparent"
anchors.fill: parent
border.color: Qt.rgba(255, 255, 255, 0.25);
border.width: 1
radius: 4
}
function logCommand(msg){
msg = log_color(msg, "lime");
consoleArea.append(msg);
}
function logMessage(msg){
msg = msg.trim();
var color = "white";
if(msg.toLowerCase().indexOf('error') >= 0){
color = "red";
} else if (msg.toLowerCase().indexOf('warning') >= 0){
color = "yellow";
}
// format multi-lines Flickable {
if(msg.split("\n").length >= 2){ id: flickable
msg = msg.split("\n").join('<br>'); anchors.fill: parent
}
log(msg, color); TextArea.flickable: TextArea {
} id : consoleArea
function log_color(msg, color){ color: MoneroComponents.Style.defaultFontColor
return "<span style='color: " + color + ";' >" + msg + "</span>"; selectionColor: MoneroComponents.Style.dimmedFontColor
} textFormat: TextEdit.RichText
function log(msg, color){ selectByMouse: true
var timestamp = Utils.formatDate(new Date(), { selectByKeyboard: true
weekday: undefined, font.family: MoneroComponents.Style.defaultFontColor
month: "numeric", font.pixelSize: 14 * scaleRatio
timeZoneName: undefined wrapMode: TextEdit.Wrap
}); readOnly: true
function logCommand(msg){
var _timestamp = log_color("[" + timestamp + "]", "#FFFFFF"); msg = log_color(msg, "lime");
var _msg = log_color(msg, color); consoleArea.append(msg);
consoleArea.append(_timestamp + " " + _msg); }
function logMessage(msg){
// scroll to bottom msg = msg.trim();
//if(flickable.contentHeight > content.height){ var color = "white";
// flickable.contentY = flickable.contentHeight; if(msg.toLowerCase().indexOf('error') >= 0){
//} color = "red";
} else if (msg.toLowerCase().indexOf('warning') >= 0){
color = "yellow";
}
// format multi-lines
if(msg.split("\n").length >= 2){
msg = msg.split("\n").join('<br>');
}
log(msg, color);
}
function log_color(msg, color){
return "<span style='color: " + color + ";' >" + msg + "</span>";
}
function log(msg, color){
var timestamp = Utils.formatDate(new Date(), {
weekday: undefined,
month: "numeric",
timeZoneName: undefined
});
var _timestamp = log_color("[" + timestamp + "]", "#FFFFFF");
var _msg = log_color(msg, color);
consoleArea.append(_timestamp + " " + _msg);
// scroll to bottom
//if(flickable.contentHeight > content.height){
// flickable.contentY = flickable.contentHeight;
//}
}
} }
}
ScrollBar.vertical: ScrollBar { ScrollBar.vertical: ScrollBar {}
// TODO: scrollbar always visible is buggy.
// QT 5.9 introduces `policy: ScrollBar.AlwaysOn`
contentItem.opacity: 1
anchors.top: flickable.top
anchors.left: flickable.right
anchors.leftMargin: 10 * scaleRatio
anchors.bottom: flickable.bottom
} }
} }