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;
|
2015-11-10 17:12:35 +03:00
|
|
|
class ProtocolWidget;
|
2017-07-04 15:08:41 +03:00
|
|
|
class IssuesWidget;
|
2016-03-04 19:41:57 +03:00
|
|
|
class JsonApiJob;
|
|
|
|
class NotificationWidget;
|
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-03-26 22:02:03 +03:00
|
|
|
explicit ActivityWidget(QWidget *parent = 0,
|
|
|
|
AccountState *account = AccountManager::instance()->accounts().first().data());
|
2015-10-19 15:41:53 +03:00
|
|
|
~ActivityWidget();
|
2015-11-19 12:50:52 +03:00
|
|
|
QSize sizeHint() const Q_DECL_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.
|
|
|
|
*/
|
|
|
|
void checkActivityTabVisibility();
|
|
|
|
|
2015-10-19 15:41:53 +03:00
|
|
|
public slots:
|
2015-11-16 17:31:24 +03:00
|
|
|
void slotOpenFile(QModelIndex indx);
|
2017-05-17 11:55:42 +03:00
|
|
|
void slotRefreshActivities(AccountState *ptr);
|
2016-03-18 18:23:21 +03:00
|
|
|
void slotRefreshNotifications(AccountState *ptr);
|
2017-05-17 11:55:42 +03:00
|
|
|
void slotRemoveAccount(AccountState *ptr);
|
2016-03-08 20:01:42 +03:00
|
|
|
void slotAccountActivityStatus(AccountState *ast, int statusCode);
|
2017-05-17 11:55:42 +03:00
|
|
|
void slotRequestCleanupAndBlacklist(const Activity &blacklistActivity);
|
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 17:12:35 +03:00
|
|
|
void copyToClipboard();
|
2015-11-10 20:10:58 +03:00
|
|
|
void rowsInserted();
|
2016-04-14 11:59:40 +03:00
|
|
|
void hideActivityTab(bool);
|
2016-05-12 12:47:42 +03:00
|
|
|
void newNotification();
|
2016-03-04 19:41:57 +03:00
|
|
|
|
|
|
|
private slots:
|
2017-05-17 11:55:42 +03:00
|
|
|
void slotBuildNotificationDisplay(const ActivityList &list);
|
|
|
|
void slotSendNotificationRequest(const QString &accountName, const QString &link, const QByteArray &verb);
|
|
|
|
void slotNotifyNetworkError(QNetworkReply *);
|
|
|
|
void slotNotifyServerFinished(const QString &reply, int replyCode);
|
|
|
|
void endNotificationRequest(NotificationWidget *widget, int replyCode);
|
2018-04-13 17:55:55 +03:00
|
|
|
void scheduleWidgetToRemove(NotificationWidget *widget, int milliseconds = 100);
|
2016-03-23 18:59:03 +03:00
|
|
|
void slotCheckToCleanWidgets();
|
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;
|
|
|
|
QPushButton *_copyBtn;
|
2015-11-02 00:27:33 +03:00
|
|
|
|
2015-11-19 18:00:22 +03:00
|
|
|
QSet<QString> _accountsWithoutActivities;
|
2017-05-17 11:55:42 +03:00
|
|
|
QMap<Activity::Identifier, NotificationWidget *> _widgetForNotifId;
|
2016-03-10 19:09:36 +03:00
|
|
|
QElapsedTimer _guiLogTimer;
|
|
|
|
QSet<int> _guiLoggedNotifications;
|
2018-03-26 00:44:32 +03:00
|
|
|
ActivityList _newNotifications;
|
2016-03-29 17:50:58 +03:00
|
|
|
ActivityList _blacklistedNotifications;
|
2016-03-23 18:59:03 +03:00
|
|
|
|
2017-05-17 11:55:42 +03:00
|
|
|
QHash<NotificationWidget *, QDateTime> _widgetsToRemove;
|
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;
|
2016-03-04 19:41:57 +03:00
|
|
|
QVBoxLayout *_notificationsLayout;
|
2018-03-26 22:02:03 +03:00
|
|
|
|
|
|
|
AccountState *_account;
|
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-03-26 22:02:03 +03:00
|
|
|
explicit ActivitySettings(QWidget *parent = 0,
|
|
|
|
AccountState *account = AccountManager::instance()->accounts().first().data());
|
2015-11-10 17:12:35 +03:00
|
|
|
~ActivitySettings();
|
2015-11-19 12:50:52 +03:00
|
|
|
QSize sizeHint() const Q_DECL_OVERRIDE { return ownCloudGui::settingsDialogSize(); }
|
2015-11-10 17:12:35 +03:00
|
|
|
|
|
|
|
public slots:
|
2017-05-17 11:55:42 +03:00
|
|
|
void slotRefresh(AccountState *ptr);
|
|
|
|
void slotRemoveAccount(AccountState *ptr);
|
2015-11-12 17:39:07 +03:00
|
|
|
|
2018-01-24 00:51:25 +03:00
|
|
|
void setNotificationRefreshInterval(std::chrono::milliseconds interval);
|
2016-03-18 18:23:21 +03:00
|
|
|
|
2018-03-26 22:02:03 +03:00
|
|
|
//void slotShowIssuesTab(const QString &folderAlias);
|
2017-07-04 15:08:41 +03:00
|
|
|
|
2016-03-08 20:01:42 +03:00
|
|
|
private slots:
|
2015-11-10 17:12:35 +03:00
|
|
|
void slotCopyToClipboard();
|
2016-03-08 20:01:42 +03:00
|
|
|
void setActivityTabHidden(bool hidden);
|
2016-03-18 18:23:21 +03:00
|
|
|
void slotRegularNotificationCheck();
|
2016-04-05 14:57:38 +03:00
|
|
|
void slotShowIssueItemCount(int cnt);
|
2016-05-12 12:47:42 +03:00
|
|
|
void slotShowActivityTab();
|
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:
|
2017-05-17 11:55:42 +03:00
|
|
|
bool event(QEvent *e) Q_DECL_OVERRIDE;
|
2015-11-18 17:25:29 +03:00
|
|
|
|
2015-11-10 17:12:35 +03:00
|
|
|
QTabWidget *_tab;
|
2016-03-08 20:01:42 +03:00
|
|
|
int _activityTabId;
|
2017-07-04 15:08:41 +03:00
|
|
|
int _protocolTabId;
|
2016-04-05 14:57:38 +03:00
|
|
|
int _syncIssueTabId;
|
2016-03-08 20:01:42 +03:00
|
|
|
|
2015-11-10 17:12:35 +03:00
|
|
|
ActivityWidget *_activityWidget;
|
|
|
|
ProtocolWidget *_protocolWidget;
|
2017-07-04 15:08:41 +03:00
|
|
|
IssuesWidget *_issuesWidget;
|
2015-11-10 20:10:58 +03:00
|
|
|
QProgressIndicator *_progressIndicator;
|
2017-05-17 11:55:42 +03:00
|
|
|
QTimer _notificationCheckTimer;
|
|
|
|
QHash<AccountState *, QElapsedTimer> _timeSinceLastCheck;
|
2018-03-26 22:02:03 +03:00
|
|
|
|
|
|
|
AccountState *_account;
|
2015-11-10 17:12:35 +03:00
|
|
|
};
|
2015-10-19 15:41:53 +03:00
|
|
|
}
|
|
|
|
#endif // ActivityWIDGET_H
|