all repos — mgba @ 3d4faa41e281ff042451032190b3191af2737d5a

mGBA Game Boy Advance Emulator

src/platform/qt/AssetInfo.cpp (view raw)

 1/* Copyright (c) 2013-2019 Jeffrey Pfau
 2 *
 3 * This Source Code Form is subject to the terms of the Mozilla Public
 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 6#include "AssetInfo.h"
 7
 8#include "GBAApp.h"
 9
10#include <QHBoxLayout>
11
12using namespace QGBA;
13
14AssetInfo::AssetInfo(QWidget* parent)
15	: QGroupBox(parent)
16{
17}
18
19void AssetInfo::addCustomProperty(const QString& id, const QString& visibleName) {
20	QHBoxLayout* newLayout = new QHBoxLayout;
21	newLayout->addWidget(new QLabel(visibleName));
22	QLabel* value = new QLabel;
23	value->setFont(GBAApp::monospaceFont());
24	value->setAlignment(Qt::AlignRight);
25	newLayout->addWidget(value);
26	m_customProperties[id] = value;
27	int index = customLocation();
28	static_cast<QBoxLayout*>(layout())->insertLayout(index, newLayout);
29}
30
31void AssetInfo::setCustomProperty(const QString& id, const QVariant& value) {
32	QLabel* label = m_customProperties[id];
33	if (!label) {
34		return;
35	}
36	label->setText(value.toString());
37}
38
39int AssetInfo::customLocation(const QString&) {
40	return layout()->count();
41}