File indexing completed on 2021-12-21 13:27:52

0001 /**
0002  * Copyright (C) 2004 Michael Pyne <mpyne@kde.org>
0003  *
0004  * This program is free software; you can redistribute it and/or modify it under
0005  * the terms of the GNU General Public License as published by the Free Software
0006  * Foundation; either version 2 of the License, or (at your option) any later
0007  * version.
0008  *
0009  * This program is distributed in the hope that it will be useful, but WITHOUT ANY
0010  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
0011  * PARTICULAR PURPOSE. See the GNU General Public License for more details.
0012  *
0013  * You should have received a copy of the GNU General Public License along with
0014  * this program.  If not, see <http://www.gnu.org/licenses/>.
0015  */
0016 
0017 #include "exampleoptions.h"
0018 
0019 #include <QUrl>
0020 #include <QHideEvent>
0021 #include <QShowEvent>
0022 #include <QVBoxLayout>
0023 
0024 #include <KLocalizedString>
0025 
0026 ExampleOptions::ExampleOptions(QWidget *parent) :
0027     QWidget(parent)
0028 {
0029     setupUi(this);
0030 
0031     setObjectName(QLatin1String("example options widget"));
0032 }
0033 
0034 void ExampleOptions::exampleSelectionChanged()
0035 {
0036     if(m_fileTagsButton->isChecked())
0037         emit fileChanged();
0038     else
0039         emit dataChanged();
0040 }
0041 
0042 void ExampleOptions::exampleDataChanged()
0043 {
0044     emit dataChanged();
0045 }
0046 
0047 void ExampleOptions::exampleFileChanged()
0048 {
0049     emit fileChanged();
0050 }
0051 
0052 ExampleOptionsDialog::ExampleOptionsDialog(QWidget *parent) :
0053     QDialog(parent)
0054 {
0055     setObjectName(QLatin1String("example options dialog"));
0056     setWindowTitle(i18n("JuK"));
0057     QVBoxLayout *l = new QVBoxLayout(this);
0058 
0059     m_options = new ExampleOptions(this);
0060     m_options->m_exampleFile->setMode(KFile::ExistingOnly|KFile::LocalOnly);
0061     l->addWidget(m_options);
0062 
0063     // Forward signals
0064 
0065     connect(m_options, SIGNAL(fileChanged()), SLOT(fileModeSelected()));
0066     connect(m_options, SIGNAL(dataChanged()), SIGNAL(dataChanged()));
0067     connect(m_options->m_exampleFile, &KUrlRequester::urlSelected,
0068             this,                     &ExampleOptionsDialog::urlChanged);
0069     connect(m_options->m_exampleFile, SIGNAL(returnPressed(QString)),
0070             this,                     SIGNAL(fileChanged(QString)));
0071 }
0072 
0073 void ExampleOptionsDialog::urlChanged(const QUrl &url)
0074 {
0075     emit fileChanged(url.path());
0076 }
0077 
0078 void ExampleOptionsDialog::hideEvent(QHideEvent *)
0079 {
0080     emit signalHidden();
0081 }
0082 
0083 void ExampleOptionsDialog::showEvent(QShowEvent *)
0084 {
0085     emit signalShown();
0086 }
0087 
0088 void ExampleOptionsDialog::fileModeSelected()
0089 {
0090     urlChanged(m_options->m_exampleFile->url());
0091 }
0092 
0093 // vim: set et sw=4 tw=0 sta: