diff options
author | Klaas Freitag <freitag@owncloud.com> | 2015-11-10 17:12:35 +0300 |
---|---|---|
committer | Klaas Freitag <freitag@owncloud.com> | 2015-11-10 17:12:35 +0300 |
commit | 0e0b6026fc27e3dd74d7e763435d64315315fab7 (patch) | |
tree | 034e16db46e07e1807d2541bb652dc5f40260280 | |
parent | cf9fec73cf5550516e6c72b4dff360ab3bcbb6ff (diff) |
Activity: Unify the GUI, and reactivate copy to clipboard for all.
-rw-r--r-- | src/gui/activitywidget.cpp | 136 | ||||
-rw-r--r-- | src/gui/activitywidget.h | 37 | ||||
-rw-r--r-- | src/gui/activitywidget.ui | 47 | ||||
-rw-r--r-- | src/gui/protocolwidget.cpp | 121 | ||||
-rw-r--r-- | src/gui/protocolwidget.h | 10 | ||||
-rw-r--r-- | src/gui/protocolwidget.ui | 92 | ||||
-rw-r--r-- | src/gui/settingsdialog.cpp | 18 | ||||
-rw-r--r-- | src/gui/settingsdialog.h | 4 |
8 files changed, 279 insertions, 186 deletions
diff --git a/src/gui/activitywidget.cpp b/src/gui/activitywidget.cpp index baee77b03..8ad1fd357 100644 --- a/src/gui/activitywidget.cpp +++ b/src/gui/activitywidget.cpp @@ -31,6 +31,7 @@ #include "accountstate.h" #include "accountmanager.h" #include "activityitemdelegate.h" +#include "protocolwidget.h" #include "ui_activitywidget.h" @@ -264,10 +265,11 @@ ActivityWidget::ActivityWidget(QWidget *parent) : _ui->_activityList->setAlternatingRowColors(true); _ui->_activityList->setModel(_model); + _ui->_headerLabel->setText(tr("Server Activities")); + _copyBtn = _ui->_dialogButtonBox->addButton(tr("Copy"), QDialogButtonBox::ActionRole); _copyBtn->setToolTip( tr("Copy the activity list to the clipboard.")); - _copyBtn->setEnabled(false); - connect(_copyBtn, SIGNAL(clicked()), SLOT(copyToClipboard())); + connect(_copyBtn, SIGNAL(clicked()), SIGNAL(copyToClipboard())); } ActivityWidget::~ActivityWidget() @@ -280,38 +282,6 @@ void ActivityWidget::slotRefresh(AccountState *ptr) _model->slotRefreshActivity(ptr); } -void ActivityWidget::copyToClipboard() -{ - QString text; - QTextStream ts(&text); -#if 0 - int topLevelItems = _ui->_activityList->topLevelItemCount(); - for (int i = 0; i < topLevelItems; i++) { - QTreeWidgetItem *child = _ui->_activityList->topLevelItem(i); - ts << left - // time stamp - << qSetFieldWidth(10) - << child->data(0,Qt::DisplayRole).toString() - // file name - << qSetFieldWidth(64) - << child->data(1,Qt::DisplayRole).toString() - // folder - << qSetFieldWidth(30) - << child->data(2, Qt::DisplayRole).toString() - // action - << qSetFieldWidth(15) - << child->data(3, Qt::DisplayRole).toString() - // size - << qSetFieldWidth(10) - << child->data(4, Qt::DisplayRole).toString() - << qSetFieldWidth(0) - << endl; - } -#endif - QApplication::clipboard()->setText(text); - emit guiLog(tr("Copied to clipboard"), tr("The sync status has been copied to the clipboard.")); -} - // FIXME: Reused from protocol widget. Move over to utilities. QString ActivityWidget::timeString(QDateTime dt, QLocale::FormatType format) const { @@ -322,6 +292,33 @@ QString ActivityWidget::timeString(QDateTime dt, QLocale::FormatType format) con return loc.toString(dt, dtFormat); } +void ActivityWidget::storeActivityList( QTextStream& ts ) +{ + ActivityList activities = _model->activityList(); + + foreach( Activity activity, activities ) { + ts << left + // account name + << qSetFieldWidth(30) + << activity._accName + // date and time + << qSetFieldWidth(34) + << activity._dateTime.toString() + // subject + << qSetFieldWidth(10) + << activity._subject + // file + << qSetFieldWidth(30) + << activity._file + // message (mostly empty) + << qSetFieldWidth(55) + << activity._message + // + << qSetFieldWidth(0) + << endl; + } +} + void ActivityWidget::slotOpenFile( ) { // FIXME make work at all. @@ -340,4 +337,75 @@ void ActivityWidget::slotOpenFile( ) #endif } + +ActivitySettings::ActivitySettings(QWidget *parent) + :QWidget(parent) +{ + QHBoxLayout *hbox = new QHBoxLayout(this); + setLayout(hbox); + + // create a tab widget for the three activity views + _tab = new QTabWidget(this); + hbox->addWidget(_tab); + _activityWidget = new ActivityWidget(this); + _tab->addTab(_activityWidget, Theme::instance()->applicationIcon(), tr("Server Activity")); + connect(_activityWidget, SIGNAL(copyToClipboard()), this, SLOT(slotCopyToClipboard())); + + _protocolWidget = new ProtocolWidget(this); + _tab->addTab(_protocolWidget, Theme::instance()->syncStateIcon(SyncResult::Success), tr("Sync Protocol")); + connect(_protocolWidget, SIGNAL(copyToClipboard()), this, SLOT(slotCopyToClipboard())); + + // Add the not-synced list into the tab + QWidget *w = new QWidget; + QVBoxLayout *vbox = new QVBoxLayout(this); + vbox->addWidget(new QLabel(tr("List of ignored or errornous files"), this)); + vbox->addWidget(_protocolWidget->issueWidget()); + QDialogButtonBox *dlgButtonBox = new QDialogButtonBox(this); + vbox->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(vbox); + _tab->addTab(w, Theme::instance()->syncStateIcon(SyncResult::Problem), tr("Not Synced")); +} + +void ActivitySettings::slotCopyToClipboard() +{ + QString text; + QTextStream ts(&text); + + int idx = _tab->currentIndex(); + QString theSubject; + + if( idx == 0 ) { + // the activity widget + _activityWidget->storeActivityList(ts); + theSubject = tr("server activity list"); + } else if(idx == 1 ) { + // the protocol widget + _protocolWidget->storeSyncActivity(ts); + theSubject = tr("sync activity list"); + } else if(idx == 2 ) { + // issues Widget + theSubject = tr("not syned items list"); + _protocolWidget->storeSyncIssues(ts); + } + + QApplication::clipboard()->setText(text); + emit guiLog(tr("Copied to clipboard"), tr("The %1 has been copied to the clipboard.").arg(theSubject)); +} + +void ActivitySettings::slotRefresh( AccountState* ptr ) +{ + _activityWidget->slotRefresh(ptr); +} + +ActivitySettings::~ActivitySettings() +{ + +} + + } diff --git a/src/gui/activitywidget.h b/src/gui/activitywidget.h index 5981c297a..64b3d0684 100644 --- a/src/gui/activitywidget.h +++ b/src/gui/activitywidget.h @@ -31,6 +31,7 @@ namespace OCC { class Account; class AccountStatusPtr; +class ProtocolWidget; namespace Ui { class ActivityWidget; @@ -89,6 +90,8 @@ public: bool canFetchMore(const QModelIndex& ) const; void fetchMore(const QModelIndex&); + ActivityList activityList() { return _finalList; } + public slots: void slotRefreshActivity(AccountState* ast); @@ -109,6 +112,7 @@ private: * @brief The ActivityWidget class * @ingroup gui */ + class ActivityWidget : public QWidget { Q_OBJECT @@ -116,21 +120,15 @@ public: explicit ActivityWidget(QWidget *parent = 0); ~ActivityWidget(); QSize sizeHint() const { return ownCloudGui::settingsDialogSize(); } - - // FIXME: Move the tab widget to its own widget that is used in settingsdialog. - QTabWidget *tabWidget() { return _ui->_tabWidget; } + void storeActivityList(QTextStream &ts); public slots: void slotOpenFile(); void slotRefresh(AccountState* ptr); -protected slots: - void copyToClipboard(); - -protected: - signals: void guiLog(const QString&, const QString&); + void copyToClipboard(); private: QString timeString(QDateTime dt, QLocale::FormatType format) const; @@ -140,5 +138,28 @@ private: ActivityListModel *_model; }; + +class ActivitySettings : public QWidget +{ + Q_OBJECT +public: + explicit ActivitySettings(QWidget *parent = 0); + ~ActivitySettings(); + QSize sizeHint() const { return ownCloudGui::settingsDialogSize(); } + +public slots: + void slotRefresh( AccountState* ptr ); + void slotCopyToClipboard(); + +signals: + void guiLog(const QString&, const QString&); + +private: + QTabWidget *_tab; + ActivityWidget *_activityWidget; + ProtocolWidget *_protocolWidget; + +}; + } #endif // ActivityWIDGET_H diff --git a/src/gui/activitywidget.ui b/src/gui/activitywidget.ui index c244cc546..ddce3e50d 100644 --- a/src/gui/activitywidget.ui +++ b/src/gui/activitywidget.ui @@ -6,46 +6,33 @@ <rect> <x>0</x> <y>0</y> - <width>672</width> - <height>640</height> + <width>693</width> + <height>556</height> </rect> </property> <property name="windowTitle"> <string>Form</string> </property> - <layout class="QGridLayout" name="gridLayout_2"> - <item row="0" column="1"> - <widget class="QTabWidget" name="_tabWidget"> - <property name="tabShape"> - <enum>QTabWidget::Rounded</enum> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="_headerLabel"> + <property name="text"> + <string>TextLabel</string> </property> - <property name="currentIndex"> - <number>0</number> - </property> - <property name="elideMode"> - <enum>Qt::ElideMiddle</enum> - </property> - <widget class="QWidget" name="protocolTab"> - <attribute name="title"> - <string>Server Activity</string> - </attribute> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <widget class="QListView" name="_activityList"/> - </item> - <item row="1" column="0"> - <widget class="QDialogButtonBox" name="_dialogButtonBox"> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - </layout> - </widget> </widget> </item> + <item row="1" column="0"> + <widget class="QListView" name="_activityList"/> + </item> + <item row="2" column="0"> + <widget class="QDialogButtonBox" name="_dialogButtonBox"/> + </item> </layout> </widget> + <tabstops> + <tabstop>_activityList</tabstop> + <tabstop>_dialogButtonBox</tabstop> + </tabstops> <resources/> <connections/> </ui> diff --git a/src/gui/protocolwidget.cpp b/src/gui/protocolwidget.cpp index a2267636f..064de3c78 100644 --- a/src/gui/protocolwidget.cpp +++ b/src/gui/protocolwidget.cpp @@ -66,17 +66,16 @@ ProtocolWidget::ProtocolWidget(QWidget *parent) : #if defined(Q_OS_MAC) _ui->_treeWidget->setMinimumWidth(400); #endif - connect(this, SIGNAL(guiLog(QString,QString)), Logger::instance(), SIGNAL(guiLog(QString,QString))); + _ui->_headerLabel->setText(tr("Local sync protocol")); - _retrySyncBtn = _ui->_dialogButtonBox->addButton(tr("Retry Sync"), QDialogButtonBox::ActionRole); - _retrySyncBtn->setEnabled(false); - connect(_retrySyncBtn, SIGNAL(clicked()), SLOT(slotRetrySync())); - - _copyBtn = _ui->_dialogButtonBox->addButton(tr("Copy"), QDialogButtonBox::ActionRole); - _copyBtn->setToolTip( tr("Copy the activity list to the clipboard.")); - _copyBtn->setEnabled(false); - connect(_copyBtn, SIGNAL(clicked()), SLOT(copyToClipboard())); + QPushButton *copyBtn = _ui->_dialogButtonBox->addButton(tr("Copy"), QDialogButtonBox::ActionRole); + copyBtn->setToolTip( tr("Copy the activity list to the clipboard.")); + copyBtn->setEnabled(true); + connect(copyBtn, SIGNAL(clicked()), SIGNAL(copyToClipboard())); + // this view is used to display all errors such as real errors, soft errors and ignored files + // it is instantiated here, but made accessible via the method issueWidget() so that it can + // be embedded into another gui element. _issueItemView = new QTreeWidget(this); header.removeLast(); _issueItemView->setHeaderLabels( header ); @@ -92,38 +91,7 @@ ProtocolWidget::~ProtocolWidget() delete _ui; } -void ProtocolWidget::copyToClipboard() -{ - QString text; - QTextStream ts(&text); - - int topLevelItems = _ui->_treeWidget->topLevelItemCount(); - for (int i = 0; i < topLevelItems; i++) { - QTreeWidgetItem *child = _ui->_treeWidget->topLevelItem(i); - ts << left - // time stamp - << qSetFieldWidth(10) - << child->data(0,Qt::DisplayRole).toString() - // file name - << qSetFieldWidth(64) - << child->data(1,Qt::DisplayRole).toString() - // folder - << qSetFieldWidth(30) - << child->data(2, Qt::DisplayRole).toString() - // action - << qSetFieldWidth(15) - << child->data(3, Qt::DisplayRole).toString() - // size - << qSetFieldWidth(10) - << child->data(4, Qt::DisplayRole).toString() - << qSetFieldWidth(0) - << endl; - } - - QApplication::clipboard()->setText(text); - emit guiLog(tr("Copied to clipboard"), tr("The sync status has been copied to the clipboard.")); -} - +#if 0 void ProtocolWidget::slotRetrySync() { FolderMan *folderMan = FolderMan::instance(); @@ -142,6 +110,7 @@ void ProtocolWidget::slotRetrySync() folderMan->slotScheduleAllFolders(); } +#endif void ProtocolWidget::showEvent(QShowEvent *ev) { @@ -167,8 +136,18 @@ void ProtocolWidget::cleanIgnoreItems(const QString& folder) itemCnt--; } + // limit also in the protocol widget + itemCnt = _issueItemView->topLevelItemCount(); + + // Limit the number of items in the issue view + while(itemCnt > 2000) { + delete _issueItemView->takeTopLevelItem(itemCnt - 1); + itemCnt--; + } + + // clean up the issue list for( int cnt = itemCnt-1; cnt >=0 ; cnt-- ) { - QTreeWidgetItem *item = _ui->_treeWidget->topLevelItem(cnt); + QTreeWidgetItem *item = _issueItemView->topLevelItem(cnt); bool isErrorItem = item->data(0, IgnoredIndicatorRole).toBool(); QString itemFolder = item->data(2, Qt::UserRole).toString(); if( isErrorItem && itemFolder == folder ) { @@ -253,6 +232,7 @@ QTreeWidgetItem* ProtocolWidget::createCompletedTreewidgetItem(const QString& fo void ProtocolWidget::computeResyncButtonEnabled() { +#if 0 FolderMan *folderMan = FolderMan::instance(); Folder::Map folders = folderMan->map(); @@ -273,6 +253,7 @@ void ProtocolWidget::computeResyncButtonEnabled() _retrySyncBtn->setEnabled(enabled); _retrySyncBtn->setToolTip(t); +#endif } @@ -301,9 +282,59 @@ void ProtocolWidget::slotItemCompleted(const QString &folder, const SyncFileItem } else { _ui->_treeWidget->insertTopLevelItem(0, line); } - if (!_copyBtn->isEnabled()) { - _copyBtn->setEnabled(true); - } + } +} + + +void ProtocolWidget::storeSyncActivity(QTextStream& ts) +{ + int topLevelItems = _ui->_treeWidget->topLevelItemCount(); + + for (int i = 0; i < topLevelItems; i++) { + QTreeWidgetItem *child = _ui->_treeWidget->topLevelItem(i); + ts << left + // time stamp + << qSetFieldWidth(10) + << child->data(0,Qt::DisplayRole).toString() + // file name + << qSetFieldWidth(64) + << child->data(1,Qt::DisplayRole).toString() + // folder + << qSetFieldWidth(30) + << child->data(2, Qt::DisplayRole).toString() + // action + << qSetFieldWidth(15) + << child->data(3, Qt::DisplayRole).toString() + // size + << qSetFieldWidth(10) + << child->data(4, Qt::DisplayRole).toString() + << qSetFieldWidth(0) + << endl; + } +} + +void ProtocolWidget::storeSyncIssues(QTextStream& ts) +{ + int topLevelItems = _issueItemView->topLevelItemCount(); + + for (int i = 0; i < topLevelItems; i++) { + QTreeWidgetItem *child = _issueItemView->topLevelItem(i); + ts << left + // time stamp + << qSetFieldWidth(10) + << child->data(0,Qt::DisplayRole).toString() + // file name + << qSetFieldWidth(64) + << child->data(1,Qt::DisplayRole).toString() + // folder + << qSetFieldWidth(30) + << child->data(2, Qt::DisplayRole).toString() + // action + << qSetFieldWidth(15) + << child->data(3, Qt::DisplayRole).toString() + + << qSetFieldWidth(0) + << endl; } } diff --git a/src/gui/protocolwidget.h b/src/gui/protocolwidget.h index 610bea372..3559c0ab0 100644 --- a/src/gui/protocolwidget.h +++ b/src/gui/protocolwidget.h @@ -46,22 +46,20 @@ public: QSize sizeHint() const { return ownCloudGui::settingsDialogSize(); } QTreeWidget *issueWidget() { return _issueItemView; } + void storeSyncActivity(QTextStream& ts); + void storeSyncIssues(QTextStream& ts); public slots: void slotProgressInfo( const QString& folder, const ProgressInfo& progress ); void slotItemCompleted( const QString& folder, const SyncFileItem& item, const PropagatorJob& job); void slotOpenFile( QTreeWidgetItem* item, int ); -protected slots: - void copyToClipboard(); - void slotRetrySync(); - protected: void showEvent(QShowEvent *); void hideEvent(QHideEvent *); signals: - void guiLog(const QString&, const QString&); + void copyToClipboard(); private: void setSyncResultStatus(const SyncResult& result ); @@ -75,8 +73,6 @@ private: const int IgnoredIndicatorRole; Ui::ProtocolWidget *_ui; QTreeWidget *_issueItemView; - QPushButton *_retrySyncBtn; - QPushButton *_copyBtn; }; } diff --git a/src/gui/protocolwidget.ui b/src/gui/protocolwidget.ui index 39f065b19..1569a89f8 100644 --- a/src/gui/protocolwidget.ui +++ b/src/gui/protocolwidget.ui @@ -13,59 +13,53 @@ <property name="windowTitle"> <string>Form</string> </property> - <layout class="QGridLayout" name="gridLayout_2"> + <layout class="QGridLayout" name="gridLayout"> <item row="0" column="0"> - <widget class="QGroupBox" name="groupBox"> - <property name="title"> - <string>Sync Activity</string> + <widget class="QLabel" name="_headerLabel"> + <property name="text"> + <string>TextLabel</string> </property> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <widget class="QTreeWidget" name="_treeWidget"> - <property name="alternatingRowColors"> - <bool>true</bool> - </property> - <property name="rootIsDecorated"> - <bool>false</bool> - </property> - <property name="uniformRowHeights"> - <bool>true</bool> - </property> - <property name="columnCount"> - <number>4</number> - </property> - <column> - <property name="text"> - <string notr="true">1</string> - </property> - </column> - <column> - <property name="text"> - <string notr="true">2</string> - </property> - </column> - <column> - <property name="text"> - <string notr="true">3</string> - </property> - </column> - <column> - <property name="text"> - <string notr="true">4</string> - </property> - </column> - </widget> - </item> - <item row="1" column="0"> - <widget class="QDialogButtonBox" name="_dialogButtonBox"> - <property name="standardButtons"> - <set>QDialogButtonBox::NoButton</set> - </property> - </widget> - </item> - </layout> </widget> </item> + <item row="1" column="0" colspan="2"> + <widget class="QTreeWidget" name="_treeWidget"> + <property name="alternatingRowColors"> + <bool>true</bool> + </property> + <property name="rootIsDecorated"> + <bool>false</bool> + </property> + <property name="uniformRowHeights"> + <bool>true</bool> + </property> + <property name="columnCount"> + <number>4</number> + </property> + <column> + <property name="text"> + <string notr="true">1</string> + </property> + </column> + <column> + <property name="text"> + <string notr="true">2</string> + </property> + </column> + <column> + <property name="text"> + <string notr="true">3</string> + </property> + </column> + <column> + <property name="text"> + <string notr="true">4</string> + </property> + </column> + </widget> + </item> + <item row="2" column="1"> + <widget class="QDialogButtonBox" name="_dialogButtonBox"/> + </item> </layout> </widget> <resources/> diff --git a/src/gui/settingsdialog.cpp b/src/gui/settingsdialog.cpp index d7b288f44..0a07c26d2 100644 --- a/src/gui/settingsdialog.cpp +++ b/src/gui/settingsdialog.cpp @@ -81,16 +81,12 @@ SettingsDialog::SettingsDialog(ownCloudGui *gui, QWidget *parent) : _activityAction = createColorAwareAction(QLatin1String(":/client/resources/activity.png"), tr("Activity")); _actionGroup->addAction(_activityAction); addActionToToolBar(_activityAction); + _activitySettings = new ActivitySettings; + _ui->stack->addWidget(_activitySettings); + connect( _activitySettings, SIGNAL(guiLog(QString,QString)), _gui, + SLOT(slotShowOptionalTrayMessage(QString,QString)) ); - // FIXME: Put this QTabWidget into its own class to be used here. - _activityWidget = new ActivityWidget; - _activityWidget->setParent(this); - _ui->stack->addWidget(_activityWidget); - _activityWidget->tabWidget()->setTabIcon(0, Theme::instance()->applicationIcon()); - - ProtocolWidget *pw = new ProtocolWidget(this); - _activityWidget->tabWidget()->addTab(pw, Theme::instance()->syncStateIcon(SyncResult::Success), tr("Sync Protocol")); - _activityWidget->tabWidget()->addTab(pw->issueWidget(), Theme::instance()->syncStateIcon(SyncResult::Problem), tr("Not Synced")); + // Add the protocol widget QAction *generalAction = createColorAwareAction(QLatin1String(":/client/resources/settings.png"), tr("General")); _actionGroup->addAction(generalAction); @@ -104,7 +100,7 @@ SettingsDialog::SettingsDialog(ownCloudGui *gui, QWidget *parent) : NetworkSettings *networkSettings = new NetworkSettings; _ui->stack->addWidget(networkSettings); - _actionGroupWidgets.insert(_activityAction, _activityWidget); + _actionGroupWidgets.insert(_activityAction, _activitySettings); _actionGroupWidgets.insert(generalAction, generalSettings); _actionGroupWidgets.insert(networkAction, networkSettings); @@ -294,7 +290,7 @@ void SettingsDialog::slotRefreshActivity( AccountState* accountState ) { if (accountState) { qDebug() << "Refreshing Activity list for " << accountState->account()->displayName(); - _activityWidget->slotRefresh(accountState); + _activitySettings->slotRefresh(accountState); } } diff --git a/src/gui/settingsdialog.h b/src/gui/settingsdialog.h index 4bfeac312..ec04dcf27 100644 --- a/src/gui/settingsdialog.h +++ b/src/gui/settingsdialog.h @@ -36,7 +36,7 @@ class AccountSettings; class Application; class FolderMan; class ownCloudGui; -class ActivityWidget; +class ActivitySettings; /** * @brief The SettingsDialog class @@ -82,7 +82,7 @@ private: // Maps the actions from the action group to the toolbar actions QHash<QAction*, QAction*> _toolbarAccountActions; - ActivityWidget *_activityWidget; + ActivitySettings *_activitySettings; QAction * _activityAction; ownCloudGui *_gui; |