File indexing completed on 2024-05-12 16:37:19
0001 /* This file is part of the KDE project 0002 * Copyright (C) 2019 Dag Andersen <danders@get2net.dk> 0003 * 0004 * This library is free software; you can redistribute it and/or 0005 * modify it under the terms of the GNU Library General Public 0006 * License as published by the Free Software Foundation; either 0007 * version 2 of the License, or (at your option) any later version. 0008 * 0009 * This library is distributed in the hope that it will be useful, 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 * Library General Public License for more details. 0013 * 0014 * You should have received a copy of the GNU Library General Public License 0015 * along with this library; see the file COPYING.LIB. If not, write to 0016 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0017 * Boston, MA 02110-1301, USA. 0018 */ 0019 0020 #include "ConfigDialog.h" 0021 0022 #include "ConfigProjectPanel.h" 0023 #include "ConfigWorkVacationPanel.h" 0024 #include "kpttaskdefaultpanel.h" 0025 #include "kptworkpackageconfigpanel.h" 0026 #include "kptcolorsconfigpanel.h" 0027 #include "ConfigDocumentationPanel.h" 0028 #include "ConfigTaskModulesPanel.h" 0029 #include "ConfigProjectTemplatesPanel.h" 0030 0031 #include <calligraplansettings.h> 0032 #include <Help.h> 0033 #include <KoIcon.h> 0034 0035 #include <KConfigSkeleton> 0036 #include <KLocalizedString> 0037 0038 #include <QStandardItem> 0039 #include <QStandardItemModel> 0040 #include <QDebug> 0041 0042 using namespace KPlato; 0043 0044 ConfigDialog::ConfigDialog(QWidget *parent, const QString& name, KConfigSkeleton *config) 0045 : KConfigDialog(parent, name, config) 0046 { 0047 m_pages << addPage(new ConfigProjectPanel(), i18n("Project Defaults"), koIconName("calligraplan")); 0048 m_pages << addPage(new ConfigWorkVacationPanel(), i18n("Work & Vacation"), koIconName("view-calendar")); 0049 m_pages << addPage(new TaskDefaultPanel(), i18n("Task Defaults"), koIconName("view-task")); 0050 m_pages << addPage(new ColorsConfigPanel(), i18n("Task Colors"), koIconName("fill-color")); 0051 ConfigTaskModulesPanel *page = new ConfigTaskModulesPanel(); 0052 m_pages << addPage(page, i18n("Task Modules"), koIconName("calligraplanwork")); 0053 connect(page, &ConfigTaskModulesPanel::settingsChanged, this, &ConfigDialog::updateButtons); 0054 connect(this, &ConfigDialog::updateWidgetsSettings, page, &ConfigTaskModulesPanel::updateSettings); 0055 connect(this, &ConfigDialog::updateWidgetsData, page, &ConfigTaskModulesPanel::updateWidgets); 0056 m_pages << addPage(new WorkPackageConfigPanel(), i18n("Work Package"), koIconName("calligraplanwork")); 0057 m_pages << addPage(new ConfigDocumentationPanel(), i18n("Documentation"), koIconName("documents")); 0058 0059 ConfigProjectTemplatesPanel *p = new ConfigProjectTemplatesPanel(); 0060 m_pages << addPage(p, i18n("Project Templates"), koIconName("calligraplan")); 0061 connect(p, &ConfigProjectTemplatesPanel::settingsChanged, this, &ConfigDialog::updateButtons); 0062 connect(this, &ConfigDialog::updateWidgetsSettings, p, &ConfigProjectTemplatesPanel::updateSettings); 0063 connect(this, &ConfigDialog::updateWidgetsData, p, &ConfigProjectTemplatesPanel::updateWidgets); 0064 } 0065 0066 void ConfigDialog::updateSettings() 0067 { 0068 emit updateWidgetsSettings(); 0069 0070 KPlatoSettings::self()->save(); 0071 emit settingsUpdated(); 0072 } 0073 0074 void ConfigDialog::updateWidgets() 0075 { 0076 emit updateWidgetsData(); 0077 } 0078 0079 bool ConfigDialog::hasChanged() 0080 { 0081 QWidget *w = currentPage()->widget()->findChild<QWidget*>("ConfigWidget"); 0082 return w ? w->property("hasChanged").toBool() : false; 0083 } 0084 0085 void ConfigDialog::showHelp() 0086 { 0087 Help::invoke("Configure_Plan_Dialog"); 0088 } 0089