Skip to content

Commit

Permalink
Merge pull request #127 from il-palmi/master
Browse files Browse the repository at this point in the history
General improvements and migration from QTableWidget to QTableView
  • Loading branch information
il-palmi authored Nov 10, 2024
2 parents b9ecb1d + e512898 commit e4acc76
Show file tree
Hide file tree
Showing 11 changed files with 850 additions and 771 deletions.
7 changes: 7 additions & 0 deletions assets/qt/NetworkSettingsDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="connectButton">
<property name="text">
<string>Connect</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="deleteConfigButton">
<property name="text">
Expand Down
83 changes: 12 additions & 71 deletions assets/qt/PinoloMainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,22 @@
<number>6</number>
</property>
<item>
<widget class="QTableWidget" name="diskTable">
<widget class="QTableView" name="drivesTableView">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>350</width>
<height>0</height>
</size>
</property>
<property name="contextMenuPolicy">
<enum>Qt::ActionsContextMenu</enum>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
Expand Down Expand Up @@ -98,41 +101,17 @@
<enum>Qt::NoPen</enum>
</property>
<property name="sortingEnabled">
<bool>true</bool>
<bool>false</bool>
</property>
<property name="cornerButtonEnabled">
<bool>false</bool>
</property>
<property name="columnCount">
<number>3</number>
</property>
<attribute name="horizontalHeaderShowSortIndicator" stdset="0">
<bool>false</bool>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderShowSortIndicator" stdset="0">
<bool>true</bool>
</attribute>
<column>
<property name="text">
<string>Drive</string>
</property>
</column>
<column>
<property name="text">
<string>Tarallo ID</string>
</property>
</column>
<column>
<property name="text">
<string>Size</string>
</property>
</column>
</widget>
</item>
<item>
Expand Down Expand Up @@ -266,7 +245,7 @@
</item>
</layout>
</widget>
<widget class="QTableWidget" name="queueTable">
<widget class="QTableView" name="queueTableView">
<property name="minimumSize">
<size>
<width>580</width>
Expand Down Expand Up @@ -316,56 +295,17 @@
<enum>Qt::NoPen</enum>
</property>
<property name="sortingEnabled">
<bool>true</bool>
<bool>false</bool>
</property>
<property name="cornerButtonEnabled">
<bool>true</bool>
</property>
<property name="columnCount">
<number>6</number>
</property>
<attribute name="horizontalHeaderShowSortIndicator" stdset="0">
<bool>true</bool>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderStretchLastSection">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string>ID</string>
</property>
</column>
<column>
<property name="text">
<string>Process</string>
</property>
</column>
<column>
<property name="text">
<string>Disk</string>
</property>
</column>
<column>
<property name="text">
<string>Status</string>
</property>
</column>
<column>
<property name="text">
<string>ETA</string>
</property>
</column>
<column>
<property name="text">
<string>Progress</string>
</property>
</column>
</widget>
</widget>
</item>
Expand Down Expand Up @@ -423,7 +363,8 @@
</action>
<action name="actionNetworkSettings">
<property name="icon">
<iconset theme="network-wired"/>
<iconset theme="network-wired">
<normaloff>.</normaloff>.</iconset>
</property>
<property name="text">
<string>Network settings</string>
Expand Down
8 changes: 5 additions & 3 deletions client.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def connectionMade(self):
self.factory.on_connection(self)
peer = self.transport.getPeer()
self.factory.update_host(f"connection_made {peer.host} {peer.port}")
print("CLIENT_PROTOCOL: Connection established.")
except Exception as e:
print(e)

Expand Down Expand Up @@ -161,6 +162,7 @@ def disconnect(self):
be closed gracefully.
"""
self.transport.loseConnection()
print("CLIENT_PROTOCOL: Connection dropped.")


class ConnectionFactory(ClientFactory, QObject):
Expand All @@ -182,11 +184,11 @@ def startedConnecting(self, connector):
print("CLIENT_FACTORY: Connecting.")

def clientConnectionFailed(self, connector, reason):
print(f"CLIENT_FACTORY: Lost connection. Reason: {reason}")
self.data_received.emit("connection_lost", str(reason.value))
print(f"CLIENT_FACTORY: Connection failed. Reason: {reason.value}")
self.data_received.emit("connection_failed", json.dumps({"reason": str(reason.value)}))

def clientConnectionLost(self, connector, reason):
print(f"CLIENT_FACTORY: Lost connection. Reason: {reason}")
print(f"CLIENT_FACTORY: Lost connection. Reason: {reason.value}")

def update_host(self, line: str):
"""Processes the given line to extract command and arguments, then emits the data.
Expand Down
30 changes: 15 additions & 15 deletions constants.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# PINOLO

DEFAULT_IP = "127.0.0.1"
LOCAL_IP = "127.0.0.1"
DEFAULT_PORT = 1030
DEFAULT_SYSTEM_PATH = ""
LOCAL_IMAGES_DIRECTORY = "localImagesDirectory"
LOCAL_DEFAULT_IMAGE = "localDefaultImage"

CLIENT_TIMEOUT = 5

Expand Down Expand Up @@ -43,18 +44,18 @@
"local_time",
]

DISK_TABLE_DRIVE = 0
DISK_TABLE_TARALLO_ID = 1
DISK_TABLE_DRIVE_SIZE = 2
DRIVES_TABLE_NAME = 0
DRIVES_TABLE_STATUS = 1
DRIVES_TABLE_TARALLO_ID = 2
DRIVES_TABLE_DRIVE_SIZE = 3

QUEUE_TABLE = ["ID", "Process", "Disk", "Status", "Eta", "Progress"]

QUEUE_TABLE_ID = 0
QUEUE_TABLE_DRIVE = 0
QUEUE_TABLE_PROCESS = 1
QUEUE_TABLE_DRIVE = 2
QUEUE_TABLE_STATUS = 3
QUEUE_TABLE_ETA = 4
QUEUE_TABLE_PROGRESS = 5
QUEUE_TABLE_STATUS = 2
QUEUE_TABLE_ETA = 3
QUEUE_TABLE_PROGRESS = 4

QUEUE_LABELS = {
"queued_badblocks": "Erase",
Expand All @@ -72,11 +73,10 @@
LOCAL_MODE = "Local"
REMOTE_MODE = "Remote"

SERVER_MODE = "latestServerMode"
SERVER_IP = "latestServerIp"
SERVER_PORT = "latestServerPort"
SERVER_IMAGES_DIRECTORY = "latestImageDirectory"
SERVER_DEFAULT_IMAGE = "latestImage"
CURRENT_SERVER_MODE = "serverMode"
CURRENT_SERVER_IMAGES_DIRECTORY = "ImagesDirectory"
CURRENT_SERVER_DEFAULT_IMAGE = "defaultImage"
CURRENT_SERVER_CONFIG_KEY = "serverConfig"

QSETTINGS_IP_GROUP = "ipGroup"

Expand Down
Loading

0 comments on commit e4acc76

Please sign in to comment.