File indexing completed on 2025-01-26 05:09:31
0001 /* 0002 * This file is part of the KDE wacomtablet project. For copyright 0003 * information and license terms see the AUTHORS and COPYING files 0004 * in the top-level directory of this distribution. 0005 * 0006 * This program is free software; you can redistribute it and/or 0007 * modify it under the terms of the GNU General Public License as 0008 * published by the Free Software Foundation; either version 2 of 0009 * the License, or (at your option) any later version. 0010 * 0011 * This program is distributed in the hope that it will be useful, 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0014 * GNU General Public License for more details. 0015 * 0016 * You should have received a copy of the GNU General Public License 0017 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0018 */ 0019 0020 #include "kcmwacomtablet.h" 0021 #include "../wacomtablet-version.h" 0022 #include "kcmwacomtabletwidget.h" 0023 0024 #include "aboutdata.h" 0025 #include "dbustabletinterface.h" 0026 #include "profilemanagement.h" 0027 0028 // KDE includes 0029 #include <KAboutData> 0030 #include <KLocalizedString> 0031 #include <KPluginFactory> 0032 0033 // Qt includes 0034 #include <QVBoxLayout> 0035 0036 using namespace Wacom; 0037 0038 K_PLUGIN_CLASS_WITH_JSON(KCMWacomTablet, "kcm_wacomtablet.json") 0039 0040 KCMWacomTablet::KCMWacomTablet(QObject *parent, const KPluginMetaData &md) 0041 : KCModule(parent, md) 0042 , m_changed(false) 0043 { 0044 initUi(); 0045 } 0046 0047 KCMWacomTablet::~KCMWacomTablet() 0048 { 0049 if (m_layout) { 0050 delete m_layout; 0051 } 0052 0053 if (m_tabletWidget) { 0054 delete m_tabletWidget; 0055 } 0056 0057 // This makes sure all global shortcuts are restored by our daemon. 0058 // Unfortunately KAction disables all global shortcuts on destruction. 0059 // There is no way to stop it from doing that so we have to use this 0060 // workaround and reload the current profile here. 0061 // BUG restore global shortcuts on exit 0062 // DBusTabletInterface::instance().setProfile( d->tabletId, , ProfileManagement::instance().profileName() ); 0063 } 0064 0065 void KCMWacomTablet::initUi() 0066 { 0067 setButtons(Apply | Help); 0068 0069 // setup module ui 0070 m_tabletWidget = new KCMWacomTabletWidget(widget()); 0071 m_layout = new QVBoxLayout(widget()); 0072 m_layout->setContentsMargins({}); 0073 m_layout->addWidget(m_tabletWidget); 0074 0075 // connect signals 0076 connect(m_tabletWidget, &KCMWacomTabletWidget::changed, this, &KCMWacomTablet::setNeedsSave); 0077 } 0078 0079 void KCMWacomTablet::load() 0080 { 0081 if (m_tabletWidget) { 0082 m_tabletWidget->reloadProfile(); 0083 } 0084 0085 setNeedsSave(false); 0086 } 0087 0088 void KCMWacomTablet::save() 0089 { 0090 if (m_tabletWidget) { 0091 m_tabletWidget->saveProfile(); 0092 } 0093 0094 setNeedsSave(false); 0095 } 0096 0097 #include "kcmwacomtablet.moc" 0098 0099 #include "moc_kcmwacomtablet.cpp"