File indexing completed on 2024-11-10 05:13:56

0001 /*
0002     SPDX-FileCopyrightText: 1999 Espen Sand <espen@kde.org>
0003     SPDX-FileCopyrightText: 2009 Dario Andres Rodriguez <andresbajotierra@gmail.com>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #include "optiondialog.h"
0009 
0010 #include "kdfconfig.h"
0011 #include "mntconfig.h"
0012 
0013 #include <KHelpClient>
0014 
0015 COptionDialog::COptionDialog( QWidget *parent )
0016         :KPageDialog( parent )
0017 {
0018     setWindowTitle( i18n("Configure") );
0019     setStandardButtons( QDialogButtonBox::Help|QDialogButtonBox::Apply|QDialogButtonBox::Ok|QDialogButtonBox::Cancel );
0020     setFaceType( KPageDialog::Tabbed );
0021 
0022     mConf = new KDFConfigWidget( this );
0023     connect( mConf, &KDFConfigWidget::configChanged, this, &COptionDialog::slotChanged );
0024     addPage( mConf, i18n("General Settings") );
0025 
0026     mMnt = new MntConfigWidget( this );
0027     connect( mMnt, &MntConfigWidget::configChanged, this, &COptionDialog::slotChanged );
0028     addPage( mMnt, i18n("Mount Commands") );
0029 
0030     button(QDialogButtonBox::Apply)->setEnabled(false);
0031     dataChanged = false;
0032     connect(button(QDialogButtonBox::Ok), &QAbstractButton::clicked,this,&COptionDialog::slotOk);
0033     connect(button(QDialogButtonBox::Apply), &QAbstractButton::clicked,this,&COptionDialog::slotApply);
0034     connect(button(QDialogButtonBox::Help), &QAbstractButton::clicked, this, &COptionDialog::slotHelp);
0035 }
0036 
0037 
0038 COptionDialog::~COptionDialog()
0039 {
0040 }
0041 
0042 
0043 void COptionDialog::slotOk()
0044 {
0045     if( dataChanged )
0046         slotApply();
0047     accept();
0048 }
0049 
0050 
0051 void COptionDialog::slotApply()
0052 {
0053     mConf->applySettings();
0054     mMnt->applySettings();
0055     Q_EMIT valueChanged();
0056     button(QDialogButtonBox::Apply)->setEnabled(false);
0057     dataChanged = false;
0058 }
0059 
0060 void COptionDialog::slotChanged()
0061 {
0062     button(QDialogButtonBox::Apply)->setEnabled(true);
0063     dataChanged = true;
0064 }
0065 
0066 void COptionDialog::slotHelp()
0067 {
0068     KHelpClient::invokeHelp(QLatin1String(""), QStringLiteral("kdf"));
0069 }
0070 
0071 
0072 
0073 #include "moc_optiondialog.cpp"