Commit 81d4f7c5 authored by Stefano Crocco's avatar Stefano Crocco
Browse files

Make it clearer where the user should enter the custom start page

When the user chooses to use a custom start page, he may not realize
where he's supposed to enter it and may think that it's the "Home page"
widget (also because most browsers don't allow to customize the home
page and the starting page separately).

To improve this situation, given that adding a label to the widget would
take too much space, the following changes have been implemented:
- only display the custom start page widget when the user actually
  chooses to use a custom start page
- add a message widget warning the user if he leaves the widget empty.

BUG: 449874
parent 72ddfa7d
Pipeline #146056 passed with stage
in 4 minutes and 52 seconds
......@@ -27,6 +27,7 @@
#include <kservice.h>
#include <KConfigGroup>
#include <KSharedConfig>
#include <KMessageWidget>
// Local
#include "ui_advancedTabOptions.h"
......@@ -40,7 +41,7 @@ enum StartPage { ShowAboutPage, ShowStartUrlPage, ShowBlankPage, ShowBookmarksPa
//-----------------------------------------------------------------------------
KKonqGeneralOptions::KKonqGeneralOptions(QWidget *parent, const QVariantList &)
: KCModule(parent)
: KCModule(parent), m_emptyStartUrlWarning(new KMessageWidget(this))
{
m_pConfig = KSharedConfig::openConfig(QStringLiteral("konquerorrc"), KConfig::NoGlobals);
QVBoxLayout *lay = new QVBoxLayout(this);
......@@ -74,6 +75,12 @@ void KKonqGeneralOptions::addHomeUrlWidgets(QVBoxLayout *lay)
QFormLayout *formLayout = new QFormLayout;
lay->addLayout(formLayout);
m_emptyStartUrlWarning->setText(i18nc("The user chose to use a custom start page but left the corresponding field empty", "Please, insert the custom start page"));
m_emptyStartUrlWarning->setMessageType(KMessageWidget::Warning);
m_emptyStartUrlWarning->setIcon(QIcon::fromTheme("dialog-warning"));
m_emptyStartUrlWarning->hide();
formLayout->addRow(m_emptyStartUrlWarning);
QLabel *startLabel = new QLabel(i18nc("@label:listbox", "When &Konqueror starts:"), this);
QWidget *containerWidget = new QWidget(this);
......@@ -94,15 +101,16 @@ void KKonqGeneralOptions::addHomeUrlWidgets(QVBoxLayout *lay)
startURL = new QLineEdit(this);
startURL->setWindowTitle(i18nc("@title:window", "Select Start Page"));
hboxLayout->addWidget(startURL);
connect(startURL, &QLineEdit::textChanged, this, &KKonqGeneralOptions::slotChanged);
connect(startURL, &QLineEdit::textChanged, this, &KKonqGeneralOptions::displayEmpytStartPageWarningIfNeeded);
QString startstr = i18n("This is the URL of the web page "
"Konqueror will show when starting.");
startURL->setToolTip(startstr);
connect(m_startCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [this](int idx) {
startURL->setEnabled(idx == ShowStartUrlPage);
startURL->setVisible(idx == ShowStartUrlPage);
displayEmpytStartPageWarningIfNeeded();
});
startURL->setEnabled(false);
startURL->hide();
////
......@@ -148,6 +156,16 @@ KKonqGeneralOptions::~KKonqGeneralOptions()
delete tabOptions;
}
void KKonqGeneralOptions::displayEmpytStartPageWarningIfNeeded()
{
qDebug() << "displayEmpytStartPageWarningIfNeeded: startUrl visible?" << startURL->isVisible() << "text is empty?" << startURL->text().isEmpty();
if (startURL->isVisible() && startURL->text().isEmpty()) {
m_emptyStartUrlWarning->animatedShow();
} else if (m_emptyStartUrlWarning->isVisible()) {
m_emptyStartUrlWarning->animatedHide();
}
}
static StartPage urlToStartPageEnum(const QString &startUrl)
{
if (startUrl == QLatin1String("konq:blank")) {
......@@ -240,10 +258,11 @@ void KKonqGeneralOptions::save()
{
KConfigGroup userSettings(m_pConfig, "UserSettings");
const int startComboIndex = m_startCombo->currentIndex();
const int choice = m_startCombo->itemData(startComboIndex).toInt();
const StartPage choice = static_cast<StartPage>(m_startCombo->itemData(startComboIndex).toInt());
QString startUrl(startPageEnumToUrl(static_cast<StartPage>(choice)));
if (startUrl.isEmpty())
if (startUrl.isEmpty()) {
startUrl = startURL->text();
}
userSettings.writeEntry("StartURL", startUrl);
userSettings.writeEntry("HomeURL", homeURL->text());
userSettings.writeEntry("AlwaysDuplicatePageWhenSplittingView", m_splitBehaviour->currentIndex() == 0);
......
......@@ -18,6 +18,7 @@ class QComboBox;
class QLineEdit;
class Ui_advancedTabOptions;
class QVBoxLayout;
class KMessageWidget;
class KKonqGeneralOptions : public KCModule
{
......@@ -32,6 +33,7 @@ public:
private Q_SLOTS:
void slotChanged();
void displayEmpytStartPageWarningIfNeeded();
private:
void addHomeUrlWidgets(QVBoxLayout *);
......@@ -43,6 +45,7 @@ private:
QLineEdit *startURL;
QComboBox *m_webEngineCombo;
QComboBox *m_splitBehaviour;
KMessageWidget *m_emptyStartUrlWarning;
Ui_advancedTabOptions *tabOptions;
};
......
Supports Markdown
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