mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-23 21:46:03 +03:00
Small fixes.
- Align progress indicator to the center. - Moves unused code. - Removes unused labels. Signed-off-by: Camila San <hello@camila.codes>
This commit is contained in:
parent
a9cd3b3a6d
commit
9de3985021
3 changed files with 35 additions and 225 deletions
|
@ -70,17 +70,12 @@ ActivityWidget::ActivityWidget(AccountState *accountState, QWidget *parent)
|
|||
_ui->_activityList->setAlternatingRowColors(true);
|
||||
_ui->_activityList->setModel(_model);
|
||||
|
||||
_ui->_notifyLabel->hide();
|
||||
_ui->_notifyScroll->hide();
|
||||
|
||||
// Create a widget container for the notifications. The ui file defines
|
||||
// a scroll area that get a widget with a layout as children
|
||||
QWidget *w = new QWidget;
|
||||
_notificationsLayout = new QVBoxLayout;
|
||||
w->setLayout(_notificationsLayout);
|
||||
_notificationsLayout->setAlignment(Qt::AlignTop);
|
||||
_ui->_notifyScroll->setAlignment(Qt::AlignTop);
|
||||
_ui->_notifyScroll->setWidget(w);
|
||||
|
||||
showLabels();
|
||||
|
||||
|
@ -267,11 +262,6 @@ void ActivityWidget::slotRemoveAccount()
|
|||
void ActivityWidget::showLabels()
|
||||
{
|
||||
QString t = tr("Server Activities");
|
||||
_ui->_headerLabel->setTextFormat(Qt::RichText);
|
||||
_ui->_headerLabel->setText(t);
|
||||
|
||||
_ui->_notifyLabel->setText(tr("Action Required: Notifications"));
|
||||
|
||||
t.clear();
|
||||
QSetIterator<QString> i(_accountsWithoutActivities);
|
||||
while (i.hasNext()) {
|
||||
|
@ -356,12 +346,8 @@ void ActivityWidget::checkActivityTabVisibility()
|
|||
_accountsWithoutActivities.count() != accountCount;
|
||||
bool hasNotifications = !_widgetForNotifId.isEmpty();
|
||||
|
||||
_ui->_headerLabel->setVisible(hasAccountsWithActivity);
|
||||
_ui->_activityList->setVisible(hasAccountsWithActivity);
|
||||
|
||||
_ui->_notifyLabel->setVisible(hasNotifications);
|
||||
_ui->_notifyScroll->setVisible(hasNotifications);
|
||||
|
||||
emit hideActivityTab(!hasAccountsWithActivity && !hasNotifications);
|
||||
}
|
||||
|
||||
|
@ -383,10 +369,9 @@ void ActivityWidget::slotOpenFile(QModelIndex indx)
|
|||
// collected.
|
||||
void ActivityWidget::slotBuildNotificationDisplay(const ActivityList &list)
|
||||
{
|
||||
QHash<QString, int> accNotified;
|
||||
QString listAccountName;
|
||||
|
||||
// Whether a new notification widget was added to the notificationLayout.
|
||||
// Whether a new notification was added to the list
|
||||
bool newNotificationShown = false;
|
||||
|
||||
foreach (auto activity, list) {
|
||||
|
@ -395,26 +380,6 @@ void ActivityWidget::slotBuildNotificationDisplay(const ActivityList &list)
|
|||
continue;
|
||||
}
|
||||
|
||||
// NotificationWidget *widget = 0;
|
||||
|
||||
// if (_widgetForNotifId.contains(activity.ident())) {
|
||||
// widget = _widgetForNotifId[activity.ident()];
|
||||
// } else {
|
||||
// widget = new NotificationWidget(this);
|
||||
// connect(widget, &NotificationWidget::sendNotificationRequest,
|
||||
// this, &ActivityWidget::slotSendNotificationRequest);
|
||||
// connect(widget, &NotificationWidget::requestCleanupAndBlacklist,
|
||||
// this, &ActivityWidget::slotRequestCleanupAndBlacklist);
|
||||
|
||||
// _notificationsLayout->addWidget(widget);
|
||||
//// _ui->_notifyScroll->setMinimumHeight( widget->height());
|
||||
// _ui->_notifyScroll->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContentsOnFirstShow);
|
||||
// _widgetForNotifId[activity.ident()] = widget;
|
||||
// newNotificationShown = true;
|
||||
// }
|
||||
|
||||
// widget->setActivity(activity);
|
||||
|
||||
// remember the list account name for the strayCat handling below.
|
||||
listAccountName = activity._accName;
|
||||
|
||||
|
@ -428,22 +393,9 @@ void ActivityWidget::slotBuildNotificationDisplay(const ActivityList &list)
|
|||
if (_guiLogTimer.elapsed() > 60 * 60 * 1000) {
|
||||
_guiLoggedNotifications.clear();
|
||||
}
|
||||
|
||||
if (!_guiLoggedNotifications.contains(activity._id)) {
|
||||
//QString host = activity._accName;
|
||||
// store the name of the account that sends the notification to be
|
||||
// able to add it to the tray notification
|
||||
// remove the user name from the account as that is not accurate here.
|
||||
// int indx = host.indexOf(QChar('@'));
|
||||
// if (indx > -1) {
|
||||
// host.remove(0, 1 + indx);
|
||||
// }
|
||||
// if (!host.isEmpty()) {
|
||||
// if (accNotified.contains(host)) {
|
||||
// accNotified[host] = accNotified[host] + 1;
|
||||
// } else {
|
||||
// accNotified[host] = 1;
|
||||
// }
|
||||
// }
|
||||
newNotificationShown = true;
|
||||
_guiLoggedNotifications.insert(activity._id);
|
||||
|
||||
// Assemble a tray notification for the NEW notification
|
||||
|
@ -460,45 +412,9 @@ void ActivityWidget::slotBuildNotificationDisplay(const ActivityList &list)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// check if there are widgets that have no corresponding activity from
|
||||
// the server any more. Collect them in a list
|
||||
// QList<Activity::Identifier> strayCats;
|
||||
// foreach (auto id, _widgetForNotifId.keys()) {
|
||||
// NotificationWidget *widget = _widgetForNotifId[id];
|
||||
|
||||
// bool found = false;
|
||||
// // do not mark widgets of other accounts to delete.
|
||||
// if (widget->activity()._accName != listAccountName) {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// foreach (auto activity, list) {
|
||||
// if (activity.ident() == id) {
|
||||
// // found an activity
|
||||
// found = true;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// if (!found) {
|
||||
// // the activity does not exist any more.
|
||||
// strayCats.append(id);
|
||||
// }
|
||||
// }
|
||||
|
||||
// .. and now delete all these stray cat widgets.
|
||||
// foreach (auto strayCatId, strayCats) {
|
||||
// NotificationWidget *widgetToGo = _widgetForNotifId[strayCatId];
|
||||
// scheduleWidgetToRemove(widgetToGo, 0);
|
||||
// }
|
||||
|
||||
checkActivityTabVisibility();
|
||||
|
||||
if (newNotificationShown) {
|
||||
// restart the gui log timer now that we show a notification
|
||||
// restart the gui log timer now that we show a new notification
|
||||
if(newNotificationShown)
|
||||
_guiLogTimer.start();
|
||||
emit newNotification();
|
||||
}
|
||||
}
|
||||
|
||||
void ActivityWidget::slotSendNotificationRequest(const QString &accountName, const QString &link, const QByteArray &verb, int row)
|
||||
|
@ -624,12 +540,6 @@ void ActivityWidget::slotCheckToCleanWidgets()
|
|||
if (_widgetsToRemove.isEmpty()) {
|
||||
_removeTimer.stop();
|
||||
}
|
||||
|
||||
// check to see if the whole notification pane should be hidden
|
||||
if (_widgetForNotifId.isEmpty()) {
|
||||
_ui->_notifyLabel->setHidden(true);
|
||||
_ui->_notifyScroll->setHidden(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -639,19 +549,21 @@ ActivitySettings::ActivitySettings(AccountState *accountState, QWidget *parent)
|
|||
: QWidget(parent)
|
||||
, _accountState(accountState)
|
||||
{
|
||||
QHBoxLayout *hbox = new QHBoxLayout(this);
|
||||
setLayout(hbox);
|
||||
_vbox = new QVBoxLayout(this);
|
||||
setLayout(_vbox);
|
||||
|
||||
// create a tab widget for the three activity views
|
||||
// _widget = new QWidget(this);
|
||||
// hbox->addWidget(_tab);
|
||||
_activityWidget = new ActivityWidget(_accountState, this);
|
||||
//_activityTabId = _tab->addTab(_activityWidget, Theme::instance()->applicationIcon(), tr("Server Activity"));
|
||||
hbox->addWidget(_activityWidget);
|
||||
_vbox->insertWidget(1, _activityWidget);
|
||||
connect(_activityWidget, &ActivityWidget::copyToClipboard, this, &ActivitySettings::slotCopyToClipboard);
|
||||
connect(_activityWidget, &ActivityWidget::hideActivityTab, this, &ActivitySettings::setActivityTabHidden);
|
||||
connect(_activityWidget, &ActivityWidget::guiLog, this, &ActivitySettings::guiLog);
|
||||
connect(_activityWidget, &ActivityWidget::newNotification, this, &ActivitySettings::slotShowActivityTab);
|
||||
connect(&_notificationCheckTimer, &QTimer::timeout,
|
||||
this, &ActivitySettings::slotRegularNotificationCheck);
|
||||
|
||||
// Add a progress indicator to spin if the acitivity list is updated.
|
||||
_progressIndicator = new QProgressIndicator(this);
|
||||
// connect a model signal to stop the animation
|
||||
connect(_activityWidget, &ActivityWidget::rowsInserted, _progressIndicator, &QProgressIndicator::stopAnimation);
|
||||
connect(_activityWidget, &ActivityWidget::rowsInserted, this, &ActivitySettings::slotDisplayActivities);
|
||||
|
||||
_protocolWidget = new ProtocolWidget(this);
|
||||
_vbox->addWidget(_protocolWidget);
|
||||
|
@ -666,19 +578,10 @@ ActivitySettings::ActivitySettings(AccountState *accountState, QWidget *parent)
|
|||
// this, &ActivitySettings::slotShowIssueItemCount);
|
||||
// connect(_issuesWidget, &IssuesWidget::copyToClipboard,
|
||||
// this, &ActivitySettings::slotCopyToClipboard);
|
||||
}
|
||||
|
||||
// Add a progress indicator to spin if the acitivity list is updated.
|
||||
_progressIndicator = new QProgressIndicator(this);
|
||||
//_tab->setCornerWidget(_progressIndicator);
|
||||
|
||||
connect(&_notificationCheckTimer, &QTimer::timeout,
|
||||
this, &ActivitySettings::slotRegularNotificationCheck);
|
||||
|
||||
// connect a model signal to stop the animation.
|
||||
connect(_activityWidget, &ActivityWidget::rowsInserted, _progressIndicator, &QProgressIndicator::stopAnimation);
|
||||
|
||||
// We want the protocol be the default
|
||||
//_tab->setCurrentIndex(1);
|
||||
void ActivitySettings::slotDisplayActivities(){
|
||||
_vbox->removeWidget(_progressIndicator);
|
||||
}
|
||||
|
||||
void ActivitySettings::setNotificationRefreshInterval(std::chrono::milliseconds interval)
|
||||
|
@ -687,22 +590,6 @@ void ActivitySettings::setNotificationRefreshInterval(std::chrono::milliseconds
|
|||
_notificationCheckTimer.start(interval.count());
|
||||
}
|
||||
|
||||
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;
|
||||
// }
|
||||
}
|
||||
|
||||
void ActivitySettings::slotShowIssueItemCount(int cnt)
|
||||
{
|
||||
QString cntText = tr("Not Synced");
|
||||
|
@ -713,22 +600,6 @@ void ActivitySettings::slotShowIssueItemCount(int cnt)
|
|||
//_tab->setTabText(_syncIssueTabId, cntText);
|
||||
}
|
||||
|
||||
void ActivitySettings::slotShowActivityTab()
|
||||
{
|
||||
// if (_activityTabId != -1) {
|
||||
// _tab->setCurrentIndex(_activityTabId);
|
||||
// }
|
||||
}
|
||||
|
||||
//void ActivitySettings::slotShowIssuesTab(const QString &folderAlias)
|
||||
//{
|
||||
// if (_syncIssueTabId == -1)
|
||||
// return;
|
||||
// _tab->setCurrentIndex(_syncIssueTabId);
|
||||
|
||||
// _issuesWidget->showFolderErrors(folderAlias);
|
||||
//}
|
||||
|
||||
void ActivitySettings::slotCopyToClipboard()
|
||||
{
|
||||
QString text;
|
||||
|
@ -737,11 +608,7 @@ void ActivitySettings::slotCopyToClipboard()
|
|||
//int idx = _tab->currentIndex();
|
||||
QString message;
|
||||
|
||||
// if (idx == _activityTabId) {
|
||||
// // the activity widget
|
||||
// _activityWidget->storeActivityList(ts);
|
||||
// message = tr("The server activity list has been copied to the clipboard.");
|
||||
// } else if (idx == _protocolTabId) {
|
||||
// if (idx == _protocolTabId) {
|
||||
// // the protocol widget
|
||||
// //_protocolWidget->storeSyncActivity(ts);
|
||||
// message = tr("The sync activity list has been copied to the clipboard.");
|
||||
|
@ -776,6 +643,8 @@ void ActivitySettings::slotRefresh()
|
|||
}
|
||||
if (_accountState && _accountState->isConnected()) {
|
||||
if (isVisible() || !timer.isValid()) {
|
||||
_vbox->insertWidget(0, _progressIndicator);
|
||||
_vbox->setAlignment(_progressIndicator, Qt::AlignHCenter);
|
||||
_progressIndicator->startAnimation();
|
||||
_activityWidget->slotRefreshActivities();
|
||||
}
|
||||
|
|
|
@ -91,7 +91,6 @@ signals:
|
|||
void copyToClipboard();
|
||||
void rowsInserted();
|
||||
void hideActivityTab(bool);
|
||||
void newNotification();
|
||||
void sendNotificationRequest(const QString &accountName, const QString &link, const QByteArray &verb, int row);
|
||||
|
||||
private slots:
|
||||
|
@ -158,10 +157,9 @@ public slots:
|
|||
|
||||
private slots:
|
||||
void slotCopyToClipboard();
|
||||
void setActivityTabHidden(bool hidden);
|
||||
void slotRegularNotificationCheck();
|
||||
void slotShowIssueItemCount(int cnt);
|
||||
void slotShowActivityTab();
|
||||
void slotDisplayActivities();
|
||||
|
||||
signals:
|
||||
void guiLog(const QString &, const QString &);
|
||||
|
@ -173,6 +171,7 @@ private:
|
|||
ProtocolWidget *_protocolWidget;
|
||||
IssuesWidget *_issuesWidget;
|
||||
QProgressIndicator *_progressIndicator;
|
||||
QVBoxLayout *_vbox;
|
||||
QTimer _notificationCheckTimer;
|
||||
QHash<AccountState *, QElapsedTimer> _timeSinceLastCheck;
|
||||
|
||||
|
|
|
@ -14,75 +14,7 @@
|
|||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="_notifyLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::PlainText</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QScrollArea" name="_notifyScroll">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
<widget class="QWidget" name="_scrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>677</width>
|
||||
<height>70</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="_headerLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::RichText</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QListView" name="_activityList">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="_bottomLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||
|
@ -98,9 +30,19 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<item row="2" column="0">
|
||||
<widget class="QDialogButtonBox" name="_dialogButtonBox"/>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QListView" name="_activityList">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
|
|
Loading…
Reference in a new issue