Clean up the main window constructor a bit
This commit is contained in:
parent
a63c7340a6
commit
e6999b3b62
@ -74,85 +74,93 @@ MainWindow::MainWindow ( QWidget *parent ) :
|
|||||||
instList ( globalSettings->get ( "InstanceDir" ).toString() )
|
instList ( globalSettings->get ( "InstanceDir" ).toString() )
|
||||||
{
|
{
|
||||||
ui->setupUi ( this );
|
ui->setupUi ( this );
|
||||||
|
setWindowTitle ( QString ( "MultiMC %1" ).arg ( AppVersion::current.toString() ) );
|
||||||
|
|
||||||
ui->instanceToolBar->setEnabled(false);
|
|
||||||
// Set the selected instance to null
|
// Set the selected instance to null
|
||||||
m_selectedInstance = nullptr;
|
m_selectedInstance = nullptr;
|
||||||
// Set active instance to null.
|
// Set active instance to null.
|
||||||
m_activeInst = nullptr;
|
m_activeInst = nullptr;
|
||||||
|
|
||||||
// the rename label is inside the rename tool button
|
// The instance action toolbar customizations
|
||||||
renameButton = new LabeledToolButton();
|
{
|
||||||
renameButton->setText("Instance Name");
|
ui->instanceToolBar->setEnabled(false);
|
||||||
connect(renameButton, SIGNAL(clicked(bool)), SLOT(on_actionRenameInstance_triggered()));
|
// the rename label is inside the rename tool button
|
||||||
ui->instanceToolBar->insertWidget(ui->actionLaunchInstance, renameButton);
|
renameButton = new LabeledToolButton();
|
||||||
ui->instanceToolBar->insertSeparator(ui->actionLaunchInstance);
|
renameButton->setText("Instance Name");
|
||||||
renameButton->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
|
connect(renameButton, SIGNAL(clicked(bool)), SLOT(on_actionRenameInstance_triggered()));
|
||||||
// Create the widget
|
ui->instanceToolBar->insertWidget(ui->actionLaunchInstance, renameButton);
|
||||||
view = new KCategorizedView ( ui->centralWidget );
|
ui->instanceToolBar->insertSeparator(ui->actionLaunchInstance);
|
||||||
drawer = new KCategoryDrawer ( view );
|
renameButton->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
|
||||||
|
}
|
||||||
|
|
||||||
view->setSelectionMode ( QAbstractItemView::SingleSelection );
|
// Create the instance list widget
|
||||||
//view->setSpacing( KDialog::spacingHint() );
|
{
|
||||||
view->setCategoryDrawer ( drawer );
|
view = new KCategorizedView ( ui->centralWidget );
|
||||||
view->setCollapsibleBlocks ( true );
|
drawer = new KCategoryDrawer ( view );
|
||||||
view->setViewMode ( QListView::IconMode );
|
|
||||||
view->setFlow ( QListView::LeftToRight );
|
|
||||||
view->setWordWrap(true);
|
|
||||||
view->setMouseTracking ( true );
|
|
||||||
view->viewport()->setAttribute ( Qt::WA_Hover );
|
|
||||||
auto delegate = new ListViewDelegate();
|
|
||||||
view->setItemDelegate(delegate);
|
|
||||||
view->setSpacing(10);
|
|
||||||
view->setUniformItemWidths(true);
|
|
||||||
view->installEventFilter(this);
|
|
||||||
|
|
||||||
proxymodel = new InstanceProxyModel ( this );
|
view->setSelectionMode ( QAbstractItemView::SingleSelection );
|
||||||
proxymodel->setSortRole ( KCategorizedSortFilterProxyModel::CategorySortRole );
|
view->setCategoryDrawer ( drawer );
|
||||||
proxymodel->setFilterRole ( KCategorizedSortFilterProxyModel::CategorySortRole );
|
view->setCollapsibleBlocks ( true );
|
||||||
//proxymodel->setDynamicSortFilter ( true );
|
view->setViewMode ( QListView::IconMode );
|
||||||
proxymodel->setSourceModel ( &instList );
|
view->setFlow ( QListView::LeftToRight );
|
||||||
proxymodel->sort ( 0 );
|
view->setWordWrap(true);
|
||||||
|
view->setMouseTracking ( true );
|
||||||
|
view->viewport()->setAttribute ( Qt::WA_Hover );
|
||||||
|
auto delegate = new ListViewDelegate();
|
||||||
|
view->setItemDelegate(delegate);
|
||||||
|
view->setSpacing(10);
|
||||||
|
view->setUniformItemWidths(true);
|
||||||
|
view->installEventFilter(this);
|
||||||
|
|
||||||
view->setFrameShape ( QFrame::NoFrame );
|
proxymodel = new InstanceProxyModel ( this );
|
||||||
|
proxymodel->setSortRole ( KCategorizedSortFilterProxyModel::CategorySortRole );
|
||||||
|
proxymodel->setFilterRole ( KCategorizedSortFilterProxyModel::CategorySortRole );
|
||||||
|
//proxymodel->setDynamicSortFilter ( true );
|
||||||
|
|
||||||
bool cat_enable = globalSettings->get("TheCat").toBool();
|
// FIXME: instList should be global-ish, or at least not tied to the main window... maybe the application itself?
|
||||||
ui->actionCAT->setChecked(cat_enable);
|
proxymodel->setSourceModel ( &instList );
|
||||||
connect(ui->actionCAT, SIGNAL(toggled(bool)), SLOT(onCatToggled(bool)));
|
proxymodel->sort ( 0 );
|
||||||
setCatBackground(cat_enable);
|
view->setFrameShape ( QFrame::NoFrame );
|
||||||
|
view->setModel ( proxymodel );
|
||||||
|
|
||||||
ui->horizontalLayout->addWidget ( view );
|
ui->horizontalLayout->addWidget ( view );
|
||||||
setWindowTitle ( QString ( "MultiMC %1" ).arg ( AppVersion::current.toString() ) );
|
}
|
||||||
// TODO: Make this work with the new settings system.
|
// The cat background
|
||||||
// restoreGeometry(settings->getConfig().value("MainWindowGeometry", saveGeometry()).toByteArray());
|
{
|
||||||
// restoreState(settings->getConfig().value("MainWindowState", saveState()).toByteArray());
|
bool cat_enable = globalSettings->get("TheCat").toBool();
|
||||||
view->setModel ( proxymodel );
|
ui->actionCAT->setChecked(cat_enable);
|
||||||
|
connect(ui->actionCAT, SIGNAL(toggled(bool)), SLOT(onCatToggled(bool)));
|
||||||
|
setCatBackground(cat_enable);
|
||||||
|
}
|
||||||
|
// start instance when double-clicked
|
||||||
connect(view, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(instanceActivated(const QModelIndex &)));
|
connect(view, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(instanceActivated(const QModelIndex &)));
|
||||||
auto selectionmodel = view->selectionModel();
|
// track the selection -- update the instance toolbar
|
||||||
connect(
|
connect(
|
||||||
selectionmodel,
|
view->selectionModel(),
|
||||||
SIGNAL(currentChanged(const QModelIndex &,const QModelIndex &)),
|
SIGNAL(currentChanged(const QModelIndex &,const QModelIndex &)),
|
||||||
this,
|
this,
|
||||||
SLOT(instanceChanged(const QModelIndex &,const QModelIndex &))
|
SLOT(instanceChanged(const QModelIndex &,const QModelIndex &))
|
||||||
);
|
);
|
||||||
|
// model reset -> selection is invalid. All the instance pointers are wrong.
|
||||||
|
// FIXME: stop using POINTERS everywhere
|
||||||
connect(&instList,SIGNAL(dataIsInvalid()),SLOT(selectionBad()));
|
connect(&instList,SIGNAL(dataIsInvalid()),SLOT(selectionBad()));
|
||||||
// Load the instances. FIXME: this is not the place I'd say.
|
|
||||||
instList.loadList();
|
|
||||||
|
|
||||||
//FIXME: WTF
|
// run the things that load and download other things... FIXME: this is NOT the place
|
||||||
if (!MinecraftVersionList::getMainList().isLoaded())
|
// FIXME: invisible actions in the background = NOPE.
|
||||||
{
|
{
|
||||||
m_versionLoadTask = MinecraftVersionList::getMainList().getLoadTask();
|
instList.loadList();
|
||||||
startTask(m_versionLoadTask);
|
if (!MinecraftVersionList::getMainList().isLoaded())
|
||||||
|
{
|
||||||
|
m_versionLoadTask = MinecraftVersionList::getMainList().getLoadTask();
|
||||||
|
startTask(m_versionLoadTask);
|
||||||
|
}
|
||||||
|
if (!LWJGLVersionList::get().isLoaded())
|
||||||
|
{
|
||||||
|
LWJGLVersionList::get().loadList();
|
||||||
|
}
|
||||||
|
assets_downloader = new OneSixAssets();
|
||||||
|
assets_downloader->start();
|
||||||
}
|
}
|
||||||
//FIXME: WTF X 2
|
|
||||||
if (!LWJGLVersionList::get().isLoaded())
|
|
||||||
{
|
|
||||||
LWJGLVersionList::get().loadList();
|
|
||||||
}
|
|
||||||
//FIXME: I guess you get the idea. This is a quick hack.
|
|
||||||
assets_downloader = new OneSixAssets();
|
|
||||||
assets_downloader->start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user