Changeset View
Changeset View
Standalone View
Standalone View
src/settings/startup/startupsettingspage.cpp
Show All 27 Lines | |||||
28 | #include <KMessageBox> | 28 | #include <KMessageBox> | ||
29 | 29 | | |||
30 | #include <QCheckBox> | 30 | #include <QCheckBox> | ||
31 | #include <QFileDialog> | 31 | #include <QFileDialog> | ||
32 | #include <QGroupBox> | 32 | #include <QGroupBox> | ||
33 | #include <QLabel> | 33 | #include <QLabel> | ||
34 | #include <QLineEdit> | 34 | #include <QLineEdit> | ||
35 | #include <QPushButton> | 35 | #include <QPushButton> | ||
36 | #include <QFormLayout> | ||||
37 | #include <QHBoxLayout> | ||||
36 | #include <QVBoxLayout> | 38 | #include <QVBoxLayout> | ||
37 | 39 | | |||
38 | StartupSettingsPage::StartupSettingsPage(const QUrl& url, QWidget* parent) : | 40 | StartupSettingsPage::StartupSettingsPage(const QUrl& url, QWidget* parent) : | ||
39 | SettingsPageBase(parent), | 41 | SettingsPageBase(parent), | ||
40 | m_url(url), | 42 | m_url(url), | ||
41 | m_homeUrl(nullptr), | 43 | m_homeUrl(nullptr), | ||
42 | m_splitView(nullptr), | 44 | m_splitView(nullptr), | ||
43 | m_editableUrl(nullptr), | 45 | m_editableUrl(nullptr), | ||
44 | m_showFullPath(nullptr), | 46 | m_showFullPath(nullptr), | ||
45 | m_filterBar(nullptr), | 47 | m_filterBar(nullptr), | ||
46 | m_showFullPathInTitlebar(nullptr) | 48 | m_showFullPathInTitlebar(nullptr) | ||
47 | { | 49 | { | ||
48 | QVBoxLayout* topLayout = new QVBoxLayout(this); | 50 | 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 | 51 | | |||
54 | // create 'Home URL' editor | | |||
55 | QGroupBox* homeBox = new QGroupBox(i18nc("@title:group", "Home Folder"), vBox); | | |||
56 | vBoxLayout->addWidget(homeBox); | | |||
57 | 52 | | |||
58 | QWidget* homeUrlBox = new QWidget(homeBox); | 53 | // create 'Home URL' editor | ||
59 | QHBoxLayout *homeUrlBoxLayout = new QHBoxLayout(homeUrlBox); | 54 | 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); | 55 | homeUrlBoxLayout->setMargin(0); | ||
61 | 56 | | |||
62 | QLabel* homeUrlLabel = new QLabel(i18nc("@label:textbox", "Location:"), homeUrlBox); | 57 | m_homeUrl = new QLineEdit(); | ||
63 | homeUrlBoxLayout->addWidget(homeUrlLabel); | | |||
64 | m_homeUrl = new QLineEdit(homeUrlBox); | | |||
65 | homeUrlBoxLayout->addWidget(m_homeUrl); | | |||
66 | m_homeUrl->setClearButtonEnabled(true); | 58 | m_homeUrl->setClearButtonEnabled(true); | ||
59 | homeUrlBoxLayout->addWidget(m_homeUrl); | ||||
67 | 60 | | |||
68 | QPushButton* selectHomeUrlButton = new QPushButton(QIcon::fromTheme(QStringLiteral("folder-open")), QString(), homeUrlBox); | 61 | QPushButton* selectHomeUrlButton = new QPushButton(QIcon::fromTheme(QStringLiteral("folder-open")), QString()); | ||
69 | homeUrlBoxLayout->addWidget(selectHomeUrlButton); | 62 | homeUrlBoxLayout->addWidget(selectHomeUrlButton); | ||
70 | 63 | | |||
71 | #ifndef QT_NO_ACCESSIBILITY | 64 | #ifndef QT_NO_ACCESSIBILITY | ||
72 | selectHomeUrlButton->setAccessibleName(i18nc("@action:button", "Select Home Location")); | 65 | selectHomeUrlButton->setAccessibleName(i18nc("@action:button", "Select Home Location")); | ||
73 | #endif | 66 | #endif | ||
74 | 67 | | |||
75 | connect(selectHomeUrlButton, &QPushButton::clicked, | 68 | connect(selectHomeUrlButton, &QPushButton::clicked, | ||
76 | this, &StartupSettingsPage::selectHomeUrl); | 69 | this, &StartupSettingsPage::selectHomeUrl); | ||
77 | 70 | | |||
78 | QWidget* buttonBox = new QWidget(homeBox); | 71 | QHBoxLayout *buttonBoxLayout = new QHBoxLayout(); | ||
elvisangelaccio: Please add a parent to this layout | |||||
ngraham: Same ^^ | |||||
79 | QHBoxLayout *buttonBoxLayout = new QHBoxLayout(buttonBox); | | |||
80 | buttonBoxLayout->setMargin(0); | 72 | buttonBoxLayout->setMargin(0); | ||
81 | 73 | | |||
82 | QPushButton* useCurrentButton = new QPushButton(i18nc("@action:button", "Use Current Location"), buttonBox); | 74 | QPushButton* useCurrentButton = new QPushButton(i18nc("@action:button", "Use Current Location")); | ||
83 | buttonBoxLayout->addWidget(useCurrentButton); | 75 | buttonBoxLayout->addWidget(useCurrentButton); | ||
84 | connect(useCurrentButton, &QPushButton::clicked, | 76 | connect(useCurrentButton, &QPushButton::clicked, | ||
85 | this, &StartupSettingsPage::useCurrentLocation); | 77 | this, &StartupSettingsPage::useCurrentLocation); | ||
86 | QPushButton* useDefaultButton = new QPushButton(i18nc("@action:button", "Use Default Location"), buttonBox); | 78 | QPushButton* useDefaultButton = new QPushButton(i18nc("@action:button", "Use Default Location")); | ||
87 | buttonBoxLayout->addWidget(useDefaultButton); | 79 | buttonBoxLayout->addWidget(useDefaultButton); | ||
88 | connect(useDefaultButton, &QPushButton::clicked, | 80 | connect(useDefaultButton, &QPushButton::clicked, | ||
89 | this, &StartupSettingsPage::useDefaultLocation); | 81 | this, &StartupSettingsPage::useDefaultLocation); | ||
90 | 82 | | |||
91 | QVBoxLayout* homeBoxLayout = new QVBoxLayout(homeBox); | 83 | QVBoxLayout *homeBoxLayout = new QVBoxLayout(); | ||
92 | homeBoxLayout->addWidget(homeUrlBox); | 84 | homeBoxLayout->setMargin(0); | ||
93 | homeBoxLayout->addWidget(buttonBox); | 85 | homeBoxLayout->addLayout(homeUrlBoxLayout); | ||
86 | homeBoxLayout->addLayout(buttonBoxLayout); | ||||
87 | | ||||
88 | topLayout->addRow(i18nc("@label:textbox", "Location:"), homeBoxLayout); | ||||
89 | | ||||
90 | | ||||
91 | topLayout->addItem(new QSpacerItem(0,12, QSizePolicy::Fixed, QSizePolicy::Fixed)); | ||||
92 | | ||||
94 | 93 | | |||
95 | // create 'Split view', 'Show full path', 'Editable location' and 'Filter bar' checkboxes | 94 | // 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); | 95 | m_splitView = new QCheckBox(i18nc("@option:check Startup Settings", "Split view mode")); | ||
97 | vBoxLayout->addWidget(m_splitView); | 96 | topLayout->addRow(i18nc("@label:checkbox", "View options:"), m_splitView); | ||
98 | m_editableUrl = new QCheckBox(i18nc("@option:check Startup Settings", "Editable location bar"), vBox); | 97 | m_editableUrl = new QCheckBox(i18nc("@option:check Startup Settings", "Editable location bar")); | ||
99 | vBoxLayout->addWidget(m_editableUrl); | 98 | topLayout->addRow(QString(), m_editableUrl); | ||
100 | m_showFullPath = new QCheckBox(i18nc("@option:check Startup Settings", "Show full path inside location bar"), vBox); | 99 | m_showFullPath = new QCheckBox(i18nc("@option:check Startup Settings", "Show full path inside location bar")); | ||
101 | vBoxLayout->addWidget(m_showFullPath); | 100 | topLayout->addRow(QString(), m_showFullPath); | ||
102 | m_filterBar = new QCheckBox(i18nc("@option:check Startup Settings", "Show filter bar"), vBox); | 101 | m_filterBar = new QCheckBox(i18nc("@option:check Startup Settings", "Show filter bar")); | ||
103 | vBoxLayout->addWidget(m_filterBar); | 102 | topLayout->addRow(QString(), m_filterBar); | ||
104 | m_showFullPathInTitlebar = new QCheckBox(i18nc("@option:check Startup Settings", "Show full path in title bar"), vBox); | 103 | m_showFullPathInTitlebar = new QCheckBox(i18nc("@option:check Startup Settings", "Show full path in title bar")); | ||
105 | vBoxLayout->addWidget(m_showFullPathInTitlebar); | 104 | 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 | 105 | | |||
112 | topLayout->addWidget(vBox); | | |||
113 | 106 | | |||
114 | loadSettings(); | 107 | loadSettings(); | ||
115 | 108 | | |||
116 | connect(m_homeUrl, &QLineEdit::textChanged, this, &StartupSettingsPage::slotSettingsChanged); | 109 | connect(m_homeUrl, &QLineEdit::textChanged, this, &StartupSettingsPage::slotSettingsChanged); | ||
117 | connect(m_splitView, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); | 110 | connect(m_splitView, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); | ||
118 | connect(m_editableUrl, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); | 111 | connect(m_editableUrl, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); | ||
119 | connect(m_showFullPath, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); | 112 | connect(m_showFullPath, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); | ||
120 | connect(m_filterBar, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); | 113 | 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