[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kwrite-devel
Subject:    Re: KDE/kdelibs/kate/plugins/wordcompletion
From:       Dominik Haumann <dhdev () gmx ! de>
Date:       2007-08-07 7:11:19
Message-ID: 200708070911.20680.dhdev () gmx ! de
[Download RAW message or body]

On Monday 06 August 2007, Rafael Fernández López wrote:
> SVN commit 697126 by ereslibre:
>
> KPluginSelector meets now doc word completion config dialog. There is an
> important issue here: we should think about how to make changes done on
> the config dialog happen on the current document, apart from saving it
> for later (that is done correctly). I have thought about having static
> properties and methods on the plugin itself, and accessing/setting them
> from the config dialog apart from saving the information to the file.
> That needs the KCModule being linked against the plugin.
>
> CCMAIL: dhdev@gmx.de

Unfortunately, that breaks how the KTextEditor plugin system and its config 
pages and configuration system are designed.
Now readConfig and writeConfig are not used anymore, but that's how plugins 
are supposed to save/load data. Applying the settings is not possible 
anymore, because the config settings are only read in ::addView now.

A way would be to readd the "Configure" button under the KPluginSelector 
widget and handle it this way (see Kate in KDE3). Also other KTE 
implementation that do not use KPluginSelector won't work (yzis). In other 
words: We can't rely on KCModule.

Also possible: If there exists something like:
X-KDE-PluginInfo-HasConfigPage=true
Then there is the "More Options" link, which emits a signal so that we can 
show the settings dialog.

Given all that, imo, we have to revert this commit :( I wasn't aware of 
those rudimentary changes KPluginSelector brings ;)

Maybe the additional configure button is the easiest way... though, it would 
be nicer to use the embedded "More Options" link.

Dominik

>  M  +14 -5     CMakeLists.txt
>  M  +4 -139    docwordcompletion.cpp
>  M  +0 -41     docwordcompletion.h
>  A             docwordcompletion_config.cpp   [License: LGPL (v2)]
>  A             docwordcompletion_config.h   [License: LGPL (v2)]
>  A             ktexteditor_docwordcompletion_config.desktop
>
>
> --- trunk/KDE/kdelibs/kate/plugins/wordcompletion/CMakeLists.txt
> #697125:697126 @@ -3,18 +3,27 @@
>
>  set(ktexteditor_docwordcompletion_PART_SRCS docwordcompletion.cpp )
>
> +kde4_add_plugin(ktexteditor_docwordcompletion
> ${ktexteditor_docwordcompletion_PART_SRCS} )
>
> -kde4_add_plugin(ktexteditor_docwordcompletion
> ${ktexteditor_docwordcompletion_PART_SRCS})
> +target_link_libraries(ktexteditor_docwordcompletion ${KDE4_KDECORE_LIBS}
> ktexteditor )
>
> -target_link_libraries(ktexteditor_docwordcompletion 
> ${KDE4_KDECORE_LIBS} ktexteditor ) +install(TARGETS
> ktexteditor_docwordcompletion DESTINATION ${PLUGIN_INSTALL_DIR} )
>
> -install(TARGETS ktexteditor_docwordcompletion  DESTINATION
> ${PLUGIN_INSTALL_DIR} ) +########### next target ###############
>
> +set(kcm_ktexteditor_docwordcompletion_PART_SRCS
> docwordcompletion_config.cpp )
>
> +kde4_add_plugin(kcm_ktexteditor_docwordcompletion
> ${kcm_ktexteditor_docwordcompletion_PART_SRCS} ) +
> +target_link_libraries(kcm_ktexteditor_docwordcompletion
> ${KDE4_KDECORE_LIBS} ktexteditor ) +
> +install(TARGETS kcm_ktexteditor_docwordcompletion DESTINATION
> ${PLUGIN_INSTALL_DIR} ) +
> +
>  ########### install files ###############
>
> -install( FILES docwordcompletionui.rc  DESTINATION 
> ${DATA_INSTALL_DIR}/ktexteditor_docwordcompletion ) -install( FILES
> ktexteditor_docwordcompletion.desktop  DESTINATION 
> ${SERVICES_INSTALL_DIR} ) +install( FILES
> ktexteditor_docwordcompletion.desktop
> +               ktexteditor_docwordcompletion_config.desktop DESTINATION 
> ${SERVICES_INSTALL_DIR} )
>
>
>
> --- trunk/KDE/kdelibs/kate/plugins/wordcompletion/docwordcompletion.cpp
> #697125:697126 @@ -169,61 +169,12 @@
>    readConfig();
>  }
>
> -void DocWordCompletionPlugin::configDialog (QWidget *parent)
> -{
> - // If we have only one page, we use a simple dialog, else an icon list
> type -  KPageDialog::FaceType ft = configPages() > 1 ? KPageDialog::List
> :     // still untested -                                                
> KPageDialog::Plain; -
> -  KPageDialog *kd = new KPageDialog ( parent );
> -  kd->setFaceType( ft );
> -  kd->setCaption( i18n("Configure") );
> -  kd->setButtons( KDialog::Ok | KDialog::Cancel | KDialog::Help );
> -  kd->setDefaultButton( KDialog::Ok );
> -
> -  QList<KTextEditor::ConfigPage*> editorPages;
> -
> -  for (uint i = 0; i < configPages (); i++)
> -  {
> -    QWidget *page = new QWidget(0);
> -
> -    KPageWidgetItem *item = new KPageWidgetItem( page, configPageName( i
> ) ); -    item->setHeader( configPageFullName( i ) );
> -// FIXME: set the icon here      item->setIcon();
> -
> -    kd->addPage( item );
> -
> -    editorPages.append( configPage( i, page ) );
> -  }
> -
> -  if (kd->exec())
> -  {
> -
> -    for( int i=0; i<editorPages.count(); i++ )
> -    {
> -      editorPages.at( i )->apply();
> -    }
> -  }
> -
> -  delete kd;
> -}
> -
> -void DocWordCompletionPlugin::readConfig()
> -{
> -  KConfigGroup cg(KGlobal::config(), "DocWordCompletion Plugin" );
> -  m_treshold = cg.readEntry( "treshold", 3 );
> -  m_autopopup = cg.readEntry( "autopopup", true );
> -}
> -
> -void DocWordCompletionPlugin::writeConfig()
> -{
> -  KConfigGroup cg(KGlobal::config(), "DocWordCompletion Plugin" );
> -  cg.writeEntry("autopopup", m_autopopup );
> -  cg.writeEntry("treshold", m_treshold );
> -}
> -
>  void DocWordCompletionPlugin::addView(KTextEditor::View *view)
>  {
> +  KConfigGroup cg(KGlobal::config(), "DocWordCompletion Plugin");
> +  uint m_treshold = cg.readEntry("treshold", 3);
> +  bool m_autopopup = cg.readEntry("autopopup", true);
> +
>    DocWordCompletionPluginView *nview = new DocWordCompletionPluginView
> (m_treshold, m_autopopup, view, m_dWCompletionModel ); m_views.append
> (nview);
>  }
> @@ -238,27 +189,6 @@
>         delete nview;
>      }
>  }
> -
> -KTextEditor::ConfigPage* DocWordCompletionPlugin::configPage( uint,
> QWidget *parent ) -{
> -  return new DocWordCompletionConfigPage( this, parent );
> -}
> -
> -QString DocWordCompletionPlugin::configPageName( uint ) const
> -{
> -  return i18n("Word Completion Plugin");
> -}
> -
> -QString DocWordCompletionPlugin::configPageFullName( uint ) const
> -{
> -  return i18n("Configure the Word Completion Plugin");
> -}
> -
> -// FIXME provide sucn a icon
> -       QPixmap DocWordCompletionPlugin::configPagePixmap( uint, int size
> ) const -{
> -  return UserIcon( "kte_wordcompletion", size );
> -}
>  //END
>
>  //BEGIN DocWordCompletionPluginView
> @@ -637,70 +567,5 @@
>  }
>  //END
>
> -//BEGIN DocWordCompletionConfigPage
> -DocWordCompletionConfigPage::DocWordCompletionConfigPage(
> DocWordCompletionPlugin *completion, QWidget *parent ) -  :
> KTextEditor::ConfigPage( parent )
> -  , m_completion( completion )
> -{
> -  QVBoxLayout *lo = new QVBoxLayout( this );
> -  lo->setSpacing( KDialog::spacingHint() );
> -
> -  cbAutoPopup = new QCheckBox( i18n("Automatically &show completion
> list"), this ); -  lo->addWidget( cbAutoPopup );
> -
> -  KHBox *hb = new KHBox( this );
> -  hb->setSpacing( KDialog::spacingHint() );
> -  lo->addWidget( hb );
> -  QLabel *l = new QLabel( i18nc(
> -      "Translators: This is the first part of two strings which will
> comprise the " -      "sentence 'Show completions when a word is at least
> N characters'. The first " -      "part is on the right side of the N,
> which is represented by a spinbox " -      "widget, followed by the
> second part: 'characters long'. Characters is a " -      "ingeger number
> between and including 1 and 30. Feel free to leave the " -      "second
> part of the sentence blank if it suits your language better. ", -     
> "Show completions &when a word is at least"), hb );
> -  sbAutoPopup = new QSpinBox( hb );
> -  sbAutoPopup->setRange( 1, 30 );
> -  sbAutoPopup->setSingleStep( 1 );
> -  l->setBuddy( sbAutoPopup );
> -  lSbRight = new QLabel( i18nc(
> -      "This is the second part of two strings that will comprise the
> sentence " -      "'Show completions when a word is at least N
> characters'", -      "characters long."), hb );
> -
> -  cbAutoPopup->setWhatsThis(i18n(
> -      "Enable the automatic completion list popup as default. The popup
> can " -      "be disabled on a view basis from the 'Tools' menu.") );
> -  sbAutoPopup->setWhatsThis(i18n(
> -      "Define the length a word should have before the completion list "
> -      "is displayed.") );
> -
> -  cbAutoPopup->setChecked( m_completion->autoPopupEnabled() );
> -  sbAutoPopup->setValue( m_completion->treshold() );
> -
> -  lo->addStretch();
> -}
> -
> -void DocWordCompletionConfigPage::apply()
> -{
> -  m_completion->setAutoPopupEnabled( cbAutoPopup->isChecked() );
> -  m_completion->setTreshold( sbAutoPopup->value() );
> -  m_completion->writeConfig();
> -}
> -
> -void DocWordCompletionConfigPage::reset()
> -{
> -  cbAutoPopup->setChecked( m_completion->autoPopupEnabled() );
> -  sbAutoPopup->setValue( m_completion->treshold() );
> -}
> -
> -void DocWordCompletionConfigPage::defaults()
> -{
> -  cbAutoPopup->setChecked( true );
> -  sbAutoPopup->setValue( 3 );
> -}
> -
> -//END DocWordCompletionConfigPage
> -
>  #include "docwordcompletion.moc"
>  // kate: space-indent on; indent-width 2; replace-tabs on; mixed-indent
> off; ---
> trunk/KDE/kdelibs/kate/plugins/wordcompletion/docwordcompletion.h
> #697125:697126 @@ -77,31 +77,8 @@
>      void addView (KTextEditor::View *view);
>      void removeView (KTextEditor::View *view);
>
> -    void readConfig();
> -    void writeConfig();
> -
> -    virtual void readConfig (KConfig *) {}
> -    virtual void writeConfig (KConfig *) {}
> -    virtual void configDialog (QWidget *parent);
> -
> -    // ConfigInterfaceExtention
> -    uint configPages() const { return 1; }
> -    bool configDialogSupported () const { return true; }
> -    KTextEditor::ConfigPage * configPage( uint number, QWidget *parent
> ); -    QString configPageName( uint ) const;
> -    QString configPageFullName( uint ) const;
> -    QPixmap configPagePixmap( uint, int ) const;
> -
> -    uint treshold() const { return m_treshold; }
> -    void setTreshold( uint t ) { m_treshold = t; }
> -    bool autoPopupEnabled() const { return m_autopopup; }
> -    void setAutoPopupEnabled( bool enable ) { m_autopopup = enable; }
> -
> -
>    private:
>      QList<class DocWordCompletionPluginView*> m_views;
> -    uint m_treshold;
> -    bool m_autopopup;
>      DocWordCompletionModel *m_dWCompletionModel;
>
>  };
> @@ -144,23 +121,5 @@
>      struct DocWordCompletionPluginViewPrivate *d;
>  };
>
> -class DocWordCompletionConfigPage : public KTextEditor::ConfigPage
> -{
> -  Q_OBJECT
> -  public:
> -    DocWordCompletionConfigPage( DocWordCompletionPlugin *completion,
> QWidget *parent ); -    virtual ~DocWordCompletionConfigPage() {}
> -
> -    virtual void apply();
> -    virtual void reset();
> -    virtual void defaults();
> -
> -  private:
> -    DocWordCompletionPlugin *m_completion;
> -    class QCheckBox *cbAutoPopup;
> -    class QSpinBox *sbAutoPopup;
> -    class QLabel *lSbRight;
> -};
> -
>  #endif // _DocWordCompletionPlugin_h_
>  // kate: space-indent on; indent-width 2; replace-tabs on; mixed-indent
> off;


_______________________________________________
KWrite-Devel mailing list
KWrite-Devel@kde.org
https://mail.kde.org/mailman/listinfo/kwrite-devel

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic