Skip to content

Commit

Permalink
fix some of the qml issues
Browse files Browse the repository at this point in the history
Signed-off-by: Matthieu Gallien <[email protected]>
  • Loading branch information
mgallien committed Apr 9, 2024
1 parent 6047e55 commit 0ec6797
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 36 deletions.
4 changes: 1 addition & 3 deletions src/gui/owncloudgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ ownCloudGui::ownCloudGui(Application *parent)
this, &ownCloudGui::slotShowSettings);

connect(_tray.data(), &Systray::shutdown,
this, &ownCloudGui::slotShutdown);
this, &QCoreApplication::quit);

ProgressDispatcher *pd = ProgressDispatcher::instance();
connect(pd, &ProgressDispatcher::progressInfo, this,
Expand Down Expand Up @@ -599,13 +599,11 @@ void ownCloudGui::slotShutdown()
{
// explicitly close windows. This is somewhat of a hack to ensure
// that saving the geometries happens ASAP during a OS shutdown

// those do delete on close
if (!_settingsDialog.isNull())
_settingsDialog->close();
if (!_logBrowser.isNull())
_logBrowser->deleteLater();
_app->quit();
}

void ownCloudGui::slotToggleLogBrowser()
Expand Down
2 changes: 2 additions & 0 deletions src/gui/systray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ void Systray::create()
if (_trayEngine) {
if (!AccountManager::instance()->accounts().isEmpty()) {

Check warning on line 116 in src/gui/systray.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/systray.cpp:116:9 [bugprone-branch-clone]

if with identical then and else branches
_trayEngine->rootContext()->setContextProperty("activityModel", UserModel::instance()->currentActivityModel());
} else {
_trayEngine->rootContext()->setContextProperty("activityModel", &_fakeActivityModel);
}

QQmlComponent trayWindowComponent(trayEngine(), QStringLiteral("qrc:/qml/src/gui/tray/Window.qml"));
Expand Down
6 changes: 4 additions & 2 deletions src/gui/systray.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
#ifndef SYSTRAY_H
#define SYSTRAY_H

#include <QSystemTrayIcon>

#include "accountmanager.h"
#include "tray/usermodel.h"

#include <QSystemTrayIcon>
#include <QQmlNetworkAccessManagerFactory>
#include <QStringListModel>

class QScreen;
class QQmlApplicationEngine;
Expand Down Expand Up @@ -188,6 +188,8 @@ private slots:
QSet<qlonglong> _callsAlreadyNotified;
QPointer<QObject> _editFileLocallyLoadingDialog;
QVector<QQuickWindow*> _fileDetailDialogs;

QStringListModel _fakeActivityModel;
};

} // namespace OCC
Expand Down
57 changes: 26 additions & 31 deletions src/gui/tray/Window.qml
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ ApplicationWindow {
Layout.leftMargin: Style.trayHorizontalMargin
verticalAlignment: Qt.AlignCenter
cache: false
source: UserModel.currentUser.avatar != "" ? UserModel.currentUser.avatar : "image://avatars/fallbackWhite"
source: (UserModel.currentUser && UserModel.currentUser.avatar !== "") ? UserModel.currentUser.avatar : "image://avatars/fallbackWhite"
Layout.preferredHeight: Style.accountAvatarSize
Layout.preferredWidth: Style.accountAvatarSize

Expand All @@ -494,7 +494,7 @@ ApplicationWindow {

Rectangle {
id: currentAccountStatusIndicatorBackground
visible: UserModel.currentUser.isConnected
visible: UserModel.currentUser && UserModel.currentUser.isConnected
&& UserModel.currentUser.serverHasUserStatus
width: Style.accountAvatarStateIndicatorSize + + Style.trayFolderStatusIndicatorSizeOffset
height: width
Expand All @@ -506,7 +506,7 @@ ApplicationWindow {

Rectangle {
id: currentAccountStatusIndicatorMouseHover
visible: UserModel.currentUser.isConnected
visible: UserModel.currentUser && UserModel.currentUser.isConnected
&& UserModel.currentUser.serverHasUserStatus
width: Style.accountAvatarStateIndicatorSize + + Style.trayFolderStatusIndicatorSizeOffset
height: width
Expand All @@ -519,9 +519,9 @@ ApplicationWindow {

Image {
id: currentAccountStatusIndicator
visible: UserModel.currentUser.isConnected
visible: UserModel.currentUser && UserModel.currentUser.isConnected
&& UserModel.currentUser.serverHasUserStatus
source: UserModel.currentUser.statusIcon
source: UserModel.currentUser ? UserModel.currentUser.statusIcon : ""
cache: false
x: currentAccountStatusIndicatorBackground.x + 1
y: currentAccountStatusIndicatorBackground.y + 1
Expand All @@ -545,7 +545,7 @@ ApplicationWindow {
id: currentAccountUser
Layout.alignment: Qt.AlignLeft | Qt.AlignBottom
width: Style.currentAccountLabelWidth
text: UserModel.currentUser.name
text: UserModel.currentUser ? UserModel.currentUser.name : ""
elide: Text.ElideRight
color: Style.currentUserHeaderTextColor

Expand All @@ -557,34 +557,34 @@ ApplicationWindow {
id: currentAccountServer
Layout.alignment: Qt.AlignLeft | Qt.AlignBottom
width: Style.currentAccountLabelWidth
text: UserModel.currentUser.server
text: UserModel.currentUser ? UserModel.currentUser.server : ""
elide: Text.ElideRight
color: Style.currentUserHeaderTextColor
visible: UserModel.numUsers() > 1
}

RowLayout {
id: currentUserStatus
visible: UserModel.currentUser.isConnected &&
visible: UserModel.currentUser && UserModel.currentUser.isConnected &&
UserModel.currentUser.serverHasUserStatus
spacing: Style.accountLabelsSpacing
width: parent.width

EnforcedPlainTextLabel {
id: emoji
visible: UserModel.currentUser.statusEmoji !== ""
visible: UserModel.currentUser && UserModel.currentUser.statusEmoji !== ""
width: Style.userStatusEmojiSize
text: UserModel.currentUser.statusEmoji
text: UserModel.currentUser ? UserModel.currentUser.statusEmoji : ""
}
EnforcedPlainTextLabel {
id: message
Layout.alignment: Qt.AlignLeft | Qt.AlignBottom
Layout.fillWidth: true
visible: UserModel.currentUser.statusMessage !== ""
visible: UserModel.currentUser && UserModel.currentUser.statusMessage !== ""
width: Style.currentAccountLabelWidth
text: UserModel.currentUser.statusMessage !== ""
text: UserModel.currentUser && UserModel.currentUser.statusMessage !== ""
? UserModel.currentUser.statusMessage
: UserModel.currentUser.server
: UserModel.currentUser ? UserModel.currentUser.server : ""
elide: Text.ElideRight
color: Style.currentUserHeaderTextColor
font.pixelSize: Style.subLinePixelSize
Expand Down Expand Up @@ -639,7 +639,7 @@ ApplicationWindow {
HeaderButton {
id: trayWindowTalkButton

visible: UserModel.currentUser.serverHasTalk
visible: UserModel.currentUser && UserModel.currentUser.serverHasTalk
icon.source: "qrc:///client/theme/white/talk-app.svg"
icon.color: Style.currentUserHeaderTextColor
onClicked: UserModel.openCurrentAccountTalk()
Expand Down Expand Up @@ -736,21 +736,17 @@ ApplicationWindow {

UnifiedSearchInputContainer {
id: trayWindowUnifiedSearchInputContainer
height: Style.unifiedSearchInputContainerHeight +
topInset +
bottomInset +
bottomUnifiedSearchInputSeparator.height
height: Style.trayWindowHeaderHeight * 0.65

anchors.top: trayWindowHeaderBackground.bottom
anchors.left: trayWindowMainItem.left
anchors.right: trayWindowMainItem.right
anchors {
top: trayWindowHeaderBackground.bottom
left: trayWindowMainItem.left
right: trayWindowMainItem.right

topInset: Style.trayHorizontalMargin + controlRoot.padding
leftInset: Style.trayHorizontalMargin + controlRoot.padding
rightInset: Style.trayHorizontalMargin + controlRoot.padding
bottomInset: bottomUnifiedSearchInputSeparator.visible ?
Style.trayHorizontalMargin + controlRoot.padding + bottomUnifiedSearchInputSeparator.height :
0
topMargin: Style.trayHorizontalMargin + controlRoot.padding
leftMargin: Style.trayHorizontalMargin + controlRoot.padding
rightMargin: Style.trayHorizontalMargin + controlRoot.padding
}

text: UserModel.currentUser.unifiedSearchResultsListModel.searchTerm
readOnly: !UserModel.currentUser.isConnected || UserModel.currentUser.unifiedSearchResultsListModel.currentFetchMoreInProgressProviderId
Expand Down Expand Up @@ -880,9 +876,8 @@ ApplicationWindow {
Rectangle {
id: syncStatusSeparator

anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
Layout.fillWidth: true
Layout.preferredHeight: 1

height: 1
color: Style.menuBorder
Expand Down Expand Up @@ -966,7 +961,7 @@ ApplicationWindow {
}
Connections {
target: activityModel
onInteractiveActivityReceived: {
function onInteractiveActivityReceived() {
if (!activityList.atYBeginning) {
newActivitiesButtonLoader.active = true;
}
Expand Down

0 comments on commit 0ec6797

Please sign in to comment.