cherry-pick #15: OriginSelectorWidget (deeb6376f7)
Action.cpp/.h: toolbar action integration for origin selector. Resolved add/add: kept Phase 1 OriginSelectorWidget.cpp.
This commit is contained in:
@@ -54,6 +54,7 @@
|
||||
#include "Workbench.h"
|
||||
#include "WorkbenchManager.h"
|
||||
#include "WorkbenchSelector.h"
|
||||
#include "OriginSelectorWidget.h"
|
||||
#include "ShortcutManager.h"
|
||||
#include "Tools.h"
|
||||
|
||||
@@ -1471,4 +1472,25 @@ void WindowAction::addTo(QWidget* widget)
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
OriginSelectorAction::OriginSelectorAction(Command* pcCmd, QObject* parent)
|
||||
: Action(pcCmd, parent)
|
||||
{}
|
||||
|
||||
OriginSelectorAction::~OriginSelectorAction() = default;
|
||||
|
||||
void OriginSelectorAction::addTo(QWidget* widget)
|
||||
{
|
||||
if (widget->inherits("QToolBar")) {
|
||||
auto* toolbar = static_cast<QToolBar*>(widget);
|
||||
auto* selector = new OriginSelectorWidget(widget);
|
||||
toolbar->addWidget(selector);
|
||||
}
|
||||
else {
|
||||
// For menus, just add the action
|
||||
widget->addAction(action());
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_Action.cpp"
|
||||
|
||||
@@ -421,6 +421,25 @@ private:
|
||||
Q_DISABLE_COPY(WindowAction)
|
||||
};
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Action for origin selector widget in toolbars.
|
||||
* Creates OriginSelectorWidget when added to a toolbar.
|
||||
*/
|
||||
class GuiExport OriginSelectorAction: public Action
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit OriginSelectorAction(Command* pcCmd, QObject* parent = nullptr);
|
||||
~OriginSelectorAction() override;
|
||||
void addTo(QWidget* widget) override;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(OriginSelectorAction)
|
||||
};
|
||||
|
||||
} // namespace Gui
|
||||
|
||||
#endif // GUI_ACTION_H
|
||||
|
||||
@@ -1236,6 +1236,7 @@ SET(Widget_CPP_SRCS
|
||||
ElideCheckBox.cpp
|
||||
FontScaledSVG.cpp
|
||||
SplitButton.cpp
|
||||
OriginSelectorWidget.cpp
|
||||
)
|
||||
SET(Widget_HPP_SRCS
|
||||
ComboLinks.h
|
||||
@@ -1262,6 +1263,7 @@ SET(Widget_HPP_SRCS
|
||||
ElideCheckBox.h
|
||||
FontScaledSVG.h
|
||||
SplitButton.h
|
||||
OriginSelectorWidget.h
|
||||
)
|
||||
SET(Widget_SRCS
|
||||
${Widget_CPP_SRCS}
|
||||
|
||||
@@ -132,6 +132,45 @@ Action* StdCmdWorkbench::createAction()
|
||||
return pcAction;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// Std_Origin
|
||||
//===========================================================================
|
||||
|
||||
DEF_STD_CMD_AC(StdCmdOrigin)
|
||||
|
||||
StdCmdOrigin::StdCmdOrigin()
|
||||
: Command("Std_Origin")
|
||||
{
|
||||
sGroup = "File";
|
||||
sMenuText = QT_TR_NOOP("&Origin");
|
||||
sToolTipText = QT_TR_NOOP("Select file origin (Local Files, Silo, etc.)");
|
||||
sWhatsThis = "Std_Origin";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "folder";
|
||||
eType = 0;
|
||||
}
|
||||
|
||||
void StdCmdOrigin::activated(int /*iMsg*/)
|
||||
{
|
||||
// Action is handled by OriginSelectorWidget
|
||||
}
|
||||
|
||||
bool StdCmdOrigin::isActive()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Action* StdCmdOrigin::createAction()
|
||||
{
|
||||
Action* pcAction = new OriginSelectorAction(this, getMainWindow());
|
||||
pcAction->setShortcut(QString::fromLatin1(getAccel()));
|
||||
applyCommandData(this->className(), pcAction);
|
||||
if (getPixmap()) {
|
||||
pcAction->setIcon(Gui::BitmapFactory().iconFromTheme(getPixmap()));
|
||||
}
|
||||
return pcAction;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// Std_RecentFiles
|
||||
//===========================================================================
|
||||
@@ -1057,6 +1096,7 @@ void CreateStdCommands()
|
||||
rcCmdMgr.addCommand(new StdCmdDlgCustomize());
|
||||
rcCmdMgr.addCommand(new StdCmdCommandLine());
|
||||
rcCmdMgr.addCommand(new StdCmdWorkbench());
|
||||
rcCmdMgr.addCommand(new StdCmdOrigin());
|
||||
rcCmdMgr.addCommand(new StdCmdRecentFiles());
|
||||
rcCmdMgr.addCommand(new StdCmdRecentMacros());
|
||||
rcCmdMgr.addCommand(new StdCmdWhatsThis());
|
||||
|
||||
@@ -1142,6 +1142,28 @@ Gui--WorkbenchComboBox::drop-down {
|
||||
border-radius: 0 4px 4px 0;
|
||||
}
|
||||
|
||||
/* Origin Selector */
|
||||
Gui--OriginSelectorWidget {
|
||||
background-color: #313244;
|
||||
color: #cdd6f4;
|
||||
border: 1px solid #45475a;
|
||||
border-radius: 4px;
|
||||
padding: 4px 8px;
|
||||
min-width: 70px;
|
||||
max-width: 120px;
|
||||
}
|
||||
|
||||
Gui--OriginSelectorWidget:hover {
|
||||
border-color: #585b70;
|
||||
background-color: #45475a;
|
||||
}
|
||||
|
||||
Gui--OriginSelectorWidget::menu-indicator {
|
||||
subcontrol-origin: padding;
|
||||
subcontrol-position: center right;
|
||||
right: 4px;
|
||||
}
|
||||
|
||||
/* Task Panel */
|
||||
QSint--ActionGroup {
|
||||
background-color: #313244;
|
||||
|
||||
@@ -834,7 +834,7 @@ ToolBarItem* StdWorkbench::setupToolBars() const
|
||||
// File
|
||||
auto file = new ToolBarItem(root);
|
||||
file->setCommand("File");
|
||||
*file << "Std_New" << "Std_Open" << "Std_Save";
|
||||
*file << "Std_Origin" << "Std_New" << "Std_Open" << "Std_Save";
|
||||
|
||||
// Edit
|
||||
auto edit = new ToolBarItem(root);
|
||||
|
||||
Reference in New Issue
Block a user