Add ProfileSelectionWidget

Refreshes list of profiles when widget becomes visible to support widget
caching.
This commit is contained in:
WarmUpTill
2025-05-22 21:38:07 +02:00
committed by WarmUpTill
parent 1c94a1ab44
commit 5e3ab19940
6 changed files with 50 additions and 45 deletions

View File

@@ -30,4 +30,23 @@ std::string GetPathInProfileDir(const char *filePath)
return result + "/" + filePath;
}
ProfileSelectionWidget::ProfileSelectionWidget(QWidget *parent)
: FilterComboBox(parent)
{
setEditable(true);
SetAllowUnmatchedSelection(true);
setMaxVisibleItems(20);
PopulateProfileSelection(this);
}
void ProfileSelectionWidget::showEvent(QShowEvent *event)
{
FilterComboBox::showEvent(event);
const QSignalBlocker b(this);
const auto text = currentText();
clear();
PopulateProfileSelection(this);
setCurrentText(text);
}
} // namespace advss

View File

@@ -1,5 +1,6 @@
#pragma once
#include <QComboBox>
#include "filter-combo-box.hpp"
#include <string>
namespace advss {
@@ -7,4 +8,14 @@ namespace advss {
void PopulateProfileSelection(QComboBox *list);
std::string GetPathInProfileDir(const char *filePath);
class ProfileSelectionWidget : public FilterComboBox {
Q_OBJECT
public:
ProfileSelectionWidget(QWidget *parent);
protected:
void showEvent(QShowEvent *event) override;
};
} // namespace advss