[core, android] Initial playtime implementation #2535
3 changed files with 0 additions and 65 deletions
|
@ -27,9 +27,6 @@ add_library(qt_common STATIC
|
|||
qt_rom_util.h qt_rom_util.cpp
|
||||
qt_applet_util.h qt_applet_util.cpp
|
||||
qt_progress_dialog.h qt_progress_dialog.cpp
|
||||
qt_playtime_manager.cpp
|
||||
qt_playtime_manager.h
|
||||
|
||||
)
|
||||
|
||||
create_target_directory_groups(qt_common)
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#include "qt_playtime_manager.h"
|
||||
|
||||
namespace QtCommon::PlayTimeManager {
|
||||
|
||||
QString ReadablePlayTime(qulonglong time_seconds) {
|
||||
if (time_seconds == 0) {
|
||||
return {};
|
||||
}
|
||||
const auto time_minutes = std::max(static_cast<double>(time_seconds) / 60, 1.0);
|
||||
const auto time_hours = static_cast<double>(time_seconds) / 3600;
|
||||
const bool is_minutes = time_minutes < 60;
|
||||
const char* unit = is_minutes ? "m" : "h";
|
||||
const auto value = is_minutes ? time_minutes : time_hours;
|
||||
|
||||
return QStringLiteral("%L1 %2")
|
||||
.arg(value, 0, 'f', !is_minutes && time_seconds % 60 != 0)
|
||||
.arg(QString::fromUtf8(unit));
|
||||
}
|
||||
|
||||
QString GetPlayTimeUnit(qulonglong time_seconds, TimeUnit unit) {
|
||||
switch (unit) {
|
||||
case TimeUnit::Hours: {
|
||||
const qulonglong hours = time_seconds / 3600;
|
||||
return QString::number(hours);
|
||||
}
|
||||
case TimeUnit::Minutes: {
|
||||
const qulonglong minutes = (time_seconds % 3600) / 60;
|
||||
return QString::number(minutes);
|
||||
}
|
||||
case TimeUnit::Seconds: {
|
||||
const qulonglong seconds = time_seconds % 60;
|
||||
return QString::number(seconds);
|
||||
}
|
||||
default:
|
||||
return QStringLiteral("0");
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace QtCommon::PlayTimeManager
|
|
@ -1,20 +0,0 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#include <QString>
|
||||
|
||||
namespace QtCommon::PlayTimeManager {
|
||||
|
||||
enum class TimeUnit {
|
||||
Hours,
|
||||
Minutes,
|
||||
Seconds
|
||||
};
|
||||
|
||||
// Converts a length of time in seconds into a readable format
|
||||
QString ReadablePlayTime(qulonglong time_seconds);
|
||||
|
||||
// Returns play time hours/minutes/seconds as a string
|
||||
QString GetPlayTimeUnit(qulonglong time_seconds, TimeUnit unit);
|
||||
|
||||
} // namespace QtCommon::PlayTimeManager
|
Loading…
Add table
Add a link
Reference in a new issue