Changeset View
Changeset View
Standalone View
Standalone View
src/settings/startup/startupsettingspage.cpp
Show All 23 Lines | |||||
24 | #include "dolphinviewcontainer.h" | 24 | #include "dolphinviewcontainer.h" | ||
25 | #include "global.h" | 25 | #include "global.h" | ||
26 | 26 | | |||
27 | #include <KLocalizedString> | 27 | #include <KLocalizedString> | ||
28 | #include <KMessageBox> | 28 | #include <KMessageBox> | ||
29 | 29 | | |||
30 | #include <QCheckBox> | 30 | #include <QCheckBox> | ||
31 | #include <QFileDialog> | 31 | #include <QFileDialog> | ||
32 | #include <QGroupBox> | | |||
33 | #include <QLabel> | | |||
34 | #include <QLineEdit> | 32 | #include <QLineEdit> | ||
35 | #include <QPushButton> | 33 | #include <QPushButton> | ||
34 | #include <QFormLayout> | ||||
35 | #include <QHBoxLayout> | ||||
36 | #include <QVBoxLayout> | 36 | #include <QVBoxLayout> | ||
37 | 37 | | |||
38 | StartupSettingsPage::StartupSettingsPage(const QUrl& url, QWidget* parent) : | 38 | StartupSettingsPage::StartupSettingsPage(const QUrl& url, QWidget* parent) : | ||
39 | SettingsPageBase(parent), | 39 | SettingsPageBase(parent), | ||
40 | m_url(url), | 40 | m_url(url), | ||
41 | m_homeUrl(nullptr), | 41 | m_homeUrl(nullptr), | ||
42 | m_splitView(nullptr), | 42 | m_splitView(nullptr), | ||
43 | m_editableUrl(nullptr), | 43 | m_editableUrl(nullptr), | ||
44 | m_showFullPath(nullptr), | 44 | m_showFullPath(nullptr), | ||
45 | m_filterBar(nullptr), | 45 | m_filterBar(nullptr), | ||
46 | m_showFullPathInTitlebar(nullptr) | 46 | m_showFullPathInTitlebar(nullptr) | ||
47 | { | 47 | { | ||
48 | QVBoxLayout* topLayout = new QVBoxLayout(this); | 48 | QFormLayout* topLayout = new QFormLayout(this); | ||
49 | QWidget* vBox = new QWidget(this); | | |||
50 | QVBoxLayout *vBoxLayout = new QVBoxLayout(vBox); | | |||
51 | vBoxLayout->setMargin(0); | | |||
52 | vBoxLayout->setAlignment(Qt::AlignTop); | | |||
53 | 49 | | |||
54 | // create 'Home URL' editor | | |||
55 | QGroupBox* homeBox = new QGroupBox(i18nc("@title:group", "Home Folder"), vBox); | | |||
56 | vBoxLayout->addWidget(homeBox); | | |||
57 | 50 | | |||
58 | QWidget* homeUrlBox = new QWidget(homeBox); | 51 | // create 'Home URL' editor | ||
59 | QHBoxLayout *homeUrlBoxLayout = new QHBoxLayout(homeUrlBox); | 52 | QHBoxLayout* homeUrlBoxLayout = new QHBoxLayout(); | ||
elvisangelaccio: Please add a parent to this layout | |||||
My understanding of Qt's layout system is that any item (including a layout) that will be added to a layout doesn't need to be given a parent, since Qt automatically re-parents it to the layout it's added to. ngraham: My understanding of Qt's layout system is that any item (including a layout) that will be added… | |||||
elvisangelaccio: Oh, right! | |||||
60 | homeUrlBoxLayout->setMargin(0); | 53 | homeUrlBoxLayout->setMargin(0); | ||
61 | 54 | | |||
62 | QLabel* homeUrlLabel = new QLabel(i18nc("@label:textbox", "Location:"), homeUrlBox); | 55 | m_homeUrl = new QLineEdit(); | ||
63 | homeUrlBoxLayout->addWidget(homeUrlLabel); | | |||
64 | m_homeUrl = new QLineEdit(homeUrlBox); | | |||
65 | homeUrlBoxLayout->addWidget(m_homeUrl); | | |||
66 | m_homeUrl->setClearButtonEnabled(true); | 56 | m_homeUrl->setClearButtonEnabled(true); | ||
57 | homeUrlBoxLayout->addWidget(m_homeUrl); | ||||
67 | 58 | | |||
68 | QPushButton* selectHomeUrlButton = new QPushButton(QIcon::fromTheme(QStringLiteral("folder-open")), QString(), homeUrlBox); | 59 | QPushButton* selectHomeUrlButton = new QPushButton(QIcon::fromTheme(QStringLiteral("folder-open")), QString()); | ||
69 | homeUrlBoxLayout->addWidget(selectHomeUrlButton); | 60 | homeUrlBoxLayout->addWidget(selectHomeUrlButton); | ||
70 | 61 | | |||
71 | #ifndef QT_NO_ACCESSIBILITY | 62 | #ifndef QT_NO_ACCESSIBILITY | ||
72 | selectHomeUrlButton->setAccessibleName(i18nc("@action:button", "Select Home Location")); | 63 | selectHomeUrlButton->setAccessibleName(i18nc("@action:button", "Select Home Location")); | ||
73 | #endif | 64 | #endif | ||
74 | 65 | | |||
75 | connect(selectHomeUrlButton, &QPushButton::clicked, | 66 | connect(selectHomeUrlButton, &QPushButton::clicked, | ||
76 | this, &StartupSettingsPage::selectHomeUrl); | 67 | this, &StartupSettingsPage::selectHomeUrl); | ||
77 | 68 | | |||
78 | QWidget* buttonBox = new QWidget(homeBox); | 69 | QHBoxLayout* buttonBoxLayout = new QHBoxLayout(); | ||
elvisangelaccio: Please add a parent to this layout | |||||
ngraham: Same ^^ | |||||
79 | QHBoxLayout *buttonBoxLayout = new QHBoxLayout(buttonBox); | | |||
80 | buttonBoxLayout->setMargin(0); | 70 | buttonBoxLayout->setMargin(0); | ||
81 | 71 | | |||
82 | QPushButton* useCurrentButton = new QPushButton(i18nc("@action:button", "Use Current Location"), buttonBox); | 72 | QPushButton* useCurrentButton = new QPushButton(i18nc("@action:button", "Use Current Location")); | ||
83 | buttonBoxLayout->addWidget(useCurrentButton); | 73 | buttonBoxLayout->addWidget(useCurrentButton); | ||
84 | connect(useCurrentButton, &QPushButton::clicked, | 74 | connect(useCurrentButton, &QPushButton::clicked, | ||
85 | this, &StartupSettingsPage::useCurrentLocation); | 75 | this, &StartupSettingsPage::useCurrentLocation); | ||
86 | QPushButton* useDefaultButton = new QPushButton(i18nc("@action:button", "Use Default Location"), buttonBox); | 76 | QPushButton* useDefaultButton = new QPushButton(i18nc("@action:button", "Use Default Location")); | ||
87 | buttonBoxLayout->addWidget(useDefaultButton); | 77 | buttonBoxLayout->addWidget(useDefaultButton); | ||
88 | connect(useDefaultButton, &QPushButton::clicked, | 78 | connect(useDefaultButton, &QPushButton::clicked, | ||
89 | this, &StartupSettingsPage::useDefaultLocation); | 79 | this, &StartupSettingsPage::useDefaultLocation); | ||
90 | 80 | | |||
91 | QVBoxLayout* homeBoxLayout = new QVBoxLayout(homeBox); | 81 | QVBoxLayout* homeBoxLayout = new QVBoxLayout(); | ||
92 | homeBoxLayout->addWidget(homeUrlBox); | 82 | homeBoxLayout->setMargin(0); | ||
93 | homeBoxLayout->addWidget(buttonBox); | 83 | homeBoxLayout->addLayout(homeUrlBoxLayout); | ||
84 | homeBoxLayout->addLayout(buttonBoxLayout); | ||||
85 | | ||||
86 | topLayout->addRow(i18nc("@label:textbox", "Start in:"), homeBoxLayout); | ||||
87 | | ||||
88 | | ||||
89 | topLayout->addItem(new QSpacerItem(0, Dolphin::VERTICAL_SPACER_HEIGHT, QSizePolicy::Fixed, QSizePolicy::Fixed)); | ||||
90 | | ||||
94 | 91 | | |||
95 | // create 'Split view', 'Show full path', 'Editable location' and 'Filter bar' checkboxes | 92 | // create 'Split view', 'Show full path', 'Editable location' and 'Filter bar' checkboxes | ||
96 | m_splitView = new QCheckBox(i18nc("@option:check Startup Settings", "Split view mode"), vBox); | 93 | m_splitView = new QCheckBox(i18nc("@option:check Startup Settings", "Split view mode")); | ||
97 | vBoxLayout->addWidget(m_splitView); | 94 | topLayout->addRow(i18nc("@label:checkbox", "Window options:"), m_splitView); | ||
98 | m_editableUrl = new QCheckBox(i18nc("@option:check Startup Settings", "Editable location bar"), vBox); | 95 | m_editableUrl = new QCheckBox(i18nc("@option:check Startup Settings", "Editable location bar")); | ||
99 | vBoxLayout->addWidget(m_editableUrl); | 96 | topLayout->addRow(QString(), m_editableUrl); | ||
100 | m_showFullPath = new QCheckBox(i18nc("@option:check Startup Settings", "Show full path inside location bar"), vBox); | 97 | m_showFullPath = new QCheckBox(i18nc("@option:check Startup Settings", "Show full path inside location bar")); | ||
101 | vBoxLayout->addWidget(m_showFullPath); | 98 | topLayout->addRow(QString(), m_showFullPath); | ||
102 | m_filterBar = new QCheckBox(i18nc("@option:check Startup Settings", "Show filter bar"), vBox); | 99 | m_filterBar = new QCheckBox(i18nc("@option:check Startup Settings", "Show filter bar")); | ||
103 | vBoxLayout->addWidget(m_filterBar); | 100 | topLayout->addRow(QString(), m_filterBar); | ||
104 | m_showFullPathInTitlebar = new QCheckBox(i18nc("@option:check Startup Settings", "Show full path in title bar"), vBox); | 101 | m_showFullPathInTitlebar = new QCheckBox(i18nc("@option:check Startup Settings", "Show full path in title bar")); | ||
105 | vBoxLayout->addWidget(m_showFullPathInTitlebar); | 102 | topLayout->addRow(QString(), m_showFullPathInTitlebar); | ||
106 | | ||||
107 | // Add a dummy widget with no restriction regarding | | |||
108 | // a vertical resizing. This assures that the dialog layout | | |||
109 | // is not stretched vertically. | | |||
110 | new QWidget(vBox); | | |||
111 | 103 | | |||
112 | topLayout->addWidget(vBox); | | |||
113 | 104 | | |||
114 | loadSettings(); | 105 | loadSettings(); | ||
115 | 106 | | |||
116 | connect(m_homeUrl, &QLineEdit::textChanged, this, &StartupSettingsPage::slotSettingsChanged); | 107 | connect(m_homeUrl, &QLineEdit::textChanged, this, &StartupSettingsPage::slotSettingsChanged); | ||
117 | connect(m_splitView, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); | 108 | connect(m_splitView, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); | ||
118 | connect(m_editableUrl, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); | 109 | connect(m_editableUrl, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); | ||
119 | connect(m_showFullPath, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); | 110 | connect(m_showFullPath, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); | ||
120 | connect(m_filterBar, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); | 111 | connect(m_filterBar, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); | ||
▲ Show 20 Lines • Show All 75 Lines • Show Last 20 Lines |
Please add a parent to this layout