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 <QVBoxLayout> | 36 | #include <QFormLayout> | ||
37 | #include <QHBoxLayout> | ||||
37 | 38 | | |||
38 | StartupSettingsPage::StartupSettingsPage(const QUrl& url, QWidget* parent) : | 39 | StartupSettingsPage::StartupSettingsPage(const QUrl& url, QWidget* parent) : | ||
39 | SettingsPageBase(parent), | 40 | SettingsPageBase(parent), | ||
40 | m_url(url), | 41 | m_url(url), | ||
41 | m_homeUrl(nullptr), | 42 | m_homeUrl(nullptr), | ||
42 | m_splitView(nullptr), | 43 | m_splitView(nullptr), | ||
43 | m_editableUrl(nullptr), | 44 | m_editableUrl(nullptr), | ||
44 | m_showFullPath(nullptr), | 45 | m_showFullPath(nullptr), | ||
45 | m_filterBar(nullptr), | 46 | m_filterBar(nullptr), | ||
46 | m_showFullPathInTitlebar(nullptr) | 47 | m_showFullPathInTitlebar(nullptr) | ||
47 | { | 48 | { | ||
48 | QVBoxLayout* topLayout = new QVBoxLayout(this); | 49 | 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 | 50 | | |||
54 | // create 'Home URL' editor | | |||
55 | QGroupBox* homeBox = new QGroupBox(i18nc("@title:group", "Home Folder"), vBox); | | |||
56 | vBoxLayout->addWidget(homeBox); | | |||
57 | | ||||
58 | QWidget* homeUrlBox = new QWidget(homeBox); | | |||
59 | QHBoxLayout *homeUrlBoxLayout = new QHBoxLayout(homeUrlBox); | | |||
60 | homeUrlBoxLayout->setMargin(0); | | |||
61 | 51 | | |||
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! | |||||
62 | QLabel* homeUrlLabel = new QLabel(i18nc("@label:textbox", "Location:"), homeUrlBox); | 52 | // create 'Home URL' editor | ||
63 | homeUrlBoxLayout->addWidget(homeUrlLabel); | 53 | m_homeUrl = new QLineEdit(); | ||
64 | m_homeUrl = new QLineEdit(homeUrlBox); | | |||
65 | homeUrlBoxLayout->addWidget(m_homeUrl); | | |||
66 | m_homeUrl->setClearButtonEnabled(true); | 54 | m_homeUrl->setClearButtonEnabled(true); | ||
67 | 55 | | |||
68 | QPushButton* selectHomeUrlButton = new QPushButton(QIcon::fromTheme(QStringLiteral("folder-open")), QString(), homeUrlBox); | 56 | QPushButton* selectHomeUrlButton = new QPushButton(QIcon::fromTheme(QStringLiteral("folder-open")), QString()); | ||
69 | homeUrlBoxLayout->addWidget(selectHomeUrlButton); | | |||
70 | | ||||
71 | #ifndef QT_NO_ACCESSIBILITY | 57 | #ifndef QT_NO_ACCESSIBILITY | ||
72 | selectHomeUrlButton->setAccessibleName(i18nc("@action:button", "Select Home Location")); | 58 | selectHomeUrlButton->setAccessibleName(i18nc("@action:button", "Select Home Location")); | ||
73 | #endif | 59 | #endif | ||
74 | 60 | | |||
75 | connect(selectHomeUrlButton, &QPushButton::clicked, | 61 | QHBoxLayout *homeUrlBoxLayout = new QHBoxLayout(); | ||
76 | this, &StartupSettingsPage::selectHomeUrl); | 62 | homeUrlBoxLayout->setMargin(0); | ||
63 | homeUrlBoxLayout->addWidget(m_homeUrl); | ||||
64 | homeUrlBoxLayout->addWidget(selectHomeUrlButton); | ||||
77 | 65 | | |||
78 | QWidget* buttonBox = new QWidget(homeBox); | 66 | topLayout->addRow(i18nc("@label:textbox", "Location:"), homeUrlBoxLayout); | ||
elvisangelaccio: Please add a parent to this layout | |||||
ngraham: Same ^^ | |||||
79 | QHBoxLayout *buttonBoxLayout = new QHBoxLayout(buttonBox); | 67 | | ||
80 | buttonBoxLayout->setMargin(0); | 68 | QPushButton* useCurrentButton = new QPushButton(i18nc("@action:button", "Use Current Location")); | ||
69 | QPushButton* useDefaultButton = new QPushButton(i18nc("@action:button", "Use Default Location")); | ||||
70 | // FIXME: These need to be wider by default to acount for long test in some locales. I think the bug is elsewhere, maybe on the behavior page where the text is also cut off? | ||||
81 | 71 | | |||
82 | QPushButton* useCurrentButton = new QPushButton(i18nc("@action:button", "Use Current Location"), buttonBox); | 72 | QHBoxLayout *buttonBoxLayout = new QHBoxLayout(); | ||
73 | buttonBoxLayout->setMargin(0); | ||||
83 | buttonBoxLayout->addWidget(useCurrentButton); | 74 | buttonBoxLayout->addWidget(useCurrentButton); | ||
84 | connect(useCurrentButton, &QPushButton::clicked, | 75 | buttonBoxLayout->setStretchFactor(useCurrentButton, 1); | ||
85 | this, &StartupSettingsPage::useCurrentLocation); | | |||
86 | QPushButton* useDefaultButton = new QPushButton(i18nc("@action:button", "Use Default Location"), buttonBox); | | |||
87 | buttonBoxLayout->addWidget(useDefaultButton); | 76 | buttonBoxLayout->addWidget(useDefaultButton); | ||
88 | connect(useDefaultButton, &QPushButton::clicked, | 77 | buttonBoxLayout->setStretchFactor(useDefaultButton, 1); | ||
89 | this, &StartupSettingsPage::useDefaultLocation); | 78 | topLayout->addRow(QString(), buttonBoxLayout); | ||
79 | | ||||
80 | | ||||
81 | topLayout->addItem(new QSpacerItem(0,12, QSizePolicy::Fixed, QSizePolicy::Fixed)); | ||||
90 | 82 | | |||
91 | QVBoxLayout* homeBoxLayout = new QVBoxLayout(homeBox); | | |||
92 | homeBoxLayout->addWidget(homeUrlBox); | | |||
93 | homeBoxLayout->addWidget(buttonBox); | | |||
94 | 83 | | |||
95 | // create 'Split view', 'Show full path', 'Editable location' and 'Filter bar' checkboxes | 84 | // 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); | 85 | m_splitView = new QCheckBox(i18nc("@option:check Startup Settings", "Split view mode")); | ||
97 | vBoxLayout->addWidget(m_splitView); | 86 | m_editableUrl = new QCheckBox(i18nc("@option:check Startup Settings", "Editable location bar")); | ||
98 | m_editableUrl = new QCheckBox(i18nc("@option:check Startup Settings", "Editable location bar"), vBox); | 87 | m_showFullPath = new QCheckBox(i18nc("@option:check Startup Settings", "Show full path inside location bar")); | ||
99 | vBoxLayout->addWidget(m_editableUrl); | 88 | m_filterBar = new QCheckBox(i18nc("@option:check Startup Settings", "Show filter bar")); | ||
100 | m_showFullPath = new QCheckBox(i18nc("@option:check Startup Settings", "Show full path inside location bar"), vBox); | 89 | m_showFullPathInTitlebar = new QCheckBox(i18nc("@option:check Startup Settings", "Show full path in title bar")); | ||
101 | vBoxLayout->addWidget(m_showFullPath); | 90 | | ||
102 | m_filterBar = new QCheckBox(i18nc("@option:check Startup Settings", "Show filter bar"), vBox); | 91 | topLayout->addRow(i18nc("@label:checkbox", "View options:"), m_splitView); | ||
103 | vBoxLayout->addWidget(m_filterBar); | 92 | topLayout->addRow(QString(), m_editableUrl); | ||
104 | m_showFullPathInTitlebar = new QCheckBox(i18nc("@option:check Startup Settings", "Show full path in title bar"), vBox); | 93 | topLayout->addRow(QString(), m_showFullPath); | ||
105 | vBoxLayout->addWidget(m_showFullPathInTitlebar); | 94 | topLayout->addRow(QString(), m_filterBar); | ||
106 | 95 | topLayout->addRow(QString(), m_showFullPathInTitlebar); | |||
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 | 96 | | |||
112 | topLayout->addWidget(vBox); | | |||
113 | 97 | | |||
114 | loadSettings(); | 98 | loadSettings(); | ||
115 | 99 | | |||
100 | connect(selectHomeUrlButton, &QPushButton::clicked, this, &StartupSettingsPage::selectHomeUrl); | ||||
101 | connect(useCurrentButton, &QPushButton::clicked, this, &StartupSettingsPage::useCurrentLocation); | ||||
102 | connect(useDefaultButton, &QPushButton::clicked, this, &StartupSettingsPage::useDefaultLocation); | ||||
116 | connect(m_homeUrl, &QLineEdit::textChanged, this, &StartupSettingsPage::slotSettingsChanged); | 103 | connect(m_homeUrl, &QLineEdit::textChanged, this, &StartupSettingsPage::slotSettingsChanged); | ||
117 | connect(m_splitView, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); | 104 | connect(m_splitView, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); | ||
118 | connect(m_editableUrl, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); | 105 | connect(m_editableUrl, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); | ||
119 | connect(m_showFullPath, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); | 106 | connect(m_showFullPath, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); | ||
120 | connect(m_filterBar, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); | 107 | connect(m_filterBar, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); | ||
121 | connect(m_showFullPathInTitlebar, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); | 108 | connect(m_showFullPathInTitlebar, &QCheckBox::toggled, this, &StartupSettingsPage::slotSettingsChanged); | ||
122 | } | 109 | } | ||
123 | 110 | | |||
▲ Show 20 Lines • Show All 72 Lines • Show Last 20 Lines |
Please add a parent to this layout