refactor: statusbar - be gone
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
This commit is contained in:
parent
822c98469f
commit
5189d29810
@ -211,8 +211,6 @@ public:
|
||||
*/
|
||||
virtual QString getLogFileRoot() = 0;
|
||||
|
||||
virtual QString getStatusbarDescription() = 0;
|
||||
|
||||
virtual QString getMainVersion() = 0;
|
||||
|
||||
/// FIXME: this really should be elsewhere...
|
||||
|
@ -179,7 +179,7 @@ QVariant InstanceList::data(const QModelIndex& index, int role) const
|
||||
case PlayTimeColumn:
|
||||
return Time::prettifyDuration(inst->totalTimePlayed());
|
||||
case LastPlayedColumn:
|
||||
return QDateTime::fromMSecsSinceEpoch(inst->lastLaunch());
|
||||
return QDateTime::fromMSecsSinceEpoch(inst->lastLaunch()); // FIXME: Qt does not retranslate this?
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -54,10 +54,6 @@ public:
|
||||
{
|
||||
setSpecificSettingsLoaded(true);
|
||||
}
|
||||
QString getStatusbarDescription() override
|
||||
{
|
||||
return tr("Unknown instance type");
|
||||
};
|
||||
QString getMainVersion() override
|
||||
{
|
||||
return tr("Unknown");
|
||||
|
@ -880,26 +880,6 @@ QString MinecraftInstance::getLogFileRoot()
|
||||
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 mcVersion = m_components->getComponentVersion("net.minecraft");
|
||||
if (mcVersion.isEmpty())
|
||||
|
@ -145,7 +145,6 @@ public:
|
||||
|
||||
QString getLogFileRoot() override;
|
||||
|
||||
QString getStatusbarDescription() override;
|
||||
QString getMainVersion() override;
|
||||
|
||||
// FIXME: remove
|
||||
|
@ -55,7 +55,6 @@
|
||||
#include <QHBoxLayout>
|
||||
#include <QHeaderView>
|
||||
#include <QMainWindow>
|
||||
#include <QStatusBar>
|
||||
#include <QToolBar>
|
||||
#include <QWidget>
|
||||
#include <QMenu>
|
||||
@ -263,7 +262,6 @@ public:
|
||||
|
||||
QWidget *centralWidget = nullptr;
|
||||
QHBoxLayout *horizontalLayout = nullptr;
|
||||
QStatusBar *statusBar = nullptr;
|
||||
|
||||
QMenuBar *menuBar = nullptr;
|
||||
QMenu *fileMenu;
|
||||
@ -588,13 +586,6 @@ public:
|
||||
actionCopyInstance->setEnabled(enabled);
|
||||
}
|
||||
|
||||
void createStatusBar(QMainWindow *MainWindow)
|
||||
{
|
||||
statusBar = new QStatusBar(MainWindow);
|
||||
statusBar->setObjectName(QStringLiteral("statusBar"));
|
||||
MainWindow->setStatusBar(statusBar);
|
||||
}
|
||||
|
||||
void createNewsToolbar(QMainWindow *MainWindow)
|
||||
{
|
||||
newsToolBar = TranslatedToolbar(MainWindow);
|
||||
@ -795,7 +786,6 @@ public:
|
||||
horizontalLayout->setContentsMargins(0, 0, 0, 0);
|
||||
MainWindow->setCentralWidget(centralWidget);
|
||||
|
||||
createStatusBar(MainWindow);
|
||||
createNewsToolbar(MainWindow);
|
||||
createInstanceToolbar(MainWindow);
|
||||
|
||||
@ -824,12 +814,6 @@ public:
|
||||
// submenu buttons
|
||||
foldersMenuButton->setText(tr("Folders"));
|
||||
helpMenuButton->setText(tr("Help"));
|
||||
|
||||
// playtime counter
|
||||
if (MainWindow->m_statusCenter)
|
||||
{
|
||||
MainWindow->updateStatusCenter();
|
||||
}
|
||||
} // 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
|
||||
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
|
||||
QWidget *spacer = new QWidget();
|
||||
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
@ -1013,12 +992,6 @@ void MainWindow::retranslateUi()
|
||||
accountMenuButton->setText(tr("Profiles"));
|
||||
}
|
||||
|
||||
if (m_selectedInstance) {
|
||||
m_statusLeft->setText(m_selectedInstance->getStatusbarDescription());
|
||||
} else {
|
||||
m_statusLeft->setText(tr("No instance selected"));
|
||||
}
|
||||
|
||||
ui->retranslateUi(this);
|
||||
}
|
||||
|
||||
@ -1738,7 +1711,6 @@ void MainWindow::globalSettingsClosed()
|
||||
//proxymodel->sort(0);
|
||||
updateMainToolBar();
|
||||
updateToolsMenu();
|
||||
updateStatusCenter();
|
||||
// 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:
|
||||
APPLICATION->settings()->set("MainWindowState", saveState().toBase64());
|
||||
@ -1952,8 +1924,6 @@ void MainWindow::instanceChanged(InstancePtr current, InstancePtr previous)
|
||||
ui->actionKillInstance->setEnabled(m_selectedInstance->isRunning());
|
||||
ui->actionExportInstance->setEnabled(m_selectedInstance->canExport());
|
||||
ui->renameButton->setText(m_selectedInstance->name());
|
||||
m_statusLeft->setText(m_selectedInstance->getStatusbarDescription());
|
||||
updateStatusCenter();
|
||||
updateInstanceToolIcon(m_selectedInstance->iconKey());
|
||||
|
||||
updateToolsMenu();
|
||||
@ -1986,7 +1956,6 @@ void MainWindow::selectionBad()
|
||||
// start by reseting everything...
|
||||
m_selectedInstance = nullptr;
|
||||
|
||||
statusBar()->clearMessage();
|
||||
ui->instanceToolBar->setEnabled(false);
|
||||
ui->setInstanceActionsEnabled(false);
|
||||
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)
|
||||
{
|
||||
auto current = view->currentInstance();
|
||||
|
@ -211,7 +211,6 @@ private:
|
||||
void activateInstance(InstancePtr instance);
|
||||
void updateInstanceToolIcon(QString new_icon);
|
||||
void setSelectedInstanceById(const QString &id);
|
||||
void updateStatusCenter();
|
||||
|
||||
void runModalTask(Task *task);
|
||||
void instanceFromInstanceTask(InstanceTask *task);
|
||||
@ -223,8 +222,6 @@ private:
|
||||
// these are managed by Qt's memory management model!
|
||||
InstanceView *view = nullptr;
|
||||
QToolButton *newsLabel = nullptr;
|
||||
QLabel *m_statusLeft = nullptr;
|
||||
QLabel *m_statusCenter = nullptr;
|
||||
QMenu *accountMenu = nullptr;
|
||||
QToolButton *accountMenuButton = nullptr;
|
||||
|
||||
|
@ -86,8 +86,12 @@ void InstanceView::createTable()
|
||||
header->setSectionResizeMode(InstanceList::LastPlayedColumn, QHeaderView::Interactive);
|
||||
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"))
|
||||
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->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &InstanceView::currentRowChanged);
|
||||
|
Loading…
x
Reference in New Issue
Block a user