mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-09-12 11:36:08 -05:00
Add ProfileSelectionWidget
Refreshes list of profiles when widget becomes visible to support widget caching.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user