Commit 73cb0fa0 authored by Michael Pyne's avatar Michael Pyne
Browse files

Add a user-defined literal for our action collection.

parent de290e15
......@@ -50,6 +50,11 @@ namespace ActionCollection
return actions()->action(key);
#endif
}
QAction *operator ""_act(const char *str, std::size_t len)
{
return action(QString::fromLatin1(str, len));
}
}
// vim: set et sw=4 tw=0 sta:
......@@ -21,6 +21,8 @@ class KActionCollection;
class QAction;
class QString;
#include <cstddef>
namespace ActionCollection
{
/**
......@@ -42,6 +44,11 @@ namespace ActionCollection
{
return dynamic_cast<T *>(action(key));
}
/**
* What ActionCollection::action does, in shorter form.
*/
QAction *operator "" _act(const char *str, std::size_t len);
}
#endif
......
......@@ -165,6 +165,8 @@ void PlaylistSplitter::setupActions()
void PlaylistSplitter::setupLayout()
{
using namespace ActionCollection; // add literal
setOpaqueResize(false);
// Disable the GUI until startup is complete (as indicated by PlaylistBox)
......@@ -243,7 +245,7 @@ void PlaylistSplitter::setupLayout()
m_playlistBox->collectionActions(), SLOT(slotSetSearchEnabled(bool)));
connect(m_searchWidget, SIGNAL(returnPressed()),
m_playlistBox->collectionActions(), SLOT(slotPlayFirst()));
connect(ActionCollection::action<KToggleAction>("showSearch"), SIGNAL(toggled(bool)),
connect("showSearch"_act, SIGNAL(toggled(bool)),
m_searchWidget, SLOT(setEnabled(bool)));
connect(m_playlistBox, &PlaylistBox::signalMoveFocusAway,
m_searchWidget, qOverload<>(&SearchWidget::setFocus));
......@@ -264,6 +266,8 @@ void PlaylistSplitter::setupLayout()
void PlaylistSplitter::readConfig()
{
using namespace ActionCollection; // add literal
KConfigGroup config(KSharedConfig::openConfig(), "Splitter");
QList<int> splitterSizes = config.readEntry("PlaylistSplitterSizes",QList<int>());
......@@ -274,7 +278,7 @@ void PlaylistSplitter::readConfig()
setSizes(splitterSizes);
bool showSearch = config.readEntry("ShowSearch", true);
ActionCollection::action<KToggleAction>("showSearch")->setChecked(showSearch);
"showSearch"_act->setChecked(showSearch);
m_searchWidget->setHidden(!showSearch);
splitterSizes = config.readEntry("EditorSplitterSizes",QList<int>());
......@@ -291,9 +295,11 @@ void PlaylistSplitter::readConfig()
void PlaylistSplitter::saveConfig()
{
using namespace ActionCollection; // add literal
KConfigGroup config(KSharedConfig::openConfig(), "Splitter");
config.writeEntry("PlaylistSplitterSizes", sizes());
config.writeEntry("ShowSearch", ActionCollection::action<KToggleAction>("showSearch")->isChecked());
config.writeEntry("ShowSearch", "showSearch"_act->isChecked());
config.writeEntry("EditorSplitterSizes", m_editorSplitter->sizes());
}
......
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