Files
create/src/Gui/OriginSelectorWidget.h
forbes-0023 deeb6376f7
Some checks failed
Build and Test / build (push) Has been cancelled
feat(gui): add OriginSelectorWidget for file origin selection (#13)
- Create OriginSelectorWidget class (QToolButton with dropdown menu)
- Add OriginSelectorAction to create widget in toolbars
- Add Std_Origin command registered in CommandStd.cpp
- Add widget to File toolbar (before New/Open/Save)
- Connect to OriginManager fastsignals for origin changes
- Add Catppuccin Mocha styling for the widget
- Widget shows current origin name/icon with connection status overlay

This implements Issue #13: Origin selector toolbar widget
2026-02-05 14:47:18 -06:00

96 lines
3.7 KiB
C++

/***************************************************************************
* 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 <QToolButton>
#include <QMenu>
#include <QActionGroup>
#include <fastsignals/signal.h>
#include <FCGlobal.h>
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