Commit 8b2b2667 authored by Urs Wolfer's avatar Urs Wolfer

Set proper minimum size of host preferences dialog. It looks like there is a...

Set proper minimum size of host preferences dialog. It looks like there is a workaround required im some cases. (+minor beautifications)

BUG:244539

svn path=/trunk/KDE/kdenetwork/krdc/; revision=1151008
parent 849a893c
......@@ -111,7 +111,7 @@ void HostPreferencesList::configureHost()
}
if (prefs) {
prefs->showDialog();
prefs->showDialog(this);
delete prefs;
} else {
KMessageBox::error(this,
......
/****************************************************************************
**
** Copyright (C) 2007 Urs Wolfer <uwolfer @ kde.org>
** Copyright (C) 2007 - 2010 Urs Wolfer <uwolfer @ kde.org>
**
** This file is part of KDE.
**
......@@ -155,32 +155,32 @@ void HostPreferences::setViewOnly(bool view)
{
m_configGroup.writeEntry("viewOnly", view);
}
bool HostPreferences::showDialogIfNeeded()
bool HostPreferences::showDialogIfNeeded(QWidget *parent)
{
if (hostConfigured()) {
if (showConfigAgain()) {
kDebug(5010) << "Show config dialog again";
return showDialog();
return showDialog(parent);
} else
return true; // no changes, no need to save
} else {
kDebug(5010) << "No config found, create new";
if (Settings::showPreferencesForNewConnections())
return showDialog();
return showDialog(parent);
else
return true;
}
}
bool HostPreferences::showDialog()
bool HostPreferences::showDialog(QWidget *parent)
{
// Prepare dialog
KDialog *dialog = new KDialog;
KDialog *dialog = new KDialog(parent);
dialog->setCaption(i18n("Host Configuration"));
QWidget *mainWidget = new QWidget(dialog);
QWidget *mainWidget = dialog->mainWidget();
QVBoxLayout *layout = new QVBoxLayout(mainWidget);
KTitleWidget *titleWidget = new KTitleWidget(dialog);
......@@ -193,7 +193,7 @@ bool HostPreferences::showDialog()
layout->addWidget(titleWidget);
QWidget* widget = createProtocolSpecificConfigPage();
if (widget) {
if (widget->layout())
widget->layout()->setMargin(0);
......@@ -212,10 +212,15 @@ bool HostPreferences::showDialog()
layout->addWidget(showAgainCheckBox);
layout->addWidget(walletSupportCheckBox);
layout->addStretch(1);
mainWidget->setLayout(layout);
dialog->setMainWidget(mainWidget);
// WORKAROUND: it seems that KDialog does not set the minimum size properly in some cases.
// see for example issue #244539. also it looks like KTitleWidget returns a too small size hint when a comment is shown.
QSize minimumSize = dialog->sizeHint();
if (m_connected) {
minimumSize += QSize(0, 50);
}
dialog->setMinimumSize(minimumSize);
// Show dialog
if (dialog->exec() == KDialog::Accepted) {
kDebug(5010) << "HostPreferences config dialog accepted";
......
......@@ -79,10 +79,10 @@ public:
* check "show this dialog again for this host".
* Returns true if user pressed ok.
*/
bool showDialogIfNeeded();
bool showDialogIfNeeded(QWidget *parent);
/** Show the configuration dialog */
bool showDialog();
bool showDialog(QWidget *parent);
/** If @p connected is true, a message is shown that settings might only apply after a reconnect. */
void setShownWhileConnected(bool connected);
......
/****************************************************************************
**
** Copyright (C) 2007 - 2009 Urs Wolfer <uwolfer @ kde.org>
** Copyright (C) 2007 - 2010 Urs Wolfer <uwolfer @ kde.org>
** Copyright (C) 2009 Tony Murray <murraytony @ gmail.com>
**
** This file is part of KDE.
......@@ -322,7 +322,7 @@ void MainWindow::newConnection(const KUrl &newUrl, bool switchFullscreenWhenConn
// Configure the view
HostPreferences* prefs = view->hostPreferences();
if (! prefs->showDialogIfNeeded()) {
if (! prefs->showDialogIfNeeded(this)) {
delete view;
return;
}
......@@ -645,8 +645,7 @@ void MainWindow::showSettingsDialog(const QString &url)
if (prefs) {
prefs->setShownWhileConnected(true);
prefs->showDialog();
delete prefs;
prefs->showDialog(this);
} else {
KMessageBox::error(this,
i18n("The selected host cannot be handled."),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment