[Amarok] Added possibility to stop editing without saving c

Seb Ruiz ruiz at kde.org
Tue Sep 29 00:02:19 CEST 2009


Hi Valentin,
Do we need to add this extra button here? IIRC, we never had a "cancel
lyrics edit" button in 1.4, and it was never requested either which
leads me to believe that it really isn't so  necessary. If you make an
editing mistake, then just refetch the lyrics from the server.

Seb

2009/9/29 Valentin Rouet <v.rouet at gmail.com>:
> commit a1a2e13a6c922c2a140b853dbb38e5e20ed012ba
> Author:     Valentin Rouet <v.rouet at gmail.com>
> AuthorDate: Sun Sep 20 21:55:09 2009 +0200
> Commit:     Valentin Rouet <v.rouet at gmail.com>
> CommitDate: Mon Sep 28 23:02:53 2009 +0200
>
>    Added possibility to stop editing without saving changes in the lyrics applet
>
> diff --git a/src/context/applets/lyrics/LyricsApplet.cpp b/src/context/applets/lyrics/LyricsApplet.cpp
> index 234b8cd..57d389f 100644
> --- a/src/context/applets/lyrics/LyricsApplet.cpp
> +++ b/src/context/applets/lyrics/LyricsApplet.cpp
> @@ -47,6 +47,7 @@ LyricsApplet::LyricsApplet( QObject* parent, const QVariantList& args )
>     , m_saveIcon( 0 )
>     , m_editIcon( 0 )
>     , m_reloadIcon( 0 )
> +    , m_closeIcon( 0 )
>     , m_lyrics( 0 )
>     , m_suggested( 0 )
>     , m_hasLyrics( false )
> @@ -85,6 +86,15 @@ void LyricsApplet::init()
>
>     connect( m_editIcon, SIGNAL( activated() ), this, SLOT( editLyrics() ) );
>
> +    QAction* closeAction = new QAction( this );
> +    closeAction->setIcon( KIcon( "document-close" ) );
> +    closeAction->setVisible( false );
> +    closeAction->setEnabled( false );
> +    m_closeIcon = addAction( closeAction );
> +    m_closeIcon->setToolTip( i18n( "Close" ) );
> +
> +    connect( m_closeIcon, SIGNAL( activated() ), this, SLOT( closeLyrics() ) );
> +
>     QAction* saveAction = new QAction( this );
>     saveAction->setIcon( KIcon( "document-save" ) );
>     saveAction->setVisible( false );
> @@ -169,7 +179,9 @@ void LyricsApplet::constraintsEvent( Plasma::Constraints constraints )
>
>     QPoint editIconPos( m_reloadIcon->pos().x() - standardPadding() - iconWidth, standardPadding() );
>     m_editIcon->setPos( editIconPos );
> -    m_saveIcon->setPos( editIconPos );
> +    m_closeIcon->setPos( editIconPos );
> +
> +    m_saveIcon->setPos( m_editIcon->pos().x() - standardPadding() - iconWidth, standardPadding() );
>
>     m_lyricsProxy->setPos( standardPadding(), m_titleLabel->pos().y() + m_titleLabel->boundingRect().height() + standardPadding() );
>
> @@ -364,6 +376,20 @@ LyricsApplet::editLyrics()
>  }
>
>  void
> +LyricsApplet::closeLyrics()
> +{
> +    if( m_hasLyrics )
> +    {
> +        m_lyrics->setPlainText( The::engineController()->currentTrack()->cachedLyrics() );
> +        m_lyrics->show();
> +        setCollapseOff();
> +        emit sizeHintChanged(Qt::MaximumSize);
> +    }
> +
> +    setEditing( false );
> +}
> +
> +void
>  LyricsApplet::saveLyrics()
>  {
>     if( m_lyrics->toPlainText().isEmpty() )
> @@ -388,6 +414,10 @@ LyricsApplet::setEditing( const bool isEditing )
>     m_editIcon->action()->setVisible( !isEditing );
>
>     // If we're editing, show and enable the save icon
> +    m_closeIcon->action()->setEnabled( isEditing );
> +    m_closeIcon->action()->setVisible( isEditing );
> +
> +    // If we're editing, show and enable the save icon
>     m_saveIcon->action()->setEnabled( isEditing );
>     m_saveIcon->action()->setVisible( isEditing );
>
> diff --git a/src/context/applets/lyrics/LyricsApplet.h b/src/context/applets/lyrics/LyricsApplet.h
> index d5d9154..c86f7c5 100644
> --- a/src/context/applets/lyrics/LyricsApplet.h
> +++ b/src/context/applets/lyrics/LyricsApplet.h
> @@ -58,6 +58,7 @@ public slots:
>  private slots:
>     void paletteChanged( const QPalette & palette );
>     void editLyrics();
> +    void closeLyrics();
>     void saveLyrics();
>
>  private:
> @@ -72,7 +73,8 @@ private:
>     Plasma::IconWidget*  m_saveIcon;
>     Plasma::IconWidget*  m_editIcon;
>     Plasma::IconWidget*  m_reloadIcon;
> -
> +    Plasma::IconWidget*  m_closeIcon;
> +
>     // holds main body
>     QGraphicsProxyWidget *m_lyricsProxy;
>     QTextBrowser* m_lyrics;
>
>
>



-- 
Seb Ruiz

http://www.sebruiz.net/
http://amarok.kde.org/


More information about the Amarok-devel mailing list