From 3e05685de25ceed8c5d856c04244817b888c4549 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Thu, 6 Jun 2024 14:35:20 +0000 Subject: [PATCH] Fixes & improvements to help tab: - Added "Configuration files directory" since it is located in different path at least on Linux and may be of interest to a player - Removed non-functioning "Open directory" buttons on mobile systems and stretched text box into now-empty space --- launcher/aboutProject/aboutproject_moc.cpp | 30 +++- launcher/aboutProject/aboutproject_moc.h | 5 + launcher/aboutProject/aboutproject_moc.ui | 192 ++++++++++++--------- 3 files changed, 142 insertions(+), 85 deletions(-) diff --git a/launcher/aboutProject/aboutproject_moc.cpp b/launcher/aboutProject/aboutproject_moc.cpp index b24f9e85d..b14f09fbd 100644 --- a/launcher/aboutProject/aboutproject_moc.cpp +++ b/launcher/aboutProject/aboutproject_moc.cpp @@ -16,6 +16,20 @@ #include "../../lib/GameConstants.h" #include "../../lib/VCMIDirs.h" +void AboutProjectView::hideAndStretchWidget(QGridLayout * layout, QWidget * toHide, QWidget * toStretch) +{ + toHide->hide(); + + int index = layout->indexOf(toStretch); + int row; + int col; + int unused; + layout->getItemPosition(index, &row, &col, &unused, &unused); + layout->removeWidget(toHide); + layout->removeWidget(toStretch); + layout->addWidget(toStretch, row, col, 1, -1); +} + AboutProjectView::AboutProjectView(QWidget * parent) : QWidget(parent) , ui(new Ui::AboutProjectView) @@ -25,8 +39,18 @@ AboutProjectView::AboutProjectView(QWidget * parent) ui->lineEditUserDataDir->setText(pathToQString(VCMIDirs::get().userDataPath())); ui->lineEditGameDir->setText(pathToQString(VCMIDirs::get().binaryPath())); ui->lineEditTempDir->setText(pathToQString(VCMIDirs::get().userLogsPath())); + ui->lineEditConfigDir->setText(pathToQString(VCMIDirs::get().userConfigPath())); ui->lineEditBuildVersion->setText(QString::fromStdString(GameConstants::VCMI_VERSION)); ui->lineEditOperatingSystem->setText(QSysInfo::prettyProductName()); + +#ifdef VCMI_MOBILE + // On mobile platforms these directories are generally not accessible from phone itself, only via USB connection from PC + // Remove "Open" buttons and stretch line with text into now-empty space + hideAndStretchWidget(ui->gridLayout, ui->openGameDataDir, ui->lineEditGameDir); + hideAndStretchWidget(ui->gridLayout, ui->openUserDataDir, ui->lineEditUserDataDir); + hideAndStretchWidget(ui->gridLayout, ui->openTempDir, ui->lineEditTempDir); + hideAndStretchWidget(ui->gridLayout, ui->openConfigDir, ui->lineEditConfigDir); +#endif } void AboutProjectView::changeEvent(QEvent *event) @@ -57,6 +81,11 @@ void AboutProjectView::on_openTempDir_clicked() QDesktopServices::openUrl(QUrl::fromLocalFile(QFileInfo(ui->lineEditTempDir->text()).absoluteFilePath())); } +void AboutProjectView::on_openConfigDir_clicked() +{ + QDesktopServices::openUrl(QUrl::fromLocalFile(QFileInfo(ui->lineEditConfigDir->text()).absoluteFilePath())); +} + void AboutProjectView::on_pushButtonDiscord_clicked() { QDesktopServices::openUrl(QUrl("https://discord.gg/chBT42V")); @@ -82,4 +111,3 @@ void AboutProjectView::on_pushButtonBugreport_clicked() { QDesktopServices::openUrl(QUrl("https://github.com/vcmi/vcmi/issues")); } - diff --git a/launcher/aboutProject/aboutproject_moc.h b/launcher/aboutProject/aboutproject_moc.h index aaad48d18..1e4703586 100644 --- a/launcher/aboutProject/aboutproject_moc.h +++ b/launcher/aboutProject/aboutproject_moc.h @@ -22,6 +22,9 @@ class AboutProjectView : public QWidget Q_OBJECT void changeEvent(QEvent *event) override; + + /// Hides a widget and expands second widgets to take place of first widget in layout + void hideAndStretchWidget(QGridLayout * layout, QWidget * toHide, QWidget * toStretch); public: explicit AboutProjectView(QWidget * parent = nullptr); @@ -48,6 +51,8 @@ private slots: void on_pushButtonBugreport_clicked(); + void on_openConfigDir_clicked(); + private: Ui::AboutProjectView * ui; diff --git a/launcher/aboutProject/aboutproject_moc.ui b/launcher/aboutProject/aboutproject_moc.ui index 7ffa28dbc..43361b6e2 100644 --- a/launcher/aboutProject/aboutproject_moc.ui +++ b/launcher/aboutProject/aboutproject_moc.ui @@ -38,7 +38,7 @@ - + 200 @@ -47,7 +47,6 @@ - 75 true @@ -80,27 +79,8 @@ - - - - - 0 - 0 - - - - - 75 - true - - - - Build Information - - - - - + + @@ -109,10 +89,10 @@ - - + + - User data directory + Open @@ -123,37 +103,15 @@ - - - - Open - - - - - - - Check for updates - - - - - - - true + + + + + true + - /home/user/.vcmi - - - true - - - - - - - Game version + Data Directories @@ -164,33 +122,10 @@ - - - - - 75 - true - - + + - Data Directories - - - - - - - true - - - /usr/share/vcmi - - - - - - - Open + Check for updates @@ -207,6 +142,33 @@ + + + + true + + + /usr/share/vcmi + + + + + + + + + + true + + + + + + + Open + + + @@ -221,16 +183,78 @@ - - + + - + User data directory + + + + + + + Game version + + + + + + + true + + + /home/user/.vcmi true + + + + + 0 + 0 + + + + + true + + + + Build Information + + + + + + + Configuration files directory + + + + + + + true + + + /home/user/.vcmi + + + true + + + + + + + Open + + +