From 80e21560eb902c4cf7fe845265428ec957ec9d84 Mon Sep 17 00:00:00 2001 From: Dominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com> Date: Sat, 11 Jan 2020 14:57:22 +0100 Subject: [PATCH] More UserLine, avatar fixes Signed-off-by: Dominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com> --- src/gui/CMakeLists.txt | 6 +++--- src/gui/tray/UserLine.qml | 4 +++- src/gui/tray/UserModel.cpp | 19 ++++++++++++++----- src/gui/tray/UserModel.h | 4 ++-- theme.qrc | 2 ++ theme/black/user.svg | 1 + theme/white/user.svg | 1 + 7 files changed, 26 insertions(+), 11 deletions(-) create mode 100644 theme/black/user.svg create mode 100644 theme/white/user.svg diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index af364ca4e..b919758de 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -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} ) diff --git a/src/gui/tray/UserLine.qml b/src/gui/tray/UserLine.qml index aeabdfea5..afccfeb40 100644 --- a/src/gui/tray/UserLine.qml +++ b/src/gui/tray/UserLine.qml @@ -91,11 +91,13 @@ MenuItem { Rectangle { color: userMoreButtonMouseArea.containsMouse ? "grey" : "transparent" opacity: 0.2 + height: userMoreButton.height - 2 + y: userMoreButton.y + 1 } Menu { id: userMoreButtonMenu - width: 100 + width: 120 background: Rectangle { border.color: "#0082c9" diff --git a/src/gui/tray/UserModel.cpp b/src/gui/tray/UserModel.cpp index 1c285d0e1..9c4f4a585 100644 --- a/src/gui/tray/UserModel.cpp +++ b/src/gui/tray/UserModel.cpp @@ -4,6 +4,8 @@ #include #include +#include +#include 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() diff --git a/src/gui/tray/UserModel.h b/src/gui/tray/UserModel.h index fc6f63989..49d9a3abb 100644 --- a/src/gui/tray/UserModel.h +++ b/src/gui/tray/UserModel.h @@ -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 diff --git a/theme.qrc b/theme.qrc index e24188f30..710ef0ff2 100644 --- a/theme.qrc +++ b/theme.qrc @@ -136,5 +136,7 @@ theme/white/talk-app.svg theme/white/caret-down.svg theme/black/caret-down.svg + theme/white/user.svg + theme/black/user.svg diff --git a/theme/black/user.svg b/theme/black/user.svg new file mode 100644 index 000000000..14aef2cd9 --- /dev/null +++ b/theme/black/user.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/theme/white/user.svg b/theme/white/user.svg new file mode 100644 index 000000000..991242ce4 --- /dev/null +++ b/theme/white/user.svg @@ -0,0 +1 @@ + \ No newline at end of file