Skip to content

Commit

Permalink
Merge pull request PrismLauncher#2383 from Trial97/scroll_new_instance
Browse files Browse the repository at this point in the history
Made Custom New Instance scrollable
  • Loading branch information
ZekeZDev authored Jun 7, 2024
2 parents 6e5c41f + 83883ca commit 39b8451
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 26 deletions.
14 changes: 13 additions & 1 deletion launcher/ui/dialogs/NewInstanceDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
#include <QFileDialog>
#include <QLayout>
#include <QPushButton>
#include <QScreen>
#include <QValidator>
#include <utility>

Expand All @@ -63,6 +64,7 @@
#include "ui/pages/modplatform/modrinth/ModrinthPage.h"
#include "ui/pages/modplatform/technic/TechnicPage.h"
#include "ui/widgets/PageContainer.h"

NewInstanceDialog::NewInstanceDialog(const QString& initialGroup,
const QString& url,
const QMap<QString, QString>& extra_info,
Expand Down Expand Up @@ -127,7 +129,17 @@ NewInstanceDialog::NewInstanceDialog(const QString& initialGroup,

updateDialogState();

restoreGeometry(QByteArray::fromBase64(APPLICATION->settings()->get("NewInstanceGeometry").toByteArray()));
if (APPLICATION->settings()->get("NewInstanceGeometry").isValid()) {
restoreGeometry(QByteArray::fromBase64(APPLICATION->settings()->get("NewInstanceGeometry").toByteArray()));
} else {
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
auto screen = parent->screen();
#else
auto screen = QGuiApplication::primaryScreen();
#endif
auto geometry = screen->availableSize();
resize(width(), qMin(geometry.height() - 50, 710));
}
}

void NewInstanceDialog::reject()
Expand Down
1 change: 0 additions & 1 deletion launcher/ui/pages/modplatform/CustomPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
CustomPage::CustomPage(NewInstanceDialog* dialog, QWidget* parent) : QWidget(parent), dialog(dialog), ui(new Ui::CustomPage)
{
ui->setupUi(this);
ui->tabWidget->tabBar()->hide();
connect(ui->versionList, &VersionSelectWidget::selectedVersionChanged, this, &CustomPage::setSelectedVersion);
filterChanged();
connect(ui->alphaFilter, &QCheckBox::stateChanged, this, &CustomPage::filterChanged);
Expand Down
52 changes: 28 additions & 24 deletions launcher/ui/pages/modplatform/CustomPage.ui
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,21 @@
<number>0</number>
</property>
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string notr="true"/>
</attribute>
<layout class="QGridLayout" name="gridLayout_2">
<item row="2" column="0">
<widget class="Line" name="line">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QWidget" name="content">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>813</width>
<height>605</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="minecraftLayout">
<item>
<widget class="VersionSelectWidget" name="versionList" native="true">
Expand Down Expand Up @@ -147,7 +139,20 @@
</item>
</layout>
</item>
<item row="4" column="0">
<item>
<widget class="Line" name="line">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="loaderLayout">
<item>
<widget class="VersionSelectWidget" name="loaderVersionList" native="true">
Expand Down Expand Up @@ -273,7 +278,6 @@
</customwidget>
</customwidgets>
<tabstops>
<tabstop>tabWidget</tabstop>
<tabstop>releaseFilter</tabstop>
<tabstop>snapshotFilter</tabstop>
<tabstop>betaFilter</tabstop>
Expand Down

0 comments on commit 39b8451

Please sign in to comment.