Core: add property command, that shows property view.

This commit is contained in:
Paddle
2024-01-19 10:26:00 +01:00
parent 10de5a19d0
commit 3136bd6fcc
4 changed files with 40 additions and 32 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

@@ -524,13 +524,6 @@ TreeWidget::TreeWidget(const char* name, QWidget* parent)
connect(this->relabelObjectAction, &QAction::triggered,
this, &TreeWidget::onRelabelObject);
this->objectPropertyAction = new QAction(this);
#ifndef Q_OS_MAC
this->objectPropertyAction->setShortcut(Qt::Key_F6);
#endif
connect(this->objectPropertyAction, &QAction::triggered,
this, &TreeWidget::onObjectProperty);
this->finishEditingAction = new QAction(this);
connect(this->finishEditingAction, &QAction::triggered,
this, &TreeWidget::onFinishEditing);
@@ -889,7 +882,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;
@@ -898,8 +891,7 @@ void TreeWidget::contextMenuEvent(QContextMenuEvent* e)
QMenu editMenu;
QActionGroup subMenuGroup(&subMenu);
subMenuGroup.setExclusive(true);
connect(&subMenuGroup, &QActionGroup::triggered,
this, &TreeWidget::onActivateDocument);
connect(&subMenuGroup, &QActionGroup::triggered, this, &TreeWidget::onActivateDocument);
MenuManager::getInstance()->setupContextMenu(&view, contextMenu);
// get the current item
@@ -969,7 +961,6 @@ void TreeWidget::contextMenuEvent(QContextMenuEvent* e)
// relabeling is only possible for a single selected document
if (SelectedObjectsList.size() == 1)
contextMenu.addAction(this->relabelObjectAction);
contextMenu.addAction(this->objectPropertyAction);
auto selItems = this->selectedItems();
// if only one item is selected, setup the edit menu
@@ -1091,21 +1082,6 @@ void TreeWidget::onRelabelObject()
editItem(item);
}
void TreeWidget::onObjectProperty()
{
int sizeOfFirstColumn = 200;
auto prop = new PropertyView(this, sizeOfFirstColumn);
QDialog* propertyDialog = new QDialog(this);
propertyDialog->setWindowTitle(QString::fromLatin1("Properties"));
propertyDialog->resize(700, 500);
QVBoxLayout* layout = new QVBoxLayout(propertyDialog);
layout->addWidget(prop);
propertyDialog->setLayout(layout);
QPoint cursorPos = QCursor::pos() - QPoint(0, 300);
propertyDialog->move(cursorPos);
propertyDialog->show();
}
void TreeWidget::onStartEditing()
{
auto action = qobject_cast<QAction*>(sender());
@@ -2989,9 +2965,6 @@ void TreeWidget::setupText()
this->relabelObjectAction->setText(tr("Rename"));
this->relabelObjectAction->setStatusTip(tr("Rename object"));
this->objectPropertyAction->setText(tr("Properties"));
this->objectPropertyAction->setStatusTip(tr("Properties of the selected object"));
this->finishEditingAction->setText(tr("Finish editing"));
this->finishEditingAction->setStatusTip(tr("Finish editing object"));

View File

@@ -154,7 +154,6 @@ protected:
protected Q_SLOTS:
void onCreateGroup();
void onRelabelObject();
void onObjectProperty();
void onActivateDocument(QAction*);
void onStartEditing();
void onFinishEditing();
@@ -209,7 +208,6 @@ private:
private:
QAction* createGroupAction;
QAction* relabelObjectAction;
QAction* objectPropertyAction;
QAction* finishEditingAction;
QAction* selectDependentsAction;
QAction* skipRecomputeAction;

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");