Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qwasmbase64iconstore.cpp
Go to the documentation of this file.
1// Copyright (C) 2018 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
5
6#include <QtCore/qfile.h>
7
9
10Q_GLOBAL_STATIC(Base64IconStore, globalWasmWindowIconStore);
11
12Base64IconStore::Base64IconStore()
13{
14 QString iconSources[static_cast<size_t>(IconType::Size)] = {
15 QStringLiteral(":/wasm-window/maximize.svg"), QStringLiteral(":/wasm-window/qtlogo.svg"),
16 QStringLiteral(":/wasm-window/restore.svg"), QStringLiteral(":/wasm-window/x.svg")
17 };
18
19 for (size_t iconType = static_cast<size_t>(IconType::First);
20 iconType < static_cast<size_t>(IconType::Size); ++iconType) {
21 QFile svgFile(iconSources[static_cast<size_t>(iconType)]);
22 if (!svgFile.open(QIODevice::ReadOnly))
23 Q_ASSERT(false); // A resource should always be opened.
24 m_storage[static_cast<size_t>(iconType)] = svgFile.readAll().toBase64();
25 }
26}
27
28Base64IconStore::~Base64IconStore() = default;
29
30Base64IconStore *Base64IconStore::get()
31{
32 return globalWasmWindowIconStore();
33}
34
35std::string_view Base64IconStore::getIcon(IconType type) const
36{
37 return m_storage[static_cast<size_t>(type)];
38}
39
40QT_END_NAMESPACE