Skip to content

Commit

Permalink
Reassign focus if necessary in mainView when count changes
Browse files Browse the repository at this point in the history
  • Loading branch information
streetpea committed Oct 23, 2024
1 parent 0e956d2 commit c5246b0
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 6 deletions.
22 changes: 20 additions & 2 deletions gui/src/qml/MainView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import org.streetpea.chiaking

Pane {
padding: 0

id: consolePane
StackView.onActivated: {
forceActiveFocus();
if(Chiaki.settings.remotePlayAsk)
Expand Down Expand Up @@ -148,6 +148,23 @@ Pane {
}
clip: true
model: Chiaki.hosts
onCountChanged: {
if(!hostsView.currentItem)
hostsView.incrementCurrentIndex();
if(!hostsView.currentItem)
return;
if(!hostsView.currentItem.visible)
{
for(var i = 0; i < hostsView.count; i++)
{
hostsView.incrementCurrentIndex()
if(hostsView.currentItem.visible)
{
break;
}
}
}
}
delegate: ItemDelegate {
visible: modelData.display
id: delegate
Expand All @@ -170,7 +187,8 @@ Pane {

function deleteHost() {
if (modelData.manual)
root.showConfirmDialog(qsTr("Delete Console"), qsTr("Are you sure you want to delete this console?"), () => Chiaki.deleteHost(index));
root.showConfirmDialog(qsTr("Delete Console"), qsTr("Are you sure you want to delete this console?"), () => {Chiaki.deleteHost(index)});

else if (modelData.discovered && !modelData.registered)
root.showConfirmDialog(qsTr("Hide Console"), qsTr("Are you sure you want to hide this console?") + "\n\n" + qsTr("Note: You can unhide from the Consoles section of the Settings under Hidden Consoles"), () => Chiaki.hideHost(modelData.mac, modelData.name));

Expand Down
1 change: 1 addition & 0 deletions gui/src/qml/PSNTokenDialog.qml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ DialogView {
ScrollBar.vertical: ScrollBar {
id: logScrollbar
policy: ScrollBar.AlwaysOn
visible: logFlick.contentHeight > logFlick.implicitHeight
}

Label {
Expand Down
1 change: 1 addition & 0 deletions gui/src/qml/RegistDialog.qml
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ DialogView {
ScrollBar.vertical: ScrollBar {
id: logScrollbar
policy: ScrollBar.AlwaysOn
visible: logFlick.contentHeight > logFlick.implicitHeight
}

Label {
Expand Down
8 changes: 5 additions & 3 deletions gui/src/qml/SettingsDialog.qml
Original file line number Diff line number Diff line change
Expand Up @@ -1084,6 +1084,7 @@ DialogView {
ScrollBar.vertical: ScrollBar {
id: consolesScrollbar
policy: ScrollBar.AlwaysOn
visible: consolesView.contentHeight > consolesView.height
}
clip: true
model: Chiaki.settings.registeredHosts
Expand Down Expand Up @@ -1275,10 +1276,11 @@ DialogView {
topMargin: 10
}
clip: true
width: 400
width: 500
ScrollBar.vertical: ScrollBar {
id: hiddenConsolesScrollbar
policy: ScrollBar.AlwaysOn
visible: hiddenConsolesView.contentHeight > hiddenConsolesView.height
}
model: Chiaki.hiddenHosts
delegate: ItemDelegate {
Expand Down Expand Up @@ -1683,7 +1685,7 @@ DialogView {
id: aboutButton
lastInFocusChain: true
implicitWidth: 200
text: qsTr("About %1").arg(Qt.application.displayName)
text: qsTr("About %1-ng").arg(Qt.application.name)
onClicked: aboutDialog.open()
Material.roundedScale: Material.SmallScale
}
Expand Down Expand Up @@ -1743,7 +1745,7 @@ DialogView {
parent: Overlay.overlay
x: Math.round((root.width - width) / 2)
y: Math.round((root.height - height) / 2)
title: qsTr("About %1").arg(Qt.application.name)
title: qsTr("About %1-ng").arg(Qt.application.name)
modal: true
standardButtons: Dialog.Ok
Material.roundedScale: Material.MediumScale
Expand Down
1 change: 1 addition & 0 deletions gui/src/qml/SteamShortcutDialog.qml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ DialogView {
ScrollBar.vertical: ScrollBar {
id: logScrollbar
policy: ScrollBar.AlwaysOn
visible: logFlick.contentHeight > logFlick.implicitHeight
}

Label {
Expand Down
2 changes: 1 addition & 1 deletion gui/src/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ void Settings::ImportSettings(QString fileurl)
LoadHiddenHosts(&settings_backup);
LoadManualHosts(&settings_backup);
LoadControllerMappings(&settings_backup);
QString profile = settings_backup.value("this_profile").toString();
QString profile = settings_backup.value("settings/this_profile").toString();
if(profile.isEmpty())
{
settings.clear();
Expand Down

0 comments on commit c5246b0

Please sign in to comment.