Merge pull request #12024 from Ondsel-Development/property_rightclick

Core : Tree: Add 'Properties' action in contextual menu. Opens a prop…
This commit is contained in:
Chris Hennes
2024-01-19 08:58:54 -06:00
committed by GitHub
4 changed files with 48 additions and 2 deletions

View File

@@ -50,6 +50,7 @@
#include "BitmapFactory.h"
#include "Command.h"
#include "Control.h"
#include "DockWindowManager.h"
#include "FileDialog.h"
#include "MainWindow.h"
#include "Selection.h"
@@ -1715,6 +1716,41 @@ bool StdCmdEdit::isActive()
return (!Selection().getCompleteSelection().empty()) || (Gui::Control().activeDialog() != nullptr);
}
//===========================================================================
// Std_Properties
//===========================================================================
DEF_STD_CMD_A(StdCmdProperties)
StdCmdProperties::StdCmdProperties()
: Command("Std_Properties")
{
sGroup = "Edit";
sMenuText = QT_TR_NOOP("Properties");
sToolTipText = QT_TR_NOOP("Show the property view, which displays the properties of the selected object.");
sWhatsThis = "Std_Properties";
sStatusTip = sToolTipText;
sAccel = "Alt+Return";
sPixmap = "document-properties";
eType = Alter3DView;
}
void StdCmdProperties::activated(int iMsg)
{
Q_UNUSED(iMsg);
QWidget* propertyView = Gui::DockWindowManager::instance()->getDockWindow("Property view");
if (propertyView) {
QWidget* parent = propertyView->parentWidget();
if (parent && !parent->isVisible()) {
parent->show();
}
}
}
bool StdCmdProperties::isActive()
{
return !Selection().getCompleteSelection().empty();
}
//======================================================================
// StdCmdExpression
//===========================================================================
@@ -1969,6 +2005,7 @@ void CreateDocCommands()
rcCmdMgr.addCommand(new StdCmdTransformManip());
rcCmdMgr.addCommand(new StdCmdAlignment());
rcCmdMgr.addCommand(new StdCmdEdit());
rcCmdMgr.addCommand(new StdCmdProperties());
rcCmdMgr.addCommand(new StdCmdExpression());
}

View File

@@ -881,7 +881,7 @@ void TreeWidget::contextMenuEvent(QContextMenuEvent* e)
MenuItem view;
Gui::Application::Instance->setupContextMenu("Tree", &view);
view << "Std_Expressions";
view << "Std_Properties" << "Separator" << "Std_Expressions";
Workbench::createLinkMenu(&view);
QMenu contextMenu;

View File

@@ -647,7 +647,7 @@ MenuItem* StdWorkbench::setupMenuBar() const
<< "Std_Refresh" << "Std_BoxSelection" << "Std_BoxElementSelection"
<< "Std_SelectAll" << "Std_Delete" << "Std_SendToPythonConsole"
<< "Separator" << "Std_Placement" << "Std_TransformManip" << "Std_Alignment"
<< "Std_Edit" << "Separator" << "Std_UserEditMode" << "Separator" << "Std_DlgPreferences";
<< "Std_Edit" << "Std_Properties" << "Separator" << "Std_UserEditMode" << "Separator" << "Std_DlgPreferences";
auto axoviews = new MenuItem;
axoviews->setCommand("Axonometric");

View File

@@ -99,6 +99,12 @@ PropertyEditor::PropertyEditor(QWidget *parent)
setHeaderHidden(true);
viewport()->installEventFilter(this);
viewport()->setMouseTracking(true);
auto hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/DockWindows/PropertyView");
int firstColumnSize = hGrp->GetInt("FirstColumnSize", 0);
if (firstColumnSize != 0) {
header()->resizeSection(0, firstColumnSize);
}
}
PropertyEditor::~PropertyEditor()
@@ -868,6 +874,9 @@ bool PropertyEditor::eventFilter(QObject* object, QEvent* event) {
else if (mouse_event->type() == QEvent::MouseButtonRelease &&
mouse_event->button() == Qt::LeftButton && dragInProgress) {
dragInProgress = false;
auto hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/DockWindows/PropertyView");
hGrp->SetInt("FirstColumnSize", header()->sectionSize(0));
return true;
}
}