Redesigned the daemon console pop-up

This commit is contained in:
Sander Ferdinand 2018-04-21 18:44:42 +02:00
parent 60cefb3820
commit 7d8d477a19

View file

@ -27,22 +27,23 @@
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import QtQuick 2.0 import QtQuick 2.0
import QtQuick.Controls 1.4 import QtQuick.Controls 2.0
import QtQuick.Dialogs 1.2 import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.1 import QtQuick.Layouts 1.1
import QtQuick.Controls.Styles 1.4 import QtQuick.Controls.Styles 1.4
import QtQuick.Window 2.0 import QtQuick.Window 2.2
import "../components" as MoneroComponents import "../components" as MoneroComponents
import "../js/Windows.js" as Windows
import "../js/Utils.js" as Utils
Window { Window {
id: root id: root
modality: Qt.ApplicationModal modality: Qt.ApplicationModal
flags: Qt.Window | Qt.FramelessWindowHint color: "black"
property alias title: dialogTitle.text flags: Windows.flags
property alias text: dialogContent.text property alias text: dialogContent.text
property alias content: root.text property alias content: root.text
property alias okVisible: okButton.visible
property alias textArea: dialogContent property alias textArea: dialogContent
property var icon property var icon
@ -50,15 +51,25 @@ Window {
signal accepted() signal accepted()
signal rejected() signal rejected()
onClosing: {
inactiveOverlay.visible = false;
}
function open() { function open() {
show() inactiveOverlay.visible = true;
show();
} }
// TODO: implement without hardcoding sizes // TODO: implement without hardcoding sizes
width: 480 width: 480
height: 280 height: 280
// background gradient
Image {
anchors.fill: parent
source: "../images/middlePanelBg.jpg"
}
// Make window draggable // Make window draggable
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
@ -70,79 +81,136 @@ Window {
ColumnLayout { ColumnLayout {
id: mainLayout id: mainLayout
spacing: 10
anchors { fill: parent; margins: 35 } anchors.fill: parent
anchors.topMargin: 20 * scaleRatio
anchors.margins: 35 * scaleRatio
spacing: 20 * scaleRatio
RowLayout { RowLayout {
id: column id: content
//anchors {fill: parent; margins: 16 } Layout.fillWidth: true
Layout.alignment: Qt.AlignHCenter Layout.fillHeight: true
Label { Flickable {
id: dialogTitle id: flickable
horizontalAlignment: Text.AlignHCenter anchors.fill: parent
font.pixelSize: 32
font.family: "Arial"
color: "#555555"
}
} TextArea.flickable: TextArea {
id : dialogContent
textFormat: TextEdit.RichText
selectByMouse: true
selectByKeyboard: true
anchors.fill: parent
font.family: "Ariel"
font.pixelSize: 14 * scaleRatio
color: MoneroComponents.Style.defaultFontColor
selectionColor: MoneroComponents.Style.dimmedFontColor
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");
textArea.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";
}
RowLayout { // format multi-lines
TextArea { if(msg.split("\n").length >= 2){
id : dialogContent msg = msg.split("\n").join('<br>');
Layout.fillWidth: true }
Layout.fillHeight: true
font.family: "Arial"
textFormat: TextEdit.AutoText
readOnly: true
font.pixelSize: 12
}
}
// Ok/Cancel buttons log(msg, color);
RowLayout { }
id: buttons function log_color(msg, color){
spacing: 60 return "<span style='color: " + color + ";' >" + msg + "</span>";
Layout.alignment: Qt.AlignHCenter }
function log(msg, color){
var timestamp = Utils.formatDate(new Date(), {
weekday: undefined,
month: "numeric",
timeZoneName: undefined
});
MoneroComponents.StandardButton { var _timestamp = log_color("[" + timestamp + "]", "#FFFFFF");
id: okButton var _msg = log_color(msg, color);
width: 120 textArea.append(_timestamp + " " + _msg);
fontSize: 14
text: qsTr("Close") + translationManager.emptyString
onClicked: {
root.close()
root.accepted()
// scroll to bottom
if(flickable.contentHeight > content.height){
flickable.contentY = flickable.contentHeight + 20;
}
}
}
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
} }
} }
}
RowLayout {
Layout.fillWidth: true
MoneroComponents.LineEdit { MoneroComponents.LineEdit {
id: sendCommandText id: sendCommandText
width: 300 Layout.fillWidth: true
placeholderText: qsTr("command + enter (e.g help)") + translationManager.emptyString placeholderText: qsTr("command + enter (e.g help)") + translationManager.emptyString
onAccepted: { onAccepted: {
if(text.length > 0) if(text.length > 0) {
daemonManager.sendCommand(text,currentWallet.nettype); textArea.logCommand(">>> " + text)
daemonManager.sendCommand(text, currentWallet.nettype);
}
text = "" text = ""
} }
} }
// Status button
// MoneroComponents.StandardButton {
// id: sendCommandButton
// enabled: sendCommandText.text.length > 0
// fontSize: 14
// text: qsTr("Send command")
// onClicked: {
// daemonManager.sendCommand(sendCommandText.text,currentWallet.testnet);
// }
// }
} }
} }
} // window borders
Rectangle {
anchors.bottom: parent.bottom
anchors.top: parent.top
anchors.left: parent.left
width:1
color: "#2F2F2F"
z: 2
}
Rectangle {
anchors.bottom: parent.bottom
anchors.top: parent.top
anchors.right: parent.right
width:1
color: "#2F2F2F"
z: 2
}
Rectangle {
anchors.bottom: parent.bottom
anchors.right: parent.right
anchors.left: parent.left
height:1
color: "#2F2F2F"
z: 2
}
}