mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-20 14:39:10 +08:00
fixing the if condition
CURA-11596
This commit is contained in:
parent
799ef9ef51
commit
bb28a7c506
@ -5,6 +5,7 @@ import json
|
||||
import os
|
||||
from typing import List, Optional
|
||||
|
||||
from PyQt6.QtCore import QUrl
|
||||
from PyQt6.QtNetwork import QLocalServer, QLocalSocket
|
||||
|
||||
from UM.Qt.QtApplication import QtApplication # For typing.
|
||||
@ -34,7 +35,7 @@ class SingleInstance:
|
||||
return False
|
||||
|
||||
# We only send the files that need to be opened.
|
||||
if not self._files_to_open or not self._url_to_open:
|
||||
if not self._files_to_open and not self._url_to_open:
|
||||
Logger.log("i", "No file need to be opened, do nothing.")
|
||||
return True
|
||||
|
||||
@ -57,7 +58,7 @@ class SingleInstance:
|
||||
single_instance_socket.write(bytes(json.dumps(payload) + "\n", encoding = "ascii"))
|
||||
|
||||
for url in self._url_to_open:
|
||||
payload = {"command": "open-url", "urlPath": url}
|
||||
payload = {"command": "open-url", "urlPath": url.toString()}
|
||||
single_instance_socket.write(bytes(json.dumps(payload) + "\n", encoding="ascii"))
|
||||
|
||||
payload = {"command": "close-connection"}
|
||||
@ -82,10 +83,12 @@ class SingleInstance:
|
||||
connection = self._single_instance_server.nextPendingConnection()
|
||||
|
||||
if connection is not None:
|
||||
x = self.__readCommands(connection)
|
||||
connection.readyRead.connect(lambda c = connection: self.__readCommands(c))
|
||||
|
||||
def __readCommands(self, connection: QLocalSocket) -> None:
|
||||
line = connection.readLine()
|
||||
print(f"line is {line}")
|
||||
while len(line) != 0: # There is also a .canReadLine()
|
||||
try:
|
||||
payload = json.loads(str(line, encoding = "ascii").strip())
|
||||
@ -101,7 +104,8 @@ class SingleInstance:
|
||||
|
||||
#command: Load a url link in Cura
|
||||
elif command == "open-url":
|
||||
self._application.callLater(lambda f = payload["urlPath"]: self._application._openUrl(f))
|
||||
url = QUrl(payload["urlPath"])
|
||||
self._application.callLater(lambda f = url: self._application._openUrl(f))
|
||||
|
||||
|
||||
# Command: Activate the window and bring it to the top.
|
||||
|
Loading…
x
Reference in New Issue
Block a user