kpilot

notepad-factory.cc

Go to the documentation of this file.
00001 /* KPilot
00002 **
00003 ** Copyright (C) 2004 by Adriaan de Groot, Joern Ahrens
00004 **
00005 ** This file defines the factory for the notepad-conduit plugin.
00006 */
00007 
00008 /*
00009 ** This program is free software; you can redistribute it and/or modify
00010 ** it under the terms of the GNU Lesser General Public License as published by
00011 ** the Free Software Foundation; either version 2.1 of the License, or
00012 ** (at your option) any later version.
00013 **
00014 ** This program is distributed in the hope that it will be useful,
00015 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00017 ** GNU Lesser General Public License for more details.
00018 **
00019 ** You should have received a copy of the GNU Lesser General Public License
00020 ** along with this program in a file called COPYING; if not, write to
00021 ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00022 ** MA 02110-1301, USA.
00023 */
00024 
00025 /*
00026 ** Bug reports and questions can be sent to kde-pim@kde.org
00027 */
00028 
00029 #include "options.h"
00030 
00031 #include <kconfig.h>
00032 #include <kinstance.h>
00033 #include <kaboutdata.h>
00034 #include <kurlrequester.h>
00035 #include <kmessagebox.h>
00036 #include <qlineedit.h>
00037 
00038 #include "pluginfactory.h"
00039 
00040 #include "notepad-conduit.h"     // Conduit action
00041 #include "notepad-setup.h"
00042 #include "notepadconduit.h"     // Settings class
00043 
00044 //----------------------------------------------------------------------------
00045 // Conduit Configuration
00046 //----------------------------------------------------------------------------
00047 class NotepadConduitConfig : public ConduitConfigBase
00048 {
00049 public:
00050     NotepadConduitConfig(QWidget *parent=0L, const char *n=0L);
00051     virtual void commit();
00052     virtual void load();
00053     static ConduitConfigBase *create(QWidget *p, const char *n)
00054     {
00055         return new NotepadConduitConfig(p, n);
00056     };
00057 
00058 protected:
00059     NotepadWidget *fConfigWidget;
00060 } ;
00061 
00062 static KAboutData *createAbout()
00063 {
00064     FUNCTIONSETUP;
00065 
00066     KAboutData *fAbout = new KAboutData("NotepadConduit",
00067         I18N_NOOP("Saves notepads to png files"),
00068         KPILOT_VERSION,
00069         I18N_NOOP("Configures the Notepad Conduit for KPilot"),
00070         KAboutData::License_LGPL,
00071         "(C) 2004, Joern Ahrens");
00072     fAbout->addAuthor("Joern Ahrens",
00073         I18N_NOOP("Primary Author"),
00074         "kde@jokele.de",
00075         "http://www.jokele.de/");
00076     fAbout->addCredit("Adriaan de Groot");
00077     fAbout->addCredit("Angus Ainslies",
00078         I18N_NOOP("Notepad conduit is based on Angus' read-notepad, part of pilot-link" ));
00079     return fAbout;
00080 }
00081 
00082 
00083 NotepadConduitConfig::NotepadConduitConfig(QWidget *p, const char *n) :
00084     ConduitConfigBase(p, n),
00085     fConfigWidget(new NotepadWidget(p))
00086 {
00087     FUNCTIONSETUP;
00088 
00089     fConduitName = i18n("Notepad");
00090     ConduitConfigBase::addAboutPage(fConfigWidget->tabWidget, createAbout());
00091     fWidget=fConfigWidget;
00092     QObject::connect(fConfigWidget->fOutputDirectory, SIGNAL(textChanged(const QString&)),
00093         this, SLOT(modified()));
00094     fConfigWidget->fOutputDirectory->setMode(KFile::Directory |
00095                                             KFile::LocalOnly);
00096 }
00097 
00098 /* virtual */ void NotepadConduitConfig::commit()
00099 {
00100     FUNCTIONSETUP;
00101 
00102     NotepadConduitSettings::setOutputDirectory(fConfigWidget->fOutputDirectory->url());
00103     NotepadConduitSettings::self()->writeConfig();
00104 }
00105 
00106 /* virtual */ void NotepadConduitConfig::load()
00107 {
00108     FUNCTIONSETUP;
00109 
00110     NotepadConduitSettings::self()->readConfig();
00111     fConfigWidget->fOutputDirectory->setURL(NotepadConduitSettings::outputDirectory());
00112     fModified=false;
00113 }
00114 
00115 extern "C"
00116 {
00117 
00118 void *init_conduit_notepad()
00119 {
00120     return new ConduitFactory<NotepadConduitConfig,NotepadConduit>(0,"abbrowserconduit");
00121 }
00122 
00123 }
00124