summaryrefslogtreecommitdiff
path: root/examples/triage/librariesinfo.cpp
blob: e50120df1d90e1fc9edfbbcaabf5ba4e5329f0d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "librariesinfo.h"
#include "theme.h"


LibrariesWidget::LibrariesWidget(QWidget* parent, BinaryViewRef bv)
{
	auto layout = new QVBoxLayout();
	layout->setContentsMargins(0, 0, 0, 0);

	auto libMetadata = bv->QueryMetadata("Libraries");
	auto libFoundMetadata = bv->QueryMetadata("LibraryFound");
	if (libMetadata && libFoundMetadata && libMetadata->IsStringList() && libFoundMetadata->IsStringList() && libMetadata->Size() == libFoundMetadata->Size())
	{
		const auto libNames = libMetadata->GetStringList();
		const auto typeLibPaths = libFoundMetadata->GetStringList();
		for (size_t i = 0; i < libNames.size(); ++i)
		{
			auto lib = libNames[i];
			auto typeLib = typeLibPaths[i];
			auto libWidget = new QLabel(QString::fromStdString("  " + lib));
			QString toolTip;
			auto style = QPalette(palette());
			if (typeLib.empty())
			{
				toolTip = "Type library: not found";
				style.setColor(QPalette::WindowText, getThemeColor(NotPresentColor));
			}
			else
			{
				toolTip = QString::fromStdString("Type library: " + typeLib);
			}
			libWidget->setToolTip(toolTip);
			libWidget->setPalette(style);
			layout->addWidget(libWidget);
		}
	}
	else if (libMetadata && libMetadata->IsStringList())
	{
		for (const auto& lib : libMetadata->GetStringList())
			layout->addWidget(new QLabel(QString::fromStdString(lib)));
	}
	else
	{
		auto style = QPalette(palette());
		style.setColor(QPalette::WindowText, getThemeColor(NotPresentColor));
		auto noLibWidget = new QLabel("No libraries found");
		noLibWidget->setPalette(style);
		layout->addWidget(noLibWidget);
	}
	setLayout(layout);
}