wiRedPanda
Logic Circuit Simulator
Loading...
Searching...
No Matches
ElementPalette.h
Go to the documentation of this file.
1// Copyright 2015 - 2026, GIBIS-UNIFESP and the wiRedPanda contributors
2// SPDX-License-Identifier: GPL-3.0-or-later
3
7
8#pragma once
9
10#include <QFileInfo>
11#include <QObject>
12#include <QStringList>
13
14class ElementLabel;
15class MainWindowUi;
16class QLayout;
17class QMimeData;
18class QSpacerItem;
19class Scene;
20
33class ElementPalette : public QObject
34{
35 Q_OBJECT
36
37public:
38 // --- Lifecycle ---
39
47 explicit ElementPalette(MainWindowUi *ui, QObject *parent = nullptr);
48
49 // --- Palette Management ---
50
55 void populate();
56
62 void updateICList(const QFileInfo &currentFile);
63
65 void updateEmbeddedICList(Scene *scene);
66
68 void retranslateLabels();
69
71 void updateTheme();
72
78 static bool nameMatchesSearch(const QString &name, const QString &query);
79
80signals:
86 void addElementRequested(QMimeData *mimeData);
87
88private slots:
90 void onSearchTextChanged(const QString &text);
92 void onSearchReturnPressed();
93
94private:
95 // --- Helpers ---
96
98 void populateMenu(QSpacerItem *spacer, const QStringList &names, QLayout *layout);
101 void connectDoubleClickAdd(ElementLabel *label);
103 void setupTabIcons();
105 int tabIndex(const QString &objectName) const;
106
107 // --- Members ---
108
109 MainWindowUi *m_ui;
110 int m_lastTabIndex = -1;
111};
Icon and name widget shown in the left-panel element palette.
ElementPalette(MainWindowUi *ui, QObject *parent=nullptr)
Constructs the palette controller.
void updateICList(const QFileInfo &currentFile)
Refreshes the IC tab to reflect .panda files next to currentFile.
void updateTheme()
Updates the memory tab icon and all memory-tab ElementLabel themes.
void populate()
Populates all category tabs with ElementLabel widgets and sets tab icons.
void retranslateLabels()
Calls updateName() on every ElementLabel in the palette (on language change).
static bool nameMatchesSearch(const QString &name, const QString &query)
void updateEmbeddedICList(Scene *scene)
Refreshes the embedded-IC section of the palette from the scene's blob registry.
void addElementRequested(QMimeData *mimeData)
Emitted when the user presses Enter in the search box.
Main circuit editing scene.
Definition Scene.h:56