aboutsummaryrefslogtreecommitdiff
path: root/application
diff options
context:
space:
mode:
authorLeland Liu <14846866+lelandliu@users.noreply.github.com>2019-07-09 22:23:24 -0400
committerPetr Mrázek <peterix@gmail.com>2021-07-22 20:26:59 +0200
commit1762d2fc7de99e38477a517c9b379447fd00b968 (patch)
tree8c510ad8f7de5e98dc8c46a3e2deac04ee4fd9a8 /application
parent8ea500de68fa184ab1198f7a68c53987840014c3 (diff)
downloadPrismLauncher-1762d2fc7de99e38477a517c9b379447fd00b968.tar.gz
PrismLauncher-1762d2fc7de99e38477a517c9b379447fd00b968.tar.bz2
PrismLauncher-1762d2fc7de99e38477a517c9b379447fd00b968.zip
Added total playtime
Diffstat (limited to 'application')
-rw-r--r--application/MainWindow.cpp20
-rw-r--r--application/MainWindow.h2
2 files changed, 21 insertions, 1 deletions
diff --git a/application/MainWindow.cpp b/application/MainWindow.cpp
index 13a7c7ae..1720ca89 100644
--- a/application/MainWindow.cpp
+++ b/application/MainWindow.cpp
@@ -259,6 +259,7 @@ public:
actionAddInstance.setTooltipId(QT_TRANSLATE_NOOP("MainWindow", "Add a new instance."));
all_actions.append(&actionAddInstance);
mainToolBar->addAction(actionAddInstance);
+ actionAddInstance.setTextId(QT_TRANSLATE_NOOP("MainWindow", "A"));
mainToolBar->addSeparator();
@@ -724,8 +725,10 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new MainWindow
connect(MMC, &MultiMC::globalSettingsClosed, this, &MainWindow::globalSettingsClosed);
m_statusLeft = new QLabel(tr("No instance selected"), this);
+ m_statusCenter = new QLabel(tr("Total playtime: 0s."), this);
m_statusRight = new ServerStatus(this);
statusBar()->addPermanentWidget(m_statusLeft, 1);
+ statusBar()->addPermanentWidget(m_statusCenter, 1);
statusBar()->addPermanentWidget(m_statusRight, 0);
// Add "manage accounts" button, right align
@@ -1327,7 +1330,6 @@ void MainWindow::setCatBackground(bool enabled)
{
QDateTime now = QDateTime::currentDateTime();
QDateTime xmas(QDate(now.date().year(), 12, 25), QTime(0, 0));
- ;
QString cat = (non_stupid_abs(now.daysTo(xmas)) <= 4) ? "catmas" : "kitteh";
view->setStyleSheet(QString(R"(
GroupView
@@ -1526,6 +1528,7 @@ void MainWindow::setSelectedInstanceById(const QString &id)
{
QModelIndex selectionIndex = proxymodel->mapFromSource(index);
view->selectionModel()->setCurrentIndex(selectionIndex, QItemSelectionModel::ClearAndSelect);
+ updateStatusCenter();
}
}
@@ -1854,6 +1857,7 @@ void MainWindow::instanceChanged(const QModelIndex &current, const QModelIndex &
ui->actionExportInstance->setEnabled(m_selectedInstance->canExport());
ui->renameButton->setText(m_selectedInstance->name());
m_statusLeft->setText(m_selectedInstance->getStatusbarDescription());
+ updateStatusCenter();
updateInstanceToolIcon(m_selectedInstance->iconKey());
updateToolsMenu();
@@ -1932,3 +1936,17 @@ void MainWindow::checkInstancePathForProblems()
warning.exec();
}
}
+
+void MainWindow::updateStatusCenter()
+{
+ int timeplayed = MMC->instances()->getTotalPlayTime();
+ int minutes = timeplayed / 60;
+ int hours = minutes / 60;
+ int seconds = timeplayed % 60;
+ if(hours != 0)
+ m_statusCenter->setText(tr("Total playtime: %1h %2m %3s").arg(hours).arg(minutes).arg(seconds));
+ else if(minutes != 0)
+ m_statusCenter->setText(tr("Total playtime: %1m %2s").arg(minutes).arg(seconds));
+ else if(seconds != 0)
+ m_statusCenter->setText(tr("Total playtime: %1s").arg(seconds));
+}
diff --git a/application/MainWindow.h b/application/MainWindow.h
index 08c6b969..c992ab94 100644
--- a/application/MainWindow.h
+++ b/application/MainWindow.h
@@ -194,6 +194,7 @@ private:
void setCatBackground(bool enabled);
void updateInstanceToolIcon(QString new_icon);
void setSelectedInstanceById(const QString &id);
+ void updateStatusCenter();
void runModalTask(Task *task);
void instanceFromInstanceTask(InstanceTask *task);
@@ -207,6 +208,7 @@ private:
InstanceProxyModel *proxymodel = nullptr;
QToolButton *newsLabel = nullptr;
QLabel *m_statusLeft = nullptr;
+ QLabel *m_statusCenter = nullptr;
ServerStatus *m_statusRight = nullptr;
QMenu *accountMenu = nullptr;
QToolButton *accountMenuButton = nullptr;