Skip to content

Commit

Permalink
Add a more functional error view #5516 (#5861)
Browse files Browse the repository at this point in the history
* Add a more functional error view #5516

* Allow filtering of ignores and warnings to see only important bits.
* Navigate from the folder view to the error view by clicking on the
  error list with the red background.
* Move the error list into its own ui file to allow easier extension.
* Fix issue around tab id handling in ActivitySettings.
* Rename "Action" column to "Issue".
* Change mouse cursor to hand over button and new error list area

Several OSX fixes provided by guruz.
  • Loading branch information
ckamm authored Jul 4, 2017
1 parent 9493e8f commit ce8341c
Show file tree
Hide file tree
Showing 16 changed files with 665 additions and 132 deletions.
2 changes: 2 additions & 0 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ set(client_UI
ignorelisteditor.ui
networksettings.ui
protocolwidget.ui
issueswidget.ui
activitywidget.ui
synclogdialog.ui
settingsdialog.ui
Expand Down Expand Up @@ -64,6 +65,7 @@ set(client_SRCS
owncloudgui.cpp
owncloudsetupwizard.cpp
protocolwidget.cpp
issueswidget.cpp
activitydata.cpp
activitylistmodel.cpp
activitywidget.cpp
Expand Down
49 changes: 49 additions & 0 deletions src/gui/accountsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,42 @@ static const char progressBarStyleC[] =
"background-color: %1; width: 1px;"
"}";

/**
* Adjusts the mouse cursor based on the region it is on over the folder tree view.
*
* Used to show that one can click the red error list box by changing the cursor
* to the pointing hand.
*/
class MouseCursorChanger : public QObject
{
Q_OBJECT
public:
MouseCursorChanger(QObject *parent)
: QObject(parent)
{
}

QTreeView *folderList;
FolderStatusModel *model;

protected:
bool eventFilter(QObject *watched, QEvent *event) override
{
if (event->type() == QEvent::HoverMove) {
Qt::CursorShape shape = Qt::ArrowCursor;
auto pos = folderList->mapFromGlobal(QCursor::pos());
auto index = folderList->indexAt(pos);
if (model->classify(index) == FolderStatusModel::RootFolder
&& (FolderStatusDelegate::errorsListRect(folderList->visualRect(index)).contains(pos)
|| FolderStatusDelegate::optionsButtonRect(folderList->visualRect(index),folderList->layoutDirection()).contains(pos))) {
shape = Qt::PointingHandCursor;
}
folderList->setCursor(shape);
}
return QObject::eventFilter(watched, event);
}
};

AccountSettings::AccountSettings(AccountState *accountState, QWidget *parent)
: QWidget(parent)
, ui(new Ui::AccountSettings)
Expand All @@ -94,6 +130,13 @@ AccountSettings::AccountSettings(AccountState *accountState, QWidget *parent)
#endif
new ToolTipUpdater(ui->_folderList);

auto mouseCursorChanger = new MouseCursorChanger(this);
mouseCursorChanger->folderList = ui->_folderList;
mouseCursorChanger->model = _model;
ui->_folderList->setMouseTracking(true);
ui->_folderList->setAttribute(Qt::WA_Hover, true);
ui->_folderList->installEventFilter(mouseCursorChanger);

createAccountToolbox();
connect(AccountManager::instance(), SIGNAL(accountAdded(AccountState *)),
SLOT(slotAccountAdded(AccountState *)));
Expand Down Expand Up @@ -301,6 +344,10 @@ void AccountSettings::slotFolderListClicked(const QModelIndex &indx)
slotCustomContextMenuRequested(pos);
return;
}
if (FolderStatusDelegate::errorsListRect(tv->visualRect(indx)).contains(pos)) {
emit showIssuesList(_model->data(indx, FolderStatusDelegate::FolderAliasRole).toString());
return;
}

// Expand root items on single click
if (_accountState && _accountState->state() == AccountState::Connected) {
Expand Down Expand Up @@ -808,3 +855,5 @@ bool AccountSettings::event(QEvent *e)
}

} // namespace OCC

#include "accountsettings.moc"
1 change: 1 addition & 0 deletions src/gui/accountsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class AccountSettings : public QWidget
signals:
void folderChanged();
void openFolderAlias(const QString &);
void showIssuesList(const QString &folderAlias);

public slots:
void slotOpenOC();
Expand Down
48 changes: 26 additions & 22 deletions src/gui/activitywidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "accountmanager.h"
#include "activityitemdelegate.h"
#include "protocolwidget.h"
#include "issueswidget.h"
#include "QProgressIndicator.h"
#include "notificationwidget.h"
#include "notificationconfirmjob.h"
Expand Down Expand Up @@ -518,33 +519,23 @@ ActivitySettings::ActivitySettings(QWidget *parent)
_tab = new QTabWidget(this);
hbox->addWidget(_tab);
_activityWidget = new ActivityWidget(this);
_activityTabId = _tab->insertTab(0, _activityWidget, Theme::instance()->applicationIcon(), tr("Server Activity"));
_activityTabId = _tab->addTab(_activityWidget, Theme::instance()->applicationIcon(), tr("Server Activity"));
connect(_activityWidget, SIGNAL(copyToClipboard()), this, SLOT(slotCopyToClipboard()));
connect(_activityWidget, SIGNAL(hideActivityTab(bool)), this, SLOT(setActivityTabHidden(bool)));
connect(_activityWidget, SIGNAL(guiLog(QString, QString)), this, SIGNAL(guiLog(QString, QString)));
connect(_activityWidget, SIGNAL(newNotification()), SLOT(slotShowActivityTab()));

_protocolWidget = new ProtocolWidget(this);
_tab->insertTab(1, _protocolWidget, Theme::instance()->syncStateIcon(SyncResult::Success), tr("Sync Protocol"));
_protocolTabId = _tab->addTab(_protocolWidget, Theme::instance()->syncStateIcon(SyncResult::Success), tr("Sync Protocol"));
connect(_protocolWidget, SIGNAL(copyToClipboard()), this, SLOT(slotCopyToClipboard()));
connect(_protocolWidget, SIGNAL(issueItemCountUpdated(int)),
this, SLOT(slotShowIssueItemCount(int)));

// Add the not-synced list into the tab
QWidget *w = new QWidget;
QVBoxLayout *vbox2 = new QVBoxLayout(w);
vbox2->addWidget(new QLabel(tr("List of ignored or erroneous files"), this));
vbox2->addWidget(_protocolWidget->issueWidget());
QDialogButtonBox *dlgButtonBox = new QDialogButtonBox(this);
vbox2->addWidget(dlgButtonBox);
QPushButton *_copyBtn = dlgButtonBox->addButton(tr("Copy"), QDialogButtonBox::ActionRole);
_copyBtn->setToolTip(tr("Copy the activity list to the clipboard."));
_copyBtn->setEnabled(true);
connect(_copyBtn, SIGNAL(clicked()), this, SLOT(slotCopyToClipboard()));

w->setLayout(vbox2);
_syncIssueTabId = _tab->insertTab(2, w, Theme::instance()->syncStateIcon(SyncResult::Problem), QString());
_issuesWidget = new IssuesWidget(this);
_syncIssueTabId = _tab->addTab(_issuesWidget, Theme::instance()->syncStateIcon(SyncResult::Problem), QString());
slotShowIssueItemCount(0); // to display the label.
connect(_issuesWidget, SIGNAL(issueCountUpdated(int)),
this, SLOT(slotShowIssueItemCount(int)));
connect(_issuesWidget, SIGNAL(copyToClipboard()),
this, SLOT(slotCopyToClipboard()));

// Add a progress indicator to spin if the acitivity list is updated.
_progressIndicator = new QProgressIndicator(this);
Expand All @@ -571,10 +562,14 @@ void ActivitySettings::setActivityTabHidden(bool hidden)
if (hidden && _activityTabId > -1) {
_tab->removeTab(_activityTabId);
_activityTabId = -1;
_protocolTabId -= 1;
_syncIssueTabId -= 1;
}

if (!hidden && _activityTabId == -1) {
_activityTabId = _tab->insertTab(0, _activityWidget, Theme::instance()->applicationIcon(), tr("Server Activity"));
_protocolTabId += 1;
_syncIssueTabId += 1;
}
}

Expand All @@ -595,6 +590,15 @@ void ActivitySettings::slotShowActivityTab()
}
}

void ActivitySettings::slotShowIssuesTab(const QString &folderAlias)
{
if (_syncIssueTabId == -1)
return;
_tab->setCurrentIndex(_syncIssueTabId);

_issuesWidget->showFolderErrors(folderAlias);
}

void ActivitySettings::slotCopyToClipboard()
{
QString text;
Expand All @@ -603,18 +607,18 @@ void ActivitySettings::slotCopyToClipboard()
int idx = _tab->currentIndex();
QString message;

if (idx == 0) {
if (idx == _activityTabId) {
// the activity widget
_activityWidget->storeActivityList(ts);
message = tr("The server activity list has been copied to the clipboard.");
} else if (idx == 1) {
} else if (idx == _protocolTabId) {
// the protocol widget
_protocolWidget->storeSyncActivity(ts);
message = tr("The sync activity list has been copied to the clipboard.");
} else if (idx == 2) {
} else if (idx == _syncIssueTabId) {
// issues Widget
message = tr("The list of unsynced items has been copied to the clipboard.");
_protocolWidget->storeSyncIssues(ts);
_issuesWidget->storeSyncIssues(ts);
}

QApplication::clipboard()->setText(text);
Expand Down
5 changes: 5 additions & 0 deletions src/gui/activitywidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ namespace OCC {
class Account;
class AccountStatusPtr;
class ProtocolWidget;
class IssuesWidget;
class JsonApiJob;
class NotificationWidget;
class ActivityListModel;
Expand Down Expand Up @@ -138,6 +139,8 @@ public slots:

void setNotificationRefreshInterval(quint64 interval);

void slotShowIssuesTab(const QString &folderAlias);

private slots:
void slotCopyToClipboard();
void setActivityTabHidden(bool hidden);
Expand All @@ -153,10 +156,12 @@ private slots:

QTabWidget *_tab;
int _activityTabId;
int _protocolTabId;
int _syncIssueTabId;

ActivityWidget *_activityWidget;
ProtocolWidget *_protocolWidget;
IssuesWidget *_issuesWidget;
QProgressIndicator *_progressIndicator;
QTimer _notificationCheckTimer;
QHash<AccountState *, QElapsedTimer> _timeSinceLastCheck;
Expand Down
10 changes: 10 additions & 0 deletions src/gui/folderstatusdelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,5 +373,15 @@ QRect FolderStatusDelegate::optionsButtonRect(QRect within, Qt::LayoutDirection
return QStyle::visualRect(direction, within, r);
}

QRect FolderStatusDelegate::errorsListRect(QRect within)
{
QFont font = QFont();
QFont aliasFont = makeAliasFont(font);
QFontMetrics fm(font);
QFontMetrics aliasFm(aliasFont);
within.setTop(within.top() + FolderStatusDelegate::rootFolderHeightWithoutErrors(fm, aliasFm));
return within;
}


} // namespace OCC
1 change: 1 addition & 0 deletions src/gui/folderstatusdelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class FolderStatusDelegate : public QStyledItemDelegate
* return the position of the option button within the item
*/
static QRect optionsButtonRect(QRect within, Qt::LayoutDirection direction);
static QRect errorsListRect(QRect within);
static int rootFolderHeightWithoutErrors(const QFontMetrics &fm, const QFontMetrics &aliasFm);

private:
Expand Down
Loading

0 comments on commit ce8341c

Please sign in to comment.