MCPcopy Create free account
hub / github.com/RGAA-Software/GoDesk / AppMenu

Method AppMenu

src/client/ui/app_menu.cpp:118–176  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
117
118 AppMenu::AppMenu(const std::vector<AppItemDesc>& items, QWidget* parent) : QWidget(parent) {
119 setFixedWidth(230);
120
121 auto root_layout = new QHBoxLayout();
122 root_layout->setSpacing(0);
123 root_layout->setContentsMargins(0,0,0,0);
124 root_layout->addStretch();
125
126 auto item_layout = new QVBoxLayout();
127 item_layout->setAlignment(Qt::AlignHCenter);
128 item_layout->setSpacing(0);
129 item_layout->setContentsMargins(0,0,0,0);
130 item_layout->addSpacing(35);
131
132 auto logo_layout = new QHBoxLayout();
133 auto logo = new QLabel(this);
134 auto image = new QImage(":resources/image/tc_icon.png");
135 auto pixmap = QPixmap::fromImage(*image);
136 pixmap = pixmap.scaled(pixmap.width()/2.5, pixmap.height()/2.5, Qt::KeepAspectRatio, Qt::SmoothTransformation);
137 logo->setPixmap(pixmap);
138
139 logo_layout->addStretch();
140 logo_layout->addWidget(logo);
141 logo_layout->addStretch();
142
143 item_layout->addLayout(logo_layout);
144 item_layout->addSpacing(35);
145
146 int idx = 0;
147 for (const auto& item : items) {
148
149 auto app_item = new AppMenuItem(item.name_, idx++, item.url_, this);
150 if (idx == 1) {
151 app_item->Select();
152 }
153
154 app_items.push_back(app_item);
155 app_item->setFixedSize(180, 40);
156 app_item->SetOnItemClickedCallback([=, this](const QString& name, int idx) {
157 if (callback_) {
158 callback_(name, idx);
159 }
160
161 for (const auto& it : app_items) {
162 if (it->GetName() != name) {
163 it->UnSelect();
164 }
165 }
166 });
167 item_layout->addWidget(app_item);
168 item_layout->addSpacing(10);
169 }
170 item_layout->addStretch();
171
172 root_layout->addLayout(item_layout);
173 root_layout->addStretch();
174
175 setLayout(root_layout);

Callers

nothing calls this directly

Calls 4

GetNameMethod · 0.80
UnSelectMethod · 0.80
SelectMethod · 0.45

Tested by

no test coverage detected