diff --git a/src/Gui/DlgPreferences.ui b/src/Gui/DlgPreferences.ui
index 844f91547f..bdee77dad0 100644
--- a/src/Gui/DlgPreferences.ui
+++ b/src/Gui/DlgPreferences.ui
@@ -13,7 +13,7 @@
1000
- 600
+ 500
diff --git a/src/Gui/DlgPreferencesImp.cpp b/src/Gui/DlgPreferencesImp.cpp
index 4d9cc16d99..b19138dff1 100644
--- a/src/Gui/DlgPreferencesImp.cpp
+++ b/src/Gui/DlgPreferencesImp.cpp
@@ -39,6 +39,7 @@
# include
# include
# include
+# include
#endif
#include
@@ -690,6 +691,22 @@ void DlgPreferencesImp::restartIfRequired()
void DlgPreferencesImp::showEvent(QShowEvent* ev)
{
QDialog::showEvent(ev);
+
+ auto screen = windowHandle()->screen();
+ auto availableSize = screen->availableSize();
+
+ // leave at least 100 px of height so preferences window does not take
+ // entire screen height. User will still be able to resize the window,
+ // but it should never start too tall.
+ auto maxStartHeight = availableSize.height() - 100;
+
+ if (height() > maxStartHeight) {
+ auto heightDifference = availableSize.height() - maxStartHeight;
+
+ // resize and reposition window so it is fully visible
+ resize(width(), maxStartHeight);
+ move(x(), heightDifference / 2);
+ }
}
QModelIndex findRootIndex(const QModelIndex& index)