mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-28 03:49:20 +03:00
Minor improvements
Signed-off-by: Dominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
This commit is contained in:
parent
1ebcd3a0fb
commit
96a74d9ef0
3 changed files with 94 additions and 58 deletions
|
@ -42,7 +42,9 @@ ActivityListModel::ActivityListModel(AccountState *accountState, QObject* parent
|
||||||
QHash<int, QByteArray> ActivityListModel::roleNames() const
|
QHash<int, QByteArray> ActivityListModel::roleNames() const
|
||||||
{
|
{
|
||||||
QHash<int, QByteArray> roles;
|
QHash<int, QByteArray> roles;
|
||||||
|
roles[DisplayPathRole] = "displaypath";
|
||||||
roles[PathRole] = "path";
|
roles[PathRole] = "path";
|
||||||
|
roles[LinkRole] = "link";
|
||||||
roles[MessageRole] = "message";
|
roles[MessageRole] = "message";
|
||||||
roles[ActionRole] = "type";
|
roles[ActionRole] = "type";
|
||||||
roles[ActionIconRole] = "icon";
|
roles[ActionIconRole] = "icon";
|
||||||
|
@ -65,11 +67,25 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const
|
||||||
QStringList list;
|
QStringList list;
|
||||||
|
|
||||||
switch (role) {
|
switch (role) {
|
||||||
|
case DisplayPathRole:
|
||||||
|
if (!a._file.isEmpty()) {
|
||||||
|
auto folder = FolderMan::instance()->folder(a._folder);
|
||||||
|
QString relPath(a._file);
|
||||||
|
if (folder) {
|
||||||
|
relPath.prepend(folder->remotePath());
|
||||||
|
}
|
||||||
|
list = FolderMan::instance()->findFileInLocalFolders(relPath, ast->account());
|
||||||
|
if (list.count() > 0) {
|
||||||
|
return list.at(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return QString();
|
||||||
case PathRole:
|
case PathRole:
|
||||||
if (!a._file.isEmpty()) {
|
if (!a._file.isEmpty()) {
|
||||||
auto folder = FolderMan::instance()->folder(a._folder);
|
auto folder = FolderMan::instance()->folder(a._folder);
|
||||||
QString relPath(a._file);
|
QString relPath(a._file);
|
||||||
if(folder) relPath.prepend(folder->remotePath());
|
if (folder)
|
||||||
|
relPath.prepend(folder->remotePath());
|
||||||
list = FolderMan::instance()->findFileInLocalFolders(relPath, ast->account());
|
list = FolderMan::instance()->findFileInLocalFolders(relPath, ast->account());
|
||||||
if (list.count() > 0) {
|
if (list.count() > 0) {
|
||||||
QString path = "file:///" + QString(list.at(0));
|
QString path = "file:///" + QString(list.at(0));
|
||||||
|
@ -141,8 +157,13 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const
|
||||||
return QString("No description available.");
|
return QString("No description available.");
|
||||||
}
|
}
|
||||||
return a._message;
|
return a._message;
|
||||||
case LinkRole:
|
case LinkRole: {
|
||||||
|
if (a._link.isEmpty()) {
|
||||||
|
return "";
|
||||||
|
} else {
|
||||||
return a._link;
|
return a._link;
|
||||||
|
}
|
||||||
|
}
|
||||||
case AccountRole:
|
case AccountRole:
|
||||||
return a._accName;
|
return a._accName;
|
||||||
case PointInTimeRole:
|
case PointInTimeRole:
|
||||||
|
@ -231,13 +252,15 @@ void ActivityListModel::slotActivitiesReceived(const QJsonDocument &json, int st
|
||||||
combineActivityLists();
|
combineActivityLists();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActivityListModel::addErrorToActivityList(Activity activity) {
|
void ActivityListModel::addErrorToActivityList(Activity activity)
|
||||||
|
{
|
||||||
qCInfo(lcActivity) << "Error successfully added to the notification list: " << activity._subject;
|
qCInfo(lcActivity) << "Error successfully added to the notification list: " << activity._subject;
|
||||||
_notificationErrorsLists.prepend(activity);
|
_notificationErrorsLists.prepend(activity);
|
||||||
combineActivityLists();
|
combineActivityLists();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActivityListModel::addIgnoredFileToList(Activity newActivity) {
|
void ActivityListModel::addIgnoredFileToList(Activity newActivity)
|
||||||
|
{
|
||||||
qCInfo(lcActivity) << "First checking for duplicates then add file to the notification list of ignored files: " << newActivity._file;
|
qCInfo(lcActivity) << "First checking for duplicates then add file to the notification list of ignored files: " << newActivity._file;
|
||||||
|
|
||||||
bool duplicate = false;
|
bool duplicate = false;
|
||||||
|
@ -260,44 +283,52 @@ void ActivityListModel::addIgnoredFileToList(Activity newActivity) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActivityListModel::addNotificationToActivityList(Activity activity) {
|
void ActivityListModel::addNotificationToActivityList(Activity activity)
|
||||||
|
{
|
||||||
qCInfo(lcActivity) << "Notification successfully added to the notification list: " << activity._subject;
|
qCInfo(lcActivity) << "Notification successfully added to the notification list: " << activity._subject;
|
||||||
_notificationLists.prepend(activity);
|
_notificationLists.prepend(activity);
|
||||||
combineActivityLists();
|
combineActivityLists();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActivityListModel::clearNotifications() {
|
void ActivityListModel::clearNotifications()
|
||||||
|
{
|
||||||
qCInfo(lcActivity) << "Clear the notifications";
|
qCInfo(lcActivity) << "Clear the notifications";
|
||||||
_notificationLists.clear();
|
_notificationLists.clear();
|
||||||
combineActivityLists();
|
combineActivityLists();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActivityListModel::removeActivityFromActivityList(int row) {
|
void ActivityListModel::removeActivityFromActivityList(int row)
|
||||||
|
{
|
||||||
Activity activity = _finalList.at(row);
|
Activity activity = _finalList.at(row);
|
||||||
removeActivityFromActivityList(activity);
|
removeActivityFromActivityList(activity);
|
||||||
combineActivityLists();
|
combineActivityLists();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActivityListModel::addSyncFileItemToActivityList(Activity activity) {
|
void ActivityListModel::addSyncFileItemToActivityList(Activity activity)
|
||||||
|
{
|
||||||
qCInfo(lcActivity) << "Successfully added to the activity list: " << activity._subject;
|
qCInfo(lcActivity) << "Successfully added to the activity list: " << activity._subject;
|
||||||
_syncFileItemLists.prepend(activity);
|
_syncFileItemLists.prepend(activity);
|
||||||
combineActivityLists();
|
combineActivityLists();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActivityListModel::removeActivityFromActivityList(Activity activity) {
|
void ActivityListModel::removeActivityFromActivityList(Activity activity)
|
||||||
|
{
|
||||||
qCInfo(lcActivity) << "Activity/Notification/Error successfully dismissed: " << activity._subject;
|
qCInfo(lcActivity) << "Activity/Notification/Error successfully dismissed: " << activity._subject;
|
||||||
qCInfo(lcActivity) << "Trying to remove Activity/Notification/Error from view... ";
|
qCInfo(lcActivity) << "Trying to remove Activity/Notification/Error from view... ";
|
||||||
|
|
||||||
int index = -1;
|
int index = -1;
|
||||||
if (activity._type == Activity::ActivityType) {
|
if (activity._type == Activity::ActivityType) {
|
||||||
index = _activityLists.indexOf(activity);
|
index = _activityLists.indexOf(activity);
|
||||||
if(index != -1) _activityLists.removeAt(index);
|
if (index != -1)
|
||||||
|
_activityLists.removeAt(index);
|
||||||
} else if (activity._type == Activity::NotificationType) {
|
} else if (activity._type == Activity::NotificationType) {
|
||||||
index = _notificationLists.indexOf(activity);
|
index = _notificationLists.indexOf(activity);
|
||||||
if(index != -1) _notificationLists.removeAt(index);
|
if (index != -1)
|
||||||
|
_notificationLists.removeAt(index);
|
||||||
} else {
|
} else {
|
||||||
index = _notificationErrorsLists.indexOf(activity);
|
index = _notificationErrorsLists.indexOf(activity);
|
||||||
if(index != -1) _notificationErrorsLists.removeAt(index);
|
if (index != -1)
|
||||||
|
_notificationErrorsLists.removeAt(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
|
@ -342,7 +373,8 @@ void ActivityListModel::combineActivityLists()
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ActivityListModel::canFetchActivities() const {
|
bool ActivityListModel::canFetchActivities() const
|
||||||
|
{
|
||||||
return _accountState->isConnected() && _accountState->account()->capabilities().hasActivities();
|
return _accountState->isConnected() && _accountState->account()->capabilities().hasActivities();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@ public:
|
||||||
ActionTextRole,
|
ActionTextRole,
|
||||||
ActionRole,
|
ActionRole,
|
||||||
MessageRole,
|
MessageRole,
|
||||||
|
DisplayPathRole,
|
||||||
PathRole,
|
PathRole,
|
||||||
LinkRole,
|
LinkRole,
|
||||||
PointInTimeRole,
|
PointInTimeRole,
|
||||||
|
|
|
@ -61,7 +61,6 @@ Window {
|
||||||
trayWindow.setX( systrayBackend.calcTrayWindowX());
|
trayWindow.setX( systrayBackend.calcTrayWindowX());
|
||||||
trayWindow.setY( systrayBackend.calcTrayWindowY());
|
trayWindow.setY( systrayBackend.calcTrayWindowY());
|
||||||
systrayBackend.setOpened();
|
systrayBackend.setOpened();
|
||||||
userModelBackend.fetchCurrentActivityModel();
|
|
||||||
}
|
}
|
||||||
onHideWindow: {
|
onHideWindow: {
|
||||||
trayWindow.hide();
|
trayWindow.hide();
|
||||||
|
@ -470,7 +469,7 @@ Window {
|
||||||
}
|
}
|
||||||
Column {
|
Column {
|
||||||
id: activityTextColumn
|
id: activityTextColumn
|
||||||
Layout.leftMargin: 6
|
Layout.leftMargin: 4
|
||||||
spacing: 4
|
spacing: 4
|
||||||
Layout.alignment: Qt.AlignLeft
|
Layout.alignment: Qt.AlignLeft
|
||||||
Text {
|
Text {
|
||||||
|
@ -482,7 +481,7 @@ Window {
|
||||||
}
|
}
|
||||||
Text {
|
Text {
|
||||||
id: activityTextInfo
|
id: activityTextInfo
|
||||||
text: path
|
text: displaypath
|
||||||
width: 220
|
width: 220
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
font.pointSize: 8
|
font.pointSize: 8
|
||||||
|
@ -499,13 +498,12 @@ Window {
|
||||||
Layout.alignment: Qt.AlignRight
|
Layout.alignment: Qt.AlignRight
|
||||||
flat: true
|
flat: true
|
||||||
hoverEnabled: false
|
hoverEnabled: false
|
||||||
visible: (path === "") ? false : true
|
visible: (path !== "") ? true : false
|
||||||
display: AbstractButton.IconOnly
|
display: AbstractButton.IconOnly
|
||||||
icon.source: "qrc:///client/resources/files.svg"
|
icon.source: "qrc:///client/resources/files.svg"
|
||||||
icon.color: "transparent"
|
icon.color: "transparent"
|
||||||
|
|
||||||
onClicked:
|
onClicked: {
|
||||||
{
|
|
||||||
Qt.openUrlExternally(path)
|
Qt.openUrlExternally(path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -515,14 +513,19 @@ Window {
|
||||||
Layout.alignment: Qt.AlignRight
|
Layout.alignment: Qt.AlignRight
|
||||||
flat: true
|
flat: true
|
||||||
hoverEnabled: false
|
hoverEnabled: false
|
||||||
|
visible: (link !== "") ? true : false
|
||||||
display: AbstractButton.IconOnly
|
display: AbstractButton.IconOnly
|
||||||
icon.source: "qrc:///client/resources/public.svg"
|
icon.source: "qrc:///client/resources/public.svg"
|
||||||
icon.color: "transparent"
|
icon.color: "transparent"
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
Qt.openUrlExternally(link)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
populate: Transition {
|
populate: Transition {
|
||||||
NumberAnimation { properties: "y"; from: -60; duration: 100; easing.type: Easing.Linear }
|
// prevent animations on initial list population
|
||||||
}
|
}
|
||||||
|
|
||||||
add: Transition {
|
add: Transition {
|
||||||
|
|
Loading…
Reference in a new issue