MCPcopy Create free account
hub / github.com/aethersdr/AetherSDR / refreshContainerCombo

Method refreshContainerCombo

src/gui/ThemeEditorDialog.cpp:897–927  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

895}
896
897void ThemeEditorDialog::refreshContainerCombo()
898{
899 if (!m_containerCombo) return;
900 QSignalBlocker block(m_containerCombo);
901 m_containerCombo->clear();
902 // Friendlier label for the empty (root) path so the dropdown is
903 // self-explanatory; userData carries the real path string.
904 m_containerCombo->addItem(QStringLiteral("(root)"), QString());
905 for (const QString& path : ThemeManager::instance().containerPaths()) {
906 if (path.isEmpty()) continue; // already added as "(root)"
907 m_containerCombo->addItem(path, path);
908 }
909 // Clamp the combo to the longest label + 4 px pad on each side
910 // (plus arrow + frame allowance). Sized once per refresh; combo
911 // stays exactly that wide regardless of which item is selected.
912 QFontMetrics fm(m_containerCombo->font());
913 int maxLabelW = 0;
914 for (int i = 0; i < m_containerCombo->count(); ++i) {
915 maxLabelW = std::max(maxLabelW,
916 fm.horizontalAdvance(m_containerCombo->itemText(i)));
917 }
918 // 4 px L + 4 px R text padding (overrides Theme.h's 6/6 default),
919 // ~20 px dropdown arrow, ~2 px frame borders.
920 m_containerCombo->setStyleSheet(QStringLiteral(
921 "QComboBox { padding: 2px 4px; }"));
922 m_containerCombo->setFixedWidth(maxLabelW + 4 + 4 + 20 + 2);
923 // Restore previous selection by path string, falling back to root.
924 int idx = m_containerCombo->findData(m_activeContainerPath);
925 if (idx < 0) idx = 0;
926 m_containerCombo->setCurrentIndex(idx);
927}
928
929void ThemeEditorDialog::onContainerChanged(int)
930{

Callers

nothing calls this directly

Calls 5

containerPathsMethod · 0.80
fontMethod · 0.80
countMethod · 0.80
clearMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected