Skip to content

Commit

Permalink
refactor/renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberRoute committed Oct 3, 2024
1 parent 9095444 commit ba68312
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
14 changes: 7 additions & 7 deletions core/arp_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def setup_ui_elements(self):
self.add_static_ui_labels()

# Connect item click signal to open_device_details
self._ui.list.itemClicked.connect(self.open_device_details)
self._ui.devices.itemClicked.connect(self.open_device_details)

# Set the default font for the list items
self.setup_font_for_list_widgets()
Expand All @@ -97,8 +97,8 @@ def setup_font_for_list_widgets(self):
"""Sets up a uniform font for list widgets."""
font = QFont()
font.setPointSize(12)
self._ui.list.setFont(font)
self._ui.listpkt.setFont(font)
self._ui.devices.setFont(font)
self._ui.responses.setFont(font)

@Slot(QListWidgetItem)
def open_device_details(self, item):
Expand Down Expand Up @@ -176,20 +176,20 @@ def handle_scan_results(self, results):
def add_device_to_list(self, ip_address, mac, hostname, device_vendor):
"""Adds a device to the list widget in the UI."""
label = f"{ip_address} {mac} {hostname}, {device_vendor}"
if not self._ui.list.findItems(label, Qt.MatchExactly):
if not self._ui.devices.findItems(label, Qt.MatchExactly):
item = QListWidgetItem(label)
item.setBackground(QColor(Qt.black))
item.setForeground(QColor(Qt.white))
self._ui.list.addItem(item)
self._ui.devices.addItem(item)

def add_packet_if_new(self, packet_label):
"""Adds a packet to the listpkt widget if it doesn't already exist."""
existing_items = self._ui.listpkt.findItems(packet_label, Qt.MatchExactly)
existing_items = self._ui.responses.findItems(packet_label, Qt.MatchExactly)
if not existing_items: # Add only if the packet is not already listed
packet_item = QListWidgetItem(packet_label)
packet_item.setBackground(QColor(Qt.black))
packet_item.setForeground(QColor(Qt.white))
self._ui.listpkt.addItem(packet_item)
self._ui.responses.addItem(packet_item)

def quit_application(self):
"""Quit the application."""
Expand Down
6 changes: 3 additions & 3 deletions ui/arpscan.ui
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</widget>
</item>
<item>
<widget class="QListWidget" name="list"/>
<widget class="QListWidget" name="devices"/>
</item>
<item>
<widget class="QLabel" name="label_2">
Expand All @@ -32,7 +32,7 @@
</widget>
</item>
<item>
<widget class="QListWidget" name="listpkt"/>
<widget class="QListWidget" name="responses"/>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
Expand Down Expand Up @@ -111,7 +111,7 @@
<connection>
<sender>clear</sender>
<signal>clicked()</signal>
<receiver>list</receiver>
<receiver>devices</receiver>
<slot>clear()</slot>
<hints>
<hint type="sourcelabel">
Expand Down
14 changes: 7 additions & 7 deletions ui/ui_arpscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ def setupUi(self, DeviceDiscovery):

self.verticalLayout.addWidget(self.label)

self.list = QListWidget(DeviceDiscovery)
self.list.setObjectName(u"list")
self.devices = QListWidget(DeviceDiscovery)
self.devices.setObjectName(u"devices")

self.verticalLayout.addWidget(self.list)
self.verticalLayout.addWidget(self.devices)

self.label_2 = QLabel(DeviceDiscovery)
self.label_2.setObjectName(u"label_2")

self.verticalLayout.addWidget(self.label_2)

self.listpkt = QListWidget(DeviceDiscovery)
self.listpkt.setObjectName(u"listpkt")
self.responses = QListWidget(DeviceDiscovery)
self.responses.setObjectName(u"responses")

self.verticalLayout.addWidget(self.listpkt)
self.verticalLayout.addWidget(self.responses)

self.groupBox = QGroupBox(DeviceDiscovery)
self.groupBox.setObjectName(u"groupBox")
Expand Down Expand Up @@ -88,7 +88,7 @@ def setupUi(self, DeviceDiscovery):

self.retranslateUi(DeviceDiscovery)
self.quit.clicked.connect(DeviceDiscovery.accept)
self.clear.clicked.connect(self.list.clear)
self.clear.clicked.connect(self.devices.clear)

QMetaObject.connectSlotsByName(DeviceDiscovery)
# setupUi
Expand Down

0 comments on commit ba68312

Please sign in to comment.