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

Method InstanceWindow

launcher/ui/InstanceWindow.cpp:34–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32#include "icons/IconList.h"
33
34InstanceWindow::InstanceWindow(InstancePtr instance, QWidget *parent)
35 : QMainWindow(parent), m_instance(instance)
36{
37 setAttribute(Qt::WA_DeleteOnClose);
38
39 auto icon = APPLICATION->icons()->getIcon(m_instance->iconKey());
40 QString windowTitle = tr("Console window for ") + m_instance->name();
41
42 // Set window properties
43 {
44 setWindowIcon(icon);
45 setWindowTitle(windowTitle);
46 }
47
48 // Add page container
49 {
50 auto provider = std::make_shared<InstancePageProvider>(m_instance);
51 m_container = new PageContainer(provider.get(), "console", this);
52 m_container->setParentContainer(this);
53 setCentralWidget(m_container);
54 setContentsMargins(0, 0, 0, 0);
55 }
56
57 // Add custom buttons to the page container layout.
58 {
59 auto horizontalLayout = new QHBoxLayout();
60 horizontalLayout->setObjectName(QStringLiteral("horizontalLayout"));
61 horizontalLayout->setContentsMargins(6, -1, 6, -1);
62
63 auto btnHelp = new QPushButton();
64 btnHelp->setText(tr("Help"));
65 horizontalLayout->addWidget(btnHelp);
66 connect(btnHelp, SIGNAL(clicked(bool)), m_container, SLOT(help()));
67
68 auto spacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
69 horizontalLayout->addSpacerItem(spacer);
70
71 m_killButton = new QPushButton();
72 horizontalLayout->addWidget(m_killButton);
73 connect(m_killButton, SIGNAL(clicked(bool)), SLOT(on_btnKillMinecraft_clicked()));
74
75 m_launchOfflineButton = new QPushButton();
76 horizontalLayout->addWidget(m_launchOfflineButton);
77 m_launchOfflineButton->setText(tr("Launch Offline"));
78 updateLaunchButtons();
79 connect(m_launchOfflineButton, SIGNAL(clicked(bool)), SLOT(on_btnLaunchMinecraftOffline_clicked()));
80
81 m_closeButton = new QPushButton();
82 m_closeButton->setText(tr("Close"));
83 horizontalLayout->addWidget(m_closeButton);
84 connect(m_closeButton, SIGNAL(clicked(bool)), SLOT(on_closeButton_clicked()));
85
86 m_container->addButtons(horizontalLayout);
87 }
88
89 // restore window state
90 {
91 auto base64State = APPLICATION->settings()->get("ConsoleWindowState").toByteArray();

Callers

nothing calls this directly

Calls 10

getIconMethod · 0.80
iconsMethod · 0.80
addButtonsMethod · 0.80
getLaunchTaskMethod · 0.80
iconKeyMethod · 0.45
nameMethod · 0.45
getMethod · 0.45
setParentContainerMethod · 0.45
setTextMethod · 0.45
settingsMethod · 0.45

Tested by

no test coverage detected