mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2026-06-29 01:54:20 +03:00
Added the option to sort instances by total playtime (#5701)
Signed-off-by: Anceph <yucehasan31@gmail.com>
This commit is contained in:
parent
f654ce8212
commit
a607373ced
3 changed files with 26 additions and 1 deletions
|
|
@ -62,6 +62,12 @@ bool InstanceProxyModel::subSortLessThan(const QModelIndex& left, const QModelIn
|
|||
QString sortMode = APPLICATION->settings()->get("InstSortMode").toString();
|
||||
if (sortMode == "LastLaunch") {
|
||||
return pdataLeft->lastLaunch() > pdataRight->lastLaunch();
|
||||
} else if (sortMode == "Playtime") {
|
||||
if (pdataLeft->totalTimePlayed() == pdataRight->totalTimePlayed()) {
|
||||
// fallback to name sorting if playtime is equal
|
||||
return m_naturalSort.compare(pdataLeft->name(), pdataRight->name()) < 0;
|
||||
}
|
||||
return pdataLeft->totalTimePlayed() > pdataRight->totalTimePlayed();
|
||||
} else {
|
||||
return m_naturalSort.compare(pdataLeft->name(), pdataRight->name()) < 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,9 @@ enum InstSortMode {
|
|||
// Sort alphabetically by name.
|
||||
Sort_Name,
|
||||
// Sort by which instance was launched most recently.
|
||||
Sort_LastLaunch
|
||||
Sort_LastLaunch,
|
||||
// Sort by which instance has the most playtime.
|
||||
Sort_Playtime,
|
||||
};
|
||||
|
||||
LauncherPage::LauncherPage(QWidget* parent) : QWidget(parent), ui(new Ui::LauncherPage)
|
||||
|
|
@ -71,6 +73,7 @@ LauncherPage::LauncherPage(QWidget* parent) : QWidget(parent), ui(new Ui::Launch
|
|||
|
||||
ui->sortingModeGroup->setId(ui->sortByNameBtn, Sort_Name);
|
||||
ui->sortingModeGroup->setId(ui->sortLastLaunchedBtn, Sort_LastLaunch);
|
||||
ui->sortingModeGroup->setId(ui->sortByPlaytimeBtn, Sort_Playtime);
|
||||
|
||||
loadSettings();
|
||||
|
||||
|
|
@ -227,6 +230,9 @@ void LauncherPage::applySettings()
|
|||
case Sort_LastLaunch:
|
||||
s->set("InstSortMode", "LastLaunch");
|
||||
break;
|
||||
case Sort_Playtime:
|
||||
s->set("InstSortMode", "Playtime");
|
||||
break;
|
||||
case Sort_Name:
|
||||
default:
|
||||
s->set("InstSortMode", "Name");
|
||||
|
|
@ -282,6 +288,8 @@ void LauncherPage::loadSettings()
|
|||
QString sortMode = s->get("InstSortMode").toString();
|
||||
if (sortMode == "LastLaunch") {
|
||||
ui->sortLastLaunchedBtn->setChecked(true);
|
||||
} else if (sortMode == "Playtime"){
|
||||
ui->sortByPlaytimeBtn->setChecked(true);
|
||||
} else {
|
||||
ui->sortByNameBtn->setChecked(true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,6 +83,16 @@
|
|||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="sortByPlaytimeBtn">
|
||||
<property name="text">
|
||||
<string>By &playtime</string>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">sortingModeGroup</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
|
|
@ -675,6 +685,7 @@
|
|||
<tabstop>scrollArea</tabstop>
|
||||
<tabstop>sortByNameBtn</tabstop>
|
||||
<tabstop>sortLastLaunchedBtn</tabstop>
|
||||
<tabstop>sortByPlaytimeBtn</tabstop>
|
||||
<tabstop>askToRenameDirBtn</tabstop>
|
||||
<tabstop>alwaysRenameDirBtn</tabstop>
|
||||
<tabstop>neverRenameDirBtn</tabstop>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue