MCPcopy Create free account
hub / github.com/FreesmTeam/FreesmLauncher / InstanceWindow

Method InstanceWindow

launcher/ui/InstanceWindow.cpp:53–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 14

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