Merge pull request #21659 from 3x380V/gui_fixes

Gui: random fixes
This commit is contained in:
Chris Hennes
2025-06-03 19:23:21 -05:00
committed by GitHub
50 changed files with 477 additions and 396 deletions
+1
View File
@@ -78,6 +78,7 @@ else()
endif()
configure_file(${CMAKE_SOURCE_DIR}/src/QtCore.h.cmake ${CMAKE_BINARY_DIR}/src/QtCore.h)
configure_file(${CMAKE_SOURCE_DIR}/src/QtWidgets.h.cmake ${CMAKE_BINARY_DIR}/src/QtWidgets.h)
function(qt_find_and_add_translation _qm_files _tr_dir _qm_dir)
file(GLOB _ts_files ${_tr_dir})
+13 -8
View File
@@ -137,16 +137,21 @@ void Action::setCheckable(bool check)
}
}
void Action::setChecked(bool check, bool no_signal)
void Action::setChecked(bool check)
{
bool blocked = false;
if (no_signal) {
blocked = _action->blockSignals(true);
}
_action->setChecked(check);
if (no_signal) {
_action->blockSignals(blocked);
}
}
/*!
* \brief Action::setBlockedChecked
* \param check
* Does the same as \ref setChecked but additionally blocks
* any signals.
*/
void Action::setBlockedChecked(bool check)
{
QSignalBlocker block(_action);
_action->setChecked(check);
}
bool Action::isChecked() const
+2 -1
View File
@@ -57,7 +57,8 @@ public:
virtual void setVisible(bool);
void setCheckable(bool);
void setChecked (bool, bool no_signal=false);
void setChecked(bool);
void setBlockedChecked(bool);
bool isChecked() const;
bool isEnabled() const;
+1
View File
@@ -137,6 +137,7 @@
#include "WorkbenchManipulator.h"
#include "WidgetFactory.h"
#include "3Dconnexion/navlib/NavlibInterface.h"
#include "QtWidgets.h"
#ifdef BUILD_TRACY_FRAME_PROFILER
#include <tracy/Tracy.hpp>
-4
View File
@@ -30,10 +30,6 @@
#include <App/Application.h>
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) && QT_VERSION < QT_VERSION_CHECK(6,8,1)
# define HAS_QTBUG_129596
#endif
class QCloseEvent;
class SoNode;
class NavlibInterface;
+21 -10
View File
@@ -344,17 +344,28 @@ public:
}
void run() override
{
prop->SaveDocFile(writer);
writer.close();
try {
prop->SaveDocFile(writer);
writer.close();
// We could have renamed the file in this thread. However, there is
// still chance of crash when we deleted the original and before rename
// the new file. So we ask the main thread to do it. There is still
// possibility of crash caused by thread other than the main, but
// that's the best we can do for now.
QMetaObject::invokeMethod(AutoSaver::instance(), "renameFile",
Qt::QueuedConnection, Q_ARG(QString,dirName)
,Q_ARG(QString,fileName),Q_ARG(QString,tmpName));
// We could have renamed the file in this thread. However, there is
// still chance of crash when we deleted the original and before rename
// the new file. So we ask the main thread to do it. There is still
// possibility of crash caused by thread other than the main, but
// that's the best we can do for now.
QMetaObject::invokeMethod(AutoSaver::instance(), "renameFile",
Qt::QueuedConnection, Q_ARG(QString,dirName)
,Q_ARG(QString,fileName),Q_ARG(QString,tmpName));
}
catch (const Base::Exception& e) {
Base::Console().warning("Exception in auto-saving: %s\n", e.what());
}
catch (const std::exception& e) {
Base::Console().warning("C++ exception in auto-saving: %s\n", e.what());
}
catch (...) {
Base::Console().warning("Unknown exception in auto-saving\n");
}
}
private:
+9 -3
View File
@@ -385,7 +385,7 @@ void Command::setupCheckable(int iMsg) {
action->setChecked(checked);
action->blockSignals(blocked);
if(action!=_pcAction->action())
_pcAction->setChecked(checked,true);
_pcAction->setBlockedChecked(checked);
}
}
@@ -899,8 +899,14 @@ const char* Command::keySequenceToAccel(int sk) const
static StringMap strings;
auto i = strings.find(sk);
if (i != strings.end())
if (i != strings.end()) {
return i->second.c_str();
}
// In case FreeCAD is loaded without GUI (issue 16407)
if (!QApplication::instance()) {
return "";
}
auto type = static_cast<QKeySequence::StandardKey>(sk);
QKeySequence ks(type);
@@ -1637,7 +1643,7 @@ Action * PythonGroupCommand::createAction()
qtAction->blockSignals(false);
}else if(qtAction->isCheckable()){
pcAction->setCheckable(true);
pcAction->setChecked(qtAction->isChecked(),true);
pcAction->setBlockedChecked(qtAction->isChecked());
}
}
}
+1 -1
View File
@@ -181,7 +181,7 @@
if(__obj && __obj->isAttachedToDocument()) {\
Gui::Command::doCommand(Gui::Command::Gui,\
"Gui.ActiveDocument.setEdit(App.getDocument('%s').getObject('%s'), %i)",\
__obj->getDocument()->getName(), __obj->getNameInDocument(), Gui::Application::Instance->getUserEditMode());\
__obj->getDocument()->getName(), __obj->getNameInDocument(), 0);\
}\
}while(0)
+8 -6
View File
@@ -1752,12 +1752,14 @@ StdCmdProperties::StdCmdProperties()
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();
}
auto dw = Gui::DockWindowManager::instance();
if (auto propertyView = dw->getDockWindow("Property view")) {
dw->activate(propertyView);
return;
}
if (auto comboView = dw->getDockWindow("Model")) {
dw->activate(comboView);
return;
}
}
+10 -10
View File
@@ -3301,7 +3301,7 @@ bool StdCmdSelForward::isActive()
DEF_STD_CMD_AC(StdTree##_name) \
void StdTree##_name::activated(int){ \
TreeParams::setDocumentMode(_v);\
if(_pcAction) _pcAction->setChecked(true,true);\
if(_pcAction) _pcAction->setBlockedChecked(true);\
}\
Action * StdTree##_name::createAction(void) {\
Action *pcAction = Command::createAction();\
@@ -3314,7 +3314,7 @@ Action * StdTree##_name::createAction(void) {\
bool StdTree##_name::isActive() {\
bool checked = TreeParams::getDocumentMode()==_v;\
if(_pcAction && _pcAction->isChecked()!=checked)\
_pcAction->setChecked(checked,true);\
_pcAction->setBlockedChecked(checked);\
return true;\
}
@@ -3374,9 +3374,9 @@ DEF_STD_CMD_AC(StdTree##_name) \
void StdTree##_name::activated(int){ \
auto checked = !TreeParams::get##_name();\
TreeParams::set##_name(checked);\
if(_pcAction) _pcAction->setChecked(checked,true);\
if(_pcAction) _pcAction->setBlockedChecked(checked);\
}\
Action * StdTree##_name::createAction(void) {\
Action * StdTree##_name::createAction() {\
Action *pcAction = Command::createAction();\
pcAction->setCheckable(true);\
pcAction->setIcon(QIcon());\
@@ -3387,7 +3387,7 @@ Action * StdTree##_name::createAction(void) {\
bool StdTree##_name::isActive() {\
bool checked = TreeParams::get##_name();\
if(_pcAction && _pcAction->isChecked()!=checked)\
_pcAction->setChecked(checked,true);\
_pcAction->setBlockedChecked(checked);\
return true;\
}
@@ -3576,7 +3576,7 @@ void StdCmdSelBoundingBox::activated(int iMsg)
if(checked != ViewParams::instance()->getShowSelectionBoundingBox()) {
ViewParams::instance()->setShowSelectionBoundingBox(checked);
if(_pcAction)
_pcAction->setChecked(checked,true);
_pcAction->setBlockedChecked(checked);
}
}
@@ -3585,7 +3585,7 @@ bool StdCmdSelBoundingBox::isActive()
if(_pcAction) {
bool checked = _pcAction->isChecked();
if(checked != ViewParams::instance()->getShowSelectionBoundingBox())
_pcAction->setChecked(!checked,true);
_pcAction->setBlockedChecked(!checked);
}
return true;
}
@@ -3819,10 +3819,10 @@ void StdCmdDockOverlayMouseTransparent::activated(int iMsg)
bool checked = !OverlayManager::instance()->isMouseTransparent();
OverlayManager::instance()->setMouseTransparent(checked);
if(_pcAction)
_pcAction->setChecked(checked,true);
_pcAction->setBlockedChecked(checked);
}
Action * StdCmdDockOverlayMouseTransparent::createAction(void) {
Action * StdCmdDockOverlayMouseTransparent::createAction() {
Action *pcAction = Command::createAction();
pcAction->setCheckable(true);
pcAction->setIcon(QIcon());
@@ -3834,7 +3834,7 @@ Action * StdCmdDockOverlayMouseTransparent::createAction(void) {
bool StdCmdDockOverlayMouseTransparent::isActive() {
bool checked = OverlayManager::instance()->isMouseTransparent();
if(_pcAction && _pcAction->isChecked()!=checked)
_pcAction->setChecked(checked,true);
_pcAction->setBlockedChecked(checked);
return true;
}
+2 -2
View File
@@ -362,7 +362,7 @@ Action* StdCmdToggleToolBarLock::createAction()
Action* action = Command::createAction();
action->setCheckable(true);
action->setChecked(ToolBarManager::getInstance()->areToolBarsLocked(), true);
action->setBlockedChecked(ToolBarManager::getInstance()->areToolBarsLocked());
return action;
}
@@ -420,7 +420,7 @@ Action * StdCmdStatusBar::createAction()
{
Action *pcAction = Command::createAction();
pcAction->setCheckable(true);
pcAction->setChecked(false, true);
pcAction->setBlockedChecked(false);
auto fsb = new FilterStatusBar(pcAction);
getMainWindow()->statusBar()->installEventFilter(fsb);
+8 -7
View File
@@ -219,8 +219,8 @@ void DlgCustomActionsImp::onActionListWidgetItemActivated(QTreeWidgetItem* item)
ui->actionMenu->setText(QString::fromUtf8(pScript->getMenuText()));
ui->actionToolTip->setText(QString::fromUtf8(pScript->getToolTipText()));
ui->actionStatus->setText(QString::fromUtf8(pScript->getStatusTip()));
ui->actionAccel->setText(
ShortcutManager::instance()->getShortcut(actionName.constData(), pScript->getAccel()));
ui->actionAccel->setKeySequence(QKeySequence(
ShortcutManager::instance()->getShortcut(actionName.constData(), pScript->getAccel())));
ui->pixmapLabel->clear();
m_sPixmap.clear();
const char* name = pScript->getPixmap();
@@ -290,9 +290,10 @@ void DlgCustomActionsImp::onButtonAddActionClicked()
ui->pixmapLabel->clear();
m_sPixmap.clear();
if (!ui->actionAccel->text().isEmpty()) {
if (!ui->actionAccel->isEmpty()) {
QString text = ui->actionAccel->text();
ShortcutManager::instance()->setShortcut(actionName.constData(),
ui->actionAccel->text().toLatin1().constData());
text.toLatin1().constData());
}
ui->actionAccel->clear();
@@ -353,8 +354,9 @@ void DlgCustomActionsImp::onButtonReplaceActionClicked()
ui->pixmapLabel->clear();
m_sPixmap.clear();
if (!ui->actionAccel->text().isEmpty()) {
macro->setAccel(ui->actionAccel->text().toLatin1());
if (!ui->actionAccel->isEmpty()) {
QString text = ui->actionAccel->text();
macro->setAccel(text.toLatin1());
}
ui->actionAccel->clear();
@@ -521,7 +523,6 @@ void DlgCustomActionsImp::changeEvent(QEvent* e)
ui->retranslateUi(this);
ui->actionListWidget->clear();
showActions();
ui->actionAccel->setText(qApp->translate("Gui::AccelLineEdit", "none"));
}
QWidget::changeEvent(e);
}
+35 -3
View File
@@ -371,8 +371,7 @@ bool DlgAddPropertyVarSet::isGroupValid()
bool DlgAddPropertyVarSet::isTypeValid()
{
std::string type = ui->comboBoxType->currentText().toStdString();
return !Base::Type::fromName(type.c_str()).isBad();
return Base::Type::fromName(type.c_str()).isDerivedFrom(App::Property::getClassTypeId());
}
bool DlgAddPropertyVarSet::areFieldsValid()
@@ -380,9 +379,41 @@ bool DlgAddPropertyVarSet::areFieldsValid()
return isNameValid() && isGroupValid() && isTypeValid();
}
void DlgAddPropertyVarSet::onTextFieldChanged([[maybe_unused]] const QString& text)
void DlgAddPropertyVarSet::onTextFieldChanged([[maybe_unused]]const QString& text)
{
setOkEnabled(areFieldsValid());
showStatusMessage();
}
void DlgAddPropertyVarSet::showStatusMessage()
{
QString error;
QString text = ui->lineEditName->text();
std::string name = text.toStdString();
if (!isGroupValid()) {
error = tr("Invalid group name");
}
else if (!isTypeValid()) {
error = tr("Invalid type name");
}
else if (name.empty()) {
error.clear();
}
else if (name != Base::Tools::getIdentifier(name)) {
error = tr("Invalid property name '%1'").arg(text);
}
else if (propertyExists(name)) {
error = tr("Property '%1' already exists").arg(text);
}
else if (App::ExpressionParser::isTokenAConstant(name)) {
error = tr("'%1' is a constant").arg(text);
}
else if (App::ExpressionParser::isTokenAUnit(name)) {
error = tr("'%1' is a unit").arg(text);
}
ui->labelError->setText(error);
}
void DlgAddPropertyVarSet::removeEditor()
@@ -409,6 +440,7 @@ void DlgAddPropertyVarSet::onTypeChanged(const QString& text)
}
setOkEnabled(areFieldsValid());
showStatusMessage();
}
void DlgAddPropertyVarSet::changeEvent(QEvent* e)
+1
View File
@@ -121,6 +121,7 @@ private:
bool areFieldsValid();
void onTextFieldChanged(const QString& text);
void showStatusMessage();
void removeEditor();
void onTypeChanged(const QString& text);
+8 -1
View File
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>418</width>
<height>223</height>
<height>234</height>
</rect>
</property>
<property name="windowTitle">
@@ -70,6 +70,13 @@
<widget class="QLineEdit" name="lineEditToolTip"/>
</item>
<item row="6" column="0" colspan="2">
<widget class="QLabel" name="labelError">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="7" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
+18 -14
View File
@@ -25,6 +25,7 @@
#include <QApplication>
#include <QMenu>
#include <QMouseEvent>
#include <QPushButton>
#include <QTreeWidget>
#endif
@@ -66,13 +67,16 @@ DlgExpressionInput::DlgExpressionInput(const App::ObjectIdentifier & _path,
// Setup UI
ui->setupUi(this);
okBtn = ui->buttonBox->button(QDialogButtonBox::Ok);
discardBtn = ui->buttonBox->button(QDialogButtonBox::Reset);
discardBtn->setToolTip(tr("Revert to last calculated value (as constant)"));
initializeVarSets();
// Connect signal(s)
connect(ui->expression, &ExpressionLineEdit::textChanged,
this, &DlgExpressionInput::textChanged);
connect(ui->discardBtn, &QPushButton::clicked,
connect(discardBtn, &QPushButton::clicked,
this, &DlgExpressionInput::setDiscarded);
if (expression) {
@@ -280,11 +284,11 @@ void DlgExpressionInput::checkExpression(const QString& text)
std::unique_ptr<Expression> result(expr->eval());
expression = expr;
ui->okBtn->setEnabled(true);
okBtn->setEnabled(true);
ui->msg->clear();
//set default palette as we may have read text right now
ui->msg->setPalette(ui->okBtn->palette());
ui->msg->setPalette(okBtn->palette());
auto * n = freecad_cast<NumberExpression*>(result.get());
if (n) {
@@ -325,12 +329,12 @@ static const bool NO_CHECK_EXPR = false;
void DlgExpressionInput::textChanged(const QString &text)
{
if (text.isEmpty()) {
ui->okBtn->setDisabled(true);
ui->discardBtn->setDefault(true);
okBtn->setDisabled(true);
discardBtn->setDefault(true);
return;
}
ui->okBtn->setDefault(true);
okBtn->setDefault(true);
try {
//resize the input field according to text size
@@ -357,7 +361,7 @@ void DlgExpressionInput::textChanged(const QString &text)
QPalette p(ui->msg->palette());
p.setColor(QPalette::WindowText, Qt::red);
ui->msg->setPalette(p);
ui->okBtn->setDisabled(true);
okBtn->setDisabled(true);
}
}
@@ -614,7 +618,7 @@ void DlgExpressionInput::setupVarSets()
ui->comboBoxVarSet->setModel(treeWidget->model());
ui->comboBoxVarSet->setView(treeWidget.get());
ui->okBtn->setEnabled(false);
okBtn->setEnabled(false);
}
std::string DlgExpressionInput::getType()
@@ -629,7 +633,7 @@ void DlgExpressionInput::onCheckVarSets(int state) {
setupVarSets();
}
else {
ui->okBtn->setEnabled(true); // normal expression
okBtn->setEnabled(true); // normal expression
}
}
@@ -719,13 +723,13 @@ void DlgExpressionInput::updateVarSetInfo(bool checkExpr)
QString nameGroup = ui->lineEditGroup->text();
if (reportGroup(nameGroup)) {
// needed to report something about the group, so disable the button
ui->okBtn->setEnabled(false);
okBtn->setEnabled(false);
return;
}
if (reportName(selected)) {
// needed to report something about the name, so disable the button
ui->okBtn->setEnabled(false);
okBtn->setEnabled(false);
return;
}
@@ -744,15 +748,15 @@ void DlgExpressionInput::updateVarSetInfo(bool checkExpr)
// We have to check the text of the expression as well
try {
checkExpression(ui->expression->text());
ui->okBtn->setEnabled(true);
okBtn->setEnabled(true);
}
catch (Base::Exception&) {
ui->okBtn->setDisabled(true);
okBtn->setDisabled(true);
}
}
}
else {
ui->okBtn->setEnabled(false);
okBtn->setEnabled(false);
reportVarSetInfo("Please select a variable set.");
}
}
+2
View File
@@ -120,6 +120,8 @@ private:
static bool varSetsVisible;
std::unique_ptr<QTreeWidget> treeWidget;
QPushButton* okBtn = nullptr;
QPushButton* discardBtn = nullptr;
};
}
+10 -40
View File
@@ -249,42 +249,6 @@
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>2</number>
</property>
<item>
<widget class="QPushButton" name="discardBtn">
<property name="toolTip">
<string>Revert to last calculated value (as constant)</string>
</property>
<property name="text">
<string>&amp;Clear</string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
<property name="default">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="okBtn">
<property name="text">
<string>&amp;OK</string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
@@ -298,6 +262,13 @@
</property>
</spacer>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Reset|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
@@ -324,15 +295,14 @@
</customwidgets>
<tabstops>
<tabstop>expression</tabstop>
<tabstop>okBtn</tabstop>
<tabstop>discardBtn</tabstop>
<tabstop>buttonBox</tabstop>
<tabstop>checkBoxVarSets</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>okBtn</sender>
<signal>clicked()</signal>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>DlgExpressionInput</receiver>
<slot>accept()</slot>
<hints>
+11 -11
View File
@@ -139,7 +139,7 @@ void DlgCustomKeyboardImp::setupConnections()
this, &DlgCustomKeyboardImp::onButtonResetClicked);
connect(ui->buttonResetAll, &QPushButton::clicked,
this, &DlgCustomKeyboardImp::onButtonResetAllClicked);
connect(ui->editShortcut, &AccelLineEdit::textChanged,
connect(ui->editShortcut, &AccelLineEdit::keySequenceChanged,
this, &DlgCustomKeyboardImp::onEditShortcutTextChanged);
// clang-format on
}
@@ -336,11 +336,11 @@ DlgCustomKeyboardImp::initCommandWidgets(QTreeWidget* commandTreeWidget,
auto timer = new QTimer(priorityList);
timer->setSingleShot(true);
if (currentShortcut) {
QObject::connect(currentShortcut, &QLineEdit::textChanged, timer, [timer]() {
QObject::connect(currentShortcut, &AccelLineEdit::keySequenceChanged, timer, [timer]() {
timer->start(200);
});
}
QObject::connect(editShortcut, &QLineEdit::textChanged, timer, [timer]() {
QObject::connect(editShortcut, &AccelLineEdit::keySequenceChanged, timer, [timer]() {
timer->start(200);
});
QObject::connect(ShortcutManager::instance(),
@@ -368,10 +368,10 @@ void DlgCustomKeyboardImp::populatePriorityList(QTreeWidget* priorityList,
priorityList->clear();
QString sc;
if (!editor->isNone() && editor->text().size()) {
if (!editor->isEmpty()) {
sc = editor->text();
}
else if (curShortcut && !curShortcut->isNone()) {
else if (curShortcut && !curShortcut->isEmpty()) {
sc = curShortcut->text();
}
@@ -466,10 +466,10 @@ void DlgCustomKeyboardImp::onCommandTreeWidgetCurrentItemChanged(QTreeWidgetItem
QKeySequence ks2 = QString::fromLatin1(cmd->getAccel());
QKeySequence ks3 = ui->editShortcut->text();
if (ks.isEmpty()) {
ui->accelLineEditShortcut->setText(tr("none"));
ui->accelLineEditShortcut->clear();
}
else {
ui->accelLineEditShortcut->setText(ks.toString(QKeySequence::NativeText));
ui->accelLineEditShortcut->setKeySequence(ks);
}
ui->buttonAssign->setEnabled(!ui->editShortcut->text().isEmpty() && (ks != ks3));
@@ -500,7 +500,7 @@ void DlgCustomKeyboardImp::setShortcutOfCurrentAction(const QString& accelText)
if (!accelText.isEmpty()) {
QKeySequence shortcut = accelText;
portableText = shortcut.toString(QKeySequence::PortableText);
ui->accelLineEditShortcut->setText(accelText);
ui->accelLineEditShortcut->setKeySequence(shortcut);
ui->editShortcut->clear();
}
else {
@@ -538,7 +538,7 @@ void DlgCustomKeyboardImp::onButtonResetClicked()
ShortcutManager::instance()->reset(name);
QString txt = ShortcutManager::instance()->getShortcut(name);
ui->accelLineEditShortcut->setText((txt.isEmpty() ? tr("none") : txt));
ui->accelLineEditShortcut->setKeySequence(QKeySequence(txt));
ui->buttonReset->setEnabled(false);
}
@@ -550,7 +550,7 @@ void DlgCustomKeyboardImp::onButtonResetAllClicked()
}
/** Checks for an already occupied shortcut. */
void DlgCustomKeyboardImp::onEditShortcutTextChanged(const QString&)
void DlgCustomKeyboardImp::onEditShortcutTextChanged(const QKeySequence&)
{
QTreeWidgetItem* item = ui->commandTreeWidget->currentItem();
if (item) {
@@ -560,7 +560,7 @@ void DlgCustomKeyboardImp::onEditShortcutTextChanged(const QString&)
CommandManager& cCmdMgr = Application::Instance->commandManager();
Command* cmd = cCmdMgr.getCommandByName(name.constData());
if (!ui->editShortcut->isNone()) {
if (!ui->editShortcut->isEmpty()) {
ui->buttonAssign->setEnabled(true);
}
else {
+1 -1
View File
@@ -108,7 +108,7 @@ protected:
void onButtonClearClicked();
void onButtonResetClicked();
void onButtonResetAllClicked();
void onEditShortcutTextChanged(const QString&);
void onEditShortcutTextChanged(const QKeySequence&);
protected Q_SLOTS:
void onAddMacroAction(const QByteArray&) override;
+3 -12
View File
@@ -365,18 +365,9 @@ int DlgPreferencesImp::minimumDialogWidth(int pageWidth) const
{
// this is additional safety spacing to ensure that everything fits with scrollbar etc.
const auto additionalMargin = style()->pixelMetric(QStyle::PM_ScrollBarExtent) + 8;
QSize size = ui->groupWidgetStack->sizeHint();
int diff = pageWidth - size.width();
int dw = width();
if (diff > 0) {
const int offset = 2;
dw += diff + offset;
}
return dw + additionalMargin;
QSize tree = ui->groupsTreeView->sizeHint();
return pageWidth + tree.width() + additionalMargin;
}
void DlgPreferencesImp::updatePageDependentWidgets()
@@ -908,7 +899,7 @@ void DlgPreferencesImp::onStackWidgetChange(int index)
ui->groupsTreeView->expand(parentItem->index());
parentItem->setExpanded(wasExpanded);
}
ui->groupsTreeView->selectionModel()->select(currentIndex, QItemSelectionModel::ClearAndSelect);
}
+14 -2
View File
@@ -24,7 +24,9 @@
#ifndef _PreComp_
#include <QApplication>
#include <QByteArray>
#include <QDateTime>
#include <QDesktopServices>
#include <QLocale>
#include <QUrl>
#endif
@@ -71,15 +73,25 @@ DlgProjectInformationImp::DlgProjectInformationImp(App::Document* doc,
, _doc(doc)
, ui(new Ui_DlgProjectInformation)
{
auto convertISODate = [](const char* isoDate) {
auto str = QString::fromUtf8(isoDate);
QDateTime dt = QDateTime::fromString(str, Qt::DateFormat::ISODate);
if (dt.isNull()) {
return str;
}
QLocale loc = QLocale::system();
return loc.toString(dt);
};
ui->setupUi(this);
ui->lineEditName->setText(QString::fromUtf8(doc->Label.getValue()));
ui->lineEditPath->setText(QString::fromUtf8(doc->FileName.getValue()));
ui->lineEditUuid->setText(QString::fromUtf8(doc->Uid.getValueStr().c_str()));
ui->lineEditProgramVersion->setText(QString::fromUtf8(doc->getProgramVersion()));
ui->lineEditCreator->setText(QString::fromUtf8(doc->CreatedBy.getValue()));
ui->lineEditDate->setText(QString::fromUtf8(doc->CreationDate.getValue()));
ui->lineEditDate->setText(convertISODate(doc->CreationDate.getValue()));
ui->lineEditLastMod->setText(QString::fromUtf8(doc->LastModifiedBy.getValue()));
ui->lineEditLastModDate->setText(QString::fromUtf8(doc->LastModifiedDate.getValue()));
ui->lineEditLastModDate->setText(convertISODate(doc->LastModifiedDate.getValue()));
ui->lineEditCompany->setText(QString::fromUtf8(doc->Company.getValue()));
// Load comboBox with unit systems
+3 -3
View File
@@ -49,13 +49,13 @@ DockWindowItems::DockWindowItems() = default;
DockWindowItems::~DockWindowItems() = default;
void DockWindowItems::addDockWidget(const char* name, Qt::DockWidgetArea pos, bool visibility, bool tabbed)
void DockWindowItems::addDockWidget(const char* name, Qt::DockWidgetArea pos, DockWindowOptions option)
{
DockWindowItem item;
item.name = QString::fromUtf8(name);
item.pos = pos;
item.visibility = visibility;
item.tabbed = tabbed;
item.visibility = option.testFlag(DockWindowOption::Visible);
item.tabbed = option.testFlag(DockWindowOption::HiddenTabbed);
_items << item;
}
+16 -1
View File
@@ -24,6 +24,7 @@
#define GUI_DOCKWINDOWMANAGER_H
#include <QObject>
#include <Base/Bitmask.h>
#include <FCGlobal.h>
class QDockWidget;
@@ -31,6 +32,18 @@ class QWidget;
namespace Gui {
enum class DockWindowOption
{
// clang-format off
Hidden = 0,
Visible = 1,
HiddenTabbed = 2,
VisibleTabbed = 3
// clang-format on
};
using DockWindowOptions = Base::Flags<DockWindowOption>;
struct DockWindowItem {
QString name;
Qt::DockWidgetArea pos;
@@ -44,7 +57,7 @@ public:
DockWindowItems();
~DockWindowItems();
void addDockWidget(const char* name, Qt::DockWidgetArea pos, bool visibility, bool tabbed);
void addDockWidget(const char* name, Qt::DockWidgetArea pos, DockWindowOptions option);
void setDockingArea(const char* name, Qt::DockWidgetArea pos);
void setVisibility(const char* name, bool v);
void setVisibility(bool v);
@@ -122,4 +135,6 @@ private:
} // namespace Gui
ENABLE_BITMASK_OPERATORS(Gui::DockWindowOption)
#endif // GUI_DOCKWINDOWMANAGER_H
+33 -11
View File
@@ -648,6 +648,7 @@ bool Document::trySetEdit(Gui::ViewProvider* p, int ModNum, const char *subname)
Application::Instance->setEditDocument(this);
if (!d->tryStartEditing(vp, obj, _subname.c_str(), ModNum)) {
d->setDocumentNameOfTaskDialog(getDocument());
return false;
}
@@ -2719,21 +2720,42 @@ void Document::handleChildren3D(ViewProvider* viewProvider, bool deleting)
if(!deleting) {
for (const auto & it : children) {
ViewProvider* ChildViewProvider = getViewProvider(it);
if (ChildViewProvider) {
auto itOld = oldChildren.find(static_cast<ViewProviderDocumentObject*>(ChildViewProvider));
if (auto ChildViewProvider = dynamic_cast<ViewProviderDocumentObject*>(getViewProvider(it))) {
auto itOld = oldChildren.find(ChildViewProvider);
if(itOld!=oldChildren.end()) oldChildren.erase(itOld);
SoSeparator* childRootNode = ChildViewProvider->getRoot();
childGroup->addChild(childRootNode);
if (SoSeparator* childRootNode = ChildViewProvider->getRoot()) {
if (childRootNode == childGroup) {
Base::Console().warning("Document::handleChildren3D: Do not add "
"group of '%s' to itself\n",
it->getNameInDocument());
}
else if (childGroup) {
childGroup->addChild(childRootNode);
}
}
SoSeparator* childFrontNode = ChildViewProvider->getFrontRoot();
if (frontGroup && childFrontNode)
frontGroup->addChild(childFrontNode);
if (SoSeparator* childFrontNode = ChildViewProvider->getFrontRoot()) {
if (childFrontNode == frontGroup) {
Base::Console().warning("Document::handleChildren3D: Do not add "
"foreground group of '%s' to itself\n",
it->getNameInDocument());
}
else if (frontGroup) {
frontGroup->addChild(childFrontNode);
}
}
SoSeparator* childBackNode = ChildViewProvider->getBackRoot();
if (backGroup && childBackNode)
backGroup->addChild(childBackNode);
if (SoSeparator* childBackNode = ChildViewProvider->getBackRoot()) {
if (childBackNode == backGroup) {
Base::Console().warning("Document::handleChildren3D: Do not add "
"background group of '%s' to itself\n",
it->getNameInDocument());
}
else if (backGroup) {
backGroup->addChild(childBackNode);
}
}
// cycling to all views of the document to remove the viewprovider from the viewer itself
for (Gui::BaseView* vIt : d->baseViews) {
+13 -1
View File
@@ -49,6 +49,7 @@
#include <App/Application.h>
#include <App/Document.h>
#include <App/ProjectFile.h>
#include <Base/Exception.h>
#include <Gui/Application.h>
#include <Gui/Command.h>
@@ -164,6 +165,7 @@ public:
QList<Info> recoveryInfo;
Info getRecoveryInfo(const QFileInfo&) const;
bool isValidProject(const QFileInfo&) const;
void writeRecoveryInfo(const Info&) const;
XmlConfig readXmlFile(const QString& fn) const;
};
@@ -433,7 +435,7 @@ DocumentRecoveryPrivate::Info DocumentRecoveryPrivate::getRecoveryInfo(const QFi
if (info.status == DocumentRecoveryPrivate::Created) {
// compare the modification dates
QFileInfo fileInfo(info.fileName);
if (!info.fileName.isEmpty() && fileInfo.exists()) {
if (!info.fileName.isEmpty() && isValidProject(fileInfo)) {
QDateTime dateRecv = QFileInfo(file).lastModified();
QDateTime dateProj = fileInfo.lastModified();
if (dateRecv < dateProj) {
@@ -449,6 +451,16 @@ DocumentRecoveryPrivate::Info DocumentRecoveryPrivate::getRecoveryInfo(const QFi
return info;
}
bool DocumentRecoveryPrivate::isValidProject(const QFileInfo& fi) const
{
if (!fi.exists()) {
return false;
}
App::ProjectFile project(fi.absoluteFilePath().toStdString());
return project.loadDocument();
}
DocumentRecoveryPrivate::XmlConfig DocumentRecoveryPrivate::readXmlFile(const QString& fn) const
{
DocumentRecoveryPrivate::XmlConfig cfg;
+1
View File
@@ -120,6 +120,7 @@
#include "Dialogs/DlgObjectSelection.h"
#include <Base/Color.h>
#include "QtWidgets.h"
FC_LOG_LEVEL_INIT("MainWindow",false,true,true)
+8 -8
View File
@@ -319,10 +319,10 @@ NavigationStyle::~NavigationStyle()
finalize();
delete this->animator;
if (pythonObject) {
if (!pythonObject.is(nullptr)) {
Base::PyGILStateLocker lock;
Py_DECREF(pythonObject);
pythonObject = nullptr;
Base::PyObjectBase* obj = static_cast<Base::PyObjectBase*>(pythonObject.ptr());
obj->setInvalid();
}
}
@@ -1914,11 +1914,11 @@ void NavigationStyle::openPopupMenu(const SbVec2s& position)
PyObject* NavigationStyle::getPyObject()
{
if (!pythonObject)
pythonObject = new NavigationStylePy(this);
Py_INCREF(pythonObject);
return pythonObject;
if (pythonObject.is(nullptr)) {
// ref counter is set to 1
pythonObject = Py::asObject(new NavigationStylePy(this));
}
return Py::new_reference_to(pythonObject);
}
// ----------------------------------------------------------------------------------
+2 -1
View File
@@ -37,6 +37,7 @@
#include <QEvent>
#include <Base/BaseClass.h>
#include <Base/SmartPtrPy.h>
#include <Gui/Namespace.h>
#include <FCGlobal.h>
#include <memory>
@@ -283,7 +284,7 @@ protected:
SbSphereSheetProjector * spinprojector;
//@}
PyObject* pythonObject;
Py::SmartPtr pythonObject;
private:
friend class NavigationAnimator;
+1 -21
View File
@@ -243,27 +243,7 @@ void PythonEditor::onComment()
void PythonEditor::onUncomment()
{
QTextCursor cursor = textCursor();
int selStart = cursor.selectionStart();
int selEnd = cursor.selectionEnd();
QTextBlock block;
cursor.beginEditBlock();
for (block = document()->begin(); block.isValid(); block = block.next()) {
int pos = block.position();
int off = block.length()-1;
// at least one char of the block is part of the selection
if ( pos >= selStart || pos+off >= selStart) {
if ( pos+1 > selEnd )
break; // end of selection reached
if (block.text().startsWith(QLatin1String("#"))) {
cursor.setPosition(block.position());
cursor.deleteChar();
selEnd--;
}
}
}
cursor.endEditBlock();
remove(QStringLiteral("#"));
}
void PythonEditor::onExecuteInConsole()
+30 -10
View File
@@ -728,16 +728,39 @@ void TaskTransformDialog::open()
Gui::TaskView::TaskDialog::open();
Gui::Application::Instance->activeDocument()->openCommand(
QT_TRANSLATE_NOOP("Command", "Transform"));
openCommand();
}
void TaskTransformDialog::openCommand()
{
if (auto document = vp->getDocument()) {
if (!document->hasPendingCommand()) {
document->openCommand(QT_TRANSLATE_NOOP("Command", "Transform"));
}
}
}
void TaskTransformDialog::updateDraggerPlacement()
{
const auto placement = vp->getObjectPlacement();
vp->setDraggerPlacement(placement);
}
void TaskTransformDialog::onUndo()
{
updateDraggerPlacement();
openCommand();
}
void TaskTransformDialog::onRedo()
{
updateDraggerPlacement();
openCommand();
}
bool TaskTransformDialog::accept()
{
if (auto documentObject = vp->getObject()) {
Gui::Document* document =
Gui::Application::Instance->getDocument(documentObject->getDocument());
assert(document);
if (auto document = vp->getDocument()) {
document->commitCommand();
document->resetEdit();
document->getDocument()->recompute();
@@ -748,10 +771,7 @@ bool TaskTransformDialog::accept()
bool TaskTransformDialog::reject()
{
if (auto documentObject = vp->getObject()) {
Gui::Document* document =
Gui::Application::Instance->getDocument(documentObject->getDocument());
assert(document);
if (auto document = vp->getDocument()) {
document->abortCommand();
document->resetEdit();
document->getDocument()->recompute();
+6
View File
@@ -166,6 +166,12 @@ public:
void open() override;
bool accept() override;
bool reject() override;
void onUndo() override;
void onRedo() override;
private:
void openCommand();
void updateDraggerPlacement();
private:
ViewProviderDragger* vp;
+10
View File
@@ -172,6 +172,16 @@ void TaskDialog::helpRequested()
}
void TaskDialog::onUndo()
{
}
void TaskDialog::onRedo()
{
}
+5 -1
View File
@@ -162,8 +162,12 @@ public:
virtual bool accept();
/// is called by the framework if the dialog is rejected (Cancel)
virtual bool reject();
/// is called by the framework if the user press the help button
/// is called by the framework if the user press the help button
virtual void helpRequested();
/// is called by the framework if the user press the undo button
virtual void onUndo();
/// is called by the framework if the user press the redo button
virtual void onRedo();
void emitDestructionSignal() {
Q_EMIT aboutToBeDestroyed();
+8 -4
View File
@@ -503,11 +503,15 @@ void TaskView::slotViewClosed(const Gui::MDIView* view)
}
}
void TaskView::transactionChangeOnDocument(const App::Document& doc)
void TaskView::transactionChangeOnDocument(const App::Document& doc, bool undo)
{
if (ActiveDialog) {
std::string name = ActiveDialog->getDocumentName();
if (name == doc.getName()) {
undo ? ActiveDialog->onUndo() : ActiveDialog->onRedo();
}
if (ActiveDialog->isAutoCloseOnTransactionChange()) {
std::string name = ActiveDialog->getDocumentName();
if (name.empty()) {
Base::Console().warning(std::string("TaskView::transactionChangeOnDocument"),
"No document name set\n");
@@ -527,12 +531,12 @@ void TaskView::transactionChangeOnDocument(const App::Document& doc)
void TaskView::slotUndoDocument(const App::Document& doc)
{
transactionChangeOnDocument(doc);
transactionChangeOnDocument(doc, true);
}
void TaskView::slotRedoDocument(const App::Document& doc)
{
transactionChangeOnDocument(doc);
transactionChangeOnDocument(doc, false);
}
/// @cond DOXERR
+1 -1
View File
@@ -187,7 +187,7 @@ private:
void slotViewClosed(const Gui::MDIView*);
void slotUndoDocument(const App::Document&);
void slotRedoDocument(const App::Document&);
void transactionChangeOnDocument(const App::Document&);
void transactionChangeOnDocument(const App::Document&, bool undo);
protected:
void keyPressEvent(QKeyEvent* event) override;
+33 -32
View File
@@ -519,6 +519,34 @@ void PythonTextEditor::prepend(const QString& str)
cursor.endEditBlock();
}
void PythonTextEditor::remove(const QString& str)
{
QTextCursor cursor = textCursor();
int selStart = cursor.selectionStart();
int selEnd = cursor.selectionEnd();
QTextBlock block;
cursor.beginEditBlock();
for (block = document()->begin(); block.isValid(); block = block.next()) {
int pos = block.position();
int off = block.length()-1;
// at least one char of the block is part of the selection
if ( pos >= selStart || pos+off >= selStart) {
if ( pos+1 > selEnd )
break; // end of selection reached
QString text = block.text();
if (text.startsWith(str)) {
cursor.setPosition(block.position());
for (int i = 0; i < str.length(); i++) {
cursor.deleteChar();
selEnd--;
}
}
}
}
cursor.endEditBlock();
}
void PythonTextEditor::keyPressEvent (QKeyEvent * e)
{
if ( e->key() == Qt::Key_Tab ) {
@@ -547,40 +575,13 @@ void PythonTextEditor::keyPressEvent (QKeyEvent * e)
// If some text is selected we remove a leading tab or
// spaces from each selected block
ParameterGrp::handle hPrefGrp = getWindowParameter();
bool space = hPrefGrp->GetBool("Spaces", true);
int indent = hPrefGrp->GetInt( "IndentSize", 4 );
QString ch = space ? QString(indent, QLatin1Char(' '))
: QStringLiteral("\t");
int selStart = cursor.selectionStart();
int selEnd = cursor.selectionEnd();
QTextBlock block;
cursor.beginEditBlock();
for (block = document()->begin(); block.isValid(); block = block.next()) {
int pos = block.position();
int off = block.length()-1;
// at least one char of the block is part of the selection
if ( pos >= selStart || pos+off >= selStart) {
if ( pos+1 > selEnd )
break; // end of selection reached
// if possible remove one tab or several spaces
QString text = block.text();
if (text.startsWith(QLatin1String("\t"))) {
cursor.setPosition(block.position());
cursor.deleteChar();
selEnd--;
}
else {
cursor.setPosition(block.position());
for (int i=0; i<indent; i++) {
if (!text.startsWith(QLatin1String(" ")))
break;
text = text.mid(1);
cursor.deleteChar();
selEnd--;
}
}
}
}
cursor.endEditBlock();
// if possible remove one tab or several spaces
remove(ch);
return;
}
+4
View File
@@ -144,6 +144,10 @@ public Q_SLOTS:
* nothing is selected
*/
void prepend(const QString& str);
/** Removes \a str from the beginning of each selected line or the current line if
* nothing is selected
*/
void remove(const QString& str);
protected:
void keyPressEvent(QKeyEvent *) override;
+8 -3
View File
@@ -137,9 +137,14 @@ ViewProvider::~ViewProvider()
ViewProvider *ViewProvider::startEditing(int ModNum)
{
if(setEdit(ModNum)) {
_iEditMode = ModNum;
return this;
try {
if (setEdit(ModNum)) {
_iEditMode = ModNum;
return this;
}
}
catch (const Base::Exception& e) {
e.reportException();
}
return nullptr;
}
+10 -3
View File
@@ -72,11 +72,18 @@ ViewProviderCoordinateSystem::~ViewProviderCoordinateSystem() {
std::vector<App::DocumentObject*> ViewProviderCoordinateSystem::claimChildren() const
{
return static_cast<App::Origin*>( getObject() )->OriginFeatures.getValues();
auto obj = getObject<App::Origin>();
std::vector<App::DocumentObject*> childs = obj->OriginFeatures.getValues();
auto it = std::find(childs.begin(), childs.end(), obj);
if (it != childs.end()) {
childs.erase(it);
}
return childs;
}
std::vector<App::DocumentObject*> ViewProviderCoordinateSystem::claimChildren3D() const {
return claimChildren ();
std::vector<App::DocumentObject*> ViewProviderCoordinateSystem::claimChildren3D() const
{
return claimChildren();
}
void ViewProviderCoordinateSystem::attach(App::DocumentObject* pcObject)
+6 -4
View File
@@ -2793,11 +2793,13 @@ ViewProvider *ViewProviderLink::startEditing(int mode) {
}
if (auto result = inherited::startEditing(mode)) {
transformDragger->addStartCallback(dragStartCallback, this);
transformDragger->addFinishCallback(dragFinishCallback, this);
transformDragger->addMotionCallback(dragMotionCallback, this);
if (transformDragger.get()) {
transformDragger->addStartCallback(dragStartCallback, this);
transformDragger->addFinishCallback(dragFinishCallback, this);
transformDragger->addMotionCallback(dragMotionCallback, this);
setDraggerPlacement(dragCtx->initialPlacement);
setDraggerPlacement(dragCtx->initialPlacement);
}
return result;
}
+22 -88
View File
@@ -358,105 +358,39 @@ void ActionSelector::onDownButtonClicked()
/**
* Constructs a line edit with no text.
* The \a parent argument is sent to the QLineEdit constructor.
* The \a parent argument is sent to the QKeySequenceEdit constructor.
*/
AccelLineEdit::AccelLineEdit ( QWidget * parent )
: QLineEdit(parent)
AccelLineEdit::AccelLineEdit(QWidget* parent)
: QKeySequenceEdit(parent)
{
setPlaceholderText(tr("Press a keyboard shortcut"));
setClearButtonEnabled(true);
keyPressedCount = 0;
if (auto le = findChild<QLineEdit*>()) {
le->setClearButtonEnabled(true);
}
}
bool AccelLineEdit::isNone() const
AccelLineEdit::AccelLineEdit(const QKeySequence& keySequence, QWidget* parent)
: QKeySequenceEdit(keySequence, parent)
{
return text().isEmpty();
if (auto le = findChild<QLineEdit*>()) {
le->setClearButtonEnabled(true);
}
}
/**
* Checks which keys are pressed and show it as text.
*/
void AccelLineEdit::keyPressEvent (QKeyEvent * e)
void AccelLineEdit::setReadOnly(bool value)
{
if (isReadOnly()) {
QLineEdit::keyPressEvent(e);
return;
if (auto le = findChild<QLineEdit*>()) {
le->setReadOnly(value);
}
}
QString txtLine = text();
bool AccelLineEdit::isEmpty() const
{
return keySequence().isEmpty();
}
int key = e->key();
Qt::KeyboardModifiers state = e->modifiers();
// Backspace clears the shortcut if text is present, else sets Backspace as shortcut.
// If a modifier is pressed without any other key, return.
// AltGr is not a modifier but doesn't have a QString representation.
switch(key) {
case Qt::Key_Backspace:
case Qt::Key_Delete:
if (state == Qt::NoModifier) {
keyPressedCount = 0;
if (isNone()) {
QKeySequence ks(key);
setText(ks.toString(QKeySequence::NativeText));
}
else {
clear();
}
}
case Qt::Key_Control:
case Qt::Key_Shift:
case Qt::Key_Alt:
case Qt::Key_Meta:
case Qt::Key_AltGr:
return;
default:
break;
}
if (txtLine.isEmpty()) {
// Text maybe cleared by QLineEdit's built in clear button
keyPressedCount = 0;
} else {
// 4 keys are allowed for QShortcut
switch (keyPressedCount) {
case 4:
keyPressedCount = 0;
txtLine.clear();
break;
case 0:
txtLine.clear();
break;
default:
txtLine += QStringLiteral(",");
break;
}
}
// Handles modifiers applying a mask.
if ((state & Qt::ControlModifier) == Qt::ControlModifier) {
QKeySequence ks(Qt::CTRL);
txtLine += ks.toString(QKeySequence::NativeText);
}
if ((state & Qt::AltModifier) == Qt::AltModifier) {
QKeySequence ks(Qt::ALT);
txtLine += ks.toString(QKeySequence::NativeText);
}
if ((state & Qt::ShiftModifier) == Qt::ShiftModifier) {
QKeySequence ks(Qt::SHIFT);
txtLine += ks.toString(QKeySequence::NativeText);
}
if ((state & Qt::MetaModifier) == Qt::MetaModifier) {
QKeySequence ks(Qt::META);
txtLine += ks.toString(QKeySequence::NativeText);
}
// Handles normal keys
QKeySequence ks(key);
txtLine += ks.toString(QKeySequence::NativeText);
setText(txtLine);
keyPressedCount++;
QString AccelLineEdit::text() const
{
return keySequence().toString(QKeySequence::NativeText);
}
// ------------------------------------------------------------------------------
+7 -9
View File
@@ -31,6 +31,7 @@
#include <QButtonGroup>
#include <QDialog>
#include <QElapsedTimer>
#include <QKeySequenceEdit>
#include <QLabel>
#include <QLineEdit>
#include <QListWidget>
@@ -132,19 +133,16 @@ private:
* The AccelLineEdit class provides a lineedit to specify shortcuts.
* \author Werner Mayer
*/
class GuiExport AccelLineEdit : public QLineEdit
class GuiExport AccelLineEdit : public QKeySequenceEdit
{
Q_OBJECT
public:
AccelLineEdit(QWidget * parent=nullptr);
bool isNone() const;
protected:
void keyPressEvent(QKeyEvent * e) override;
private:
int keyPressedCount;
explicit AccelLineEdit(QWidget* parent = nullptr);
explicit AccelLineEdit(const QKeySequence& keySequence, QWidget* parent = nullptr);
void setReadOnly(bool value);
bool isEmpty() const;
QString text() const;
};
// ------------------------------------------------------------------------------
+18 -9
View File
@@ -463,6 +463,9 @@ void Workbench::removeTaskWatcher()
std::list<std::string> Workbench::listToolbars() const
{
std::unique_ptr<ToolBarItem> tb(setupToolBars());
setupCustomToolbars(tb.get(), "Toolbar");
WorkbenchManipulator::changeToolBars(tb.get());
std::list<std::string> bars;
QList<ToolBarItem*> items = tb->getItems();
for (const auto & item : items) {
@@ -474,6 +477,8 @@ std::list<std::string> Workbench::listToolbars() const
std::list<std::pair<std::string, std::list<std::string>>> Workbench::getToolbarItems() const
{
std::unique_ptr<ToolBarItem> tb(setupToolBars());
setupCustomToolbars(tb.get(), "Toolbar");
WorkbenchManipulator::changeToolBars(tb.get());
std::list<std::pair<std::string, std::list<std::string>>> itemsList;
QList<ToolBarItem*> items = tb->getItems();
@@ -492,6 +497,9 @@ std::list<std::pair<std::string, std::list<std::string>>> Workbench::getToolbarI
std::list<std::string> Workbench::listMenus() const
{
std::unique_ptr<MenuItem> mb(setupMenuBar());
addPermanentMenuItems(mb.get());
WorkbenchManipulator::changeMenuBar(mb.get());
std::list<std::string> menus;
QList<MenuItem*> items = mb->getItems();
for (const auto & item : items) {
@@ -852,13 +860,13 @@ ToolBarItem* StdWorkbench::setupCommandBars() const
DockWindowItems* StdWorkbench::setupDockWindows() const
{
auto root = new DockWindowItems();
root->addDockWidget("Std_TreeView", Qt::LeftDockWidgetArea, true, false);
root->addDockWidget("Std_PropertyView", Qt::LeftDockWidgetArea, true, false);
root->addDockWidget("Std_SelectionView", Qt::LeftDockWidgetArea, false, false);
root->addDockWidget("Std_ComboView", Qt::LeftDockWidgetArea, true, true);
root->addDockWidget("Std_TaskView", Qt::LeftDockWidgetArea, true, true);
root->addDockWidget("Std_ReportView", Qt::BottomDockWidgetArea, false, true);
root->addDockWidget("Std_PythonView", Qt::BottomDockWidgetArea, false, true);
root->addDockWidget("Std_TreeView", Qt::LeftDockWidgetArea, Gui::DockWindowOption::Visible);
root->addDockWidget("Std_PropertyView", Qt::LeftDockWidgetArea, Gui::DockWindowOption::Visible);
root->addDockWidget("Std_SelectionView", Qt::LeftDockWidgetArea, Gui::DockWindowOption::Hidden);
root->addDockWidget("Std_ComboView", Qt::LeftDockWidgetArea, Gui::DockWindowOption::VisibleTabbed);
root->addDockWidget("Std_TaskView", Qt::LeftDockWidgetArea, Gui::DockWindowOption::VisibleTabbed);
root->addDockWidget("Std_ReportView", Qt::BottomDockWidgetArea, Gui::DockWindowOption::HiddenTabbed);
root->addDockWidget("Std_PythonView", Qt::BottomDockWidgetArea, Gui::DockWindowOption::HiddenTabbed);
//Dagview through parameter.
ParameterGrp::handle group = App::GetApplication().GetUserParameter().
@@ -866,7 +874,7 @@ DockWindowItems* StdWorkbench::setupDockWindows() const
bool enabled = group->GetBool("Enabled", false);
if (enabled) {
root->addDockWidget("Std_DAGView", Qt::RightDockWidgetArea, false, false);
root->addDockWidget("Std_DAGView", Qt::RightDockWidgetArea, Gui::DockWindowOption::Hidden);
}
return root;
@@ -987,7 +995,7 @@ ToolBarItem* NoneWorkbench::setupCommandBars() const
DockWindowItems* NoneWorkbench::setupDockWindows() const
{
auto root = new DockWindowItems();
root->addDockWidget("Std_ReportView", Qt::BottomDockWidgetArea, true, false);
root->addDockWidget("Std_ReportView", Qt::BottomDockWidgetArea, Gui::DockWindowOption::Visible);
return root;
}
@@ -1049,6 +1057,7 @@ PythonBaseWorkbench::~PythonBaseWorkbench()
delete _toolBar;
delete _commandBar;
if (_workbenchPy) {
Base::PyGILStateLocker lock;
_workbenchPy->setInvalid();
_workbenchPy->DecRef();
}
+34 -42
View File
@@ -3752,37 +3752,33 @@ void PropertyMaterialItem::setValue(const QVariant& value)
auto mat = value.value<Material>();
Base::Color dc;
dc.setValue<QColor>(mat.diffuseColor);
uint32_t dcp = dc.getPackedValue();
Base::Color ac;
ac.setValue<QColor>(mat.ambientColor);
uint32_t acp = ac.getPackedValue();
Base::Color sc;
sc.setValue<QColor>(mat.specularColor);
uint32_t scp = sc.getPackedValue();
Base::Color ec;
ec.setValue<QColor>(mat.emissiveColor);
uint32_t ecp = ec.getPackedValue();
float s = mat.shininess;
float t = mat.transparency;
QString data = QStringLiteral("App.Material("
"DiffuseColor=(%1,%2,%3),"
"AmbientColor=(%4,%5,%6),"
"SpecularColor=(%7,%8,%9),"
"EmissiveColor=(%10,%11,%12),"
"Shininess=(%13),"
"Transparency=(%14),"
")")
.arg(dc.r, 0, 'f', decimals())
.arg(dc.g, 0, 'f', decimals())
.arg(dc.b, 0, 'f', decimals())
.arg(ac.r, 0, 'f', decimals())
.arg(ac.g, 0, 'f', decimals())
.arg(ac.b, 0, 'f', decimals())
.arg(sc.r, 0, 'f', decimals())
.arg(sc.g, 0, 'f', decimals())
.arg(sc.b, 0, 'f', decimals())
.arg(ec.r, 0, 'f', decimals())
.arg(ec.g, 0, 'f', decimals())
.arg(ec.b, 0, 'f', decimals())
.arg(s, 0, 'f', decimals())
.arg(t, 0, 'f', decimals());
"DiffuseColor = %1,"
"AmbientColor = %2,"
"SpecularColor = %3,"
"EmissiveColor = %4,"
"Shininess = %5,"
"Transparency = %6,"
")")
.arg(dcp)
.arg(acp)
.arg(scp)
.arg(ecp)
.arg(s, 0, 'f', 10)
.arg(t, 0, 'f', 10);
setPropertyValue(data);
}
@@ -4258,37 +4254,33 @@ void PropertyMaterialListItem::setValue(const QVariant& value)
auto mat = list[0].value<Material>();
Base::Color dc;
dc.setValue<QColor>(mat.diffuseColor);
uint32_t dcp = dc.getPackedValue();
Base::Color ac;
ac.setValue<QColor>(mat.ambientColor);
uint32_t acp = ac.getPackedValue();
Base::Color sc;
sc.setValue<QColor>(mat.specularColor);
uint32_t scp = sc.getPackedValue();
Base::Color ec;
ec.setValue<QColor>(mat.emissiveColor);
uint32_t ecp = ec.getPackedValue();
float s = mat.shininess;
float t = mat.transparency;
QString item = QStringLiteral("App.Material("
"DiffuseColor=(%1,%2,%3),"
"AmbientColor=(%4,%5,%6),"
"SpecularColor=(%7,%8,%9),"
"EmissiveColor=(%10,%11,%12),"
"Shininess=(%13),"
"Transparency=(%14),"
")")
.arg(dc.r, 0, 'f', decimals())
.arg(dc.g, 0, 'f', decimals())
.arg(dc.b, 0, 'f', decimals())
.arg(ac.r, 0, 'f', decimals())
.arg(ac.g, 0, 'f', decimals())
.arg(ac.b, 0, 'f', decimals())
.arg(sc.r, 0, 'f', decimals())
.arg(sc.g, 0, 'f', decimals())
.arg(sc.b, 0, 'f', decimals())
.arg(ec.r, 0, 'f', decimals())
.arg(ec.g, 0, 'f', decimals())
.arg(ec.b, 0, 'f', decimals())
.arg(s, 0, 'f', decimals())
.arg(t, 0, 'f', decimals());
"DiffuseColor = %1,"
"AmbientColor = %2,"
"SpecularColor = %3,"
"EmissiveColor = %4,"
"Shininess = %5,"
"Transparency = %6,"
")")
.arg(dcp)
.arg(acp)
.arg(scp)
.arg(ecp)
.arg(s, 0, 'f', 10)
.arg(t, 0, 'f', 10);
str << item << ")";
setPropertyValue(data);
+2 -2
View File
@@ -29,7 +29,7 @@
#include <App/Document.h>
#include <Base/Console.h>
#include <Base/Exception.h>
#include <Gui/Command.h>
#include <Gui/CommandT.h>
#include "ViewProvider.h"
@@ -50,7 +50,7 @@ bool ViewProviderPart::doubleClicked()
try {
QString text = QObject::tr("Edit %1").arg(QString::fromUtf8(getObject()->Label.getValue()));
Gui::Command::openCommand(text.toUtf8());
FCMD_SET_EDIT(pcObject);
Gui::cmdSetEdit(pcObject);
return true;
}
catch (const Base::Exception& e) {
+2 -2
View File
@@ -34,7 +34,7 @@
#include <App/Document.h>
#include <Gui/Application.h>
#include <Gui/BitmapFactory.h>
#include <Gui/Command.h>
#include <Gui/CommandT.h>
#include <Gui/Control.h>
#include <Gui/Document.h>
#include <Gui/MainWindow.h>
@@ -63,7 +63,7 @@ bool ViewProvider::doubleClicked()
try {
QString text = QObject::tr("Edit %1").arg(QString::fromUtf8(getObject()->Label.getValue()));
Gui::Command::openCommand(text.toUtf8());
FCMD_SET_EDIT(pcObject);
Gui::cmdSetEdit(pcObject);
}
catch (const Base::Exception&) {
Gui::Command::abortCommand();
+2 -2
View File
@@ -24,7 +24,7 @@
#include "PreCompiled.h"
#include <App/Document.h>
#include <Gui/Command.h>
#include <Gui/CommandT.h>
#include <Mod/PartDesign/App/FeatureBase.h>
#include "ViewProviderBase.h"
@@ -54,7 +54,7 @@ bool ViewProviderBase::doubleClicked()
std::string Msg("Edit ");
Msg += base->Label.getValue();
Gui::Command::openCommand(Msg.c_str());
FCMD_SET_EDIT(base);
Gui::cmdSetEdit(base);
}
catch (const Base::Exception&) {
Gui::Command::abortCommand();
+2 -2
View File
@@ -340,7 +340,7 @@ void CmdTechDrawToggleFrame::activated(int iMsg)
Gui::Action *action = this->getAction();
if (action) {
action->setChecked(!vpPage->getFrameState(), true);
action->setBlockedChecked(!vpPage->getFrameState());
}
}
@@ -358,7 +358,7 @@ bool CmdTechDrawToggleFrame::isActive()
Gui::Action* action = this->getAction();
if (action) {
action->setChecked(vpp && !vpp->getFrameState(), true);
action->setBlockedChecked(vpp && !vpp->getFrameState());
}
return true;
+11
View File
@@ -0,0 +1,11 @@
#ifndef FREECAD_QTWIDGETS_H
#define FREECAD_QTWIDGETS_H
#include <QtGlobal>
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) && QT_VERSION < QT_VERSION_CHECK(6,8,1)
# define HAS_QTBUG_129596
#endif
#endif // FREECAD_QTWIDGETS_H