Skip to content
Snippets Groups Projects
Commit 571cc5a1 authored by Pospelov, Gennady's avatar Pospelov, Gennady
Browse files

Resizable modal dialogs on Mac

parent 8997e662
No related branches found
No related tags found
No related merge requests found
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "DistributionDialog.h" #include "DistributionDialog.h"
#include "DistributionEditor.h" #include "DistributionEditor.h"
#include "SessionItem.h" #include "SessionItem.h"
#include "StyleUtils.h"
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QPushButton> #include <QPushButton>
...@@ -45,6 +46,7 @@ DistributionDialog::DistributionDialog(QWidget *parent) ...@@ -45,6 +46,7 @@ DistributionDialog::DistributionDialog(QWidget *parent)
setLayout(layout); setLayout(layout);
setAttribute(Qt::WA_DeleteOnClose, true); setAttribute(Qt::WA_DeleteOnClose, true);
StyleUtils::setResizable(this);
} }
void DistributionDialog::setItem(SessionItem *item) void DistributionDialog::setItem(SessionItem *item)
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "mainwindow_constants.h" #include "mainwindow_constants.h"
#include "ExternalProperty.h" #include "ExternalProperty.h"
#include "MaterialItemUtils.h" #include "MaterialItemUtils.h"
#include "StyleUtils.h"
#include <QAction> #include <QAction>
#include <QPushButton> #include <QPushButton>
#include <QSettings> #include <QSettings>
...@@ -46,6 +47,8 @@ MaterialEditorDialog::MaterialEditorDialog(MaterialModel* materialModel, QWidget ...@@ -46,6 +47,8 @@ MaterialEditorDialog::MaterialEditorDialog(MaterialModel* materialModel, QWidget
layout->addLayout(createButtonLayout()); layout->addLayout(createButtonLayout());
setLayout(layout); setLayout(layout);
StyleUtils::setResizable(this);
} }
//! replaces original material model with the model modified by MaterialEditor //! replaces original material model with the model modified by MaterialEditor
......
...@@ -156,7 +156,7 @@ QWidget* createCustomDoubleEditor(const SessionItem& item) ...@@ -156,7 +156,7 @@ QWidget* createCustomDoubleEditor(const SessionItem& item)
result->setKeyboardTracking(true); result->setKeyboardTracking(true);
result->setFocusPolicy(Qt::StrongFocus); result->setFocusPolicy(Qt::StrongFocus);
result->installEventFilter(new WheelEventEater(result)); // result->installEventFilter(new WheelEventEater(result));
result->setMaximum(std::numeric_limits<double>::max()); result->setMaximum(std::numeric_limits<double>::max());
result->setMinimum(std::numeric_limits<double>::lowest()); result->setMinimum(std::numeric_limits<double>::lowest());
...@@ -178,7 +178,7 @@ QWidget* createCustomIntEditor(const SessionItem& item) ...@@ -178,7 +178,7 @@ QWidget* createCustomIntEditor(const SessionItem& item)
{ {
auto result = new QSpinBox; auto result = new QSpinBox;
result->setFocusPolicy(Qt::StrongFocus); result->setFocusPolicy(Qt::StrongFocus);
result->installEventFilter(new WheelEventEater(result)); // result->installEventFilter(new WheelEventEater(result));
result->setMaximum(std::numeric_limits<int>::max()); result->setMaximum(std::numeric_limits<int>::max());
result->setKeyboardTracking(true); result->setKeyboardTracking(true);
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "PythonSyntaxHighlighter.h" #include "PythonSyntaxHighlighter.h"
#include "WarningSign.h" #include "WarningSign.h"
#include "InstrumentItems.h" #include "InstrumentItems.h"
#include "StyleUtils.h"
#include <QFileDialog> #include <QFileDialog>
#include <QMessageBox> #include <QMessageBox>
#include <QPushButton> #include <QPushButton>
...@@ -74,6 +75,7 @@ PythonScriptWidget::PythonScriptWidget(QWidget *parent) ...@@ -74,6 +75,7 @@ PythonScriptWidget::PythonScriptWidget(QWidget *parent)
setLayout(mainLayout); setLayout(mainLayout);
setAttribute(Qt::WA_DeleteOnClose, true); setAttribute(Qt::WA_DeleteOnClose, true);
StyleUtils::setResizable(this);
} }
void PythonScriptWidget::generatePythonScript(const MultiLayerItem *sampleItem, void PythonScriptWidget::generatePythonScript(const MultiLayerItem *sampleItem,
......
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
#include "StyleUtils.h" #include "StyleUtils.h"
#include "DesignerHelper.h" #include "DesignerHelper.h"
#include "hostosinfo.h"
#include <QDialog>
#include <QTreeView> #include <QTreeView>
void StyleUtils::setPropertyStyle(QTreeView* tree) void StyleUtils::setPropertyStyle(QTreeView* tree)
...@@ -41,7 +43,7 @@ QString StyleUtils::propertyTreeStyle() ...@@ -41,7 +43,7 @@ QString StyleUtils::propertyTreeStyle()
"QTreeView::branch:open:has-children:!has-siblings," "QTreeView::branch:open:has-children:!has-siblings,"
"QTreeView::branch:open:has-children:has-siblings {" "QTreeView::branch:open:has-children:has-siblings {"
"padding:2px 2px 2px 2px;border-image: none; image: url(:/images/caret-down.svg);" "padding:2px 2px 2px 2px;border-image: none; image: url(:/images/caret-down.svg);"
"}"; "}";
// background of selected rows restored // background of selected rows restored
result += "QTreeView::item:selected{background:#3daee9;}"; result += "QTreeView::item:selected{background:#3daee9;}";
...@@ -51,19 +53,19 @@ QString StyleUtils::propertyTreeStyle() ...@@ -51,19 +53,19 @@ QString StyleUtils::propertyTreeStyle()
QString StyleUtils::realtimeTreeStyle() QString StyleUtils::realtimeTreeStyle()
{ {
QString result = QString result
"QTreeView::branch {background: " = "QTreeView::branch {background: "
"palette(base);}QTreeView::branch:has-siblings:!adjoins-item " "palette(base);}QTreeView::branch:has-siblings:!adjoins-item "
"{border-image: url(:/images/treeview-vline.png) 0;}QTreeView::branch:has-siblings:" "{border-image: url(:/images/treeview-vline.png) 0;}QTreeView::branch:has-siblings:"
"adjoins-item {border-image: url(:/images/treeview-branch-more.png) 0;}QTreeView::branch:" "adjoins-item {border-image: url(:/images/treeview-branch-more.png) 0;}QTreeView::branch:"
"!has-children:!has-siblings:adjoins-item {border-image: " "!has-children:!has-siblings:adjoins-item {border-image: "
"url(:/images/treeview-branch-end.png) " "url(:/images/treeview-branch-end.png) "
"0;}QTreeView::branch:has-children:!has-siblings:closed" "0;}QTreeView::branch:has-children:!has-siblings:closed"
",QTreeView::branch:closed:has-children:has-siblings {border-image: none;image: " ",QTreeView::branch:closed:has-children:has-siblings {border-image: none;image: "
"url(:/images/" "url(:/images/"
"treeview-branch-closed.png);}QTreeView::branch:open:has-children:!has-siblings," "treeview-branch-closed.png);}QTreeView::branch:open:has-children:!has-siblings,"
"QTreeView::branch:open:has-children:has-siblings {border-image: none;image: " "QTreeView::branch:open:has-children:has-siblings {border-image: none;image: "
"url(:/images/treeview-branch-open.png);}"; "url(:/images/treeview-branch-open.png);}";
return result; return result;
} }
...@@ -85,3 +87,12 @@ QFont StyleUtils::labelFont(bool bold) ...@@ -85,3 +87,12 @@ QFont StyleUtils::labelFont(bool bold)
return result; return result;
} }
void StyleUtils::setResizable(QDialog* dialog)
{
if (GUI_OS_Utils::HostOsInfo::isMacHost()) {
dialog->setWindowFlags(Qt::WindowCloseButtonHint | Qt::CustomizeWindowHint
| Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint
| Qt::Window);
}
}
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <QFont> #include <QFont>
class QTreeView; class QTreeView;
class QWidget;
namespace StyleUtils namespace StyleUtils
{ {
...@@ -39,6 +40,9 @@ BA_CORE_API_ QFont sectionFont(bool bold = false); ...@@ -39,6 +40,9 @@ BA_CORE_API_ QFont sectionFont(bool bold = false);
//! Returns font for labels. //! Returns font for labels.
BA_CORE_API_ QFont labelFont(bool bold = false); BA_CORE_API_ QFont labelFont(bool bold = false);
//! Make modal dialog resizable.
BA_CORE_API_ void setResizable(QDialog* dialog);
} }
#endif #endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment