prefsmodule.cpp
1
22#include "prefsmodule.h"
23
24#include <tdeaboutdata.h>
25#include <kdebug.h>
26#include <kcombobox.h>
27#include <tdelocale.h>
28#include <ktrader.h>
29
30#include <tqlayout.h>
31#include <tqlabel.h>
32#include <tqbuttongroup.h>
33
34#include <tdemacros.h>
35
36extern "C"
37{
38 TDE_EXPORT TDECModule *create_komposerconfig( TQWidget *parent, const char * ) {
39 return new Komposer::PrefsModule( parent, "komposerprefs" );
40 }
41}
42using namespace Komposer;
43
44PrefsModule::PrefsModule( TQWidget *parent, const char *name )
45 : KPrefsModule( Komposer::Prefs::self(), parent, name )
46{
47 TQVBoxLayout *topLayout = new TQVBoxLayout( this );
48
49 EditorSelection *editors = new EditorSelection( i18n( "Editors" ),
50 Komposer::Prefs::self()->m_activeEditor,
51 this );
52 topLayout->addWidget( editors->groupBox() );
53
54 addWid( editors );
55
56 load();
57}
58
59const TDEAboutData*
60PrefsModule::aboutData() const
61{
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" ) );
66
67 about->addAuthor( "Zack Rusin", 0, "zack@kde.org" );;
68
69 return about;
70}
71
72
73EditorSelection::EditorSelection( const TQString &text, TQString &reference,
74 TQWidget *parent )
75 : m_reference( reference )
76{
77 m_box = new TQGroupBox( 0, TQt::Vertical, text, parent );
78 TQVBoxLayout *boxLayout = new TQVBoxLayout( m_box->layout() );
79 boxLayout->setAlignment( TQt::AlignTop );
80
81 m_editorsCombo = new KComboBox( m_box );
82 boxLayout->addWidget( m_editorsCombo );
83
84 connect( m_editorsCombo, TQ_SIGNAL(activated(const TQString&)),
85 TQ_SLOT(slotActivated(const TQString&)) );
86}
87
88EditorSelection::~EditorSelection()
89{
90}
91
92TQGroupBox*
93EditorSelection::groupBox() const
94{
95 return m_box;
96}
97
98void
99EditorSelection::readConfig()
100{
101 m_editorsCombo->clear();
102
103 TDETrader::OfferList editors = TDETrader::self()->query(
104 TQString::fromLatin1( "Komposer/Editor" ) );
105 TDETrader::OfferList::ConstIterator it;
106 int i = 0;
107 for ( it = editors.begin(); it != editors.end(); ++it, ++i ) {
108 if ( !(*it)->hasServiceType( TQString::fromLatin1( "Komposer/Editor" ) ) )
109 continue;
110
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 );
115 }
116}
117
118void EditorSelection::writeConfig()
119{
120 m_reference = m_services[ m_editorsCombo->currentText()]->
121 property( "X-TDE-KomposerIdentifier" ).toString();
122}
123
124void
125EditorSelection::slotActivated( const TQString &editor )
126{
127 if ( !editor.isEmpty() )
128 emit changed();
129}
130
131void
132EditorSelection::setItem( const TQString &str )
133{
134 for ( int i = 0; i < m_editorsCombo->count(); ++i ) {
135 if ( m_editorsCombo->text( i ) == str ) {
136 m_editorsCombo->setCurrentItem( i );
137 break;
138 }
139 }
140}
141
142#include "prefsmodule.moc"
attachment.h
Definition: attachment.h:29