refactor: statusbar - be gone

Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
This commit is contained in:
Sefa Eyeoglu 2022-10-01 23:21:09 +02:00
parent 822c98469f
commit 5189d29810
No known key found for this signature in database
GPG Key ID: C10411294912A422
8 changed files with 6 additions and 73 deletions

View File

@ -211,8 +211,6 @@ public:
*/ */
virtual QString getLogFileRoot() = 0; virtual QString getLogFileRoot() = 0;
virtual QString getStatusbarDescription() = 0;
virtual QString getMainVersion() = 0; virtual QString getMainVersion() = 0;
/// FIXME: this really should be elsewhere... /// FIXME: this really should be elsewhere...

View File

@ -179,7 +179,7 @@ QVariant InstanceList::data(const QModelIndex& index, int role) const
case PlayTimeColumn: case PlayTimeColumn:
return Time::prettifyDuration(inst->totalTimePlayed()); return Time::prettifyDuration(inst->totalTimePlayed());
case LastPlayedColumn: case LastPlayedColumn:
return QDateTime::fromMSecsSinceEpoch(inst->lastLaunch()); return QDateTime::fromMSecsSinceEpoch(inst->lastLaunch()); // FIXME: Qt does not retranslate this?
} }
break; break;
} }

View File

@ -54,10 +54,6 @@ public:
{ {
setSpecificSettingsLoaded(true); setSpecificSettingsLoaded(true);
} }
QString getStatusbarDescription() override
{
return tr("Unknown instance type");
};
QString getMainVersion() override QString getMainVersion() override
{ {
return tr("Unknown"); return tr("Unknown");

View File

@ -880,26 +880,6 @@ QString MinecraftInstance::getLogFileRoot()
return gameRoot(); return gameRoot();
} }
QString MinecraftInstance::getStatusbarDescription()
{
QString description = getMainVersion();
if(m_settings->get("ShowGameTime").toBool())
{
if (lastTimePlayed() > 0) {
description.append(tr(", last played for %1").arg(Time::prettifyDuration(lastTimePlayed())));
}
if (totalTimePlayed() > 0) {
description.append(tr(", total played for %1").arg(Time::prettifyDuration(totalTimePlayed())));
}
}
if(hasCrashed())
{
description.append(tr(", has crashed."));
}
return description;
}
QString MinecraftInstance::getMainVersion() { QString MinecraftInstance::getMainVersion() {
QString mcVersion = m_components->getComponentVersion("net.minecraft"); QString mcVersion = m_components->getComponentVersion("net.minecraft");
if (mcVersion.isEmpty()) if (mcVersion.isEmpty())

View File

@ -145,7 +145,6 @@ public:
QString getLogFileRoot() override; QString getLogFileRoot() override;
QString getStatusbarDescription() override;
QString getMainVersion() override; QString getMainVersion() override;
// FIXME: remove // FIXME: remove

View File

@ -55,7 +55,6 @@
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QHeaderView> #include <QHeaderView>
#include <QMainWindow> #include <QMainWindow>
#include <QStatusBar>
#include <QToolBar> #include <QToolBar>
#include <QWidget> #include <QWidget>
#include <QMenu> #include <QMenu>
@ -263,7 +262,6 @@ public:
QWidget *centralWidget = nullptr; QWidget *centralWidget = nullptr;
QHBoxLayout *horizontalLayout = nullptr; QHBoxLayout *horizontalLayout = nullptr;
QStatusBar *statusBar = nullptr;
QMenuBar *menuBar = nullptr; QMenuBar *menuBar = nullptr;
QMenu *fileMenu; QMenu *fileMenu;
@ -588,13 +586,6 @@ public:
actionCopyInstance->setEnabled(enabled); actionCopyInstance->setEnabled(enabled);
} }
void createStatusBar(QMainWindow *MainWindow)
{
statusBar = new QStatusBar(MainWindow);
statusBar->setObjectName(QStringLiteral("statusBar"));
MainWindow->setStatusBar(statusBar);
}
void createNewsToolbar(QMainWindow *MainWindow) void createNewsToolbar(QMainWindow *MainWindow)
{ {
newsToolBar = TranslatedToolbar(MainWindow); newsToolBar = TranslatedToolbar(MainWindow);
@ -795,7 +786,6 @@ public:
horizontalLayout->setContentsMargins(0, 0, 0, 0); horizontalLayout->setContentsMargins(0, 0, 0, 0);
MainWindow->setCentralWidget(centralWidget); MainWindow->setCentralWidget(centralWidget);
createStatusBar(MainWindow);
createNewsToolbar(MainWindow); createNewsToolbar(MainWindow);
createInstanceToolbar(MainWindow); createInstanceToolbar(MainWindow);
@ -824,12 +814,6 @@ public:
// submenu buttons // submenu buttons
foldersMenuButton->setText(tr("Folders")); foldersMenuButton->setText(tr("Folders"));
helpMenuButton->setText(tr("Help")); helpMenuButton->setText(tr("Help"));
// playtime counter
if (MainWindow->m_statusCenter)
{
MainWindow->updateStatusCenter();
}
} // retranslateUi } // retranslateUi
}; };
@ -895,11 +879,6 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new MainWindow
// When the global settings page closes, we want to know about it and update our state // When the global settings page closes, we want to know about it and update our state
connect(APPLICATION, &Application::globalSettingsClosed, this, &MainWindow::globalSettingsClosed); connect(APPLICATION, &Application::globalSettingsClosed, this, &MainWindow::globalSettingsClosed);
m_statusLeft = new QLabel(tr("No instance selected"), this);
m_statusCenter = new QLabel(tr("Total playtime: 0s"), this);
statusBar()->addPermanentWidget(m_statusLeft, 1);
statusBar()->addPermanentWidget(m_statusCenter, 0);
// Add "manage accounts" button, right align // Add "manage accounts" button, right align
QWidget *spacer = new QWidget(); QWidget *spacer = new QWidget();
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
@ -1013,12 +992,6 @@ void MainWindow::retranslateUi()
accountMenuButton->setText(tr("Profiles")); accountMenuButton->setText(tr("Profiles"));
} }
if (m_selectedInstance) {
m_statusLeft->setText(m_selectedInstance->getStatusbarDescription());
} else {
m_statusLeft->setText(tr("No instance selected"));
}
ui->retranslateUi(this); ui->retranslateUi(this);
} }
@ -1738,7 +1711,6 @@ void MainWindow::globalSettingsClosed()
//proxymodel->sort(0); //proxymodel->sort(0);
updateMainToolBar(); updateMainToolBar();
updateToolsMenu(); updateToolsMenu();
updateStatusCenter();
// This needs to be done to prevent UI elements disappearing in the event the config is changed // This needs to be done to prevent UI elements disappearing in the event the config is changed
// but Prism Launcher exits abnormally, causing the window state to never be saved: // but Prism Launcher exits abnormally, causing the window state to never be saved:
APPLICATION->settings()->set("MainWindowState", saveState().toBase64()); APPLICATION->settings()->set("MainWindowState", saveState().toBase64());
@ -1952,8 +1924,6 @@ void MainWindow::instanceChanged(InstancePtr current, InstancePtr previous)
ui->actionKillInstance->setEnabled(m_selectedInstance->isRunning()); ui->actionKillInstance->setEnabled(m_selectedInstance->isRunning());
ui->actionExportInstance->setEnabled(m_selectedInstance->canExport()); ui->actionExportInstance->setEnabled(m_selectedInstance->canExport());
ui->renameButton->setText(m_selectedInstance->name()); ui->renameButton->setText(m_selectedInstance->name());
m_statusLeft->setText(m_selectedInstance->getStatusbarDescription());
updateStatusCenter();
updateInstanceToolIcon(m_selectedInstance->iconKey()); updateInstanceToolIcon(m_selectedInstance->iconKey());
updateToolsMenu(); updateToolsMenu();
@ -1986,7 +1956,6 @@ void MainWindow::selectionBad()
// start by reseting everything... // start by reseting everything...
m_selectedInstance = nullptr; m_selectedInstance = nullptr;
statusBar()->clearMessage();
ui->instanceToolBar->setEnabled(false); ui->instanceToolBar->setEnabled(false);
ui->setInstanceActionsEnabled(false); ui->setInstanceActionsEnabled(false);
updateToolsMenu(); updateToolsMenu();
@ -2036,16 +2005,6 @@ void MainWindow::checkInstancePathForProblems()
} }
} }
void MainWindow::updateStatusCenter()
{
m_statusCenter->setVisible(APPLICATION->settings()->get("ShowGlobalGameTime").toBool());
int timePlayed = APPLICATION->instances()->getTotalPlayTime();
if (timePlayed > 0) {
m_statusCenter->setText(tr("Total playtime: %1").arg(Time::prettifyDuration(timePlayed)));
}
}
void MainWindow::refreshCurrentInstance(bool running) void MainWindow::refreshCurrentInstance(bool running)
{ {
auto current = view->currentInstance(); auto current = view->currentInstance();

View File

@ -211,7 +211,6 @@ private:
void activateInstance(InstancePtr instance); void activateInstance(InstancePtr instance);
void updateInstanceToolIcon(QString new_icon); void updateInstanceToolIcon(QString new_icon);
void setSelectedInstanceById(const QString &id); void setSelectedInstanceById(const QString &id);
void updateStatusCenter();
void runModalTask(Task *task); void runModalTask(Task *task);
void instanceFromInstanceTask(InstanceTask *task); void instanceFromInstanceTask(InstanceTask *task);
@ -223,8 +222,6 @@ private:
// these are managed by Qt's memory management model! // these are managed by Qt's memory management model!
InstanceView *view = nullptr; InstanceView *view = nullptr;
QToolButton *newsLabel = nullptr; QToolButton *newsLabel = nullptr;
QLabel *m_statusLeft = nullptr;
QLabel *m_statusCenter = nullptr;
QMenu *accountMenu = nullptr; QMenu *accountMenu = nullptr;
QToolButton *accountMenuButton = nullptr; QToolButton *accountMenuButton = nullptr;

View File

@ -86,8 +86,12 @@ void InstanceView::createTable()
header->setSectionResizeMode(InstanceList::LastPlayedColumn, QHeaderView::Interactive); header->setSectionResizeMode(InstanceList::LastPlayedColumn, QHeaderView::Interactive);
m_table->verticalHeader()->setDefaultSectionSize(m_rowHeight + 1 + 1); // padding top and bottom m_table->verticalHeader()->setDefaultSectionSize(m_rowHeight + 1 + 1); // padding top and bottom
m_table->setColumnWidth(InstanceList::GameVersionColumn, 96 + 3 + 3);
m_table->setColumnWidth(InstanceList::PlayTimeColumn, 96 + 3 + 3);
m_table->setColumnWidth(InstanceList::LastPlayedColumn, 128 + 3 + 3);
if (!APPLICATION->settings()->contains("InstanceViewTableHeaderState")) if (!APPLICATION->settings()->contains("InstanceViewTableHeaderState"))
m_table->sortByColumn(InstanceList::LastPlayedColumn, Qt::AscendingOrder); m_table->sortByColumn(InstanceList::LastPlayedColumn, Qt::DescendingOrder);
connect(m_table, &QAbstractItemView::doubleClicked, this, &InstanceView::activateInstance); connect(m_table, &QAbstractItemView::doubleClicked, this, &InstanceView::activateInstance);
connect(m_table->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &InstanceView::currentRowChanged); connect(m_table->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &InstanceView::currentRowChanged);