MCPcopy Create free account
hub / github.com/MultiMC/Launcher / MainWindow

Method MainWindow

launcher/ui/MainWindow.cpp:683–864  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

681};
682
683MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new MainWindow::Ui)
684{
685 ui->setupUi(this);
686
687 // OSX magic.
688 setUnifiedTitleAndToolBarOnMac(true);
689
690 // Global shortcuts
691 {
692 // FIXME: This is kinda weird. and bad. We need some kind of managed shutdown.
693 auto q = new QShortcut(QKeySequence::Quit, this);
694 connect(q, SIGNAL(activated()), qApp, SLOT(quit()));
695 }
696
697 // Konami Code
698 {
699 secretEventFilter = new KonamiCode(this);
700 connect(secretEventFilter, &KonamiCode::triggered, this, &MainWindow::konamiTriggered);
701 }
702
703 // Add the news label to the news toolbar.
704 {
705 m_newsChecker.reset(new NewsChecker(APPLICATION->network(), BuildConfig.NEWS_RSS_URL));
706 newsLabel = new QToolButton();
707 newsLabel->setIcon(APPLICATION->getThemedIcon("news"));
708 newsLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
709 newsLabel->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
710 newsLabel->setFocusPolicy(Qt::NoFocus);
711 ui->newsToolBar->insertWidget(ui->actionMoreNews, newsLabel);
712 QObject::connect(newsLabel, &QAbstractButton::clicked, this, &MainWindow::newsButtonClicked);
713 QObject::connect(m_newsChecker.get(), &NewsChecker::newsLoaded, this, &MainWindow::updateNewsLabel);
714 updateNewsLabel();
715 }
716
717 // Create the instance list widget
718 {
719 view = new InstanceView(ui->centralWidget);
720
721 view->setSelectionMode(QAbstractItemView::SingleSelection);
722 // FIXME: leaks ListViewDelegate
723 view->setItemDelegate(new ListViewDelegate(this));
724 view->setFrameShape(QFrame::NoFrame);
725 // do not show ugly blue border on the mac
726 view->setAttribute(Qt::WA_MacShowFocusRect, false);
727
728 view->installEventFilter(this);
729 view->setContextMenuPolicy(Qt::CustomContextMenu);
730 connect(view, &QWidget::customContextMenuRequested, this, &MainWindow::showInstanceContextMenu);
731 connect(view, &InstanceView::droppedURLs, this, &MainWindow::droppedURLs, Qt::QueuedConnection);
732
733 proxymodel = new InstanceProxyModel(this);
734 proxymodel->setSourceModel(APPLICATION->instances().get());
735 proxymodel->sort(0);
736 connect(proxymodel, &InstanceProxyModel::dataChanged, this, &MainWindow::instanceDataChanged);
737
738 view->setModel(proxymodel);
739 view->setSourceOfGroupCollapseStatus([](const QString & groupName)->bool {
740 return APPLICATION->instances()->isGroupCollapsed(groupName);

Callers

nothing calls this directly

Calls 15

QUrlClass · 0.85
networkMethod · 0.80
getThemedIconMethod · 0.80
setSourceModelMethod · 0.80
instancesMethod · 0.80
isGroupCollapsedMethod · 0.80
iconsMethod · 0.80
addActionMethod · 0.80
accountsMethod · 0.80
reloadNewsMethod · 0.80
updatesAreAllowedMethod · 0.80

Tested by

no test coverage detected