summaryrefslogtreecommitdiff
path: root/modules/controlcenter/dev/DevDebugPane.qml
blob: 88d6542261c10c0414d929127179ea91c3df7f58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
pragma ComponentBehavior: Bound

import "."
import ".."
import qs.components
import qs.components.controls
import qs.components.containers
import qs.config
import Quickshell
import Quickshell.Widgets
import QtQuick
import QtQuick.Layouts

Item {
    id: root

    required property DevSession session

    anchors.fill: parent

    ColumnLayout {
        anchors.fill: parent
        anchors.margins: Appearance.padding.large
        spacing: Appearance.spacing.normal

        StyledText {
            text: qsTr("Debug Panel")
            font.pointSize: Appearance.font.size.larger
            font.weight: 500
        }

        // Action Buttons Section
        StyledRect {
            Layout.fillWidth: true
            implicitHeight: buttonsLayout.implicitHeight + Appearance.padding.large * 2
            radius: Appearance.rounding.normal
            color: Colours.tPalette.m3surfaceContainer

            ColumnLayout {
                id: buttonsLayout

                anchors.fill: parent
                anchors.margins: Appearance.padding.large
                spacing: Appearance.spacing.normal

                StyledText {
                    text: qsTr("Actions")
                    font.pointSize: Appearance.font.size.normal
                    font.weight: 500
                }

                Flow {
                    Layout.fillWidth: true
                    spacing: Appearance.spacing.small

                    TextButton {
                        text: qsTr("Clear Log")
                        onClicked: {
                            debugOutput.text = "";
                            appendLog("Debug log cleared");
                        }
                    }

                    TextButton {
                        text: qsTr("Test Action")
                        onClicked: {
                            appendLog("Test action executed at " + new Date().toLocaleTimeString());
                        }
                    }

                    TextButton {
                        text: qsTr("Log Network State")
                        onClicked: {
                            appendLog("Network state:");
                            appendLog("  Active: " + (root.session.network.active ? "Yes" : "No"));
                        }
                    }
                }
            }
        }

        // Debug Output Section
        StyledRect {
            Layout.fillWidth: true
            Layout.fillHeight: true
            radius: Appearance.rounding.normal
            color: Colours.tPalette.m3surfaceContainer

            ColumnLayout {
                anchors.fill: parent
                anchors.margins: Appearance.padding.large
                spacing: Appearance.spacing.small

                RowLayout {
                    Layout.fillWidth: true

                    StyledText {
                        text: qsTr("Debug Output")
                        font.pointSize: Appearance.font.size.normal
                        font.weight: 500
                    }

                    Item {
                        Layout.fillWidth: true
                    }

                    TextButton {
                        text: qsTr("Copy")
                        onClicked: {
                            debugOutput.selectAll();
                            debugOutput.copy();
                            debugOutput.deselect();
                            appendLog("Output copied to clipboard");
                        }
                    }
                }

                StyledFlickable {
                    id: flickable

                    Layout.fillWidth: true
                    Layout.fillHeight: true
                    flickableDirection: Flickable.VerticalFlick
                    contentHeight: debugOutput.implicitHeight

                    TextEdit {
                        id: debugOutput

                        width: flickable.width
                        readOnly: true
                        wrapMode: TextEdit.Wrap
                        font.family: Appearance.font.family.mono
                        font.pointSize: Appearance.font.size.smaller
                        renderType: TextEdit.NativeRendering
                        textFormat: TextEdit.PlainText
                        color: "#ffb0ca"  // Use primary color - will be set programmatically
                        
                        Component.onCompleted: {
                            color = Colours.palette.m3primary;
                            appendLog("Debug panel initialized");
                        }

                        onTextChanged: {
                            // Ensure color stays set when text changes
                            color = Colours.palette.m3primary;
                            if (flickable.contentHeight > flickable.height) {
                                flickable.contentY = flickable.contentHeight - flickable.height;
                            }
                        }
                    }
                }

                StyledScrollBar {
                    flickable: flickable
                    policy: ScrollBar.AlwaysOn
                }
            }
        }
    }

    function appendLog(message: string): void {
        const timestamp = new Date().toLocaleTimeString();
        debugOutput.text += `[${timestamp}] ${message}\n`;
    }

    function log(message: string): void {
        appendLog(message);
    }
}