mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-27 17:37:36 +03:00
Rather show overall progress in settings dialog.
This commit is contained in:
parent
7fb7cc8c46
commit
1cc60e755b
9 changed files with 132 additions and 18 deletions
|
@ -459,14 +459,17 @@ void AccountSettings::slotOpenOC()
|
|||
QDesktopServices::openUrl( _OCUrl );
|
||||
}
|
||||
|
||||
void AccountSettings::slotSetProgress( Progress::Kind kind, const QString& folder, const QString& file, long p1, long p2 )
|
||||
QStandardItem* AccountSettings::itemForFolder(const QString& folder)
|
||||
{
|
||||
// qDebug() << "================================> Progress for folder " << folder << " file " << file << ": "<< p1;
|
||||
QStandardItem *item = NULL;
|
||||
|
||||
if( folder.isEmpty() ) {
|
||||
return item;
|
||||
}
|
||||
|
||||
int row = 0;
|
||||
|
||||
if( folder.isEmpty() ) return;
|
||||
|
||||
QStandardItem *item = _model->item( row );
|
||||
item = _model->item( row );
|
||||
|
||||
while( item ) {
|
||||
if( item->data( FolderStatusDelegate::FolderAliasRole ) == folder ) {
|
||||
|
@ -475,6 +478,28 @@ void AccountSettings::slotSetProgress( Progress::Kind kind, const QString& folde
|
|||
}
|
||||
item = _model->item( ++row );
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
void AccountSettings::slotSetOverallProgress( const QString& folder, const QString& file, int fileNo, int fileCnt,
|
||||
qlonglong p1, qlonglong p2)
|
||||
{
|
||||
QStandardItem *item = itemForFolder(folder);
|
||||
if( item ) {
|
||||
item->setData( p1, FolderStatusDelegate::OverallProgress1);
|
||||
item->setData( p2, FolderStatusDelegate::OverallProgress2);
|
||||
item->setData( fileNo, FolderStatusDelegate::OverallFileNo);
|
||||
item->setData( fileCnt, FolderStatusDelegate::OverallFileCount);
|
||||
item->setData( file, FolderStatusDelegate::OverallCurrentFile);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void AccountSettings::slotSetProgress( Progress::Kind kind, const QString& folder, const QString& file, long p1, long p2 )
|
||||
{
|
||||
// qDebug() << "================================> Progress for folder " << folder << " file " << file << ": "<< p1;
|
||||
|
||||
QStandardItem *item = itemForFolder( folder );
|
||||
|
||||
if( item ) {
|
||||
if( p1 == p2 ) { // File upload finished.
|
||||
|
@ -509,7 +534,7 @@ void AccountSettings::slotSetProgress( Progress::Kind kind, const QString& folde
|
|||
t->deleteLater();
|
||||
}
|
||||
// calculate the normalization factor and set the min and max
|
||||
_progressFactor = 100.0/p2;
|
||||
// _progressFactor = 100.0/p2;
|
||||
item->setData( QVariant(true), FolderStatusDelegate::AddProgressSpace );
|
||||
item->setData( 0, FolderStatusDelegate::SyncProgressPercent1);
|
||||
item->setData( 100, FolderStatusDelegate::SyncProgressPercent2);
|
||||
|
@ -535,7 +560,7 @@ void AccountSettings::slotSetProgress( Progress::Kind kind, const QString& folde
|
|||
shortFile = kindString + QLatin1String(" ") + shortFile;
|
||||
item->setData( shortFile, FolderStatusDelegate::SyncFileName );
|
||||
} else { // File progress
|
||||
item->setData( int(_progressFactor * p1), FolderStatusDelegate::SyncProgressPercent1);
|
||||
// item->setData( int(_progressFactor * p1), FolderStatusDelegate::SyncProgressPercent1);
|
||||
item->setData( (qlonglong) p1, FolderStatusDelegate::SyncProgressBytes1);
|
||||
_lastSyncProgress = p1;
|
||||
|
||||
|
|
|
@ -66,6 +66,7 @@ public slots:
|
|||
void slotDoubleClicked( const QModelIndex& );
|
||||
void slotFolderOpenAction( const QString& );
|
||||
void slotSetProgress( Progress::Kind, const QString&, const QString&, long, long );
|
||||
void slotSetOverallProgress( const QString&, const QString&, int, int, qlonglong, qlonglong );
|
||||
void slotUpdateQuota( qint64,qint64 );
|
||||
|
||||
protected slots:
|
||||
|
@ -84,6 +85,8 @@ protected slots:
|
|||
|
||||
private:
|
||||
void folderToModelItem( QStandardItem *, Folder * );
|
||||
QStandardItem* itemForFolder(const QString& );
|
||||
|
||||
Ui::AccountSettings *ui;
|
||||
QPointer<FileItemDialog> _fileItemDialog;
|
||||
FolderMan *_folderMan;
|
||||
|
|
|
@ -418,7 +418,6 @@ void CSyncThread::cb_overall_progress(const char *file_name, int file_no, int fi
|
|||
if(thread) {
|
||||
thread->overallTransmissionProgress( file, file_no, file_cnt, o1, o2 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CSyncThread::setLastAuthCookies(QList<QNetworkCookie> c)
|
||||
|
|
|
@ -125,8 +125,13 @@ void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
|
|||
QString syncFile = qvariant_cast<QString>(index.data(SyncFileName));
|
||||
int progressPercent1 = qvariant_cast<int>(index.data(SyncProgressPercent1));
|
||||
int progressPercent2 = qvariant_cast<int>(index.data(SyncProgressPercent2));
|
||||
qlonglong progressBytes1 = qvariant_cast<int>(index.data(SyncProgressBytes1));
|
||||
qlonglong progressBytes2 = qvariant_cast<int>(index.data(SyncProgressBytes2));
|
||||
qlonglong fileBytes1 = qvariant_cast<qlonglong>(index.data(SyncProgressBytes1));
|
||||
qlonglong fileBytes2 = qvariant_cast<qlonglong>(index.data(SyncProgressBytes2));
|
||||
|
||||
qlonglong overallBytes1 = qvariant_cast<qlonglong>(index.data(OverallProgress1));
|
||||
qlonglong overallBytes2 = qvariant_cast<qlonglong>(index.data(OverallProgress2));
|
||||
int currentFileCount = qvariant_cast<int>(index.data(OverallFileNo));
|
||||
int overallFileCount = qvariant_cast<int>(index.data(OverallFileCount));
|
||||
|
||||
// QString statusText = qvariant_cast<QString>(index.data(FolderStatus));
|
||||
bool syncEnabled = index.data(FolderSyncEnabled).toBool();
|
||||
|
@ -194,10 +199,12 @@ void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
|
|||
painter->drawText(localPathRect, elidedPathText);
|
||||
|
||||
// paint an error overlay if there is an error string
|
||||
|
||||
int h = iconRect.bottom();
|
||||
if( !errorText.isEmpty() ) {
|
||||
QRect errorRect = localPathRect;
|
||||
errorRect.setLeft( iconRect.left());
|
||||
errorRect.setTop( iconRect.bottom()+subFm.height()/2 );
|
||||
errorRect.setTop( h );
|
||||
errorRect.setHeight(subFm.height()+aliasMargin);
|
||||
errorRect.setRight( option.rect.right()-aliasMargin );
|
||||
|
||||
|
@ -221,8 +228,78 @@ void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
|
|||
eText = errorText.left(linebreak);
|
||||
}
|
||||
painter->drawText(errorTextRect, eText);
|
||||
}
|
||||
|
||||
h = errorRect.bottom();
|
||||
}
|
||||
h += aliasMargin;
|
||||
|
||||
if( !syncFile.isEmpty()) {
|
||||
int fileNameTextHeight = subFm.boundingRect(tr("File")).height();
|
||||
int barHeight = fileNameTextHeight;
|
||||
int overallWidth = option.rect.width()-2*aliasMargin;
|
||||
|
||||
painter->save();
|
||||
// painter->setBrush( option.palette.brightText() );
|
||||
// painter->drawRoundedRect( progressRect, 2, 2 ); // do not draw the box.
|
||||
|
||||
// Sizes-Text
|
||||
QString s1 = Utility::octetsToString( overallBytes1+fileBytes1 );
|
||||
QString s2 = Utility::octetsToString( overallBytes2 );
|
||||
QString overallSyncString = tr("%1 of %2, file %3 of %4").arg(s1).arg(s2).arg(currentFileCount).arg(overallFileCount);
|
||||
|
||||
QRect octetRect = subFm.boundingRect( overallSyncString );
|
||||
int progressTextWidth = octetRect.width();
|
||||
|
||||
// Overall Bar.
|
||||
QRect pBRect;
|
||||
pBRect.setTop( h );
|
||||
pBRect.setLeft( iconRect.left());
|
||||
pBRect.setHeight(barHeight);
|
||||
pBRect.setWidth( overallWidth - progressTextWidth - margin );
|
||||
|
||||
int overallPercent = (overallBytes1+fileBytes1) *100.0/overallBytes2;
|
||||
QStyleOptionProgressBarV2 pBarOpt;
|
||||
pBarOpt.state = option.state | QStyle::State_Horizontal;
|
||||
pBarOpt.minimum = 0;
|
||||
pBarOpt.maximum = 100;
|
||||
pBarOpt.progress = overallPercent;
|
||||
pBarOpt.orientation = Qt::Horizontal;
|
||||
pBarOpt.palette = option.palette;
|
||||
pBarOpt.rect = pBRect;
|
||||
|
||||
QApplication::style()->drawControl( QStyle::CE_ProgressBar, &pBarOpt, painter );
|
||||
|
||||
// Overall Progress Text
|
||||
QRect overallProgressRect;
|
||||
overallProgressRect.setTop( pBRect.top() );
|
||||
overallProgressRect.setHeight( pBRect.height() );
|
||||
overallProgressRect.setLeft( pBRect.right()+margin);
|
||||
overallProgressRect.setWidth( progressTextWidth );
|
||||
painter->setFont(progressFont);
|
||||
painter->drawText( overallProgressRect, Qt::AlignRight+Qt::AlignVCenter, overallSyncString);
|
||||
|
||||
s1 = Utility::octetsToString( fileBytes2);
|
||||
octetRect = subFm.boundingRect( tr("%1 of %2").arg(s1).arg(s1) );
|
||||
progressTextWidth = octetRect.width()+20;
|
||||
|
||||
QRect fileRect;
|
||||
fileRect.setTop( pBRect.bottom() + margin);
|
||||
fileRect.setLeft( iconRect.left());
|
||||
fileRect.setWidth( overallWidth - margin - progressTextWidth );
|
||||
fileRect.setHeight(fileNameTextHeight);
|
||||
painter->drawText( fileRect, syncFile );
|
||||
|
||||
QRect fileProgressRect;
|
||||
fileProgressRect.setTop(pBRect.bottom()+margin);
|
||||
fileProgressRect.setLeft(fileRect.right()+margin);
|
||||
fileProgressRect.setWidth(progressTextWidth);
|
||||
fileProgressRect.setHeight(fileNameTextHeight);
|
||||
s1 = Utility::octetsToString(fileBytes1);
|
||||
s2 = Utility::octetsToString(fileBytes2);
|
||||
QString fileProgressString = tr("%1 of %2").arg(s1).arg(s2);
|
||||
painter->drawText( fileProgressRect, Qt::AlignRight+Qt::AlignVCenter, fileProgressString );
|
||||
}
|
||||
#if 0
|
||||
/* Display the sync progress. */
|
||||
if( !syncFile.isEmpty() ) {
|
||||
int fileNameTextHeight = subFm.boundingRect(tr("File")).height();
|
||||
|
@ -284,6 +361,7 @@ void FolderStatusDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
|
|||
painter->restore();
|
||||
|
||||
}
|
||||
#endif
|
||||
// painter->drawText(lastSyncRect, tr("Last Sync: %1").arg( statusText ));
|
||||
// painter->drawText(statusRect, tr("Sync Status: %1").arg( syncStatus ));
|
||||
painter->restore();
|
||||
|
|
|
@ -49,7 +49,13 @@ class FolderStatusDelegate : public QStyledItemDelegate
|
|||
SyncProgressPercent2,
|
||||
SyncProgressBytes1,
|
||||
SyncProgressBytes2,
|
||||
AddProgressSpace
|
||||
AddProgressSpace,
|
||||
OverallProgress1,
|
||||
OverallProgress2,
|
||||
OverallPercent,
|
||||
OverallFileNo,
|
||||
OverallFileCount,
|
||||
OverallCurrentFile
|
||||
};
|
||||
void paint( QPainter*, const QStyleOptionViewItem&, const QModelIndex& ) const;
|
||||
QSize sizeHint( const QStyleOptionViewItem&, const QModelIndex& ) const;
|
||||
|
|
|
@ -445,7 +445,7 @@ void ownCloudFolder::slotFileTransmissionProgress(Progress::Kind kind, const QSt
|
|||
void ownCloudFolder::slotOverallTransmissionProgress( const QString& fileName, int fileNo, int fileCnt,
|
||||
long long o1, long long o2)
|
||||
{
|
||||
ProgressDispatcher::instance()->setOverallProgress( fileName, fileNo, fileCnt, qlonglong(o1), qlonglong(o2));
|
||||
ProgressDispatcher::instance()->setOverallProgress( alias(), fileName, fileNo, fileCnt, qlonglong(o1), qlonglong(o2));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -80,9 +80,10 @@ void ProgressDispatcher::setFolderProgress( Progress::Kind kind, const QString&
|
|||
emit folderProgress( kind, alias, file, p1, p2 );
|
||||
}
|
||||
|
||||
void ProgressDispatcher::setOverallProgress( const QString& file, int fileNo, int fileCnt, qlonglong o1, qlonglong o2 )
|
||||
void ProgressDispatcher::setOverallProgress( const QString& folder, const QString& file, int fileNo, int fileCnt,
|
||||
qlonglong o1, qlonglong o2 )
|
||||
{
|
||||
emit overallProgress( file, fileNo, fileCnt, o1, o2 );
|
||||
emit overallProgress( folder, file, fileNo, fileCnt, o1, o2 );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -49,11 +49,11 @@ public:
|
|||
|
||||
public:
|
||||
void setFolderProgress( Progress::Kind, const QString&, const QString&, long, long );
|
||||
void setOverallProgress( const QString&, int, int, qlonglong, qlonglong);
|
||||
void setOverallProgress(const QString&, const QString&, int, int, qlonglong, qlonglong);
|
||||
|
||||
signals:
|
||||
void folderProgress( Progress::Kind, const QString&, const QString&, long, long );
|
||||
void overallProgress(const QString&, int, int, qlonglong, qlonglong );
|
||||
void overallProgress(const QString&, const QString&, int, int, qlonglong, qlonglong );
|
||||
|
||||
public slots:
|
||||
|
||||
|
|
|
@ -74,6 +74,8 @@ SettingsDialog::SettingsDialog(Application *app, QWidget *parent) :
|
|||
|
||||
connect( ProgressDispatcher::instance(), SIGNAL(folderProgress(Progress::Kind, QString,QString,long,long)),
|
||||
_accountSettings, SLOT(slotSetProgress(Progress::Kind, QString,QString,long,long)));
|
||||
connect( ProgressDispatcher::instance(), SIGNAL(overallProgress(QString,QString, int,int,qlonglong,qlonglong)),
|
||||
_accountSettings, SLOT(slotSetOverallProgress( const QString&, const QString&, int, int, qlonglong , qlonglong )));
|
||||
|
||||
connect(ProgressDispatcher::instance(), SIGNAL(shortFolderProgress(QString, QString)),
|
||||
this, SLOT(slotShortFolderProgress(QString, QString)));
|
||||
|
|
Loading…
Reference in a new issue