Resize Edit Profile dialog only when possible

Summary:
Initial window width is set to be wider than (default) minimum possible
size. This adds some whitespace and increases width of text inputs
on "tabs" page.

This was made unconditionally, which could increase the width past
screen's right edge on small screens.

It is changed to be at most 2/3 of the screen's width now. Note that
minimum window size is still in effect; the limit affects only
additional width.

Test Plan:
(Instructions for X11)

* Run `Xephyr -dpi 96 -screen 800x600 :1`
* Run `DISPLAY=:1 kwin_x11`
* Run `DISPLAY=:1 ./konsole`
* Open edit profile dialog, resize it to minimum allowable size.
* Measure the window size.
* Close Xephyr.
* Run `Xephyr -dpi 96 -screen WxH :1`, where `W` is the measured window
  width + 20, and `H` is anything larger than measured height.
* Run `DISPLAY=:1 kwin_x11`
* Run `DISPLAY=:1 ./konsole`
* Open edit profile dialog

**Expected result:**
Edit Profile dialog's width should be a bit smaller than Xephyr's
screen

Reviewers: #konsole, hindenburg

Reviewed By: #konsole, hindenburg

Subscribers: hindenburg, konsole-devel

Tags: #konsole

Differential Revision: https://phabricator.kde.org/D19400
wilder-portage
Mariusz Glebocki 7 years ago committed by Kurt Hindenburg
parent 5a5da130c1
commit 8847626993
  1. 16
      src/EditProfileDialog.cpp

@ -215,12 +215,6 @@ EditProfileDialog::EditProfileDialog(QWidget *parent)
connect(this, &KPageDialog::currentPageChanged,
this, &Konsole::EditProfileDialog::preparePage);
QFontMetrics fm(font());
const int ch = fm.width(QLatin1Char('0'));
// Increase width a bit instead of using possible minimum
resize(sizeHint().width() + 10*ch, sizeHint().height());
createTempProfile();
}
@ -953,8 +947,14 @@ bool EditProfileDialog::eventFilter(QObject *watched, QEvent *event)
QSize EditProfileDialog::sizeHint() const
{
// return QSize();
return QDialog::sizeHint();
QFontMetrics fm(font());
const int ch = fm.width(QLatin1Char('0'));
// By default minimum size is used. Increase it to make text inputs
// on "tabs" page wider and to add some whitespace on right side
// of other pages. The window will not be wider than 2/3 of
// the screen width (unless necessary to fit everything)
return QDialog::sizeHint() + QSize(10*ch, 0);
}
void EditProfileDialog::unpreviewAll()

Loading…
Cancel
Save