File indexing completed on 2024-05-12 17:07:10

0001 /*
0002     "Desktop Options" Tab for KDesktop configuration
0003 
0004     SPDX-FileCopyrightText: 1996 Martin R. Jones
0005     SPDX-FileCopyrightText: 1998 Bernd Wuebben
0006     SPDX-FileCopyrightText: 1998 Christian Tibirna
0007     SPDX-FileCopyrightText: 1998-2007 David Faure <faure@kde.org>
0008     SPDX-FileCopyrightText: 2010 Matthias Fuchs <mat69@gmx.net>
0009 
0010     SPDX-License-Identifier: GPL-2.0-or-later
0011 */
0012 
0013 // Own
0014 #include "globalpaths.h"
0015 #include "desktoppathsdata.h"
0016 #include "desktoppathssettings.h"
0017 #include "ui_globalpaths.h"
0018 
0019 #include <KLineEdit>
0020 #include <KPluginFactory>
0021 #include <KUrlRequester>
0022 
0023 K_PLUGIN_FACTORY_WITH_JSON(KcmDesktopPathsFactory, "kcm_desktoppaths.json", registerPlugin<DesktopPathConfig>(); registerPlugin<DesktopPathsData>();)
0024 
0025 DesktopPathConfig::DesktopPathConfig(QWidget *parent, const QVariantList &)
0026     : KCModule(parent)
0027     , m_ui(new Ui::DesktopPathsView)
0028     , m_data(new DesktopPathsData(this))
0029 {
0030     m_ui->setupUi(this);
0031     setQuickHelp(
0032         i18n("<h1>Paths</h1>\n"
0033              "This module allows you to choose where in the filesystem the "
0034              "files on your desktop should be stored.\n"
0035              "Use the \"Whats This?\" (Shift+F1) to get help on specific options."));
0036     addConfig(m_data->settings(), this);
0037 
0038     connect(this, &DesktopPathConfig::defaultsIndicatorsVisibleChanged, this, &DesktopPathConfig::updateDefaultIndicator);
0039     connect(m_data->settings(), &DesktopPathsSettings::widgetChanged, this, &DesktopPathConfig::updateDefaultIndicator);
0040 }
0041 
0042 DesktopPathConfig::~DesktopPathConfig()
0043 {
0044 }
0045 
0046 void DesktopPathConfig::updateDefaultIndicator()
0047 {
0048     setDefaultIndicatorVisible(m_ui->kcfg_desktopLocation, m_data->settings()->defaultDesktopLocation());
0049     setDefaultIndicatorVisible(m_ui->kcfg_documentsLocation, m_data->settings()->defaultDocumentsLocation());
0050     setDefaultIndicatorVisible(m_ui->kcfg_downloadsLocation, m_data->settings()->defaultDownloadsLocation());
0051     setDefaultIndicatorVisible(m_ui->kcfg_musicLocation, m_data->settings()->defaultMusicLocation());
0052     setDefaultIndicatorVisible(m_ui->kcfg_picturesLocation, m_data->settings()->defaultPicturesLocation());
0053     setDefaultIndicatorVisible(m_ui->kcfg_videosLocation, m_data->settings()->defaultVideosLocation());
0054     setDefaultIndicatorVisible(m_ui->kcfg_publicLocation, m_data->settings()->defaultPublicLocation());
0055     setDefaultIndicatorVisible(m_ui->kcfg_templatesLocation, m_data->settings()->defaultTemplatesLocation());
0056 }
0057 
0058 void DesktopPathConfig::setDefaultIndicatorVisible(KUrlRequester *widget, const QVariant &defaultValue)
0059 {
0060     bool isDefault = widget->url() == defaultValue.toUrl();
0061     widget->lineEdit()->setProperty("_kde_highlight_neutral", defaultsIndicatorsVisible() && !isDefault);
0062     widget->update();
0063 }
0064 
0065 #include "globalpaths.moc"