File indexing completed on 2023-12-03 08:28:38

0001 /*
0002  * Settings KCM Dialog
0003  *
0004  * Copyright (C) 2011 Martin Klapetek <martin.klapetek@gmail.com>
0005  * Copyright (C) 2014 Siddhartha Sahu <sh.siddhartha@gmail.com>
0006  *
0007  * This library is free software; you can redistribute it and/or
0008  * modify it under the terms of the GNU Lesser General Public
0009  * License as published by the Free Software Foundation; either
0010  * version 2.1 of the License, or (at your option) any later version.
0011  *
0012  * This library is distributed in the hope that it will be useful,
0013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0015  * Lesser General Public License for more details.
0016  *
0017  * You should have received a copy of the GNU Lesser General Public
0018  * License along with this library; if not, write to the Free Software
0019  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
0020  */
0021 
0022 #include "settings-kcm-dialog.h"
0023 
0024 #include <KNotifyConfigWidget>
0025 #include <KMessageBox>
0026 #include <KLocalizedString>
0027 
0028 namespace KTp
0029 {
0030 
0031 SettingsKcmDialog::SettingsKcmDialog(QWidget *parent) :
0032     KSettings::Dialog(parent)
0033 {
0034     setAttribute(Qt::WA_DeleteOnClose);
0035     resize(700, 640);
0036 
0037     
0038     if (KPluginMetaData data(QStringLiteral("plasma/kcms/systemsettings/kcm_kaccounts")); data.isValid()) {
0039         addModule(data);
0040     } else if (KService::serviceByDesktopName(QStringLiteral("kcm_kaccounts"))) {
0041         addModule(QStringLiteral("kcm_kaccounts"));
0042     } else {
0043         KMessageBox::error(this,
0044             i18n("It appears you do not have the IM Accounts control module installed. Please install kaccounts-integration package."),
0045             i18n("IM Accounts KCM Plugin Is Not Installed"));
0046 
0047     }
0048 
0049 }
0050 
0051 void SettingsKcmDialog::addGeneralSettingsModule()
0052 {
0053     addModule(QLatin1String("kcm_ktp_integration_module"));
0054 }
0055 
0056 void SettingsKcmDialog::addNotificationsModule()
0057 {
0058     KNotifyConfigWidget *notificationWidget = new KNotifyConfigWidget(this);
0059     notificationWidget->setApplication(QLatin1String("ktelepathy"));
0060     connect(this, SIGNAL(accepted()),
0061             notificationWidget, SLOT(save()));
0062 
0063     connect(notificationWidget, SIGNAL(changed(bool)),
0064             this, SLOT(enableButtonApply(bool)));
0065 
0066     connect(this, SIGNAL(applyClicked()),
0067             notificationWidget, SLOT(save()));
0068 
0069     KPageWidgetItem *notificationPage = new KPageWidgetItem(notificationWidget, i18n("Notifications"));
0070     notificationPage->setIcon(QIcon::fromTheme(QStringLiteral("preferences-desktop-notification")));
0071     addPage(notificationPage);
0072 }
0073 
0074 }