Fix search focusing
Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
parent
7138425c85
commit
4332b62a62
@ -30,9 +30,9 @@
|
||||
#include "ui/widgets/PageContainer.h"
|
||||
#include "ui/widgets/VersionSelectWidget.h"
|
||||
|
||||
class LoaderPage : public VersionSelectWidget, public BasePage {
|
||||
class InstallLoaderPage : public VersionSelectWidget, public BasePage {
|
||||
public:
|
||||
LoaderPage(const QString& id,
|
||||
InstallLoaderPage(const QString& id,
|
||||
const QString& icon,
|
||||
const QString& name,
|
||||
// "lightweight" loaders are independent to any game version
|
||||
@ -86,9 +86,7 @@ InstallLoaderDialog::InstallLoaderDialog(std::shared_ptr<PackProfile> profile, Q
|
||||
|
||||
auto refreshButton = new QPushButton(tr("&Refresh"), this);
|
||||
connect(refreshButton, &QPushButton::pressed, this, [this] {
|
||||
LoaderPage* page = dynamic_cast<LoaderPage*>(m_container->selectedPage());
|
||||
Q_ASSERT(page != nullptr);
|
||||
page->loadList();
|
||||
dynamic_cast<InstallLoaderPage*>(m_container->selectedPage())->loadList();
|
||||
});
|
||||
buttonLayout->addWidget(refreshButton);
|
||||
|
||||
@ -106,18 +104,20 @@ InstallLoaderDialog::InstallLoaderDialog(std::shared_ptr<PackProfile> profile, Q
|
||||
connect(m_container, &PageContainer::selectedPageChanged, this,
|
||||
[this](BasePage* previous, BasePage* selected) { updateAcceptButton(selected); });
|
||||
updateAcceptButton(m_container->selectedPage());
|
||||
|
||||
dynamic_cast<InstallLoaderPage*>(m_container->selectedPage())->selectSearch();
|
||||
}
|
||||
|
||||
QList<BasePage*> InstallLoaderDialog::getPages()
|
||||
{
|
||||
return { // Forge
|
||||
new LoaderPage("net.minecraftforge", "forge", tr("Forge"), false, m_profile, this),
|
||||
new InstallLoaderPage("net.minecraftforge", "forge", tr("Forge"), false, m_profile, this),
|
||||
// Fabric
|
||||
new LoaderPage("net.fabricmc.fabric-loader", "fabricmc-small", tr("Fabric"), true, m_profile, this),
|
||||
new InstallLoaderPage("net.fabricmc.fabric-loader", "fabricmc-small", tr("Fabric"), true, m_profile, this),
|
||||
// Quilt
|
||||
new LoaderPage("org.quiltmc.quilt-loader", "quiltmc", tr("Quilt"), true, m_profile, this),
|
||||
new InstallLoaderPage("org.quiltmc.quilt-loader", "quiltmc", tr("Quilt"), true, m_profile, this),
|
||||
// LiteLoader
|
||||
new LoaderPage("com.mumfrey.liteloader", "liteloader", tr("LiteLoader"), false, m_profile, this)
|
||||
new InstallLoaderPage("com.mumfrey.liteloader", "liteloader", tr("LiteLoader"), false, m_profile, this)
|
||||
};
|
||||
}
|
||||
|
||||
@ -135,9 +135,7 @@ void InstallLoaderDialog::updateAcceptButton(const BasePage* page)
|
||||
void InstallLoaderDialog::done(int result)
|
||||
{
|
||||
if (result == Accepted) {
|
||||
LoaderPage* page = dynamic_cast<LoaderPage*>(m_container->selectedPage());
|
||||
Q_ASSERT(page != nullptr);
|
||||
|
||||
auto* page = dynamic_cast<InstallLoaderPage*>(m_container->selectedPage());
|
||||
if (page->selectedVersion()) {
|
||||
m_profile->setComponentVersion(page->id(), page->selectedVersion()->descriptor());
|
||||
m_profile->resolve(Net::Mode::Online);
|
||||
|
@ -55,7 +55,7 @@ VersionSelectDialog::VersionSelectDialog(BaseVersionList *vlist, QString title,
|
||||
m_verticalLayout = new QVBoxLayout(this);
|
||||
m_verticalLayout->setObjectName(QStringLiteral("verticalLayout"));
|
||||
|
||||
m_versionWidget = new VersionSelectWidget(true, parent);
|
||||
m_versionWidget = new VersionSelectWidget(parent);
|
||||
m_verticalLayout->addWidget(m_versionWidget);
|
||||
|
||||
m_horizontalLayout = new QHBoxLayout();
|
||||
@ -123,6 +123,7 @@ int VersionSelectDialog::exec()
|
||||
{
|
||||
QDialog::open();
|
||||
m_versionWidget->initialize(m_vlist);
|
||||
m_versionWidget->selectSearch();
|
||||
if(resizeOnColumn != -1)
|
||||
{
|
||||
m_versionWidget->setResizeOn(resizeOnColumn);
|
||||
|
@ -46,7 +46,7 @@ void JavaSettingsWidget::setupUi()
|
||||
m_verticalLayout = new QVBoxLayout(this);
|
||||
m_verticalLayout->setObjectName(QStringLiteral("verticalLayout"));
|
||||
|
||||
m_versionWidget = new VersionSelectWidget(true, this);
|
||||
m_versionWidget = new VersionSelectWidget(this);
|
||||
m_verticalLayout->addWidget(m_versionWidget);
|
||||
|
||||
m_horizontalLayout = new QHBoxLayout();
|
||||
@ -126,6 +126,7 @@ void JavaSettingsWidget::setupUi()
|
||||
void JavaSettingsWidget::initialize()
|
||||
{
|
||||
m_versionWidget->initialize(APPLICATION->javalist().get());
|
||||
m_versionWidget->selectSearch();
|
||||
m_versionWidget->setResizeOn(2);
|
||||
auto s = APPLICATION->settings();
|
||||
// Memory
|
||||
|
@ -11,10 +11,8 @@
|
||||
|
||||
#include "ui/dialogs/CustomMessageBox.h"
|
||||
|
||||
VersionSelectWidget::VersionSelectWidget(QWidget* parent) : VersionSelectWidget(false, parent) {}
|
||||
|
||||
VersionSelectWidget::VersionSelectWidget(bool focusSearch, QWidget* parent)
|
||||
: QWidget(parent), focusSearch(focusSearch)
|
||||
VersionSelectWidget::VersionSelectWidget(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
setObjectName(QStringLiteral("VersionSelectWidget"));
|
||||
verticalLayout = new QVBoxLayout(this);
|
||||
@ -116,9 +114,6 @@ void VersionSelectWidget::initialize(BaseVersionList *vlist)
|
||||
listView->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||
listView->header()->setSectionResizeMode(resizeOnColumn, QHeaderView::Stretch);
|
||||
|
||||
if (focusSearch)
|
||||
search->setFocus();
|
||||
|
||||
if (!m_vlist->isLoaded())
|
||||
{
|
||||
loadList();
|
||||
@ -210,6 +205,11 @@ void VersionSelectWidget::selectCurrent()
|
||||
}
|
||||
}
|
||||
|
||||
void VersionSelectWidget::selectSearch()
|
||||
{
|
||||
search->setFocus();
|
||||
}
|
||||
|
||||
void VersionSelectWidget::selectRecommended()
|
||||
{
|
||||
auto idx = m_proxyModel->getRecommended();
|
||||
|
@ -52,7 +52,6 @@ class VersionSelectWidget: public QWidget
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit VersionSelectWidget(QWidget *parent);
|
||||
explicit VersionSelectWidget(bool focusSearch = false, QWidget *parent = 0);
|
||||
~VersionSelectWidget();
|
||||
|
||||
//! loads the list if needed.
|
||||
@ -65,6 +64,7 @@ public:
|
||||
BaseVersion::Ptr selectedVersion() const;
|
||||
void selectRecommended();
|
||||
void selectCurrent();
|
||||
void selectSearch();
|
||||
|
||||
void setCurrentVersion(const QString & version);
|
||||
void setFuzzyFilter(BaseVersionList::ModelRoles role, QString filter);
|
||||
@ -74,6 +74,7 @@ public:
|
||||
void setEmptyErrorString(QString emptyErrorString);
|
||||
void setEmptyMode(VersionListView::EmptyMode mode);
|
||||
void setResizeOn(int column);
|
||||
|
||||
bool eventFilter(QObject* watched, QEvent* event) override;
|
||||
|
||||
signals:
|
||||
@ -98,7 +99,6 @@ private:
|
||||
int resizeOnColumn = 0;
|
||||
Task * loadTask;
|
||||
bool preselectedAlready = false;
|
||||
bool focusSearch;
|
||||
|
||||
QVBoxLayout *verticalLayout = nullptr;
|
||||
VersionListView *listView = nullptr;
|
||||
|
Loading…
x
Reference in New Issue
Block a user