2015-10-19 15:41:53 +03:00
|
|
|
/*
|
|
|
|
* Copyright (C) by Klaas Freitag <freitag@owncloud.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
2016-10-25 12:00:07 +03:00
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
2015-10-19 15:41:53 +03:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ACTIVITYWIDGET_H
|
|
|
|
#define ACTIVITYWIDGET_H
|
|
|
|
|
|
|
|
#include <QDialog>
|
|
|
|
#include <QDateTime>
|
|
|
|
#include <QLocale>
|
|
|
|
#include <QAbstractListModel>
|
2018-01-24 00:51:25 +03:00
|
|
|
#include <chrono>
|
2015-10-19 15:41:53 +03:00
|
|
|
|
|
|
|
#include "progressdispatcher.h"
|
|
|
|
#include "owncloudgui.h"
|
2015-11-02 00:27:33 +03:00
|
|
|
#include "account.h"
|
2016-03-11 13:37:45 +03:00
|
|
|
#include "activitydata.h"
|
2018-03-26 22:02:03 +03:00
|
|
|
#include "accountmanager.h"
|
2015-10-19 15:41:53 +03:00
|
|
|
|
|
|
|
#include "ui_activitywidget.h"
|
|
|
|
|
|
|
|
class QPushButton;
|
2015-11-10 20:10:58 +03:00
|
|
|
class QProgressIndicator;
|
2015-10-19 15:41:53 +03:00
|
|
|
|
|
|
|
namespace OCC {
|
|
|
|
|
2015-11-02 00:27:33 +03:00
|
|
|
class Account;
|
2015-11-04 18:40:22 +03:00
|
|
|
class AccountStatusPtr;
|
2016-03-04 19:41:57 +03:00
|
|
|
class JsonApiJob;
|
2016-03-11 13:37:45 +03:00
|
|
|
class ActivityListModel;
|
2015-11-02 00:27:33 +03:00
|
|
|
|
2015-10-19 15:41:53 +03:00
|
|
|
namespace Ui {
|
2017-05-17 11:55:42 +03:00
|
|
|
class ActivityWidget;
|
2015-10-19 15:41:53 +03:00
|
|
|
}
|
|
|
|
class Application;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief The ActivityWidget class
|
|
|
|
* @ingroup gui
|
2015-11-16 17:38:08 +03:00
|
|
|
*
|
|
|
|
* The list widget to display the activities, contained in the
|
|
|
|
* subsequent ActivitySettings widget.
|
2015-10-19 15:41:53 +03:00
|
|
|
*/
|
2015-11-10 17:12:35 +03:00
|
|
|
|
2015-10-19 15:41:53 +03:00
|
|
|
class ActivityWidget : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2018-11-11 12:56:22 +03:00
|
|
|
explicit ActivityWidget(AccountState *accountState, QWidget *parent = nullptr);
|
2015-10-19 15:41:53 +03:00
|
|
|
~ActivityWidget();
|
2018-11-11 13:09:29 +03:00
|
|
|
QSize sizeHint() const override { return ownCloudGui::settingsDialogSize(); }
|
2015-11-10 17:12:35 +03:00
|
|
|
void storeActivityList(QTextStream &ts);
|
2015-11-02 17:44:13 +03:00
|
|
|
|
2016-04-14 12:35:16 +03:00
|
|
|
/**
|
|
|
|
* Adjusts the activity tab's and some widgets' visibility
|
|
|
|
*
|
|
|
|
* Based on whether activities are enabled and whether notifications are
|
|
|
|
* available.
|
|
|
|
*/
|
2018-08-13 16:17:40 +03:00
|
|
|
void checkActivityWidgetVisibility();
|
2016-04-14 12:35:16 +03:00
|
|
|
|
2015-10-19 15:41:53 +03:00
|
|
|
public slots:
|
2015-11-16 17:31:24 +03:00
|
|
|
void slotOpenFile(QModelIndex indx);
|
2018-03-27 18:19:22 +03:00
|
|
|
void slotRefreshActivities();
|
|
|
|
void slotRefreshNotifications();
|
|
|
|
void slotRemoveAccount();
|
|
|
|
void slotAccountActivityStatus(int statusCode);
|
2018-05-14 21:21:30 +03:00
|
|
|
void addError(const QString &folderAlias, const QString &message, ErrorCategory category);
|
2018-07-18 00:57:07 +03:00
|
|
|
void slotProgressInfo(const QString &folder, const ProgressInfo &progress);
|
2018-05-14 21:21:30 +03:00
|
|
|
void slotItemCompleted(const QString &folder, const SyncFileItemPtr &item);
|
2015-10-19 15:41:53 +03:00
|
|
|
|
|
|
|
signals:
|
2017-05-17 11:55:42 +03:00
|
|
|
void guiLog(const QString &, const QString &);
|
2015-11-10 20:10:58 +03:00
|
|
|
void rowsInserted();
|
2016-04-14 11:59:40 +03:00
|
|
|
void hideActivityTab(bool);
|
2018-04-25 18:20:42 +03:00
|
|
|
void sendNotificationRequest(const QString &accountName, const QString &link, const QByteArray &verb, int row);
|
2016-03-04 19:41:57 +03:00
|
|
|
|
|
|
|
private slots:
|
2017-05-17 11:55:42 +03:00
|
|
|
void slotBuildNotificationDisplay(const ActivityList &list);
|
2018-04-24 17:38:36 +03:00
|
|
|
void slotSendNotificationRequest(const QString &accountName, const QString &link, const QByteArray &verb, int row);
|
2017-05-17 11:55:42 +03:00
|
|
|
void slotNotifyNetworkError(QNetworkReply *);
|
|
|
|
void slotNotifyServerFinished(const QString &reply, int replyCode);
|
2018-08-13 16:17:40 +03:00
|
|
|
void endNotificationRequest(int replyCode);
|
2018-04-21 02:24:31 +03:00
|
|
|
void slotNotificationRequestFinished(int statusCode);
|
2018-04-25 18:20:42 +03:00
|
|
|
void slotPrimaryButtonClickedOnListView(const QModelIndex &index);
|
|
|
|
void slotSecondaryButtonClickedOnListView(const QModelIndex &index);
|
2015-10-19 15:41:53 +03:00
|
|
|
|
|
|
|
private:
|
2015-11-19 18:00:22 +03:00
|
|
|
void showLabels();
|
2015-10-19 15:41:53 +03:00
|
|
|
QString timeString(QDateTime dt, QLocale::FormatType format) const;
|
|
|
|
Ui::ActivityWidget *_ui;
|
2015-11-19 18:00:22 +03:00
|
|
|
QSet<QString> _accountsWithoutActivities;
|
2016-03-10 19:09:36 +03:00
|
|
|
QElapsedTimer _guiLogTimer;
|
|
|
|
QSet<int> _guiLoggedNotifications;
|
2016-03-29 17:50:58 +03:00
|
|
|
ActivityList _blacklistedNotifications;
|
2016-03-23 18:59:03 +03:00
|
|
|
|
|
|
|
QTimer _removeTimer;
|
2016-03-16 18:31:52 +03:00
|
|
|
|
|
|
|
// number of currently running notification requests. If non zero,
|
|
|
|
// no query for notifications is started.
|
|
|
|
int _notificationRequestsRunning;
|
2016-03-10 19:09:36 +03:00
|
|
|
|
2015-11-02 00:27:33 +03:00
|
|
|
ActivityListModel *_model;
|
2018-03-27 18:19:22 +03:00
|
|
|
AccountState *_accountState;
|
2018-07-16 14:06:02 +03:00
|
|
|
const QString _accept;
|
|
|
|
const QString _remote_share;
|
2015-10-19 15:41:53 +03:00
|
|
|
};
|
|
|
|
|
2015-11-10 17:12:35 +03:00
|
|
|
|
2015-11-16 17:38:08 +03:00
|
|
|
/**
|
|
|
|
* @brief The ActivitySettings class
|
|
|
|
* @ingroup gui
|
|
|
|
*
|
|
|
|
* Implements a tab for the settings dialog, displaying the three activity
|
|
|
|
* lists.
|
|
|
|
*/
|
2015-11-10 17:12:35 +03:00
|
|
|
class ActivitySettings : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2018-11-11 12:56:22 +03:00
|
|
|
explicit ActivitySettings(AccountState *accountState, QWidget *parent = nullptr);
|
2018-03-27 18:19:22 +03:00
|
|
|
|
2015-11-10 17:12:35 +03:00
|
|
|
~ActivitySettings();
|
2018-11-11 13:09:29 +03:00
|
|
|
QSize sizeHint() const override { return ownCloudGui::settingsDialogSize(); }
|
2015-11-10 17:12:35 +03:00
|
|
|
|
|
|
|
public slots:
|
2018-03-27 18:19:22 +03:00
|
|
|
void slotRefresh();
|
|
|
|
void slotRemoveAccount();
|
2018-01-24 00:51:25 +03:00
|
|
|
void setNotificationRefreshInterval(std::chrono::milliseconds interval);
|
2016-03-18 18:23:21 +03:00
|
|
|
|
2016-03-08 20:01:42 +03:00
|
|
|
private slots:
|
2016-03-18 18:23:21 +03:00
|
|
|
void slotRegularNotificationCheck();
|
2018-05-14 14:40:42 +03:00
|
|
|
void slotDisplayActivities();
|
2015-11-10 17:12:35 +03:00
|
|
|
|
|
|
|
signals:
|
2017-05-17 11:55:42 +03:00
|
|
|
void guiLog(const QString &, const QString &);
|
2015-11-10 17:12:35 +03:00
|
|
|
|
|
|
|
private:
|
2018-11-11 13:09:29 +03:00
|
|
|
bool event(QEvent *e) override;
|
2015-11-18 17:25:29 +03:00
|
|
|
|
2015-11-10 17:12:35 +03:00
|
|
|
ActivityWidget *_activityWidget;
|
2015-11-10 20:10:58 +03:00
|
|
|
QProgressIndicator *_progressIndicator;
|
2018-05-14 14:40:42 +03:00
|
|
|
QVBoxLayout *_vbox;
|
2017-05-17 11:55:42 +03:00
|
|
|
QTimer _notificationCheckTimer;
|
|
|
|
QHash<AccountState *, QElapsedTimer> _timeSinceLastCheck;
|
2018-03-26 22:02:03 +03:00
|
|
|
|
2018-03-27 18:19:22 +03:00
|
|
|
AccountState *_accountState;
|
2015-11-10 17:12:35 +03:00
|
|
|
};
|
2015-10-19 15:41:53 +03:00
|
|
|
}
|
|
|
|
#endif // ActivityWIDGET_H
|