Commit f9721878 authored by Michael Pyne's avatar Michael Pyne

Fix the "Show Columns" menu to show correct state on startup.

The "Show Columns" menu would previously have a checkbox entered for
every possible column for the playlist shown by default at JuK startup,
even though most columns were not visible.

This turned out to be because the class that reads the column
configuration (Playlist::SharedSettings) was not being used to generate
the Show Columns menu options. Instead the Playlist's own (defaulted)
values were used.

At this point in execution we can't force SharedSettings->apply() to run
because the Playlist is not fully setup. Instead we expose the config
values and use those to generate the menu.
parent c6afa4c5
......@@ -1311,6 +1311,7 @@ void Playlist::slotInitialize()
//////////////////////////////////////////////////
QAction *showAction;
const auto sharedSettings = SharedSettings::instance();
for(int i = 0; i < header()->count(); ++i) {
if(i - columnOffset() == PlaylistItem::FileNameColumn)
......@@ -1319,7 +1320,7 @@ void Playlist::slotInitialize()
showAction = new QAction(headerItem()->text(i), m_headerMenu);
showAction->setData(i);
showAction->setCheckable(true);
showAction->setChecked(!isColumnHidden(i));
showAction->setChecked(sharedSettings->isColumnVisible(i));
m_headerMenu->addAction(showAction);
resizeColumnToContents(i);
......
......@@ -62,6 +62,15 @@ void Playlist::SharedSettings::toggleColumnVisible(int column)
writeConfig();
}
bool Playlist::SharedSettings::isColumnVisible(int column) const
{
if(column >= m_columnsVisible.size()) {
return false;
}
return m_columnsVisible[column];
}
void Playlist::SharedSettings::setInlineCompletionMode(KCompletion::CompletionMode mode)
{
m_inlineCompletion = mode;
......
......@@ -38,8 +38,10 @@ public:
*/
void setColumnOrder(const Playlist *l);
void toggleColumnVisible(int column);
bool isColumnVisible(int column) const;
void setInlineCompletionMode(KCompletion::CompletionMode mode);
/**
* Apply the settings.
*/
......
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