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// Qt-Security score:significant reason:default
4
6
7#include <QtCore/qfile.h>
8
10
11Q_GLOBAL_STATIC(Base64IconStore, globalWasmWindowIconStore);
12
13Base64IconStore::Base64IconStore()
14{
15 QString iconSources[static_cast<size_t>(IconType::Size)] = {
16 QStringLiteral(":/wasm-window/maximize.svg"), QStringLiteral(":/wasm-window/qtlogo.svg"),
17 QStringLiteral(":/wasm-window/restore.svg"), QStringLiteral(":/wasm-window/x.svg")
18 };
19
20 for (size_t iconType = static_cast<size_t>(IconType::First);
21 iconType < static_cast<size_t>(IconType::Size); ++iconType) {
22 QFile svgFile(iconSources[static_cast<size_t>(iconType)]);
23 if (!svgFile.open(QIODevice::ReadOnly))
24 Q_ASSERT(false); // A resource should always be opened.
25 m_storage[static_cast<size_t>(iconType)] = svgFile.readAll().toBase64();
26 }
27}
28
29Base64IconStore::~Base64IconStore() = default;
30
31Base64IconStore *Base64IconStore::get()
32{
33 return globalWasmWindowIconStore();
34}
35
36std::string_view Base64IconStore::getIcon(IconType type) const
37{
38 return m_storage[static_cast<size_t>(type)];
39}
40
41QT_END_NAMESPACE
Combined button and popup list for selecting options.