mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-26 23:28:14 +03:00
StatusModel: Have another property accountConnected.
With that , make the status model aware of the account connection state. With that, we can grey out the correct state icon if the account is not connected and display the normal icon if the account is connected.
This commit is contained in:
parent
1245ed6f06
commit
bb3bd6930a
4 changed files with 10 additions and 7 deletions
|
@ -227,7 +227,7 @@ void AccountSettings::slotAddFolder( Folder *folder )
|
|||
if( ! folder || folder->alias().isEmpty() ) return;
|
||||
|
||||
QStandardItem *item = new QStandardItem();
|
||||
folderToModelItem( item, folder );
|
||||
folderToModelItem( item, folder, _account->state() == Account::Connected );
|
||||
_model->appendRow( item );
|
||||
// in order to update the enabled state of the "Sync now" button
|
||||
connect(folder, SIGNAL(syncStateChange()), this, SLOT(slotFolderSyncStateChange()), Qt::UniqueConnection);
|
||||
|
@ -249,7 +249,7 @@ void AccountSettings::setGeneralErrors( const QStringList& errors )
|
|||
}
|
||||
}
|
||||
|
||||
void AccountSettings::folderToModelItem( QStandardItem *item, Folder *f )
|
||||
void AccountSettings::folderToModelItem( QStandardItem *item, Folder *f, bool accountConnected )
|
||||
{
|
||||
if( ! item || !f ) return;
|
||||
|
||||
|
@ -257,6 +257,7 @@ void AccountSettings::folderToModelItem( QStandardItem *item, Folder *f )
|
|||
item->setData( f->remotePath(), FolderStatusDelegate::FolderSecondPathRole );
|
||||
item->setData( f->alias(), FolderStatusDelegate::FolderAliasRole );
|
||||
item->setData( f->syncPaused(), FolderStatusDelegate::FolderSyncPaused );
|
||||
item->setData( accountConnected, FolderStatusDelegate::FolderAccountConnected );
|
||||
SyncResult res = f->syncResult();
|
||||
SyncResult::Status status = res.status();
|
||||
|
||||
|
@ -516,7 +517,7 @@ void AccountSettings::slotUpdateFolderState( Folder *folder )
|
|||
}
|
||||
|
||||
if( item ) {
|
||||
folderToModelItem( item, folder );
|
||||
folderToModelItem( item, folder, _account->state() == Account::Connected );
|
||||
} else {
|
||||
// the dialog is not visible.
|
||||
}
|
||||
|
@ -782,10 +783,10 @@ void AccountSettings::slotSyncStateChange(const QString& alias)
|
|||
{
|
||||
Q_UNUSED(alias);
|
||||
|
||||
FolderMan *folderMan = FolderMan::instance();
|
||||
SyncResult state = folderMan->accountStatus(folderMan->map().values());
|
||||
QIcon icon;
|
||||
if (_account && _account->state() == Account::Connected) {
|
||||
FolderMan *folderMan = FolderMan::instance();
|
||||
SyncResult state = folderMan->accountStatus(folderMan->map().values());
|
||||
icon = Theme::instance()->syncStateIcon(state.status());
|
||||
} else {
|
||||
icon = Theme::instance()->folderOfflineIcon();
|
||||
|
|
|
@ -86,7 +86,7 @@ protected slots:
|
|||
|
||||
private:
|
||||
QString shortenFilename( const QString& folder, const QString& file ) const;
|
||||
void folderToModelItem( QStandardItem *, Folder * );
|
||||
void folderToModelItem(QStandardItem *, Folder * , bool accountConnected);
|
||||
QStandardItem* itemForFolder(const QString& );
|
||||
void showConnectionLabel( const QString& message, const QString& tooltip = QString() );
|
||||
|
||||
|
|
|
@ -133,8 +133,9 @@ void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
|
|||
QString itemString = qvariant_cast<QString>(index.data(SyncProgressItemString));
|
||||
int warningCount = qvariant_cast<int>(index.data(WarningCount));
|
||||
bool syncOngoing = qvariant_cast<bool>(index.data(SyncRunning));
|
||||
|
||||
// QString statusText = qvariant_cast<QString>(index.data(FolderStatus));
|
||||
bool syncEnabled = index.data(FolderSyncEnabled).toBool();
|
||||
bool syncEnabled = index.data(FolderAccountConnected).toBool();
|
||||
// QString syncStatus = syncEnabled? tr( "Enabled" ) : tr( "Disabled" );
|
||||
|
||||
QRect iconRect = option.rect;
|
||||
|
|
|
@ -44,6 +44,7 @@ class FolderStatusDelegate : public QStyledItemDelegate
|
|||
FolderErrorMsg,
|
||||
FolderSyncPaused,
|
||||
FolderStatusIconRole,
|
||||
FolderAccountConnected,
|
||||
|
||||
SyncProgressOverallPercent,
|
||||
SyncProgressOverallString,
|
||||
|
|
Loading…
Reference in a new issue