/*************************************************************************** * Copyright (c) 2025 Kindred Systems * * * * This file is part of the FreeCAD CAx development system. * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Library General Public * * License as published by the Free Software Foundation; either * * version 2 of the License, or (at your option) any later version. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Library General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this library; see the file COPYING.LIB. If not, * * write to the Free Software Foundation, Inc., 59 Temple Place, * * Suite 330, Boston, MA 02111-1307, USA * * * ***************************************************************************/ #ifndef GUI_ORIGINSELECTORWIDGET_H #define GUI_ORIGINSELECTORWIDGET_H #include #include #include #include #include namespace Gui { class FileOrigin; /** * @brief Toolbar widget for selecting the current file origin * * OriginSelectorWidget displays the currently selected origin and provides * a dropdown menu to switch between available origins (Local Files, Silo * instances, etc.). * * Visual design: * Collapsed (toolbar state): * ┌──────────────────┐ * │ ☁️ Work ▼ │ ~70-100px wide * └──────────────────┘ * * Expanded (dropdown open): * ┌──────────────────┐ * │ ✓ ☁️ Work │ ← Current selection (checkmark) * │ ☁️ Prod │ * │ 📁 Local │ * ├──────────────────┤ * │ ⚙️ Manage... │ ← Opens config dialog * └──────────────────┘ */ class GuiExport OriginSelectorWidget : public QToolButton { Q_OBJECT public: explicit OriginSelectorWidget(QWidget* parent = nullptr); ~OriginSelectorWidget() override; private Q_SLOTS: void onOriginActionTriggered(QAction* action); void onManageOriginsClicked(); private: void setupUi(); void connectSignals(); void disconnectSignals(); void onOriginRegistered(const std::string& originId); void onOriginUnregistered(const std::string& originId); void onCurrentOriginChanged(const std::string& originId); void updateDisplay(); void rebuildMenu(); QIcon iconForOrigin(FileOrigin* origin) const; QMenu* m_menu; QActionGroup* m_originActions; QAction* m_manageAction; // Signal connections fastsignals::scoped_connection m_connRegistered; fastsignals::scoped_connection m_connUnregistered; fastsignals::scoped_connection m_connChanged; }; } // namespace Gui #endif // GUI_ORIGINSELECTORWIDGET_H