all repos — mgba @ c4123a238685d644b20e11aee4fec72427e0c9f4

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 <QFontDatabase>
 9#include <QHBoxLayout>
10
11using namespace QGBA;
12
13AssetInfo::AssetInfo(QWidget* parent)
14	: QGroupBox(parent)
15{
16}
17
18void AssetInfo::addCustomProperty(const QString& id, const QString& visibleName) {
19	QHBoxLayout* newLayout = new QHBoxLayout;
20	newLayout->addWidget(new QLabel(visibleName));
21	QLabel* value = new QLabel;
22	value->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
23	value->setAlignment(Qt::AlignRight);
24	newLayout->addWidget(value);
25	m_customProperties[id] = value;
26	int index = customLocation();
27	static_cast<QBoxLayout*>(layout())->insertLayout(index, newLayout);
28}
29
30void AssetInfo::setCustomProperty(const QString& id, const QVariant& value) {
31	QLabel* label = m_customProperties[id];
32	if (!label) {
33		return;
34	}
35	label->setText(value.toString());
36}
37
38int AssetInfo::customLocation(const QString&) {
39	return layout()->count();
40}