SLOT(slotAccountAdded(AccountState *)));
connect(AccountManager::instance(), SIGNAL(accountRemoved(AccountState *)),
SLOT(slotAccountRemoved(AccountState *)));
+ connect(FolderMan::instance(), SIGNAL(folderListChanged(Folder::Map)),
+ SLOT(slotUpdateFolderFilters()));
// Adjust copyToClipboard() when making changes here!
void IssuesWidget::slotAccountAdded(AccountState *account)
{
_ui->filterAccount->addItem(account->account()->displayName(), QVariant::fromValue(account));
+ updateAccountChoiceVisibility();
}
void IssuesWidget::slotAccountRemoved(AccountState *account)
if (account == _ui->filterAccount->itemData(i).value<AccountState *>())
_ui->filterAccount->removeItem(i);
}
+ updateAccountChoiceVisibility();
+}
+
+void IssuesWidget::updateAccountChoiceVisibility()
+{
+ bool visible = _ui->filterAccount->count() > 2;
+ _ui->filterAccount->setVisible(visible);
+ _ui->accountLabel->setVisible(visible);
+ slotUpdateFolderFilters();
}
AccountState *IssuesWidget::currentAccountFilter() const
{
auto account = _ui->filterAccount->currentData().value<AccountState *>();
+ // If there is no account selector, show folders for the single
+ // available account
+ if (_ui->filterAccount->isHidden() && _ui->filterAccount->count() > 1) {
+ account = _ui->filterAccount->itemData(1).value<AccountState *>();
+ }
+
if (!account) {
_ui->filterFolder->setCurrentIndex(0);
}
for (int i = _ui->filterFolder->count() - 1; i >= 1; --i) {
_ui->filterFolder->removeItem(i);
}
+
+ // Find all selectable folders while figuring out if we need a folder
+ // selector in the first place
+ bool anyAccountHasMultipleFolders = false;
+ QSet<AccountState *> accountsWithFolders;
for (auto folder : FolderMan::instance()->map().values()) {
+ if (accountsWithFolders.contains(folder->accountState()))
+ anyAccountHasMultipleFolders = true;
+ accountsWithFolders.insert(folder->accountState());
+
if (folder->accountState() != account)
continue;
_ui->filterFolder->addItem(folder->shortGuiLocalPath(), folder->alias());
}
+
+ // If we don't need the combo box, hide it.
+ _ui->filterFolder->setVisible(anyAccountHasMultipleFolders);
+ _ui->folderLabel->setVisible(anyAccountHasMultipleFolders);
+
+ // If there's no choice, select the only folder and disable
+ if (_ui->filterFolder->count() == 2 && anyAccountHasMultipleFolders) {
+ _ui->filterFolder->setCurrentIndex(1);
+ _ui->filterFolder->setEnabled(false);
+ }
}
void IssuesWidget::storeSyncIssues(QTextStream &ts)
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
- <layout class="QFormLayout" name="formLayout">
+ <layout class="QFormLayout" name="accountFolderLayout">
<item row="0" column="0">
- <widget class="QLabel" name="label">
+ <widget class="QLabel" name="accountLabel">
<property name="text">
<string>Account</string>
</property>
</widget>
</item>
<item row="1" column="0">
- <widget class="QLabel" name="label_2">
+ <widget class="QLabel" name="folderLabel">
<property name="text">
<string>Folder</string>
</property>