Add "View details" to PC list (#1221)

* feat: add view pc details menu item

* feat: show mac address

* fix: cast mac byte array to string
This commit is contained in:
Jorys Paulin 2024-05-01 04:23:25 +02:00 committed by GitHub
parent 211fec0ff0
commit c096238998
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 35 additions and 1 deletions

View File

@ -6,6 +6,7 @@ import ComputerModel 1.0
import ComputerManager 1.0
import StreamingPreferences 1.0
import SystemProperties 1.0
import SdlGamepadKeyNavigation 1.0
CenteredGridView {
@ -215,6 +216,14 @@ CenteredGridView {
deletePcDialog.open()
}
}
NavigableMenuItem {
parentMenu: pcContextMenu
text: qsTr("View Details")
onTriggered: {
showPcDetailsDialog.pcDetails = model.details
showPcDetailsDialog.open()
}
}
}
}
@ -395,5 +404,14 @@ CenteredGridView {
}
}
NavigableMessageDialog {
id: showPcDetailsDialog
property int pcIndex : -1;
property string pcDetails : "";
text: showPcDetailsDialog.pcDetails
imageSrc: "qrc:/res/baseline-help_outline-24px.svg"
standardButtons: Dialog.Ok | (SystemProperties.hasBrowser ? Dialog.Help : 0)
}
ScrollBar.vertical: ScrollBar {}
}

View File

@ -42,6 +42,20 @@ QVariant ComputerModel::data(const QModelIndex& index, int role) const
return computer->state == NvComputer::CS_UNKNOWN;
case ServerSupportedRole:
return computer->isSupportedServerVersion;
case DetailsRole:
return tr("Name: %1\nStatus: %2\nActive Address: %3\nUUID: %4\nLocal Address: %5\nRemote Address: %6\nIPv6 Address: %7\nManual Address: %8\nMAC Address: %9\nPair State: %10\nRunning Game ID: %11\nHTTPS Port: %12")
.arg(computer->name)
.arg(computer->state == NvComputer::CS_ONLINE ? tr("Online") : tr("Offline"))
.arg(computer->activeAddress.toString())
.arg(computer->uuid)
.arg(computer->localAddress.toString())
.arg(computer->remoteAddress.toString())
.arg(computer->ipv6Address.toString())
.arg(computer->manualAddress.toString())
.arg(computer->macAddress.isEmpty() ? "<NULL>" : QString(computer->macAddress.toHex(':')))
.arg(computer->pairState == NvComputer::PS_PAIRED ? tr("Paired") : tr("Unpaired"))
.arg(computer->currentGameId)
.arg(computer->activeHttpsPort);
default:
return QVariant();
}
@ -69,6 +83,7 @@ QHash<int, QByteArray> ComputerModel::roleNames() const
names[WakeableRole] = "wakeable";
names[StatusUnknownRole] = "statusUnknown";
names[ServerSupportedRole] = "serverSupported";
names[DetailsRole] = "details";
return names;
}

View File

@ -15,7 +15,8 @@ class ComputerModel : public QAbstractListModel
BusyRole,
WakeableRole,
StatusUnknownRole,
ServerSupportedRole
ServerSupportedRole,
DetailsRole
};
public: