fixes #0004244: Std_SetAppearance always appears on a corner of the secondary monitor
This commit is contained in:
@@ -1078,17 +1078,26 @@ StdCmdSetAppearance::StdCmdSetAppearance()
|
||||
void StdCmdSetAppearance::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
#if 0
|
||||
static QPointer<QDialog> dlg = 0;
|
||||
if (!dlg)
|
||||
dlg = new Gui::Dialog::DlgDisplayPropertiesImp(getMainWindow());
|
||||
dlg = new Gui::Dialog::DlgDisplayPropertiesImp(true, getMainWindow());
|
||||
dlg->setModal(false);
|
||||
dlg->setAttribute(Qt::WA_DeleteOnClose);
|
||||
dlg->show();
|
||||
#else
|
||||
Gui::Control().showDialog(new Gui::Dialog::TaskDisplayProperties());
|
||||
#endif
|
||||
}
|
||||
|
||||
bool StdCmdSetAppearance::isActive(void)
|
||||
{
|
||||
#if 0
|
||||
return Gui::Selection().size() != 0;
|
||||
#else
|
||||
return (Gui::Control().activeDialog() == nullptr) &&
|
||||
(Gui::Selection().size() != 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
||||
@@ -64,6 +64,7 @@ class DlgDisplayPropertiesImp::Private
|
||||
typedef boost::signals2::connection DlgDisplayPropertiesImp_Connection;
|
||||
public:
|
||||
Ui::DlgDisplayProperties ui;
|
||||
bool floating;
|
||||
DlgDisplayPropertiesImp_Connection connectChangedObject;
|
||||
};
|
||||
|
||||
@@ -74,7 +75,7 @@ public:
|
||||
* The dialog will by default be modeless, unless you set 'modal' to
|
||||
* true to construct a modal dialog.
|
||||
*/
|
||||
DlgDisplayPropertiesImp::DlgDisplayPropertiesImp(QWidget* parent, Qt::WindowFlags fl)
|
||||
DlgDisplayPropertiesImp::DlgDisplayPropertiesImp(bool floating, QWidget* parent, Qt::WindowFlags fl)
|
||||
: QDialog( parent, fl )
|
||||
, d(new Private)
|
||||
{
|
||||
@@ -83,6 +84,7 @@ DlgDisplayPropertiesImp::DlgDisplayPropertiesImp(QWidget* parent, Qt::WindowFlag
|
||||
d->ui.changePlot->hide();
|
||||
d->ui.buttonLineColor->setModal(false);
|
||||
d->ui.buttonColor->setModal(false);
|
||||
d->floating = floating;
|
||||
|
||||
std::vector<Gui::ViewProvider*> views = getSelection();
|
||||
setDisplayModes(views);
|
||||
@@ -97,11 +99,13 @@ DlgDisplayPropertiesImp::DlgDisplayPropertiesImp(QWidget* parent, Qt::WindowFlag
|
||||
setLineTransparency(views);
|
||||
|
||||
// embed this dialog into a dockable widget container
|
||||
Gui::DockWindowManager* pDockMgr = Gui::DockWindowManager::instance();
|
||||
QDockWidget* dw = pDockMgr->addDockWindow("Display properties", this, Qt::AllDockWidgetAreas);
|
||||
dw->setFeatures(QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable);
|
||||
dw->setFloating(true);
|
||||
dw->show();
|
||||
if (floating) {
|
||||
Gui::DockWindowManager* pDockMgr = Gui::DockWindowManager::instance();
|
||||
QDockWidget* dw = pDockMgr->addDockWindow("Display properties", this, Qt::AllDockWidgetAreas);
|
||||
dw->setFeatures(QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable);
|
||||
dw->setFloating(true);
|
||||
dw->show();
|
||||
}
|
||||
|
||||
Gui::Selection().Attach(this);
|
||||
|
||||
@@ -120,6 +124,11 @@ DlgDisplayPropertiesImp::~DlgDisplayPropertiesImp()
|
||||
Gui::Selection().Detach(this);
|
||||
}
|
||||
|
||||
void DlgDisplayPropertiesImp::showDefaultButtons(bool ok)
|
||||
{
|
||||
d->ui.buttonBox->setVisible(ok);
|
||||
}
|
||||
|
||||
void DlgDisplayPropertiesImp::changeEvent(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
@@ -224,9 +233,11 @@ void DlgDisplayPropertiesImp::slotChangedObject(const Gui::ViewProvider& obj,
|
||||
*/
|
||||
void DlgDisplayPropertiesImp::reject()
|
||||
{
|
||||
// closes the dock window
|
||||
Gui::DockWindowManager* pDockMgr = Gui::DockWindowManager::instance();
|
||||
pDockMgr->removeDockWindow(this);
|
||||
if (d->floating) {
|
||||
// closes the dock window
|
||||
Gui::DockWindowManager* pDockMgr = Gui::DockWindowManager::instance();
|
||||
pDockMgr->removeDockWindow(this);
|
||||
}
|
||||
QDialog::reject();
|
||||
}
|
||||
|
||||
@@ -626,5 +637,35 @@ std::vector<Gui::ViewProvider*> DlgDisplayPropertiesImp::getSelection() const
|
||||
return views;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/* TRANSLATOR Gui::Dialog::TaskDisplayProperties */
|
||||
|
||||
TaskDisplayProperties::TaskDisplayProperties()
|
||||
{
|
||||
this->setButtonPosition(TaskDisplayProperties::South);
|
||||
widget = new DlgDisplayPropertiesImp(false);
|
||||
widget->showDefaultButtons(false);
|
||||
taskbox = new Gui::TaskView::TaskBox(QPixmap(), widget->windowTitle(),true, 0);
|
||||
taskbox->groupLayout()->addWidget(widget);
|
||||
Content.push_back(taskbox);
|
||||
}
|
||||
|
||||
TaskDisplayProperties::~TaskDisplayProperties()
|
||||
{
|
||||
// automatically deleted in the sub-class
|
||||
}
|
||||
|
||||
QDialogButtonBox::StandardButtons TaskDisplayProperties::getStandardButtons() const
|
||||
{
|
||||
return QDialogButtonBox::Close;
|
||||
}
|
||||
|
||||
bool TaskDisplayProperties::reject()
|
||||
{
|
||||
widget->reject();
|
||||
return (widget->result() == QDialog::Rejected);
|
||||
}
|
||||
|
||||
#include "moc_DlgDisplayPropertiesImp.cpp"
|
||||
|
||||
|
||||
@@ -28,7 +28,9 @@
|
||||
#include <vector>
|
||||
#include <QDialog>
|
||||
|
||||
#include "Selection.h"
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/TaskView/TaskDialog.h>
|
||||
#include <Gui/TaskView/TaskView.h>
|
||||
#include <App/Material.h>
|
||||
|
||||
namespace App
|
||||
@@ -54,11 +56,13 @@ class DlgDisplayPropertiesImp : public QDialog,
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DlgDisplayPropertiesImp(QWidget* parent = nullptr, Qt::WindowFlags fl = 0);
|
||||
DlgDisplayPropertiesImp(bool floating, QWidget* parent = nullptr, Qt::WindowFlags fl = 0);
|
||||
~DlgDisplayPropertiesImp();
|
||||
/// Observer message from the Selection
|
||||
void OnChange(Gui::SelectionSingleton::SubjectType &rCaller,
|
||||
Gui::SelectionSingleton::MessageType Reason);
|
||||
void showDefaultButtons(bool);
|
||||
void reject();
|
||||
|
||||
private Q_SLOTS:
|
||||
void on_changeMaterial_activated(int);
|
||||
@@ -78,7 +82,6 @@ protected:
|
||||
|
||||
private:
|
||||
void slotChangedObject(const Gui::ViewProvider&, const App::Property& Prop);
|
||||
void reject();
|
||||
void setDisplayModes(const std::vector<ViewProvider*>&);
|
||||
void setMaterial(const std::vector<ViewProvider*>&);
|
||||
void setColorPlot(const std::vector<ViewProvider*>&);
|
||||
@@ -96,6 +99,30 @@ private:
|
||||
std::unique_ptr<Private> d;
|
||||
};
|
||||
|
||||
class TaskDisplayProperties : public Gui::TaskView::TaskDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TaskDisplayProperties();
|
||||
~TaskDisplayProperties();
|
||||
|
||||
public:
|
||||
bool reject();
|
||||
|
||||
bool isAllowedAlterDocument(void) const
|
||||
{ return true; }
|
||||
bool isAllowedAlterView(void) const
|
||||
{ return true; }
|
||||
bool isAllowedAlterSelection(void) const
|
||||
{ return true; }
|
||||
QDialogButtonBox::StandardButtons getStandardButtons() const;
|
||||
|
||||
private:
|
||||
DlgDisplayPropertiesImp* widget;
|
||||
Gui::TaskView::TaskBox* taskbox;
|
||||
};
|
||||
|
||||
} // namespace Dialog
|
||||
} // namespace Gui
|
||||
|
||||
|
||||
Reference in New Issue
Block a user