diff --git a/CellFrameDashboardGUI/DapServiceController.cpp b/CellFrameDashboardGUI/DapServiceController.cpp index 6f2a209b32edf122b6656c792d0a6570dd34dcb7..b2bfb7d51d757c0e1d27a2a3fb2a92fcdbefd109 100644 --- a/CellFrameDashboardGUI/DapServiceController.cpp +++ b/CellFrameDashboardGUI/DapServiceController.cpp @@ -85,6 +85,8 @@ void DapServiceController::registerCommand() m_transceivers.append(qMakePair(dynamic_cast<DapAbstractCommand*>(m_DAPRpcSocket->addService(new DapAddWalletCommand("DapAddWalletCommand", m_DAPRpcSocket))), QString("walletCreated"))); // The command to get a list of available wallets m_transceivers.append(qMakePair(dynamic_cast<DapAbstractCommand*>(m_DAPRpcSocket->addService(new DapGetListWalletsCommand("DapGetListWalletsCommand", m_DAPRpcSocket))), QString("walletsListReceived"))); + // Command to save data from the Logs tab + m_transceivers.append(qMakePair(dynamic_cast<DapAbstractCommand*>(m_DAPRpcSocket->addService(new DapExportLogCommand("DapExportLogCommand",m_DAPRpcSocket))), QString("exportLogs"))); registerEmmitedSignal(); } diff --git a/CellFrameDashboardGUI/DapServiceController.h b/CellFrameDashboardGUI/DapServiceController.h index 90288f3552c0e408e8f689110cecd59bdd1ac051..7866c5735c139175ca486a93ce6250a9f45dc977 100644 --- a/CellFrameDashboardGUI/DapServiceController.h +++ b/CellFrameDashboardGUI/DapServiceController.h @@ -10,13 +10,14 @@ #include <QDataStream> #include "DapServiceClient.h" +#include "DapWallet.h" #include "Handlers/DapAbstractCommand.h" #include "Handlers/DapQuitApplicationCommand.h" #include "Handlers/DapActivateClientCommand.h" #include "Handlers/DapUpdateLogsCommand.h" #include "Handlers/DapAddWalletCommand.h" #include "Handlers/DapGetListWalletsCommand.h" -#include "DapWallet.h" +#include "Handlers/DapExportLogCommand.h" class DapServiceController : public QObject { @@ -85,8 +86,11 @@ signals: void versionChanged(const QString &version); /// The signal is emitted when a command to activate a client is received. void clientActivated(); - /// A signal that is used to transmit data to the log model. - /// @param historyString QStringList + ///This signal sends data about saving a file from the Logs tab + /// @param saveLogRezult + void saveLogRezult(const QVariant& message); + ///A signal that is used to transmit data to the log model. + /// @param logUpdated QStringList void logUpdated(const QVariant& logs); void walletCreated(const QVariant& wallet); diff --git a/CellFrameDashboardGUI/qml.qrc b/CellFrameDashboardGUI/qml.qrc index 871e8d518fd7d2166c565ed70e37adad825a9b10..4c146773938f73aaeea929fe758dda70630efa6b 100755 --- a/CellFrameDashboardGUI/qml.qrc +++ b/CellFrameDashboardGUI/qml.qrc @@ -125,5 +125,10 @@ <file>screen/desktop/Console/DapConsoleTopPanel.qml</file> <file>screen/desktop/Console/DapConsoleTopPanelForm.ui.qml</file> <file>res/icons/icon.ico</file> + <file>res/icons/ic_flag.png</file> + <file>res/icons/buy_icon.png</file> + <file>res/icons/ic_arrow_drop_down_dark_blue.png</file> + <file>res/icons/ic_arrow_drop_up_dark_blue.png</file> + <file>res/icons/sell_icon.png</file> </qresource> </RCC> diff --git a/CellFrameDashboardGUI/res/icons/buy_icon.png b/CellFrameDashboardGUI/res/icons/buy_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..73059a679d93adf2fe007130dfac72d0f5b4a5d8 Binary files /dev/null and b/CellFrameDashboardGUI/res/icons/buy_icon.png differ diff --git a/CellFrameDashboardGUI/res/icons/ic_arrow_drop_down_dark_blue.png b/CellFrameDashboardGUI/res/icons/ic_arrow_drop_down_dark_blue.png new file mode 100644 index 0000000000000000000000000000000000000000..1ac87aaa588bca2ae4b208cab2e93b3606f7b1e3 Binary files /dev/null and b/CellFrameDashboardGUI/res/icons/ic_arrow_drop_down_dark_blue.png differ diff --git a/CellFrameDashboardGUI/res/icons/ic_arrow_drop_up_dark_blue.png b/CellFrameDashboardGUI/res/icons/ic_arrow_drop_up_dark_blue.png new file mode 100644 index 0000000000000000000000000000000000000000..3fe34c8940c90afcecbe24eefd9a9db045be19fb Binary files /dev/null and b/CellFrameDashboardGUI/res/icons/ic_arrow_drop_up_dark_blue.png differ diff --git a/CellFrameDashboardGUI/res/icons/ic_flag.png b/CellFrameDashboardGUI/res/icons/ic_flag.png new file mode 100644 index 0000000000000000000000000000000000000000..679d3b98ace1a9f868f7f05b4ea0642056df065c Binary files /dev/null and b/CellFrameDashboardGUI/res/icons/ic_flag.png differ diff --git a/CellFrameDashboardGUI/res/icons/sell_icon.png b/CellFrameDashboardGUI/res/icons/sell_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..bf39ea660064efbbf5708841662ee5a6b50aa971 Binary files /dev/null and b/CellFrameDashboardGUI/res/icons/sell_icon.png differ diff --git a/CellFrameDashboardGUI/screen/desktop/Dashboard/DapDashboardTopPanel.qml b/CellFrameDashboardGUI/screen/desktop/Dashboard/DapDashboardTopPanel.qml index 485ee280ff5edb56c2c3939adf4abc40cf21f0d8..69912e4283fc90127fc451449d872c164bda14b9 100644 --- a/CellFrameDashboardGUI/screen/desktop/Dashboard/DapDashboardTopPanel.qml +++ b/CellFrameDashboardGUI/screen/desktop/Dashboard/DapDashboardTopPanel.qml @@ -14,6 +14,11 @@ DapDashboardTopPanelForm id: modelWallets } + ListModel + { + id: modelTokens + } + Connections { target: dapServiceController diff --git a/CellFrameDashboardGUI/screen/desktop/Dashboard/DapDashboardTopPanelForm.ui.qml b/CellFrameDashboardGUI/screen/desktop/Dashboard/DapDashboardTopPanelForm.ui.qml index 7d5179e63a45ccd1cb36d7f6d0e8abf4e1893bad..1a41f58423b1775a93834dfd3c54a0d4276f4405 100644 --- a/CellFrameDashboardGUI/screen/desktop/Dashboard/DapDashboardTopPanelForm.ui.qml +++ b/CellFrameDashboardGUI/screen/desktop/Dashboard/DapDashboardTopPanelForm.ui.qml @@ -25,7 +25,7 @@ DapAbstractTopPanel // Wallet selection combo box Rectangle { - id: frameComboBox + id: frameComboBoxWallet anchors.left: textHeaderWallet.right anchors.verticalCenter: parent.verticalCenter @@ -37,6 +37,7 @@ DapAbstractTopPanel { id: comboboxWallet model: modelWallets + mainLineText: "all wallets" indicatorImageNormal: "qrc:/res/icons/ic_arrow_drop_down.png" indicatorImageActive: "qrc:/res/icons/ic_arrow_drop_up.png" sidePaddingNormal: 0 * pt @@ -66,7 +67,54 @@ DapAbstractTopPanel colorDropShadow: "#40ABABAB" fontComboBox.pixelSize: 14 * pt fontComboBox.family: "Roboto" + } + } + + // Token selection combo box + Rectangle + { + id: frameComboBoxToken + + anchors.left: frameComboBoxWallet.right + anchors.verticalCenter: parent.verticalCenter + anchors.leftMargin: 70 * pt + width: 148 * pt + color: "transparent" + DapComboBox + { + id: comboboxToken + model: modelTokens + mainLineText: "all tokens" + indicatorImageNormal: "qrc:/res/icons/ic_arrow_drop_down.png" + indicatorImageActive: "qrc:/res/icons/ic_arrow_drop_up.png" + sidePaddingNormal: 0 * pt + sidePaddingActive: 16 * pt + normalColorText: "#070023" + hilightColorText: "#FFFFFF" + normalColorTopText: "#FFFFFF" + hilightColorTopText: "#070023" + hilightColor: "#330F54" + normalTopColor: "#070023" + widthPopupComboBoxNormal: 148 * pt + widthPopupComboBoxActive: 180 * pt + heightComboBoxNormal: 24 * pt + heightComboBoxActive: 44 * pt + bottomIntervalListElement: 8 * pt + topEffect: false + x: popup.visible ? sidePaddingActive * (-1) : sidePaddingNormal + normalColor: "#FFFFFF" + hilightTopColor: normalColor + paddingTopItemDelegate: 8 * pt + heightListElement: 32 * pt + intervalListElement: 10 * pt + indicatorWidth: 24 * pt + indicatorHeight: indicatorWidth + indicatorLeftInterval: 8 * pt + colorTopNormalDropShadow: "#00000000" + colorDropShadow: "#40ABABAB" + fontComboBox.pixelSize: 14 * pt + fontComboBox.family: "Roboto" } } @@ -75,7 +123,7 @@ DapAbstractTopPanel { id: headerWalletBalance text: qsTr("Wallet balance") - anchors.left: frameComboBox.right + anchors.left: frameComboBoxToken.right anchors.leftMargin: 70 * pt anchors.verticalCenter: parent.verticalCenter font.family: DapMainApplicationWindow.dapFontRobotoRegular.name diff --git a/CellFrameDashboardGUI/screen/desktop/Exchange/DapExchangeRightPanelForm.ui.qml b/CellFrameDashboardGUI/screen/desktop/Exchange/DapExchangeRightPanelForm.ui.qml index 30854206e6f566b91165ea20266419ec6970da86..67cd44497c5d67ae7013b7feb78821aa8175238f 100644 --- a/CellFrameDashboardGUI/screen/desktop/Exchange/DapExchangeRightPanelForm.ui.qml +++ b/CellFrameDashboardGUI/screen/desktop/Exchange/DapExchangeRightPanelForm.ui.qml @@ -3,7 +3,7 @@ import "../../" DapAbstractRightPanel { - dapFrame.color: "yellow" + visible: false } /*##^## diff --git a/CellFrameDashboardGUI/screen/desktop/Exchange/DapExchangeScreen.qml b/CellFrameDashboardGUI/screen/desktop/Exchange/DapExchangeScreen.qml index e3fb119f13ce3cdb71f114d48b2af96baa796a23..d522f19abbdd78238ddbaf43db55cc74d2092714 100644 --- a/CellFrameDashboardGUI/screen/desktop/Exchange/DapExchangeScreen.qml +++ b/CellFrameDashboardGUI/screen/desktop/Exchange/DapExchangeScreen.qml @@ -1,4 +1,645 @@ import QtQuick 2.4 +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.0 +import "qrc:/widgets" -DapExchangeScreenForm { + +DapExchangeScreenForm +{ + ListModel{ + id:candleModel + ListElement{time:1546543400;minimum:10000;maximum:10550;open:10050;close:10100;} + ListElement{time:1546543700;minimum:10200;maximum:10450;open:10350;close:10400;} + ListElement{time:1546544000;minimum:10200;maximum:10450;open:10350;close:10400;} + ListElement{time:1546544300;minimum:10200;maximum:10450;open:10350;close:10400;} + ListElement{time:1546544600;minimum:10200;maximum:10450;open:10350;close:10400;} + ListElement{time:1546544900;minimum:10200;maximum:10450;open:10350;close:10400;} + ListElement{time:1546545200;minimum:10200;maximum:10450;open:10350;close:10400;} + ListElement{time:1546545500;minimum:10200;maximum:10450;open:10350;close:10400;} + ListElement{time:1546545800;minimum:10200;maximum:10450;open:10350;close:10400;} + ListElement{time:1546546100;minimum:10200;maximum:10450;open:10350;close:10400;} + ListElement{time:1546546400;minimum:10200;maximum:10450;open:10350;close:10400;} + ListElement{time:1546546700;minimum:10300;maximum:10550;open:10450;close:10400;} + ListElement{time:1546547000;minimum:10200;maximum:10650;open:10350;close:10400;} + ListElement{time:1546547300;minimum:10200;maximum:10450;open:10350;close:10400;} + ListElement{time:1546547600;minimum:10200;maximum:10450;open:10350;close:10400;} + ListElement{time:1546547900;minimum:10200;maximum:10450;open:10350;close:10400;} + ListElement{time:1546548200;minimum:10200;maximum:10450;open:10350;close:10400;} + ListElement{time:1546548500;minimum:10200;maximum:10450;open:10350;close:10400;} + ListElement{time:1546548800;minimum:10200;maximum:10450;open:10350;close:10400;} + ListElement{time:1546549100;minimum:10200;maximum:10450;open:10350;close:10400;} + ListElement{time:1546549400;minimum:10300;maximum:10650;open:10450;close:10400;} + ListElement{time:1546549700;minimum:10200;maximum:10450;open:10350;close:10400;} + ListElement{time:1546550000;minimum:10200;maximum:10450;open:10350;close:10400;} + ListElement{time:1546550300;minimum:10200;maximum:10450;open:10350;close:10400;} + ListElement{time:1546550600;minimum:10200;maximum:10450;open:10350;close:10400;} + ListElement{time:1546550900;minimum:10500;maximum:10650;open:10550;close:10580;} + ListElement{time:1546551200;minimum:10200;maximum:10450;open:10350;close:10400;} + ListElement{time:1546551500;minimum:10200;maximum:10450;open:10350;close:10400;} + ListElement{time:1546551800;minimum:10200;maximum:10450;open:10350;close:10400;} + ListElement{time:1546552100;minimum:10200;maximum:10450;open:10350;close:10400;} + ListElement{time:1546552400;minimum:10200;maximum:10450;open:10350;close:10400;} + ListElement{time:1546552700;minimum:10200;maximum:10450;open:10350;close:10400;} + ListElement{time:1546553000;minimum:10200;maximum:10450;open:10350;close:10400;} + ListElement{time:1546553300;minimum:10200;maximum:10450;open:10350;close:10400;} + ListElement{time:1546553600;minimum:10650;maximum:10950;open:10800;close:10750;} + ListElement{time:1546553900;minimum:10200;maximum:10450;open:10350;close:10400;} + ListElement{time:1546554200;minimum:10200;maximum:10450;open:10350;close:10400;} + ListElement{time:1546554500;minimum:10200;maximum:10450;open:10350;close:10400;} + ListElement{time:1546554800;minimum:10200;maximum:10450;open:10350;close:10400;} + } + //=====================================DapChartCandleStick========================================================= + Component + { + id:candleChart + + + Canvas + { + + id: chartCanvas + + //@detalis rightTime Indicates the completion time of the graph on the display. + property var rightTime: 1546564800 + ///@detalis maxXLine Indicates the maximum number of vertical lines. + property int maxXLine: 6 + ///@detalis maxYLine Indicates the maximum number of horisontal lines. + property int maxYLine: 10 + ///@detalis heightNoLine Indicates an indentation at the top where horizontal lines are not displayed. + property int heightNoLine: 40*pt + ///@detalis marginHorizontalLineToYAxisText Indicates the indent between text and lines. + property int marginHorizontalLineToYAxisText:14 * pt + ///@detalis rightTextField Width of the right text box. + property int rightTextField: 31 * pt + ///@detalis bottomOutLine The height of the line protrusion below the graph field. + property int bottomOutLine: 4 * pt + ///@detalis fontColorArea Axial font color. + property string fontColorArea: "#757184" + ///@detalis fontSizeArea Size font. + property int fontSizeArea: 10 * pt + ///@detalis topMarginXAxisText Indicates the indent between text and lines. + property int topMarginXAxisText: 8 * pt + ///@detalis lineColorArea Line color. + property string lineColorArea: "#C7C6CE" + ///@detalis lineWidthArea Width color. + property int lineWidthArea: 1 + ///@detalis candleColorUp Bull color. + property string candleColorUp:"#6F9F00" + ///@detalis candleColorDown Bear candle color + property string candleColorDown:"#EB4D4B" + ///@detalis candleWidthLine Width candle. + property int candleWidthLine: 1 * pt + ///@detalis candleWidth Width body candle. + property int candleWidth: 5 * pt + ///@detalis imageCursorPath Path icon flug current. + property string imageCursorPath: "qrc:/res/icons/ic_flag.png" + ///@detalis imageCursorWidth Width icon. + property int imageCursorWidth: 44 * pt + ///@detalis imageCursorHeight Height icon. + property int imageCursorHeight: 16 * pt + ///@detalis colorCursorLine Cursor line color. + property string colorCursorLine:"#070023" + ///@detalis colorCursorFont Cursor font color. + property string colorCursorFont: "#FFFFFF" + ///@detalis fontSizeCursor Cursor font size. + property int fontSizeCursor: 10*pt + ///@detalis currentValue Current value price. + property int currentValue: 10236 + ///@detalis stepTime Time step for vertical line. + property int stepTime:thisProperty.hour + ///@detalis cashCandle The number of candles outside the screen from the right and left. + property int cashCandle: 5 + ///@detalis isRightTimeCurrent Graphic redraw resolution for offset + property bool isRightTimeCurrent: false + ///@detalis moveTimeForVisual Time offset for visualization of vertical stripes + property var moveTimeForVisual: 20*thisProperty.minute + ///@detalis currentValueTime Data update time for the current price value. + property alias currentValueTime:currentTimer.interval + ///@detalis timeReloadCanvas Screen refresh time when the graph is shifted. + property alias timeReloadCanvas:moveTimer.interval + + //For private values. + QtObject + { + id: thisProperty + ///@detalis minValuePrice Axis minimum value. + property int minValuePrice: 10000 + ///@detalis maxValuePrice Axis maximum value. + property int maxValuePrice: 10800 + //Graphics working field. + ///@detalis fieldXMin Minimum value x. + property int fieldXMin: 0 + ///@detalis fieldXMax Maximum value x. + property int fieldXMax: 100 + ///@detalis fieldYMin Minimum value y. + property int fieldYMin: 0 + ///@detalis fieldYMax Maximum value y. + property int fieldYMax: 100 + //Variables for setting time. + //Year. + property int year: 31556926; + //Month. + property int month: 2629743; + //Week. + property int week: 604800; + //Day. + property int day: 86400; + //Hour. + property int hour: 3600; + //Minute. + property int minute: 60; + ///@detalis yRealFactor Coordinate multiplier y. + property var yRealFactor: 0.0 + ///@detalis xRealFactor Coordinate multiplier x. + property var xRealFactor: 0.0 + ///@detalis intervalPrice The gap between the minimum and maximum values on the y axis. + property var intervalPrice: 0.0 + ///@detalis positionMouseX Temporarily remembers the position of the mouse to calculate the offset. + property int positionMouseX:0 + ///@detalis modelCountMin The minimum value of the counter for the passage of values (constantly recounted). + property int modelCountMin: 0 + ///@detalis modelCountMax The maximum value of the counter for the passage of values (constantly recounted). + property int modelCountMax: candleModel.count + ///@detalis currentTime Time current. + property var currentTime: new Date() + + } + + Component.onCompleted: + { + loadImage(imageCursorPath); + } + + onPaint: + { + canvasPaint(); + } + + //Price change timer. + Timer + { + id:currentTimer + repeat: true + interval: 10000 + onTriggered: + { + thisProperty.currentTime = new Date(); + if(isRightTimeCurrent)rightTime = thisProperty.currentTime; + canvasPaint(); + } + } + + MouseArea + { + id:areaCanvas + anchors.fill: parent + + //Image refresh timer. + Timer + { + id:moveTimer + repeat: true + interval: 30 + onTriggered: + { + if(rightTime < thisProperty.currentTime) + { + rightTime = rightTime + (thisProperty.positionMouseX-areaCanvas.mouseX)*thisProperty.xRealFactor; + canvasPaint(); + thisProperty.positionMouseX = areaCanvas.mouseX + isRightTimeCurrent = true; + } + else + { var tmpRightTime = (thisProperty.positionMouseX-areaCanvas.mouseX)*thisProperty.xRealFactor; + if(tmpRightTime<0) + { + rightTime = rightTime + (thisProperty.positionMouseX-areaCanvas.mouseX)*thisProperty.xRealFactor; + canvasPaint(); + thisProperty.positionMouseX = areaCanvas.mouseX + isRightTimeCurrent = false; + } + } + } + } + + onPressed: + { + if(mouse.button === Qt.LeftButton) + { + thisProperty.positionMouseX = mouseX; + moveTimer.start(); + } + } + + onReleased: + { + moveTimer.stop(); + autoSetDisplayCandle(); + } + } + + //Drawing a graph on the screen. + function canvasPaint() + { + autoSetWidthPrice() + init(); + var ctx = getContext("2d"); + ctx.clearRect(0,0,parent.width,parent.height) + timeToXLineChart(ctx); + valuePriceYLineChart(ctx); + fillCandle(ctx); + chartCanvas.requestPaint(); + } + + //Configuring candlestick options for rendering. + function autoSetDisplayCandle() + { + var valueActualTime = stepTime*maxXLine; + var minTime = rightTime - valueActualTime; + var isFirst = false; + var isEnded = false; + var firstCandle = 0; + var endedCandle = thisProperty.modelCountMax; + for (var count = thisProperty.modelCountMin;count<thisProperty.modelCountMax;count++) + { + if(!isFirst | minTime > candleModel.get(count).time) + { + isFirst = true; + if(count>10)thisProperty.modelCountMin = count-cashCandle; + else thisProperty.modelCountMin = 0; + } + if(!isEnded | rightTime>candleModel.get(count).time) + { + isEnded = true; + if(count < candleModel.count-10)thisProperty.modelCountMax = count+cashCandle; + else thisProperty.modelCountMax = candleModel.count; + } + } + } + + ///Auto selection of the lower and upper limit. + function autoSetWidthPrice() + { + autoSetDisplayCandle(); + var minPrice = candleModel.get(thisProperty.modelCountMin).minimum; + var maxPrice = candleModel.get(thisProperty.modelCountMin).maximum; + + for(var count = thisProperty.modelCountMin; count < thisProperty.modelCountMax; count++) + { + + if(minPrice > candleModel.get(count).minimum) minPrice = candleModel.get(count).minimum; + if(maxPrice < candleModel.get(count).maximum) maxPrice = candleModel.get(count).maximum; + } + if(currentValue>maxPrice)maxPrice=currentValue; + if(currentValue<minPrice)minPrice=currentValue; + thisProperty.maxValuePrice = maxPrice; + thisProperty.minValuePrice = minPrice; + } + + ///Initiation property. + function init() + { + thisProperty.fieldYMin = imageCursorHeight/2; + thisProperty.fieldXMax = chartCanvas.width - rightTextField - marginHorizontalLineToYAxisText; + thisProperty.fieldYMax = chartCanvas.height - fontSizeArea - topMarginXAxisText - bottomOutLine; + thisProperty.intervalPrice = thisProperty.maxValuePrice - thisProperty.minValuePrice; + thisProperty.yRealFactor = thisProperty.intervalPrice / (thisProperty.fieldYMax - thisProperty.fieldYMin); + thisProperty.xRealFactor = (stepTime*maxXLine)/(thisProperty.fieldXMax-thisProperty.fieldXMin); + } + + //Time conversion. + function timeToXChart(TimeX) + { + var a = new Date(TimeX * 1000); + var hour = a.getHours(); + if(hour<10)hour = '0'+hour; + var min = a.getMinutes(); + if(min<10)min='0'+min; + var time = hour + ':' + min; + return time; + } + + //X grid calculation and drawing. + function timeToXLineChart(ctx) + { + for(var count = 0; count < maxXLine; count++) + { + var timeRound = rightTime%stepTime + var timeLine = rightTime - (stepTime*count)-timeRound; + var timeXAxis = ((stepTime * count) + timeRound + moveTimeForVisual)/thisProperty.xRealFactor; + verticalLineChart(ctx,thisProperty.fieldXMax - timeXAxis,timeToXChart(timeLine + moveTimeForVisual)); + } + } + + //Y grid calculation and drawing. + function valuePriceYLineChart(ctx) + { + var realInterval = (thisProperty.fieldYMax - thisProperty.fieldYMin)/maxYLine; + var stepPrise = 10; + + for(var scanStep = 1; scanStep < 100000;scanStep*=10) + { + if(thisProperty.intervalPrice /scanStep <= maxYLine) {stepPrise = scanStep; break;} + if(thisProperty.intervalPrice /(scanStep*5) <= maxYLine) {stepPrise = scanStep*5;break;} + } + for(var count = 0; count<maxYLine;count++) + { + if(count === 0) + { + horizontalLineChart(ctx,thisProperty.fieldYMax,""); + } + else + if(thisProperty.fieldYMax-((stepPrise*count/thisProperty.yRealFactor))>heightNoLine) + { + var stepTo = stepPrise*count - thisProperty.minValuePrice%stepPrise; + horizontalLineChart(ctx,thisProperty.fieldYMax-((stepTo/thisProperty.yRealFactor)),thisProperty.minValuePrice+stepTo); + } + } + horizontalLineCurrentLevelChart(ctx,thisProperty.fieldYMax - (currentValue - thisProperty.minValuePrice)/thisProperty.yRealFactor,currentValue); + } + + //Candle drawing. + function fillCandle(ctx) + { + + for(var count = thisProperty.modelCountMin; count< thisProperty.modelCountMax ; count++) + { + + candleVisual(ctx,candleModel.get(count).time,candleModel.get(count).minimum, + candleModel.get(count).maximum,candleModel.get(count).open,candleModel.get(count).close); + } + } + + //Vertical line draw. + function verticalLineChart(ctx,x,text) + { + ctx.beginPath() + ctx.lineWidth = lineWidthArea; + ctx.strokeStyle = lineColorArea; + ctx.moveTo(x, chartCanvas.height-fontSizeArea-topMarginXAxisText); + ctx.lineTo(x, thisProperty.fieldYMin); + ctx.font = "normal "+fontSizeArea+ "px Roboto"; + ctx.fillStyle = fontColorArea; + ctx.fillText(text,x-13,chartCanvas.height); + ctx.stroke(); + } + + //horizontal line draw. + function horizontalLineChart(ctx,y,text) + { + ctx.beginPath(); + //ctx.save(); + ctx.lineWidth = lineWidthArea; + ctx.strokeStyle = lineColorArea; + ctx.moveTo(thisProperty.fieldXMax, y); + ctx.lineTo(0, y); + ctx.font = "normal "+fontSizeArea+ "px Roboto"; + ctx.fillStyle = fontColorArea; + ctx.fillText(text,chartCanvas.width - rightTextField,y+3); + ctx.stroke(); + } + + //Candle draw. + function candleVisual(ctx,pointTime,minimum,maximum,open,close) + { + var timeXAxis = thisProperty.fieldXMax-(rightTime-pointTime)/thisProperty.xRealFactor; + if(thisProperty.fieldXMax>timeXAxis) + { + ctx.beginPath() + ctx.lineWidth = candleWidthLine; + if(open < close) + { + ctx.strokeStyle = candleColorUp; + ctx.fillStyle = candleColorUp; + }else + { + ctx.strokeStyle = candleColorDown; + ctx.fillStyle = candleColorDown; + } + + ctx.moveTo(timeXAxis,getYValue(minimum)); + ctx.lineTo(timeXAxis, getYValue(maximum)); + ctx.moveTo(timeXAxis-(candleWidth/2), getYValue(open)); + ctx.lineTo(timeXAxis-(candleWidth/2), getYValue(close)); + ctx.lineTo(timeXAxis+(candleWidth/2), getYValue(close)); + ctx.lineTo(timeXAxis+(candleWidth/2), getYValue(open)); + ctx.lineTo(timeXAxis-(candleWidth/2), getYValue(open)); + ctx.stroke(); + ctx.fill(); + } + } + + //Converting Values to Coordinates. + function getYValue(value) + { + return thisProperty.fieldYMax - (value - thisProperty.minValuePrice)/thisProperty.yRealFactor; + } + + //Draw a line with the current value. + function horizontalLineCurrentLevelChart(ctx,y,text) + { + ctx.beginPath() + ctx.lineWidth = lineWidthArea; + ctx.strokeStyle = colorCursorLine; + ctx.moveTo(0, y); + ctx.lineTo(chartCanvas.width - imageCursorWidth + 4, y); + ctx.drawImage(imageCursorPath, chartCanvas.width-imageCursorWidth, y-imageCursorHeight/2,imageCursorWidth,imageCursorHeight); + ctx.font = "normal " +fontSizeCursor+ "px Roboto"; + ctx.fillStyle = colorCursorFont; + ctx.fillText(text,chartCanvas.width - rightTextField - (5*pt),y+imageCursorHeight/5); + ctx.stroke(); + chartCanvas.requestPaint(); + } + + } + } +///===============================DapChartCandleStick================================================================ + +///===============================DapUiQmlWidgetChainExchanges======================================================= + + Component + { + id: delegateOrderPanel + ///Order panel + Item + { + + ///@detalis currencyName + property string currencyName: qsTr("KLVN") + ///@detalis balance Balance. + property string balance: "0" + ///@detalis fontStyleOrder Font style. + property string fontStyleOrder: "Roboto" + width: 312 * pt + height: 292 * pt + + ColumnLayout + { + anchors.top: parent.top + anchors.topMargin: 16 * pt + + ///The header of the panel + Item + { + width: childrenRect.width + height: childrenRect.height + + RowLayout + { + spacing: 8 * pt + Rectangle + { + width: 32 + height: 32 + + Image + { + source: path + anchors.fill: parent + } + } + + Text + { + color: "#4F5357" + font.pixelSize: 14 * pt + font.family: fontStyleOrder + font.bold: true + text: titleOrder + } + } + } + + Text + { + text: qsTr("Balance: ") + balance + " " + currencyName + color: "#ACACAF" + font.family: "Roboto" + font.pixelSize: 12 * pt + } + + Rectangle + { + width: parent.width + height: 6 * pt + + } + + + Item + { + width: childrenRect.width + height: childrenRect.height + + ///Input fields via repeater + ColumnLayout + { + spacing: 16 * pt + + Repeater + { + model: [qsTr("Ammount"), qsTr("Price"), qsTr("Total"), qsTr("Fee (0.2%)"), qsTr("Total+Fee")] + RowLayout + { + spacing: 0 + Rectangle + { + height: childrenRect.height + width: 120 * pt + + Text + { + text: modelData + color: "#ACACAF" + font.family: fontStyleOrder + font.pixelSize: 12 * pt + } + } + + + Rectangle + { + width: 130 * pt + height: 22 * pt + border.width: 1 * pt + border.color: "#B0B1B5" + + TextInput + { + id: currencyTextInput + anchors.left: parent.left + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.right: textCurrency.left + anchors.leftMargin: 6 * pt + anchors.rightMargin: 6 * pt + color: readOnly ? "#ACACAF" : "#737880" + font.family: fontStyleOrder + font.pixelSize: 12 * pt + verticalAlignment: Qt.AlignVCenter + validator: RegExpValidator{ regExp: /\d+/ } + clip: true + readOnly: index === 3 || index === 4 + text: readOnly ? "0" : "" + } + + Text + { + id: textCurrency + anchors.right: parent.right + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.rightMargin: 6 * pt + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignRight + color: currencyTextInput.readOnly ? "#ACACAF" : "#737880" + font.family: fontStyleOrder + font.pixelSize: 12 * pt + text: index === 0 ? currencyName : qsTr("USD") + } + } + } + } + } + + } + + + Rectangle + { + height: 12 * pt + width: parent.width + } + ///Order button + DapButton + { + anchors.right: parent.right + textButton: titleOrder + widthButton: 130 * pt + heightButton: 30 * pt + fontButton.pixelSize: 13 * pt + colorBackgroundNormal: "#3E3853" + colorBackgroundHover: "#3E3853" + horizontalAligmentText:Qt.AlignHCenter + borderColorButton: "#000000" + borderWidthButton: 0 + fontButton.family: "Roboto" + fontButton.weight: Font.Normal + colorTextButton: "#FFFFFF" + + } + + } + } + + } + + + +///===============================DapUiQmlWidgetChainExchanges======================================================= +} +/*##^## +Designer { + D{i:0;autoSize:true;height:480;width:640} } +##^##*/ diff --git a/CellFrameDashboardGUI/screen/desktop/Exchange/DapExchangeScreenForm.ui.qml b/CellFrameDashboardGUI/screen/desktop/Exchange/DapExchangeScreenForm.ui.qml index 020f0bf98e06b658d7c94a246603f3c5290abb26..17dc8bc5f107d04a6f33af9734e33f8f48882ce7 100644 --- a/CellFrameDashboardGUI/screen/desktop/Exchange/DapExchangeScreenForm.ui.qml +++ b/CellFrameDashboardGUI/screen/desktop/Exchange/DapExchangeScreenForm.ui.qml @@ -1,7 +1,308 @@ import QtQuick 2.4 +import QtQuick.Controls 2.0 +import "qrc:/widgets" import "../../" DapAbstractScreen { - dapFrame.color: "magenta" + ///Top panel in tab Exchange + Rectangle + { + id: topPanelExchange + anchors.left: parent.left + anchors.right: parent.right + anchors.top: parent.top + anchors.leftMargin: 24 * pt + anchors.topMargin: 12 * pt + anchors.rightMargin: 24 * pt + height: 30 * pt + + ///Token ComboBox + Rectangle + { + id: leftComboBox + anchors.top: topPanelExchange.top + anchors.left: topPanelExchange.left + width: 112 * pt + height: parent.height + + DapComboBox + { + model: + ListModel + { + id: ÑonversionList + ListElement + { + text: "TKN1/NGD" + } + ListElement + { + text: "TKN2/NGD" + } + ListElement + { + text: "NGD/KLVN" + } + ListElement + { + text: "KLVN/USD" + } + } + widthPopupComboBoxActive: 144 * pt + widthPopupComboBoxNormal: 112 * pt + sidePaddingActive: 16 * pt + sidePaddingNormal: 0 + x: popup.visible ? sidePaddingActive * (-1) : sidePaddingNormal + heightComboBoxNormal: 24 * pt + heightComboBoxActive: 44 * pt + bottomIntervalListElement: 6 * pt + indicatorImageNormal: "qrc:/res/icons/ic_arrow_drop_down_dark_blue.png" + indicatorImageActive: "qrc:/res/icons/ic_arrow_drop_up_dark_blue.png" + fontComboBox.pixelSize: 16 * pt + fontComboBox.family: "Roboto" + normalColor: "#FFFFFF" + hilightColor: "#330F54" + normalTopColor: "#FFFFFF" + hilightTopColor: normalTopColor + normalColorText: "#070023" + hilightColorText: "#FFFFFF" + normalColorTopText: "#070023" + hilightColorTopText: "#070023" + paddingTopItemDelegate: 8 * pt + heightListElement: 32 * pt + intervalListElement: 10 * pt + indicatorWidth: 24 * pt + indicatorHeight: indicatorWidth + indicatorLeftInterval: 8 * pt + colorTopNormalDropShadow: "#00000000" + colorDropShadow: "#40ABABAB" + topEffect: true + } + } + + ///Time ComboBox + Rectangle + { + id: rightComboBox + anchors.left: leftComboBox.right + anchors.leftMargin: 72 * pt + anchors.top: topPanelExchange.top + width: 100 * pt + height: parent.height + DapComboBox + { + model: + ListModel + { + ListElement + { + text: "1 minute" + } + ListElement + { + text: "5 minute" + } + ListElement + { + text: "15 minute" + } + ListElement + { + text: "30 minute" + } + ListElement { + text: "1 hour" + } + ListElement + { + text: "4 hour" + } + ListElement + { + text: "12 hour" + } + ListElement + { + text: "24 hour" + } + } + + widthPopupComboBoxActive: 132 * pt + widthPopupComboBoxNormal: 100 * pt + sidePaddingActive: 16 * pt + sidePaddingNormal: 0 + x: popup.visible ? sidePaddingActive * (-1) : sidePaddingNormal + heightComboBoxNormal: 24 * pt + heightComboBoxActive: 44 * pt + bottomIntervalListElement: 6 * pt + indicatorImageNormal: "qrc:/res/icons/ic_arrow_drop_down_dark_blue.png" + indicatorImageActive: "qrc:/res/icons/ic_arrow_drop_up_dark_blue.png" + fontComboBox.pixelSize: 14 * pt + fontComboBox.family: "Roboto" + normalColor: "#FFFFFF" + hilightColor: "#330F54" + normalTopColor: "#FFFFFF" + hilightTopColor: normalTopColor + normalColorText: "#070023" + hilightColorText: "#FFFFFF" + normalColorTopText: "#070023" + hilightColorTopText: "#070023" + paddingTopItemDelegate: 8 * pt + heightListElement: 32 * pt + intervalListElement: 10 * pt + indicatorWidth: 24 * pt + indicatorHeight: indicatorWidth + indicatorLeftInterval: 8 * pt + colorTopNormalDropShadow: "#00000000" + colorDropShadow: "#40ABABAB" + topEffect: true + } + } + + ///Value Last price + Rectangle + { + id: lastPrice + height: parent.height + width: 150 * pt + anchors.right: volume24.left + anchors.rightMargin: 30 * pt + + Text + { + anchors.left: lastPrice.left + anchors.bottom: value_lastPrice.top + anchors.bottomMargin: 6 * pt + color: "#757184" + font.pixelSize: 10 * pt + font.family: "Roboto" + text: qsTr("Last price") + } + Text + { + id: value_lastPrice + anchors.left: lastPrice.left + anchors.bottom: lastPrice.bottom + color: "#070023" + font.pixelSize: 12 * pt + font.family: "Roboto" + text: qsTr("$ 10 807.35 NGD") + } + Text + { + anchors.left: value_lastPrice.right + anchors.bottom: lastPrice.bottom + anchors.leftMargin: 6 * pt + color: "#6F9F00" + font.pixelSize: 10 * pt + font.family: "Roboto" + text: qsTr("+3.59%") + } + } + ///Value 24h volume + Rectangle + { + id: volume24 + + height: parent.height + width: 75 * pt + anchors.right: topPanelExchange.right + + Text + { + anchors.right: volume24.right + anchors.bottom: value_valume24.top + anchors.bottomMargin: 6 * pt + color: "#757184" + font.pixelSize: 10 * pt + font.family: "Roboto" + text: qsTr("24h volume") + } + Text + { + id: value_valume24 + anchors.right: volume24.right + anchors.bottom: volume24.bottom + color: "#070023" + font.pixelSize: 12 * pt + font.family: "Roboto" + text: qsTr("9 800 TKN1") + } + } + } + + ///Candlestick chart loader + Loader + { + id: loaderCandleStick + sourceComponent: candleChart + anchors.top: topPanelExchange.bottom + anchors.left: parent.left + anchors.right:parent.right + anchors.leftMargin: 24 * pt + anchors.rightMargin: 24 * pt + anchors.topMargin: 16 * pt + height: 282 * pt + } + + ///Dividing horizontal line + Rectangle + { + id:horizontalLine + anchors.top: loaderCandleStick.bottom + anchors.topMargin: 24 * pt + height: 1*pt + width: parent.width + color: "#E3E2E6" + } + ///Model with a list of orders + ListModel + { + id: orderModel + ListElement{titleOrder:"Buy"; path:"qrc:/res/icons/buy_icon.png"} + ListElement{titleOrder:"Sell"; path:"qrc:/res/icons/sell_icon.png"} + } + ///Left down panel + Rectangle + { + id:exchangeBottomPanel + anchors.top: horizontalLine.bottom + anchors.right: parent.right + anchors.left: parent.left + anchors.bottom: parent.bottom + anchors.leftMargin: 24 * pt + anchors.rightMargin: 24 * pt + ///List of orders + ListView + { + id: orderListView + anchors.left: parent.left + anchors.top: parent.top + anchors.bottom: parent.bottom + orientation: ListView.Horizontal + interactive: false + model: orderModel + delegate: delegateOrderPanel + width: childrenRect.width + } + ///Dividing vertical line + Rectangle + { + id:verticalLine + anchors.left: orderListView.right + height: parent.height + width: 1 * pt + color: "#E3E2E6" + } + ///frame for the history widget + Rectangle + { + width:430 * pt + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.left: verticalLine.right + anchors.right: parent.right + } + } } diff --git a/CellFrameDashboardGUI/screen/desktop/Exchange/DapExchangeTopPanelForm.ui.qml b/CellFrameDashboardGUI/screen/desktop/Exchange/DapExchangeTopPanelForm.ui.qml index 4684bbd8e0d2e4b43855ef20c2f7051699a8665b..0917d206a7ce7d402e776663af456b89dbfd8481 100644 --- a/CellFrameDashboardGUI/screen/desktop/Exchange/DapExchangeTopPanelForm.ui.qml +++ b/CellFrameDashboardGUI/screen/desktop/Exchange/DapExchangeTopPanelForm.ui.qml @@ -1,9 +1,98 @@ import QtQuick 2.4 +import QtQuick.Controls 2.0 +import "qrc:/widgets" import "../../" DapAbstractTopPanelForm { + anchors.fill: parent + // Static text "Wallet" + Label + { + id: textHeaderWallet + text: qsTr("Wallet") + anchors.left: parent.left + anchors.leftMargin: 24 * pt + anchors.verticalCenter: parent.verticalCenter + font.family: "Roboto" + font.pixelSize: 12 * pt + color: "#ACAAB5" + } + + // Wallet selection combo box + Rectangle + { + id: frameComboBox + + anchors.left: textHeaderWallet.right + anchors.verticalCenter: parent.verticalCenter + anchors.leftMargin: 30 * pt + width: 148 * pt + color: "transparent" + + DapComboBox + { + id: comboboxWallet + //model: modelWallets + indicatorImageNormal: "qrc:/res/icons/ic_arrow_drop_down.png" + indicatorImageActive: "qrc:/res/icons/ic_arrow_drop_up.png" + sidePaddingNormal: 0 * pt + sidePaddingActive: 16 * pt + normalColorText: "#070023" + hilightColorText: "#FFFFFF" + normalColorTopText: "#FFFFFF" + hilightColorTopText: "#070023" + hilightColor: "#330F54" + normalTopColor: "#070023" + widthPopupComboBoxNormal: 148 * pt + widthPopupComboBoxActive: 180 * pt + heightComboBoxNormal: 24 * pt + heightComboBoxActive: 44 * pt + bottomIntervalListElement: 8 * pt + topEffect: false + x: popup.visible ? sidePaddingActive * (-1) : sidePaddingNormal + normalColor: "#FFFFFF" + hilightTopColor: normalColor + paddingTopItemDelegate: 8 * pt + heightListElement: 32 * pt + intervalListElement: 10 * pt + indicatorWidth: 24 * pt + indicatorHeight: indicatorWidth + indicatorLeftInterval: 8 * pt + colorTopNormalDropShadow: "#00000000" + colorDropShadow: "#40ABABAB" + fontComboBox.pixelSize: 14 * pt + fontComboBox.family: "Roboto" + + } + } + + // Static wallet balance text "Wallet balance" + Label + { + id: headerWalletBalance + text: qsTr("Wallet balance") + anchors.left: frameComboBox.right + anchors.leftMargin: 70 * pt + anchors.verticalCenter: parent.verticalCenter + font.family: "Roboto" + font.pixelSize: 12 * pt + color: "#ACAAB5" + } + + // Dynamic wallet balance text + Label + { + id: textWalletBalance + text: "$ 3 050 745.3453289 USD" + anchors.left: headerWalletBalance.right + anchors.leftMargin: 18 * pt + anchors.verticalCenter: parent.verticalCenter + font.family: "Roboto" + font.pixelSize: 16 * pt + color: "#FFFFFF" + } } diff --git a/CellFrameDashboardGUI/screen/desktop/Logs/DapLogsScreen.qml b/CellFrameDashboardGUI/screen/desktop/Logs/DapLogsScreen.qml index 2b81e7daef78d0344fdf223499dcfefa68fd8e8e..b17c7a54223cb527222b4dd9d5b27bf8dd46ec55 100644 --- a/CellFrameDashboardGUI/screen/desktop/Logs/DapLogsScreen.qml +++ b/CellFrameDashboardGUI/screen/desktop/Logs/DapLogsScreen.qml @@ -1,11 +1,14 @@ import QtQuick.Window 2.2 -import QtQuick.Controls 2.1 -import QtQuick 2.0 import QtGraphicalEffects 1.0 import QtQml 2.0 +import QtQuick 2.4 +import QtQuick.Controls 2.0 +import "../../" DapLogsScreenForm { + id:dapLogsScreenForm + ///@detalis firstMarginList First indent in the delegate to the first word. property int firstMarginList: 16 * pt ///@detalis secondMarginList Second indent between the first and second word. @@ -23,6 +26,13 @@ DapLogsScreenForm ///@detalis Font color. property string fontColor: "#070023" + //Slot for updating data in the model. The signal comes from C++. + Connections + { + target: dapServiceController + onLogUpdated:fillModel(logs); + } + ///In this block, the properties are only auxiliary for internal use. QtObject { @@ -36,13 +46,6 @@ DapLogsScreenForm property var todayYear property var stringTime } - //Slot for updating data in the model. The signal comes from C++. - Connections - { - target: dapServiceController - onLogUpdated:fillModel(logs); - - } //Creates a list model for the example Component.onCompleted: @@ -58,10 +61,6 @@ DapLogsScreenForm dapServiceController.requestToService("DapUpdateLogsCommand",200); } - ListModel - { - id:dapLogsModel - } //The Component Header Component { @@ -239,6 +238,7 @@ DapLogsScreenForm } } + //Splits a string from the log. function parceStringFromLog(string) { @@ -257,7 +257,7 @@ DapLogsScreenForm var stringTime = parceTime(arrLogString[1]); dapLogsModel.append({"type":arrLogString[2], "info":arrLogString[4], "file":arrLogString[3], "time":getTime(stringTime), - "date":getDay(stringTime)}); + "date":getDay(stringTime), "momentTime":stringTime}); } } diff --git a/CellFrameDashboardGUI/screen/desktop/Logs/DapLogsTab.qml b/CellFrameDashboardGUI/screen/desktop/Logs/DapLogsTab.qml index 8996c3b440e744a9fad1926386decf431d983ae3..7d46b5dccc3734a8634fa7d5fb3279d74f301245 100644 --- a/CellFrameDashboardGUI/screen/desktop/Logs/DapLogsTab.qml +++ b/CellFrameDashboardGUI/screen/desktop/Logs/DapLogsTab.qml @@ -2,5 +2,9 @@ import QtQuick 2.4 DapLogsTabForm { - + ///Log window model. + ListModel + { + id:dapLogsModel + } } diff --git a/CellFrameDashboardGUI/screen/desktop/Logs/DapLogsTabForm.ui.qml b/CellFrameDashboardGUI/screen/desktop/Logs/DapLogsTabForm.ui.qml index c9167d8121110203ea1ac39d109d789ebb8830e4..5fc3f38b08ebb783c1426de63fb06676ce4b8e32 100644 --- a/CellFrameDashboardGUI/screen/desktop/Logs/DapLogsTabForm.ui.qml +++ b/CellFrameDashboardGUI/screen/desktop/Logs/DapLogsTabForm.ui.qml @@ -11,4 +11,5 @@ DapAbstractTab dapScreen: DapLogsScreen { } dapRightPanel: DapLogsRightPanel { } + } diff --git a/CellFrameDashboardGUI/screen/desktop/Logs/DapLogsTopPanel.qml b/CellFrameDashboardGUI/screen/desktop/Logs/DapLogsTopPanel.qml index 684fa7762bb5bafde4b236c627caeb7d7aa650af..a3ac598d7cdee31b69dba9ba08abb3360fbcba89 100644 --- a/CellFrameDashboardGUI/screen/desktop/Logs/DapLogsTopPanel.qml +++ b/CellFrameDashboardGUI/screen/desktop/Logs/DapLogsTopPanel.qml @@ -1,17 +1,18 @@ import QtQuick 2.4 import QtQuick.Dialogs 1.2 import Qt.labs.platform 1.0 -import QtGraphicalEffects 1.0 import "../../" DapLogsTopPanelForm { + ///@detalis filterFileArray Array with filters for the file saving window. + property var filterFileArray:["Text files (*.txt)", "Log files (*.log)"] + ///Loader for the Save window. Loader { id:saveWindow } - ///Component for the Save dialog box. Component { @@ -21,12 +22,20 @@ DapLogsTopPanelForm id: saveDialog title: "Save the file" fileMode: FileDialog.SaveFile + nameFilters: filterFileArray + selectedNameFilter.index: 0 + modality: Qt.WindowModal onFileChanged: { setPropertyDefaultWindow(); - } + var resultAddres = String(currentFile).replace(/file:\/\//,""); + resultAddres = resultAddres.replace(/\.([$A-Za-z0-9]{2,4})/,""); + resultAddres += "." + selectedNameFilter.extensions[0]; + dapServiceController.requestToService("DapExportLogCommand",resultAddres,sendLogToFile()); + + } onRejected: { setPropertyDefaultWindow(); @@ -34,6 +43,31 @@ DapLogsTopPanelForm Component.onCompleted: visible = true; } } + ///Creates a string from the model to save to a file. + function sendLogToFile() + { + var logArray = ""; + var tmpDate = new Date(); + for(var ind = 0; ind<dapLogsModel.count;ind++) + { + tmpDate.setTime(dapLogsModel.get(ind).momentTime); + var dd = tmpDate.getDate(); + if (dd < 10) dd = '0' + dd; + + var mm = tmpDate.getMonth() + 1; + if (mm < 10) mm = '0' + mm; + + var yy = tmpDate.getFullYear() % 100; + if (yy < 10) yy = '0' + yy; + + logArray+="[" + mm + "/" + dd + "/" + yy + "-" + dapLogsModel.get(ind).time +"] "; + logArray+="["+dapLogsModel.get(ind).type+"] "; + logArray+="["+dapLogsModel.get(ind).file+"] "; + logArray+=dapLogsModel.get(ind).info +"\n"; + } + return logArray; + + } ///Creating a screenshot of a window function grub() diff --git a/CellFrameDashboardService/CellFrameDashboardService.pro b/CellFrameDashboardService/CellFrameDashboardService.pro index 8b47e620143982179fbec0b20cf3df5bb9d2f7eb..b5d91d91cc90900144d82e1afc3bb8a56d98494f 100755 --- a/CellFrameDashboardService/CellFrameDashboardService.pro +++ b/CellFrameDashboardService/CellFrameDashboardService.pro @@ -19,14 +19,14 @@ win32 { CONFIG -= console VERSION = $${VER_MAJ}.$${VER_MIN}.$$VER_PAT DEFINES += CLI_PATH=\\\"./cellframe-node-cli.exe\\\" - DEFINES += LOG_FILE=\\\"./opt/cellframe-node/var/log/cellframe-node_logs.txt\\\" + DEFINES += LOG_FILE=\\\"./opt/cellframe-node/var/log/cellframe-node.log\\\" DEFINES += CMD_LOG=\\\"./opt/cellframe-dashboard/data/cellframe-cmd_log.txt\\\" DEFINES += HAVE_STRNDUP } else { VERSION = $$VER_MAJ\.$$VER_MIN\-$$VER_PAT DEFINES += CLI_PATH=\\\"/opt/cellframe-node/bin/cellframe-node-cli\\\" - DEFINES += LOG_FILE=\\\"/opt/cellframe-node/var/log/cellframe-node_logs.txt\\\" + DEFINES += LOG_FILE=\\\"/opt/cellframe-node/var/log/cellframe-node.log\\\" DEFINES += CMD_LOG=\\\"/opt/cellframe-dashboard/data/cellframe-cmd_log.txt\\\" } diff --git a/CellFrameDashboardService/DapServiceController.cpp b/CellFrameDashboardService/DapServiceController.cpp index 26d6b7e0a5572f1fb133c9c88912f735d296148a..51ecd629d00f6750f1dd656e6887dea879ff51ee 100755 --- a/CellFrameDashboardService/DapServiceController.cpp +++ b/CellFrameDashboardService/DapServiceController.cpp @@ -54,6 +54,8 @@ void DapServiceController::registerCommand() m_pServer->addService(new DapAddWalletCommand("DapAddWalletCommand", m_pServer)); // The command to get a list of available wallets m_pServer->addService(new DapGetListWalletsCommand("DapGetListWalletsCommand", m_pServer)); + // Saving the file with the logs + m_pServer->addService(new DapExportLogCommand("DapExportLogCommand", m_pServer)); } /// Initialize system tray. @@ -87,4 +89,5 @@ void DapServiceController::initSystemTrayIcon() Q_ASSERT(command); command->notifyToClient(); }); + } diff --git a/CellFrameDashboardService/DapServiceController.h b/CellFrameDashboardService/DapServiceController.h index 95fae1a0588e1e030f777fde9ee689e1a08159ae..230f0967c3a262aecd727508e66d070ca08ead04 100755 --- a/CellFrameDashboardService/DapServiceController.h +++ b/CellFrameDashboardService/DapServiceController.h @@ -29,10 +29,12 @@ typedef class DapRpcLocalServer DapUiService; #include "Handlers/DapUpdateLogsCommand.h" #include "Handlers/DapAddWalletCommand.h" #include "Handlers/DapGetListWalletsCommand.h" +#include "Handlers/DapExportLogCommand.h" #include "DapSystemTrayIcon.h" #include "DapToolTipWidget.h" + /** * @brief The DapServiceController class * Service class which provide handle operations with dashboard. diff --git a/libCellFrameDashboardCommon/Handlers/DapExportLogCommand.cpp b/libCellFrameDashboardCommon/Handlers/DapExportLogCommand.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9f26d85d8d9a34494fab73e499bfd38253844423 --- /dev/null +++ b/libCellFrameDashboardCommon/Handlers/DapExportLogCommand.cpp @@ -0,0 +1,42 @@ +#include "DapExportLogCommand.h" + +/// Overloaded constructor. +/// @param asServiceName Service name. +/// @param apSocket Client connection socket with service. +/// @param parent Parent. +DapExportLogCommand::DapExportLogCommand(const QString &asServicename, QObject *parent) + : DapAbstractCommand(asServicename, parent) +{ + +} + +/// Send a response to the client. +/// A log file is saved from the GUI window. +/// @param arg1...arg10 Parameters. +/// @return Reply to client. +QVariant DapExportLogCommand::respondToClient(const QVariant &arg1, const QVariant &arg2, const QVariant &arg3, + const QVariant &arg4, const QVariant &arg5, const QVariant &arg6, + const QVariant &arg7, const QVariant &arg8, const QVariant &arg9, + const QVariant &arg10) +{ + Q_UNUSED(arg3) + Q_UNUSED(arg4) + Q_UNUSED(arg5) + Q_UNUSED(arg6) + Q_UNUSED(arg7) + Q_UNUSED(arg8) + Q_UNUSED(arg9) + Q_UNUSED(arg10) + + QFile saveDapLog(arg1.toString()); + if (!saveDapLog.open(QIODevice::WriteOnly | QIODevice::Text)) + { + qCritical("The file does not write."); + return false; + } + QTextStream saveLog(&saveDapLog); + saveLog << arg2.toString(); + + saveDapLog.close(); + return QVariant(); +} diff --git a/libCellFrameDashboardCommon/Handlers/DapExportLogCommand.h b/libCellFrameDashboardCommon/Handlers/DapExportLogCommand.h new file mode 100644 index 0000000000000000000000000000000000000000..79d21af12cbdeb94dd3c6e20848c21577cd7b789 --- /dev/null +++ b/libCellFrameDashboardCommon/Handlers/DapExportLogCommand.h @@ -0,0 +1,30 @@ +#ifndef DAPSAVELOGCOMMAND_H +#define DAPSAVELOGCOMMAND_H + +#include <QFile> + +#include "DapAbstractCommand.h" + +class DapExportLogCommand : public DapAbstractCommand +{ + +public: + /// Overloaded constructor. + /// @param asServiceName Service name. + /// @param apSocket Client connection socket with service. + /// @param parent Parent. + explicit DapExportLogCommand(const QString &asServicename, QObject *parent = nullptr); + +public slots: + /// Send a response to the client. + /// /// A log file is saved from the GUI window. + /// @param arg1...arg10 Parameters. + /// @return Reply to client. + QVariant respondToClient(const QVariant &arg1 = QVariant(), const QVariant &arg2 = QVariant(), + const QVariant &arg3 = QVariant(), const QVariant &arg4 = QVariant(), + const QVariant &arg5 = QVariant(), const QVariant &arg6 = QVariant(), + const QVariant &arg7 = QVariant(), const QVariant &arg8 = QVariant(), + const QVariant &arg9 = QVariant(), const QVariant &arg10 = QVariant()) override; +}; + +#endif // DAPSAVELOGCOMMAND_H diff --git a/libCellFrameDashboardCommon/libCellFrameDashboardCommon.pri b/libCellFrameDashboardCommon/libCellFrameDashboardCommon.pri index 7b36bc172d8c06ebd6c80e5f94770dfc1de60ddf..ad96da03d85a27c1b35e36bb198c4d1ae9c43d51 100755 --- a/libCellFrameDashboardCommon/libCellFrameDashboardCommon.pri +++ b/libCellFrameDashboardCommon/libCellFrameDashboardCommon.pri @@ -24,6 +24,7 @@ SOURCES +=\ $$PWD/Handlers/DapAbstractCommand.cpp \ $$PWD/Handlers/DapActivateClientCommand.cpp \ $$PWD/Handlers/DapGetListWalletsCommand.cpp \ + $$PWD/Handlers/DapExportLogCommand.cpp \ $$PWD/Handlers/DapQuitApplicationCommand.cpp \ $$PWD/Handlers/DapAddWalletCommand.cpp \ $$PWD/Handlers/DapUpdateLogsCommand.cpp @@ -41,6 +42,7 @@ HEADERS +=\ $$PWD/Handlers/DapAbstractCommand.h \ $$PWD/Handlers/DapActivateClientCommand.h \ $$PWD/Handlers/DapGetListWalletsCommand.h \ + $$PWD/Handlers/DapExportLogCommand.h \ $$PWD/Handlers/DapQuitApplicationCommand.h \ $$PWD/Handlers/DapAddWalletCommand.h \ $$PWD/Handlers/DapUpdateLogsCommand.h diff --git a/libdap-qt-ui-qml b/libdap-qt-ui-qml index bca1afe6ba3bbf9ef85bfaa64b679d99265ea7e8..ab16ad669cfc09a69d071a88add98110d473010e 160000 --- a/libdap-qt-ui-qml +++ b/libdap-qt-ui-qml @@ -1 +1 @@ -Subproject commit bca1afe6ba3bbf9ef85bfaa64b679d99265ea7e8 +Subproject commit ab16ad669cfc09a69d071a88add98110d473010e