mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-21 20:45:51 +03:00
Display error status in statusdialog.
This commit is contained in:
parent
fbb46b64f9
commit
2501cc57d5
4 changed files with 59 additions and 11 deletions
|
@ -31,5 +31,7 @@
|
|||
<file>resources/owncloud-error-48.png</file>
|
||||
<file>resources/owncloud-sync-48.png</file>
|
||||
<file>resources/owncloud-sync-ok-48.png</file>
|
||||
|
||||
<file>resources/warning-16.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
BIN
resources/warning-16.png
Normal file
BIN
resources/warning-16.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 596 B |
|
@ -92,7 +92,7 @@ void Folder::checkLocalPath()
|
|||
setSyncEnabled(false);
|
||||
|
||||
if( !fi.exists() ) {
|
||||
_syncResult.setErrorString(tr("The local folder %1 does not exist.").arg(_path));
|
||||
_syncResult.setErrorString(tr("Local folder %1 does not exist.").arg(_path));
|
||||
} else {
|
||||
if( !fi.isDir() ) {
|
||||
_syncResult.setErrorString(tr("Path %1 should be a directory but is not.").arg(_path));
|
||||
|
|
|
@ -72,20 +72,29 @@ QSize FolderViewDelegate::sizeHint(const QStyleOptionViewItem & option ,
|
|||
QFontMetrics fm(font);
|
||||
QFontMetrics aliasFm(aliasFont);
|
||||
|
||||
int margin = aliasFm.height()/2;
|
||||
|
||||
w = 8 + fm.boundingRect( p ).width();
|
||||
|
||||
// calc height
|
||||
int h = aliasFm.height()/2; // margin to top
|
||||
|
||||
int h = margin; // margin to top
|
||||
h += aliasFm.height(); // alias
|
||||
h += fm.height()/2; // between alias and local path
|
||||
h += fm.height(); // local path
|
||||
h += fm.height()/2; // between local and remote path
|
||||
h += fm.height(); // remote path
|
||||
h += aliasFm.height()/2; // bottom margin
|
||||
h += margin; // bottom margin
|
||||
|
||||
int minHeight = 48 + fm.height()/2 + fm.height()/2; // icon + margins
|
||||
int minHeight = 48 + margin + margin; // icon + margins
|
||||
|
||||
if( h < minHeight ) h = minHeight;
|
||||
|
||||
// add some space to show an error condition.
|
||||
if( ! qvariant_cast<QString>(index.data(FolderErrorMsg)).isEmpty() ) {
|
||||
h += margin+fm.height();
|
||||
}
|
||||
|
||||
return QSize( w, h );
|
||||
}
|
||||
|
||||
|
@ -98,18 +107,23 @@ void FolderViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
|
|||
|
||||
QFont aliasFont = QApplication::font();
|
||||
QFont subFont = QApplication::font();
|
||||
QFont errorFont = subFont;
|
||||
|
||||
//font.setPixelSize(font.weight()+);
|
||||
aliasFont.setBold(true);
|
||||
aliasFont.setPointSize( subFont.pointSize()+2 );
|
||||
|
||||
QFontMetrics subFm( subFont );
|
||||
QFontMetrics aliasFm( aliasFont );
|
||||
int margin = aliasFm.height()/2;
|
||||
|
||||
QIcon folderIcon = qvariant_cast<QIcon>(index.data(FolderIconRole));
|
||||
QIcon statusIcon = qvariant_cast<QIcon>(index.data(FolderStatusIcon));
|
||||
QString aliasText = qvariant_cast<QString>(index.data(FolderAliasRole));
|
||||
QString pathText = qvariant_cast<QString>(index.data(FolderPathRole));
|
||||
QString remotePath = qvariant_cast<QString>(index.data(FolderSecondPathRole));
|
||||
QString errorText = qvariant_cast<QString>(index.data(FolderErrorMsg));
|
||||
|
||||
// QString statusText = qvariant_cast<QString>(index.data(FolderStatus));
|
||||
bool syncEnabled = index.data(FolderSyncEnabled).toBool();
|
||||
// QString syncStatus = syncEnabled? tr( "Enabled" ) : tr( "Disabled" );
|
||||
|
@ -119,16 +133,22 @@ void FolderViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
|
|||
QRect aliasRect = option.rect;
|
||||
QRect iconRect = option.rect;
|
||||
|
||||
iconRect.setRight( iconsize.width()+30 );
|
||||
iconRect.setTop( iconRect.top() + (iconRect.height()-iconsize.height())/2);
|
||||
aliasRect.setLeft(iconRect.right());
|
||||
iconRect.setLeft( margin );
|
||||
iconRect.setWidth( 48 );
|
||||
iconRect.setTop( iconRect.top() + margin ); // (iconRect.height()-iconsize.height())/2);
|
||||
|
||||
QRect statusRect = iconRect;
|
||||
statusRect.setLeft( option.rect.right() - margin - 48 );
|
||||
statusRect.setRight( option.rect.right() - margin );
|
||||
|
||||
aliasRect.setLeft(iconRect.right()+margin);
|
||||
|
||||
aliasRect.setTop(aliasRect.top() + aliasFm.height()/2 );
|
||||
aliasRect.setBottom(aliasRect.top()+subFm.height());
|
||||
|
||||
// local directory box
|
||||
QRect localPathRect = aliasRect;
|
||||
localPathRect.setTop(aliasRect.bottom() + subFm.height() / 2);
|
||||
localPathRect.setTop(aliasRect.bottom() + margin / 3);
|
||||
localPathRect.setBottom(localPathRect.top()+subFm.height());
|
||||
|
||||
// remote directory box
|
||||
|
@ -136,14 +156,16 @@ void FolderViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
|
|||
remotePathRect.setTop( localPathRect.bottom() + subFm.height()/2 );
|
||||
remotePathRect.setBottom( remotePathRect.top() + subFm.height());
|
||||
|
||||
iconRect.setBottom(remotePathRect.bottom());
|
||||
|
||||
//painter->drawPixmap(QPoint(iconRect.right()/2,iconRect.top()/2),icon.pixmap(iconsize.width(),iconsize.height()));
|
||||
if( syncEnabled ) {
|
||||
painter->drawPixmap(QPoint(iconRect.left()+15,iconRect.top()), folderIcon.pixmap(iconsize.width(),iconsize.height()));
|
||||
painter->drawPixmap(QPoint(iconRect.left(),iconRect.top()), folderIcon.pixmap(iconsize.width(),iconsize.height()));
|
||||
} else {
|
||||
painter->drawPixmap(QPoint(iconRect.left()+15,iconRect.top()), folderIcon.pixmap(iconsize.width(),iconsize.height(), QIcon::Disabled ));
|
||||
painter->drawPixmap(QPoint(iconRect.left(),iconRect.top()), folderIcon.pixmap(iconsize.width(),iconsize.height(), QIcon::Disabled ));
|
||||
}
|
||||
|
||||
painter->drawPixmap(QPoint(option.rect.right() - 4 - 48, option.rect.top() + (option.rect.height()-48)/2 ), statusIcon.pixmap(48,48));
|
||||
painter->drawPixmap(QPoint(statusRect.left(), statusRect.top()), statusIcon.pixmap(48,48));
|
||||
|
||||
painter->setFont(aliasFont);
|
||||
painter->drawText(aliasRect, aliasText);
|
||||
|
@ -152,6 +174,30 @@ void FolderViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
|
|||
painter->drawText(localPathRect.left(),localPathRect.top()+17, pathText);
|
||||
painter->drawText(remotePathRect, tr("Remote path: %1").arg(remotePath));
|
||||
|
||||
// paint an error overlay if there is an error string
|
||||
if( !errorText.isEmpty() ) {
|
||||
QRect errorRect = localPathRect;
|
||||
errorRect.setLeft( iconRect.left());
|
||||
errorRect.setTop( iconRect.bottom()+subFm.height()/2 );
|
||||
errorRect.setHeight(subFm.height()+margin);
|
||||
errorRect.setRight( statusRect.right() );
|
||||
|
||||
painter->setBrush( QColor(0xbb, 0x4d, 0x4d) );
|
||||
painter->setPen( QColor(0xaa, 0xaa, 0xaa));
|
||||
painter->drawRoundedRect( errorRect, 4, 4 );
|
||||
|
||||
QIcon warnIcon(":/mirall/resources/warning-16");
|
||||
painter->drawPixmap( QPoint(errorRect.left()+2, errorRect.top()+2), warnIcon.pixmap(QSize(16,16)));
|
||||
|
||||
painter->setPen( Qt::white );
|
||||
painter->setFont(errorFont);
|
||||
QRect errorTextRect = errorRect;
|
||||
errorTextRect.setLeft( errorTextRect.left()+margin/2 +16);
|
||||
errorTextRect.setTop( errorTextRect.top()+margin/2 );
|
||||
|
||||
painter->drawText(errorTextRect, errorText);
|
||||
}
|
||||
|
||||
// painter->drawText(lastSyncRect, tr("Last Sync: %1").arg( statusText ));
|
||||
// painter->drawText(statusRect, tr("Sync Status: %1").arg( syncStatus ));
|
||||
painter->restore();
|
||||
|
|
Loading…
Reference in a new issue