setting.cc预留导入导出配置文件
This commit is contained in:
@@ -244,6 +244,28 @@ static auto AddProfileLongItem(creeper::ThemeManager& manager) {
|
|||||||
fbpro::Clickable {[]{ ShowAddProfileDialog(); }},
|
fbpro::Clickable {[]{ ShowAddProfileDialog(); }},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
static auto ImportProfileLongItem(creeper::ThemeManager& manager) {
|
||||||
|
return new FilledButton {
|
||||||
|
fbpro::ThemeManager {manager},
|
||||||
|
fbpro::Text {QStringLiteral("导入配置")},
|
||||||
|
widget::pro::SizePolicy {QSizePolicy::Fixed, QSizePolicy::Expanding},
|
||||||
|
widget::pro::MinimumHeight {40},
|
||||||
|
widget::pro::MinimumWidth {320},
|
||||||
|
fbpro::Radius {12},
|
||||||
|
fbpro::Clickable {[]{ qDebug() << "ImportProfileLongItem"; }},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
static auto ExportProfileLongItem(creeper::ThemeManager& manager) {
|
||||||
|
return new FilledButton {
|
||||||
|
fbpro::ThemeManager {manager},
|
||||||
|
fbpro::Text {QStringLiteral("导出配置")},
|
||||||
|
widget::pro::SizePolicy {QSizePolicy::Fixed, QSizePolicy::Expanding},
|
||||||
|
widget::pro::MinimumHeight {40},
|
||||||
|
widget::pro::MinimumWidth {320},
|
||||||
|
fbpro::Radius {12},
|
||||||
|
fbpro::Clickable {[]{ qDebug() << "ExportProfileLongItem"; }},
|
||||||
|
};
|
||||||
|
}
|
||||||
static auto ProfileItemComponent(creeper::ThemeManager& manager, ConfigProfile& profile,
|
static auto ProfileItemComponent(creeper::ThemeManager& manager, ConfigProfile& profile,
|
||||||
const std::shared_ptr<MutableValue<std::vector<ConfigProfile>>>& profiles_store) {
|
const std::shared_ptr<MutableValue<std::vector<ConfigProfile>>>& profiles_store) {
|
||||||
QString matrix_size = "规格:" + QString{ "%1 * %2" }.arg(profile.matrix_width).arg(profile.matrix_height);
|
QString matrix_size = "规格:" + QString{ "%1 * %2" }.arg(profile.matrix_width).arg(profile.matrix_height);
|
||||||
@@ -421,9 +443,19 @@ auto SettingComponent(SettingComponentState& state) noexcept -> raw_pointer<QWid
|
|||||||
lnpro::Alignment {Qt::AlignTop},
|
lnpro::Alignment {Qt::AlignTop},
|
||||||
lnpro::Margin {10},
|
lnpro::Margin {10},
|
||||||
lnpro::Spacing {10},
|
lnpro::Spacing {10},
|
||||||
|
lnpro::Item<Row> {
|
||||||
lnpro::Item{
|
lnpro::Item{
|
||||||
AddProfileLongItem(state.manager)
|
AddProfileLongItem(state.manager)
|
||||||
},
|
},
|
||||||
|
lnpro::Item {
|
||||||
|
ImportProfileLongItem(state.manager)
|
||||||
|
},
|
||||||
|
lnpro::Item {
|
||||||
|
ExportProfileLongItem(state.manager)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
col::pro::Item<ScrollArea>{
|
col::pro::Item<ScrollArea>{
|
||||||
scroll::pro::ThemeManager { state.manager },
|
scroll::pro::ThemeManager { state.manager },
|
||||||
scroll::pro::HorizontalScrollBarPolicy { Qt::ScrollBarAlwaysOff },
|
scroll::pro::HorizontalScrollBarPolicy { Qt::ScrollBarAlwaysOff },
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#include <qsize.h>
|
#include <qsize.h>
|
||||||
#include <qsizepolicy.h>
|
#include <qsizepolicy.h>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <QEvent>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@@ -509,6 +510,45 @@ SensorUiState& sensor_state() {
|
|||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void RefreshPortsForView(SensorUiState& sensor) {
|
||||||
|
QStringList ports_list;
|
||||||
|
const auto ports = ffmsep::CPStreamCore::list_available_ports();
|
||||||
|
ports_list.reserve(static_cast<qsizetype>(ports.size()));
|
||||||
|
for (const auto& info: ports) {
|
||||||
|
ports_list.emplace_back(QString::fromStdString(info.port));
|
||||||
|
}
|
||||||
|
if (!sensor.selected_port.isEmpty()) {
|
||||||
|
const bool exists = ports_list.contains(sensor.selected_port);
|
||||||
|
if (!exists) {
|
||||||
|
sensor.selected_port = ports_list.isEmpty() ? QString{} : ports_list.front();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!ports_list.isEmpty()) {
|
||||||
|
sensor.selected_port = ports_list.front();
|
||||||
|
}
|
||||||
|
|
||||||
|
sensor.port_items->set(std::move(ports_list));
|
||||||
|
RefreshProfilesForView();
|
||||||
|
}
|
||||||
|
|
||||||
|
class PortHoverRefreshFilter final : public QObject {
|
||||||
|
public:
|
||||||
|
explicit PortHoverRefreshFilter(SensorUiState& sensor, QObject* parent = nullptr)
|
||||||
|
: QObject(parent)
|
||||||
|
, sensor_(sensor) { }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool eventFilter(QObject* watched, QEvent* event) override {
|
||||||
|
if (event && event->type() == QEvent::Enter) {
|
||||||
|
RefreshPortsForView(sensor_);
|
||||||
|
}
|
||||||
|
return QObject::eventFilter(watched, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
SensorUiState& sensor_;
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void RefreshProfilesForView() {
|
void RefreshProfilesForView() {
|
||||||
@@ -581,6 +621,12 @@ static auto ComConfigComponent(ThemeManager& manager) {
|
|||||||
dmpro::Items{},
|
dmpro::Items{},
|
||||||
sensor.port_items,
|
sensor.port_items,
|
||||||
},
|
},
|
||||||
|
dmpro::Apply{ [&sensor](dropdown_menu::internal::DropdownMenu& self) {
|
||||||
|
if (!self.property("portHoverRefreshAttached").toBool()) {
|
||||||
|
self.installEventFilter(new PortHoverRefreshFilter(sensor, &self));
|
||||||
|
self.setProperty("portHoverRefreshAttached", true);
|
||||||
|
}
|
||||||
|
} },
|
||||||
},
|
},
|
||||||
lnpro::Item<FilledDropdownMenu>{
|
lnpro::Item<FilledDropdownMenu>{
|
||||||
dmpro::ThemeManager{ manager },
|
dmpro::ThemeManager{ manager },
|
||||||
@@ -642,33 +688,6 @@ static auto ComConfigComponent(ThemeManager& manager) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} } },
|
} } },
|
||||||
lnpro::Item<IconButton>{
|
|
||||||
ibpro::ThemeManager{ manager },
|
|
||||||
ibpro::FixedSize{ 40, 40 },
|
|
||||||
ibpro::Color{ IconButton::Color::TONAL },
|
|
||||||
ibpro::Font{ material::kRegularExtraSmallFont },
|
|
||||||
ibpro::FontIcon{ material::icon::kRefresh },
|
|
||||||
ibpro::Clickable{ [&sensor] {
|
|
||||||
QStringList ports_list;
|
|
||||||
const auto ports = ffmsep::CPStreamCore::list_available_ports();
|
|
||||||
ports_list.reserve(static_cast<qsizetype>(ports.size()));
|
|
||||||
for (const auto& info: ports) {
|
|
||||||
ports_list.emplace_back(QString::fromStdString(info.port));
|
|
||||||
}
|
|
||||||
if (!sensor.selected_port.isEmpty()) {
|
|
||||||
const bool exists = ports_list.contains(sensor.selected_port);
|
|
||||||
if (!exists) {
|
|
||||||
sensor.selected_port = ports_list.isEmpty() ? QString{} : ports_list.front();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (!ports_list.isEmpty()) {
|
|
||||||
sensor.selected_port = ports_list.front();
|
|
||||||
}
|
|
||||||
|
|
||||||
sensor.port_items->set(std::move(ports_list));
|
|
||||||
RefreshProfilesForView();
|
|
||||||
} },
|
|
||||||
},
|
|
||||||
lnpro::Item<FilledButton>{
|
lnpro::Item<FilledButton>{
|
||||||
fbpro::ThemeManager{ manager },
|
fbpro::ThemeManager{ manager },
|
||||||
fbpro::FixedSize{ 40, 40 },
|
fbpro::FixedSize{ 40, 40 },
|
||||||
|
|||||||
Reference in New Issue
Block a user