mirror of
https://github.com/KDE/latte-dock.git
synced 2025-01-07 09:18:03 +03:00
publish Shared to relevant ComboBox
This commit is contained in:
parent
c27de681d1
commit
d813a15b57
@ -54,39 +54,24 @@ QWidget *SharedCmbBoxDelegate::createEditor(QWidget *parent, const QStyleOptionV
|
||||
//! setEditorData (const) function
|
||||
editor->setFocusPolicy(Qt::StrongFocus);
|
||||
|
||||
/*
|
||||
QStringList assignedActivities = index.model()->data(index, Qt::UserRole).toStringList();
|
||||
QStringList availableActivities = m_settingsDialog->availableActivities();
|
||||
QStringList activities = m_settingsDialog->activities();
|
||||
|
||||
QStringList shownActivities;
|
||||
|
||||
for (const auto &activity : activities) {
|
||||
if (assignedActivities.contains(activity) || availableActivities.contains(activity)) {
|
||||
shownActivities.append(activity);
|
||||
}
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < shownActivities.count(); ++i) {
|
||||
|
||||
KActivities::Info info(shownActivities[i]);
|
||||
QStringList assignedShares = index.model()->data(index, Qt::UserRole).toStringList();
|
||||
QStringList availableShares = m_settingsDialog->availableSharesFor(index.row());
|
||||
|
||||
for (unsigned int i = 0; i < availableShares.count(); ++i) {
|
||||
QString indicator = " ";
|
||||
|
||||
if (assignedActivities.contains(shownActivities[i])) {
|
||||
if (assignedShares.contains(availableShares[i])) {
|
||||
indicator = QString::fromUtf8("\u2714") + " ";
|
||||
}
|
||||
|
||||
if (info.state() != KActivities::Info::Invalid) {
|
||||
editor->addItem(QIcon::fromTheme(info.icon()), QString(indicator + info.name()), QVariant(shownActivities[i]));
|
||||
}
|
||||
editor->addItem(QString(indicator + availableShares[i]), QVariant(availableShares[i]));
|
||||
}
|
||||
|
||||
connect(editor, static_cast<void(QComboBox::*)(int)>(&QComboBox::activated), [ = ](int index) {
|
||||
editor->setFocusPolicy(Qt::ClickFocus);
|
||||
editor->clearFocus();
|
||||
});
|
||||
*/
|
||||
|
||||
return editor;
|
||||
}
|
||||
|
||||
|
@ -287,6 +287,31 @@ QStringList SettingsDialog::availableActivities()
|
||||
return m_availableActivities;
|
||||
}
|
||||
|
||||
QStringList SettingsDialog::availableSharesFor(int row)
|
||||
{
|
||||
QStringList availables;
|
||||
QStringList regs;
|
||||
|
||||
for (int i = 0; i < m_model->rowCount(); ++i) {
|
||||
QString name = m_model->data(m_model->index(i, NAMECOLUMN), Qt::DisplayRole).toString();
|
||||
QStringList shares = m_model->data(m_model->index(i, SHAREDCOLUMN), Qt::UserRole).toStringList();
|
||||
|
||||
if (i != row) {
|
||||
if (shares.isEmpty()) {
|
||||
availables << name;
|
||||
} else {
|
||||
regs << shares;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto r : regs) {
|
||||
availables.removeAll(r);
|
||||
}
|
||||
|
||||
return availables;
|
||||
}
|
||||
|
||||
void SettingsDialog::setCurrentPage(Types::LatteConfigPage page)
|
||||
{
|
||||
if (page == Types::LayoutPage) {
|
||||
@ -878,7 +903,7 @@ void SettingsDialog::loadSettings()
|
||||
qDebug() << "SHARES MAP ::: " << m_sharesMap;
|
||||
|
||||
for(QHash<const QString, QStringList>::iterator i=m_sharesMap.begin(); i!=m_sharesMap.end(); ++i) {
|
||||
int sharedPos = rowForId(QString(QDir::homePath() + "/.config/latte/" + i.key() + ".layout.latte"));
|
||||
int sharedPos = rowForName(i.key());
|
||||
|
||||
if (sharedPos >= 0) {
|
||||
m_model->setData(m_model->index(sharedPos, SHAREDCOLUMN), i.value(), Qt::UserRole);
|
||||
@ -984,6 +1009,7 @@ QStringList SettingsDialog::currentLayoutsSettings()
|
||||
bool menu = m_model->data(m_model->index(i, MENUCOLUMN), Qt::DisplayRole).toString() == CheckMark;
|
||||
bool borders = m_model->data(m_model->index(i, BORDERSCOLUMN), Qt::DisplayRole).toString() == CheckMark;
|
||||
QStringList lActivities = m_model->data(m_model->index(i, ACTIVITYCOLUMN), Qt::UserRole).toStringList();
|
||||
QStringList shares = m_model->data(m_model->index(i, SHAREDCOLUMN), Qt::UserRole).toStringList();
|
||||
|
||||
layoutSettings << id;
|
||||
layoutSettings << color;
|
||||
@ -993,6 +1019,7 @@ QStringList SettingsDialog::currentLayoutsSettings()
|
||||
layoutSettings << QString::number((int)menu);
|
||||
layoutSettings << QString::number((int)borders);
|
||||
layoutSettings << lActivities;
|
||||
layoutSettings << shares;
|
||||
}
|
||||
|
||||
return layoutSettings;
|
||||
@ -1600,6 +1627,19 @@ int SettingsDialog::rowForId(QString id)
|
||||
return -1;
|
||||
}
|
||||
|
||||
int SettingsDialog::rowForName(QString layoutName)
|
||||
{
|
||||
for (int i = 0; i < m_model->rowCount(); ++i) {
|
||||
QString rowName = m_model->data(m_model->index(i, NAMECOLUMN), Qt::DisplayRole).toString();
|
||||
|
||||
if (rowName == layoutName) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
QString SettingsDialog::uniqueTempDirectory()
|
||||
{
|
||||
QTemporaryDir tempDir;
|
||||
|
@ -59,6 +59,7 @@ public:
|
||||
|
||||
QStringList activities();
|
||||
QStringList availableActivities();
|
||||
QStringList availableSharesFor(int row);
|
||||
|
||||
void requestImagesDialog(int row);
|
||||
void requestColorsDialog(int row);
|
||||
@ -103,6 +104,7 @@ private:
|
||||
bool saveAllChanges();
|
||||
|
||||
int rowForId(QString id);
|
||||
int rowForName(QString layoutName);
|
||||
int ascendingRowFor(QString name);
|
||||
|
||||
QString uniqueTempDirectory();
|
||||
|
Loading…
Reference in New Issue
Block a user