22 #include "prefsmodule.h"
24 #include <tdeaboutdata.h>
26 #include <kcombobox.h>
27 #include <tdelocale.h>
32 #include <tqbuttongroup.h>
34 #include <tdemacros.h>
38 TDE_EXPORT TDECModule *create_komposerconfig( TQWidget *parent,
const char * ) {
39 return new Komposer::PrefsModule( parent,
"komposerprefs" );
44 PrefsModule::PrefsModule( TQWidget *parent,
const char *name )
45 : KPrefsModule(
Komposer::Prefs::self(), parent, name )
47 TQVBoxLayout *topLayout =
new TQVBoxLayout(
this );
49 EditorSelection *editors =
new EditorSelection( i18n(
"Editors" ),
50 Komposer::Prefs::self()->m_activeEditor,
52 topLayout->addWidget( editors->groupBox() );
60 PrefsModule::aboutData()
const
62 TDEAboutData *about =
new TDEAboutData( I18N_NOOP(
"komposerconfig" ),
63 I18N_NOOP(
"TDE Komposer" ),
64 0, 0, TDEAboutData::License_LGPL,
65 I18N_NOOP(
"(c), 2003-2004 Zack Rusin" ) );
67 about->addAuthor(
"Zack Rusin", 0,
"zack@kde.org" );;
73 EditorSelection::EditorSelection(
const TQString &text, TQString &reference,
75 : m_reference( reference )
77 m_box =
new TQGroupBox( 0, TQt::Vertical, text, parent );
78 TQVBoxLayout *boxLayout =
new TQVBoxLayout( m_box->layout() );
79 boxLayout->setAlignment( TQt::AlignTop );
81 m_editorsCombo =
new KComboBox( m_box );
82 boxLayout->addWidget( m_editorsCombo );
84 connect( m_editorsCombo, TQ_SIGNAL(activated(const TQString&)),
85 TQ_SLOT(slotActivated(
const TQString&)) );
88 EditorSelection::~EditorSelection()
93 EditorSelection::groupBox()
const
99 EditorSelection::readConfig()
101 m_editorsCombo->clear();
103 TDETrader::OfferList editors = TDETrader::self()->query(
104 TQString::fromLatin1(
"Komposer/Editor" ) );
105 TDETrader::OfferList::ConstIterator it;
107 for ( it = editors.begin(); it != editors.end(); ++it, ++i ) {
108 if ( !(*it)->hasServiceType( TQString::fromLatin1(
"Komposer/Editor" ) ) )
111 TQString name = (*it)->property(
"X-TDE-KomposerIdentifier" ).toString();
112 m_editorsCombo->insertItem( name );
113 if ( m_reference.contains( name ) )
114 m_editorsCombo->setCurrentItem( i );
118 void EditorSelection::writeConfig()
120 m_reference = m_services[ m_editorsCombo->currentText()]->
121 property(
"X-TDE-KomposerIdentifier" ).toString();
125 EditorSelection::slotActivated(
const TQString &editor )
127 if ( !editor.isEmpty() )
132 EditorSelection::setItem(
const TQString &str )
134 for (
int i = 0; i < m_editorsCombo->count(); ++i ) {
135 if ( m_editorsCombo->text( i ) == str ) {
136 m_editorsCombo->setCurrentItem( i );
142 #include "prefsmodule.moc"