aboutsummaryrefslogtreecommitdiff
path: root/libs/uibase/src/expanderwidget.cpp
diff options
context:
space:
mode:
authorSulfurNitride <SulfurNitride@users.noreply.github.com>2026-02-11 02:37:39 -0600
committerSulfurNitride <SulfurNitride@users.noreply.github.com>2026-02-11 02:37:39 -0600
commit7ee008e150bc5bcf76082d726f719ee0fdfda982 (patch)
tree27fb39be241fdb5ac2734c574de678977d1856d0 /libs/uibase/src/expanderwidget.cpp
Fluorine Manager: full Linux port of Mod Organizer 2
Complete native Linux port with FUSE-based virtual filesystem, Proton/umu-run integration, and Flatpak packaging. Key features: - FUSE VFS replacing Windows USVFS (in-process + standalone helper for Flatpak) - Proton/GE-Proton/umu-run launcher with env var forwarding - Flatpak support (sandbox-aware VFS, NXM handler, umu-run) - Wine prefix management UI - Case-insensitive path resolution for Linux filesystems - QSettings-safe INI handling (avoids Bethesda INI corruption) - Portable instance support with auto-generated launcher scripts Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'libs/uibase/src/expanderwidget.cpp')
-rw-r--r--libs/uibase/src/expanderwidget.cpp93
1 files changed, 93 insertions, 0 deletions
diff --git a/libs/uibase/src/expanderwidget.cpp b/libs/uibase/src/expanderwidget.cpp
new file mode 100644
index 0000000..451ab07
--- /dev/null
+++ b/libs/uibase/src/expanderwidget.cpp
@@ -0,0 +1,93 @@
+#include <uibase/expanderwidget.h>
+#include <QIODevice>
+
+namespace MOBase
+{
+
+ExpanderWidget::ExpanderWidget() : m_button(nullptr), m_content(nullptr), opened_(false)
+{}
+
+ExpanderWidget::ExpanderWidget(QToolButton* button, QWidget* content) : ExpanderWidget()
+{
+ set(button, content);
+}
+
+void ExpanderWidget::set(QToolButton* button, QWidget* content, bool o)
+{
+ m_button = button;
+ m_content = content;
+
+ m_button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
+ QObject::connect(m_button, &QToolButton::clicked, [&] {
+ toggle();
+ });
+
+ toggle(o);
+}
+
+void ExpanderWidget::toggle()
+{
+ if (opened()) {
+ toggle(false);
+ } else {
+ toggle(true);
+ }
+}
+
+void ExpanderWidget::toggle(bool b)
+{
+ if (b != opened_) {
+ emit aboutToToggle(b);
+ }
+
+ if (b) {
+ m_button->setArrowType(Qt::DownArrow);
+ m_content->show();
+ } else {
+ m_button->setArrowType(Qt::RightArrow);
+ m_content->hide();
+ }
+
+ if (b != opened_) {
+ // the state has to be remembered instead of using m_content's visibility
+ // because saving the state in saveConflictExpandersState() happens after the
+ // dialog is closed, which marks all the widgets hidden
+ opened_ = b;
+
+ emit toggled(b);
+ }
+}
+
+bool ExpanderWidget::opened() const
+{
+ return opened_;
+}
+
+QByteArray ExpanderWidget::saveState() const
+{
+ QByteArray result;
+ QDataStream stream(&result, QIODevice::WriteOnly);
+
+ stream << opened();
+
+ return result;
+}
+
+void ExpanderWidget::restoreState(const QByteArray& a)
+{
+ QDataStream stream(a);
+
+ bool opened = false;
+ stream >> opened;
+
+ if (stream.status() == QDataStream::Ok) {
+ toggle(opened);
+ }
+}
+
+QToolButton* ExpanderWidget::button() const
+{
+ return m_button;
+}
+
+} // namespace MOBase