Skip to content
This repository was archived by the owner on Aug 28, 2020. It is now read-only.

Commit 49357d9

Browse files
committed
Merge pull request #98 from robertbasic/feature/better-visual-indicator-of-debugging-status
Feature/better visual indicator of debugging status. Resolves #93
2 parents d219af2 + 40865be commit 49357d9

File tree

3 files changed

+59
-7
lines changed

3 files changed

+59
-7
lines changed

pugdebug/gui/main_window.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
from PyQt5.QtCore import Qt
1313
from PyQt5.QtWidgets import (QMainWindow, QToolBar, QMenuBar, QDockWidget,
14-
QLabel, QAction)
14+
QAction)
1515
from PyQt5.QtGui import QFont, QKeySequence
1616

1717
from pugdebug.gui.file_browser import PugdebugFileBrowser
@@ -21,6 +21,7 @@
2121
from pugdebug.gui.stacktraces import PugdebugStacktraceViewer
2222
from pugdebug.gui.breakpoints import PugdebugBreakpointViewer
2323
from pugdebug.gui.expressions import PugdebugExpressionViewer
24+
from pugdebug.gui.statusbar import PugdebugStatusBar
2425
from pugdebug.models.settings import get_setting, set_setting, has_setting
2526

2627

@@ -67,8 +68,9 @@ def setup_gui_elements(self):
6768
self.setup_statusbar()
6869

6970
def setup_statusbar(self):
70-
self.permanent_statusbar = QLabel("Idle...")
71+
self.permanent_statusbar = PugdebugStatusBar()
7172
self.statusBar().addPermanentWidget(self.permanent_statusbar)
73+
self.set_debugging_status(0)
7274

7375
def setup_fonts(self):
7476
font = QFont('mono')
@@ -246,8 +248,8 @@ def get_breakpoint_viewer(self):
246248
def get_expression_viewer(self):
247249
return self.expression_viewer
248250

249-
def set_statusbar_text(self, text):
250-
self.permanent_statusbar.setText(text)
251+
def set_debugging_status(self, status):
252+
self.permanent_statusbar.set_debugging_status(status)
251253

252254
def __add_dock_widget(self, widget, title, area):
253255
dw = QDockWidget(title, self)

pugdebug/gui/statusbar.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# -*- coding: utf-8 -*-
2+
3+
"""
4+
pugdebug - a standalone PHP debugger
5+
=========================
6+
copyright: (c) 2015 Robert Basic
7+
license: GNU GPL v3, see LICENSE for more details
8+
"""
9+
10+
__author__ = "robertbasic"
11+
12+
from PyQt5.QtGui import QPainter, QColor, QPixmap
13+
from PyQt5.QtWidgets import QLabel, QWidget, QHBoxLayout
14+
15+
16+
class PugdebugStatusBar(QWidget):
17+
18+
def __init__(self):
19+
super(PugdebugStatusBar, self).__init__()
20+
self.label = QLabel(self)
21+
self.light = QLabel(self)
22+
23+
layout = QHBoxLayout()
24+
layout.addWidget(self.light)
25+
layout.addWidget(self.label)
26+
27+
self.setLayout(layout)
28+
29+
def set_debugging_status(self, status):
30+
if status == 0:
31+
text = "Idle ..."
32+
color = "gray"
33+
elif status == 1:
34+
text = 'Waiting for connection ...'
35+
color = "orange"
36+
elif status == 2:
37+
text = 'Debugging stopped ...'
38+
color = "red"
39+
elif status == 3:
40+
text = 'Debugging in progress ...'
41+
color = "green"
42+
43+
self.label.setText(text)
44+
45+
self.pixmap = QPixmap(10, 10)
46+
color = QColor(color)
47+
self.pixmap.fill(color)
48+
painter = QPainter(self.pixmap)
49+
painter.drawRect(0, 0, 10, 10)
50+
self.light.setPixmap(self.pixmap)

pugdebug/pugdebug.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ def start_debug(self):
380380
self.document_viewer.remove_line_highlights()
381381

382382
self.debugger.start_debug()
383-
self.main_window.set_statusbar_text("Waiting for connection...")
383+
self.main_window.set_debugging_status(1)
384384

385385
def handle_debugging_started(self):
386386
"""Handle when debugging starts
@@ -397,7 +397,7 @@ def handle_debugging_started(self):
397397
398398
Open the index file in the document viewer.
399399
"""
400-
self.main_window.set_statusbar_text("Debugging in progress...")
400+
self.main_window.set_debugging_status(3)
401401

402402
self.main_window.toggle_actions(True)
403403

@@ -430,7 +430,7 @@ def handle_debugging_stopped(self):
430430

431431
self.main_window.toggle_actions(False)
432432

433-
self.main_window.set_statusbar_text("Debugging stopped...")
433+
self.main_window.set_debugging_status(2)
434434

435435
self.expression_viewer.clear_values()
436436

0 commit comments

Comments
 (0)