More UserLine, avatar fixes
authorDominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
Sat, 11 Jan 2020 13:57:22 +0000 (14:57 +0100)
committerDominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
Sat, 11 Jan 2020 13:57:22 +0000 (14:57 +0100)
Signed-off-by: Dominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
src/gui/CMakeLists.txt
src/gui/tray/UserLine.qml
src/gui/tray/UserModel.cpp
src/gui/tray/UserModel.h
theme.qrc
theme/black/user.svg [new file with mode: 0644]
theme/white/user.svg [new file with mode: 0644]

index af364ca4ed3d29a51711de6421026db6895be90d..b919758deb4d121c63e709721d51e31e34ed703b 100644 (file)
@@ -1,5 +1,5 @@
 project(gui)
-find_package(Qt5 REQUIRED COMPONENTS Widgets)
+find_package(Qt5 REQUIRED COMPONENTS Widgets Svg)
 set(CMAKE_AUTOMOC TRUE)
 set(CMAKE_AUTOUIC TRUE)
 set(CMAKE_AUTORCC TRUE)
@@ -297,7 +297,7 @@ else()
 endif()
 
 add_library(updater STATIC ${updater_SRCS})
-target_link_libraries(updater ${synclib_NAME} Qt5::Widgets Qt5::Network Qt5::Xml Qt5::WebEngineWidgets)
+target_link_libraries(updater ${synclib_NAME} Qt5::Widgets Qt5::Svg Qt5::Network Qt5::Xml Qt5::WebEngineWidgets)
 target_include_directories(updater PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
 
 set_target_properties( ${APPLICATION_EXECUTABLE} PROPERTIES
@@ -307,7 +307,7 @@ set_target_properties( ${APPLICATION_EXECUTABLE} PROPERTIES
 set_target_properties( ${APPLICATION_EXECUTABLE} PROPERTIES
         INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/${APPLICATION_EXECUTABLE};${CMAKE_INSTALL_RPATH}" )
 
-target_link_libraries( ${APPLICATION_EXECUTABLE} Qt5::Widgets Qt5::Network Qt5::Xml)
+target_link_libraries( ${APPLICATION_EXECUTABLE} Qt5::Widgets Qt5::Svg Qt5::Network Qt5::Xml)
 target_link_libraries( ${APPLICATION_EXECUTABLE} ${synclib_NAME} )
 target_link_libraries( ${APPLICATION_EXECUTABLE} updater )
 target_link_libraries( ${APPLICATION_EXECUTABLE} ${OS_SPECIFIC_LINK_LIBRARIES} )
index aeabdfea5f935b7e1e705eb48627b8d6b0fdcf04..afccfeb402684d06f54429d6b8c28be24c7cf7cc 100644 (file)
@@ -91,11 +91,13 @@ MenuItem {
                     Rectangle {\r
                     color: userMoreButtonMouseArea.containsMouse ? "grey" : "transparent"\r
                     opacity: 0.2\r
+                    height: userMoreButton.height - 2\r
+                    y: userMoreButton.y + 1\r
                 }\r
 \r
                 Menu {\r
                     id: userMoreButtonMenu\r
-                    width: 100\r
+                    width: 120\r
 \r
                     background: Rectangle {\r
                         border.color: "#0082c9"\r
index 1c285d0e10e6f90e4446c0df4bec5470fa3762df..9c4f4a58515c0beddf82e6b982c655e3ece7db08 100644 (file)
@@ -4,6 +4,8 @@
 
 #include <QDesktopServices>
 #include <QIcon>
+#include <QSvgRenderer>
+#include <QPainter>
 
 namespace OCC {
 
@@ -73,18 +75,25 @@ QString User::server(bool shortened) const
     return serverUrl;
 }
 
-QImage User::avatar() const
+QImage User::avatar(bool whiteBg) const
 {
     QImage img = AvatarJob::makeCircularAvatar(_account->account()->avatar());
     if (img.isNull()) {
-        img = AvatarJob::makeCircularAvatar(QImage(":/client/resources/account.png"));
+        QImage image(128, 128, QImage::Format_ARGB32);
+        image.fill(Qt::GlobalColor::transparent);
+        QPainter painter(&image);
+
+        QSvgRenderer renderer(QString(whiteBg ? ":/client/theme/black/user.svg" : ":/client/theme/white/user.svg"));
+        renderer.render(&painter);
+
+        return image;
+    } else {
+        return img;
     }
-    return img;
 }
 
 bool User::serverHasTalk() const
 {
-    auto test = _account->hasTalk();
     return _account->hasTalk();
 }
 
@@ -152,7 +161,7 @@ Q_INVOKABLE QImage UserModel::currentUserAvatar()
 
 QImage UserModel::avatarById(const int &id)
 {
-    return _users[id].avatar();
+    return _users[id].avatar(true);
 }
 
 Q_INVOKABLE QString UserModel::currentUserName()
index fc6f63989498634c96108c4b37f79e513d13a270..49d9a3abb7546f2588e468b96b14c957f13538d2 100644 (file)
@@ -29,7 +29,7 @@ public:
     QString server(bool shortened = true) const;
     bool serverHasTalk() const;
     bool hasActivities() const;
-    QImage avatar() const;
+    QImage avatar(bool whiteBg = false) const;
     QString id() const;
     void login() const;
     void logout() const;
@@ -106,4 +106,4 @@ public:
 };
 
 }
-#endif // USERMODEL_H
\ No newline at end of file
+#endif // USERMODEL_H
index e24188f3090e0a70aa8abaf18cb4aef365f58884..710ef0ff2a15ccc3cd1bdde19d679c1bc04c68e1 100644 (file)
--- a/theme.qrc
+++ b/theme.qrc
         <file>theme/white/talk-app.svg</file>
         <file>theme/white/caret-down.svg</file>
         <file>theme/black/caret-down.svg</file>
+        <file>theme/white/user.svg</file>
+        <file>theme/black/user.svg</file>
     </qresource>
 </RCC>
diff --git a/theme/black/user.svg b/theme/black/user.svg
new file mode 100644 (file)
index 0000000..14aef2c
--- /dev/null
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 16 16" height="16" width="16" version="1.1"><path d="m5 3.8c0 1.4 0.1 2.4 0.8 3.5 0.2 0.286 0.5 0.35 0.7 0.6 0.135 0.5 0.24 0.98 0.1 1.5-1.275 0.45-2.49 1-3.6 1.6-0.85 0.6-0.785 0.31-1 2.3-0.16 1.59 3.5 1.7 6 1.7s6.163-0.1 6-1.7c-0.215-2-0.23-1.71-1-2.3-1.1-0.654-2.45-1.167-3.6-1.6-0.15-0.56-0.04-0.973 0.1-1.5 0.235-0.25 0.5-0.363 0.7-0.6 0.69-0.885 0.8-2.425 0.8-3.5 0-1.59-1.43-2.8-3-2.8-1.75 0-3 1.43-3 2.8z" fill="#000"/></svg>
\ No newline at end of file
diff --git a/theme/white/user.svg b/theme/white/user.svg
new file mode 100644 (file)
index 0000000..991242c
--- /dev/null
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 16 16" height="16" width="16" version="1.1"><path d="m5 3.8c0 1.4 0.1 2.4 0.8 3.5 0.2 0.286 0.5 0.35 0.7 0.6 0.135 0.5 0.24 0.98 0.1 1.5-1.275 0.45-2.49 1-3.6 1.6-0.85 0.6-0.785 0.31-1 2.3-0.16 1.59 3.5 1.7 6 1.7s6.163-0.1 6-1.7c-0.215-2-0.23-1.71-1-2.3-1.1-0.654-2.45-1.167-3.6-1.6-0.15-0.56-0.04-0.973 0.1-1.5 0.235-0.25 0.5-0.363 0.7-0.6 0.69-0.885 0.8-2.425 0.8-3.5 0-1.59-1.43-2.8-3-2.8-1.75 0-3 1.43-3 2.8z" fill="#fff"/></svg>
\ No newline at end of file