mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-06-13 13:47:46 +02:00
Rework Launcher as General category
Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
@ -72,24 +72,14 @@ LauncherPage::LauncherPage(QWidget* parent) : QWidget(parent), ui(new Ui::Launch
|
||||
ui->sortingModeGroup->setId(ui->sortByNameBtn, Sort_Name);
|
||||
ui->sortingModeGroup->setId(ui->sortLastLaunchedBtn, Sort_LastLaunch);
|
||||
|
||||
defaultFormat = new QTextCharFormat(ui->fontPreview->currentCharFormat());
|
||||
|
||||
m_languageModel = APPLICATION->translations();
|
||||
loadSettings();
|
||||
|
||||
ui->updateSettingsBox->setHidden(!APPLICATION->updater());
|
||||
|
||||
connect(ui->fontSizeBox, QOverload<int>::of(&QSpinBox::valueChanged), this, &LauncherPage::refreshFontPreview);
|
||||
connect(ui->consoleFont, &QFontComboBox::currentFontChanged, this, &LauncherPage::refreshFontPreview);
|
||||
connect(ui->themeCustomizationWidget, &ThemeCustomizationWidget::currentWidgetThemeChanged, this, &LauncherPage::refreshFontPreview);
|
||||
|
||||
connect(ui->themeCustomizationWidget, &ThemeCustomizationWidget::currentCatChanged, APPLICATION, &Application::currentCatChanged);
|
||||
}
|
||||
|
||||
LauncherPage::~LauncherPage()
|
||||
{
|
||||
delete ui;
|
||||
delete defaultFormat;
|
||||
}
|
||||
|
||||
bool LauncherPage::apply()
|
||||
@ -194,9 +184,9 @@ void LauncherPage::on_skinsDirBrowseBtn_clicked()
|
||||
}
|
||||
}
|
||||
|
||||
void LauncherPage::on_metadataDisableBtn_clicked()
|
||||
void LauncherPage::on_metadataEnableBtn_clicked()
|
||||
{
|
||||
ui->metadataWarningLabel->setHidden(!ui->metadataDisableBtn->isChecked());
|
||||
ui->metadataWarningLabel->setHidden(ui->metadataEnableBtn->isChecked());
|
||||
}
|
||||
|
||||
void LauncherPage::applySettings()
|
||||
@ -217,9 +207,6 @@ void LauncherPage::applySettings()
|
||||
s->set("RequestTimeout", ui->timeoutSecondsSpinBox->value());
|
||||
|
||||
// Console settings
|
||||
QString consoleFontFamily = ui->consoleFont->currentFont().family();
|
||||
s->set("ConsoleFont", consoleFontFamily);
|
||||
s->set("ConsoleFontSize", ui->fontSizeBox->value());
|
||||
s->set("ConsoleMaxLines", ui->lineLimitSpinBox->value());
|
||||
s->set("ConsoleOverflowStop", ui->checkStopLogging->checkState() != Qt::Unchecked);
|
||||
|
||||
@ -245,13 +232,10 @@ void LauncherPage::applySettings()
|
||||
break;
|
||||
}
|
||||
|
||||
// Cat
|
||||
s->set("CatOpacity", ui->catOpacitySpinBox->value());
|
||||
|
||||
// Mods
|
||||
s->set("ModMetadataDisabled", ui->metadataDisableBtn->isChecked());
|
||||
s->set("ModDependenciesDisabled", ui->dependenciesDisableBtn->isChecked());
|
||||
s->set("SkipModpackUpdatePrompt", ui->skipModpackUpdatePromptBtn->isChecked());
|
||||
s->set("ModMetadataDisabled", !ui->metadataEnableBtn->isChecked());
|
||||
s->set("ModDependenciesDisabled", !ui->dependenciesEnableBtn->isChecked());
|
||||
s->set("SkipModpackUpdatePrompt", !ui->modpackUpdatePromptBtn->isChecked());
|
||||
}
|
||||
void LauncherPage::loadSettings()
|
||||
{
|
||||
@ -262,11 +246,6 @@ void LauncherPage::loadSettings()
|
||||
ui->updateIntervalSpinBox->setValue(APPLICATION->updater()->getUpdateCheckInterval() / 3600);
|
||||
}
|
||||
|
||||
// Toolbar/menu bar settings (not applicable if native menu bar is present)
|
||||
ui->toolsBox->setEnabled(!QMenuBar().isNativeMenuBar());
|
||||
#ifdef Q_OS_MACOS
|
||||
ui->toolsBox->setVisible(!QMenuBar().isNativeMenuBar());
|
||||
#endif
|
||||
ui->preferMenuBarCheckBox->setChecked(s->get("MenuBarInsteadOfToolBar").toBool());
|
||||
|
||||
ui->numberOfConcurrentTasksSpinBox->setValue(s->get("NumberOfConcurrentTasks").toInt());
|
||||
@ -275,17 +254,6 @@ void LauncherPage::loadSettings()
|
||||
ui->timeoutSecondsSpinBox->setValue(s->get("RequestTimeout").toInt());
|
||||
|
||||
// Console settings
|
||||
QString fontFamily = APPLICATION->settings()->get("ConsoleFont").toString();
|
||||
QFont consoleFont(fontFamily);
|
||||
ui->consoleFont->setCurrentFont(consoleFont);
|
||||
|
||||
bool conversionOk = true;
|
||||
int fontSize = APPLICATION->settings()->get("ConsoleFontSize").toInt(&conversionOk);
|
||||
if (!conversionOk) {
|
||||
fontSize = 11;
|
||||
}
|
||||
ui->fontSizeBox->setValue(fontSize);
|
||||
refreshFontPreview();
|
||||
ui->lineLimitSpinBox->setValue(s->get("ConsoleMaxLines").toInt());
|
||||
ui->checkStopLogging->setChecked(s->get("ConsoleOverflowStop").toBool());
|
||||
|
||||
@ -307,59 +275,11 @@ void LauncherPage::loadSettings()
|
||||
ui->sortByNameBtn->setChecked(true);
|
||||
}
|
||||
|
||||
// Cat
|
||||
ui->catOpacitySpinBox->setValue(s->get("CatOpacity").toInt());
|
||||
|
||||
// Mods
|
||||
ui->metadataDisableBtn->setChecked(s->get("ModMetadataDisabled").toBool());
|
||||
ui->metadataWarningLabel->setHidden(!ui->metadataDisableBtn->isChecked());
|
||||
ui->dependenciesDisableBtn->setChecked(s->get("ModDependenciesDisabled").toBool());
|
||||
ui->skipModpackUpdatePromptBtn->setChecked(s->get("SkipModpackUpdatePrompt").toBool());
|
||||
}
|
||||
|
||||
void LauncherPage::refreshFontPreview()
|
||||
{
|
||||
const LogColors& colors = APPLICATION->themeManager()->getLogColors();
|
||||
|
||||
int fontSize = ui->fontSizeBox->value();
|
||||
QString fontFamily = ui->consoleFont->currentFont().family();
|
||||
ui->fontPreview->clear();
|
||||
defaultFormat->setFont(QFont(fontFamily, fontSize));
|
||||
|
||||
auto print = [this, colors](const QString& message, MessageLevel::Enum level) {
|
||||
QTextCharFormat format(*defaultFormat);
|
||||
|
||||
QColor bg = colors.background.value(level);
|
||||
QColor fg = colors.foreground.value(level);
|
||||
|
||||
if (bg.isValid())
|
||||
format.setBackground(bg);
|
||||
|
||||
if (fg.isValid())
|
||||
format.setForeground(fg);
|
||||
|
||||
// append a paragraph/line
|
||||
auto workCursor = ui->fontPreview->textCursor();
|
||||
workCursor.movePosition(QTextCursor::End);
|
||||
workCursor.insertText(message, format);
|
||||
workCursor.insertBlock();
|
||||
};
|
||||
|
||||
print(QString("%1 version: %2 (%3)\n")
|
||||
.arg(BuildConfig.LAUNCHER_DISPLAYNAME, BuildConfig.printableVersionString(), BuildConfig.BUILD_PLATFORM),
|
||||
MessageLevel::Launcher);
|
||||
|
||||
QDate today = QDate::currentDate();
|
||||
|
||||
if (today.month() == 10 && today.day() == 31)
|
||||
print(tr("[Test/ERROR] OOoooOOOoooo! A spooky error!"), MessageLevel::Error);
|
||||
else
|
||||
print(tr("[Test/ERROR] A spooky error!"), MessageLevel::Error);
|
||||
|
||||
print(tr("[Test/INFO] A harmless message..."), MessageLevel::Info);
|
||||
print(tr("[Test/WARN] A not so spooky warning."), MessageLevel::Warning);
|
||||
print(tr("[Test/DEBUG] A secret debugging message..."), MessageLevel::Debug);
|
||||
print(tr("[Test/FATAL] A terrifying fatal error!"), MessageLevel::Fatal);
|
||||
ui->metadataEnableBtn->setChecked(!s->get("ModMetadataDisabled").toBool());
|
||||
ui->metadataWarningLabel->setHidden(ui->metadataEnableBtn->isChecked());
|
||||
ui->dependenciesEnableBtn->setChecked(!s->get("ModDependenciesDisabled").toBool());
|
||||
ui->modpackUpdatePromptBtn->setChecked(!s->get("SkipModpackUpdatePrompt").toBool());
|
||||
}
|
||||
|
||||
void LauncherPage::retranslate()
|
||||
|
@ -57,8 +57,8 @@ class LauncherPage : public QWidget, public BasePage {
|
||||
explicit LauncherPage(QWidget* parent = 0);
|
||||
~LauncherPage();
|
||||
|
||||
QString displayName() const override { return tr("Launcher"); }
|
||||
QIcon icon() const override { return APPLICATION->getThemedIcon("launcher"); }
|
||||
QString displayName() const override { return tr("General"); }
|
||||
QIcon icon() const override { return APPLICATION->getThemedIcon("settings"); }
|
||||
QString id() const override { return "launcher-settings"; }
|
||||
QString helpPage() const override { return "Launcher-settings"; }
|
||||
bool apply() override;
|
||||
@ -75,23 +75,8 @@ class LauncherPage : public QWidget, public BasePage {
|
||||
void on_downloadsDirBrowseBtn_clicked();
|
||||
void on_javaDirBrowseBtn_clicked();
|
||||
void on_skinsDirBrowseBtn_clicked();
|
||||
void on_metadataDisableBtn_clicked();
|
||||
|
||||
/*!
|
||||
* Updates the font preview
|
||||
*/
|
||||
void refreshFontPreview();
|
||||
void on_metadataEnableBtn_clicked();
|
||||
|
||||
private:
|
||||
Ui::LauncherPage* ui;
|
||||
|
||||
/*!
|
||||
* Stores the currently selected update channel.
|
||||
*/
|
||||
QString m_currentUpdateChannel;
|
||||
|
||||
// default format for the font preview...
|
||||
QTextCharFormat* defaultFormat;
|
||||
|
||||
std::shared_ptr<TranslationsModel> m_languageModel;
|
||||
};
|
||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user