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

Method InstanceWindow

launcher/ui/InstanceWindow.cpp:52–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50#include "icons/IconList.h"
51
52InstanceWindow::InstanceWindow(BaseInstance* instance, QWidget* parent) : QMainWindow(parent), m_instance(instance)
53{
54 setAttribute(Qt::WA_DeleteOnClose);
55
56 auto icon = APPLICATION->icons()->getIcon(m_instance->iconKey());
57 QString windowTitle = tr("Console window for ") + m_instance->name();
58
59 // Set window properties
60 {
61 setWindowIcon(icon);
62 setWindowTitle(windowTitle);
63 }
64
65 // Add page container
66 {
67 auto provider = std::make_shared<InstancePageProvider>(m_instance);
68 m_container = new PageContainer(provider.get(), "console", this);
69 m_container->setParentContainer(this);
70 setCentralWidget(m_container);
71 setContentsMargins(0, 0, 0, 0);
72 }
73
74 // Add custom buttons to the page container layout.
75 {
76 auto horizontalLayout = new QHBoxLayout(this);
77 horizontalLayout->setObjectName(QStringLiteral("horizontalLayout"));
78 horizontalLayout->setContentsMargins(0, 0, 6, 6);
79
80 auto btnHelp = new QPushButton(this);
81 btnHelp->setText(tr("Help"));
82 horizontalLayout->addWidget(btnHelp);
83 connect(btnHelp, &QPushButton::clicked, m_container, &PageContainer::help);
84
85 auto spacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
86 horizontalLayout->addSpacerItem(spacer);
87
88 m_launchButton = new QToolButton(this);
89 m_launchButton->setText(tr("&Launch"));
90 m_launchButton->setToolTip(tr("Launch the instance"));
91 m_launchButton->setPopupMode(QToolButton::MenuButtonPopup);
92 m_launchButton->setMinimumWidth(80); // HACK!!
93 horizontalLayout->addWidget(m_launchButton);
94 connect(m_launchButton, &QPushButton::clicked, this, [this] { APPLICATION->launch(m_instance); });
95
96 m_killButton = new QPushButton(this);
97 m_killButton->setText(tr("&Kill"));
98 m_killButton->setToolTip(tr("Kill the running instance"));
99 m_killButton->setShortcut(QKeySequence(tr("Ctrl+K")));
100 horizontalLayout->addWidget(m_killButton);
101 connect(m_killButton, &QPushButton::clicked, this, [this] { APPLICATION->kill(m_instance); });
102
103 updateButtons();
104
105 m_closeButton = new QPushButton(this);
106 m_closeButton->setText(tr("Close"));
107 horizontalLayout->addWidget(m_closeButton);
108 connect(m_closeButton, &QPushButton::clicked, this, &QMainWindow::close);
109

Callers

nothing calls this directly

Calls 15

iconsMethod · 0.80
addButtonsMethod · 0.80
getLaunchTaskMethod · 0.80
setInstanceWindowMethod · 0.80
launchMethod · 0.65
getIconMethod · 0.45
iconKeyMethod · 0.45
nameMethod · 0.45
getMethod · 0.45
setParentContainerMethod · 0.45
setTextMethod · 0.45
killMethod · 0.45

Tested by

no test coverage detected