add action to show/hide lyrics widget

parent c1b5b195
<!DOCTYPE kpartgui>
<kpartgui name="juk" version="11">
<kpartgui name="juk" version="12">
<MenuBar>
<Menu name="file" noMerge="1"><text>&amp;File</text>
<Action name="file_new"/>
......@@ -26,6 +26,7 @@
<Menu name="view" noMerge="1"><text>&amp;View</text>
<Action name="showSearch"/>
<Action name="showEditor"/>
<Action name="showLyrics"/>
<Action name="showHistory"/>
<Action name="showUpcoming"/>
<Action name="showColumns"/>
......
<!-- PLEASE UPDATE jukui-rtl.rc WHEN UPDATING THIS FILE -->
<!DOCTYPE kpartgui>
<kpartgui name="juk" version="11">
<kpartgui name="juk" version="12">
<MenuBar>
<Menu name="file" noMerge="1"><text>&amp;File</text>
<Action name="file_new"/>
......@@ -28,6 +28,7 @@
<Menu name="view" noMerge="1"><text>&amp;View</text>
<Action name="showSearch"/>
<Action name="showEditor"/>
<Action name="showLyrics"/>
<Action name="showHistory"/>
<Action name="showUpcoming"/>
<Action name="showColumns"/>
......
......@@ -4,9 +4,15 @@
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <KAction>
#include <KLocalizedString>
#include <KActionCollection>
#include <KToggleAction>
#include <KConfigGroup>
#include "lyricswidget.h"
#include "tag.h"
#include "actioncollection.h"
LyricsWidget::LyricsWidget(QWidget* parent): QTextBrowser(parent),
m_networkAccessManager(new QNetworkAccessManager)
......@@ -14,10 +20,26 @@ LyricsWidget::LyricsWidget(QWidget* parent): QTextBrowser(parent),
setReadOnly(true);
setWordWrapMode(QTextOption::WordWrap);
setOpenExternalLinks(true);
KToggleAction *show = new KToggleAction(KIcon(QLatin1String("view-media-lyrics")),
i18n("Show &Lyrics"), this);
ActionCollection::actions()->addAction("showLyrics", show);
connect(show, SIGNAL(toggled(bool)), this, SLOT(setShown(bool)));
KConfigGroup config(KGlobal::config(), "LyricsWidget");
bool shown = config.readEntry("Show", false);
show->setChecked(shown);
setShown(shown);
}
LyricsWidget::~LyricsWidget()
{
delete m_networkAccessManager;
KConfigGroup config(KGlobal::config(), "LyricsWidget");
config.writeEntry("Show", ActionCollection::action<KToggleAction>("showLyrics")->isChecked());
}
void LyricsWidget::playing(const FileHandle &file)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment