00001
00022
#include "prefsmodule.h"
00023
00024
#include <kaboutdata.h>
00025
#include <kdebug.h>
00026
#include <kcombobox.h>
00027
#include <klocale.h>
00028
#include <ktrader.h>
00029
00030
#include <qlayout.h>
00031
#include <qlabel.h>
00032
#include <qbuttongroup.h>
00033
00034
extern "C"
00035 {
00036 KCModule *create_komposerconfig(
QWidget *parent,
const char * ) {
00037
return new Komposer::PrefsModule( parent,
"komposerprefs" );
00038 }
00039 }
00040
using namespace Komposer;
00041
00042 PrefsModule::PrefsModule(
QWidget *parent,
const char *name )
00043 : KPrefsModule( Komposer::Prefs::self(), parent, name )
00044 {
00045
QVBoxLayout *topLayout =
new QVBoxLayout(
this );
00046
00047 EditorSelection *editors =
new EditorSelection( i18n(
"Editors" ),
00048 Komposer::Prefs::self()->m_activeEditor,
00049
this );
00050 topLayout->addWidget( editors->groupBox() );
00051
00052 addWid( editors );
00053
00054 load();
00055 }
00056
00057
const KAboutData*
00058 PrefsModule::aboutData()
const
00059
{
00060 KAboutData *about =
new KAboutData( I18N_NOOP(
"komposerconfig" ),
00061 I18N_NOOP(
"KDE Komposer" ),
00062 0, 0, KAboutData::License_LGPL,
00063 I18N_NOOP(
"(c), 2003 Zack Rusin" ) );
00064
00065 about->addAuthor(
"Zack Rusin", 0,
"zack@kde.org" );;
00066
00067
return about;
00068 }
00069
00070
00071 EditorSelection::EditorSelection(
const QString& text,
QString& reference,
00072
QWidget *parent )
00073 : m_reference( reference )
00074 {
00075 m_box =
new QGroupBox( 0, Qt::Vertical, text, parent );
00076 QVBoxLayout *boxLayout =
new QVBoxLayout( m_box->layout() );
00077 boxLayout->setAlignment( Qt::AlignTop );
00078
00079 m_editorsCombo =
new KComboBox( m_box );
00080 boxLayout->addWidget( m_editorsCombo );
00081
00082 connect( m_editorsCombo, SIGNAL(activated(
const QString&)),
00083 SLOT(slotActivated(
const QString&)) );
00084 }
00085
00086 EditorSelection::~EditorSelection()
00087 {
00088 }
00089
00090 QGroupBox*
00091 EditorSelection::groupBox() const
00092 {
00093
return m_box;
00094 }
00095
00096
void
00097 EditorSelection::readConfig()
00098 {
00099 m_editorsCombo->clear();
00100
00101 KTrader::OfferList editors = KTrader::self()->query( QString::fromLatin1(
"Komposer/Editor" ) );
00102 KTrader::OfferList::ConstIterator it;
00103
int i = 0;
00104
for ( it = editors.begin(); it != editors.end(); ++it, ++i ) {
00105
if ( !(*it)->hasServiceType( QString::fromLatin1(
"Komposer/Editor" ) ) )
00106
continue;
00107
00108
QString name = (*it)->property(
"X-KDE-KomposerIdentifier" ).toString();
00109 m_editorsCombo->insertItem( name );
00110
if ( m_reference.contains( name ) )
00111 m_editorsCombo->setCurrentItem( i );
00112 }
00113 }
00114
00115
void EditorSelection::writeConfig()
00116 {
00117 m_reference = m_services[ m_editorsCombo->currentText()]->
00118 property(
"X-KDE-KomposerIdentifier" ).toString();
00119 }
00120
00121
void
00122 EditorSelection::slotActivated(
const QString& editor )
00123 {
00124
if ( !editor.isEmpty() )
00125 emit changed();
00126 }
00127
00128
void
00129 EditorSelection::setItem(
const QString& str )
00130 {
00131
for (
int i = 0; i < m_editorsCombo->count(); ++i ) {
00132
if ( m_editorsCombo->text( i ) == str ) {
00133 m_editorsCombo->setCurrentItem( i );
00134
break;
00135 }
00136 }
00137 }
00138
00139
#include "prefsmodule.moc"