Ported Dolphin from KDialog to QDialog and save/restoreDialogSize to KWindowConfig::save/restoreWindowSize with the help of the porting scripts.

REVIEW: 122305
This commit is contained in:
Emmanuel Pescosta 2015-02-03 09:25:33 +01:00
parent 122e1c6288
commit 3515582495
23 changed files with 153 additions and 148 deletions

View file

@ -51,7 +51,6 @@
#include <KConfig> #include <KConfig>
#include <kdeversion.h> #include <kdeversion.h>
#include <kdualaction.h> #include <kdualaction.h>
#include <KDialog>
#include <KJobWidgets> #include <KJobWidgets>
#include <QLineEdit> #include <QLineEdit>
#include <KToolBar> #include <KToolBar>
@ -78,6 +77,7 @@
#include <QPushButton> #include <QPushButton>
#include <QCloseEvent> #include <QCloseEvent>
#include <QShowEvent> #include <QShowEvent>
#include <QDialog>
namespace { namespace {
// Used for GeneralSettings::version() to determine whether // Used for GeneralSettings::version() to determine whether
@ -361,9 +361,9 @@ void DolphinMainWindow::closeEvent(QCloseEvent* event)
if (m_tabWidget->count() > 1 && GeneralSettings::confirmClosingMultipleTabs() && closedByUser) { if (m_tabWidget->count() > 1 && GeneralSettings::confirmClosingMultipleTabs() && closedByUser) {
// Ask the user if he really wants to quit and close all tabs. // Ask the user if he really wants to quit and close all tabs.
// Open a confirmation dialog with 3 buttons: // Open a confirmation dialog with 3 buttons:
// KDialog::Yes -> Quit // QDialogButtonBox::Yes -> Quit
// KDialog::No -> Close only the current tab // QDialogButtonBox::No -> Close only the current tab
// KDialog::Cancel -> do nothing // QDialogButtonBox::Cancel -> do nothing
QDialog *dialog = new QDialog(this, Qt::Dialog); QDialog *dialog = new QDialog(this, Qt::Dialog);
dialog->setWindowTitle(i18nc("@title:window", "Confirmation")); dialog->setWindowTitle(i18nc("@title:window", "Confirmation"));
dialog->setModal(true); dialog->setModal(true);
@ -969,7 +969,7 @@ void DolphinMainWindow::setUrlAsCaption(const QUrl& url)
caption.append(fileName); caption.append(fileName);
setCaption(caption); setWindowTitle(caption);
} }
void DolphinMainWindow::setupActions() void DolphinMainWindow::setupActions()

View file

@ -19,7 +19,6 @@
#include "informationpanelcontent.h" #include "informationpanelcontent.h"
#include <KDialog>
#include <KFileItem> #include <KFileItem>
#include <KIO/JobUiDelegate> #include <KIO/JobUiDelegate>
#include <KIO/PreviewJob> #include <KIO/PreviewJob>
@ -56,6 +55,7 @@
#include <QTimer> #include <QTimer>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QFontDatabase> #include <QFontDatabase>
#include <QStyle>
#include "dolphin_informationpanelsettings.h" #include "dolphin_informationpanelsettings.h"
#include "filemetadataconfigurationdialog.h" #include "filemetadataconfigurationdialog.h"
@ -86,7 +86,6 @@ InformationPanelContent::InformationPanelContent(QWidget* parent) :
this, &InformationPanelContent::markOutdatedPreview); this, &InformationPanelContent::markOutdatedPreview);
QVBoxLayout* layout = new QVBoxLayout(this); QVBoxLayout* layout = new QVBoxLayout(this);
layout->setSpacing(KDialog::spacingHint());
// preview // preview
const int minPreviewWidth = KIconLoader::SizeEnormous + KIconLoader::SizeMedium; const int minPreviewWidth = KIconLoader::SizeEnormous + KIconLoader::SizeMedium;
@ -423,7 +422,7 @@ void InformationPanelContent::adjustWidgetSizes(int width)
// so that the width of the information panel gets increased. // so that the width of the information panel gets increased.
// To prevent this, the maximum width is adjusted to // To prevent this, the maximum width is adjusted to
// the current width of the panel. // the current width of the panel.
const int maxWidth = width - KDialog::spacingHint() * 4; const int maxWidth = width - style()->layoutSpacing(QSizePolicy::DefaultType, QSizePolicy::DefaultType, Qt::Horizontal) * 4;
m_nameLabel->setMaximumWidth(maxWidth); m_nameLabel->setMaximumWidth(maxWidth);
// The metadata widget also contains a text widget which may return // The metadata widget also contains a text widget which may return

View file

@ -30,8 +30,7 @@
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QShowEvent> #include <QShowEvent>
#include <QToolButton> #include <QToolButton>
#include <QDialog>
#include <KDialog>
#include <QIcon> #include <QIcon>
#include <KIconLoader> #include <KIconLoader>
#include <QUrl> #include <QUrl>
@ -109,7 +108,7 @@ void PhononWidget::showEvent(QShowEvent *event)
if (!m_topLayout) { if (!m_topLayout) {
m_topLayout = new QVBoxLayout(this); m_topLayout = new QVBoxLayout(this);
m_topLayout->setMargin(0); m_topLayout->setMargin(0);
m_topLayout->setSpacing(KDialog::spacingHint());
QHBoxLayout *controlsLayout = new QHBoxLayout(this); QHBoxLayout *controlsLayout = new QHBoxLayout(this);
controlsLayout->setMargin(0); controlsLayout->setMargin(0);
controlsLayout->setSpacing(0); controlsLayout->setSpacing(0);

View file

@ -24,9 +24,14 @@
#include <KSharedConfig> #include <KSharedConfig>
#include <KLocalizedString> #include <KLocalizedString>
#include "kitemviews/kfileitemmodel.h" #include "kitemviews/kfileitemmodel.h"
#include <KConfigGroup>
#include <KWindowConfig>
#include <QCheckBox> #include <QCheckBox>
#include <QLabel> #include <QLabel>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QDialogButtonBox>
#include <QPushButton>
#ifdef HAVE_BALOO #ifdef HAVE_BALOO
#include <Baloo/IndexerConfig> #include <Baloo/IndexerConfig>
@ -34,21 +39,21 @@
AdditionalInfoDialog::AdditionalInfoDialog(QWidget* parent, AdditionalInfoDialog::AdditionalInfoDialog(QWidget* parent,
const QList<QByteArray>& visibleRoles) : const QList<QByteArray>& visibleRoles) :
KDialog(parent), QDialog(parent),
m_visibleRoles(visibleRoles), m_visibleRoles(visibleRoles),
m_listWidget(0) m_listWidget(0)
{ {
setCaption(i18nc("@title:window", "Additional Information")); setWindowTitle(i18nc("@title:window", "Additional Information"));
setButtons(Ok | Cancel); setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
setDefaultButton(Ok);
QWidget* mainWidget = new QWidget(this); auto layout = new QVBoxLayout(this);
mainWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); setLayout(layout);
// Add header // Add header
QLabel* header = new QLabel(mainWidget); auto header = new QLabel(this);
header->setText(i18nc("@label", "Select which additional information should be shown:")); header->setText(i18nc("@label", "Select which additional information should be shown:"));
header->setWordWrap(true); header->setWordWrap(true);
layout->addWidget(header);
// Add checkboxes // Add checkboxes
bool indexingEnabled = false; bool indexingEnabled = false;
@ -57,7 +62,7 @@ AdditionalInfoDialog::AdditionalInfoDialog(QWidget* parent,
indexingEnabled = config.fileIndexingEnabled(); indexingEnabled = config.fileIndexingEnabled();
#endif #endif
m_listWidget = new QListWidget(mainWidget); m_listWidget = new QListWidget(this);
m_listWidget->setSelectionMode(QAbstractItemView::NoSelection); m_listWidget->setSelectionMode(QAbstractItemView::NoSelection);
const QList<KFileItemModel::RoleInfo> rolesInfo = KFileItemModel::rolesInformation(); const QList<KFileItemModel::RoleInfo> rolesInfo = KFileItemModel::rolesInformation();
foreach (const KFileItemModel::RoleInfo& info, rolesInfo) { foreach (const KFileItemModel::RoleInfo& info, rolesInfo) {
@ -72,23 +77,25 @@ AdditionalInfoDialog::AdditionalInfoDialog(QWidget* parent,
item->setFlags(item->flags() & ~Qt::ItemIsEnabled); item->setFlags(item->flags() & ~Qt::ItemIsEnabled);
} }
} }
QVBoxLayout* layout = new QVBoxLayout(mainWidget);
layout->addWidget(header);
layout->addWidget(m_listWidget); layout->addWidget(m_listWidget);
setMainWidget(mainWidget); auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
connect(buttonBox, &QDialogButtonBox::accepted, this, &AdditionalInfoDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &AdditionalInfoDialog::reject);
layout->addWidget(buttonBox);
auto okButton = buttonBox->button(QDialogButtonBox::Ok);
okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
okButton->setDefault(true);
const KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"), "AdditionalInfoDialog"); const KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"), "AdditionalInfoDialog");
restoreDialogSize(dialogConfig); KWindowConfig::restoreWindowSize(windowHandle(), dialogConfig);
connect(this, &AdditionalInfoDialog::okClicked, this, &AdditionalInfoDialog::slotOk);
} }
AdditionalInfoDialog::~AdditionalInfoDialog() AdditionalInfoDialog::~AdditionalInfoDialog()
{ {
KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"), "AdditionalInfoDialog"); KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"), "AdditionalInfoDialog");
saveDialogSize(dialogConfig, KConfigBase::Persistent); KWindowConfig::saveWindowSize(windowHandle(), dialogConfig);
} }
QList<QByteArray> AdditionalInfoDialog::visibleRoles() const QList<QByteArray> AdditionalInfoDialog::visibleRoles() const
@ -96,7 +103,7 @@ QList<QByteArray> AdditionalInfoDialog::visibleRoles() const
return m_visibleRoles; return m_visibleRoles;
} }
void AdditionalInfoDialog::slotOk() void AdditionalInfoDialog::accept()
{ {
m_visibleRoles.clear(); m_visibleRoles.clear();
@ -109,5 +116,6 @@ void AdditionalInfoDialog::slotOk()
} }
++index; ++index;
} }
}
QDialog::accept();
}

View file

@ -20,7 +20,7 @@
#ifndef ADDITIONALINFODIALOG_H #ifndef ADDITIONALINFODIALOG_H
#define ADDITIONALINFODIALOG_H #define ADDITIONALINFODIALOG_H
#include <KDialog> #include <QDialog>
#include <QList> #include <QList>
#include <QListWidget> #include <QListWidget>
@ -28,7 +28,7 @@
/** /**
* @brief Dialog for changing the additional information shown in the view. * @brief Dialog for changing the additional information shown in the view.
*/ */
class AdditionalInfoDialog : public KDialog class AdditionalInfoDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
@ -37,8 +37,8 @@ public:
virtual ~AdditionalInfoDialog(); virtual ~AdditionalInfoDialog();
QList<QByteArray> visibleRoles() const; QList<QByteArray> visibleRoles() const;
private slots: public slots:
void slotOk(); void accept() Q_DECL_OVERRIDE;
private: private:
QList<QByteArray> m_visibleRoles; QList<QByteArray> m_visibleRoles;

View file

@ -30,11 +30,13 @@
#include <QLibrary> #include <QLibrary>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QStandardPaths> #include <QStandardPaths>
#include <QDialogButtonBox>
#include <QPushButton>
ConfigurePreviewPluginDialog::ConfigurePreviewPluginDialog(const QString& pluginName, ConfigurePreviewPluginDialog::ConfigurePreviewPluginDialog(const QString& pluginName,
const QString& desktopEntryName, const QString& desktopEntryName,
QWidget* parent) : QWidget* parent) :
KDialog(parent) QDialog(parent)
{ {
QSharedPointer<ThumbCreator> previewPlugin; QSharedPointer<ThumbCreator> previewPlugin;
const QString pluginPath = KPluginLoader::findPlugin(desktopEntryName); const QString pluginPath = KPluginLoader::findPlugin(desktopEntryName);
@ -45,24 +47,21 @@ ConfigurePreviewPluginDialog::ConfigurePreviewPluginDialog(const QString& plugin
} }
} }
setCaption(i18nc("@title:window", "Configure Preview for %1", pluginName)); setWindowTitle(i18nc("@title:window", "Configure Preview for %1", pluginName));
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
setMinimumWidth(400); setMinimumWidth(400);
setButtons(Ok | Cancel);
setDefaultButton(Ok); auto layout = new QVBoxLayout(this);
setLayout(layout);
if (previewPlugin) { if (previewPlugin) {
auto mainWidget = new QWidget(this);
mainWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
setMainWidget(mainWidget);
auto configurationWidget = previewPlugin->createConfigurationWidget(); auto configurationWidget = previewPlugin->createConfigurationWidget();
configurationWidget->setParent(mainWidget); configurationWidget->setParent(this);
auto layout = new QVBoxLayout(mainWidget);
layout->addWidget(configurationWidget); layout->addWidget(configurationWidget);
layout->addStretch(); layout->addStretch();
connect(this, &ConfigurePreviewPluginDialog::okClicked, this, [=] { connect(this, &ConfigurePreviewPluginDialog::accepted, this, [=] {
// TODO: It would be great having a mechanism to tell PreviewJob that only previews // TODO: It would be great having a mechanism to tell PreviewJob that only previews
// for a specific MIME-type should be regenerated. As this is not available yet we // for a specific MIME-type should be regenerated. As this is not available yet we
// delete the whole thumbnails directory. // delete the whole thumbnails directory.
@ -73,4 +72,13 @@ ConfigurePreviewPluginDialog::ConfigurePreviewPluginDialog(const QString& plugin
KIO::del(QUrl::fromLocalFile(thumbnailsPath), KIO::HideProgressInfo); KIO::del(QUrl::fromLocalFile(thumbnailsPath), KIO::HideProgressInfo);
}); });
} }
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
connect(buttonBox, &QDialogButtonBox::accepted, this, &ConfigurePreviewPluginDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &ConfigurePreviewPluginDialog::reject);
layout->addWidget(buttonBox);
auto okButton = buttonBox->button(QDialogButtonBox::Ok);
okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
okButton->setDefault(true);
} }

View file

@ -20,12 +20,12 @@
#ifndef CONFIGUREPREVIEWPLUGINDIALOG_H #ifndef CONFIGUREPREVIEWPLUGINDIALOG_H
#define CONFIGUREPREVIEWPLUGINDIALOG_H #define CONFIGUREPREVIEWPLUGINDIALOG_H
#include <KDialog> #include <QDialog>
/** /**
* @brief Dialog for configuring preview-plugins. * @brief Dialog for configuring preview-plugins.
*/ */
class ConfigurePreviewPluginDialog : public KDialog class ConfigurePreviewPluginDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT

View file

@ -21,7 +21,6 @@
#include <dolphin_generalsettings.h> #include <dolphin_generalsettings.h>
#include <KDialog>
#include <KLocalizedString> #include <KLocalizedString>
#include <QCheckBox> #include <QCheckBox>
@ -58,15 +57,11 @@ ConfirmationsSettingsPage::ConfirmationsSettingsPage(QWidget* parent) :
m_confirmClosingMultipleTabs = new QCheckBox(i18nc("@option:check Ask for confirmation when", m_confirmClosingMultipleTabs = new QCheckBox(i18nc("@option:check Ask for confirmation when",
"Closing Dolphin windows with multiple tabs"), this); "Closing Dolphin windows with multiple tabs"), this);
topLayout->addSpacing(KDialog::spacingHint());
topLayout->addWidget(confirmLabelKde); topLayout->addWidget(confirmLabelKde);
topLayout->addSpacing(KDialog::spacingHint());
topLayout->addWidget(m_confirmMoveToTrash); topLayout->addWidget(m_confirmMoveToTrash);
topLayout->addWidget(m_confirmDelete); topLayout->addWidget(m_confirmDelete);
topLayout->addWidget(m_confirmScriptExecution); topLayout->addWidget(m_confirmScriptExecution);
topLayout->addSpacing(KDialog::spacingHint());
topLayout->addWidget(confirmLabelDolphin); topLayout->addWidget(confirmLabelDolphin);
topLayout->addSpacing(KDialog::spacingHint());
topLayout->addWidget(m_confirmClosingMultipleTabs); topLayout->addWidget(m_confirmClosingMultipleTabs);
topLayout->addStretch(); topLayout->addStretch();

View file

@ -26,7 +26,6 @@
#include <settings/settingspagebase.h> #include <settings/settingspagebase.h>
#include "statusbarsettingspage.h" #include "statusbarsettingspage.h"
#include <KDialog>
#include <KLocalizedString> #include <KLocalizedString>
#include <QTabWidget> #include <QTabWidget>
@ -38,7 +37,6 @@ GeneralSettingsPage::GeneralSettingsPage(const QUrl& url, QWidget* parent) :
{ {
QVBoxLayout* topLayout = new QVBoxLayout(this); QVBoxLayout* topLayout = new QVBoxLayout(this);
topLayout->setMargin(0); topLayout->setMargin(0);
topLayout->setSpacing(KDialog::spacingHint());
QTabWidget* tabWidget = new QTabWidget(this); QTabWidget* tabWidget = new QTabWidget(this);

View file

@ -23,7 +23,6 @@
#include "configurepreviewplugindialog.h" #include "configurepreviewplugindialog.h"
#include <KConfigGroup> #include <KConfigGroup>
#include <KDialog>
#include <KGlobal> #include <KGlobal>
#include <KLocalizedString> #include <KLocalizedString>
#include <KNumInput> #include <KNumInput>
@ -88,7 +87,6 @@ PreviewsSettingsPage::PreviewsSettingsPage(QWidget* parent) :
fileSizeBoxLayout->addWidget(remoteFileSizeLabel, 0, Qt::AlignRight); fileSizeBoxLayout->addWidget(remoteFileSizeLabel, 0, Qt::AlignRight);
fileSizeBoxLayout->addWidget(m_remoteFileSizeBox); fileSizeBoxLayout->addWidget(m_remoteFileSizeBox);
topLayout->addSpacing(KDialog::spacingHint());
topLayout->addWidget(showPreviewsLabel); topLayout->addWidget(showPreviewsLabel);
topLayout->addWidget(m_listView); topLayout->addWidget(m_listView);
topLayout->addLayout(fileSizeBoxLayout); topLayout->addLayout(fileSizeBoxLayout);

View file

@ -21,7 +21,6 @@
#include <dolphin_generalsettings.h> #include <dolphin_generalsettings.h>
#include <KDialog>
#include <KLocalizedString> #include <KLocalizedString>
#include <QCheckBox> #include <QCheckBox>
@ -36,7 +35,6 @@ StatusBarSettingsPage::StatusBarSettingsPage(QWidget* parent) :
m_showSpaceInfo = new QCheckBox(i18nc("@option:check", "Show space information"), this); m_showSpaceInfo = new QCheckBox(i18nc("@option:check", "Show space information"), this);
QVBoxLayout* topLayout = new QVBoxLayout(this); QVBoxLayout* topLayout = new QVBoxLayout(this);
topLayout->addSpacing(KDialog::spacingHint());
topLayout->addWidget(m_showZoomSlider); topLayout->addWidget(m_showZoomSlider);
topLayout->addWidget(m_showSpaceInfo); topLayout->addWidget(m_showSpaceInfo);
topLayout->addStretch(); topLayout->addStretch();

View file

@ -19,7 +19,6 @@
#include "kcmdolphingeneral.h" #include "kcmdolphingeneral.h"
#include <KDialog>
#include <KLocalizedString> #include <KLocalizedString>
#include <KPluginFactory> #include <KPluginFactory>
#include <KPluginLoader> #include <KPluginLoader>
@ -48,7 +47,6 @@ DolphinGeneralConfigModule::DolphinGeneralConfigModule(QWidget* parent, const QV
QVBoxLayout* topLayout = new QVBoxLayout(this); QVBoxLayout* topLayout = new QVBoxLayout(this);
topLayout->setMargin(0); topLayout->setMargin(0);
topLayout->setSpacing(KDialog::spacingHint());
QTabWidget* tabWidget = new QTabWidget(this); QTabWidget* tabWidget = new QTabWidget(this);

View file

@ -19,7 +19,6 @@
#include "kcmdolphinnavigation.h" #include "kcmdolphinnavigation.h"
#include <KDialog>
#include <KPluginFactory> #include <KPluginFactory>
#include <KPluginLoader> #include <KPluginLoader>
@ -43,7 +42,6 @@ DolphinNavigationConfigModule::DolphinNavigationConfigModule(QWidget* parent, co
QVBoxLayout* topLayout = new QVBoxLayout(this); QVBoxLayout* topLayout = new QVBoxLayout(this);
topLayout->setMargin(0); topLayout->setMargin(0);
topLayout->setSpacing(KDialog::spacingHint());
m_navigation = new NavigationSettingsPage(this); m_navigation = new NavigationSettingsPage(this);
connect(m_navigation, &NavigationSettingsPage::changed, this, static_cast<void(DolphinNavigationConfigModule::*)()>(&DolphinNavigationConfigModule::changed)); connect(m_navigation, &NavigationSettingsPage::changed, this, static_cast<void(DolphinNavigationConfigModule::*)()>(&DolphinNavigationConfigModule::changed));

View file

@ -19,7 +19,6 @@
#include "kcmdolphinservices.h" #include "kcmdolphinservices.h"
#include <KDialog>
#include <KPluginFactory> #include <KPluginFactory>
#include <KPluginLoader> #include <KPluginLoader>
@ -43,7 +42,6 @@ DolphinServicesConfigModule::DolphinServicesConfigModule(QWidget* parent, const
QVBoxLayout* topLayout = new QVBoxLayout(this); QVBoxLayout* topLayout = new QVBoxLayout(this);
topLayout->setMargin(0); topLayout->setMargin(0);
topLayout->setSpacing(KDialog::spacingHint());
m_services = new ServicesSettingsPage(this); m_services = new ServicesSettingsPage(this);
connect(m_services, &ServicesSettingsPage::changed, this, static_cast<void(DolphinServicesConfigModule::*)()>(&DolphinServicesConfigModule::changed)); connect(m_services, &ServicesSettingsPage::changed, this, static_cast<void(DolphinServicesConfigModule::*)()>(&DolphinServicesConfigModule::changed));

View file

@ -19,7 +19,6 @@
#include "kcmdolphinviewmodes.h" #include "kcmdolphinviewmodes.h"
#include <KDialog>
#include <KLocalizedString> #include <KLocalizedString>
#include <KPluginFactory> #include <KPluginFactory>
#include <KPluginLoader> #include <KPluginLoader>
@ -49,7 +48,6 @@ DolphinViewModesConfigModule::DolphinViewModesConfigModule(QWidget* parent, cons
QVBoxLayout* topLayout = new QVBoxLayout(this); QVBoxLayout* topLayout = new QVBoxLayout(this);
topLayout->setMargin(0); topLayout->setMargin(0);
topLayout->setSpacing(KDialog::spacingHint());
QTabWidget* tabWidget = new QTabWidget(this); QTabWidget* tabWidget = new QTabWidget(this);

View file

@ -21,7 +21,6 @@
#include "dolphin_generalsettings.h" #include "dolphin_generalsettings.h"
#include <KDialog>
#include <KLocalizedString> #include <KLocalizedString>
#include <QCheckBox> #include <QCheckBox>
@ -32,13 +31,10 @@ NavigationSettingsPage::NavigationSettingsPage(QWidget* parent) :
m_openArchivesAsFolder(0), m_openArchivesAsFolder(0),
m_autoExpandFolders(0) m_autoExpandFolders(0)
{ {
const int spacing = KDialog::spacingHint();
QVBoxLayout* topLayout = new QVBoxLayout(this); QVBoxLayout* topLayout = new QVBoxLayout(this);
QWidget* vBox = new QWidget(this); QWidget* vBox = new QWidget(this);
QVBoxLayout *vBoxLayout = new QVBoxLayout(vBox); QVBoxLayout *vBoxLayout = new QVBoxLayout(vBox);
vBoxLayout->setMargin(0); vBoxLayout->setMargin(0);
vBoxLayout->setSpacing(spacing);
vBoxLayout->setAlignment(Qt::AlignTop); vBoxLayout->setAlignment(Qt::AlignTop);
m_openArchivesAsFolder = new QCheckBox(i18nc("@option:check", "Open archives as folder"), vBox); m_openArchivesAsFolder = new QCheckBox(i18nc("@option:check", "Open archives as folder"), vBox);

View file

@ -24,7 +24,6 @@
#include "dolphin_generalsettings.h" #include "dolphin_generalsettings.h"
#include <KDialog>
#include <KFileDialog> #include <KFileDialog>
#include <KLocalizedString> #include <KLocalizedString>
#include <QLineEdit> #include <QLineEdit>
@ -49,13 +48,10 @@ StartupSettingsPage::StartupSettingsPage(const QUrl& url, QWidget* parent) :
m_showFullPath(0), m_showFullPath(0),
m_filterBar(0) m_filterBar(0)
{ {
const int spacing = KDialog::spacingHint();
QVBoxLayout* topLayout = new QVBoxLayout(this); QVBoxLayout* topLayout = new QVBoxLayout(this);
QWidget* vBox = new QWidget(this); QWidget* vBox = new QWidget(this);
QVBoxLayout *vBoxLayout = new QVBoxLayout(vBox); QVBoxLayout *vBoxLayout = new QVBoxLayout(vBox);
vBoxLayout->setMargin(0); vBoxLayout->setMargin(0);
vBoxLayout->setSpacing(spacing);
vBoxLayout->setAlignment(Qt::AlignTop); vBoxLayout->setAlignment(Qt::AlignTop);
// create 'Home URL' editor // create 'Home URL' editor
@ -65,7 +61,6 @@ StartupSettingsPage::StartupSettingsPage(const QUrl& url, QWidget* parent) :
QWidget* homeUrlBox = new QWidget(homeBox); QWidget* homeUrlBox = new QWidget(homeBox);
QHBoxLayout *homeUrlBoxLayout = new QHBoxLayout(homeUrlBox); QHBoxLayout *homeUrlBoxLayout = new QHBoxLayout(homeUrlBox);
homeUrlBoxLayout->setMargin(0); homeUrlBoxLayout->setMargin(0);
homeUrlBoxLayout->setSpacing(spacing);
QLabel* homeUrlLabel = new QLabel(i18nc("@label:textbox", "Location:"), homeUrlBox); QLabel* homeUrlLabel = new QLabel(i18nc("@label:textbox", "Location:"), homeUrlBox);
homeUrlBoxLayout->addWidget(homeUrlLabel); homeUrlBoxLayout->addWidget(homeUrlLabel);
@ -86,7 +81,6 @@ StartupSettingsPage::StartupSettingsPage(const QUrl& url, QWidget* parent) :
QWidget* buttonBox = new QWidget(homeBox); QWidget* buttonBox = new QWidget(homeBox);
QHBoxLayout *buttonBoxLayout = new QHBoxLayout(buttonBox); QHBoxLayout *buttonBoxLayout = new QHBoxLayout(buttonBox);
buttonBoxLayout->setMargin(0); buttonBoxLayout->setMargin(0);
buttonBoxLayout->setSpacing(spacing);
QPushButton* useCurrentButton = new QPushButton(i18nc("@action:button", "Use Current Location"), buttonBox); QPushButton* useCurrentButton = new QPushButton(i18nc("@action:button", "Use Current Location"), buttonBox);
buttonBoxLayout->addWidget(useCurrentButton); buttonBoxLayout->addWidget(useCurrentButton);

View file

@ -20,21 +20,16 @@
#include "trashsettingspage.h" #include "trashsettingspage.h"
#include <KCModuleProxy> #include <KCModuleProxy>
#include <KDialog>
#include <QVBoxLayout>
#include <QVBoxLayout> #include <QVBoxLayout>
TrashSettingsPage::TrashSettingsPage(QWidget* parent) : TrashSettingsPage::TrashSettingsPage(QWidget* parent) :
SettingsPageBase(parent) SettingsPageBase(parent)
{ {
const int spacing = KDialog::spacingHint();
QVBoxLayout* topLayout = new QVBoxLayout(this); QVBoxLayout* topLayout = new QVBoxLayout(this);
QWidget* vBox = new QWidget(this); QWidget* vBox = new QWidget(this);
QVBoxLayout *vBoxVBoxLayout = new QVBoxLayout(vBox); QVBoxLayout *vBoxVBoxLayout = new QVBoxLayout(vBox);
vBoxVBoxLayout->setMargin(0); vBoxVBoxLayout->setMargin(0);
vBoxVBoxLayout->setSpacing(spacing);
m_proxy = new KCModuleProxy("kcmtrash"); m_proxy = new KCModuleProxy("kcmtrash");
topLayout->addWidget(m_proxy); topLayout->addWidget(m_proxy);

View file

@ -26,7 +26,6 @@
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QTabWidget> #include <QTabWidget>
#include <KDialog>
#include <KLocalizedString> #include <KLocalizedString>
ViewSettingsPage::ViewSettingsPage(QWidget* parent) : ViewSettingsPage::ViewSettingsPage(QWidget* parent) :
@ -35,7 +34,6 @@ ViewSettingsPage::ViewSettingsPage(QWidget* parent) :
{ {
QVBoxLayout* topLayout = new QVBoxLayout(this); QVBoxLayout* topLayout = new QVBoxLayout(this);
topLayout->setMargin(0); topLayout->setMargin(0);
topLayout->setSpacing(KDialog::spacingHint());
QTabWidget* tabWidget = new QTabWidget(this); QTabWidget* tabWidget = new QTabWidget(this);

View file

@ -34,6 +34,8 @@
#include <KMessageBox> #include <KMessageBox>
#include <QUrl> #include <QUrl>
#include <KComboBox> #include <KComboBox>
#include <KConfigGroup>
#include <KWindowConfig>
#include <QButtonGroup> #include <QButtonGroup>
#include <QCheckBox> #include <QCheckBox>
@ -42,11 +44,13 @@
#include <QLabel> #include <QLabel>
#include <QPushButton> #include <QPushButton>
#include <QRadioButton> #include <QRadioButton>
#include <QDialogButtonBox>
#include <QVBoxLayout>
#include <views/viewproperties.h> #include <views/viewproperties.h>
ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) : ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
KDialog(dolphinView), QDialog(dolphinView),
m_isDirty(false), m_isDirty(false),
m_dolphinView(dolphinView), m_dolphinView(dolphinView),
m_viewProps(0), m_viewProps(0),
@ -66,24 +70,26 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
Q_ASSERT(dolphinView); Q_ASSERT(dolphinView);
const bool useGlobalViewProps = GeneralSettings::globalViewProps(); const bool useGlobalViewProps = GeneralSettings::globalViewProps();
setCaption(i18nc("@title:window", "View Properties")); setWindowTitle(i18nc("@title:window", "View Properties"));
setButtons(KDialog::Ok | KDialog::Cancel | KDialog::Apply); setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
const QUrl& url = dolphinView->url(); const QUrl& url = dolphinView->url();
m_viewProps = new ViewProperties(url); m_viewProps = new ViewProperties(url);
m_viewProps->setAutoSaveEnabled(false); m_viewProps->setAutoSaveEnabled(false);
QWidget* main = new QWidget(); auto layout = new QVBoxLayout(this);
QVBoxLayout* topLayout = new QVBoxLayout(); setLayout(layout);
auto propsGrid = new QWidget(this);
layout->addWidget(propsGrid);
// create 'Properties' group containing view mode, sorting, sort order and show hidden files // create 'Properties' group containing view mode, sorting, sort order and show hidden files
QWidget* propsBox = main; QWidget* propsBox = this;
if (!useGlobalViewProps) { if (!useGlobalViewProps) {
propsBox = new QGroupBox(i18nc("@title:group", "Properties"), main); propsBox = new QGroupBox(i18nc("@title:group", "Properties"), this);
layout->addWidget(propsBox);
} }
QWidget* propsGrid = new QWidget();
QLabel* viewModeLabel = new QLabel(i18nc("@label:listbox", "View mode:"), propsGrid); QLabel* viewModeLabel = new QLabel(i18nc("@label:listbox", "View mode:"), propsGrid);
m_viewMode = new KComboBox(propsGrid); m_viewMode = new KComboBox(propsGrid);
m_viewMode->addItem(QIcon::fromTheme("view-list-icons"), i18nc("@item:inlistbox", "Icons"), DolphinView::IconsView); m_viewMode->addItem(QIcon::fromTheme("view-list-icons"), i18nc("@item:inlistbox", "Icons"), DolphinView::IconsView);
@ -130,8 +136,6 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
propsBoxLayout->addWidget(m_showHiddenFiles); propsBoxLayout->addWidget(m_showHiddenFiles);
propsBoxLayout->addWidget(m_additionalInfo); propsBoxLayout->addWidget(m_additionalInfo);
topLayout->addWidget(propsBox);
connect(m_viewMode, static_cast<void(KComboBox::*)(int)>(&KComboBox::currentIndexChanged), connect(m_viewMode, static_cast<void(KComboBox::*)(int)>(&KComboBox::currentIndexChanged),
this, &ViewPropertiesDialog::slotViewModeChanged); this, &ViewPropertiesDialog::slotViewModeChanged);
connect(m_sorting, static_cast<void(KComboBox::*)(int)>(&KComboBox::currentIndexChanged), connect(m_sorting, static_cast<void(KComboBox::*)(int)>(&KComboBox::currentIndexChanged),
@ -149,14 +153,12 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
connect(m_showHiddenFiles, &QCheckBox::clicked, connect(m_showHiddenFiles, &QCheckBox::clicked,
this, &ViewPropertiesDialog::slotShowHiddenFilesChanged); this, &ViewPropertiesDialog::slotShowHiddenFilesChanged);
connect(this, &ViewPropertiesDialog::okClicked, this, &ViewPropertiesDialog::slotOk);
connect(this, &ViewPropertiesDialog::applyClicked, this, &ViewPropertiesDialog::slotApply);
// Only show the following settings if the view properties are remembered // Only show the following settings if the view properties are remembered
// for each directory: // for each directory:
if (!useGlobalViewProps) { if (!useGlobalViewProps) {
// create 'Apply View Properties To' group // create 'Apply View Properties To' group
QGroupBox* applyBox = new QGroupBox(i18nc("@title:group", "Apply View Properties To"), main); QGroupBox* applyBox = new QGroupBox(i18nc("@title:group", "Apply View Properties To"), this);
layout->addWidget(applyBox);
m_applyToCurrentFolder = new QRadioButton(i18nc("@option:radio Apply View Properties To", m_applyToCurrentFolder = new QRadioButton(i18nc("@option:radio Apply View Properties To",
"Current folder"), applyBox); "Current folder"), applyBox);
@ -176,10 +178,8 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
applyBoxLayout->addWidget(m_applyToSubFolders); applyBoxLayout->addWidget(m_applyToSubFolders);
applyBoxLayout->addWidget(m_applyToAllFolders); applyBoxLayout->addWidget(m_applyToAllFolders);
m_useAsDefault = new QCheckBox(i18nc("@option:check", "Use these view properties as default"), main); m_useAsDefault = new QCheckBox(i18nc("@option:check", "Use these view properties as default"), this);
layout->addWidget(m_useAsDefault);
topLayout->addWidget(applyBox);
topLayout->addWidget(m_useAsDefault);
connect(m_applyToCurrentFolder, &QRadioButton::clicked, connect(m_applyToCurrentFolder, &QRadioButton::clicked,
this, &ViewPropertiesDialog::markAsDirty); this, &ViewPropertiesDialog::markAsDirty);
@ -191,12 +191,25 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
this, &ViewPropertiesDialog::markAsDirty); this, &ViewPropertiesDialog::markAsDirty);
} }
main->setLayout(topLayout); layout->addStretch();
setMainWidget(main);
const KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"), auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Apply, this);
"ViewPropertiesDialog"); connect(buttonBox, &QDialogButtonBox::accepted, this, &ViewPropertiesDialog::accept);
restoreDialogSize(dialogConfig); connect(buttonBox, &QDialogButtonBox::rejected, this, &ViewPropertiesDialog::reject);
layout->addWidget(buttonBox);
auto okButton = buttonBox->button(QDialogButtonBox::Ok);
okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
okButton->setDefault(true);
auto applyButton = buttonBox->button(QDialogButtonBox::Apply);
connect(applyButton, &QPushButton::clicked, this, &ViewPropertiesDialog::slotApply);
connect(this, &ViewPropertiesDialog::isDirtyChanged, applyButton, [applyButton](bool isDirty) {
applyButton->setEnabled(isDirty);
});
const KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"), "ViewPropertiesDialog");
KWindowConfig::restoreWindowSize(windowHandle(), dialogConfig);
loadSettings(); loadSettings();
} }
@ -207,15 +220,14 @@ ViewPropertiesDialog::~ViewPropertiesDialog()
delete m_viewProps; delete m_viewProps;
m_viewProps = 0; m_viewProps = 0;
KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"), KConfigGroup dialogConfig(KSharedConfig::openConfig("dolphinrc"), "ViewPropertiesDialog");
"ViewPropertiesDialog"); KWindowConfig::saveWindowSize(windowHandle(), dialogConfig);
saveDialogSize(dialogConfig, KConfigBase::Persistent);
} }
void ViewPropertiesDialog::slotOk() void ViewPropertiesDialog::accept()
{ {
applyViewProperties(); applyViewProperties();
accept(); QDialog::accept();
} }
void ViewPropertiesDialog::slotApply() void ViewPropertiesDialog::slotApply()
@ -275,8 +287,10 @@ void ViewPropertiesDialog::slotShowHiddenFilesChanged()
void ViewPropertiesDialog::markAsDirty(bool isDirty) void ViewPropertiesDialog::markAsDirty(bool isDirty)
{ {
m_isDirty = isDirty; if (m_isDirty != isDirty) {
enableButtonApply(isDirty); m_isDirty = isDirty;
emit isDirtyChanged(isDirty);
}
} }
void ViewPropertiesDialog::configureAdditionalInfo() void ViewPropertiesDialog::configureAdditionalInfo()

View file

@ -23,7 +23,7 @@
#include "libdolphin_export.h" #include "libdolphin_export.h"
#include <KDialog> #include <QDialog>
class QCheckBox; class QCheckBox;
class KComboBox; class KComboBox;
@ -39,7 +39,7 @@ class DolphinView;
* and previews should be shown. The properties can be assigned to the current folder, * and previews should be shown. The properties can be assigned to the current folder,
* or recursively to all sub folders. * or recursively to all sub folders.
*/ */
class LIBDOLPHINPRIVATE_EXPORT ViewPropertiesDialog : public KDialog class LIBDOLPHINPRIVATE_EXPORT ViewPropertiesDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
@ -47,8 +47,10 @@ public:
explicit ViewPropertiesDialog(DolphinView* dolphinView); explicit ViewPropertiesDialog(DolphinView* dolphinView);
virtual ~ViewPropertiesDialog(); virtual ~ViewPropertiesDialog();
public slots:
void accept() Q_DECL_OVERRIDE;
private slots: private slots:
void slotOk();
void slotApply(); void slotApply();
void slotViewModeChanged(int index); void slotViewModeChanged(int index);
void slotSortingChanged(int index); void slotSortingChanged(int index);
@ -60,6 +62,9 @@ private slots:
void markAsDirty(bool isDirty); void markAsDirty(bool isDirty);
void configureAdditionalInfo(); void configureAdditionalInfo();
signals:
void isDirtyChanged(bool isDirty);
private: private:
void applyViewProperties(); void applyViewProperties();
void loadSettings(); void loadSettings();

View file

@ -25,7 +25,10 @@
#include <QProgressBar> #include <QProgressBar>
#include <QTimer> #include <QTimer>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QDialogButtonBox>
#include <QPushButton>
#include <KConfigGroup>
#include <KLocalizedString> #include <KLocalizedString>
#include <KIO/JobClasses> #include <KIO/JobClasses>
@ -34,7 +37,7 @@
ViewPropsProgressInfo::ViewPropsProgressInfo(QWidget* parent, ViewPropsProgressInfo::ViewPropsProgressInfo(QWidget* parent,
const QUrl& dir, const QUrl& dir,
const ViewProperties& viewProps) : const ViewProperties& viewProps) :
KDialog(parent), QDialog(parent),
m_dir(dir), m_dir(dir),
m_viewProps(0), m_viewProps(0),
m_label(0), m_label(0),
@ -45,9 +48,8 @@ ViewPropsProgressInfo::ViewPropsProgressInfo(QWidget* parent,
{ {
const QSize minSize = minimumSize(); const QSize minSize = minimumSize();
setMinimumSize(QSize(320, minSize.height())); setMinimumSize(QSize(320, minSize.height()));
setWindowTitle(i18nc("@title:window", "Applying View Properties"));
setCaption(i18nc("@title:window", "Applying View Properties")); setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
setButtons(KDialog::Cancel);
m_viewProps = new ViewProperties(dir); m_viewProps = new ViewProperties(dir);
m_viewProps->setDirProperties(viewProps); m_viewProps->setDirProperties(viewProps);
@ -56,20 +58,24 @@ ViewPropsProgressInfo::ViewPropsProgressInfo(QWidget* parent,
// that the view properties are saved twice: // that the view properties are saved twice:
m_viewProps->setAutoSaveEnabled(false); m_viewProps->setAutoSaveEnabled(false);
QWidget* main = new QWidget(); auto layout = new QVBoxLayout(this);
QVBoxLayout* topLayout = new QVBoxLayout(); setLayout(layout);
m_label = new QLabel(i18nc("@info:progress", "Counting folders: %1", 0), main); m_label = new QLabel(i18nc("@info:progress", "Counting folders: %1", 0), this);
m_progressBar = new QProgressBar(main); layout->addWidget(m_label);
m_progressBar = new QProgressBar(this);
m_progressBar->setMinimum(0); m_progressBar->setMinimum(0);
m_progressBar->setMaximum(0); m_progressBar->setMaximum(0);
m_progressBar->setValue(0); m_progressBar->setValue(0);
layout->addWidget(m_progressBar);
topLayout->addWidget(m_label); layout->addStretch();
topLayout->addWidget(m_progressBar);
main->setLayout(topLayout); auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel, this);
setMainWidget(main); connect(buttonBox, &QDialogButtonBox::accepted, this, &ViewPropsProgressInfo::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &ViewPropsProgressInfo::reject);
layout->addWidget(buttonBox);
// Use the directory size job to count the number of directories first. This // Use the directory size job to count the number of directories first. This
// allows to give a progress indication for the user when applying the view // allows to give a progress indication for the user when applying the view
@ -85,8 +91,6 @@ ViewPropsProgressInfo::ViewPropsProgressInfo(QWidget* parent,
connect(m_timer, &QTimer::timeout, connect(m_timer, &QTimer::timeout,
this, &ViewPropsProgressInfo::updateProgress); this, &ViewPropsProgressInfo::updateProgress);
m_timer->start(300); m_timer->start(300);
connect(this, &ViewPropsProgressInfo::cancelClicked, this, &ViewPropsProgressInfo::cancelApplying);
} }
ViewPropsProgressInfo::~ViewPropsProgressInfo() ViewPropsProgressInfo::~ViewPropsProgressInfo()
@ -99,7 +103,22 @@ void ViewPropsProgressInfo::closeEvent(QCloseEvent* event)
{ {
m_timer->stop(); m_timer->stop();
m_applyViewPropsJob = 0; m_applyViewPropsJob = 0;
KDialog::closeEvent(event); QDialog::closeEvent(event);
}
void ViewPropsProgressInfo::reject()
{
if (m_dirSizeJob) {
m_dirSizeJob->kill();
m_dirSizeJob = 0;
}
if (m_applyViewPropsJob) {
m_applyViewPropsJob->kill();
m_applyViewPropsJob = 0;
}
QDialog::reject();
} }
void ViewPropsProgressInfo::updateProgress() void ViewPropsProgressInfo::updateProgress()
@ -132,16 +151,3 @@ void ViewPropsProgressInfo::applyViewProperties()
this, &ViewPropsProgressInfo::close); this, &ViewPropsProgressInfo::close);
} }
void ViewPropsProgressInfo::cancelApplying()
{
if (m_dirSizeJob) {
m_dirSizeJob->kill();
m_dirSizeJob = 0;
}
if (m_applyViewPropsJob) {
m_applyViewPropsJob->kill();
m_applyViewPropsJob = 0;
}
}

View file

@ -20,7 +20,7 @@
#ifndef VIEWPROPSPROGRESSINFO_H #ifndef VIEWPROPSPROGRESSINFO_H
#define VIEWPROPSPROGRESSINFO_H #define VIEWPROPSPROGRESSINFO_H
#include <KDialog> #include <QDialog>
#include <kio/directorysizejob.h> #include <kio/directorysizejob.h>
#include <QUrl> #include <QUrl>
@ -37,7 +37,7 @@ class ViewProperties;
* It is possible to cancel the applying. In this case the already applied * It is possible to cancel the applying. In this case the already applied
* view properties won't get reverted. * view properties won't get reverted.
*/ */
class ViewPropsProgressInfo : public KDialog class ViewPropsProgressInfo : public QDialog
{ {
Q_OBJECT Q_OBJECT
@ -58,10 +58,12 @@ public:
protected: protected:
virtual void closeEvent(QCloseEvent* event) Q_DECL_OVERRIDE; virtual void closeEvent(QCloseEvent* event) Q_DECL_OVERRIDE;
public slots:
void reject() Q_DECL_OVERRIDE;
private slots: private slots:
void updateProgress(); void updateProgress();
void applyViewProperties(); void applyViewProperties();
void cancelApplying();
private: private:
QUrl m_dir; QUrl m_dir;