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