Support sort orders of the repo list (#1526)
* Support sort orders of the repo list * Add the icon image * Remove categories in sort orders * Update action names
This commit is contained in:
parent
6b60b251c0
commit
e91b057025
15 changed files with 124 additions and 16 deletions
BIN
images/toolbar/sorts-orange.png
Normal file
BIN
images/toolbar/sorts-orange.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
BIN
images/toolbar/sorts-orange@2x.png
Normal file
BIN
images/toolbar/sorts-orange@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
BIN
images/toolbar/sorts.png
Normal file
BIN
images/toolbar/sorts.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 466 B |
BIN
images/toolbar/sorts@2x.png
Normal file
BIN
images/toolbar/sorts@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 948 B |
19
qt.css
19
qt.css
|
@ -725,3 +725,22 @@ AccountView QPushButton:hover#mSettingsPushButton {
|
|||
image: url(:/images/toolbar/settings-orange.png);
|
||||
}
|
||||
|
||||
AccountView QPushButton#mSortPushButton {
|
||||
border: 0;
|
||||
border-radius: 0;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
image: url(:/images/toolbar/sorts.png);
|
||||
}
|
||||
|
||||
AccountView QPushButton#mSortPushButton::menu-indicator {
|
||||
image: "";
|
||||
}
|
||||
|
||||
AccountView QPushButton:hover#mSortPushButton {
|
||||
border: 0;
|
||||
border-radius: 0;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
image: url(:/images/toolbar/sorts-orange.png);
|
||||
}
|
||||
|
|
|
@ -227,6 +227,10 @@
|
|||
<file>images/toolbar/refresh-new@2x.png</file>
|
||||
<file>images/toolbar/refresh-orange.png</file>
|
||||
<file>images/toolbar/refresh-orange@2x.png</file>
|
||||
<file>images/toolbar/sorts-orange.png</file>
|
||||
<file>images/toolbar/sorts-orange@2x.png</file>
|
||||
<file>images/toolbar/sorts.png</file>
|
||||
<file>images/toolbar/sorts@2x.png</file>
|
||||
<file>qt.css</file>
|
||||
<file>qt-win.css</file>
|
||||
<file>qt-mac.css</file>
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <QTimer>
|
||||
|
||||
#include "utils/utils.h"
|
||||
#include "ui/repo-tree-model.h"
|
||||
#include "utils/utils-mac.h"
|
||||
#include "seafile-applet.h"
|
||||
#include "ui/tray-icon.h"
|
||||
|
@ -56,10 +57,10 @@ const char *kProxyPort = "proxy_port";
|
|||
const char *kProxyUsername = "proxy_username";
|
||||
const char *kProxyPassword = "proxy_password";
|
||||
const char *kHideWindowsIncompatiblePathNotification = "hide_windows_incompatible_path_notification";
|
||||
const char *kRepoSortOrdersGroup = "repo_sort_orders";
|
||||
|
||||
const int kCheckSystemProxyIntervalMSecs = 5 * 1000;
|
||||
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
QString softwareSeafile()
|
||||
{
|
||||
|
@ -163,6 +164,9 @@ void SettingsManager::loadSettings()
|
|||
|
||||
autoStart_ = get_seafile_auto_start();
|
||||
|
||||
QSettings settings;
|
||||
repo_sort_orders_ = settings.value(kRepoSortOrdersGroup).toInt();
|
||||
|
||||
#ifdef HAVE_FINDER_SYNC_SUPPORT
|
||||
// try to do a reinstall, or we may use findersync somewhere else
|
||||
// this action won't stop findersync if running already
|
||||
|
@ -621,6 +625,19 @@ void SettingsManager::setComputerName(const QString &computerName)
|
|||
seafApplet->rpcClient()->seafileSetConfig("client_name", computerName);
|
||||
}
|
||||
|
||||
void SettingsManager::setRepoSortOrder(int order)
|
||||
{
|
||||
QSettings settings;
|
||||
settings.setValue(kRepoSortOrdersGroup, order);
|
||||
|
||||
repo_sort_orders_ = order;
|
||||
}
|
||||
|
||||
int SettingsManager::repoSortOrder() const
|
||||
{
|
||||
return repo_sort_orders_;
|
||||
}
|
||||
|
||||
#ifdef HAVE_SHIBBOLETH_SUPPORT
|
||||
QString SettingsManager::getLastShibUrl()
|
||||
{
|
||||
|
|
|
@ -99,6 +99,9 @@ public:
|
|||
bool isEnableSyncingWithExistingFolder() const;
|
||||
void setEnableSyncingWithExistingFolder(bool enabled);
|
||||
|
||||
void setRepoSortOrder(int order);
|
||||
int repoSortOrder() const;
|
||||
|
||||
#ifdef HAVE_SHIBBOLETH_SUPPORT
|
||||
QString getLastShibUrl();
|
||||
void setLastShibUrl(const QString& url);
|
||||
|
@ -154,6 +157,7 @@ private:
|
|||
bool verify_http_sync_cert_disabled_;
|
||||
bool shell_ext_enabled_;
|
||||
int delete_confirm_threshold_;
|
||||
int repo_sort_orders_;
|
||||
|
||||
// proxy settings
|
||||
SeafileProxy current_proxy_;
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "api/requests.h"
|
||||
#include "filebrowser/auto-update-mgr.h"
|
||||
#include "repo-service.h"
|
||||
#include "ui/repo-tree-model.h"
|
||||
|
||||
#include "account-view.h"
|
||||
#include "settings-dialog.h"
|
||||
|
@ -66,6 +67,10 @@ AccountView::AccountView(QWidget *parent)
|
|||
// automatically.
|
||||
mRefreshLabel->setPixmap(QIcon(":/images/toolbar/refresh-new.png").pixmap(20));
|
||||
mRefreshLabel->installEventFilter(this);
|
||||
|
||||
setupSortingMenu();
|
||||
mSortPushButton->setMenu(sorting_menu_);
|
||||
|
||||
connect(mSettingsPushButton, &QPushButton::clicked, this, &AccountView::slotShowSettingsDialog);
|
||||
}
|
||||
|
||||
|
@ -373,3 +378,41 @@ void AccountView::slotShowSettingsDialog()
|
|||
seafApplet->settingsDialog()->activateWindow();
|
||||
}
|
||||
|
||||
void AccountView::setupSortingMenu()
|
||||
{
|
||||
sorting_menu_ = new QMenu;
|
||||
|
||||
QAction *title = new QAction(tr("Sort libraries by"));
|
||||
title->setEnabled(false);
|
||||
sorting_menu_->addAction(title);
|
||||
sorting_menu_->addSeparator();
|
||||
|
||||
auto order = seafApplet->settingsManager()->repoSortOrder();
|
||||
QAction *order_by_mtime = new QAction(tr("Modification time"));
|
||||
if (order == RepoTreeModel::SORT_BY_LAST_UPDATED) {
|
||||
order_by_mtime->setIcon(QIcon(":/images/account-checked.png"));
|
||||
} else {
|
||||
order_by_mtime->setIcon(QIcon(":/images/account-else.png"));
|
||||
}
|
||||
sorting_menu_->addAction(order_by_mtime);
|
||||
QAction *order_by_name = new QAction(tr("Library names"));
|
||||
if (order == RepoTreeModel::SORT_BY_NAME) {
|
||||
order_by_name->setIcon(QIcon(":/images/account-checked.png"));
|
||||
} else {
|
||||
order_by_name->setIcon(QIcon(":/images/account-else.png"));
|
||||
}
|
||||
sorting_menu_->addAction(order_by_name);
|
||||
|
||||
connect(order_by_mtime, &QAction::triggered, [=]() {
|
||||
order_by_mtime->setIcon(QIcon(":/images/account-checked.png"));
|
||||
order_by_name->setIcon(QIcon(":/images/account-else.png"));
|
||||
seafApplet->settingsManager()->setRepoSortOrder(RepoTreeModel::SORT_BY_LAST_UPDATED);
|
||||
emit sortOrderUpdated();
|
||||
});
|
||||
connect(order_by_name, &QAction::triggered, [=]() {
|
||||
order_by_mtime->setIcon(QIcon(":/images/account-else.png"));
|
||||
order_by_name->setIcon(QIcon(":/images/account-checked.png"));
|
||||
seafApplet->settingsManager()->setRepoSortOrder(RepoTreeModel::SORT_BY_NAME);
|
||||
emit sortOrderUpdated();
|
||||
});
|
||||
};
|
||||
|
|
|
@ -40,15 +40,18 @@ private:
|
|||
Q_DISABLE_COPY(AccountView)
|
||||
|
||||
QAction *makeAccountAction(const Account& account);
|
||||
void setupSortingMenu();
|
||||
bool eventFilter(QObject *obj, QEvent *event);
|
||||
|
||||
// Account operations
|
||||
QAction *add_account_action_;
|
||||
QAction *account_settings_action_;
|
||||
QMenu *account_menu_;
|
||||
QMenu *sorting_menu_;
|
||||
|
||||
signals:
|
||||
void refresh();
|
||||
void sortOrderUpdated();
|
||||
};
|
||||
|
||||
#endif // SEAFILE_CLIENT_UI_ACCOUNT_VIEW_H
|
||||
|
|
|
@ -166,6 +166,8 @@ void CloudView::createAccountView()
|
|||
// #endif
|
||||
connect(account_view_, SIGNAL(refresh()),
|
||||
this, SLOT(onRefreshClicked()));
|
||||
connect(account_view_, SIGNAL(sortOrderUpdated()),
|
||||
this, SLOT(onSortOrderUpdated()));
|
||||
}
|
||||
|
||||
void CloudView::createTabs()
|
||||
|
@ -462,6 +464,11 @@ void CloudView::onRefreshClicked()
|
|||
}
|
||||
}
|
||||
|
||||
void CloudView::onSortOrderUpdated()
|
||||
{
|
||||
repos_tab_->refresh();
|
||||
}
|
||||
|
||||
void CloudView::resizeEvent(QResizeEvent* event)
|
||||
{
|
||||
if (shouldUseFramelessWindow()) {
|
||||
|
|
|
@ -44,6 +44,7 @@ private slots:
|
|||
void refreshStatusBar();
|
||||
void showServerStatusDialog();
|
||||
void onRefreshClicked();
|
||||
void onSortOrderUpdated();
|
||||
void onMinimizeBtnClicked();
|
||||
void onCloseBtnClicked();
|
||||
void chooseFolderToSync();
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "rpc/rpc-client.h"
|
||||
#include "rpc/clone-task.h"
|
||||
#include "repo-service.h"
|
||||
#include "settings-mgr.h"
|
||||
|
||||
#include "repo-item.h"
|
||||
#include "repo-tree-view.h"
|
||||
|
@ -618,10 +619,20 @@ bool RepoFilterProxyModel::lessThan(const QModelIndex &left,
|
|||
// repos
|
||||
RepoItem *cl = (RepoItem *)item_l;
|
||||
RepoItem *cr = (RepoItem *)item_r;
|
||||
if (cl->repo().mtime != cr->repo().mtime) {
|
||||
return cl->repo().mtime > cr->repo().mtime;
|
||||
int order = seafApplet->settingsManager()->repoSortOrder();
|
||||
|
||||
if (order == RepoTreeModel::SORT_BY_NAME) {
|
||||
if (cl->repo().name != cr->repo().name) {
|
||||
return cl->repo().name < cr->repo().name;
|
||||
} else {
|
||||
return cl->repo().mtime < cr->repo().mtime;
|
||||
}
|
||||
} else {
|
||||
return cl->repo().name > cr->repo().name;
|
||||
if (cl->repo().mtime != cr->repo().mtime) {
|
||||
return cl->repo().mtime > cr->repo().mtime;
|
||||
} else {
|
||||
return cl->repo().name < cr->repo().name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -47,6 +47,11 @@ public:
|
|||
CAT_INDEX_SYNCED_REPOS,
|
||||
};
|
||||
|
||||
enum RepoSortOrders {
|
||||
SORT_BY_LAST_UPDATED = 0,
|
||||
SORT_BY_NAME = 1,
|
||||
};
|
||||
|
||||
RepoTreeModel(QObject *parent=0);
|
||||
~RepoTreeModel();
|
||||
void setRepos(const std::vector<ServerRepo>& repos);
|
||||
|
|
|
@ -14,9 +14,6 @@
|
|||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>15</number>
|
||||
</property>
|
||||
|
@ -95,17 +92,14 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<widget class="QPushButton" name="mSortPushButton">
|
||||
<property name="toolTip">
|
||||
<string>sort</string>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</spacer>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="mRefreshLabel">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue