From 2501cc57d53db7faf84b62b1bd4c8eb2f24a52b3 Mon Sep 17 00:00:00 2001 From: Klaas Freitag Date: Tue, 30 Oct 2012 14:18:03 +0100 Subject: [PATCH] Display error status in statusdialog. --- mirall.qrc | 2 ++ resources/warning-16.png | Bin 0 -> 596 bytes src/mirall/folder.cpp | 2 +- src/mirall/statusdialog.cpp | 66 ++++++++++++++++++++++++++++++------ 4 files changed, 59 insertions(+), 11 deletions(-) create mode 100644 resources/warning-16.png 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 0000000000000000000000000000000000000000..43ca31a31871751e291ed4ae0a43e2d98cdf0b74 GIT binary patch literal 596 zcmV-a0;~OrP)=*gEtt=qgkZ2WcrqY7(0?$^FO?a>2XUw9*HDa1NaF z@OuwOwASng#Q>tJeKmRSTwoAd>whL*v@S-Ar+U%SIo(~bF70$q?I;f2hvwL{7^U;b zw*BD0M(BMqro}&V2*W@OP{GO3=%amW&w?cO?-~auS$=Y#<)@EOh2!YhoZXWkUa;=S z@ZZX3l4u!f_gAJi&FE}$2CGXn*ks=8+cm7Eys zU~b|CdHj)4a9W7hL>0$^_B%BP8QDjACRVHHHinKSo>&nW@cmT@orH{EYk+`G9GahX zI~Wi1Oy~%}gp}rxJT?oiC;2*<^i#R|~)W-VQBrF&w4GR~1a&85xL*&7(@?XNdKu7s+>4 ix2BaJzs}xZAN&D5t-?v>AdPzf0000(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();