diff --git a/mirall.qrc b/mirall.qrc index 07362942f..123869a17 100644 --- a/mirall.qrc +++ b/mirall.qrc @@ -31,5 +31,7 @@ resources/owncloud-error-48.png resources/owncloud-sync-48.png resources/owncloud-sync-ok-48.png + + resources/warning-16.png diff --git a/resources/warning-16.png b/resources/warning-16.png new file mode 100644 index 000000000..43ca31a31 Binary files /dev/null and b/resources/warning-16.png differ diff --git a/src/mirall/folder.cpp b/src/mirall/folder.cpp index d841a5142..5c4548fff 100644 --- a/src/mirall/folder.cpp +++ b/src/mirall/folder.cpp @@ -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)); diff --git a/src/mirall/statusdialog.cpp b/src/mirall/statusdialog.cpp index 24fb8a650..cd66b057c 100644 --- a/src/mirall/statusdialog.cpp +++ b/src/mirall/statusdialog.cpp @@ -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(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(index.data(FolderIconRole)); QIcon statusIcon = qvariant_cast(index.data(FolderStatusIcon)); QString aliasText = qvariant_cast(index.data(FolderAliasRole)); QString pathText = qvariant_cast(index.data(FolderPathRole)); QString remotePath = qvariant_cast(index.data(FolderSecondPathRole)); + QString errorText = qvariant_cast(index.data(FolderErrorMsg)); + // QString statusText = qvariant_cast(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();