mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-06-17 14:11:33 +00:00
Move Add PC button to toolbar
This commit is contained in:
+15
-55
@@ -77,9 +77,7 @@ GridView {
|
|||||||
Image {
|
Image {
|
||||||
id: pcIcon
|
id: pcIcon
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
source: {
|
source: "qrc:/res/ic_tv_white_48px.svg"
|
||||||
model.addPc ? "qrc:/res/ic_add_to_queue_white_48px.svg" : "qrc:/res/ic_tv_white_48px.svg"
|
|
||||||
}
|
|
||||||
sourceSize {
|
sourceSize {
|
||||||
width: 200
|
width: 200
|
||||||
height: 200
|
height: 200
|
||||||
@@ -92,7 +90,7 @@ GridView {
|
|||||||
anchors.horizontalCenter: pcIcon.horizontalCenter
|
anchors.horizontalCenter: pcIcon.horizontalCenter
|
||||||
anchors.verticalCenter: pcIcon.verticalCenter
|
anchors.verticalCenter: pcIcon.verticalCenter
|
||||||
anchors.verticalCenterOffset: -10
|
anchors.verticalCenterOffset: -10
|
||||||
visible: !model.addPc && !model.statusUnknown && (!model.online || !model.paired)
|
visible: !model.statusUnknown && (!model.online || !model.paired)
|
||||||
source: !model.online ? "qrc:/res/baseline-warning-24px.svg" : "qrc:/res/baseline-lock-24px.svg"
|
source: !model.online ? "qrc:/res/baseline-warning-24px.svg" : "qrc:/res/baseline-lock-24px.svg"
|
||||||
sourceSize {
|
sourceSize {
|
||||||
width: 75
|
width: 75
|
||||||
@@ -107,7 +105,7 @@ GridView {
|
|||||||
anchors.verticalCenterOffset: -10
|
anchors.verticalCenterOffset: -10
|
||||||
width: 75
|
width: 75
|
||||||
height: 75
|
height: 75
|
||||||
visible: !model.addPc && model.statusUnknown
|
visible: model.statusUnknown
|
||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
@@ -136,15 +134,12 @@ GridView {
|
|||||||
parentMenu: pcContextMenu
|
parentMenu: pcContextMenu
|
||||||
text: "Wake PC"
|
text: "Wake PC"
|
||||||
onTriggered: computerModel.wakeComputer(index)
|
onTriggered: computerModel.wakeComputer(index)
|
||||||
visible: !model.addPc && !model.online && model.wakeable
|
visible: !model.online && model.wakeable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (model.addPc) {
|
if (model.online) {
|
||||||
addPcDialog.open()
|
|
||||||
}
|
|
||||||
else if (model.online) {
|
|
||||||
if (model.paired) {
|
if (model.paired) {
|
||||||
// go to game view
|
// go to game view
|
||||||
var component = Qt.createComponent("AppView.qml")
|
var component = Qt.createComponent("AppView.qml")
|
||||||
@@ -176,15 +171,13 @@ GridView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onPressAndHold: {
|
onPressAndHold: {
|
||||||
if (!model.addPc) {
|
// popup() ensures the menu appears under the mouse cursor
|
||||||
// popup() ensures the menu appears under the mouse cursor
|
if (pcContextMenu.popup) {
|
||||||
if (pcContextMenu.popup) {
|
pcContextMenu.popup()
|
||||||
pcContextMenu.popup()
|
}
|
||||||
}
|
else {
|
||||||
else {
|
// Qt 5.9 doesn't have popup()
|
||||||
// Qt 5.9 doesn't have popup()
|
pcContextMenu.open()
|
||||||
pcContextMenu.open()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,11 +190,9 @@ GridView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Keys.onMenuPressed: {
|
Keys.onMenuPressed: {
|
||||||
if (!model.addPc) {
|
// We must use open() here so the menu is positioned on
|
||||||
// We must use open() here so the menu is positioned on
|
// the ItemDelegate and not where the mouse cursor is
|
||||||
// the ItemDelegate and not where the mouse cursor is
|
pcContextMenu.open()
|
||||||
pcContextMenu.open()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -245,37 +236,6 @@ GridView {
|
|||||||
onAccepted: deletePc()
|
onAccepted: deletePc()
|
||||||
}
|
}
|
||||||
|
|
||||||
Dialog {
|
|
||||||
id: addPcDialog
|
|
||||||
property string label: "Enter the IP address of your GameStream PC"
|
|
||||||
|
|
||||||
standardButtons: StandardButton.Ok | StandardButton.Cancel
|
|
||||||
|
|
||||||
onAccepted: {
|
|
||||||
if (editText.text) {
|
|
||||||
ComputerManager.addNewHost(editText.text, false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onVisibleChanged: {
|
|
||||||
if (visible) {
|
|
||||||
editText.forceActiveFocus()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ColumnLayout {
|
|
||||||
Text {
|
|
||||||
id: addPcDialogLabel
|
|
||||||
text: addPcDialog.label
|
|
||||||
}
|
|
||||||
|
|
||||||
TextField {
|
|
||||||
id: editText
|
|
||||||
Layout.fillWidth: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ScrollBar.vertical: ScrollBar {
|
ScrollBar.vertical: ScrollBar {
|
||||||
parent: pcGrid.parent
|
parent: pcGrid.parent
|
||||||
anchors {
|
anchors {
|
||||||
|
|||||||
@@ -22,18 +22,6 @@ QVariant ComputerModel::data(const QModelIndex& index, int role) const
|
|||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index.row() == m_Computers.count()) {
|
|
||||||
// We insert a synthetic item at the end for the Add PC option
|
|
||||||
switch (role) {
|
|
||||||
case NameRole:
|
|
||||||
return "Add PC";
|
|
||||||
case AddPcRole:
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return QVariant();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Q_ASSERT(index.row() < m_Computers.count());
|
Q_ASSERT(index.row() < m_Computers.count());
|
||||||
|
|
||||||
NvComputer* computer = m_Computers[index.row()];
|
NvComputer* computer = m_Computers[index.row()];
|
||||||
@@ -50,8 +38,6 @@ QVariant ComputerModel::data(const QModelIndex& index, int role) const
|
|||||||
return computer->currentGameId != 0;
|
return computer->currentGameId != 0;
|
||||||
case WakeableRole:
|
case WakeableRole:
|
||||||
return !computer->macAddress.isEmpty();
|
return !computer->macAddress.isEmpty();
|
||||||
case AddPcRole:
|
|
||||||
return false;
|
|
||||||
case StatusUnknownRole:
|
case StatusUnknownRole:
|
||||||
return computer->state == NvComputer::CS_UNKNOWN;
|
return computer->state == NvComputer::CS_UNKNOWN;
|
||||||
default:
|
default:
|
||||||
@@ -67,8 +53,7 @@ int ComputerModel::rowCount(const QModelIndex& parent) const
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add PC placeholder counts as 1
|
return m_Computers.count();
|
||||||
return m_Computers.count() + 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QHash<int, QByteArray> ComputerModel::roleNames() const
|
QHash<int, QByteArray> ComputerModel::roleNames() const
|
||||||
@@ -79,7 +64,6 @@ QHash<int, QByteArray> ComputerModel::roleNames() const
|
|||||||
names[OnlineRole] = "online";
|
names[OnlineRole] = "online";
|
||||||
names[PairedRole] = "paired";
|
names[PairedRole] = "paired";
|
||||||
names[BusyRole] = "busy";
|
names[BusyRole] = "busy";
|
||||||
names[AddPcRole] = "addPc";
|
|
||||||
names[WakeableRole] = "wakeable";
|
names[WakeableRole] = "wakeable";
|
||||||
names[StatusUnknownRole] = "statusUnknown";
|
names[StatusUnknownRole] = "statusUnknown";
|
||||||
|
|
||||||
|
|||||||
@@ -14,8 +14,7 @@ class ComputerModel : public QAbstractListModel
|
|||||||
PairedRole,
|
PairedRole,
|
||||||
BusyRole,
|
BusyRole,
|
||||||
WakeableRole,
|
WakeableRole,
|
||||||
StatusUnknownRole,
|
StatusUnknownRole
|
||||||
AddPcRole
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -218,6 +218,33 @@ ApplicationWindow {
|
|||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NavigableToolButton {
|
||||||
|
id: addPcButton
|
||||||
|
visible: stackView.currentItem.objectName === "Computers"
|
||||||
|
|
||||||
|
Image {
|
||||||
|
source: "qrc:/res/ic_add_to_queue_white_48px.svg"
|
||||||
|
anchors.centerIn: parent
|
||||||
|
sourceSize {
|
||||||
|
width: toolBar.height - toolBar.anchors.bottomMargin - toolBar.anchors.topMargin
|
||||||
|
height: toolBar.height - toolBar.anchors.bottomMargin - toolBar.anchors.topMargin
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ToolTip.delay: 1000
|
||||||
|
ToolTip.timeout: 3000
|
||||||
|
ToolTip.visible: hovered
|
||||||
|
ToolTip.text: "Add a new PC manually"
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
addPcDialog.open()
|
||||||
|
}
|
||||||
|
|
||||||
|
Keys.onDownPressed: {
|
||||||
|
stackView.currentItem.forceActiveFocus(Qt.TabFocus)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
NavigableToolButton {
|
NavigableToolButton {
|
||||||
property string browserUrl: ""
|
property string browserUrl: ""
|
||||||
|
|
||||||
@@ -403,4 +430,34 @@ ApplicationWindow {
|
|||||||
// For keyboard/gamepad navigation
|
// For keyboard/gamepad navigation
|
||||||
onAccepted: Qt.quit()
|
onAccepted: Qt.quit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Dialog {
|
||||||
|
id: addPcDialog
|
||||||
|
property string label: "Enter the IP address of your GameStream PC"
|
||||||
|
|
||||||
|
standardButtons: StandardButton.Ok | StandardButton.Cancel
|
||||||
|
|
||||||
|
onAccepted: {
|
||||||
|
if (editText.text) {
|
||||||
|
ComputerManager.addNewHost(editText.text, false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onVisibleChanged: {
|
||||||
|
if (visible) {
|
||||||
|
editText.forceActiveFocus()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
Text {
|
||||||
|
text: addPcDialog.label
|
||||||
|
}
|
||||||
|
|
||||||
|
TextField {
|
||||||
|
id: editText
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user