From 41bb83054ca3914c900b1940f2cf11d1d0254384 Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 1 Jan 2025 20:17:49 +0100 Subject: [PATCH 01/84] removed unencrypted FT --- .../src/gui/settings/TransferPage.cpp | 6 ++++- .../src/gui/settings/TransferPage.h | 1 - .../src/gui/settings/TransferPage.ui | 24 ------------------- 3 files changed, 5 insertions(+), 26 deletions(-) diff --git a/retroshare-gui/src/gui/settings/TransferPage.cpp b/retroshare-gui/src/gui/settings/TransferPage.cpp index 6a0feaf2b..5b3b49908 100644 --- a/retroshare-gui/src/gui/settings/TransferPage.cpp +++ b/retroshare-gui/src/gui/settings/TransferPage.cpp @@ -52,7 +52,7 @@ TransferPage::TransferPage(QWidget * parent, Qt::WindowFlags flags) QObject::connect(ui._queueSize_SB,SIGNAL(valueChanged(int)),this,SLOT(updateQueueSize(int))) ; QObject::connect(ui._max_up_SB,SIGNAL(valueChanged(int)),this,SLOT(updateMaxUploadSlots(int))) ; QObject::connect(ui._defaultStrategy_CB,SIGNAL(activated(int)),this,SLOT(updateDefaultStrategy(int))) ; - QObject::connect(ui._e2e_encryption_CB,SIGNAL(activated(int)),this,SLOT(updateEncryptionPolicy(int))) ; + //QObject::connect(ui._e2e_encryption_CB,SIGNAL(activated(int)),this,SLOT(updateEncryptionPolicy(int))) ; QObject::connect(ui._diskSpaceLimit_SB,SIGNAL(valueChanged(int)),this,SLOT(updateDiskSizeLimit(int))) ; QObject::connect(ui._max_tr_up_per_sec_SB, SIGNAL( valueChanged( int ) ), this, SLOT( updateMaxTRUpRate(int) ) ); QObject::connect(ui._filePermDirectDL_CB,SIGNAL(activated(int)),this,SLOT(updateFilePermDirectDL(int))); @@ -112,6 +112,7 @@ void TransferPage::updateMaxUploadSlots(int b) rsFiles->setMaxUploadSlotsPerFriend(b) ; } +#ifdef TO_REMOVE void TransferPage::updateEncryptionPolicy(int b) { switch(b) @@ -123,6 +124,7 @@ void TransferPage::updateEncryptionPolicy(int b) break ; } } +#endif void TransferPage::updateFilePermDirectDL(int i) { @@ -160,11 +162,13 @@ void TransferPage::load() case FileChunksInfo::CHUNK_STRATEGY_RANDOM: whileBlocking(ui._defaultStrategy_CB)->setCurrentIndex(2) ; break ; } +#ifdef TO_REMOVE switch(rsFiles->defaultEncryptionPolicy()) { case RS_FILE_CTRL_ENCRYPTION_POLICY_PERMISSIVE: whileBlocking(ui._e2e_encryption_CB)->setCurrentIndex(0) ; break ; case RS_FILE_CTRL_ENCRYPTION_POLICY_STRICT : whileBlocking(ui._e2e_encryption_CB)->setCurrentIndex(1) ; break ; } +#endif whileBlocking(ui._diskSpaceLimit_SB)->setValue(rsFiles->freeDiskSpaceLimit()) ; whileBlocking(ui._max_tr_up_per_sec_SB)->setValue(rsTurtle->getMaxTRForwardRate()) ; diff --git a/retroshare-gui/src/gui/settings/TransferPage.h b/retroshare-gui/src/gui/settings/TransferPage.h index a2a0a1061..077d5a6ec 100644 --- a/retroshare-gui/src/gui/settings/TransferPage.h +++ b/retroshare-gui/src/gui/settings/TransferPage.h @@ -47,7 +47,6 @@ class TransferPage: public ConfigPage void updateDefaultStrategy(int) ; void updateDiskSizeLimit(int) ; void updateMaxTRUpRate(int); - void updateEncryptionPolicy(int); void updateMaxUploadSlots(int); void updateFilePermDirectDL(int); void updateIgnoreLists(); diff --git a/retroshare-gui/src/gui/settings/TransferPage.ui b/retroshare-gui/src/gui/settings/TransferPage.ui index b6d8cd7ff..e77ee1742 100644 --- a/retroshare-gui/src/gui/settings/TransferPage.ui +++ b/retroshare-gui/src/gui/settings/TransferPage.ui @@ -400,13 +400,6 @@ p, li { white-space: pre-wrap; } - - - - End-to-end encryption: - - - @@ -503,23 +496,6 @@ p, li { white-space: pre-wrap; } - - - - <html><head/><body><p>Anonymous tunnels can be end-o-end encrypted. In order to maintain backward compatibility, this can be made optional (choosing &quot;Accepted&quot;), but in the end, all Retroshare nodes will be switched to &quot;Enforced&quot;, meaning that all anonymous transfers will be end-to-end encrypted. With &quot;Accepted&quot;, it is likely that you will transfer using twice as many tunnels, since there is no way to know that an encrypted and a clear tunnel actually transfer from the same source.</p></body></html> - - - - Accepted - - - - - Enforced - - - - From 89ceba2f924b37c253be3bbeaec89700af382aee Mon Sep 17 00:00:00 2001 From: defnax Date: Thu, 2 Jan 2025 23:36:43 +0100 Subject: [PATCH 02/84] Fixed some frames to use StyledPanel to get styles on system theme * update mac os section --- .../gui/Posted/PostedListWidgetWithModel.ui | 64 +++++++++---------- .../GxsChannelPostsWidgetWithModel.ui | 6 +- .../src/gui/gxsforums/GxsForumThreadWidget.ui | 28 ++++---- retroshare.pri | 5 +- 4 files changed, 53 insertions(+), 50 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui index 8074388dc..734c4a233 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui @@ -54,7 +54,7 @@ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> +</style></head><body style=" font-family:'.AppleSystemUIFont'; font-size:13pt; font-weight:400; font-style:normal;"> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:8pt;">Description</span></p></body></html> @@ -355,10 +355,10 @@ p, li { white-space: pre-wrap; } - QFrame::Box + QFrame::StyledPanel - QFrame::Sunken + QFrame::Raised @@ -576,37 +576,10 @@ p, li { white-space: pre-wrap; } - - ElidedLabel - QLabel -
gui/common/ElidedLabel.h
- 1 -
- - GxsIdChooser - QComboBox -
gui/gxs/GxsIdChooser.h
-
- - GxsIdLabel - QLabel -
gui/gxs/GxsIdLabel.h
-
LineEditClear QLineEdit -
gui/common/LineEditClear.h
-
- - RSComboBox - QComboBox -
gui/common/RSComboBox.h
-
- - RSTabWidget - QTabWidget -
gui/common/RSTabWidget.h
- 1 +
gui/common/LineEditClear.h
RSTreeView @@ -614,15 +587,42 @@ p, li { white-space: pre-wrap; }
gui/common/RSTreeView.h
1
+ + GxsIdLabel + QLabel +
gui/gxs/GxsIdLabel.h
+
+ + ElidedLabel + QLabel +
gui/common/ElidedLabel.h
+ 1 +
SubscribeToolButton QToolButton
gui/common/SubscribeToolButton.h
+ + RSComboBox + QComboBox +
gui/common/RSComboBox.h
+
+ + GxsIdChooser + QComboBox +
gui/gxs/GxsIdChooser.h
+
+ + RSTabWidget + QTabWidget +
gui/common/RSTabWidget.h
+ 1 +
- + diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui index 6bd0fb86b..2740b4654 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui @@ -29,10 +29,10 @@ - QFrame::Box + QFrame::StyledPanel - QFrame::Sunken + QFrame::Raised @@ -402,7 +402,7 @@ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> +</style></head><body style=" font-family:'.AppleSystemUIFont'; font-size:13pt; font-weight:400; font-style:normal;"> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:8pt;">Description</span></p></body></html> diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.ui b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.ui index 5a9c51e93..439234047 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.ui +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.ui @@ -48,10 +48,10 @@ - QFrame::Box + QFrame::StyledPanel - QFrame::Sunken + QFrame::Raised @@ -578,10 +578,9 @@ - ElidedLabel - QLabel -
gui/common/ElidedLabel.h
- 1 + LineEditClear + QLineEdit +
gui/common/LineEditClear.h
GxsIdLabel @@ -589,9 +588,15 @@
gui/gxs/GxsIdLabel.h
- LineEditClear - QLineEdit -
gui/common/LineEditClear.h
+ ElidedLabel + QLabel +
gui/common/ElidedLabel.h
+ 1 +
+ + SubscribeToolButton + QToolButton +
gui/common/SubscribeToolButton.h
RSImageBlockWidget @@ -609,11 +614,6 @@ QComboBox
gui/common/RSComboBox.h
- - SubscribeToolButton - QToolButton -
gui/common/SubscribeToolButton.h
-
diff --git a/retroshare.pri b/retroshare.pri index 22bf11d3f..203c320b3 100644 --- a/retroshare.pri +++ b/retroshare.pri @@ -132,7 +132,7 @@ use_dht_stunner_ext_ip:CONFIG -= no_use_dht_stunner_ext_ip # To select your MacOsX version append the following assignation to qmake # command line "CONFIG+=rs_macos10.11" where 10.11 depends your version -macx:CONFIG *= rs_macos10.11 +macx:CONFIG *= rs_macos11.1 rs_macos10.8:CONFIG -= rs_macos10.11 rs_macos10.9:CONFIG -= rs_macos10.11 rs_macos10.10:CONFIG -= rs_macos10.11 @@ -842,6 +842,9 @@ macx-* { QMAKE_LIBDIR += "/usr/local/opt/openssl/lib" QMAKE_LIBDIR += "/usr/local/opt/sqlcipher/lib" QMAKE_LIBDIR += "/usr/local/opt/miniupnpc/lib" + INCLUDEPATH += "/usr/local/opt/libxml2/include/libxml2" + INCLUDEPATH += "/usr/local/opt/libxslt/include" + QMAKE_LIBDIR += "/usr/local/opt/libxslt/lib" } # If not yet defined attempt UPnP library autodetection should works at least From e5f2ef2335b698262d1906660a98429174c624f9 Mon Sep 17 00:00:00 2001 From: defnax Date: Fri, 3 Jan 2025 19:10:45 +0100 Subject: [PATCH 03/84] remove font sizes from the ui files --- retroshare-gui/src/gui/ChatLobbyWidget.ui | 8 +--- retroshare-gui/src/gui/FriendsDialog.ui | 8 ++-- retroshare-gui/src/gui/HomePage.ui | 21 +-------- retroshare-gui/src/gui/Identity/IdDialog.ui | 28 ++++-------- retroshare-gui/src/gui/MainWindow.ui | 7 +-- retroshare-gui/src/gui/NewsFeed.ui | 1 - retroshare-gui/src/gui/Posted/PhotoView.ui | 19 +++----- retroshare-gui/src/gui/Posted/PostedItem.ui | 15 +++---- retroshare-gui/src/gui/StartDialog.ui | 6 +-- .../src/gui/common/FriendSelectionWidget.ui | 7 +-- .../src/gui/common/GroupTreeWidget.ui | 5 --- .../src/gui/common/NewFriendList.ui | 5 --- retroshare-gui/src/gui/msgs/MessageWidget.ui | 45 +------------------ retroshare-gui/src/gui/msgs/MessagesDialog.ui | 17 +------ retroshare-gui/src/gui/settings/settingsw.ui | 10 +---- retroshare-gui/src/util/RichTextEdit.ui | 14 +++--- 16 files changed, 46 insertions(+), 170 deletions(-) diff --git a/retroshare-gui/src/gui/ChatLobbyWidget.ui b/retroshare-gui/src/gui/ChatLobbyWidget.ui index 8f8e8f29d..e0c2182c4 100644 --- a/retroshare-gui/src/gui/ChatLobbyWidget.ui +++ b/retroshare-gui/src/gui/ChatLobbyWidget.ui @@ -73,7 +73,6 @@ - 12 75 true @@ -191,11 +190,6 @@
- - - 11 - - 16 @@ -464,7 +458,7 @@ LineEditClear QLineEdit -
gui/common/LineEditClear.h
+
gui/common/LineEditClear.h
RSTreeWidget diff --git a/retroshare-gui/src/gui/FriendsDialog.ui b/retroshare-gui/src/gui/FriendsDialog.ui index a8e8217fc..02408e382 100644 --- a/retroshare-gui/src/gui/FriendsDialog.ui +++ b/retroshare-gui/src/gui/FriendsDialog.ui @@ -102,7 +102,7 @@ Qt::NoFocus
- + :/icons/help_64.png:/icons/help_64.png @@ -132,10 +132,10 @@ - QFrame::StyledPanel + QFrame::Box - QFrame::Raised + QFrame::Sunken @@ -401,8 +401,8 @@ - + diff --git a/retroshare-gui/src/gui/HomePage.ui b/retroshare-gui/src/gui/HomePage.ui index 5de0fa6fe..e716577b8 100644 --- a/retroshare-gui/src/gui/HomePage.ui +++ b/retroshare-gui/src/gui/HomePage.ui @@ -43,7 +43,6 @@ Courier New - 10 75 true @@ -88,7 +87,6 @@ - 11 75 true @@ -107,7 +105,7 @@ ... - + :/icons/help_64.png:/icons/help_64.png @@ -233,11 +231,6 @@
- - - 12 - - Open Source cross-platform, private and secure decentralized communication platform. @@ -317,11 +310,6 @@ private and secure decentralized communication platform. - - - 11 - - @@ -405,11 +393,6 @@ private and secure decentralized communication platform. - - - 11 - - Do you need help with Retroshare? @@ -424,8 +407,8 @@ private and secure decentralized communication platform. - + diff --git a/retroshare-gui/src/gui/Identity/IdDialog.ui b/retroshare-gui/src/gui/Identity/IdDialog.ui index ee28522e3..edf3e8bcf 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.ui +++ b/retroshare-gui/src/gui/Identity/IdDialog.ui @@ -91,7 +91,6 @@ - 12 75 true @@ -218,11 +217,6 @@ 0 - - - 11 - - Qt::CustomContextMenu @@ -301,8 +295,8 @@ 0 0 - 505 - 703 + 513 + 764
@@ -1018,11 +1012,6 @@ border-image: url(:/images/closepressed.png)
- - - 11 - - Qt::CustomContextMenu @@ -1083,7 +1072,12 @@ border-image: url(:/images/closepressed.png) LineEditClear QLineEdit -
gui/common/LineEditClear.h
+
gui/common/LineEditClear.h
+
+ + RSComboBox + QComboBox +
gui/common/RSComboBox.h
RSTreeWidget @@ -1094,11 +1088,7 @@ border-image: url(:/images/closepressed.png) ElidedLabel QLabel
gui/common/ElidedLabel.h
-
- - RSComboBox - QComboBox -
gui/common/RSComboBox.h
+ 1
RSTextBrowser diff --git a/retroshare-gui/src/gui/MainWindow.ui b/retroshare-gui/src/gui/MainWindow.ui index 55a7145e0..796593dfd 100644 --- a/retroshare-gui/src/gui/MainWindow.ui +++ b/retroshare-gui/src/gui/MainWindow.ui @@ -33,11 +33,6 @@ 0 - - - 12 - - QFrame::NoFrame @@ -157,7 +152,7 @@ - + :/images/kcmsystem24.png:/images/kcmsystem24.png diff --git a/retroshare-gui/src/gui/NewsFeed.ui b/retroshare-gui/src/gui/NewsFeed.ui index 32a679a74..d6ae3aaa4 100644 --- a/retroshare-gui/src/gui/NewsFeed.ui +++ b/retroshare-gui/src/gui/NewsFeed.ui @@ -70,7 +70,6 @@ - 12 75 true diff --git a/retroshare-gui/src/gui/Posted/PhotoView.ui b/retroshare-gui/src/gui/Posted/PhotoView.ui index e1e7a21e5..31db767c9 100644 --- a/retroshare-gui/src/gui/Posted/PhotoView.ui +++ b/retroshare-gui/src/gui/Posted/PhotoView.ui @@ -22,7 +22,6 @@ MS Sans Serif - 11 75 true true @@ -103,7 +102,6 @@ MS Sans Serif - 9 50 false @@ -114,7 +112,7 @@
- + 24 @@ -134,7 +132,6 @@ MS Sans Serif - 11 75 true true @@ -150,7 +147,6 @@ MS Sans Serif - 9 @@ -163,7 +159,6 @@ MS Sans Serif - 9 @@ -209,17 +204,17 @@ + + AvatarWidget + QLabel +
gui/common/AvatarWidget.h
+ 1 +
GxsIdLabel QLabel
gui/gxs/GxsIdLabel.h
- - AvatarWidget - QWidget -
gui/common/AvatarWidget.h
- 1 -
AspectRatioPixmapLabel QLabel diff --git a/retroshare-gui/src/gui/Posted/PostedItem.ui b/retroshare-gui/src/gui/Posted/PostedItem.ui index 24d570b16..cbf5ae7f4 100644 --- a/retroshare-gui/src/gui/Posted/PostedItem.ui +++ b/retroshare-gui/src/gui/Posted/PostedItem.ui @@ -262,7 +262,6 @@ - 11 75 true true @@ -726,17 +725,17 @@
- - GxsIdLabel - QLabel -
gui/gxs/GxsIdLabel.h
-
ElidedLabel QLabel
gui/common/ElidedLabel.h
1
+ + GxsIdLabel + QLabel +
gui/gxs/GxsIdLabel.h
+
ZoomableLabel QLabel @@ -744,9 +743,9 @@
- - + + diff --git a/retroshare-gui/src/gui/StartDialog.ui b/retroshare-gui/src/gui/StartDialog.ui index 8c491caeb..dd037adf4 100644 --- a/retroshare-gui/src/gui/StartDialog.ui +++ b/retroshare-gui/src/gui/StartDialog.ui @@ -345,8 +345,8 @@ The current identities/locations will not be affected. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="Create new Profile..."><span style=" font-family:'MS Shell Dlg 2'; font-size:8pt; text-decoration: underline; color:#0000ff;">New Profile/Node</span></a></p></body></html> +</style></head><body style=" font-family:'Sans'; font-size:13pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="Create new Profile..."><span style=" font-family:'MS Shell Dlg 2'; font-size:14pt; text-decoration: underline; color:#0000ff;">New Profile/Node</span></a></p></body></html>
@@ -370,8 +370,8 @@ p, li { white-space: pre-wrap; } - + diff --git a/retroshare-gui/src/gui/common/FriendSelectionWidget.ui b/retroshare-gui/src/gui/common/FriendSelectionWidget.ui index 065c9013b..a9bc8b407 100644 --- a/retroshare-gui/src/gui/common/FriendSelectionWidget.ui +++ b/retroshare-gui/src/gui/common/FriendSelectionWidget.ui @@ -38,11 +38,6 @@ 0 - - - 11 - - Qt::CustomContextMenu @@ -71,7 +66,7 @@ LineEditClear QLineEdit -
gui/common/LineEditClear.h
+
gui/common/LineEditClear.h
RSTreeWidget diff --git a/retroshare-gui/src/gui/common/GroupTreeWidget.ui b/retroshare-gui/src/gui/common/GroupTreeWidget.ui index 029d71fb9..10b5eb48b 100644 --- a/retroshare-gui/src/gui/common/GroupTreeWidget.ui +++ b/retroshare-gui/src/gui/common/GroupTreeWidget.ui @@ -70,11 +70,6 @@ 0 - - - 11 - - Qt::CustomContextMenu diff --git a/retroshare-gui/src/gui/common/NewFriendList.ui b/retroshare-gui/src/gui/common/NewFriendList.ui index 4bd4dfdc6..286cf4304 100644 --- a/retroshare-gui/src/gui/common/NewFriendList.ui +++ b/retroshare-gui/src/gui/common/NewFriendList.ui @@ -58,11 +58,6 @@ - - - 12 - - Qt::CustomContextMenu diff --git a/retroshare-gui/src/gui/msgs/MessageWidget.ui b/retroshare-gui/src/gui/msgs/MessageWidget.ui index de580d7e5..cd4a7c401 100644 --- a/retroshare-gui/src/gui/msgs/MessageWidget.ui +++ b/retroshare-gui/src/gui/msgs/MessageWidget.ui @@ -6,7 +6,7 @@ 0 0 - 698 + 738 539 @@ -59,11 +59,6 @@ 0 - - - 9 - - Qt::LeftToRight @@ -211,11 +206,6 @@ 0 - - - 9 - - Tags: @@ -232,11 +222,6 @@ 0 - - - 9 - - Subject: @@ -253,11 +238,6 @@ 0 - - - 9 - - Cc: @@ -277,11 +257,6 @@ 0 - - - 9 - - Bcc: @@ -298,11 +273,6 @@ 0 - - - 9 - - To: @@ -321,7 +291,6 @@ - 9 75 true @@ -373,11 +342,6 @@ 16777215 - - - 9 - - true @@ -416,11 +380,6 @@ 0 - - - 9 - - From: @@ -860,8 +819,8 @@ - + diff --git a/retroshare-gui/src/gui/msgs/MessagesDialog.ui b/retroshare-gui/src/gui/msgs/MessagesDialog.ui index 5f1d83eca..516511265 100644 --- a/retroshare-gui/src/gui/msgs/MessagesDialog.ui +++ b/retroshare-gui/src/gui/msgs/MessagesDialog.ui @@ -139,11 +139,6 @@ 0 - - - 11 - - Qt::CustomContextMenu @@ -253,11 +248,6 @@ 0 - - - 11 - - @@ -375,11 +365,6 @@ Qt::Vertical - - - 10 - - Qt::CustomContextMenu @@ -466,7 +451,7 @@ LineEditClear QLineEdit -
gui/common/LineEditClear.h
+
gui/common/LineEditClear.h
RSTabWidget diff --git a/retroshare-gui/src/gui/settings/settingsw.ui b/retroshare-gui/src/gui/settings/settingsw.ui index d1cbd3caf..605e8558e 100644 --- a/retroshare-gui/src/gui/settings/settingsw.ui +++ b/retroshare-gui/src/gui/settings/settingsw.ui @@ -35,11 +35,6 @@ 16777215 - - - 11 - - Qt::IgnoreAction @@ -100,7 +95,6 @@ - 12 75 true @@ -135,8 +129,8 @@ 0 0 - 1313 - 849 + 1264 + 845 diff --git a/retroshare-gui/src/util/RichTextEdit.ui b/retroshare-gui/src/util/RichTextEdit.ui index 63e624b5e..5bb57a792 100644 --- a/retroshare-gui/src/util/RichTextEdit.ui +++ b/retroshare-gui/src/util/RichTextEdit.ui @@ -6,7 +6,7 @@ 0 0 - 703 + 784 312 @@ -566,7 +566,6 @@ MS Sans Serif - 9 @@ -590,16 +589,16 @@
- - MimeTextEdit - QTextEdit -
gui/common/MimeTextEdit.h
-
RSComboBox QComboBox
gui/common/RSComboBox.h
+ + MimeTextEdit + QTextEdit +
gui/common/MimeTextEdit.h
+
f_textedit @@ -608,7 +607,6 @@ f_menu - From c9599ea8174b925d0b6cbc30a15a1faa46cb275d Mon Sep 17 00:00:00 2001 From: defnax Date: Thu, 9 Jan 2025 19:43:35 +0100 Subject: [PATCH 04/84] Moved background image to standard light --- .../src/gui/qss/stylesheet/Standard_Light.qss | 34 ++++++++++++++++++ .../src/gui/qss/stylesheet/default.qss | 35 ------------------- 2 files changed, 34 insertions(+), 35 deletions(-) diff --git a/retroshare-gui/src/gui/qss/stylesheet/Standard_Light.qss b/retroshare-gui/src/gui/qss/stylesheet/Standard_Light.qss index df6b9d51c..ec1992f5b 100644 --- a/retroshare-gui/src/gui/qss/stylesheet/Standard_Light.qss +++ b/retroshare-gui/src/gui/qss/stylesheet/Standard_Light.qss @@ -2712,3 +2712,37 @@ PhotoItem QFrame#photoFrame { PhotoItem QWidget:hover { background-color: #7ecbfb; } + + +/* StartDialog + To get the same style for all user and not use last connected one. */ + +StartDialog QFrame#loginframe{ + border-image: url(:/images/logo/background_lessblue.png) 0 0 0 0 stretch stretch; + border-width: 0px; +} +StartDialog QFrame#loginframe QCheckBox, +StartDialog QFrame#loginframe QLabel { + background: transparent; +} +StartDialog QGroupBox#profilGBox { + background: rgba(0,0,0,10%); + border-radius: 3px; + border-width: 0px; +} + +StartDialog QGroupBox#profilGBox * { + background-color: white; + color: black; +} + +StartDialog QPushButton#loadButton { + background: transparent; + border-image: url(:/images/btn_blue.png) 4; + border-width: 4; + color: white; +} +StartDialog QPushButton#loadButton:hover { + background: transparent; + border-image: url(:/images/btn_blue_hover.png) 4; +} diff --git a/retroshare-gui/src/gui/qss/stylesheet/default.qss b/retroshare-gui/src/gui/qss/stylesheet/default.qss index defcc82f8..3a3bfeb5c 100644 --- a/retroshare-gui/src/gui/qss/stylesheet/default.qss +++ b/retroshare-gui/src/gui/qss/stylesheet/default.qss @@ -141,41 +141,6 @@ QLabel#newLabel:enabled { } -/* StartDialog - To get the same style for all user and not use last connected one. */ - -StartDialog QFrame#loginframe{ - border-image: url(:/images/logo/background_lessblue.png) 0 0 0 0 stretch stretch; - border-width: 0px; -} -StartDialog QFrame#loginframe QCheckBox, -StartDialog QFrame#loginframe QLabel { - background: transparent; -} -StartDialog QGroupBox#profilGBox { - background: rgba(0,0,0,10%); - border-radius: 3px; - border-width: 0px; -} - -StartDialog QGroupBox#profilGBox * { - background-color: white; - color: black; -} - -StartDialog QPushButton#loadButton { - background: transparent; - border-image: url(:/images/btn_blue.png) 4; - border-width: 4; - color: white; -} -StartDialog QPushButton#loadButton:hover { - background: transparent; - border-image: url(:/images/btn_blue_hover.png) 4; -} - - - /* GenCertDialog Change colors here because GUI is not started yet so no user StyleSheet loads */ From e18bb74a5e7b9f222a92f40db64cb9aa83f8ac82 Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 10 Jan 2025 22:47:46 +0100 Subject: [PATCH 05/84] added non-backward compatible flag change for v0.7 about sha1 certs --- retroshare.pri | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/retroshare.pri b/retroshare.pri index 22bf11d3f..06842064c 100644 --- a/retroshare.pri +++ b/retroshare.pri @@ -286,7 +286,7 @@ isEmpty(RS_THREAD_LIB):RS_THREAD_LIB = pthread # # V07_NON_BACKWARD_COMPATIBLE_CHANGE_002: # -# What: Use RSA+SHA256 instead of RSA+SHA1 for PGP certificate signatures +# What: Use RSA+SHA256 instead of RSA+SHA1 for SSL certificates # # Why: Sha1 is likely to be prone to primary collisions anytime soon, so it is urgent to turn to a more secure solution. # @@ -296,16 +296,26 @@ isEmpty(RS_THREAD_LIB):RS_THREAD_LIB = pthread # # What: Do not hash PGP certificate twice when signing # -# Why: hasing twice is not per se a security issue, but it makes it harder to change the settings for hashing. +# Why: hasing twice is not per se a security issue, but it makes it harder to change the settings for hashing. # -# Backward compat: patched peers cannot connect to non patched peers older than Nov 2017. +# Backward compat: patched peers cannot connect to non patched peers older than Nov 2017. # # V07_NON_BACKWARD_COMPATIBLE_CHANGE_004: # # What: Do not probe that GXS tunnels accept fast items. Just assume they do. +# # Why: Avoids sending probe packets +# # BackwardCompat: old RS before Mai 2019 will not be able to distant chat. # +# V07_NON_BACKWARD_COMPATIBLE_CHANGE_005: +# +# What: Stop accepting certificates signed with sha1 algorithm +# +# Why: Sha1 has been declared insecure and shouldn't be used anymore. +# +# BackwardCompat: Retroshare profiles generated before Nov.2024 with openpgp-sdk may still use sha1 +# ########################################################################################################################################################### ########################################################################################################################################################### From e8353850001c55aafcf3280b828d141f17be66b3 Mon Sep 17 00:00:00 2001 From: defnax Date: Sat, 18 Jan 2025 16:06:03 +0100 Subject: [PATCH 06/84] restore back changes --- retroshare-gui/src/gui/ChatLobbyWidget.ui | 1 + retroshare-gui/src/gui/Identity/IdDialog.ui | 1 + retroshare-gui/src/gui/NewsFeed.ui | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/ChatLobbyWidget.ui b/retroshare-gui/src/gui/ChatLobbyWidget.ui index e0c2182c4..b2f711b72 100644 --- a/retroshare-gui/src/gui/ChatLobbyWidget.ui +++ b/retroshare-gui/src/gui/ChatLobbyWidget.ui @@ -73,6 +73,7 @@ + 12 75 true diff --git a/retroshare-gui/src/gui/Identity/IdDialog.ui b/retroshare-gui/src/gui/Identity/IdDialog.ui index edf3e8bcf..69d1cd8fd 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.ui +++ b/retroshare-gui/src/gui/Identity/IdDialog.ui @@ -91,6 +91,7 @@ + 12 75 true diff --git a/retroshare-gui/src/gui/NewsFeed.ui b/retroshare-gui/src/gui/NewsFeed.ui index d6ae3aaa4..ff8c17f5e 100644 --- a/retroshare-gui/src/gui/NewsFeed.ui +++ b/retroshare-gui/src/gui/NewsFeed.ui @@ -70,7 +70,8 @@ - 75 + 12 + 75 true From 86d96fe60c01202ef681c6665ffc122fae92e83f Mon Sep 17 00:00:00 2001 From: defnax Date: Wed, 22 Jan 2025 23:21:32 +0100 Subject: [PATCH 07/84] Fixed fonts for macos Fixed Toolbar fonts Fixed forum composer fonts --- retroshare-gui/src/gui/MainWindow.cpp | 5 ++++ .../src/gui/gxsforums/CreateGxsForumMsg.ui | 23 ++++++++----------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index b1e4b1e69..f93721044 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -564,6 +564,11 @@ void MainWindow::addPage(MainPage *page, QActionGroup *grp, QListiconPixmap()),page->pageName()) ; ui->listWidget->addItem(item) ; +#if defined(Q_OS_DARWIN) + QFont f = ui->toolBarPage->font(); + action->setFont(f); +#endif + if (notify) { QPair pair = QPair( action, item); diff --git a/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.ui b/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.ui index 10105a630..683c8f07d 100644 --- a/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.ui +++ b/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.ui @@ -7,7 +7,7 @@ 0 0 640 - 465 + 551 @@ -132,17 +132,12 @@ - - - MS Sans Serif - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8.25pt;"><br /></p></body></html> +</style></head><body style=" font-family:''; font-size:; font-weight:400; font-style:normal;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html> @@ -382,6 +377,11 @@ p, li { white-space: pre-wrap; } + + MimeTextEdit + QTextEdit +
gui/common/MimeTextEdit.h
+
GxsIdChooser QComboBox @@ -399,15 +399,10 @@ p, li { white-space: pre-wrap; }
gui/common/HashBox.h
1
- - MimeTextEdit - QTextEdit -
gui/common/MimeTextEdit.h
-
- + From 85b6d1809401c4f648070782151d91ac389e50d3 Mon Sep 17 00:00:00 2001 From: defnax Date: Thu, 23 Jan 2025 22:22:26 +0100 Subject: [PATCH 08/84] Fixed fonts to use default system --- .../gui/gxschannels/CreateGxsChannelMsg.ui | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui index 510da23a1..01e58118f 100644 --- a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui +++ b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui @@ -191,8 +191,8 @@ p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt; font-weight:600;">Attachments:</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src=":/images/feedback_arrow.png" /><span style=" font-family:'MS Shell Dlg 2'; font-size:8pt;"> Use Drag and Drop / Add Files button, to Hash new files.</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src=":/images/feedback_arrow.png" /><span style=" font-family:'MS Shell Dlg 2'; font-size:8pt;"> Copy/Paste RetroShare links from your shares</span></p></body></html> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src=":/images/feedback_arrow.png" /><span style=" font-family:''; font-size:;"> Use Drag and Drop / Add Files button, to Hash new files.</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src=":/images/feedback_arrow.png" /><span style=" font-family:''; font-size:;"> Copy/Paste RetroShare links from your shares</span></p></body></html>
Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop @@ -515,8 +515,8 @@ p, li { white-space: pre-wrap; } 0 0 - 63 - 24 + 98 + 30 @@ -611,6 +611,11 @@ p, li { white-space: pre-wrap; }
+ + RSComboBox + QComboBox +
gui/common/RSComboBox.h
+
ChannelPostThumbnailView QWidget @@ -629,15 +634,10 @@ p, li { white-space: pre-wrap; }
util/RichTextEdit.h
1
- - RSComboBox - QComboBox -
gui/common/RSComboBox.h
-
- + From b99988385f0e95d12a0dbdea6cb4f38c3e7a199e Mon Sep 17 00:00:00 2001 From: defnax Date: Thu, 30 Jan 2025 19:53:59 +0100 Subject: [PATCH 09/84] Added brew packages for RNP --- build_scripts/OSX/MacOS_X_InstallGuide.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/build_scripts/OSX/MacOS_X_InstallGuide.md b/build_scripts/OSX/MacOS_X_InstallGuide.md index 4afa90e2c..4b3f6a8c5 100644 --- a/build_scripts/OSX/MacOS_X_InstallGuide.md +++ b/build_scripts/OSX/MacOS_X_InstallGuide.md @@ -85,6 +85,13 @@ Install HomeBrew following this guide: [HomeBrew](http://brew.sh/) $ brew install rapidjson $ brew install sqlcipher +For RNP lib: + + $ brew install bzip2 + $ brew install zlib + $ brew install json-c + $ brew install botan@2 + #### Install CMake $ brew install cmake From e14fc66ca3df906e65471b35d7fd4d0cd092057c Mon Sep 17 00:00:00 2001 From: defnax Date: Wed, 5 Feb 2025 20:55:03 +0100 Subject: [PATCH 10/84] Settings for default tree & listwidget fonts --- retroshare-gui/src/gui/ChatLobbyWidget.cpp | 23 ++++++++++++++++ retroshare-gui/src/gui/ChatLobbyWidget.h | 3 +++ retroshare-gui/src/gui/Identity/IdDialog.cpp | 20 ++++++++++++++ retroshare-gui/src/gui/Identity/IdDialog.h | 2 ++ retroshare-gui/src/gui/MainWindow.cpp | 27 +++++++++++++++++++ retroshare-gui/src/gui/MainWindow.h | 3 +++ .../src/gui/chat/ChatLobbyDialog.cpp | 22 +++++++++++++++ retroshare-gui/src/gui/chat/ChatLobbyDialog.h | 3 +++ .../src/gui/common/NewFriendList.cpp | 25 +++++++++++++++++ retroshare-gui/src/gui/common/NewFriendList.h | 3 +++ .../src/gui/gxs/GxsGroupFrameDialog.cpp | 19 +++++++++++++ .../src/gui/gxs/GxsGroupFrameDialog.h | 3 ++- .../src/gui/msgs/MessagesDialog.cpp | 25 +++++++++++++++++ retroshare-gui/src/gui/msgs/MessagesDialog.h | 3 +++ 14 files changed, 180 insertions(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/ChatLobbyWidget.cpp b/retroshare-gui/src/gui/ChatLobbyWidget.cpp index 9682bc4c5..75894fea1 100644 --- a/retroshare-gui/src/gui/ChatLobbyWidget.cpp +++ b/retroshare-gui/src/gui/ChatLobbyWidget.cpp @@ -230,6 +230,7 @@ ChatLobbyWidget::ChatLobbyWidget(QWidget *parent, Qt::WindowFlags flags) int ltwH = misc::getFontSizeFactor("LobbyTreeWidget", 1.5).height(); ui.lobbyTreeWidget->setIconSize(QSize(ltwH,ltwH)); + updateFontSize(); } ChatLobbyWidget::~ChatLobbyWidget() @@ -1368,3 +1369,25 @@ int ChatLobbyWidget::getNumColVisible() } return iNumColVis; } + +void ChatLobbyWidget::showEvent(QShowEvent *event) +{ + if (!event->spontaneous()) { + updateFontSize(); + } +} + +void ChatLobbyWidget::updateFontSize() +{ +#if defined(Q_OS_DARWIN) + int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 13).toInt(); +#else + int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 11).toInt(); +#endif + QFont newFont = ui.lobbyTreeWidget->font(); + if (newFont.pointSize() != customFontSize) { + newFont.setPointSize(customFontSize); + QFontMetricsF fontMetrics(newFont); + ui.lobbyTreeWidget->setFont(newFont); + } +} diff --git a/retroshare-gui/src/gui/ChatLobbyWidget.h b/retroshare-gui/src/gui/ChatLobbyWidget.h index a5055788e..ce451fe04 100644 --- a/retroshare-gui/src/gui/ChatLobbyWidget.h +++ b/retroshare-gui/src/gui/ChatLobbyWidget.h @@ -76,6 +76,8 @@ public: uint unreadCount(); + virtual void showEvent(QShowEvent *) ; + signals: void unreadCountChanged(uint unreadCount); @@ -112,6 +114,7 @@ private slots: void updateNotify(ChatLobbyId id, unsigned int count) ; void idChooserCurrentIndexChanged(int index); + void updateFontSize(); private: void autoSubscribeLobby(QTreeWidgetItem *item); diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index 032acaa2d..8a099aac8 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -956,6 +956,10 @@ void IdDialog::showEvent(QShowEvent *s) needUpdateCirclesOnNextShow = false; MainPage::showEvent(s); + + if (!s->spontaneous()) { + updateFontSize(); + } } void IdDialog::createExternalCircle() @@ -2599,3 +2603,19 @@ void IdDialog::restoreExpandedCircleItems(const std::vector& expanded_root restoreTopLevel(mExternalOtherCircleItem,1); restoreTopLevel(mMyCircleItem,2); } + +void IdDialog::updateFontSize() +{ +#if defined(Q_OS_DARWIN) + int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 13).toInt(); +#else + int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 11).toInt(); +#endif + QFont newFont = ui->idTreeWidget->font(); + if (newFont.pointSize() != customFontSize) { + newFont.setPointSize(customFontSize); + QFontMetricsF fontMetrics(newFont); + ui->idTreeWidget->setFont(newFont); + ui->treeWidget_membership->setFont(newFont); + } +} diff --git a/retroshare-gui/src/gui/Identity/IdDialog.h b/retroshare-gui/src/gui/Identity/IdDialog.h index 403b3a437..ea6095d63 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.h +++ b/retroshare-gui/src/gui/Identity/IdDialog.h @@ -113,6 +113,8 @@ private slots: static QString inviteMessage(); void sendInvite(); + void updateFontSize(); + private: void processSettings(bool load); QString createUsageString(const RsIdentityUsage& u) const; diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index b1e4b1e69..0eb5b69c9 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -67,6 +67,7 @@ #include "notifyqt.h" #include "common/UserNotify.h" #include "gui/ServicePermissionDialog.h" +#include "gui/settings/rsharesettings.h" #ifdef UNFINISHED #include "unfinished/ApplicationWindow.h" @@ -1022,6 +1023,7 @@ void SetForegroundWindowInternal(HWND hWnd) /* Show the dialog. */ raiseWindow(); + /* Set the focus to the specified page. */ _instance->ui->stackPages->setCurrentPage(page); } @@ -1819,6 +1821,31 @@ void MainWindow::setCompactStatusMode(bool compact) //opModeStatus: TODO Show only ??? } +void MainWindow::showEvent(QShowEvent *event) +{ + if (!event->spontaneous()) { + updateFontSize(); + } +} + +void MainWindow::updateFontSize() +{ +#if defined(Q_OS_DARWIN) + int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 13).toInt(); +#else + int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 11).toInt(); +#endif + QFont newFont = ui->listWidget->font(); + if (newFont.pointSize() != customFontSize) { + newFont.setPointSize(customFontSize); + QFontMetricsF fontMetrics(newFont); + int iconHeight = fontMetrics.height()*1.5; + ui->listWidget->setFont(newFont); + ui->toolBarPage->setFont(newFont); + ui->listWidget->setIconSize(QSize(iconHeight, iconHeight)); + } +} + Gui_InputDialogReturn MainWindow::guiInputDialog(const QString& windowTitle, const QString& labelText, QLineEdit::EchoMode textEchoMode, bool modal) { diff --git a/retroshare-gui/src/gui/MainWindow.h b/retroshare-gui/src/gui/MainWindow.h index a7f3013f1..99219de42 100644 --- a/retroshare-gui/src/gui/MainWindow.h +++ b/retroshare-gui/src/gui/MainWindow.h @@ -204,6 +204,8 @@ public: static bool hiddenmode; + virtual void showEvent(QShowEvent *) ; + public slots: void receiveNewArgs(QStringList args); void displayErrorMessage(int,int,const QString&) ; @@ -307,6 +309,7 @@ private slots: void doQuit(); void updateTrayCombine(); + void updateFontSize(); private: void initStackedPage(); diff --git a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp index 3b92883e8..56feb5f2f 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp +++ b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp @@ -1017,3 +1017,25 @@ void ChatLobbyDialog::setWindowed(bool windowed) if (chatLobbyPage)// If not defined, we are on autosubscribe loop of lobby widget constructor. So don't recall it. showDialog(RS_CHAT_FOCUS); } + +void ChatLobbyDialog::showEvent(QShowEvent *event) +{ + if (!event->spontaneous()) { + updateFontSize(); + } +} + +void ChatLobbyDialog::updateFontSize() +{ +#if defined(Q_OS_DARWIN) + int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 13).toInt(); +#else + int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 11).toInt(); +#endif + QFont newFont = ui.participantsList->font(); + if (newFont.pointSize() != customFontSize) { + newFont.setPointSize(customFontSize); + QFontMetricsF fontMetrics(newFont); + ui.participantsList->setFont(newFont); + } +} diff --git a/retroshare-gui/src/gui/chat/ChatLobbyDialog.h b/retroshare-gui/src/gui/chat/ChatLobbyDialog.h index 065abacee..7df0f01b9 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyDialog.h +++ b/retroshare-gui/src/gui/chat/ChatLobbyDialog.h @@ -54,6 +54,8 @@ public: inline bool isWindowed() const { return dynamic_cast(this->window()) != nullptr; } + virtual void showEvent(QShowEvent *) ; + public slots: void leaveLobby() ; private slots: @@ -64,6 +66,7 @@ private slots: void showInPeopleTab(); void toggleWindowed(){setWindowed(!isWindowed());} void setWindowed(bool windowed); + void updateFontSize(); signals: void typingEventReceived(ChatLobbyId) ; diff --git a/retroshare-gui/src/gui/common/NewFriendList.cpp b/retroshare-gui/src/gui/common/NewFriendList.cpp index 6acb8da9a..9e5039f76 100644 --- a/retroshare-gui/src/gui/common/NewFriendList.cpp +++ b/retroshare-gui/src/gui/common/NewFriendList.cpp @@ -55,6 +55,7 @@ #include "gui/connect/ConnectProgressDialog.h" #include "gui/common/ElidedLabel.h" #include "gui/notifyqt.h" +#include "gui/settings/rsharesettings.h" #include "NewFriendList.h" #include "ui_NewFriendList.h" @@ -1693,3 +1694,27 @@ void NewFriendList::expandGroup(const RsNodeGroupId& gid) QModelIndex index = mProxyModel->mapFromSource(mModel->getIndexOfGroup(gid)); ui->peerTreeWidget->setExpanded(index,true) ; } + +void NewFriendList::showEvent(QShowEvent *event) +{ + if (!event->spontaneous()) { + updateFontSize(); + } +} + +void NewFriendList::updateFontSize() +{ +#if defined(Q_OS_DARWIN) + int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 13).toInt(); +#else + int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 11).toInt(); +#endif + QFont newFont = ui->peerTreeWidget->font(); + if (newFont.pointSize() != customFontSize) { + newFont.setPointSize(customFontSize); + QFontMetricsF fontMetrics(newFont); + int iconHeight = fontMetrics.height()*1.5; + ui->peerTreeWidget->setFont(newFont); + ui->peerTreeWidget->setIconSize(QSize(iconHeight, iconHeight)); + } +} diff --git a/retroshare-gui/src/gui/common/NewFriendList.h b/retroshare-gui/src/gui/common/NewFriendList.h index 7424bcfcf..4679b7804 100644 --- a/retroshare-gui/src/gui/common/NewFriendList.h +++ b/retroshare-gui/src/gui/common/NewFriendList.h @@ -54,6 +54,8 @@ public: explicit NewFriendList(QWidget *parent = 0); ~NewFriendList(); + virtual void showEvent(QShowEvent *) ; + // Add a tool button to the tool area void addToolButton(QToolButton *toolButton); void processSettings(bool load); @@ -95,6 +97,7 @@ private slots: void sortColumn(int col,Qt::SortOrder so); void itemExpanded(const QModelIndex&); void itemCollapsed(const QModelIndex&); + void updateFontSize(); protected: void changeEvent(QEvent *e); diff --git a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp index 069c51b79..a4789b7d9 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp +++ b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp @@ -193,6 +193,9 @@ void GxsGroupFrameDialog::showEvent(QShowEvent* /*event*/) bool empty = mCachedGroupMetas.empty() || children==0; updateDisplay( empty ); + + updateFontSize(); + } void GxsGroupFrameDialog::paintEvent(QPaintEvent *pe) @@ -1274,3 +1277,19 @@ void GxsGroupFrameDialog::distantRequestGroupData() checkRequestGroup(group_id) ; } +void GxsGroupFrameDialog::updateFontSize() +{ +#if defined(Q_OS_DARWIN) + int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 13).toInt(); +#else + int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 11).toInt(); +#endif + QFont newFont = ui->groupTreeWidget->font(); + if (newFont.pointSize() != customFontSize) { + newFont.setPointSize(customFontSize); + QFontMetricsF fontMetrics(newFont); + ui->groupTreeWidget->setFont(newFont); + } +} + + diff --git a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.h b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.h index 81bba553d..a70e6c890 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.h +++ b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.h @@ -110,7 +110,8 @@ protected: void updateGroupStatisticsReal(const RsGxsGroupId &groupId); void updateMessageSummaryListReal(RsGxsGroupId groupId); - + void updateFontSize(); + private slots: void todo(); diff --git a/retroshare-gui/src/gui/msgs/MessagesDialog.cpp b/retroshare-gui/src/gui/msgs/MessagesDialog.cpp index 85611b585..5cf408267 100644 --- a/retroshare-gui/src/gui/msgs/MessagesDialog.cpp +++ b/retroshare-gui/src/gui/msgs/MessagesDialog.cpp @@ -1660,3 +1660,28 @@ void MessagesDialog::updateInterface() ui.tabWidget->setTabIcon(0, FilesDefs::getIconFromQtResourcePath(":/icons/warning_yellow_128.png")); } } + +void MessagesDialog::showEvent(QShowEvent *event) +{ + if (!event->spontaneous()) { + updateFontSize(); + } +} + +void MessagesDialog::updateFontSize() +{ +#if defined(Q_OS_DARWIN) + int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 13).toInt(); +#else + int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 11).toInt(); +#endif + QFont newFont = ui.listWidget->font(); + if (newFont.pointSize() != customFontSize) { + newFont.setPointSize(customFontSize); + QFontMetricsF fontMetrics(newFont); + ui.listWidget->setFont(newFont); + ui.quickViewWidget->setFont(newFont); + ui.messageTreeWidget->setFont(newFont); + } +} + diff --git a/retroshare-gui/src/gui/msgs/MessagesDialog.h b/retroshare-gui/src/gui/msgs/MessagesDialog.h index 1d10137c2..753f910dd 100644 --- a/retroshare-gui/src/gui/msgs/MessagesDialog.h +++ b/retroshare-gui/src/gui/msgs/MessagesDialog.h @@ -54,6 +54,7 @@ public: // replaced by shortcut // virtual void keyPressEvent(QKeyEvent *) ; + virtual void showEvent(QShowEvent *) ; QColor textColorInbox() const { return mTextColorInbox; } @@ -110,6 +111,8 @@ private slots: void tabChanged(int tab); void tabCloseRequested(int tab); + void updateFontSize(); + private: void handleEvent_main_thread(std::shared_ptr event); void handleTagEvent_main_thread(std::shared_ptr event); From 18f4ef5574137ea3cb65186a36792d0503c05ab7 Mon Sep 17 00:00:00 2001 From: defnax Date: Thu, 6 Feb 2025 19:02:40 +0100 Subject: [PATCH 11/84] Fix fonts --- retroshare-gui/src/gui/Identity/IdDialog.cpp | 3 +++ .../src/gui/common/FriendSelectionWidget.cpp | 18 ++++++++++++++++++ .../src/gui/common/FriendSelectionWidget.h | 1 + 3 files changed, 22 insertions(+) diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index 8a099aac8..c69b71647 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -2617,5 +2617,8 @@ void IdDialog::updateFontSize() QFontMetricsF fontMetrics(newFont); ui->idTreeWidget->setFont(newFont); ui->treeWidget_membership->setFont(newFont); + contactsItem->setFont(RSID_COL_NICKNAME, newFont); + allItem->setFont(RSID_COL_NICKNAME, newFont); + ownItem->setFont(RSID_COL_NICKNAME, newFont); } } diff --git a/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp b/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp index 4608d1796..2d42726c8 100644 --- a/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp +++ b/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp @@ -28,6 +28,7 @@ #include "gui/notifyqt.h" #include "gui/common/RSTreeWidgetItem.h" #include "gui/common/StatusDefs.h" +#include "gui/settings/rsharesettings.h" #include "util/qtthreadsutils.h" #include "gui/common/PeerDefs.h" #include "gui/common/GroupDefs.h" @@ -223,6 +224,8 @@ void FriendSelectionWidget::showEvent(QShowEvent */*e*/) { if(gxsIds.empty()) loadIdentities(); + + updateFontSize(); } void FriendSelectionWidget::start() { @@ -1271,3 +1274,18 @@ bool FriendSelectionWidget::isFilterConnected() { return mActionFilterConnected->isChecked(); } + +void FriendSelectionWidget::updateFontSize() +{ +#if defined(Q_OS_DARWIN) + int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 13).toInt(); +#else + int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 11).toInt(); +#endif + QFont newFont = ui->friendList->font(); + if (newFont.pointSize() != customFontSize) { + newFont.setPointSize(customFontSize); + QFontMetricsF fontMetrics(newFont); + ui->friendList->setFont(newFont); + } +} diff --git a/retroshare-gui/src/gui/common/FriendSelectionWidget.h b/retroshare-gui/src/gui/common/FriendSelectionWidget.h index f10a748fc..cde084ede 100644 --- a/retroshare-gui/src/gui/common/FriendSelectionWidget.h +++ b/retroshare-gui/src/gui/common/FriendSelectionWidget.h @@ -144,6 +144,7 @@ private slots: void itemChanged(QTreeWidgetItem *item, int column); void selectAll() ; void deselectAll() ; + void updateFontSize(); private: void fillList(); From 533caea81e88da3b6ad96bdfc08b1499df25589f Mon Sep 17 00:00:00 2001 From: defnax Date: Thu, 6 Feb 2025 20:20:28 +0100 Subject: [PATCH 12/84] Added Fonts settings --- .../src/gui/settings/AppearancePage.cpp | 10 + .../src/gui/settings/AppearancePage.h | 2 + .../src/gui/settings/AppearancePage.ui | 307 ++++++++++-------- .../src/gui/settings/TransferPage.ui | 2 +- 4 files changed, 187 insertions(+), 134 deletions(-) diff --git a/retroshare-gui/src/gui/settings/AppearancePage.cpp b/retroshare-gui/src/gui/settings/AppearancePage.cpp index a96df209d..6e7b7d63d 100755 --- a/retroshare-gui/src/gui/settings/AppearancePage.cpp +++ b/retroshare-gui/src/gui/settings/AppearancePage.cpp @@ -101,6 +101,9 @@ AppearancePage::AppearancePage(QWidget * parent, Qt::WindowFlags flags) connect(ui.mainPageButtonType_CB, SIGNAL(currentIndexChanged(int)), this, SLOT(updateRbtPageOnToolBar() )); // connect(ui.menuItemsButtonType_CB, SIGNAL(currentIndexChanged(int)), this, SLOT(updateActionButtonLoc() )); + + connect(ui.minimumFontSize_SB, SIGNAL(valueChanged(int)), this, SLOT(updateFontSize())) ; + } void AppearancePage::switch_status_grpStatus(bool b) { switch_status(MainWindow::StatusGrpStatus ,"ShowStatusBar", b) ; } @@ -360,3 +363,10 @@ void AppearancePage::load() whileBlocking(ui.checkBoxShowSystrayOnStatus)->setChecked(Settings->valueFromGroup("StatusBar", "ShowSysTrayOnStatusBar", QVariant(false)).toBool()); } + +void AppearancePage::updateFontSize() +{ + Settings->beginGroup(QString("File")); + Settings->setValue("MinimumFontSize", ui.minimumFontSize_SB->value()); + Settings->endGroup(); +} \ No newline at end of file diff --git a/retroshare-gui/src/gui/settings/AppearancePage.h b/retroshare-gui/src/gui/settings/AppearancePage.h index 897563753..741bd752e 100755 --- a/retroshare-gui/src/gui/settings/AppearancePage.h +++ b/retroshare-gui/src/gui/settings/AppearancePage.h @@ -71,6 +71,8 @@ private slots: // void updateCmboListItemSize(); void updateStyle() ; + void updateFontSize(); + private: void switch_status(MainWindow::StatusElement s,const QString& key,bool b); diff --git a/retroshare-gui/src/gui/settings/AppearancePage.ui b/retroshare-gui/src/gui/settings/AppearancePage.ui index 96e5effe8..592113e01 100755 --- a/retroshare-gui/src/gui/settings/AppearancePage.ui +++ b/retroshare-gui/src/gui/settings/AppearancePage.ui @@ -14,22 +14,7 @@ Qt::NoContextMenu - - 6 - - - 6 - - - 6 - - - 6 - - - 0 - - + @@ -86,110 +71,12 @@ - - - - - 0 - 64 - - - - Qt::NoContextMenu - - - - - - Style - - - - - - - 150 - 0 - - - - Choose RetroShare's interface style - - - - - - - Qt::Horizontal - - - - 215 - 20 - - - - - - - - - - - - 0 - 64 - - - - Style Sheet - - - - - - - 150 - 0 - - - - - - - - Qt::Horizontal - - - - 215 - 20 - - - - - - - - - - - Qt::Vertical - - - - 361 - 61 - - - - - + 0 - 228 + 0 @@ -198,8 +85,8 @@ Tool Bar - - + + @@ -237,7 +124,7 @@ - + @@ -289,19 +176,6 @@ - - - - Qt::Vertical - - - - 20 - 40 - - - - @@ -352,10 +226,79 @@ + + + + Qt::Vertical + + + + 20 + 40 + + + + - + + + + Fonts + + + + + + + + Minimum font size + + + + + + + 11 + + + 64 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 188 + 96 + + + + + + + + Status Bar @@ -464,6 +407,104 @@ + + + + Qt::Vertical + + + + 361 + 61 + + + + + + + + + 0 + 64 + + + + Qt::NoContextMenu + + + + + + Style + + + + + + + 150 + 0 + + + + Choose RetroShare's interface style + + + + + + + Qt::Horizontal + + + + 215 + 20 + + + + + + + + + + + + 0 + 64 + + + + Style Sheet + + + + + + + 150 + 0 + + + + + + + + Qt::Horizontal + + + + 215 + 20 + + + + + + + diff --git a/retroshare-gui/src/gui/settings/TransferPage.ui b/retroshare-gui/src/gui/settings/TransferPage.ui index e77ee1742..4b48be012 100644 --- a/retroshare-gui/src/gui/settings/TransferPage.ui +++ b/retroshare-gui/src/gui/settings/TransferPage.ui @@ -14,7 +14,7 @@ - 1 + 0 From 7399c42dfbe43b2bd8d4eb0b166db3ee15a55743 Mon Sep 17 00:00:00 2001 From: defnax Date: Sat, 8 Feb 2025 15:13:43 +0100 Subject: [PATCH 13/84] Fix settings --- retroshare-gui/src/gui/settings/AppearancePage.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/retroshare-gui/src/gui/settings/AppearancePage.cpp b/retroshare-gui/src/gui/settings/AppearancePage.cpp index 6e7b7d63d..72b2a4bf7 100755 --- a/retroshare-gui/src/gui/settings/AppearancePage.cpp +++ b/retroshare-gui/src/gui/settings/AppearancePage.cpp @@ -362,6 +362,13 @@ void AppearancePage::load() whileBlocking(ui.checkBoxShowToasterDisable)->setChecked(Settings->valueFromGroup("StatusBar", "ShowToaster", QVariant(true)).toBool()); whileBlocking(ui.checkBoxShowSystrayOnStatus)->setChecked(Settings->valueFromGroup("StatusBar", "ShowSysTrayOnStatusBar", QVariant(false)).toBool()); + Settings->beginGroup(QString("File")); +#if defined(Q_OS_DARWIN) + whileBlocking(ui.minimumFontSize_SB)->setValue( Settings->value("MinimumFontSize", 13 ).toInt()); +#else + whileBlocking(ui.minimumFontSize_SB)->setValue( Settings->value("MinimumFontSize", 11 ).toInt()); +#endif + Settings->endGroup(); } void AppearancePage::updateFontSize() From b168110a581440b39b2fdc2e53c858168b3f698a Mon Sep 17 00:00:00 2001 From: defnax Date: Sat, 8 Feb 2025 15:44:39 +0100 Subject: [PATCH 14/84] Added for settings list fonts settings --- .../src/gui/settings/rsettingswin.cpp | 22 +++++++++++++++++++ .../src/gui/settings/rsettingswin.h | 2 ++ 2 files changed, 24 insertions(+) diff --git a/retroshare-gui/src/gui/settings/rsettingswin.cpp b/retroshare-gui/src/gui/settings/rsettingswin.cpp index 1d3d4ecc3..663cc7d03 100644 --- a/retroshare-gui/src/gui/settings/rsettingswin.cpp +++ b/retroshare-gui/src/gui/settings/rsettingswin.cpp @@ -239,3 +239,25 @@ void SettingsPage::notifySettingsChanged() if (NotifyQt::getInstance()) NotifyQt::getInstance()->notifySettingsChanged(); } + +void SettingsPage::showEvent(QShowEvent *event) +{ + if (!event->spontaneous()) { + updateFontSize(); + } +} + +void SettingsPage::updateFontSize() +{ +#if defined(Q_OS_DARWIN) + int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 13).toInt(); +#else + int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 11).toInt(); +#endif + QFont newFont = ui.listWidget->font(); + if (newFont.pointSize() != customFontSize) { + newFont.setPointSize(customFontSize); + QFontMetricsF fontMetrics(newFont); + ui.listWidget->setFont(newFont); + } +} diff --git a/retroshare-gui/src/gui/settings/rsettingswin.h b/retroshare-gui/src/gui/settings/rsettingswin.h index 74fb0d40c..64d8ebb52 100755 --- a/retroshare-gui/src/gui/settings/rsettingswin.h +++ b/retroshare-gui/src/gui/settings/rsettingswin.h @@ -53,6 +53,7 @@ protected: ~SettingsPage(); void addPage(ConfigPage*) ; + virtual void showEvent(QShowEvent *) override; public slots: //! Go to a specific part of the control panel. @@ -67,6 +68,7 @@ private slots: private: void initStackedWidget(); + void updateFontSize(); private: FloatingHelpBrowser *mHelpBrowser; From 3ffa36207998e2c2fccc969cf536d86f12c56e15 Mon Sep 17 00:00:00 2001 From: defnax Date: Sun, 9 Feb 2025 18:05:36 +0100 Subject: [PATCH 15/84] Added for Composer fonts settings --- .../src/gui/msgs/MessageComposer.cpp | 23 ++++++++ retroshare-gui/src/gui/msgs/MessageComposer.h | 2 + .../src/gui/settings/MessagePage.cpp | 13 +++++ retroshare-gui/src/gui/settings/MessagePage.h | 1 + .../src/gui/settings/MessagePage.ui | 52 +++++++++++++++---- 5 files changed, 82 insertions(+), 9 deletions(-) diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.cpp b/retroshare-gui/src/gui/msgs/MessageComposer.cpp index 4e0219b0c..bbca45bd3 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.cpp +++ b/retroshare-gui/src/gui/msgs/MessageComposer.cpp @@ -2933,3 +2933,26 @@ void MessageComposer::checkLength() ui.actionSend->setEnabled(true); } } + +void MessageComposer::showEvent(QShowEvent *event) +{ + if (!event->spontaneous()) { + updateFontSize(); + } +} + +void MessageComposer::updateFontSize() +{ +#if defined(Q_OS_DARWIN) + int customFontSize = Settings->valueFromGroup("Messages", "MinimumFontSize", 13).toInt(); +#else + int customFontSize = Settings->valueFromGroup("Messages", "MinimumFontSize", 12).toInt(); +#endif + QFont newFont = ui.msgText->font(); + if (newFont.pointSize() != customFontSize) { + newFont.setPointSize(customFontSize); + QFontMetricsF fontMetrics(newFont); + ui.msgText->setFont(newFont); + ui.comboSize->setCurrentIndex(ui.comboSize->findText(QString::number(newFont.pointSize()))); + } +} \ No newline at end of file diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.h b/retroshare-gui/src/gui/msgs/MessageComposer.h index 040681095..d89aecda5 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.h +++ b/retroshare-gui/src/gui/msgs/MessageComposer.h @@ -95,6 +95,7 @@ public slots: protected: void closeEvent (QCloseEvent * event); bool eventFilter(QObject *obj, QEvent *ev); + virtual void showEvent(QShowEvent *) ; private slots: /* toggle Contacts DockWidget */ @@ -169,6 +170,7 @@ private slots: static QString inviteMessage(); void checkLength(); + void updateFontSize(); private: static QString buildReplyHeader(const MessageInfo &msgInfo); diff --git a/retroshare-gui/src/gui/settings/MessagePage.cpp b/retroshare-gui/src/gui/settings/MessagePage.cpp index ff302317d..de4908088 100644 --- a/retroshare-gui/src/gui/settings/MessagePage.cpp +++ b/retroshare-gui/src/gui/settings/MessagePage.cpp @@ -55,6 +55,7 @@ MessagePage::MessagePage(QWidget * parent, Qt::WindowFlags flags) connect(ui.loadEmbeddedImages, SIGNAL(toggled(bool)), this,SLOT(updateLoadEmbededImages() )); connect(ui.openComboBox, SIGNAL(currentIndexChanged(int)),this,SLOT(updateMsgOpen() )); connect(ui.emoticonscheckBox, SIGNAL(toggled(bool)), this,SLOT(updateLoadEmoticons() )); + connect(ui.minimumFontSize_SB, SIGNAL(valueChanged(int)), this, SLOT(updateFontSize())) ; mTagEventHandlerId = 0; rsEvents->registerEventsHandler( [this](std::shared_ptr event) { RsQThreadUtils::postToObject( [this,event]() { handleEvent_main_thread(event); }); }, mTagEventHandlerId, RsEventType::MAIL_TAG ); @@ -121,6 +122,11 @@ MessagePage::load() whileBlocking(ui.loadEmbeddedImages)->setChecked(Settings->getMsgLoadEmbeddedImages()); whileBlocking(ui.openComboBox)->setCurrentIndex(ui.openComboBox->findData(Settings->getMsgOpen())); whileBlocking(ui.emoticonscheckBox)->setChecked(Settings->value("Emoticons", true).toBool()); +#if defined(Q_OS_DARWIN) + whileBlocking(ui.minimumFontSize_SB)->setValue( Settings->value("MinimumFontSize", 13 ).toInt()); +#else + whileBlocking(ui.minimumFontSize_SB)->setValue( Settings->value("MinimumFontSize", 12 ).toInt()); +#endif Settings->endGroup(); // state of filter combobox @@ -298,3 +304,10 @@ void MessagePage::currentRowChangedTag(int row) ui.deletepushButton->setEnabled(bDeleteEnable); } +void MessagePage::updateFontSize() +{ + Settings->beginGroup(QString("Messages")); + Settings->setValue("MinimumFontSize", ui.minimumFontSize_SB->value()); + Settings->endGroup(); +} + diff --git a/retroshare-gui/src/gui/settings/MessagePage.h b/retroshare-gui/src/gui/settings/MessagePage.h index 774d31b95..c5b9f7544 100644 --- a/retroshare-gui/src/gui/settings/MessagePage.h +++ b/retroshare-gui/src/gui/settings/MessagePage.h @@ -60,6 +60,7 @@ private slots: void updateDistantMsgs() ; void updateMsgTags() ; void updateLoadEmoticons(); + void updateFontSize(); private: void handleEvent_main_thread(std::shared_ptr event); diff --git a/retroshare-gui/src/gui/settings/MessagePage.ui b/retroshare-gui/src/gui/settings/MessagePage.ui index fd55218e8..d2c44e69e 100644 --- a/retroshare-gui/src/gui/settings/MessagePage.ui +++ b/retroshare-gui/src/gui/settings/MessagePage.ui @@ -16,8 +16,8 @@ 0 - - + + Distant messages: @@ -52,7 +52,7 @@ - + Reading @@ -65,17 +65,37 @@ - - + + - + + + Qt::Horizontal + + + + 40 + 20 + + + + + + - Open messages in + Minimum font size - + + + 10 + + + 64 + + @@ -93,10 +113,24 @@ + + + + + + Open messages in + + + + + + + + - + Tags From 43d64bf0c5aa76a3726310b3598880eeca6de2d2 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 9 Feb 2025 21:05:11 +0100 Subject: [PATCH 16/84] added abstract item model for identity --- retroshare-gui/src/gui/Identity/IdDialog.cpp | 222 +++-- retroshare-gui/src/gui/Identity/IdDialog.h | 11 +- retroshare-gui/src/gui/Identity/IdDialog.ui | 46 +- .../src/gui/Identity/IdentityListModel.cpp | 814 ++++++++++++++++++ .../src/gui/Identity/IdentityListModel.h | 219 +++++ retroshare-gui/src/retroshare-gui.pro | 2 + 6 files changed, 1142 insertions(+), 172 deletions(-) create mode 100644 retroshare-gui/src/gui/Identity/IdentityListModel.cpp create mode 100644 retroshare-gui/src/gui/Identity/IdentityListModel.h diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index 032acaa2d..23556d3ad 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -31,6 +31,8 @@ #include "IdDialog.h" #include "ui_IdDialog.h" #include "IdEditDialog.h" +#include "IdentityListModel.h" + #include "gui/RetroShareLink.h" #include "gui/chat/ChatDialog.h" #include "gui/Circles/CreateCircleDialog.h" @@ -92,11 +94,6 @@ /**************************************************************** */ -#define RSID_COL_NICKNAME 0 -#define RSID_COL_KEYID 1 -#define RSID_COL_IDTYPE 2 -#define RSID_COL_VOTES 3 - #define RSIDREP_COL_NAME 0 #define RSIDREP_COL_OPINION 1 #define RSIDREP_COL_COMMENT 2 @@ -168,37 +165,16 @@ IdDialog::IdDialog(QWidget *parent) //mCirclesBroadcastBase = new RsGxsUpdateBroadcastBase(rsGxsCircles, this); //connect(mCirclesBroadcastBase, SIGNAL(fillDisplay(bool)), this, SLOT(updateCirclesDisplay(bool))); - ownItem = new QTreeWidgetItem(); - ownItem->setText(RSID_COL_NICKNAME, tr("My own identities")); - ownItem->setFont(RSID_COL_NICKNAME, ui->idTreeWidget->font()); - ownItem->setData(RSID_COL_VOTES, Qt::DecorationRole,0xff); // this is in order to prevent displaying a reputaiton icon next to these items. + mIdListModel = new RsIdentityListModel(this); - allItem = new QTreeWidgetItem(); - allItem->setText(RSID_COL_NICKNAME, tr("All")); - allItem->setFont(RSID_COL_NICKNAME, ui->idTreeWidget->font()); - allItem->setData(RSID_COL_VOTES, Qt::DecorationRole,0xff); - - contactsItem = new QTreeWidgetItem(); - contactsItem->setText(RSID_COL_NICKNAME, tr("My contacts")); - contactsItem->setFont(RSID_COL_NICKNAME, ui->idTreeWidget->font()); - contactsItem->setData(RSID_COL_VOTES, Qt::DecorationRole,0xff); - - - ui->idTreeWidget->insertTopLevelItem(0, ownItem); - ui->idTreeWidget->insertTopLevelItem(0, allItem); - ui->idTreeWidget->insertTopLevelItem(0, contactsItem ); + ui->idTreeWidget->setModel(mIdListModel); ui->treeWidget_membership->clear(); ui->treeWidget_membership->setItemDelegateForColumn(CIRCLEGROUP_CIRCLE_COL_GROUPNAME,new GxsIdTreeItemDelegate()); - /* Setup UI helper */ mStateHelper = new UIStateHelper(this); -// mStateHelper->addWidget(IDDIALOG_IDLIST, ui->idTreeWidget); - mStateHelper->addLoadPlaceholder(IDDIALOG_IDLIST, ui->idTreeWidget, false); - mStateHelper->addClear(IDDIALOG_IDLIST, ui->idTreeWidget); - //mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui->lineEdit_Nickname); mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui->lineEdit_PublishTS); mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui->lineEdit_KeyId); mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui->lineEdit_Type); @@ -257,8 +233,7 @@ IdDialog::IdDialog(QWidget *parent) connect(ui->inviteButton, SIGNAL(clicked()), this, SLOT(sendInvite())); connect(ui->editButton, SIGNAL(clicked()), this, SLOT(editIdentity())); - connect( ui->idTreeWidget, &RSTreeWidget::itemDoubleClicked, - this, &IdDialog::chatIdentityItem ); + connect( ui->idTreeWidget, &RSTreeWidget::itemDoubleClicked, this, &IdDialog::chatIdentityItem ); ui->editButton->hide(); @@ -340,46 +315,27 @@ IdDialog::IdDialog(QWidget *parent) ui->toolButton_New->setMenu(menu); /* Add filter actions */ - QTreeWidgetItem *headerItem = ui->idTreeWidget->headerItem(); - QString headerText = headerItem->text(RSID_COL_NICKNAME); - ui->filterLineEdit->addFilter(QIcon(), headerText, RSID_COL_NICKNAME, QString("%1 %2").arg(tr("Search"), headerText)); - - headerItem->setData(RSID_COL_VOTES,Qt::UserRole,tr("Reputation")); + ui->filterLineEdit->addFilter(QIcon(), tr("Name"), RsIdentityListModel::COLUMN_THREAD_NAME, QString("%1 %2").arg(tr("Search"), tr("Search name"))); + ui->filterLineEdit->addFilter(QIcon(), tr("ID"), RsIdentityListModel::COLUMN_THREAD_ID, tr("Search ID")); /* Set initial section sizes */ - QHeaderView * circlesheader = ui->treeWidget_membership->header () ; - circlesheader->resizeSection (CIRCLEGROUP_CIRCLE_COL_GROUPNAME, QFontMetricsF(ui->idTreeWidget->font()).width("Circle name")*1.5) ; - ui->treeWidget_membership->setColumnWidth(CIRCLEGROUP_CIRCLE_COL_GROUPNAME, 270); - - ui->filterLineEdit->addFilter(QIcon(), tr("ID"), RSID_COL_KEYID, tr("Search ID")); + QHeaderView * circlesheader = ui->treeWidget_membership->header () ; + circlesheader->resizeSection (CIRCLEGROUP_CIRCLE_COL_GROUPNAME, QFontMetricsF(ui->idTreeWidget->font()).width("Circle name")*1.5) ; + ui->treeWidget_membership->setColumnWidth(CIRCLEGROUP_CIRCLE_COL_GROUPNAME, 270); /* Setup tree */ - ui->idTreeWidget->sortByColumn(RSID_COL_NICKNAME, Qt::AscendingOrder); + ui->idTreeWidget->sortByColumn(RsIdentityListModel::COLUMN_THREAD_NAME, Qt::AscendingOrder); - ui->idTreeWidget->enableColumnCustomize(true); - ui->idTreeWidget->setColumnCustomizable(RSID_COL_NICKNAME, false); - - ui->idTreeWidget->setColumnHidden(RSID_COL_IDTYPE, true); - ui->idTreeWidget->setColumnHidden(RSID_COL_KEYID, true); - - /* Set initial column width */ - int fontWidth = QFontMetricsF(ui->idTreeWidget->font()).width("W"); - ui->idTreeWidget->setColumnWidth(RSID_COL_NICKNAME, 14 * fontWidth); - ui->idTreeWidget->setColumnWidth(RSID_COL_KEYID, 20 * fontWidth); - ui->idTreeWidget->setColumnWidth(RSID_COL_IDTYPE, 18 * fontWidth); - ui->idTreeWidget->setColumnWidth(RSID_COL_VOTES, 2 * fontWidth); + ui->idTreeWidget->setColumnHidden(RsIdentityListModel::COLUMN_THREAD_OWNER, true); + ui->idTreeWidget->setColumnHidden(RsIdentityListModel::COLUMN_THREAD_ID, true); ui->idTreeWidget->setItemDelegate(new RSElidedItemDelegate()); - ui->idTreeWidget->setItemDelegateForColumn( - RSID_COL_NICKNAME, - new GxsIdTreeItemDelegate()); - ui->idTreeWidget->setItemDelegateForColumn( - RSID_COL_VOTES, - new ReputationItemDelegate(RsReputationLevel(0xff))); + ui->idTreeWidget->setItemDelegateForColumn( RsIdentityListModel::COLUMN_THREAD_NAME, new GxsIdTreeItemDelegate()); + ui->idTreeWidget->setItemDelegateForColumn( RsIdentityListModel::COLUMN_THREAD_REPUTATION, new ReputationItemDelegate(RsReputationLevel(0xff))); /* Set header resize modes and initial section sizes */ QHeaderView * idheader = ui->idTreeWidget->header(); - QHeaderView_setSectionResizeModeColumn(idheader, RSID_COL_VOTES, QHeaderView::ResizeToContents); + QHeaderView_setSectionResizeModeColumn(idheader, RsIdentityListModel::COLUMN_THREAD_REPUTATION, QHeaderView::ResizeToContents); idheader->setStretchLastSection(true); mStateHelper->setActive(IDDIALOG_IDDETAILS, false); @@ -1266,40 +1222,41 @@ static QString getHumanReadableDuration(uint32_t seconds) void IdDialog::processSettings(bool load) { - Settings->beginGroup("IdDialog"); - - // state of peer tree - ui->idTreeWidget->processSettings(load); - - if (load) { - // load settings - - // filterColumn - ui->filterLineEdit->setCurrentFilter(Settings->value("filterColumn", RSID_COL_NICKNAME).toInt()); - - // state of splitter - ui->mainSplitter->restoreState(Settings->value("splitter").toByteArray()); - - //Restore expanding - allItem->setExpanded(Settings->value("ExpandAll", QVariant(true)).toBool()); - ownItem->setExpanded(Settings->value("ExpandOwn", QVariant(true)).toBool()); - contactsItem->setExpanded(Settings->value("ExpandContacts", QVariant(true)).toBool()); - } else { - // save settings - - // filterColumn - Settings->setValue("filterColumn", ui->filterLineEdit->currentFilter()); - - // state of splitter - Settings->setValue("splitter", ui->mainSplitter->saveState()); - - //save expanding - Settings->setValue("ExpandAll", allItem->isExpanded()); - Settings->setValue("ExpandContacts", contactsItem->isExpanded()); - Settings->setValue("ExpandOwn", ownItem->isExpanded()); - } - - Settings->endGroup(); +#warning TODO +// Settings->beginGroup("IdDialog"); +// +// // state of peer tree +// ui->idTreeWidget->processSettings(load); +// +// if (load) { +// // load settings +// +// // filterColumn +// ui->filterLineEdit->setCurrentFilter(Settings->value("filterColumn", RSID_COL_NICKNAME).toInt()); +// +// // state of splitter +// ui->mainSplitter->restoreState(Settings->value("splitter").toByteArray()); +// +// //Restore expanding +// allItem->setExpanded(Settings->value("ExpandAll", QVariant(true)).toBool()); +// ownItem->setExpanded(Settings->value("ExpandOwn", QVariant(true)).toBool()); +// contactsItem->setExpanded(Settings->value("ExpandContacts", QVariant(true)).toBool()); +// } else { +// // save settings +// +// // filterColumn +// Settings->setValue("filterColumn", ui->filterLineEdit->currentFilter()); +// +// // state of splitter +// Settings->setValue("splitter", ui->mainSplitter->saveState()); +// +// //save expanding +// Settings->setValue("ExpandAll", allItem->isExpanded()); +// Settings->setValue("ExpandContacts", contactsItem->isExpanded()); +// Settings->setValue("ExpandOwn", ownItem->isExpanded()); +// } +// +// Settings->endGroup(); } void IdDialog::filterChanged(const QString& /*text*/) @@ -2076,6 +2033,28 @@ void IdDialog::updateDisplay(bool complete) } } +std::list IdDialog::getSelectedIdentities() const +{ + QModelIndexList selectedIndexes = ui->idTreeWidget->selectionModel()->selectedIndexes(); + std::list res; + + for(auto indx:selectedIndexes) + if(indx.column() == RsIdentityListModel::COLUMN_THREAD_NAME) // this removes duplicates + res.push_back(mIdListModel->getIdentity(indx)); + + return res; +} + +RsGxsId IdDialog::getSelectedIdentity() const +{ + auto lst = getSelectedIdentities(); + + if(lst.size() != 1) + return RsGxsId(); + else + return lst.front(); +} + void IdDialog::addIdentity() { IdEditDialog dlg(this); @@ -2085,45 +2064,25 @@ void IdDialog::addIdentity() void IdDialog::removeIdentity() { - QTreeWidgetItem *item = ui->idTreeWidget->currentItem(); - if (!item) - { -#ifdef ID_DEBUG - std::cerr << "IdDialog::editIdentity() Invalid item"; - std::cerr << std::endl; -#endif - return; - } + RsGxsId id = getSelectedIdentity(); + + if(id.isNull()) + return; if ((QMessageBox::question(this, tr("Really delete?"), tr("Do you really want to delete this identity?\nThis cannot be undone."), QMessageBox::Yes|QMessageBox::No, QMessageBox::No))== QMessageBox::Yes) - { - std::string keyId = item->text(RSID_COL_KEYID).toStdString(); - RsGxsId kid(keyId); - - rsIdentity->deleteIdentity(kid); - } + rsIdentity->deleteIdentity(id); } void IdDialog::editIdentity() { - QTreeWidgetItem *item = ui->idTreeWidget->currentItem(); - if (!item) - { -#ifdef ID_DEBUG - std::cerr << "IdDialog::editIdentity() Invalid item"; - std::cerr << std::endl; -#endif - return; - } + RsGxsId id = getSelectedIdentity(); - RsGxsGroupId keyId = RsGxsGroupId(item->text(RSID_COL_KEYID).toStdString()); - if (keyId.isNull()) { - return; - } + if(id.isNull()) + return; - IdEditDialog dlg(this); - dlg.setupExistingId(keyId); - dlg.exec(); + IdEditDialog dlg(this); + dlg.setupExistingId(RsGxsGroupId(id)); + dlg.exec(); } void IdDialog::filterIds() @@ -2131,7 +2090,18 @@ void IdDialog::filterIds() int filterColumn = ui->filterLineEdit->currentFilter(); QString text = ui->filterLineEdit->text(); - ui->idTreeWidget->filterItems(filterColumn, text); + RsIdentityListModel::FilterType ft; + + switch(filterColumn) + { + case RsIdentityListModel::COLUMN_THREAD_ID: ft = RsIdentityListModel::FILTER_TYPE_ID; + break; + default: + case RsIdentityListModel::COLUMN_THREAD_NAME: ft = RsIdentityListModel::FILTER_TYPE_NAME; + break; + + } + mIdListModel->setFilter(ft,{ text }); } void IdDialog::IdListCustomPopupMenu( QPoint ) diff --git a/retroshare-gui/src/gui/Identity/IdDialog.h b/retroshare-gui/src/gui/Identity/IdDialog.h index 403b3a437..e8d0c52df 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.h +++ b/retroshare-gui/src/gui/Identity/IdDialog.h @@ -35,6 +35,7 @@ class IdDialog; class UIStateHelper; class QTreeWidgetItem; +class RsIdentityListModel; class IdDialog : public MainPage { @@ -134,9 +135,6 @@ private: private: UIStateHelper *mStateHelper; - QTreeWidgetItem *contactsItem; - QTreeWidgetItem *allItem; - QTreeWidgetItem *ownItem; QTreeWidgetItem *mExternalBelongingCircleItem; QTreeWidgetItem *mExternalOtherCircleItem; QTreeWidgetItem *mMyCircleItem; @@ -145,10 +143,15 @@ private: void saveExpandedCircleItems(std::vector &expanded_root_items, std::set& expanded_circle_items) const; void restoreExpandedCircleItems(const std::vector& expanded_root_items,const std::set& expanded_circle_items); - RsGxsGroupId mId; + RsGxsId getSelectedIdentity() const; + std::list getSelectedIdentities() const; + + RsGxsGroupId mId; RsGxsGroupId mIdToNavigate; int filter; + RsIdentityListModel *mIdListModel; + void handleEvent_main_thread(std::shared_ptr event); RsEventsHandlerId_t mEventHandlerId_identity; RsEventsHandlerId_t mEventHandlerId_circles; diff --git a/retroshare-gui/src/gui/Identity/IdDialog.ui b/retroshare-gui/src/gui/Identity/IdDialog.ui index 69d1cd8fd..faab8a48b 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.ui +++ b/retroshare-gui/src/gui/Identity/IdDialog.ui @@ -91,7 +91,7 @@ - 12 + 12 75 true @@ -211,7 +211,7 @@ - + 0 @@ -236,39 +236,6 @@ true - - false - - - - Persons - - - - - Identity ID - - - - - Owned by - - - - - - - - Votes - - - AlignLeading|AlignVCenter - - - - :/icons/flag-green.png:/icons/flag-green.png - - @@ -296,8 +263,8 @@ 0 0 - 513 - 764 + 535 + 784 @@ -1080,11 +1047,6 @@ border-image: url(:/images/closepressed.png) QComboBox
gui/common/RSComboBox.h
- - RSTreeWidget - QTreeWidget -
gui/common/RSTreeWidget.h
-
ElidedLabel QLabel diff --git a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp new file mode 100644 index 000000000..d7b5f2449 --- /dev/null +++ b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp @@ -0,0 +1,814 @@ +/******************************************************************************* + * retroshare-gui/src/gui/msgs/RsFriendListModel.cpp * + * * + * Copyright 2019 by Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "gui/common/AvatarDefs.h" +#include "util/qtthreadsutils.h" +#include "util/HandleRichText.h" +#include "util/DateTime.h" +#include "gui/gxs/GxsIdDetails.h" +#include "retroshare/rsexpr.h" + +#include "IdentityListModel.h" + +//#define DEBUG_MODEL +//#define DEBUG_MODEL_INDEX + +std::ostream& operator<<(std::ostream& o, const QModelIndex& i);// defined elsewhere + +static const uint16_t UNDEFINED_GROUP_INDEX_VALUE = (sizeof(uintptr_t)==4)?0x1ff:0xffff; // max value for 9 bits +static const uint16_t UNDEFINED_NODE_INDEX_VALUE = (sizeof(uintptr_t)==4)?0x1ff:0xffff; // max value for 9 bits +static const uint16_t UNDEFINED_PROFILE_INDEX_VALUE = (sizeof(uintptr_t)==4)?0xfff:0xffff; // max value for 12 bits + +const QString RsIdentityListModel::FilterString("filtered"); + +const uint32_t MAX_INTERNAL_DATA_UPDATE_DELAY = 300 ; // re-update the internal data every 5 mins. Should properly cover sleep/wake-up changes. +const uint32_t MAX_NODE_UPDATE_DELAY = 10 ; // re-update the internal data every 5 mins. Should properly cover sleep/wake-up changes. + +static const uint32_t NODE_DETAILS_UPDATE_DELAY = 5; // update each node every 5 secs. + +RsIdentityListModel::RsIdentityListModel(QObject *parent) + : QAbstractItemModel(parent) + , mLastInternalDataUpdate(0), mLastNodeUpdate(0) +{ + mFilterStrings.clear(); +} + +RsIdentityListModel::EntryIndex::EntryIndex() + : type(ENTRY_TYPE_UNKNOWN),category_index(UNDEFINED_GROUP_INDEX_VALUE),identity_index(UNDEFINED_NODE_INDEX_VALUE) +{ +} + +// The index encodes the whole hierarchy of parents. This allows to very efficiently compute indices of the parent of an index. +// +// On 32 bits and 64 bits architectures the format is the following: +// +// 0x [2 bits] [30 bits] +// | | +// | | +// | | +// | +----------------------- identity index +// +-------------------------------- category +// +// Only valid indexes a 0x00->UNDEFINED_INDEX_VALUE-1. + +bool RsIdentityListModel::convertIndexToInternalId(const EntryIndex& e,quintptr& id) +{ + // the internal id is set to the place in the table of items. We simply shift to allow 0 to mean something special. + + id = (((uint32_t)e.type) << 30) + ((uint32_t)e.identity_index); + return true; +} +bool RsIdentityListModel::convertInternalIdToIndex(quintptr ref,EntryIndex& e) +{ + if(ref == 0) + return false ; + + e.category_index = (ref >> 30) & 0x3;// 2 bits + e.identity_index = (ref >> 0) & 0x3fffffff;// 30 bits + + return true; +} + +static QIcon createAvatar(const QPixmap &avatar, const QPixmap &overlay) +{ + int avatarWidth = avatar.width(); + int avatarHeight = avatar.height(); + + QPixmap pixmap(avatar); + + int overlaySize = (avatarWidth > avatarHeight) ? (avatarWidth/2.5) : (avatarHeight/2.5); + int overlayX = avatarWidth - overlaySize; + int overlayY = avatarHeight - overlaySize; + + QPainter painter(&pixmap); + painter.drawPixmap(overlayX, overlayY, overlaySize, overlaySize, overlay); + + QIcon icon; + icon.addPixmap(pixmap); + return icon; +} + +void RsIdentityListModel::preMods() +{ + emit layoutAboutToBeChanged(); +} +void RsIdentityListModel::postMods() +{ + emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(rowCount()-1,columnCount()-1,(void*)NULL)); + emit layoutChanged(); +} + +int RsIdentityListModel::rowCount(const QModelIndex& parent) const +{ + if(parent.column() >= COLUMN_THREAD_NB_COLUMNS) + return 0; + + if(parent.internalId() == 0) + return mTopLevel.size(); + + EntryIndex index; + if(!convertInternalIdToIndex(parent.internalId(),index)) + return 0; + + if(index.type == ENTRY_TYPE_CATEGORY) + return mCategories[index.category_index].child_identity_indices.size(); + else + return 0; +} + +int RsIdentityListModel::columnCount(const QModelIndex &/*parent*/) const +{ + return COLUMN_THREAD_NB_COLUMNS ; +} + +bool RsIdentityListModel::hasChildren(const QModelIndex &parent) const +{ + if(!parent.isValid()) + return true; + + EntryIndex parent_index ; + convertInternalIdToIndex(parent.internalId(),parent_index); + + if(parent_index.type == ENTRY_TYPE_IDENTITY) + return false; + + if(parent_index.type == ENTRY_TYPE_CATEGORY) + return !mCategories[parent_index.category_index].child_identity_indices.empty(); + + return false; +} + +RsIdentityListModel::EntryIndex RsIdentityListModel::EntryIndex::parent() const +{ + EntryIndex i(*this); + + switch(type) + { + case ENTRY_TYPE_CATEGORY: return EntryIndex(); + + case ENTRY_TYPE_IDENTITY: i.type = ENTRY_TYPE_CATEGORY; + i.identity_index = UNDEFINED_NODE_INDEX_VALUE; + break; + case ENTRY_TYPE_UNKNOWN: + //Can be when request root index. + break; + } + + return i; +} + +RsIdentityListModel::EntryIndex RsIdentityListModel::EntryIndex::child(int row,const std::vector& top_level) const +{ + EntryIndex i(*this); + + switch(type) + { + case ENTRY_TYPE_UNKNOWN: + i = top_level[row]; + break; + + case ENTRY_TYPE_CATEGORY: i.type = ENTRY_TYPE_IDENTITY; + i.identity_index = row; + break; + + case ENTRY_TYPE_IDENTITY: i = EntryIndex(); + break; + } + + return i; + +} +uint32_t RsIdentityListModel::EntryIndex::parentRow(int /* nb_groups */) const +{ + switch(type) + { + default: + case ENTRY_TYPE_UNKNOWN : return 0; + case ENTRY_TYPE_CATEGORY : return category_index; + case ENTRY_TYPE_IDENTITY : return identity_index; + } +} + +QModelIndex RsIdentityListModel::index(int row, int column, const QModelIndex& parent) const +{ + if(row < 0 || column < 0 || column >= columnCount(parent) || row >= rowCount(parent)) + return QModelIndex(); + + if(parent.internalId() == 0) + { + quintptr ref ; + + convertIndexToInternalId(mTopLevel[row],ref); + return createIndex(row,column,ref) ; + } + + EntryIndex parent_index ; + convertInternalIdToIndex(parent.internalId(),parent_index); +#ifdef DEBUG_MODEL_INDEX + RsDbg() << "Index row=" << row << " col=" << column << " parent=" << parent << std::endl; +#endif + + quintptr ref; + EntryIndex new_index = parent_index.child(row,mTopLevel); + convertIndexToInternalId(new_index,ref); + +#ifdef DEBUG_MODEL_INDEX + RsDbg() << " returning " << createIndex(row,column,ref) << std::endl; +#endif + + return createIndex(row,column,ref); +} + +QModelIndex RsIdentityListModel::parent(const QModelIndex& index) const +{ + if(!index.isValid()) + return QModelIndex(); + + EntryIndex I ; + convertInternalIdToIndex(index.internalId(),I); + + EntryIndex p = I.parent(); + + if(p.type == ENTRY_TYPE_UNKNOWN) + return QModelIndex(); + + quintptr i; + convertIndexToInternalId(p,i); + + return createIndex(I.parentRow(mCategories.size()),0,i); +} + +Qt::ItemFlags RsIdentityListModel::flags(const QModelIndex& index) const +{ + if (!index.isValid()) + return Qt::ItemFlags(); + + return QAbstractItemModel::flags(index); +} + +QVariant RsIdentityListModel::headerData(int section, Qt::Orientation /*orientation*/, int role) const +{ + if(role == Qt::DisplayRole) + switch(section) + { + case COLUMN_THREAD_NAME: return tr("Name"); + case COLUMN_THREAD_ID: return tr("Id"); + case COLUMN_THREAD_REPUTATION: return tr("Reputation"); + case COLUMN_THREAD_OWNER: return tr("Owner"); + default: + return QVariant(); + } + + return QVariant(); +} + +QVariant RsIdentityListModel::data(const QModelIndex &index, int role) const +{ +#ifdef DEBUG_MESSAGE_MODEL + std::cerr << "calling data(" << index << ") role=" << role << std::endl; +#endif + + if(!index.isValid()) + return QVariant(); + + quintptr ref = (index.isValid())?index.internalId():0 ; + +#ifdef DEBUG_MESSAGE_MODEL + std::cerr << "data(" << index << ")" ; +#endif + + if(!ref) + { +#ifdef DEBUG_MESSAGE_MODEL + std::cerr << " [empty]" << std::endl; +#endif + return QVariant() ; + } + + EntryIndex entry; + + if(!convertInternalIdToIndex(ref,entry)) + { +#ifdef DEBUG_MESSAGE_MODEL + std::cerr << "Bad pointer: " << (void*)ref << std::endl; +#endif + return QVariant() ; + } + + switch(role) + { + case Qt::SizeHintRole: return sizeHintRole(entry,index.column()) ; + case Qt::DisplayRole: return displayRole(entry,index.column()) ; + case Qt::FontRole: return fontRole(entry,index.column()) ; + case Qt::DecorationRole: return decorationRole(entry,index.column()) ; + + case FilterRole: return filterRole(entry,index.column()) ; + case SortRole: return sortRole(entry,index.column()) ; + + default: + return QVariant(); + } +} + +bool RsIdentityListModel::passesFilter(const EntryIndex& e,int /*column*/) const +{ + QString s ; + bool passes_strings = true ; + + if(e.type == ENTRY_TYPE_IDENTITY && !mFilterStrings.empty()) + { + switch(mFilterType) + { + case FILTER_TYPE_ID: s = displayRole(e,COLUMN_THREAD_ID).toString(); + break; + + case FILTER_TYPE_NAME: s = displayRole(e,COLUMN_THREAD_NAME).toString(); + if(s.isNull()) + passes_strings = false; + break; + case FILTER_TYPE_NONE: + RS_ERR("None Type for Filter."); + }; + } + + if(!s.isNull()) + for(auto iter(mFilterStrings.begin()); iter != mFilterStrings.end(); ++iter) + passes_strings = passes_strings && s.contains(*iter,Qt::CaseInsensitive); + + return passes_strings; +} + +QVariant RsIdentityListModel::filterRole(const EntryIndex& e,int column) const +{ + if(passesFilter(e,column)) + return QVariant(FilterString); + + return QVariant(QString()); +} + +uint32_t RsIdentityListModel::updateFilterStatus(ForumModelIndex /*i*/,int /*column*/,const QStringList& /*strings*/) +{ + return 0; +} + + +void RsIdentityListModel::setFilter(FilterType filter_type, const QStringList& strings) +{ +#ifdef DEBUG_MODEL + std::cerr << "Setting filter to filter_type=" << int(filter_type) << " and strings to " ; + foreach(const QString& str,strings) + std::cerr << "\"" << str.toStdString() << "\" " ; + std::cerr << std::endl; +#endif + + preMods(); + + mFilterType = filter_type; + mFilterStrings = strings; + + postMods(); +} + +QVariant RsIdentityListModel::toolTipRole(const EntryIndex& /*fmpe*/,int /*column*/) const +{ + return QVariant(); +} + +QVariant RsIdentityListModel::sizeHintRole(const EntryIndex& e,int col) const +{ + float x_factor = QFontMetricsF(QApplication::font()).height()/14.0f ; + float y_factor = QFontMetricsF(QApplication::font()).height()/14.0f ; + + if(e.type == ENTRY_TYPE_IDENTITY) + y_factor *= 3.0; + + if(e.type == ENTRY_TYPE_CATEGORY) + y_factor *= 1.5; + + switch(col) + { + default: + case COLUMN_THREAD_NAME: return QVariant( QSize(x_factor * 70 , y_factor*14*1.1f )); + case COLUMN_THREAD_ID: return QVariant( QSize(x_factor * 175, y_factor*14*1.1f )); + case COLUMN_THREAD_REPUTATION: return QVariant( QSize(x_factor * 20 , y_factor*14*1.1f )); + case COLUMN_THREAD_OWNER: return QVariant( QSize(x_factor * 70 , y_factor*14*1.1f )); + } +} + +QVariant RsIdentityListModel::sortRole(const EntryIndex& entry,int column) const +{ + switch(column) + { +#warning TODO +// case COLUMN_THREAD_LAST_CONTACT: +// { +// switch(entry.type) +// { +// case ENTRY_TYPE_PROFILE: +// { +// const HierarchicalProfileInformation *prof = getProfileInfo(entry); +// +// if(!prof) +// return QVariant(); +// +// uint32_t last_contact = 0; +// +// for(uint32_t i=0;ichild_node_indices.size();++i) +// last_contact = std::max(last_contact, mLocations[prof->child_node_indices[i]].node_info.lastConnect); +// +// return QVariant(last_contact); +// } +// break; +// default: +// return QVariant(); +// } +// } +// break; + + default: + return displayRole(entry,column); + } +} + +QVariant RsIdentityListModel::fontRole(const EntryIndex& e, int col) const +{ +#ifdef DEBUG_MODEL_INDEX + std::cerr << " font role " << e.type << ", (" << (int)e.group_index << ","<< (int)e.profile_index << ","<< (int)e.node_index << ") col="<< col<<": " << std::endl; +#endif + + int status = onlineRole(e,col).toInt(); + + switch (status) + { + case RS_STATUS_INACTIVE: + { + QFont font ; + QTreeView* myParent = dynamic_cast(QAbstractItemModel::parent()); + if (myParent) + font = myParent->font(); + + font.setBold(true); + + return QVariant(font); + } + default: + return QVariant(); + } +} + +QVariant RsIdentityListModel::displayRole(const EntryIndex& e, int col) const +{ +#ifdef DEBUG_MODEL_INDEX + std::cerr << " Display role " << e.type << ", (" << (int)e.group_index << ","<< (int)e.profile_index << ","<< (int)e.node_index << ") col="<< col<<": "; +#endif + + switch(e.type) + { + case ENTRY_TYPE_CATEGORY: + { + const HierarchicalCategoryInformation *cat = getCategoryInfo(e); + + if(!cat) + return QVariant(); + + switch(col) + { + case COLUMN_THREAD_NAME: +#ifdef DEBUG_MODEL_INDEX + std::cerr << group->group_info.name.c_str() ; +#endif + + if(!cat->child_identity_indices.empty()) + return QVariant(cat->category_name+" (" + QString::number(cat->child_identity_indices.size()) + ")"); + else + return QVariant(cat->category_name); + + default: + return QVariant(); + } + } + break; + + case ENTRY_TYPE_IDENTITY: + { + const HierarchicalIdentityInformation *idinfo = getIdentityInfo(e); + + if(!idinfo) + return QVariant(); + + RsIdentityDetails det; + + if(!rsIdentity->getIdDetails(idinfo->id,det)) + return QVariant(); + +#ifdef DEBUG_MODEL_INDEX + std::cerr << profile->profile_info.name.c_str() ; +#endif + switch(col) + { + case COLUMN_THREAD_NAME: return QVariant(QString::fromUtf8(det.mNickname.c_str())); + case COLUMN_THREAD_ID: return QVariant(QString::fromStdString(det.mId.toStdString()) ); + case COLUMN_THREAD_OWNER: return QVariant(QString::fromStdString(det.mPgpId.toStdString()) ); + case COLUMN_THREAD_REPUTATION: return QVariant(QString::number((uint8_t)det.mReputation.mOverallReputationLevel)); + default: + return QVariant(); + } + } + break; + + default: //ENTRY_TYPE + return QVariant(); + } +} + +// This function makes sure that the internal data gets updated. They are situations where the otification system cannot +// send the information about changes, such as when the computer is put on sleep. + +void RsIdentityListModel::checkInternalData(bool force) +{ + rstime_t now = time(NULL); + + if( (mLastInternalDataUpdate + MAX_INTERNAL_DATA_UPDATE_DELAY < now) || force) + updateInternalData(); +} + +const RsIdentityListModel::HierarchicalCategoryInformation *RsIdentityListModel::getCategoryInfo(const EntryIndex& e) const +{ + if(e.category_index >= mCategories.size()) + return NULL ; + else + return &mCategories[e.category_index]; +} + +const RsIdentityListModel::HierarchicalIdentityInformation *RsIdentityListModel::getIdentityInfo(const EntryIndex& e) const +{ + // First look into the relevant group, then for the correct profile in this group. + + if(e.type != ENTRY_TYPE_IDENTITY) + return NULL ; + + if(e.category_index >= mCategories.size()) + return NULL ; + + if(e.identity_index < mCategories[e.category_index].child_identity_indices.size()) + return &mIdentities[mCategories[e.category_index].child_identity_indices[e.identity_index]]; + else + return &mIdentities[e.identity_index]; +} + +QVariant RsIdentityListModel::decorationRole(const EntryIndex& entry,int col) const +{ + if(col > 0) + return QVariant(); + + switch(entry.type) + { + + case ENTRY_TYPE_CATEGORY: + return QVariant(); + + case ENTRY_TYPE_IDENTITY: + { + const HierarchicalIdentityInformation *hn = getIdentityInfo(entry); + + if(!hn) + return QVariant(); + + QPixmap sslAvatar; + AvatarDefs::getAvatarFromGxsId(hn->id, sslAvatar); + + return QVariant(QIcon(sslAvatar)); + } + default: return QVariant(); + } +} + +void RsIdentityListModel::clear() +{ + preMods(); + + mIdentities.clear(); + mTopLevel.clear(); + + mCategories.clear(); + mCategories.resize(3); + mCategories[0].category_name = tr("My own identities"); + mCategories[1].category_name = tr("My contacts"); + mCategories[2].category_name = tr("All"); + + postMods(); + + emit friendListChanged(); +} + +void RsIdentityListModel::debug_dump() const +{ +// std::cerr << "==== FriendListModel Debug dump ====" << std::endl; +// +// for(uint32_t j=0;jid; + else + return RsGxsId(); +} + +RsIdentityListModel::EntryType RsIdentityListModel::getType(const QModelIndex& i) const +{ + if(!i.isValid()) + return ENTRY_TYPE_UNKNOWN; + + EntryIndex e; + if(!convertInternalIdToIndex(i.internalId(),e)) + return ENTRY_TYPE_UNKNOWN; + + return e.type; +} + +void RsIdentityListModel::setIdentities(const std::list& identities_meta) +{ + preMods(); + beginResetModel(); + clear(); + + for(auto id:identities_meta) + { + HierarchicalIdentityInformation idinfo; + idinfo.id = RsGxsId(id.mGroupId); + + if(rsIdentity->isOwnId(idinfo.id)) + mCategories[CATEGORY_OWN].child_identity_indices.push_back(mIdentities.size()); + else if(rsIdentity->isARegularContact(RsGxsId(id.mGroupId))) + mCategories[CATEGORY_CTS].child_identity_indices.push_back(mIdentities.size()); + else + mCategories[CATEGORY_ALL].child_identity_indices.push_back(mIdentities.size()); + + mIdentities.push_back(idinfo); + } + + if (mCategories.size()>0) + { + beginInsertRows(QModelIndex(),0,mCategories.size()-1); + endInsertRows(); + } + + endResetModel(); + postMods(); + + mLastInternalDataUpdate = time(NULL); + +} + +void RsIdentityListModel::updateInternalData() +{ + RsThread::async([this]() + { + // 1 - get message data from p3GxsForums + + std::list *ids = new std::list(); + + if(!rsIdentity->getIdentitiesSummaries(*ids)) + { + std::cerr << __PRETTY_FUNCTION__ << " failed to retrieve identity metadata." << std::endl; + return; + } + + // 3 - update the model in the UI thread. + + RsQThreadUtils::postToObject( [ids,this]() + { + /* Here it goes any code you want to be executed on the Qt Gui + * thread, for example to update the data model with new information + * after a blocking call to RetroShare API complete, note that + * Qt::QueuedConnection is important! + */ + + setIdentities(*ids) ; + + delete ids; + + + }, this ); + + }); + +} + +void RsIdentityListModel::collapseItem(const QModelIndex& index) +{ + if(getType(index) != ENTRY_TYPE_CATEGORY) + return; + + EntryIndex entry; + + if(!convertInternalIdToIndex(index.internalId(),entry)) + return; + + mExpandedCategories[entry.category_index] = false; + + // apparently we cannot be subtle here. + emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mTopLevel.size()-1,columnCount()-1,(void*)NULL)); +} + +void RsIdentityListModel::expandItem(const QModelIndex& index) +{ + if(getType(index) != ENTRY_TYPE_CATEGORY) + return; + + EntryIndex entry; + + if(!convertInternalIdToIndex(index.internalId(),entry)) + return; + + mExpandedCategories[entry.category_index] = true; + + // apparently we cannot be subtle here. + emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mTopLevel.size()-1,columnCount()-1,(void*)NULL)); +} + +bool RsIdentityListModel::isCategoryExpanded(const EntryIndex& e) const +{ + return true; +#warning TODO +// if(e.type != ENTRY_TYPE_CATEGORY) +// return false; +// +// EntryIndex entry; +// +// if(!convertInternalIdToIndex(e.internalId(),entry)) +// return false; +// +// return mExpandedCategories[entry.category_index]; +} + diff --git a/retroshare-gui/src/gui/Identity/IdentityListModel.h b/retroshare-gui/src/gui/Identity/IdentityListModel.h new file mode 100644 index 000000000..b6e410ae2 --- /dev/null +++ b/retroshare-gui/src/gui/Identity/IdentityListModel.h @@ -0,0 +1,219 @@ +/******************************************************************************* + * retroshare-gui/src/gui/msgs/RsFriendListModel.h * + * * + * Copyright 2019 by Cyril Soler * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + +#pragma once + +#include +#include + +#include "retroshare/rsstatus.h" +#include "retroshare/rsmsgs.h" +#include "retroshare/rspeers.h" +#include "retroshare/rsidentity.h" + +typedef uint32_t ForumModelIndex; + +// This class is the item model used by Qt to display the information + +class RsIdentityListModel : public QAbstractItemModel +{ + Q_OBJECT + +public: + explicit RsIdentityListModel(QObject *parent = NULL); + ~RsIdentityListModel(){} + + enum Columns { + COLUMN_THREAD_NAME = 0x00, + COLUMN_THREAD_ID = 0x01, + COLUMN_THREAD_OWNER = 0x02, + COLUMN_THREAD_REPUTATION = 0x03, + COLUMN_THREAD_NB_COLUMNS = 0x04 + }; + + enum Roles{ SortRole = Qt::UserRole+1, + StatusRole = Qt::UserRole+2, + UnreadRole = Qt::UserRole+3, + FilterRole = Qt::UserRole+4, + }; + + enum FilterType{ FILTER_TYPE_NONE = 0x00, + FILTER_TYPE_ID = 0x01, + FILTER_TYPE_NAME = 0x02 + }; + + enum EntryType{ ENTRY_TYPE_UNKNOWN = 0x00, + ENTRY_TYPE_CATEGORY = 0x01, + ENTRY_TYPE_IDENTITY = 0x02 + }; + + static const int CATEGORY_OWN = 0x00; + static const int CATEGORY_CTS = 0x01; + static const int CATEGORY_ALL = 0x02; + + struct HierarchicalCategoryInformation + { + QString category_name; + std::vector child_identity_indices; // index in the array of hierarchical profiles + }; + struct HierarchicalIdentityInformation + { + RsGxsId id; + }; + + // This structure encodes the position of a node in the hierarchy. The type tells which of the index fields are valid. + + struct EntryIndex + { + public: + EntryIndex(); + + EntryType type; // type of the entry (group,profile,location) + + // Indices w.r.t. parent. The set of indices entirely determines the position of the entry in the hierarchy. + // An index of 0xff means "undefined" + + uint16_t category_index; // index of the category in the mCategory array + uint16_t identity_index; // index of the identity in its own category + + EntryIndex parent() const; + EntryIndex child(int row,const std::vector& top_level) const; + uint32_t parentRow(int) const; + }; + + QModelIndex root() const{ return createIndex(0,0,(void*)NULL) ;} + QModelIndex getIndexOfGroup(const RsNodeGroupId& mid) const; + + static const QString FilterString ; + + // This method will asynchroneously update the data + + EntryType getType(const QModelIndex&) const; + + RsGxsId getIdentity(const QModelIndex&) const; + + void setFilter(FilterType filter_type, const QStringList& strings) ; + + void expandItem(const QModelIndex&) ; + void collapseItem(const QModelIndex&) ; + + // Overloaded methods from QAbstractItemModel + + int rowCount(const QModelIndex& parent = QModelIndex()) const override; + int columnCount(const QModelIndex &parent = QModelIndex()) const override; + bool hasChildren(const QModelIndex &parent = QModelIndex()) const override; + + QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const override; + QModelIndex parent(const QModelIndex& child) const override; + Qt::ItemFlags flags(const QModelIndex& index) const override; + + QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + + void clear() ; + + /* Color definitions (for standard see default.qss) */ + QColor mTextColorGroup; + QColor mTextColorStatus[RS_STATUS_COUNT]; + +private: + const HierarchicalCategoryInformation *getCategoryInfo (const EntryIndex&) const; + const HierarchicalIdentityInformation *getIdentityInfo(const EntryIndex&) const; + + bool isCategoryExpanded(const EntryIndex& e) const; + void checkIdentity(HierarchicalIdentityInformation& node); + + std::map::const_iterator checkProfileIndex(const RsPgpId& pgp_id, + std::map& pgp_indices, + std::vector& mProfiles, + bool create); + + std::map::const_iterator createInvalidatedProfile(const RsPgpId& pgp_id, + const RsPgpFingerprint& fpr, + std::map& pgp_indices, + std::vector& mProfiles); + + QVariant sizeHintRole (const EntryIndex& e, int col) const; + QVariant displayRole (const EntryIndex& e, int col) const; + QVariant decorationRole(const EntryIndex& e, int col) const; + QVariant toolTipRole (const EntryIndex& e, int col) const; + QVariant statusRole (const EntryIndex& e, int col) const; + QVariant sortRole (const EntryIndex& e, int col) const; + QVariant fontRole (const EntryIndex& e, int col) const; + QVariant textColorRole (const EntryIndex& e, int col) const; + QVariant onlineRole (const EntryIndex& e, int col) const; + QVariant filterRole (const EntryIndex& e, int col) const; + + /*! + * \brief debug_dump + * Dumps the hierarchy of posts in the terminal, to allow checking whether the internal representation is correct. + */ + +public slots: + void checkInternalData(bool force); + void debug_dump() const; + +signals: + void dataLoaded(); // emitted after the messages have been set. Can be used to updated the UI. + void friendListChanged(); // emitted after the messages have been set. Can be used to updated the UI. + void dataAboutToLoad(); + +private: + void updateInternalData(); + void setIdentities(const std::list& identities_meta); + bool passesFilter(const EntryIndex &e, int column) const; + + void preMods() ; + void postMods() ; + + void *getParentRef(void *ref,int& row) const; + void *getChildRef(void *ref,int row) const; + int getChildrenCount(void *ref) const; + + static bool convertIndexToInternalId(const EntryIndex& e,quintptr& ref); + static bool convertInternalIdToIndex(quintptr ref, EntryIndex& e); + + uint32_t updateFilterStatus(ForumModelIndex i,int column,const QStringList& strings); + + QStringList mFilterStrings; + FilterType mFilterType; + + rstime_t mLastInternalDataUpdate; + rstime_t mLastNodeUpdate;; + + // The 3 vectors below store thehierarchical information for groups, profiles and locations, + // meaning which is the child/parent of which. The actual group/profile/node data are also stored in the + // structure. + + mutable std::vector mCategories; + mutable std::vector mIdentities; + + // The top level list contains all nodes to display, which type depends on the option to display groups or not. + // Idices in the list may be profile indices or group indices. In the former case the profile child index refers to + // the inde in the mProfiles tab, whereas in the the later case, the child index refers to the index of the profile in the + // group it belows to. + + std::vector mTopLevel; + + // keeps track of expanded/collapsed items, so as to only show icon for collapsed profiles + + std::vector mExpandedCategories; +}; + diff --git a/retroshare-gui/src/retroshare-gui.pro b/retroshare-gui/src/retroshare-gui.pro index d73117b84..86ebbed07 100644 --- a/retroshare-gui/src/retroshare-gui.pro +++ b/retroshare-gui/src/retroshare-gui.pro @@ -1257,6 +1257,7 @@ identities { HEADERS += \ gui/Identity/IdDialog.h \ + gui/Identity/IdentityListModel.h \ gui/Identity/IdEditDialog.h \ gui/Identity/IdDetailsDialog.h \ @@ -1266,6 +1267,7 @@ identities { SOURCES += \ gui/Identity/IdDialog.cpp \ + gui/Identity/IdentityListModel.cpp \ gui/Identity/IdEditDialog.cpp \ gui/Identity/IdDetailsDialog.cpp \ From 6d394c9f55bdf62afc32529ceae1645ae7c1ab86 Mon Sep 17 00:00:00 2001 From: defnax Date: Mon, 10 Feb 2025 19:41:19 +0100 Subject: [PATCH 17/84] Added for channel composer default size settings --- .../src/gui/common/GroupTreeWidget.cpp | 26 +++ .../src/gui/common/GroupTreeWidget.h | 3 + .../src/gui/gxs/GxsGroupFrameDialog.cpp | 19 -- .../src/gui/gxs/GxsGroupFrameDialog.h | 3 +- .../src/gui/settings/MessagePage.ui | 164 ++++++++++-------- retroshare-gui/src/util/RichTextEdit.cpp | 23 +++ retroshare-gui/src/util/RichTextEdit.h | 2 + 7 files changed, 149 insertions(+), 91 deletions(-) diff --git a/retroshare-gui/src/gui/common/GroupTreeWidget.cpp b/retroshare-gui/src/gui/common/GroupTreeWidget.cpp index 0597a652c..f84010016 100644 --- a/retroshare-gui/src/gui/common/GroupTreeWidget.cpp +++ b/retroshare-gui/src/gui/common/GroupTreeWidget.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include @@ -67,6 +68,8 @@ GroupTreeWidget::GroupTreeWidget(QWidget *parent) : connect(ui->treeWidget, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(itemActivated(QTreeWidgetItem*,int))); } + updateFontSize(); + int H = QFontMetricsF(ui->treeWidget->font()).height() ; #if QT_VERSION < QT_VERSION_CHECK(5,11,0) int W = QFontMetricsF(ui->treeWidget->font()).width("_") ; @@ -667,3 +670,26 @@ void GroupTreeWidget::sort() { ui->treeWidget->resort(); } + +void GroupTreeWidget::showEvent(QShowEvent *event) +{ + if (!event->spontaneous()) { + updateFontSize(); + } +} + +void GroupTreeWidget::updateFontSize() +{ +#if defined(Q_OS_DARWIN) + int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 13).toInt(); +#else + int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 11).toInt(); +#endif + QFont newFont = ui->treeWidget->font(); + if (newFont.pointSize() != customFontSize) { + newFont.setPointSize(customFontSize); + QFontMetricsF fontMetrics(newFont); + ui->treeWidget->setFont(newFont); + } +} + diff --git a/retroshare-gui/src/gui/common/GroupTreeWidget.h b/retroshare-gui/src/gui/common/GroupTreeWidget.h index b27c37014..7c95ec757 100644 --- a/retroshare-gui/src/gui/common/GroupTreeWidget.h +++ b/retroshare-gui/src/gui/common/GroupTreeWidget.h @@ -30,6 +30,7 @@ class QToolButton; class RshareSettings; class RSTreeWidgetItemCompareRole; class RSTreeWidget; +class QShowEvent; #define GROUPTREEWIDGET_COLOR_STANDARD -1 #define GROUPTREEWIDGET_COLOR_CATEGORY 0 @@ -142,6 +143,7 @@ signals: protected: void changeEvent(QEvent *e); + virtual void showEvent(QShowEvent *) override; private slots: void customContextMenuRequested(const QPoint &pos); @@ -151,6 +153,7 @@ private slots: void distantSearch(); void sort(); + void updateFontSize(); private: void calculateScore(QTreeWidgetItem *item, const QString &filterText); diff --git a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp index a4789b7d9..069c51b79 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp +++ b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp @@ -193,9 +193,6 @@ void GxsGroupFrameDialog::showEvent(QShowEvent* /*event*/) bool empty = mCachedGroupMetas.empty() || children==0; updateDisplay( empty ); - - updateFontSize(); - } void GxsGroupFrameDialog::paintEvent(QPaintEvent *pe) @@ -1277,19 +1274,3 @@ void GxsGroupFrameDialog::distantRequestGroupData() checkRequestGroup(group_id) ; } -void GxsGroupFrameDialog::updateFontSize() -{ -#if defined(Q_OS_DARWIN) - int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 13).toInt(); -#else - int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 11).toInt(); -#endif - QFont newFont = ui->groupTreeWidget->font(); - if (newFont.pointSize() != customFontSize) { - newFont.setPointSize(customFontSize); - QFontMetricsF fontMetrics(newFont); - ui->groupTreeWidget->setFont(newFont); - } -} - - diff --git a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.h b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.h index a70e6c890..81bba553d 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.h +++ b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.h @@ -110,8 +110,7 @@ protected: void updateGroupStatisticsReal(const RsGxsGroupId &groupId); void updateMessageSummaryListReal(RsGxsGroupId groupId); - void updateFontSize(); - + private slots: void todo(); diff --git a/retroshare-gui/src/gui/settings/MessagePage.ui b/retroshare-gui/src/gui/settings/MessagePage.ui index d2c44e69e..a0579ab69 100644 --- a/retroshare-gui/src/gui/settings/MessagePage.ui +++ b/retroshare-gui/src/gui/settings/MessagePage.ui @@ -17,43 +17,14 @@ - - - - Distant messages: - - - - - - - Everyone - - - - - Contacts - - - - - Nobody - - - - - - - - Accept encrypted distant messages from - - - - - - + + + 0 + 0 + + Reading @@ -65,40 +36,6 @@ - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Minimum font size - - - - - - - 10 - - - 64 - - - - - @@ -130,7 +67,7 @@
- + Tags @@ -206,6 +143,93 @@ + + + + Distant messages: + + + + + + + Everyone + + + + + Contacts + + + + + Nobody + + + + + + + + Accept encrypted distant messages from + + + + + + + + + + + 0 + 0 + + + + Fonts + + + + + + + + Qt::LeftToRight + + + Minimum font size + + + + + + + 10 + + + 64 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + diff --git a/retroshare-gui/src/util/RichTextEdit.cpp b/retroshare-gui/src/util/RichTextEdit.cpp index 9d4596a82..9d88d989f 100644 --- a/retroshare-gui/src/util/RichTextEdit.cpp +++ b/retroshare-gui/src/util/RichTextEdit.cpp @@ -614,3 +614,26 @@ void RichTextEdit::checkLength(){ void RichTextEdit::setPlaceHolderTextPosted() { f_textedit->setPlaceholderText(tr("Text (optional)")); } + +void RichTextEdit::showEvent(QShowEvent *event) +{ + if (!event->spontaneous()) { + updateFontSize(); + } +} + +void RichTextEdit::updateFontSize() +{ +#if defined(Q_OS_DARWIN) + int customFontSize = Settings->valueFromGroup("Messages", "MinimumFontSize", 13).toInt(); +#else + int customFontSize = Settings->valueFromGroup("Messages", "MinimumFontSize", 12).toInt(); +#endif + QFont newFont = f_textedit->font(); + if (newFont.pointSize() != customFontSize) { + newFont.setPointSize(customFontSize); + QFontMetricsF fontMetrics(newFont); + f_textedit->setFont(newFont); + f_fontsize->setCurrentIndex(f_fontsize->findText(QString::number(newFont.pointSize()))); + } +} diff --git a/retroshare-gui/src/util/RichTextEdit.h b/retroshare-gui/src/util/RichTextEdit.h index aae9d20ab..a621a8514 100644 --- a/retroshare-gui/src/util/RichTextEdit.h +++ b/retroshare-gui/src/util/RichTextEdit.h @@ -69,6 +69,7 @@ signals: void insertImage(); void textSource(); void checkLength(); + void updateFontSize(); protected: void mergeFormatOnWordOrSelection(const QTextCharFormat &format); @@ -78,6 +79,7 @@ signals: void list(bool checked, QTextListFormat::Style style); void indent(int delta); void focusInEvent(QFocusEvent *event); + virtual void showEvent(QShowEvent *); QStringList m_paragraphItems; int m_fontsize_h1; From a5752ec4d38461155b4319fbbac4050014cf0da1 Mon Sep 17 00:00:00 2001 From: defnax Date: Mon, 10 Feb 2025 20:03:43 +0100 Subject: [PATCH 18/84] Fixed alignment for the attachment counter --- retroshare-gui/src/gui/msgs/MessageModel.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/retroshare-gui/src/gui/msgs/MessageModel.cpp b/retroshare-gui/src/gui/msgs/MessageModel.cpp index 6116e42b4..14b15479c 100644 --- a/retroshare-gui/src/gui/msgs/MessageModel.cpp +++ b/retroshare-gui/src/gui/msgs/MessageModel.cpp @@ -209,6 +209,8 @@ QVariant RsMessageModel::data(const QModelIndex &index, int role) const std::cerr << "calling data(" << index << ") role=" << role << std::endl; #endif + int coln = index.column(); + if(!index.isValid()) return QVariant(); @@ -251,6 +253,14 @@ QVariant RsMessageModel::data(const QModelIndex &index, int role) const return QVariant(font); } + + if (role == Qt::TextAlignmentRole) + { + if((coln == COLUMN_THREAD_ATTACHMENT)) + return int( Qt::AlignHCenter | Qt::AlignVCenter); + else + return QVariant(); + } #ifdef DEBUG_MESSAGE_MODEL std::cerr << " [ok]" << std::endl; From 435e8ce50c12d709513441eb7a3ba906148a4cdf Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 10 Feb 2025 21:18:31 +0100 Subject: [PATCH 19/84] continued implementation of IdentityListModel --- retroshare-gui/src/gui/Identity/IdDialog.cpp | 411 ++++++++---------- retroshare-gui/src/gui/Identity/IdDialog.h | 5 +- .../src/gui/Identity/IdentityListModel.cpp | 23 +- .../src/gui/Identity/IdentityListModel.h | 16 +- 4 files changed, 209 insertions(+), 246 deletions(-) diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index 23556d3ad..a8e4baba8 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -120,6 +120,7 @@ static const uint32_t SortRole = Qt::UserRole+1 ; +#ifdef TO_REMOVE // quick solution for RSID_COL_VOTES sorting class TreeWidgetItem : public QTreeWidgetItem { @@ -143,6 +144,7 @@ class TreeWidgetItem : public QTreeWidgetItem return data(column,Qt::DisplayRole).toString().toUpper() < other.data(column,Qt::DisplayRole).toString().toUpper(); } }; +#endif /** Constructor */ IdDialog::IdDialog(QWidget *parent) @@ -233,7 +235,7 @@ IdDialog::IdDialog(QWidget *parent) connect(ui->inviteButton, SIGNAL(clicked()), this, SLOT(sendInvite())); connect(ui->editButton, SIGNAL(clicked()), this, SLOT(editIdentity())); - connect( ui->idTreeWidget, &RSTreeWidget::itemDoubleClicked, this, &IdDialog::chatIdentityItem ); + connect( ui->idTreeWidget, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(chatIdentityItem(QModelIndex&)) ); ui->editButton->hide(); @@ -247,9 +249,10 @@ IdDialog::IdDialog(QWidget *parent) clearPerson(); +#ifdef TODO /* Add filter types */ - QMenu *idTWHMenu = new QMenu(tr("Show Items"), this); - ui->idTreeWidget->addContextMenuMenu(idTWHMenu); + QMenu *idTWHMenu = new QMenu(tr("Show Items"), this); + ui->idTreeWidget->addContextMenuMenu(idTWHMenu); QActionGroup *idTWHActionGroup = new QActionGroup(this); QAction *idTWHAction = new QAction(QIcon(),tr("All"), this); @@ -302,6 +305,7 @@ IdDialog::IdDialog(QWidget *parent) idTWHAction->setData(RSID_FILTER_BANNED); connect(idTWHAction, SIGNAL(toggled(bool)), this, SLOT(filterToggled(bool))); idTWHMenu->addAction(idTWHAction); +#endif QAction *CreateIDAction = new QAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/person.png"),tr("Create new Identity"), this); connect(CreateIDAction, SIGNAL(triggered()), this, SLOT(addIdentity())); @@ -1277,22 +1281,20 @@ void IdDialog::filterToggled(const bool &value) void IdDialog::updateSelection() { - QTreeWidgetItem *item = ui->idTreeWidget->currentItem(); - RsGxsGroupId id; + auto id = RsGxsGroupId(getSelectedIdentity()); - if (item) { - id = RsGxsGroupId(item->text(RSID_COL_KEYID).toStdString()); - } - - if (id != mId) { + if(id != mId) + { mId = id; updateIdentity(); - //updateRepList(); } } - - +void IdDialog::updateIdList() +{ + mIdListModel->updateIdentityList(); +} +#ifdef TO_REMOVE void IdDialog::updateIdList() { //int accept = filter; @@ -1583,6 +1585,7 @@ void IdDialog::loadIdentities(const std::map& ids_set filterIds(); updateSelection(); } +#endif void IdDialog::updateIdentity() { @@ -2001,18 +2004,18 @@ void IdDialog::navigate(const RsGxsId& gxs_id) std::cerr << "IdDialog::navigate to " << gxs_id.toStdString() << std::endl; #endif + QModelIndex indx = mIdListModel->getIndexOfIdentity(gxs_id); + // in order to do this, we just select the correct ID in the ID list if (!gxs_id.isNull()) { - QList select = ui->idTreeWidget->findItems(QString::fromStdString(gxs_id.toStdString()),Qt::MatchExactly | Qt::MatchRecursive | Qt::MatchWrap,RSID_COL_KEYID) ; - - if(select.empty()) + if(!indx.isValid()) { mIdToNavigate = RsGxsGroupId(gxs_id); std::cerr << "Cannot find item with ID " << gxs_id << " in ID list." << std::endl; return; } - ui->idTreeWidget->setCurrentItem(*select.begin(),true); + ui->idTreeWidget->selectionModel()->select(indx,QItemSelectionModel::ClearAndSelect); } mIdToNavigate = RsGxsGroupId(); @@ -2106,187 +2109,171 @@ void IdDialog::filterIds() void IdDialog::IdListCustomPopupMenu( QPoint ) { - QMenu *contextMenu = new QMenu(this); + QMenu *contextMenu = new QMenu(this); + std::list own_identities; + rsIdentity->getOwnIds(own_identities); - std::list own_identities; - rsIdentity->getOwnIds(own_identities); + // make some stats about what's selected. If the same value is used for all selected items, it can be switched. - // make some stats about what's selected. If the same value is used for all selected items, it can be switched. + auto lst = getSelectedIdentities(); - QList selected_items = ui->idTreeWidget->selectedItems(); + //bool root_node_present = false ; + bool one_item_owned_by_you = false ; + uint32_t n_positive_reputations = 0 ; + uint32_t n_negative_reputations = 0 ; + uint32_t n_neutral_reputations = 0 ; + uint32_t n_is_a_contact = 0 ; + uint32_t n_is_not_a_contact = 0 ; + uint32_t n_selected_items =0 ; - bool root_node_present = false ; - bool one_item_owned_by_you = false ; - uint32_t n_positive_reputations = 0 ; - uint32_t n_negative_reputations = 0 ; - uint32_t n_neutral_reputations = 0 ; - uint32_t n_is_a_contact = 0 ; - uint32_t n_is_not_a_contact = 0 ; - uint32_t n_selected_items =0 ; + for(auto& keyId :lst) + { + //if(it == allItem || it == contactsItem || it == ownItem) + //{ + // root_node_present = true ; + // continue ; + //} - for(auto& it :selected_items) - { - if(it == allItem || it == contactsItem || it == ownItem) - { - root_node_present = true ; - continue ; - } + //uint32_t item_flags = mIdListModel->data(RSID_COL_KEYID,Qt::UserRole).toUInt() ; - uint32_t item_flags = it->data(RSID_COL_KEYID,Qt::UserRole).toUInt() ; - - if(item_flags & RSID_FILTER_OWNED_BY_YOU) - one_item_owned_by_you = true ; + if(rsIdentity->isOwnId(keyId)) + one_item_owned_by_you = true ; #ifdef ID_DEBUG - std::cerr << " item flags = " << item_flags << std::endl; + std::cerr << " item flags = " << item_flags << std::endl; #endif - RsGxsId keyId(it->text(RSID_COL_KEYID).toStdString()); + RsIdentityDetails det ; + rsIdentity->getIdDetails(keyId,det) ; - RsIdentityDetails det ; - rsIdentity->getIdDetails(keyId,det) ; + switch(det.mReputation.mOwnOpinion) + { + case RsOpinion::NEGATIVE: ++n_negative_reputations; break; + case RsOpinion::POSITIVE: ++n_positive_reputations; break; + case RsOpinion::NEUTRAL: ++n_neutral_reputations; break; + } - switch(det.mReputation.mOwnOpinion) - { - case RsOpinion::NEGATIVE: ++n_negative_reputations; break; - case RsOpinion::POSITIVE: ++n_positive_reputations; break; - case RsOpinion::NEUTRAL: ++n_neutral_reputations; break; - } + ++n_selected_items; - ++n_selected_items; + if(rsIdentity->isARegularContact(keyId)) + ++n_is_a_contact ; + else + ++n_is_not_a_contact ; + } - if(rsIdentity->isARegularContact(keyId)) - ++n_is_a_contact ; - else - ++n_is_not_a_contact ; - } + if(!one_item_owned_by_you) + { + QFrame *widget = new QFrame(contextMenu); + widget->setObjectName("gradFrame"); //Use qss + //widget->setStyleSheet( ".QWidget{background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,stop:0 #FEFEFE, stop:1 #E8E8E8); border: 1px solid #CCCCCC;}"); - if(!root_node_present) // don't show menu if some of the root nodes are present - { + // create menu header + QHBoxLayout *hbox = new QHBoxLayout(widget); + hbox->setMargin(0); + hbox->setSpacing(6); - if(!one_item_owned_by_you) - { - QFrame *widget = new QFrame(contextMenu); - widget->setObjectName("gradFrame"); //Use qss - //widget->setStyleSheet( ".QWidget{background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,stop:0 #FEFEFE, stop:1 #E8E8E8); border: 1px solid #CCCCCC;}"); + QLabel *iconLabel = new QLabel(widget); + iconLabel->setObjectName("trans_Icon"); + QPixmap pix = FilesDefs::getPixmapFromQtResourcePath(":/images/user/friends24.png").scaledToHeight(QFontMetricsF(iconLabel->font()).height()*1.5); + iconLabel->setPixmap(pix); + iconLabel->setMaximumSize(iconLabel->frameSize().height() + pix.height(), pix.width()); + hbox->addWidget(iconLabel); - // create menu header - QHBoxLayout *hbox = new QHBoxLayout(widget); - hbox->setMargin(0); - hbox->setSpacing(6); + QLabel *textLabel = new QLabel("" + ui->titleBarLabel->text() + "", widget); + textLabel->setObjectName("trans_Text"); + hbox->addWidget(textLabel); - QLabel *iconLabel = new QLabel(widget); - iconLabel->setObjectName("trans_Icon"); - QPixmap pix = FilesDefs::getPixmapFromQtResourcePath(":/images/user/friends24.png").scaledToHeight(QFontMetricsF(iconLabel->font()).height()*1.5); - iconLabel->setPixmap(pix); - iconLabel->setMaximumSize(iconLabel->frameSize().height() + pix.height(), pix.width()); - hbox->addWidget(iconLabel); + QSpacerItem *spacerItem = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + hbox->addItem(spacerItem); - QLabel *textLabel = new QLabel("" + ui->titleBarLabel->text() + "", widget); - textLabel->setObjectName("trans_Text"); - hbox->addWidget(textLabel); + widget->setLayout(hbox); - QSpacerItem *spacerItem = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); - hbox->addItem(spacerItem); + QWidgetAction *widgetAction = new QWidgetAction(this); + widgetAction->setDefaultWidget(widget); + contextMenu->addAction(widgetAction); - widget->setLayout(hbox); + if(n_selected_items == 1) // if only one item is selected, allow to chat with this item + { + if(own_identities.size() <= 1) + { + QAction *action = contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/chats.png"), tr("Chat with this person"), this, SLOT(chatIdentity())); - QWidgetAction *widgetAction = new QWidgetAction(this); - widgetAction->setDefaultWidget(widget); - contextMenu->addAction(widgetAction); + if(own_identities.empty()) + action->setEnabled(false) ; + else + action->setData(QString::fromStdString((own_identities.front()).toStdString())) ; + } + else + { + QMenu *mnu = contextMenu->addMenu(FilesDefs::getIconFromQtResourcePath(":/icons/png/chats.png"),tr("Chat with this person as...")) ; - if(n_selected_items == 1) // if only one item is selected, allow to chat with this item - { - if(own_identities.size() <= 1) - { - QAction *action = contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/chats.png"), tr("Chat with this person"), this, SLOT(chatIdentity())); + for(std::list::const_iterator it=own_identities.begin();it!=own_identities.end();++it) + { + RsIdentityDetails idd ; + rsIdentity->getIdDetails(*it,idd) ; - if(own_identities.empty()) - action->setEnabled(false) ; - else - action->setData(QString::fromStdString((own_identities.front()).toStdString())) ; - } - else - { - QMenu *mnu = contextMenu->addMenu(FilesDefs::getIconFromQtResourcePath(":/icons/png/chats.png"),tr("Chat with this person as...")) ; + QPixmap pixmap ; - for(std::list::const_iterator it=own_identities.begin();it!=own_identities.end();++it) - { - RsIdentityDetails idd ; - rsIdentity->getIdDetails(*it,idd) ; + if(idd.mAvatar.mSize == 0 || !GxsIdDetails::loadPixmapFromData(idd.mAvatar.mData, idd.mAvatar.mSize, pixmap,GxsIdDetails::SMALL)) + pixmap = GxsIdDetails::makeDefaultIcon(*it,GxsIdDetails::SMALL) ; - QPixmap pixmap ; + QAction *action = mnu->addAction(QIcon(pixmap), QString("%1 (%2)").arg(QString::fromUtf8(idd.mNickname.c_str()), QString::fromStdString((*it).toStdString())), this, SLOT(chatIdentity())); + action->setData(QString::fromStdString((*it).toStdString())) ; + } + } + } + // always allow to send messages + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/mail/write-mail.png"), tr("Send message"), this, SLOT(sendMsg())); - if(idd.mAvatar.mSize == 0 || !GxsIdDetails::loadPixmapFromData(idd.mAvatar.mData, idd.mAvatar.mSize, pixmap,GxsIdDetails::SMALL)) - pixmap = GxsIdDetails::makeDefaultIcon(*it,GxsIdDetails::SMALL) ; + contextMenu->addSeparator(); - QAction *action = mnu->addAction(QIcon(pixmap), QString("%1 (%2)").arg(QString::fromUtf8(idd.mNickname.c_str()), QString::fromStdString((*it).toStdString())), this, SLOT(chatIdentity())); - action->setData(QString::fromStdString((*it).toStdString())) ; - } - } - } - // always allow to send messages - contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/mail/write-mail.png"), tr("Send message"), this, SLOT(sendMsg())); + if(n_is_a_contact == 0) + contextMenu->addAction(QIcon(), tr("Add to Contacts"), this, SLOT(addtoContacts())); - contextMenu->addSeparator(); + if(n_is_not_a_contact == 0) + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/cancel.svg"), tr("Remove from Contacts"), this, SLOT(removefromContacts())); - if(n_is_a_contact == 0) - contextMenu->addAction(QIcon(), tr("Add to Contacts"), this, SLOT(addtoContacts())); + if (n_selected_items==1) + contextMenu->addAction(QIcon(""),tr("Copy identity to clipboard"),this,SLOT(copyRetroshareLink())) ; - if(n_is_not_a_contact == 0) - contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/cancel.svg"), tr("Remove from Contacts"), this, SLOT(removefromContacts())); + contextMenu->addSeparator(); + + if(n_positive_reputations == 0) // only unban when all items are banned + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/thumbs-up.png"), tr("Set positive opinion"), this, SLOT(positivePerson())); + + if(n_neutral_reputations == 0) // only unban when all items are banned + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/thumbs-neutral.png"), tr("Set neutral opinion"), this, SLOT(neutralPerson())); + + if(n_negative_reputations == 0) + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/thumbs-down.png"), tr("Set negative opinion"), this, SLOT(negativePerson())); + + if(one_item_owned_by_you && n_selected_items==1) + { + contextMenu->addSeparator(); + + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_EDIT),tr("Edit identity"),this,SLOT(editIdentity())) ; + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/cancel.svg"),tr("Delete identity"),this,SLOT(removeIdentity())) ; + } } - if (n_selected_items==1) - contextMenu->addAction(QIcon(""),tr("Copy identity to clipboard"),this,SLOT(copyRetroshareLink())) ; + //contextMenu = ui->idTreeWidget->createStandardContextMenu(contextMenu); - contextMenu->addSeparator(); - - if(n_positive_reputations == 0) // only unban when all items are banned - contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/thumbs-up.png"), tr("Set positive opinion"), this, SLOT(positivePerson())); - - if(n_neutral_reputations == 0) // only unban when all items are banned - contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/thumbs-neutral.png"), tr("Set neutral opinion"), this, SLOT(neutralPerson())); - - if(n_negative_reputations == 0) - contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/thumbs-down.png"), tr("Set negative opinion"), this, SLOT(negativePerson())); - - if(one_item_owned_by_you && n_selected_items==1) - { - contextMenu->addSeparator(); - - contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_EDIT),tr("Edit identity"),this,SLOT(editIdentity())) ; - contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/cancel.svg"),tr("Delete identity"),this,SLOT(removeIdentity())) ; - } - - } - - contextMenu = ui->idTreeWidget->createStandardContextMenu(contextMenu); - - contextMenu->exec(QCursor::pos()); - delete contextMenu; + contextMenu->exec(QCursor::pos()); + delete contextMenu; } void IdDialog::copyRetroshareLink() { - QTreeWidgetItem *item = ui->idTreeWidget->currentItem(); + auto gxs_id = getSelectedIdentity(); - if (!item) + if (gxs_id.isNull()) { std::cerr << "IdDialog::editIdentity() Invalid item"; std::cerr << std::endl; return; } - RsGxsId gxs_id(item->text(RSID_COL_KEYID).toStdString()); - - if(gxs_id.isNull()) - { - std::cerr << "Null GXS id. Something went wrong." << std::endl; - return ; - } - RsIdentityDetails details ; if(! rsIdentity->getIdDetails(gxs_id,details)) @@ -2324,35 +2311,33 @@ void IdDialog::copyRetroshareLink() }); } -void IdDialog::chatIdentity() +void IdDialog::chatIdentityItem(const QModelIndex& indx) { - QTreeWidgetItem* item = ui->idTreeWidget->currentItem(); - if (!item) - { - std::cerr << __PRETTY_FUNCTION__ << " Error. Invalid item!" << std::endl; - return; - } + auto toGxsId = mIdListModel->getIdentity(indx); - chatIdentityItem(item); -} - -void IdDialog::chatIdentityItem(QTreeWidgetItem* item) -{ - if(!item) + if(toGxsId.isNull()) { std::cerr << __PRETTY_FUNCTION__ << " Error. Invalid item." << std::endl; return; } + chatIdentity(toGxsId); +} - std::string&& toIdString(item->text(RSID_COL_KEYID).toStdString()); - RsGxsId toGxsId(toIdString); - if(toGxsId.isNull()) - { - std::cerr << __PRETTY_FUNCTION__ << " Error. Invalid destination id: " - << toIdString << std::endl; - return; - } +void IdDialog::chatIdentity() +{ + auto id = getSelectedIdentity(); + if(id.isNull()) + { + std::cerr << __PRETTY_FUNCTION__ << " Error. Invalid item!" << std::endl; + return; + } + + chatIdentity(id); +} + +void IdDialog::chatIdentity(const RsGxsId& toGxsId) +{ RsGxsId fromGxsId; QAction* action = qobject_cast(QObject::sender()); if(!action) @@ -2371,8 +2356,7 @@ void IdDialog::chatIdentityItem(QTreeWidgetItem* item) if(fromGxsId.isNull()) { - std::cerr << __PRETTY_FUNCTION__ << " Error. Could not determine sender" - << " identity to open chat toward: " << toIdString << std::endl; + std::cerr << __PRETTY_FUNCTION__ << " Error. Could not determine sender identity to open chat toward: " << toGxsId << std::endl; return; } @@ -2389,12 +2373,12 @@ void IdDialog::chatIdentityItem(QTreeWidgetItem* item) void IdDialog::sendMsg() { - QList selected_items = ui->idTreeWidget->selectedItems(); + auto lst = getSelectedIdentities(); - if(selected_items.empty()) + if(lst.empty()) return ; - if(selected_items.size() > 20) + if(lst.size() > 20) if(QMessageBox::warning(nullptr,tr("Too many identities"),tr("

It is not recommended to send a message to more than 20 persons at once. Large scale diffusion of data (including friend invitations) are much more efficiently handled by forums. Click ok to proceed anyway.

"),QMessageBox::Ok|QMessageBox::Cancel,QMessageBox::Cancel)==QMessageBox::Cancel) return; @@ -2402,14 +2386,9 @@ void IdDialog::sendMsg() if (nMsgDialog == NULL) return; - for(auto& it : selected_items) - { - QTreeWidgetItem *item = it ; + for(const auto& id : lst) + nMsgDialog->addRecipient(MessageComposer::TO, id); - std::string keyId = item->text(RSID_COL_KEYID).toStdString(); - - nMsgDialog->addRecipient(MessageComposer::TO, RsGxsId(keyId)); - } nMsgDialog->show(); nMsgDialog->activateWindow(); @@ -2423,13 +2402,10 @@ QString IdDialog::inviteMessage() void IdDialog::sendInvite() { - QTreeWidgetItem *item = ui->idTreeWidget->currentItem(); - if (!item) - { - return; - } + auto id = getSelectedIdentity(); - RsGxsId id(ui->lineEdit_KeyId->text().toStdString()); + if(id.isNull()) + return; //if ((QMessageBox::question(this, tr("Send invite?"),tr("Do you really want send a invite with your Certificate?"),QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes))== QMessageBox::Yes) { @@ -2444,15 +2420,10 @@ void IdDialog::sendInvite() void IdDialog::negativePerson() { - QList selected_items = ui->idTreeWidget->selectedItems(); - for(auto& it : selected_items) - { - QTreeWidgetItem *item = it ; + auto lst = getSelectedIdentities(); - std::string Id = item->text(RSID_COL_KEYID).toStdString(); - - rsReputations->setOwnOpinion(RsGxsId(Id), RsOpinion::NEGATIVE); - } + for(const auto& id : lst) + rsReputations->setOwnOpinion(id, RsOpinion::NEGATIVE); updateIdentity(); updateIdList(); @@ -2460,30 +2431,20 @@ void IdDialog::negativePerson() void IdDialog::neutralPerson() { - QList selected_items = ui->idTreeWidget->selectedItems(); - for(auto& it : selected_items) - { - QTreeWidgetItem *item = it ; + auto lst = getSelectedIdentities(); - std::string Id = item->text(RSID_COL_KEYID).toStdString(); - - rsReputations->setOwnOpinion(RsGxsId(Id), RsOpinion::NEUTRAL); - } + for(const auto& id : lst) + rsReputations->setOwnOpinion(id, RsOpinion::NEUTRAL); updateIdentity(); updateIdList(); } void IdDialog::positivePerson() { - QList selected_items = ui->idTreeWidget->selectedItems(); - for(auto& it : selected_items) - { - QTreeWidgetItem *item = it ; + auto lst = getSelectedIdentities(); - std::string Id = item->text(RSID_COL_KEYID).toStdString(); - - rsReputations->setOwnOpinion(RsGxsId(Id), RsOpinion::POSITIVE); - } + for(const auto& id : lst) + rsReputations->setOwnOpinion(id, RsOpinion::POSITIVE); updateIdentity(); updateIdList(); @@ -2491,28 +2452,20 @@ void IdDialog::positivePerson() void IdDialog::addtoContacts() { - QList selected_items = ui->idTreeWidget->selectedItems(); - for(auto& it : selected_items) - { - QTreeWidgetItem *item = it ; - std::string Id = item->text(RSID_COL_KEYID).toStdString(); + auto lst = getSelectedIdentities(); - rsIdentity->setAsRegularContact(RsGxsId(Id),true); - } + for(const auto& id : lst) + rsIdentity->setAsRegularContact(id,true); updateIdList(); } void IdDialog::removefromContacts() { - QList selected_items = ui->idTreeWidget->selectedItems(); - for(auto& it : selected_items) - { - QTreeWidgetItem *item = it ; - std::string Id = item->text(RSID_COL_KEYID).toStdString(); + auto lst = getSelectedIdentities(); - rsIdentity->setAsRegularContact(RsGxsId(Id),false); - } + for(const auto& id : lst) + rsIdentity->setAsRegularContact(id,false); updateIdList(); } diff --git a/retroshare-gui/src/gui/Identity/IdDialog.h b/retroshare-gui/src/gui/Identity/IdDialog.h index e8d0c52df..f88cccda0 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.h +++ b/retroshare-gui/src/gui/Identity/IdDialog.h @@ -87,8 +87,9 @@ private slots: void removeIdentity(); void editIdentity(); void chatIdentity(); - void chatIdentityItem(QTreeWidgetItem* item); - void sendMsg(); + void chatIdentityItem(const QModelIndex &indx); + void chatIdentity(const RsGxsId& toGxsId); + void sendMsg(); void copyRetroshareLink(); void on_closeInfoFrameButton_Invite_clicked(); diff --git a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp index d7b5f2449..804f190c6 100644 --- a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp +++ b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp @@ -457,12 +457,29 @@ QVariant RsIdentityListModel::sortRole(const EntryIndex& entry,int column) const } } +QModelIndex RsIdentityListModel::getIndexOfIdentity(const RsGxsId& id) const +{ + for(uint i=0;i& identi } -void RsIdentityListModel::updateInternalData() +void RsIdentityListModel::updateIdentityList() { RsThread::async([this]() { diff --git a/retroshare-gui/src/gui/Identity/IdentityListModel.h b/retroshare-gui/src/gui/Identity/IdentityListModel.h index b6e410ae2..3500737a8 100644 --- a/retroshare-gui/src/gui/Identity/IdentityListModel.h +++ b/retroshare-gui/src/gui/Identity/IdentityListModel.h @@ -99,7 +99,9 @@ public: }; QModelIndex root() const{ return createIndex(0,0,(void*)NULL) ;} - QModelIndex getIndexOfGroup(const RsNodeGroupId& mid) const; + QModelIndex getIndexOfIdentity(const RsGxsId& id) const; + + void updateIdentityList(); static const QString FilterString ; @@ -140,16 +142,6 @@ private: bool isCategoryExpanded(const EntryIndex& e) const; void checkIdentity(HierarchicalIdentityInformation& node); - std::map::const_iterator checkProfileIndex(const RsPgpId& pgp_id, - std::map& pgp_indices, - std::vector& mProfiles, - bool create); - - std::map::const_iterator createInvalidatedProfile(const RsPgpId& pgp_id, - const RsPgpFingerprint& fpr, - std::map& pgp_indices, - std::vector& mProfiles); - QVariant sizeHintRole (const EntryIndex& e, int col) const; QVariant displayRole (const EntryIndex& e, int col) const; QVariant decorationRole(const EntryIndex& e, int col) const; @@ -158,7 +150,6 @@ private: QVariant sortRole (const EntryIndex& e, int col) const; QVariant fontRole (const EntryIndex& e, int col) const; QVariant textColorRole (const EntryIndex& e, int col) const; - QVariant onlineRole (const EntryIndex& e, int col) const; QVariant filterRole (const EntryIndex& e, int col) const; /*! @@ -176,7 +167,6 @@ signals: void dataAboutToLoad(); private: - void updateInternalData(); void setIdentities(const std::list& identities_meta); bool passesFilter(const EntryIndex &e, int column) const; From 5005c0303d5c4211a456b1edda172e478dc658c5 Mon Sep 17 00:00:00 2001 From: defnax Date: Tue, 11 Feb 2025 18:51:20 +0100 Subject: [PATCH 20/84] Fixed to update the fonts for MainWindow ListWidget --- retroshare-gui/src/gui/MainWindow.cpp | 10 ++-------- retroshare-gui/src/gui/MainWindow.h | 2 -- retroshare-gui/src/gui/settings/AppearancePage.cpp | 2 ++ 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index 0eb5b69c9..69ba1494e 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -1642,6 +1642,8 @@ void MainWindow::settingsChanged() ui->toolBarAction->setIconSize(QSize(toolSize,toolSize)); int itemSize = Settings->getListItemIconSize(); ui->listWidget->setIconSize(QSize(itemSize,itemSize)); + + updateFontSize(); } void MainWindow::externalLinkActivated(const QUrl &url) @@ -1821,13 +1823,6 @@ void MainWindow::setCompactStatusMode(bool compact) //opModeStatus: TODO Show only ??? } -void MainWindow::showEvent(QShowEvent *event) -{ - if (!event->spontaneous()) { - updateFontSize(); - } -} - void MainWindow::updateFontSize() { #if defined(Q_OS_DARWIN) @@ -1841,7 +1836,6 @@ void MainWindow::updateFontSize() QFontMetricsF fontMetrics(newFont); int iconHeight = fontMetrics.height()*1.5; ui->listWidget->setFont(newFont); - ui->toolBarPage->setFont(newFont); ui->listWidget->setIconSize(QSize(iconHeight, iconHeight)); } } diff --git a/retroshare-gui/src/gui/MainWindow.h b/retroshare-gui/src/gui/MainWindow.h index 99219de42..56745d7d6 100644 --- a/retroshare-gui/src/gui/MainWindow.h +++ b/retroshare-gui/src/gui/MainWindow.h @@ -204,8 +204,6 @@ public: static bool hiddenmode; - virtual void showEvent(QShowEvent *) ; - public slots: void receiveNewArgs(QStringList args); void displayErrorMessage(int,int,const QString&) ; diff --git a/retroshare-gui/src/gui/settings/AppearancePage.cpp b/retroshare-gui/src/gui/settings/AppearancePage.cpp index 72b2a4bf7..c471649cb 100755 --- a/retroshare-gui/src/gui/settings/AppearancePage.cpp +++ b/retroshare-gui/src/gui/settings/AppearancePage.cpp @@ -376,4 +376,6 @@ void AppearancePage::updateFontSize() Settings->beginGroup(QString("File")); Settings->setValue("MinimumFontSize", ui.minimumFontSize_SB->value()); Settings->endGroup(); + + NotifyQt::getInstance()->notifySettingsChanged(); } \ No newline at end of file From 49242e185b91917a0410d7b1f73dde723d4ec084 Mon Sep 17 00:00:00 2001 From: defnax Date: Wed, 12 Feb 2025 18:36:13 +0100 Subject: [PATCH 21/84] Fixed fonts update --- retroshare-gui/src/gui/common/GroupTreeWidget.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/retroshare-gui/src/gui/common/GroupTreeWidget.cpp b/retroshare-gui/src/gui/common/GroupTreeWidget.cpp index f84010016..3945037dd 100644 --- a/retroshare-gui/src/gui/common/GroupTreeWidget.cpp +++ b/retroshare-gui/src/gui/common/GroupTreeWidget.cpp @@ -30,6 +30,7 @@ #include "gui/settings/rsharesettings.h" #include "util/QtVersion.h" #include "util/DateTime.h" +#include "gui/notifyqt.h" #include #include @@ -690,6 +691,8 @@ void GroupTreeWidget::updateFontSize() newFont.setPointSize(customFontSize); QFontMetricsF fontMetrics(newFont); ui->treeWidget->setFont(newFont); + int H = QFontMetricsF(ui->treeWidget->font()).height() ; + ui->treeWidget->setIconSize(QSize(H*1.8,H*1.8)); } } From cd338613c1583d0040f2f9d42cdb8ff5633ca85a Mon Sep 17 00:00:00 2001 From: defnax Date: Wed, 12 Feb 2025 19:26:16 +0100 Subject: [PATCH 22/84] Attempt for forums tree fonts settings --- .../gui/gxsforums/GxsForumThreadWidget.cpp | 27 +++++++++++++++++++ .../src/gui/gxsforums/GxsForumThreadWidget.h | 3 +++ 2 files changed, 30 insertions(+) diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp index 11d04fdd8..f19bfee5a 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp @@ -250,6 +250,7 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget ui->setupUi(this); //setUpdateWhenInvisible(true); + updateFontSize(); //mUpdating = false; mUnreadCount = 0; @@ -367,6 +368,8 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget blankPost(); + + ui->subscribeToolButton->setToolTip(tr( "

Subscribing to the forum will gather \ available posts from your subscribed friends, and make the \ forum visible to all other friends.

Afterwards you can unsubscribe from the context menu of the forum list at left.

")); @@ -2099,3 +2102,27 @@ void GxsForumThreadWidget::showAuthorInPeople(const RsGxsForumMsg& msg) MainWindow::showWindow(MainWindow::People); idDialog->navigate(RsGxsId(msg.mMeta.mAuthorId)); } + +void GxsForumThreadWidget::showEvent(QShowEvent *event) +{ + if (!event->spontaneous()) { + updateFontSize(); + } +} + +void GxsForumThreadWidget::updateFontSize() +{ +#if defined(Q_OS_DARWIN) + int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 13).toInt(); +#else + int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 12).toInt(); +#endif + QFont newFont = ui->threadTreeWidget->font(); + if (newFont.pointSize() != customFontSize) { + newFont.setPointSize(customFontSize); + QFontMetricsF fontMetrics(newFont); + ui->threadTreeWidget->setFont(newFont); + int iconHeight = fontMetrics.height() * 1.4; + ui->threadTreeWidget->setIconSize(QSize(iconHeight, iconHeight)); + } +} diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h index 322c64fae..b867c2399 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h @@ -97,6 +97,7 @@ public: protected: //bool eventFilter(QObject *obj, QEvent *ev); //void changeEvent(QEvent *e); + virtual void showEvent(QShowEvent *) override; /* RsGxsUpdateBroadcastWidget */ virtual void updateDisplay(bool complete); @@ -160,6 +161,8 @@ private slots: void filterColumnChanged(int column); void filterItems(const QString &text); + void updateFontSize(); + #if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0) void expandSubtree(); #endif From 40d6c3c9737f91438119cf0b5172e2e0ed0dabbc Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 14 Feb 2025 16:54:02 +0100 Subject: [PATCH 23/84] first working version of IdentityModel --- .../src/gui/Identity/IdentityListModel.cpp | 191 +++++++++--------- .../src/gui/Identity/IdentityListModel.h | 11 +- 2 files changed, 107 insertions(+), 95 deletions(-) diff --git a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp index 804f190c6..4f843def7 100644 --- a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp +++ b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp @@ -42,10 +42,6 @@ std::ostream& operator<<(std::ostream& o, const QModelIndex& i);// defined elsewhere -static const uint16_t UNDEFINED_GROUP_INDEX_VALUE = (sizeof(uintptr_t)==4)?0x1ff:0xffff; // max value for 9 bits -static const uint16_t UNDEFINED_NODE_INDEX_VALUE = (sizeof(uintptr_t)==4)?0x1ff:0xffff; // max value for 9 bits -static const uint16_t UNDEFINED_PROFILE_INDEX_VALUE = (sizeof(uintptr_t)==4)?0xfff:0xffff; // max value for 12 bits - const QString RsIdentityListModel::FilterString("filtered"); const uint32_t MAX_INTERNAL_DATA_UPDATE_DELAY = 300 ; // re-update the internal data every 5 mins. Should properly cover sleep/wake-up changes. @@ -61,7 +57,7 @@ RsIdentityListModel::RsIdentityListModel(QObject *parent) } RsIdentityListModel::EntryIndex::EntryIndex() - : type(ENTRY_TYPE_UNKNOWN),category_index(UNDEFINED_GROUP_INDEX_VALUE),identity_index(UNDEFINED_NODE_INDEX_VALUE) + : type(ENTRY_TYPE_INVALID),category_index(0),identity_index(0) { } @@ -69,31 +65,43 @@ RsIdentityListModel::EntryIndex::EntryIndex() // // On 32 bits and 64 bits architectures the format is the following: // -// 0x [2 bits] [30 bits] -// | | -// | | -// | | -// | +----------------------- identity index -// +-------------------------------- category +// 0x [2 bits] 00000 [24 bits] [2 bits] +// | | | +// | | +-------------- type (0=top level, 1=category, 2=identity) +// | +----------------------- identity index +// +-------------------------------------- category index // -// Only valid indexes a 0x00->UNDEFINED_INDEX_VALUE-1. bool RsIdentityListModel::convertIndexToInternalId(const EntryIndex& e,quintptr& id) { - // the internal id is set to the place in the table of items. We simply shift to allow 0 to mean something special. + // the internal id is set to the place in the table of items. We simply shift to allow 0 to mean something special. - id = (((uint32_t)e.type) << 30) + ((uint32_t)e.identity_index); - return true; + if(e.type == ENTRY_TYPE_INVALID) + { + RsErr() << "ERROR: asked for the internal id of an invalid EntryIndex" ; + id = 0; + return true; + } + if(bool(e.identity_index >> 24)) + { + RsErr() << "Cannot encode more than 2^24 identities. Somthing's wrong. e.identity_index = " << std::hex << e.identity_index << std::dec ; + id = 0; + return false; + } + + id = (((uint32_t)e.category_index) << 30) + ((uint32_t)e.identity_index << 2) + ((uint32_t)e.type); + + return true; } bool RsIdentityListModel::convertInternalIdToIndex(quintptr ref,EntryIndex& e) { - if(ref == 0) - return false ; + // Compatible with ref=0 since it will cause type=TOP_LEVEL - e.category_index = (ref >> 30) & 0x3;// 2 bits - e.identity_index = (ref >> 0) & 0x3fffffff;// 30 bits + e.type = static_cast((ref >> 0) & 0x3) ;// 2 bits + e.identity_index = (ref >> 2) & 0xffffff;// 24 bits + e.category_index = (ref >> 30) & 0x3 ;// 2 bits - return true; + return true; } static QIcon createAvatar(const QPixmap &avatar, const QPixmap &overlay) @@ -130,17 +138,18 @@ int RsIdentityListModel::rowCount(const QModelIndex& parent) const if(parent.column() >= COLUMN_THREAD_NB_COLUMNS) return 0; - if(parent.internalId() == 0) - return mTopLevel.size(); + EntryIndex index; - EntryIndex index; - if(!convertInternalIdToIndex(parent.internalId(),index)) - return 0; + if(!parent.isValid() || !convertInternalIdToIndex(parent.internalId(),index)) + return mCategories.size(); - if(index.type == ENTRY_TYPE_CATEGORY) - return mCategories[index.category_index].child_identity_indices.size(); - else - return 0; + switch(index.type) + { + case ENTRY_TYPE_CATEGORY: return mCategories[index.category_index].child_identity_indices.size(); + case ENTRY_TYPE_TOP_LEVEL: return mCategories.size(); + default: + return 0; + } } int RsIdentityListModel::columnCount(const QModelIndex &/*parent*/) const @@ -156,6 +165,9 @@ bool RsIdentityListModel::hasChildren(const QModelIndex &parent) const EntryIndex parent_index ; convertInternalIdToIndex(parent.internalId(),parent_index); + if(parent_index.type == ENTRY_TYPE_TOP_LEVEL) + return true; + if(parent_index.type == ENTRY_TYPE_IDENTITY) return false; @@ -171,12 +183,15 @@ RsIdentityListModel::EntryIndex RsIdentityListModel::EntryIndex::parent() const switch(type) { - case ENTRY_TYPE_CATEGORY: return EntryIndex(); + case ENTRY_TYPE_CATEGORY: i.type = ENTRY_TYPE_TOP_LEVEL; + i.category_index = 0; + i.identity_index = 0; + break; - case ENTRY_TYPE_IDENTITY: i.type = ENTRY_TYPE_CATEGORY; - i.identity_index = UNDEFINED_NODE_INDEX_VALUE; + case ENTRY_TYPE_IDENTITY: i.type = ENTRY_TYPE_CATEGORY; + i.identity_index = 0; break; - case ENTRY_TYPE_UNKNOWN: + case ENTRY_TYPE_TOP_LEVEL: //Can be when request root index. break; } @@ -184,17 +199,21 @@ RsIdentityListModel::EntryIndex RsIdentityListModel::EntryIndex::parent() const return i; } -RsIdentityListModel::EntryIndex RsIdentityListModel::EntryIndex::child(int row,const std::vector& top_level) const +RsIdentityListModel::EntryIndex RsIdentityListModel::EntryIndex::child(int row) const { - EntryIndex i(*this); + EntryIndex i; switch(type) { - case ENTRY_TYPE_UNKNOWN: - i = top_level[row]; + case ENTRY_TYPE_TOP_LEVEL: + i.type = ENTRY_TYPE_CATEGORY; + i.category_index = row; + i.identity_index = 0; + break; case ENTRY_TYPE_CATEGORY: i.type = ENTRY_TYPE_IDENTITY; + i.category_index = category_index; i.identity_index = row; break; @@ -205,12 +224,12 @@ RsIdentityListModel::EntryIndex RsIdentityListModel::EntryIndex::child(int row,c return i; } -uint32_t RsIdentityListModel::EntryIndex::parentRow(int /* nb_groups */) const +uint32_t RsIdentityListModel::EntryIndex::parentRow() const { switch(type) { default: - case ENTRY_TYPE_UNKNOWN : return 0; + case ENTRY_TYPE_TOP_LEVEL: return 0; case ENTRY_TYPE_CATEGORY : return category_index; case ENTRY_TYPE_IDENTITY : return identity_index; } @@ -221,14 +240,6 @@ QModelIndex RsIdentityListModel::index(int row, int column, const QModelIndex& p if(row < 0 || column < 0 || column >= columnCount(parent) || row >= rowCount(parent)) return QModelIndex(); - if(parent.internalId() == 0) - { - quintptr ref ; - - convertIndexToInternalId(mTopLevel[row],ref); - return createIndex(row,column,ref) ; - } - EntryIndex parent_index ; convertInternalIdToIndex(parent.internalId(),parent_index); #ifdef DEBUG_MODEL_INDEX @@ -236,7 +247,7 @@ QModelIndex RsIdentityListModel::index(int row, int column, const QModelIndex& p #endif quintptr ref; - EntryIndex new_index = parent_index.child(row,mTopLevel); + EntryIndex new_index = parent_index.child(row); convertIndexToInternalId(new_index,ref); #ifdef DEBUG_MODEL_INDEX @@ -256,13 +267,13 @@ QModelIndex RsIdentityListModel::parent(const QModelIndex& index) const EntryIndex p = I.parent(); - if(p.type == ENTRY_TYPE_UNKNOWN) + if(p.type == ENTRY_TYPE_TOP_LEVEL) return QModelIndex(); quintptr i; convertIndexToInternalId(p,i); - return createIndex(I.parentRow(mCategories.size()),0,i); + return createIndex(I.parentRow(),0,i); } Qt::ItemFlags RsIdentityListModel::flags(const QModelIndex& index) const @@ -466,6 +477,7 @@ QModelIndex RsIdentityListModel::getIndexOfIdentity(const RsGxsId& id) const EntryIndex e; e.category_index = i; e.identity_index = j; + e.type = ENTRY_TYPE_IDENTITY; quintptr idx; convertIndexToInternalId(e,idx); @@ -634,9 +646,8 @@ void RsIdentityListModel::clear() preMods(); mIdentities.clear(); - mTopLevel.clear(); - mCategories.clear(); + mCategories.resize(3); mCategories[0].category_name = tr("My own identities"); mCategories[1].category_name = tr("My contacts"); @@ -649,40 +660,36 @@ void RsIdentityListModel::clear() void RsIdentityListModel::debug_dump() const { -// std::cerr << "==== FriendListModel Debug dump ====" << std::endl; -// -// for(uint32_t j=0;j& identi void RsIdentityListModel::updateIdentityList() { + std::cerr << "Updating identity list" << std::endl; + RsThread::async([this]() { // 1 - get message data from p3GxsForums @@ -774,9 +783,9 @@ void RsIdentityListModel::updateIdentityList() */ setIdentities(*ids) ; - delete ids; + debug_dump(); }, this ); @@ -797,7 +806,7 @@ void RsIdentityListModel::collapseItem(const QModelIndex& index) mExpandedCategories[entry.category_index] = false; // apparently we cannot be subtle here. - emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mTopLevel.size()-1,columnCount()-1,(void*)NULL)); + emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mCategories.size()-1,columnCount()-1,(void*)NULL)); } void RsIdentityListModel::expandItem(const QModelIndex& index) @@ -813,7 +822,7 @@ void RsIdentityListModel::expandItem(const QModelIndex& index) mExpandedCategories[entry.category_index] = true; // apparently we cannot be subtle here. - emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mTopLevel.size()-1,columnCount()-1,(void*)NULL)); + emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mCategories.size()-1,columnCount()-1,(void*)NULL)); } bool RsIdentityListModel::isCategoryExpanded(const EntryIndex& e) const diff --git a/retroshare-gui/src/gui/Identity/IdentityListModel.h b/retroshare-gui/src/gui/Identity/IdentityListModel.h index 3500737a8..bd4ecd87e 100644 --- a/retroshare-gui/src/gui/Identity/IdentityListModel.h +++ b/retroshare-gui/src/gui/Identity/IdentityListModel.h @@ -59,9 +59,10 @@ public: FILTER_TYPE_NAME = 0x02 }; - enum EntryType{ ENTRY_TYPE_UNKNOWN = 0x00, + enum EntryType{ ENTRY_TYPE_TOP_LEVEL = 0x00, ENTRY_TYPE_CATEGORY = 0x01, - ENTRY_TYPE_IDENTITY = 0x02 + ENTRY_TYPE_IDENTITY = 0x02, + ENTRY_TYPE_INVALID = 0x03 }; static const int CATEGORY_OWN = 0x00; @@ -87,6 +88,8 @@ public: EntryType type; // type of the entry (group,profile,location) + friend std::ostream& operator<<(std::ostream& o, const EntryIndex& e) { return o << "(" << e.type << "," << e.category_index << "," << e.identity_index << ")";} + // Indices w.r.t. parent. The set of indices entirely determines the position of the entry in the hierarchy. // An index of 0xff means "undefined" @@ -94,8 +97,8 @@ public: uint16_t identity_index; // index of the identity in its own category EntryIndex parent() const; - EntryIndex child(int row,const std::vector& top_level) const; - uint32_t parentRow(int) const; + EntryIndex child(int row) const; + uint32_t parentRow() const; }; QModelIndex root() const{ return createIndex(0,0,(void*)NULL) ;} From ac620d907774ee9dbdddfb357b82a6f614ee09a8 Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 14 Feb 2025 22:01:11 +0100 Subject: [PATCH 24/84] fixed display of reputation --- retroshare-gui/src/gui/Identity/IdDialog.cpp | 48 ++++++++++--------- .../src/gui/Identity/IdentityListModel.cpp | 23 +++++---- retroshare-gui/src/gui/gxs/GxsIdDetails.cpp | 7 ++- 3 files changed, 45 insertions(+), 33 deletions(-) diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index a8e4baba8..768c413b5 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -226,8 +226,8 @@ IdDialog::IdDialog(QWidget *parent) connect(ui->editIdentity, SIGNAL(triggered()), this, SLOT(editIdentity())); connect(ui->chatIdentity, SIGNAL(triggered()), this, SLOT(chatIdentity())); - connect(ui->idTreeWidget, SIGNAL(itemSelectionChanged()), this, SLOT(updateSelection())); - connect(ui->idTreeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(IdListCustomPopupMenu(QPoint))); + connect(ui->idTreeWidget->selectionModel(),SIGNAL(selectionChanged(const QItemSelection&,const QItemSelection&)),this,SLOT(updateSelection())); + connect(ui->idTreeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(IdListCustomPopupMenu(QPoint))); connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString))); connect(ui->ownOpinion_CB, SIGNAL(currentIndexChanged(int)), this, SLOT(modifyReputation())); @@ -1283,6 +1283,7 @@ void IdDialog::updateSelection() { auto id = RsGxsGroupId(getSelectedIdentity()); + std::cerr << "updating selection to id " << id << std::endl; if(id != mId) { mId = id; @@ -2042,8 +2043,13 @@ std::list IdDialog::getSelectedIdentities() const std::list res; for(auto indx:selectedIndexes) + { + RsGxsId id; + if(indx.column() == RsIdentityListModel::COLUMN_THREAD_NAME) // this removes duplicates - res.push_back(mIdListModel->getIdentity(indx)); + if( !(id = mIdListModel->getIdentity(indx)).isNull() ) + res.push_back(id); + } return res; } @@ -2232,29 +2238,27 @@ void IdDialog::IdListCustomPopupMenu( QPoint ) if(n_is_not_a_contact == 0) contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/cancel.svg"), tr("Remove from Contacts"), this, SLOT(removefromContacts())); + } + if (n_selected_items==1) + contextMenu->addAction(QIcon(""),tr("Copy identity to clipboard"),this,SLOT(copyRetroshareLink())) ; - if (n_selected_items==1) - contextMenu->addAction(QIcon(""),tr("Copy identity to clipboard"),this,SLOT(copyRetroshareLink())) ; + contextMenu->addSeparator(); + if(n_positive_reputations == 0) // only unban when all items are banned + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/thumbs-up.png"), tr("Set positive opinion"), this, SLOT(positivePerson())); + + if(n_neutral_reputations == 0) // only unban when all items are banned + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/thumbs-neutral.png"), tr("Set neutral opinion"), this, SLOT(neutralPerson())); + + if(n_negative_reputations == 0) + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/thumbs-down.png"), tr("Set negative opinion"), this, SLOT(negativePerson())); + + if(one_item_owned_by_you && n_selected_items==1) + { contextMenu->addSeparator(); - if(n_positive_reputations == 0) // only unban when all items are banned - contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/thumbs-up.png"), tr("Set positive opinion"), this, SLOT(positivePerson())); - - if(n_neutral_reputations == 0) // only unban when all items are banned - contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/thumbs-neutral.png"), tr("Set neutral opinion"), this, SLOT(neutralPerson())); - - if(n_negative_reputations == 0) - contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/thumbs-down.png"), tr("Set negative opinion"), this, SLOT(negativePerson())); - - if(one_item_owned_by_you && n_selected_items==1) - { - contextMenu->addSeparator(); - - contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_EDIT),tr("Edit identity"),this,SLOT(editIdentity())) ; - contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/cancel.svg"),tr("Delete identity"),this,SLOT(removeIdentity())) ; - } - + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_EDIT),tr("Edit identity"),this,SLOT(editIdentity())) ; + contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/cancel.svg"),tr("Delete identity"),this,SLOT(removeIdentity())) ; } //contextMenu = ui->idTreeWidget->createStandardContextMenu(contextMenu); diff --git a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp index 4f843def7..286f7830c 100644 --- a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp +++ b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp @@ -567,7 +567,6 @@ QVariant RsIdentityListModel::displayRole(const EntryIndex& e, int col) const case COLUMN_THREAD_NAME: return QVariant(QString::fromUtf8(det.mNickname.c_str())); case COLUMN_THREAD_ID: return QVariant(QString::fromStdString(det.mId.toStdString()) ); case COLUMN_THREAD_OWNER: return QVariant(QString::fromStdString(det.mPgpId.toStdString()) ); - case COLUMN_THREAD_REPUTATION: return QVariant(QString::number((uint8_t)det.mReputation.mOverallReputationLevel)); default: return QVariant(); } @@ -579,7 +578,7 @@ QVariant RsIdentityListModel::displayRole(const EntryIndex& e, int col) const } } -// This function makes sure that the internal data gets updated. They are situations where the otification system cannot +// This function makes sure that the internal data gets updated. They are situations where the notification system cannot // send the information about changes, such as when the computer is put on sleep. void RsIdentityListModel::checkInternalData(bool force) @@ -616,12 +615,8 @@ const RsIdentityListModel::HierarchicalIdentityInformation *RsIdentityListModel: QVariant RsIdentityListModel::decorationRole(const EntryIndex& entry,int col) const { - if(col > 0) - return QVariant(); - switch(entry.type) { - case ENTRY_TYPE_CATEGORY: return QVariant(); @@ -632,12 +627,20 @@ QVariant RsIdentityListModel::decorationRole(const EntryIndex& entry,int col) co if(!hn) return QVariant(); - QPixmap sslAvatar; - AvatarDefs::getAvatarFromGxsId(hn->id, sslAvatar); + if(col == COLUMN_THREAD_REPUTATION) + return QVariant( static_cast(rsReputations->overallReputationLevel(hn->id)) ); + else if(col == COLUMN_THREAD_NAME) + { + QPixmap sslAvatar; + AvatarDefs::getAvatarFromGxsId(hn->id, sslAvatar); - return QVariant(QIcon(sslAvatar)); + return QVariant(QIcon(sslAvatar)); + } } - default: return QVariant(); + break; + + default: + return QVariant(); } } diff --git a/retroshare-gui/src/gui/gxs/GxsIdDetails.cpp b/retroshare-gui/src/gui/gxs/GxsIdDetails.cpp index b1961a6e6..d854b1f76 100644 --- a/retroshare-gui/src/gui/gxs/GxsIdDetails.cpp +++ b/retroshare-gui/src/gui/gxs/GxsIdDetails.cpp @@ -95,7 +95,12 @@ void ReputationItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem const QRect r = option.rect; // get pixmap - unsigned int icon_index = qvariant_cast(index.data(Qt::DecorationRole)); + auto v = index.data(Qt::DecorationRole); + + if(!v.canConvert(QVariant::Int)) + return; + + unsigned int icon_index = qvariant_cast(v); if(icon_index > mMaxLevelToDisplay) return ; From 3153df11232aecab3050d305458e3a9dfc5e7713 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 15 Feb 2025 19:55:30 +0100 Subject: [PATCH 25/84] fixed display of icons --- retroshare-gui/src/gui/Identity/IdDialog.cpp | 7 +- .../src/gui/Identity/IdentityListModel.cpp | 74 +++++++++++++++++-- .../src/gui/Identity/IdentityListModel.h | 3 +- 3 files changed, 74 insertions(+), 10 deletions(-) diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index 768c413b5..6269fa3e8 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -328,13 +328,13 @@ IdDialog::IdDialog(QWidget *parent) ui->treeWidget_membership->setColumnWidth(CIRCLEGROUP_CIRCLE_COL_GROUPNAME, 270); /* Setup tree */ - ui->idTreeWidget->sortByColumn(RsIdentityListModel::COLUMN_THREAD_NAME, Qt::AscendingOrder); + //ui->idTreeWidget->sortByColumn(RsIdentityListModel::COLUMN_THREAD_NAME, Qt::AscendingOrder); ui->idTreeWidget->setColumnHidden(RsIdentityListModel::COLUMN_THREAD_OWNER, true); ui->idTreeWidget->setColumnHidden(RsIdentityListModel::COLUMN_THREAD_ID, true); ui->idTreeWidget->setItemDelegate(new RSElidedItemDelegate()); - ui->idTreeWidget->setItemDelegateForColumn( RsIdentityListModel::COLUMN_THREAD_NAME, new GxsIdTreeItemDelegate()); + //ui->idTreeWidget->setItemDelegateForColumn( RsIdentityListModel::COLUMN_THREAD_NAME, new GxsIdTreeItemDelegate()); ui->idTreeWidget->setItemDelegateForColumn( RsIdentityListModel::COLUMN_THREAD_REPUTATION, new ReputationItemDelegate(RsReputationLevel(0xff))); /* Set header resize modes and initial section sizes */ @@ -2124,6 +2124,9 @@ void IdDialog::IdListCustomPopupMenu( QPoint ) auto lst = getSelectedIdentities(); + if(lst.empty()) + return ; + //bool root_node_present = false ; bool one_item_owned_by_you = false ; uint32_t n_positive_reputations = 0 ; diff --git a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp index 286f7830c..08a790076 100644 --- a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp +++ b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp @@ -192,6 +192,7 @@ RsIdentityListModel::EntryIndex RsIdentityListModel::EntryIndex::parent() const i.identity_index = 0; break; case ENTRY_TYPE_TOP_LEVEL: + default: //Can be when request root index. break; } @@ -218,6 +219,7 @@ RsIdentityListModel::EntryIndex RsIdentityListModel::EntryIndex::child(int row) break; case ENTRY_TYPE_IDENTITY: i = EntryIndex(); + default: break; } @@ -338,7 +340,8 @@ QVariant RsIdentityListModel::data(const QModelIndex &index, int role) const case Qt::SizeHintRole: return sizeHintRole(entry,index.column()) ; case Qt::DisplayRole: return displayRole(entry,index.column()) ; case Qt::FontRole: return fontRole(entry,index.column()) ; - case Qt::DecorationRole: return decorationRole(entry,index.column()) ; + case Qt::ForegroundRole: return foregroundRole(entry,index.column()) ; + case Qt::DecorationRole: return decorationRole(entry,index.column()) ; case FilterRole: return filterRole(entry,index.column()) ; case SortRole: return sortRole(entry,index.column()) ; @@ -407,9 +410,37 @@ void RsIdentityListModel::setFilter(FilterType filter_type, const QStringList& s postMods(); } -QVariant RsIdentityListModel::toolTipRole(const EntryIndex& /*fmpe*/,int /*column*/) const +QVariant RsIdentityListModel::toolTipRole(const EntryIndex& fmpe,int /*column*/) const { - return QVariant(); + switch(fmpe.type) + { + case ENTRY_TYPE_IDENTITY: + { + RsGxsId id(mIdentities[mCategories[fmpe.category_index].child_identity_indices[fmpe.identity_index]].id); + + if(rsIdentity->isOwnId(id)) + return QVariant(tr("This identity is owned by you")); + + RsIdentityDetails det; + if(!rsIdentity->getIdDetails(id,det)) + return QVariant(); + + if(det.mPgpId.isNull()) + return QVariant("Anonymous identity"); + else + { + RsPeerDetails dd; + rsPeers->getGPGDetails(det.mPgpId,dd); + + return QVariant("Identity owned by profile \""+ QString::fromUtf8(dd.name.c_str()) +"\" ("+QString::fromStdString(det.mPgpId.toStdString())); + } + } + + break; + case ENTRY_TYPE_CATEGORY: ; // fallthrough + default: + return QVariant(); + } } QVariant RsIdentityListModel::sizeHintRole(const EntryIndex& e,int col) const @@ -418,7 +449,7 @@ QVariant RsIdentityListModel::sizeHintRole(const EntryIndex& e,int col) const float y_factor = QFontMetricsF(QApplication::font()).height()/14.0f ; if(e.type == ENTRY_TYPE_IDENTITY) - y_factor *= 3.0; + y_factor *= 1.0; if(e.type == ENTRY_TYPE_CATEGORY) y_factor *= 1.5; @@ -485,8 +516,39 @@ QModelIndex RsIdentityListModel::getIndexOfIdentity(const RsGxsId& id) const } return QModelIndex(); } -QVariant RsIdentityListModel::fontRole(const EntryIndex& e, int col) const +QVariant RsIdentityListModel::foregroundRole(const EntryIndex& e, int /*col*/) const { + auto it = getIdentityInfo(e); + if(!it) + return QVariant(); + RsGxsId id(it->id); + RsIdentityDetails det; + + if(!rsIdentity->getIdDetails(id,det)) + return QVariant(); + + if(det.mFlags & RS_IDENTITY_FLAGS_IS_DEPRECATED) + return QVariant(QColor(Qt::red)); + + return QVariant(); +} +QVariant RsIdentityListModel::fontRole(const EntryIndex& e, int /*col*/) const +{ + auto it = getIdentityInfo(e); + if(!it) + return QVariant(); + RsGxsId id(it->id); + + if(rsIdentity->isOwnId(id)) + { + QFont f; + f.setBold(true); + return QVariant(f); + } + else + return QVariant(); +} + #ifdef DEBUG_MODEL_INDEX std::cerr << " font role " << e.type << ", (" << (int)e.group_index << ","<< (int)e.profile_index << ","<< (int)e.node_index << ") col="<< col<<": " << std::endl; #endif @@ -511,8 +573,6 @@ QVariant RsIdentityListModel::fontRole(const EntryIndex& e, int col) const return QVariant(); } #endif - return QVariant(); -} QVariant RsIdentityListModel::displayRole(const EntryIndex& e, int col) const { diff --git a/retroshare-gui/src/gui/Identity/IdentityListModel.h b/retroshare-gui/src/gui/Identity/IdentityListModel.h index bd4ecd87e..70ad39de7 100644 --- a/retroshare-gui/src/gui/Identity/IdentityListModel.h +++ b/retroshare-gui/src/gui/Identity/IdentityListModel.h @@ -152,7 +152,8 @@ private: QVariant statusRole (const EntryIndex& e, int col) const; QVariant sortRole (const EntryIndex& e, int col) const; QVariant fontRole (const EntryIndex& e, int col) const; - QVariant textColorRole (const EntryIndex& e, int col) const; + QVariant foregroundRole(const EntryIndex& e, int col) const; + QVariant textColorRole (const EntryIndex& e, int col) const; QVariant filterRole (const EntryIndex& e, int col) const; /*! From 80b90066202facd7f2703b897646534186094d27 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 16 Feb 2025 17:58:08 +0100 Subject: [PATCH 26/84] fixed drop menus for header and data --- retroshare-gui/src/gui/Identity/IdDialog.cpp | 79 +++++++++++++++----- retroshare-gui/src/gui/Identity/IdDialog.h | 4 +- 2 files changed, 63 insertions(+), 20 deletions(-) diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index 6269fa3e8..c44f99ca8 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -229,6 +229,9 @@ IdDialog::IdDialog(QWidget *parent) connect(ui->idTreeWidget->selectionModel(),SIGNAL(selectionChanged(const QItemSelection&,const QItemSelection&)),this,SLOT(updateSelection())); connect(ui->idTreeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(IdListCustomPopupMenu(QPoint))); + ui->idTreeWidget->header()->setContextMenuPolicy(Qt::CustomContextMenu); + connect(ui->idTreeWidget->header(), SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(headerContextMenuRequested(QPoint))); + connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString))); connect(ui->ownOpinion_CB, SIGNAL(currentIndexChanged(int)), this, SLOT(modifyReputation())); @@ -2113,9 +2116,48 @@ void IdDialog::filterIds() mIdListModel->setFilter(ft,{ text }); } +void IdDialog::headerContextMenuRequested(QPoint) +{ + QMenu displayMenu(this); + + // create menu header + //QHBoxLayout *hbox = new QHBoxLayout(widget); + //hbox->setMargin(0); + //hbox->setSpacing(6); + + auto addEntry = [&](const QString& name,RsIdentityListModel::Columns col) + { + QAction *action = displayMenu.addAction(QIcon(), name, this, SLOT(toggleColumnVisible())); + action->setCheckable(true); + action->setData(static_cast(col)); + action->setChecked(!ui->idTreeWidget->header()->isSectionHidden(col)); + }; + + addEntry(tr("Id"),RsIdentityListModel::COLUMN_THREAD_ID); + addEntry(tr("Owner"),RsIdentityListModel::COLUMN_THREAD_OWNER); + addEntry(tr("Reputation"),RsIdentityListModel::COLUMN_THREAD_REPUTATION); + + //addEntry(tr("Name"),RsIdentityListModel::COLUMN_THREAD_NAME); + + displayMenu.exec(QCursor::pos()); +} + +void IdDialog::toggleColumnVisible() +{ + QAction *action = dynamic_cast(sender()); + + std::cerr << "Aciton = " << (void*)action << std::endl; + if (!action) + return; + + int column = action->data().toInt(); + bool visible = action->isChecked(); + + ui->idTreeWidget->setColumnHidden(column, !visible); +} void IdDialog::IdListCustomPopupMenu( QPoint ) { - QMenu *contextMenu = new QMenu(this); + QMenu contextMenu(this); std::list own_identities; rsIdentity->getOwnIds(own_identities); @@ -2172,7 +2214,7 @@ void IdDialog::IdListCustomPopupMenu( QPoint ) if(!one_item_owned_by_you) { - QFrame *widget = new QFrame(contextMenu); + QFrame *widget = new QFrame(&contextMenu); widget->setObjectName("gradFrame"); //Use qss //widget->setStyleSheet( ".QWidget{background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,stop:0 #FEFEFE, stop:1 #E8E8E8); border: 1px solid #CCCCCC;}"); @@ -2199,13 +2241,13 @@ void IdDialog::IdListCustomPopupMenu( QPoint ) QWidgetAction *widgetAction = new QWidgetAction(this); widgetAction->setDefaultWidget(widget); - contextMenu->addAction(widgetAction); + contextMenu.addAction(widgetAction); if(n_selected_items == 1) // if only one item is selected, allow to chat with this item { if(own_identities.size() <= 1) { - QAction *action = contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/chats.png"), tr("Chat with this person"), this, SLOT(chatIdentity())); + QAction *action = contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/chats.png"), tr("Chat with this person"), this, SLOT(chatIdentity())); if(own_identities.empty()) action->setEnabled(false) ; @@ -2214,7 +2256,7 @@ void IdDialog::IdListCustomPopupMenu( QPoint ) } else { - QMenu *mnu = contextMenu->addMenu(FilesDefs::getIconFromQtResourcePath(":/icons/png/chats.png"),tr("Chat with this person as...")) ; + QMenu *mnu = contextMenu.addMenu(FilesDefs::getIconFromQtResourcePath(":/icons/png/chats.png"),tr("Chat with this person as...")) ; for(std::list::const_iterator it=own_identities.begin();it!=own_identities.end();++it) { @@ -2232,42 +2274,41 @@ void IdDialog::IdListCustomPopupMenu( QPoint ) } } // always allow to send messages - contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/mail/write-mail.png"), tr("Send message"), this, SLOT(sendMsg())); + contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(":/icons/mail/write-mail.png"), tr("Send message"), this, SLOT(sendMsg())); - contextMenu->addSeparator(); + contextMenu.addSeparator(); if(n_is_a_contact == 0) - contextMenu->addAction(QIcon(), tr("Add to Contacts"), this, SLOT(addtoContacts())); + contextMenu.addAction(QIcon(), tr("Add to Contacts"), this, SLOT(addtoContacts())); if(n_is_not_a_contact == 0) - contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/cancel.svg"), tr("Remove from Contacts"), this, SLOT(removefromContacts())); + contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(":/icons/cancel.svg"), tr("Remove from Contacts"), this, SLOT(removefromContacts())); } if (n_selected_items==1) - contextMenu->addAction(QIcon(""),tr("Copy identity to clipboard"),this,SLOT(copyRetroshareLink())) ; + contextMenu.addAction(QIcon(""),tr("Copy identity to clipboard"),this,SLOT(copyRetroshareLink())) ; - contextMenu->addSeparator(); + contextMenu.addSeparator(); if(n_positive_reputations == 0) // only unban when all items are banned - contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/thumbs-up.png"), tr("Set positive opinion"), this, SLOT(positivePerson())); + contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/thumbs-up.png"), tr("Set positive opinion"), this, SLOT(positivePerson())); if(n_neutral_reputations == 0) // only unban when all items are banned - contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/thumbs-neutral.png"), tr("Set neutral opinion"), this, SLOT(neutralPerson())); + contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/thumbs-neutral.png"), tr("Set neutral opinion"), this, SLOT(neutralPerson())); if(n_negative_reputations == 0) - contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/thumbs-down.png"), tr("Set negative opinion"), this, SLOT(negativePerson())); + contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(":/icons/png/thumbs-down.png"), tr("Set negative opinion"), this, SLOT(negativePerson())); if(one_item_owned_by_you && n_selected_items==1) { - contextMenu->addSeparator(); + contextMenu.addSeparator(); - contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_EDIT),tr("Edit identity"),this,SLOT(editIdentity())) ; - contextMenu->addAction(FilesDefs::getIconFromQtResourcePath(":/icons/cancel.svg"),tr("Delete identity"),this,SLOT(removeIdentity())) ; + contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_EDIT),tr("Edit identity"),this,SLOT(editIdentity())) ; + contextMenu.addAction(FilesDefs::getIconFromQtResourcePath(":/icons/cancel.svg"),tr("Delete identity"),this,SLOT(removeIdentity())) ; } //contextMenu = ui->idTreeWidget->createStandardContextMenu(contextMenu); - contextMenu->exec(QCursor::pos()); - delete contextMenu; + contextMenu.exec(QCursor::pos()); } void IdDialog::copyRetroshareLink() diff --git a/retroshare-gui/src/gui/Identity/IdDialog.h b/retroshare-gui/src/gui/Identity/IdDialog.h index f88cccda0..106316cf7 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.h +++ b/retroshare-gui/src/gui/Identity/IdDialog.h @@ -99,6 +99,8 @@ private slots: /** Create the context popup menu and it's submenus */ void IdListCustomPopupMenu( QPoint point ); + void headerContextMenuRequested(QPoint); + void toggleColumnVisible(); void CircleListCustomPopupMenu(QPoint point) ; #ifdef SUSPENDED @@ -119,7 +121,7 @@ private: void processSettings(bool load); QString createUsageString(const RsIdentityUsage& u) const; - void requestIdData(std::list &ids); + void requestIdData(std::list &ids); bool fillIdListItem(const RsGxsIdGroup& data, QTreeWidgetItem *&item, const RsPgpId &ownPgpId, int accept); void insertIdList(uint32_t token); void filterIds(); From ed6debb3c6456a2d738e81855f0ea12f2909afd5 Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 17 Feb 2025 23:15:53 +0100 Subject: [PATCH 27/84] added save/load selection (not working yet) --- retroshare-gui/src/gui/Identity/IdDialog.cpp | 131 +++++++++++------- retroshare-gui/src/gui/Identity/IdDialog.h | 6 +- .../src/gui/Identity/IdentityListModel.cpp | 13 +- .../src/gui/Identity/IdentityListModel.h | 2 +- 4 files changed, 97 insertions(+), 55 deletions(-) diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index c44f99ca8..246451574 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -1296,60 +1296,16 @@ void IdDialog::updateSelection() void IdDialog::updateIdList() { + std::set expanded_indices; + std::set > selected_indices; + + saveExpandedPathsAndSelection_idTreeView(expanded_indices, selected_indices); + mIdListModel->updateIdentityList(); + + restoreExpandedPathsAndSelection_idTreeView(expanded_indices, selected_indices); } #ifdef TO_REMOVE -void IdDialog::updateIdList() -{ - //int accept = filter; - std::cerr << "Updating ID list" << std::endl; - - RsThread::async([this]() - { - // 1 - get message data from p3GxsForums - -#ifdef DEBUG_FORUMS - std::cerr << "Retrieving post data for post " << mThreadId << std::endl; -#endif - - std::list identity_metas ; - - if (!rsIdentity->getIdentitiesSummaries(identity_metas)) - { - std::cerr << "IdDialog::insertIdList() Error getting GroupData" << std::endl; - return; - } - - std::set ids; - for(auto it(identity_metas.begin());it!=identity_metas.end();++it) - ids.insert(RsGxsId((*it).mGroupId)); - - std::vector groups; - - if(!rsIdentity->getIdentitiesInfo(ids,groups)) - { - std::cerr << "IdDialog::insertIdList() Error getting identities info" << std::endl; - return; - } - - auto ids_set = new std::map(); - - for(auto it(groups.begin()); it!=groups.end(); ++it) - (*ids_set)[(*it).mMeta.mGroupId] = *it; - - RsQThreadUtils::postToObject( [ids_set, this] () - { - /* Here it goes any code you want to be executed on the Qt Gui - * thread, for example to update the data model with new information - * after a blocking call to RetroShare API complete */ - loadIdentities(*ids_set); - delete ids_set; - - }, this ); - - }); -} - bool IdDialog::fillIdListItem(const RsGxsIdGroup& data, QTreeWidgetItem *&item, const RsPgpId &ownPgpId, int accept) { bool isLinkedToOwnNode = (data.mPgpKnown && (data.mPgpId == ownPgpId)) ; @@ -1633,9 +1589,16 @@ void IdDialog::updateIdentity() * thread, for example to update the data model with new information * after a blocking call to RetroShare API complete */ + std::set expanded_indexes; + std::set > selected_indices; + + saveExpandedPathsAndSelection_idTreeView(expanded_indexes, selected_indices); + loadIdentity(group); - }, this ); + restoreExpandedPathsAndSelection_idTreeView(expanded_indexes, selected_indices); + + }, this ); }); } @@ -2570,3 +2533,67 @@ void IdDialog::restoreExpandedCircleItems(const std::vector& expanded_root restoreTopLevel(mExternalOtherCircleItem,1); restoreTopLevel(mMyCircleItem,2); } + +void IdDialog::saveExpandedPathsAndSelection_idTreeView(std::set& expanded_indexes, + std::set >& selected_indices) +{ + std::cerr << "Saving expended paths and selection..." << std::endl; + + QModelIndexList selectedIndexes = ui->idTreeWidget->selectionModel()->selectedIndexes(); + + // convert all selected indices into something that is not QModelIndex-related, so that we can find it again after refreshing the list + + for(auto m:selectedIndexes) + { + auto t = mIdListModel->getType(m); + QString s ; + + if(t==RsIdentityListModel::ENTRY_TYPE_CATEGORY) + s = QString::number(mIdListModel->getCategory(m)); + else + s = QString::fromStdString(mIdListModel->getIdentity(m).toStdString()); + + selected_indices.insert(std::make_pair(t,s)); + + std::cerr << "added " << s.toStdString() << " to selection save" << std::endl; + } + + for(int row = 0; row < mIdListModel->rowCount(); ++row) + { + auto m = mIdListModel->index(row,0); + + if(ui->idTreeWidget->isExpanded( m )); + expanded_indexes.insert( QString::number(mIdListModel->getCategory(m))); + + std::cerr << "added " << QString::number(mIdListModel->getCategory(m)).toStdString() << " to expanded save" << std::endl; + } + +#ifdef DEBUG_NEW_FRIEND_LIST + std::cerr << " selected index: \"" << sel.toStdString() << "\"" << std::endl; +#endif +} + +void IdDialog::restoreExpandedPathsAndSelection_idTreeView(const std::set& expanded_indexes, + const std::set >& selected_indices) +{ + std::cerr << "Restoring expended paths and selection..." << std::endl; +#ifdef DEBUG_NEW_FRIEND_LIST + std::cerr << " index to select: \"" << index_to_select.toStdString() << "\"" << std::endl; +#endif + ui->idTreeWidget->blockSignals(true) ; + + for(int row = 0; row < mIdListModel->rowCount(); ++row) + { + auto m = mIdListModel->index(row,0); + + if(expanded_indexes.find(QString::number(mIdListModel->getCategory(m))) != expanded_indexes.end()) + { + ui->idTreeWidget->setExpanded(m,true); + } + } + + //ui->idTreeWidget->selectionModel()->select(index, QItemSelectionModel::Select | QItemSelectionModel::Rows); + + ui->idTreeWidget->blockSignals(false) ; +} + diff --git a/retroshare-gui/src/gui/Identity/IdDialog.h b/retroshare-gui/src/gui/Identity/IdDialog.h index 106316cf7..4822e52c7 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.h +++ b/retroshare-gui/src/gui/Identity/IdDialog.h @@ -23,7 +23,8 @@ #include "gui/gxs/RsGxsUpdateBroadcastPage.h" -#include +#include "retroshare/rsidentity.h" +#include "IdentityListModel.h" #include @@ -121,6 +122,9 @@ private: void processSettings(bool load); QString createUsageString(const RsIdentityUsage& u) const; + void restoreExpandedPathsAndSelection_idTreeView(const std::set& expanded_indexes, const std::set >& selected_indices); + void saveExpandedPathsAndSelection_idTreeView(std::set& expanded_indexes, std::set >& selected_indices); + void requestIdData(std::list &ids); bool fillIdListItem(const RsGxsIdGroup& data, QTreeWidgetItem *&item, const RsPgpId &ownPgpId, int accept); void insertIdList(uint32_t token); diff --git a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp index 08a790076..cfe0ef4ff 100644 --- a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp +++ b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp @@ -785,6 +785,17 @@ RsIdentityListModel::EntryType RsIdentityListModel::getType(const QModelIndex& i return e.type; } +int RsIdentityListModel::getCategory(const QModelIndex& i) const +{ + if(!i.isValid()) + return CATEGORY_ALL; + + EntryIndex e; + if(!convertInternalIdToIndex(i.internalId(),e)) + return CATEGORY_ALL; + + return e.category_index; +} void RsIdentityListModel::setIdentities(const std::list& identities_meta) { preMods(); @@ -848,7 +859,7 @@ void RsIdentityListModel::updateIdentityList() setIdentities(*ids) ; delete ids; - debug_dump(); + //debug_dump(); }, this ); diff --git a/retroshare-gui/src/gui/Identity/IdentityListModel.h b/retroshare-gui/src/gui/Identity/IdentityListModel.h index 70ad39de7..6e6f93146 100644 --- a/retroshare-gui/src/gui/Identity/IdentityListModel.h +++ b/retroshare-gui/src/gui/Identity/IdentityListModel.h @@ -111,8 +111,8 @@ public: // This method will asynchroneously update the data EntryType getType(const QModelIndex&) const; - RsGxsId getIdentity(const QModelIndex&) const; + int getCategory(const QModelIndex&) const; void setFilter(FilterType filter_type, const QStringList& strings) ; From c61c939b2a6bdfa35c86bd758189ea505ef91f8b Mon Sep 17 00:00:00 2001 From: defnax Date: Tue, 18 Feb 2025 19:56:11 +0100 Subject: [PATCH 28/84] Fixed to get fonts work in forums tree --- retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp index f19bfee5a..8a0357303 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp @@ -308,10 +308,10 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget connect(ui->latestPostInThreadView_TB, SIGNAL(toggled(bool)), this, SLOT(toggleLstPostInThreadView(bool))); /* Set own item delegate */ - RSElidedItemDelegate *itemDelegate = new RSElidedItemDelegate(this); - itemDelegate->setSpacing(QSize(0, 2)); - itemDelegate->setOnlyPlainText(true); - ui->threadTreeWidget->setItemDelegate(itemDelegate); + //RSElidedItemDelegate *itemDelegate = new RSElidedItemDelegate(this); + //itemDelegate->setSpacing(QSize(0, 2)); + //itemDelegate->setOnlyPlainText(true); + //ui->threadTreeWidget->setItemDelegate(itemDelegate); /* add filter actions */ ui->filterLineEdit->addFilter(QIcon(), tr("Title"), RsGxsForumModel::COLUMN_THREAD_TITLE, tr("Search Title")); From 37c0f16a273c02055e7cfb95408f649be27639c8 Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 19 Feb 2025 12:05:21 +0100 Subject: [PATCH 29/84] fixed update of visible items --- retroshare-gui/src/gui/Identity/IdDialog.cpp | 87 ++++++++++++------- .../src/gui/Identity/IdentityListModel.cpp | 27 +++++- .../src/gui/Identity/IdentityListModel.h | 8 ++ 3 files changed, 90 insertions(+), 32 deletions(-) diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index 246451574..5327bdbfb 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -1296,6 +1296,9 @@ void IdDialog::updateSelection() void IdDialog::updateIdList() { + std::cerr << "Updating identity list in widget: stack is:" << std::endl; + //print_stacktrace(); + std::set expanded_indices; std::set > selected_indices; @@ -1592,11 +1595,11 @@ void IdDialog::updateIdentity() std::set expanded_indexes; std::set > selected_indices; - saveExpandedPathsAndSelection_idTreeView(expanded_indexes, selected_indices); + //saveExpandedPathsAndSelection_idTreeView(expanded_indexes, selected_indices); loadIdentity(group); - restoreExpandedPathsAndSelection_idTreeView(expanded_indexes, selected_indices); + //restoreExpandedPathsAndSelection_idTreeView(expanded_indexes, selected_indices); }, this ); }); @@ -1785,9 +1788,9 @@ void IdDialog::loadIdentity(RsGxsIdGroup data) switch(info.mOwnOpinion) { - case RsOpinion::NEGATIVE: ui->ownOpinion_CB->setCurrentIndex(0); break; - case RsOpinion::NEUTRAL : ui->ownOpinion_CB->setCurrentIndex(1); break; - case RsOpinion::POSITIVE: ui->ownOpinion_CB->setCurrentIndex(2); break; + case RsOpinion::NEGATIVE: whileBlocking(ui->ownOpinion_CB)->setCurrentIndex(0); break; + case RsOpinion::NEUTRAL : whileBlocking(ui->ownOpinion_CB)->setCurrentIndex(1); break; + case RsOpinion::POSITIVE: whileBlocking(ui->ownOpinion_CB)->setCurrentIndex(2); break; default: std::cerr << "Unexpected value in own opinion: " << static_cast(info.mOwnOpinion) << std::endl; @@ -2537,35 +2540,37 @@ void IdDialog::restoreExpandedCircleItems(const std::vector& expanded_root void IdDialog::saveExpandedPathsAndSelection_idTreeView(std::set& expanded_indexes, std::set >& selected_indices) { - std::cerr << "Saving expended paths and selection..." << std::endl; + std::cerr << "Saving expended paths and selection... thread " << (void*)pthread_self() << std::endl; QModelIndexList selectedIndexes = ui->idTreeWidget->selectionModel()->selectedIndexes(); // convert all selected indices into something that is not QModelIndex-related, so that we can find it again after refreshing the list for(auto m:selectedIndexes) - { - auto t = mIdListModel->getType(m); - QString s ; + if(m.column()==RsIdentityListModel::COLUMN_THREAD_ID) + { + auto t = mIdListModel->getType(m); + QString s ; - if(t==RsIdentityListModel::ENTRY_TYPE_CATEGORY) - s = QString::number(mIdListModel->getCategory(m)); - else - s = QString::fromStdString(mIdListModel->getIdentity(m).toStdString()); + if(t==RsIdentityListModel::ENTRY_TYPE_CATEGORY) + s = QString::number(mIdListModel->getCategory(m)); + else + s = QString::fromStdString(mIdListModel->getIdentity(m).toStdString()); - selected_indices.insert(std::make_pair(t,s)); + selected_indices.insert(std::make_pair(t,s)); - std::cerr << "added " << s.toStdString() << " to selection save" << std::endl; - } + std::cerr << "added " << s.toStdString() << " to selection save" << std::endl; + } for(int row = 0; row < mIdListModel->rowCount(); ++row) { - auto m = mIdListModel->index(row,0); + auto m = mIdListModel->index(row,0,QModelIndex()); - if(ui->idTreeWidget->isExpanded( m )); - expanded_indexes.insert( QString::number(mIdListModel->getCategory(m))); - - std::cerr << "added " << QString::number(mIdListModel->getCategory(m)).toStdString() << " to expanded save" << std::endl; + if(ui->idTreeWidget->isExpanded( m )) + { + expanded_indexes.insert( QString::number(mIdListModel->getCategory(m))); + std::cerr << "added " << QString::number(mIdListModel->getCategory(m)).toStdString() << " to expanded save" << std::endl; + } } #ifdef DEBUG_NEW_FRIEND_LIST @@ -2577,23 +2582,47 @@ void IdDialog::restoreExpandedPathsAndSelection_idTreeView(const std::set >& selected_indices) { std::cerr << "Restoring expended paths and selection..." << std::endl; -#ifdef DEBUG_NEW_FRIEND_LIST + ui->idTreeWidget->blockSignals(true) ; + ui->idTreeWidget->selectionModel()->blockSignals(true); + + ui->idTreeWidget->selectionModel()->clear(); + + for(auto it:selected_indices) + { + if(it.first==RsIdentityListModel::ENTRY_TYPE_CATEGORY) + ui->idTreeWidget->selectionModel()->select(mIdListModel->index(it.first,0,QModelIndex()),QItemSelectionModel::Select | QItemSelectionModel::Rows); + else if(it.first==RsIdentityListModel::ENTRY_TYPE_IDENTITY) + { + auto indx = mIdListModel->getIndexOfIdentity(RsGxsId(it.second.toStdString())); + + if(indx.isValid()) + { + std::cerr << "trying to resotre selection of id " << it.second.toStdString() << std::endl; + ui->idTreeWidget->selectionModel()->select(indx,QItemSelectionModel::Select | QItemSelectionModel::Rows); + } + else + std::cerr << "Index is invalid!" << std::endl; + } + } + //ui->idTreeWidget->selectionModel()->select(index, QItemSelectionModel::Select | QItemSelectionModel::Rows); + + ui->idTreeWidget->blockSignals(false) ; + ui->idTreeWidget->selectionModel()->blockSignals(false); + + #ifdef DEBUG_NEW_FRIEND_LIST std::cerr << " index to select: \"" << index_to_select.toStdString() << "\"" << std::endl; #endif - ui->idTreeWidget->blockSignals(true) ; - for(int row = 0; row < mIdListModel->rowCount(); ++row) { - auto m = mIdListModel->index(row,0); + auto m = mIdListModel->index(row,0,QModelIndex()); if(expanded_indexes.find(QString::number(mIdListModel->getCategory(m))) != expanded_indexes.end()) { + std::cerr << "Restoring expanded index " << QString::number(mIdListModel->getCategory(m)).toStdString() << std::endl; ui->idTreeWidget->setExpanded(m,true); } + else + ui->idTreeWidget->setExpanded(m,false); } - - //ui->idTreeWidget->selectionModel()->select(index, QItemSelectionModel::Select | QItemSelectionModel::Rows); - - ui->idTreeWidget->blockSignals(false) ; } diff --git a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp index cfe0ef4ff..0f14d406f 100644 --- a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp +++ b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp @@ -54,8 +54,15 @@ RsIdentityListModel::RsIdentityListModel(QObject *parent) , mLastInternalDataUpdate(0), mLastNodeUpdate(0) { mFilterStrings.clear(); + mIdentityUpdateTimer = new QTimer(); + connect(mIdentityUpdateTimer,SIGNAL(timeout()),this,SLOT(timerUpdate())); } +void RsIdentityListModel::timerUpdate() +{ + std::cerr << "updating indices" << std::endl; + emit dataChanged(index(0,0,QModelIndex()),index(2,0,QModelIndex())); +} RsIdentityListModel::EntryIndex::EntryIndex() : type(ENTRY_TYPE_INVALID),category_index(0),identity_index(0) { @@ -410,6 +417,18 @@ void RsIdentityListModel::setFilter(FilterType filter_type, const QStringList& s postMods(); } +bool RsIdentityListModel::requestIdentityDetails(const RsGxsId& id,RsIdentityDetails& det) const +{ + if(!rsIdentity->getIdDetails(id,det)) + { + mIdentityUpdateTimer->stop(); + mIdentityUpdateTimer->setSingleShot(true); + mIdentityUpdateTimer->start(500); + return false; + } + + return true; +} QVariant RsIdentityListModel::toolTipRole(const EntryIndex& fmpe,int /*column*/) const { switch(fmpe.type) @@ -422,7 +441,7 @@ QVariant RsIdentityListModel::toolTipRole(const EntryIndex& fmpe,int /*column*/) return QVariant(tr("This identity is owned by you")); RsIdentityDetails det; - if(!rsIdentity->getIdDetails(id,det)) + if(!requestIdentityDetails(id,det)) return QVariant(); if(det.mPgpId.isNull()) @@ -524,7 +543,7 @@ QVariant RsIdentityListModel::foregroundRole(const EntryIndex& e, int /*col*/) c RsGxsId id(it->id); RsIdentityDetails det; - if(!rsIdentity->getIdDetails(id,det)) + if(!requestIdentityDetails(id,det)) return QVariant(); if(det.mFlags & RS_IDENTITY_FLAGS_IS_DEPRECATED) @@ -616,7 +635,7 @@ QVariant RsIdentityListModel::displayRole(const EntryIndex& e, int col) const RsIdentityDetails det; - if(!rsIdentity->getIdDetails(idinfo->id,det)) + if(!requestIdentityDetails(idinfo->id,det)) return QVariant(); #ifdef DEBUG_MODEL_INDEX @@ -696,6 +715,8 @@ QVariant RsIdentityListModel::decorationRole(const EntryIndex& entry,int col) co return QVariant(QIcon(sslAvatar)); } + else + return QVariant(); } break; diff --git a/retroshare-gui/src/gui/Identity/IdentityListModel.h b/retroshare-gui/src/gui/Identity/IdentityListModel.h index 6e6f93146..9bf96205f 100644 --- a/retroshare-gui/src/gui/Identity/IdentityListModel.h +++ b/retroshare-gui/src/gui/Identity/IdentityListModel.h @@ -32,6 +32,8 @@ typedef uint32_t ForumModelIndex; // This class is the item model used by Qt to display the information +class QTimer; + class RsIdentityListModel : public QAbstractItemModel { Q_OBJECT @@ -164,6 +166,7 @@ private: public slots: void checkInternalData(bool force); void debug_dump() const; + void timerUpdate(); signals: void dataLoaded(); // emitted after the messages have been set. Can be used to updated the UI. @@ -181,6 +184,8 @@ private: void *getChildRef(void *ref,int row) const; int getChildrenCount(void *ref) const; + bool requestIdentityDetails(const RsGxsId& id,RsIdentityDetails& det) const; + static bool convertIndexToInternalId(const EntryIndex& e,quintptr& ref); static bool convertInternalIdToIndex(quintptr ref, EntryIndex& e); @@ -209,5 +214,8 @@ private: // keeps track of expanded/collapsed items, so as to only show icon for collapsed profiles std::vector mExpandedCategories; + + // List of identities for which getIdDetails() failed, to be requested again. + mutable QTimer *mIdentityUpdateTimer; }; From a826a8651cd489cfd6ff39528781398eaf162b2f Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 23 Feb 2025 14:50:48 +0100 Subject: [PATCH 30/84] added filtering --- retroshare-gui/src/gui/Identity/IdDialog.cpp | 179 +++++++++++++++--- retroshare-gui/src/gui/Identity/IdDialog.h | 7 + .../src/gui/Identity/IdentityListModel.cpp | 2 +- 3 files changed, 157 insertions(+), 31 deletions(-) diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index 5327bdbfb..3081e8424 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -146,6 +146,59 @@ class TreeWidgetItem : public QTreeWidgetItem }; #endif +std::ostream& operator<<(std::ostream& o, const QModelIndex& i);// defined elsewhere + +class IdListSortFilterProxyModel: public QSortFilterProxyModel +{ +public: + explicit IdListSortFilterProxyModel(const QHeaderView *header,QObject *parent = NULL) + : QSortFilterProxyModel(parent) + , m_header(header) + , m_sortingEnabled(false), m_sortByState(false) + { + setDynamicSortFilter(false); // causes crashes when true. + } + + bool lessThan(const QModelIndex& left, const QModelIndex& right) const override + { +// bool online1 = (left .data(RsFriendListModel::OnlineRole).toInt() != RS_STATUS_OFFLINE); +// bool online2 = (right.data(RsFriendListModel::OnlineRole).toInt() != RS_STATUS_OFFLINE); +// +// if((online1 != online2) && m_sortByState) +// return (m_header->sortIndicatorOrder()==Qt::AscendingOrder)?online1:online2 ; // always put online nodes first + +#ifdef DEBUG_NEW_FRIEND_LIST + std::cerr << "Comparing index " << left << " with index " << right << std::endl; +#endif + return QSortFilterProxyModel::lessThan(left,right); + } + + bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override + { + // do not show empty groups + + QModelIndex index = sourceModel()->index(source_row,0,source_parent); + + return index.data(RsIdentityListModel::FilterRole).toString() == RsIdentityListModel::FilterString ; + } + + void sort( int column, Qt::SortOrder order = Qt::AscendingOrder ) override + { + if(m_sortingEnabled) + return QSortFilterProxyModel::sort(column,order) ; + } + + void setSortingEnabled(bool b) { m_sortingEnabled = b ; } + void setSortByState(bool b) { m_sortByState = b ; } + bool sortByState() const { return m_sortByState ; } + +private: + const QHeaderView *m_header ; + bool m_sortingEnabled; + bool m_sortByState; +}; + + /** Constructor */ IdDialog::IdDialog(QWidget *parent) : MainPage(parent) @@ -169,7 +222,15 @@ IdDialog::IdDialog(QWidget *parent) mIdListModel = new RsIdentityListModel(this); - ui->idTreeWidget->setModel(mIdListModel); + mProxyModel = new IdListSortFilterProxyModel(ui->idTreeWidget->header(),this); + + mProxyModel->setSourceModel(mIdListModel); + mProxyModel->setSortRole(RsIdentityListModel::SortRole); + mProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); + mProxyModel->setFilterRole(RsIdentityListModel::FilterRole); + mProxyModel->setFilterRegExp(QRegExp(RsIdentityListModel::FilterString)); + + ui->idTreeWidget->setModel(mProxyModel); ui->treeWidget_membership->clear(); ui->treeWidget_membership->setItemDelegateForColumn(CIRCLEGROUP_CIRCLE_COL_GROUPNAME,new GxsIdTreeItemDelegate()); @@ -1206,9 +1267,18 @@ IdDialog::~IdDialog() // save settings processSettings(false); + delete mIdListModel; + delete mProxyModel; delete(ui); } - +void IdDialog::idListItemExpanded(const QModelIndex& index) +{ + mIdListModel->expandItem(mProxyModel->mapToSource(index)); +} +void IdDialog::idListItemCollapsed(const QModelIndex& index) +{ + mIdListModel->collapseItem(mProxyModel->mapToSource(index)); +} static QString getHumanReadableDuration(uint32_t seconds) { if(seconds < 60) @@ -1299,14 +1369,7 @@ void IdDialog::updateIdList() std::cerr << "Updating identity list in widget: stack is:" << std::endl; //print_stacktrace(); - std::set expanded_indices; - std::set > selected_indices; - - saveExpandedPathsAndSelection_idTreeView(expanded_indices, selected_indices); - - mIdListModel->updateIdentityList(); - - restoreExpandedPathsAndSelection_idTreeView(expanded_indices, selected_indices); + applyWhileKeepingTree( [this]() { mIdListModel->updateIdentityList(); }); } #ifdef TO_REMOVE bool IdDialog::fillIdListItem(const RsGxsIdGroup& data, QTreeWidgetItem *&item, const RsPgpId &ownPgpId, int accept) @@ -1595,12 +1658,8 @@ void IdDialog::updateIdentity() std::set expanded_indexes; std::set > selected_indices; - //saveExpandedPathsAndSelection_idTreeView(expanded_indexes, selected_indices); - loadIdentity(group); - //restoreExpandedPathsAndSelection_idTreeView(expanded_indexes, selected_indices); - }, this ); }); } @@ -2016,7 +2075,7 @@ std::list IdDialog::getSelectedIdentities() const RsGxsId id; if(indx.column() == RsIdentityListModel::COLUMN_THREAD_NAME) // this removes duplicates - if( !(id = mIdListModel->getIdentity(indx)).isNull() ) + if( !(id = mIdListModel->getIdentity(mProxyModel->mapToSource(indx))).isNull() ) res.push_back(id); } @@ -2553,23 +2612,24 @@ void IdDialog::saveExpandedPathsAndSelection_idTreeView(std::set& expan QString s ; if(t==RsIdentityListModel::ENTRY_TYPE_CATEGORY) - s = QString::number(mIdListModel->getCategory(m)); + s = QString::number(mIdListModel->getCategory(mProxyModel->mapToSource(m))); else - s = QString::fromStdString(mIdListModel->getIdentity(m).toStdString()); + s = QString::fromStdString(mIdListModel->getIdentity(mProxyModel->mapToSource(m)).toStdString()); selected_indices.insert(std::make_pair(t,s)); std::cerr << "added " << s.toStdString() << " to selection save" << std::endl; } - for(int row = 0; row < mIdListModel->rowCount(); ++row) + for(int row = 0; row < mProxyModel->rowCount(); ++row) { - auto m = mIdListModel->index(row,0,QModelIndex()); + auto m = mProxyModel->index(row,0); if(ui->idTreeWidget->isExpanded( m )) { - expanded_indexes.insert( QString::number(mIdListModel->getCategory(m))); - std::cerr << "added " << QString::number(mIdListModel->getCategory(m)).toStdString() << " to expanded save" << std::endl; + auto str = QString::number(mIdListModel->getCategory(mProxyModel->mapToSource(m))); + expanded_indexes.insert( str ); + std::cerr << "added " << m << " cat " << str.toStdString() << " to expanded save" << std::endl; } } @@ -2585,19 +2645,17 @@ void IdDialog::restoreExpandedPathsAndSelection_idTreeView(const std::setidTreeWidget->blockSignals(true) ; ui->idTreeWidget->selectionModel()->blockSignals(true); - ui->idTreeWidget->selectionModel()->clear(); - for(auto it:selected_indices) { if(it.first==RsIdentityListModel::ENTRY_TYPE_CATEGORY) - ui->idTreeWidget->selectionModel()->select(mIdListModel->index(it.first,0,QModelIndex()),QItemSelectionModel::Select | QItemSelectionModel::Rows); + ui->idTreeWidget->selectionModel()->select(mProxyModel->mapFromSource(mIdListModel->index(it.first,0,QModelIndex())),QItemSelectionModel::Select | QItemSelectionModel::Rows); else if(it.first==RsIdentityListModel::ENTRY_TYPE_IDENTITY) { - auto indx = mIdListModel->getIndexOfIdentity(RsGxsId(it.second.toStdString())); + auto indx = mProxyModel->mapFromSource(mIdListModel->getIndexOfIdentity(RsGxsId(it.second.toStdString()))); if(indx.isValid()) { - std::cerr << "trying to resotre selection of id " << it.second.toStdString() << std::endl; + std::cerr << "trying to restore selection of id " << it.second.toStdString() << std::endl; ui->idTreeWidget->selectionModel()->select(indx,QItemSelectionModel::Select | QItemSelectionModel::Rows); } else @@ -2606,23 +2664,84 @@ void IdDialog::restoreExpandedPathsAndSelection_idTreeView(const std::setidTreeWidget->selectionModel()->select(index, QItemSelectionModel::Select | QItemSelectionModel::Rows); - ui->idTreeWidget->blockSignals(false) ; - ui->idTreeWidget->selectionModel()->blockSignals(false); - #ifdef DEBUG_NEW_FRIEND_LIST std::cerr << " index to select: \"" << index_to_select.toStdString() << "\"" << std::endl; #endif for(int row = 0; row < mIdListModel->rowCount(); ++row) { - auto m = mIdListModel->index(row,0,QModelIndex()); + auto m = ui->idTreeWidget->model()->index(row,0); + + std::cerr << " index category = " << mIdListModel->getCategory(m) << std::endl; if(expanded_indexes.find(QString::number(mIdListModel->getCategory(m))) != expanded_indexes.end()) { std::cerr << "Restoring expanded index " << QString::number(mIdListModel->getCategory(m)).toStdString() << std::endl; + std::cerr << "Calling setExpanded " << m << std::endl; ui->idTreeWidget->setExpanded(m,true); } else ui->idTreeWidget->setExpanded(m,false); } + ui->idTreeWidget->blockSignals(false) ; + ui->idTreeWidget->selectionModel()->blockSignals(false); } +void IdDialog::applyWhileKeepingTree(std::function predicate) +{ + std::set expanded_indexes; + std::set > selected; + + saveExpandedPathsAndSelection_idTreeView(expanded_indexes, selected); + +#ifdef DEBUG_NEW_FRIEND_LIST + std::cerr << "After collecting selection, selected paths is: \"" << selected.toStdString() << "\", " ; + std::cerr << "expanded paths are: " << std::endl; + for(auto path:expanded_indexes) + std::cerr << " \"" << path.toStdString() << "\"" << std::endl; + std::cerr << "Current sort column is: " << mLastSortColumn << " and order is " << mLastSortOrder << std::endl; +#endif + whileBlocking(ui->idTreeWidget)->clearSelection(); + + // This is a hack to avoid crashes on windows while calling endInsertRows(). I'm not sure wether these crashes are + // due to a Qt bug, or a misuse of the proxy model on my side. Anyway, this solves them for good. + // As a side effect we need to save/restore hidden columns because setSourceModel() resets this setting. + + // save hidden columns and sizes + std::vector col_visible(RsIdentityListModel::COLUMN_THREAD_NB_COLUMNS); + std::vector col_sizes(RsIdentityListModel::COLUMN_THREAD_NB_COLUMNS); + + for(int i=0;iidTreeWidget->isColumnHidden(i); + col_sizes[i] = ui->idTreeWidget->columnWidth(i); + } + +#ifdef DEBUG_NEW_FRIEND_LIST + std::cerr << "Applying predicate..." << std::endl; +#endif + mProxyModel->setSourceModel(nullptr); + + predicate(); + + mProxyModel->setSourceModel(mIdListModel); + restoreExpandedPathsAndSelection_idTreeView(expanded_indexes,selected); + + // restore hidden columns + for(uint32_t i=0;iidTreeWidget->setColumnHidden(i,!col_visible[i]); + ui->idTreeWidget->setColumnWidth(i,col_sizes[i]); + } + + // restore sorting + // sortColumn(mLastSortColumn,mLastSortOrder); +#ifdef DEBUG_NEW_FRIEND_LIST + std::cerr << "Sorting again with sort column: " << mLastSortColumn << " and order " << mLastSortOrder << std::endl; +#endif + mProxyModel->setSortingEnabled(true); +// mProxyModel->sort(mLastSortColumn,mLastSortOrder); + mProxyModel->setSortingEnabled(false); + +// if(selected_index.isValid()) +// ui->idTreeWidget->scrollTo(selected_index); +} diff --git a/retroshare-gui/src/gui/Identity/IdDialog.h b/retroshare-gui/src/gui/Identity/IdDialog.h index 4822e52c7..594f4f5e3 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.h +++ b/retroshare-gui/src/gui/Identity/IdDialog.h @@ -37,6 +37,7 @@ class IdDialog; class UIStateHelper; class QTreeWidgetItem; class RsIdentityListModel; +class IdListSortFilterProxyModel; class IdDialog : public MainPage { @@ -150,14 +151,20 @@ private: void saveExpandedCircleItems(std::vector &expanded_root_items, std::set& expanded_circle_items) const; void restoreExpandedCircleItems(const std::vector& expanded_root_items,const std::set& expanded_circle_items); + void applyWhileKeepingTree(std::function predicate); + RsGxsId getSelectedIdentity() const; std::list getSelectedIdentities() const; + void idListItemExpanded(const QModelIndex& index); + void idListItemCollapsed(const QModelIndex& index); + RsGxsGroupId mId; RsGxsGroupId mIdToNavigate; int filter; RsIdentityListModel *mIdListModel; + IdListSortFilterProxyModel *mProxyModel; void handleEvent_main_thread(std::shared_ptr event); RsEventsHandlerId_t mEventHandlerId_identity; diff --git a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp index 0f14d406f..3d4b579d7 100644 --- a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp +++ b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp @@ -96,7 +96,7 @@ bool RsIdentityListModel::convertIndexToInternalId(const EntryIndex& e,quintptr& return false; } - id = (((uint32_t)e.category_index) << 30) + ((uint32_t)e.identity_index << 2) + ((uint32_t)e.type); + id = ((0x3 & (uint32_t)e.category_index) << 30) + ((uint32_t)e.identity_index << 2) + (0x3 & (uint32_t)e.type); return true; } From ee27c528257336e9c29acda365f8907df5281007 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 23 Feb 2025 16:33:47 +0100 Subject: [PATCH 31/84] improved save/restore of selection/expanded items --- retroshare-gui/src/gui/Identity/IdDialog.cpp | 101 +++++++++++++++++- retroshare-gui/src/gui/Identity/IdDialog.h | 11 +- .../src/gui/Identity/IdentityListModel.cpp | 8 ++ .../src/gui/Identity/IdentityListModel.h | 2 + 4 files changed, 114 insertions(+), 8 deletions(-) diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index 3081e8424..405ab9479 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -238,6 +238,9 @@ IdDialog::IdDialog(QWidget *parent) /* Setup UI helper */ mStateHelper = new UIStateHelper(this); + connect(ui->idTreeWidget,SIGNAL(expanded(const QModelIndex&)),this,SLOT(trace_expanded(const QModelIndex&)),Qt::DirectConnection); + connect(ui->idTreeWidget,SIGNAL(collapsed(const QModelIndex&)),this,SLOT(trace_collapsed(const QModelIndex&)),Qt::DirectConnection); + mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui->lineEdit_PublishTS); mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui->lineEdit_KeyId); mStateHelper->addWidget(IDDIALOG_IDDETAILS, ui->lineEdit_Type); @@ -2596,6 +2599,7 @@ void IdDialog::restoreExpandedCircleItems(const std::vector& expanded_root restoreTopLevel(mMyCircleItem,2); } +#ifdef TO_REMOVE void IdDialog::saveExpandedPathsAndSelection_idTreeView(std::set& expanded_indexes, std::set >& selected_indices) { @@ -2685,13 +2689,13 @@ void IdDialog::restoreExpandedPathsAndSelection_idTreeView(const std::setidTreeWidget->blockSignals(false) ; ui->idTreeWidget->selectionModel()->blockSignals(false); } +#endif void IdDialog::applyWhileKeepingTree(std::function predicate) { - std::set expanded_indexes; - std::set > selected; + std::set expanded,selected; - saveExpandedPathsAndSelection_idTreeView(expanded_indexes, selected); + saveExpandedPathsAndSelection_idTreeView(expanded, selected); #ifdef DEBUG_NEW_FRIEND_LIST std::cerr << "After collecting selection, selected paths is: \"" << selected.toStdString() << "\", " ; @@ -2724,7 +2728,7 @@ void IdDialog::applyWhileKeepingTree(std::function predicate) predicate(); mProxyModel->setSourceModel(mIdListModel); - restoreExpandedPathsAndSelection_idTreeView(expanded_indexes,selected); + restoreExpandedPathsAndSelection_idTreeView(expanded,selected); // restore hidden columns for(uint32_t i=0;i predicate) // if(selected_index.isValid()) // ui->idTreeWidget->scrollTo(selected_index); } +#define DEBUG_ID_DIALOG + +void IdDialog::saveExpandedPathsAndSelection_idTreeView(std::set& expanded, std::set& selected) +{ +// QModelIndexList selectedIndexes = ui->idTreeWidget->selectionModel()->selectedIndexes(); +// QModelIndex current_index = selectedIndexes.empty()?QModelIndex():(*selectedIndexes.begin()); + +#ifdef DEBUG_ID_DIALOG + std::cerr << "Saving expended paths and selection..." << std::endl; +#endif + + for(int row = 0; row < mProxyModel->rowCount(); ++row) + recursSaveExpandedItems_idTreeView(mProxyModel->index(row,0),QStringList(),expanded,selected); +} + +void IdDialog::restoreExpandedPathsAndSelection_idTreeView(const std::set& expanded, const std::set& selected) +{ + ui->idTreeWidget->blockSignals(true) ; + + for(int row = 0; row < mProxyModel->rowCount(); ++row) + recursRestoreExpandedItems_idTreeView(mProxyModel->index(row,0),QStringList(),expanded,selected); + + ui->idTreeWidget->blockSignals(false) ; +} + +void IdDialog::recursSaveExpandedItems_idTreeView(const QModelIndex& index,const QStringList& parent_path,std::set& expanded,std::set& selected) +{ + QStringList local_path = parent_path; + local_path.push_back(index.sibling(index.row(),RsIdentityListModel::COLUMN_THREAD_NAME).data(RsIdentityListModel::TreePathRole).toString()) ; + + if(ui->idTreeWidget->isExpanded(index)) + { +#ifdef DEBUG_ID_DIALOG + std::cerr << "Adding expanded path "; + for(auto L:local_path) std::cerr << "\"" << L.toStdString() << "\" " ; std::cerr << std::endl; +#endif + if(index.isValid()) + expanded.insert(local_path) ; + + for(int row=0;rowrowCount(index);++row) + recursSaveExpandedItems_idTreeView(index.child(row,0),local_path,expanded,selected) ; + } + + if(ui->idTreeWidget->selectionModel()->isSelected(index)) + { +#ifdef DEBUG_ID_DIALOG + std::cerr << "Adding selected path "; + for(auto L:local_path) std::cerr << "\"" << L.toStdString() << "\" " ; std::cerr << std::endl; +#endif + selected.insert(local_path); + } +} + +void IdDialog::recursRestoreExpandedItems_idTreeView(const QModelIndex& index,const QStringList& parent_path,const std::set& expanded,const std::set& selected) +{ + QStringList local_path = parent_path; + local_path.push_back(index.sibling(index.row(),RsIdentityListModel::COLUMN_THREAD_NAME).data(RsIdentityListModel::TreePathRole).toString()) ; + + if(expanded.find(local_path) != expanded.end()) + { +#ifdef DEBUG_ID_DIALOG + std::cerr << " re expanding " ; + for(auto L:local_path) std::cerr << "\"" << L.toStdString() << "\" " ; std::cerr << std::endl; +#endif + + ui->idTreeWidget->setExpanded(index,true) ; + + for(int row=0;rowrowCount(index);++row) + recursRestoreExpandedItems_idTreeView(index.child(row,0),local_path,expanded,selected) ; + } + + if(selected.find(local_path) != selected.end()) + { +#ifdef DEBUG_ID_DIALOG + std::cerr << "Restoring selected path "; + for(auto L:local_path) std::cerr << "\"" << L.toStdString() << "\" " ; std::cerr << std::endl; +#endif + ui->idTreeWidget->selectionModel()->select(index, QItemSelectionModel::Select | QItemSelectionModel::Rows); + } +} +void IdDialog::trace_collapsed(const QModelIndex& i) +{ +std::cerr << "Collapsed " << i << std::endl; +} + +void IdDialog::trace_expanded(const QModelIndex& i) +{ +std::cerr << "Expanded " << i << std::endl; +} diff --git a/retroshare-gui/src/gui/Identity/IdDialog.h b/retroshare-gui/src/gui/Identity/IdDialog.h index 594f4f5e3..dfb85a0bb 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.h +++ b/retroshare-gui/src/gui/Identity/IdDialog.h @@ -71,8 +71,9 @@ protected: private slots: void updateIdList(); void updateCircles(); - - void createExternalCircle(); +void trace_expanded(const QModelIndex&); +void trace_collapsed(const QModelIndex& i); + void createExternalCircle(); void showEditExistingCircle(); void updateCirclesDisplay(); void toggleAutoBanIdentities(bool b); @@ -123,8 +124,10 @@ private: void processSettings(bool load); QString createUsageString(const RsIdentityUsage& u) const; - void restoreExpandedPathsAndSelection_idTreeView(const std::set& expanded_indexes, const std::set >& selected_indices); - void saveExpandedPathsAndSelection_idTreeView(std::set& expanded_indexes, std::set >& selected_indices); + void saveExpandedPathsAndSelection_idTreeView(std::set &expanded, std::set &selected); + void restoreExpandedPathsAndSelection_idTreeView(const std::set& expanded, const std::set& selelected); + void recursSaveExpandedItems_idTreeView(const QModelIndex& index, const QStringList& parent_path, std::set& expanded, std::set& selected); + void recursRestoreExpandedItems_idTreeView(const QModelIndex& index,const QStringList& parent_path,const std::set& expanded,const std::set& selected); void requestIdData(std::list &ids); bool fillIdListItem(const RsGxsIdGroup& data, QTreeWidgetItem *&item, const RsPgpId &ownPgpId, int accept); diff --git a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp index 3d4b579d7..829dd7d73 100644 --- a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp +++ b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp @@ -352,6 +352,7 @@ QVariant RsIdentityListModel::data(const QModelIndex &index, int role) const case FilterRole: return filterRole(entry,index.column()) ; case SortRole: return sortRole(entry,index.column()) ; + case TreePathRole: return treePathRole(entry,index.column()) ; default: return QVariant(); @@ -483,6 +484,13 @@ QVariant RsIdentityListModel::sizeHintRole(const EntryIndex& e,int col) const } } +QVariant RsIdentityListModel::treePathRole(const EntryIndex& entry,int column) const +{ + if(entry.type == ENTRY_TYPE_CATEGORY) + return QString::number((int)entry.category_index); + else + return QString::fromStdString(mIdentities[entry.identity_index].id.toStdString()); +} QVariant RsIdentityListModel::sortRole(const EntryIndex& entry,int column) const { switch(column) diff --git a/retroshare-gui/src/gui/Identity/IdentityListModel.h b/retroshare-gui/src/gui/Identity/IdentityListModel.h index 9bf96205f..9c5d8eb27 100644 --- a/retroshare-gui/src/gui/Identity/IdentityListModel.h +++ b/retroshare-gui/src/gui/Identity/IdentityListModel.h @@ -54,6 +54,7 @@ public: StatusRole = Qt::UserRole+2, UnreadRole = Qt::UserRole+3, FilterRole = Qt::UserRole+4, + TreePathRole = Qt::UserRole+5, }; enum FilterType{ FILTER_TYPE_NONE = 0x00, @@ -157,6 +158,7 @@ private: QVariant foregroundRole(const EntryIndex& e, int col) const; QVariant textColorRole (const EntryIndex& e, int col) const; QVariant filterRole (const EntryIndex& e, int col) const; + QVariant treePathRole (const EntryIndex& entry,int column) const; /*! * \brief debug_dump From 0bda8eeb8d2e2cf0832b7a3ebd58b9081c9c6a22 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 23 Feb 2025 18:43:48 +0100 Subject: [PATCH 32/84] fixed save/restore of expanded items --- retroshare-gui/src/gui/Identity/IdDialog.cpp | 154 ++---------------- retroshare-gui/src/gui/Identity/IdDialog.h | 7 +- .../src/gui/Identity/IdentityListModel.cpp | 38 +---- 3 files changed, 28 insertions(+), 171 deletions(-) diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index 405ab9479..687f11f3d 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -440,7 +440,7 @@ IdDialog::IdDialog(QWidget *parent) connect(ui->treeWidget_membership, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(CircleListCustomPopupMenu(QPoint))); connect(ui->autoBanIdentities_CB, SIGNAL(toggled(bool)), this, SLOT(toggleAutoBanIdentities(bool))); - updateIdTimer.setSingleShot(true); + updateIdTimer.setSingleShot(true); connect(&updateIdTimer, SIGNAL(timeout()), this, SLOT(updateIdList())); } @@ -1274,14 +1274,7 @@ IdDialog::~IdDialog() delete mProxyModel; delete(ui); } -void IdDialog::idListItemExpanded(const QModelIndex& index) -{ - mIdListModel->expandItem(mProxyModel->mapToSource(index)); -} -void IdDialog::idListItemCollapsed(const QModelIndex& index) -{ - mIdListModel->collapseItem(mProxyModel->mapToSource(index)); -} + static QString getHumanReadableDuration(uint32_t seconds) { if(seconds < 60) @@ -1372,7 +1365,13 @@ void IdDialog::updateIdList() std::cerr << "Updating identity list in widget: stack is:" << std::endl; //print_stacktrace(); - applyWhileKeepingTree( [this]() { mIdListModel->updateIdentityList(); }); + applyWhileKeepingTree( [this]() { + + mIdListModel->updateIdentityList(); + + } + + ); } #ifdef TO_REMOVE bool IdDialog::fillIdListItem(const RsGxsIdGroup& data, QTreeWidgetItem *&item, const RsPgpId &ownPgpId, int accept) @@ -1506,114 +1505,6 @@ bool IdDialog::fillIdListItem(const RsGxsIdGroup& data, QTreeWidgetItem *&item, return true; } -void IdDialog::loadIdentities(const std::map& ids_set_const) -{ - auto ids_set(ids_set_const); - - std::cerr << "Loading ID list" << std::endl; - - //First: Get current item to restore after - RsGxsGroupId oldCurrentId = mIdToNavigate; - { - QTreeWidgetItem *oldCurrent = ui->idTreeWidget->currentItem(); - if (oldCurrent) { - oldCurrentId = RsGxsGroupId(oldCurrent->text(RSID_COL_KEYID).toStdString()); - } - } - - //Save expanding - Settings->beginGroup("IdDialog"); - Settings->setValue("ExpandAll", allItem->isExpanded()); - Settings->setValue("ExpandContacts", contactsItem->isExpanded()); - Settings->setValue("ExpandOwn", ownItem->isExpanded()); - Settings->endGroup(); - - - int accept = filter; - - mStateHelper->setActive(IDDIALOG_IDLIST, true); - - RsPgpId ownPgpId = rsPeers->getGPGOwnId(); - - // Update existing and remove not existing items - // Also remove items that do not have the correct parent - - QTreeWidgetItemIterator itemIterator(ui->idTreeWidget); - QTreeWidgetItem *item = NULL; - - while ((item = *itemIterator) != NULL) - { - ++itemIterator; - auto it = ids_set.find(RsGxsGroupId(item->text(RSID_COL_KEYID).toStdString())) ; - - if(it == ids_set.end()) - { - if(item != allItem && item != contactsItem && item != ownItem) - delete(item); - - continue ; - } - - QTreeWidgetItem *parent_item = item->parent() ; - -// if(it->second.mMeta.mPublishTs > time(NULL) - 20 || it->second.mMeta.mGroupId == RsGxsGroupId("3de2172503675206b3a23c997e5ee688")) -// std::cerr << "Captured ID " <second.mMeta.mGroupId << std::endl; - - if( (parent_item == allItem && it->second.mIsAContact) || (parent_item == contactsItem && !it->second.mIsAContact)) - { - delete item ; // do not remove from the list, so that it is added again in the correct place. - continue ; - } - - if (!fillIdListItem(it->second, item, ownPgpId, accept)) - delete(item); - - ids_set.erase(it); // erase, so it is not considered to be a new item - } - - /* Insert new items */ - for (std::map::const_iterator vit = ids_set.begin(); vit != ids_set.end(); ++vit) - { - RsGxsIdGroup data = vit->second ; - - item = NULL; - - if (fillIdListItem(data, item, ownPgpId, accept)) - { - if(data.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN) - ownItem->addChild(item); - else if(data.mIsAContact) - contactsItem->addChild(item); - else - allItem->addChild(item); - - } - } - - /* count items */ - int itemCount = contactsItem->childCount() + allItem->childCount() + ownItem->childCount(); - ui->label_count->setText( "(" + QString::number( itemCount ) + ")" ); - - int contactsCount = contactsItem->childCount() ; - int allCount = allItem->childCount() ; - int ownCount = ownItem->childCount(); - - contactsItem->setText(0, tr("My contacts") + ((contactsCount>0)?" (" + QString::number( contactsCount ) + ")":"") ); - allItem->setText(0, tr("All") + ((allCount>0)?" (" + QString::number( allCount ) + ")":"") ); - ownItem->setText(0, tr("My own identities") + ((ownCount>0)?" (" + QString::number( ownCount ) + ")":"") ); - - - //Restore expanding - Settings->beginGroup("IdDialog"); - allItem->setExpanded(Settings->value("ExpandAll", QVariant(true)).toBool()); - ownItem->setExpanded(Settings->value("ExpandOwn", QVariant(true)).toBool()); - contactsItem->setExpanded(Settings->value("ExpandContacts", QVariant(true)).toBool()); - Settings->endGroup(); - - navigate(RsGxsId(oldCurrentId)); - filterIds(); - updateSelection(); -} #endif void IdDialog::updateIdentity() @@ -2696,7 +2587,6 @@ void IdDialog::applyWhileKeepingTree(std::function predicate) std::set expanded,selected; saveExpandedPathsAndSelection_idTreeView(expanded, selected); - #ifdef DEBUG_NEW_FRIEND_LIST std::cerr << "After collecting selection, selected paths is: \"" << selected.toStdString() << "\", " ; std::cerr << "expanded paths are: " << std::endl; @@ -2704,7 +2594,6 @@ void IdDialog::applyWhileKeepingTree(std::function predicate) std::cerr << " \"" << path.toStdString() << "\"" << std::endl; std::cerr << "Current sort column is: " << mLastSortColumn << " and order is " << mLastSortOrder << std::endl; #endif - whileBlocking(ui->idTreeWidget)->clearSelection(); // This is a hack to avoid crashes on windows while calling endInsertRows(). I'm not sure wether these crashes are // due to a Qt bug, or a misuse of the proxy model on my side. Anyway, this solves them for good. @@ -2720,16 +2609,17 @@ void IdDialog::applyWhileKeepingTree(std::function predicate) col_sizes[i] = ui->idTreeWidget->columnWidth(i); } +#ifdef SUSPENDED #ifdef DEBUG_NEW_FRIEND_LIST std::cerr << "Applying predicate..." << std::endl; #endif mProxyModel->setSourceModel(nullptr); - +#endif predicate(); - mProxyModel->setSourceModel(mIdListModel); restoreExpandedPathsAndSelection_idTreeView(expanded,selected); +// mProxyModel->setSourceModel(mIdListModel); // restore hidden columns for(uint32_t i=0;i predicate) ui->idTreeWidget->setColumnWidth(i,col_sizes[i]); } +#ifdef SUSPENDED // restore sorting // sortColumn(mLastSortColumn,mLastSortOrder); #ifdef DEBUG_NEW_FRIEND_LIST std::cerr << "Sorting again with sort column: " << mLastSortColumn << " and order " << mLastSortOrder << std::endl; #endif - mProxyModel->setSortingEnabled(true); +// mProxyModel->setSortingEnabled(true); // mProxyModel->sort(mLastSortColumn,mLastSortOrder); - mProxyModel->setSortingEnabled(false); +// mProxyModel->setSortingEnabled(false); // if(selected_index.isValid()) // ui->idTreeWidget->scrollTo(selected_index); +#endif } #define DEBUG_ID_DIALOG void IdDialog::saveExpandedPathsAndSelection_idTreeView(std::set& expanded, std::set& selected) { -// QModelIndexList selectedIndexes = ui->idTreeWidget->selectionModel()->selectedIndexes(); -// QModelIndex current_index = selectedIndexes.empty()?QModelIndex():(*selectedIndexes.begin()); - #ifdef DEBUG_ID_DIALOG std::cerr << "Saving expended paths and selection..." << std::endl; #endif @@ -2766,6 +2655,8 @@ void IdDialog::saveExpandedPathsAndSelection_idTreeView(std::set& e void IdDialog::restoreExpandedPathsAndSelection_idTreeView(const std::set& expanded, const std::set& selected) { + whileBlocking(ui->idTreeWidget)->clearSelection(); + ui->idTreeWidget->blockSignals(true) ; for(int row = 0; row < mProxyModel->rowCount(); ++row) @@ -2829,12 +2720,3 @@ void IdDialog::recursRestoreExpandedItems_idTreeView(const QModelIndex& index,co ui->idTreeWidget->selectionModel()->select(index, QItemSelectionModel::Select | QItemSelectionModel::Rows); } } -void IdDialog::trace_collapsed(const QModelIndex& i) -{ -std::cerr << "Collapsed " << i << std::endl; -} - -void IdDialog::trace_expanded(const QModelIndex& i) -{ -std::cerr << "Expanded " << i << std::endl; -} diff --git a/retroshare-gui/src/gui/Identity/IdDialog.h b/retroshare-gui/src/gui/Identity/IdDialog.h index dfb85a0bb..dcf9b14f9 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.h +++ b/retroshare-gui/src/gui/Identity/IdDialog.h @@ -69,10 +69,8 @@ protected: private slots: - void updateIdList(); + void updateIdList(); void updateCircles(); -void trace_expanded(const QModelIndex&); -void trace_collapsed(const QModelIndex& i); void createExternalCircle(); void showEditExistingCircle(); void updateCirclesDisplay(); @@ -159,9 +157,6 @@ private: RsGxsId getSelectedIdentity() const; std::list getSelectedIdentities() const; - void idListItemExpanded(const QModelIndex& index); - void idListItemCollapsed(const QModelIndex& index); - RsGxsGroupId mId; RsGxsGroupId mIdToNavigate; int filter; diff --git a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp index 829dd7d73..ebf4fdd86 100644 --- a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp +++ b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp @@ -863,39 +863,19 @@ void RsIdentityListModel::updateIdentityList() { std::cerr << "Updating identity list" << std::endl; - RsThread::async([this]() + std::list ids ; + + if(!rsIdentity->getIdentitiesSummaries(ids)) { - // 1 - get message data from p3GxsForums - - std::list *ids = new std::list(); - - if(!rsIdentity->getIdentitiesSummaries(*ids)) - { - std::cerr << __PRETTY_FUNCTION__ << " failed to retrieve identity metadata." << std::endl; - return; - } - - // 3 - update the model in the UI thread. - - RsQThreadUtils::postToObject( [ids,this]() - { - /* Here it goes any code you want to be executed on the Qt Gui - * thread, for example to update the data model with new information - * after a blocking call to RetroShare API complete, note that - * Qt::QueuedConnection is important! - */ - - setIdentities(*ids) ; - delete ids; - - //debug_dump(); - - }, this ); - - }); + std::cerr << __PRETTY_FUNCTION__ << " failed to retrieve identity metadata." << std::endl; + return; + } + setIdentities(ids) ; } + + void RsIdentityListModel::collapseItem(const QModelIndex& index) { if(getType(index) != ENTRY_TYPE_CATEGORY) From 756ded0b5d0086f362ea3e435a2e0d8b52a97364 Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 24 Feb 2025 20:39:13 +0100 Subject: [PATCH 33/84] fixed sorting --- retroshare-gui/src/gui/Identity/IdDialog.cpp | 32 ++++++++++++++--- retroshare-gui/src/gui/Identity/IdDialog.h | 6 +++- .../src/gui/Identity/IdentityListModel.cpp | 36 +++++-------------- 3 files changed, 41 insertions(+), 33 deletions(-) diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index 687f11f3d..f35f3fb65 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -302,7 +302,8 @@ IdDialog::IdDialog(QWidget *parent) connect(ui->inviteButton, SIGNAL(clicked()), this, SLOT(sendInvite())); connect(ui->editButton, SIGNAL(clicked()), this, SLOT(editIdentity())); - connect( ui->idTreeWidget, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(chatIdentityItem(QModelIndex&)) ); + connect(ui->idTreeWidget, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(chatIdentityItem(QModelIndex&)) ); + connect(ui->idTreeWidget->header(),SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(sortColumn(int,Qt::SortOrder))); ui->editButton->hide(); @@ -2627,21 +2628,20 @@ void IdDialog::applyWhileKeepingTree(std::function predicate) ui->idTreeWidget->setColumnWidth(i,col_sizes[i]); } + mProxyModel->setSortingEnabled(true); + mProxyModel->sort(mLastSortColumn,mLastSortOrder); + mProxyModel->setSortingEnabled(false); #ifdef SUSPENDED // restore sorting // sortColumn(mLastSortColumn,mLastSortOrder); #ifdef DEBUG_NEW_FRIEND_LIST std::cerr << "Sorting again with sort column: " << mLastSortColumn << " and order " << mLastSortOrder << std::endl; #endif -// mProxyModel->setSortingEnabled(true); -// mProxyModel->sort(mLastSortColumn,mLastSortOrder); -// mProxyModel->setSortingEnabled(false); // if(selected_index.isValid()) // ui->idTreeWidget->scrollTo(selected_index); #endif } -#define DEBUG_ID_DIALOG void IdDialog::saveExpandedPathsAndSelection_idTreeView(std::set& expanded, std::set& selected) { @@ -2720,3 +2720,25 @@ void IdDialog::recursRestoreExpandedItems_idTreeView(const QModelIndex& index,co ui->idTreeWidget->selectionModel()->select(index, QItemSelectionModel::Select | QItemSelectionModel::Rows); } } +void IdDialog::sortColumn(int col,Qt::SortOrder so) +{ +#ifdef DEBUG_NEW_FRIEND_LIST + std::cerr << "Sorting with column=" << col << " and order=" << so << std::endl; +#endif + std::set expanded_indexes,selected_indexes; + + saveExpandedPathsAndSelection_idTreeView(expanded_indexes, selected_indexes); + whileBlocking(ui->idTreeWidget)->clearSelection(); + + mProxyModel->setSortingEnabled(true); + mProxyModel->sort(col,so); + mProxyModel->setSortingEnabled(false); + + restoreExpandedPathsAndSelection_idTreeView(expanded_indexes,selected_indexes); + + //if(selected_index.isValid()) + // ui->peerTreeWidget->scrollTo(selected_index); + + mLastSortColumn = col; + mLastSortOrder = so; +} diff --git a/retroshare-gui/src/gui/Identity/IdDialog.h b/retroshare-gui/src/gui/Identity/IdDialog.h index dcf9b14f9..811e4424f 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.h +++ b/retroshare-gui/src/gui/Identity/IdDialog.h @@ -75,6 +75,7 @@ private slots: void showEditExistingCircle(); void updateCirclesDisplay(); void toggleAutoBanIdentities(bool b); + void sortColumn(int col,Qt::SortOrder so); void acceptCircleSubscription() ; void cancelCircleSubscription() ; @@ -149,7 +150,10 @@ private: QTreeWidgetItem *mMyCircleItem; RsGxsUpdateBroadcastBase *mCirclesBroadcastBase ; - void saveExpandedCircleItems(std::vector &expanded_root_items, std::set& expanded_circle_items) const; + int mLastSortColumn; + Qt::SortOrder mLastSortOrder; + + void saveExpandedCircleItems(std::vector &expanded_root_items, std::set& expanded_circle_items) const; void restoreExpandedCircleItems(const std::vector& expanded_root_items,const std::set& expanded_circle_items); void applyWhileKeepingTree(std::function predicate); diff --git a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp index ebf4fdd86..2a1cd193f 100644 --- a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp +++ b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp @@ -495,34 +495,13 @@ QVariant RsIdentityListModel::sortRole(const EntryIndex& entry,int column) const { switch(column) { -#warning TODO -// case COLUMN_THREAD_LAST_CONTACT: -// { -// switch(entry.type) -// { -// case ENTRY_TYPE_PROFILE: -// { -// const HierarchicalProfileInformation *prof = getProfileInfo(entry); -// -// if(!prof) -// return QVariant(); -// -// uint32_t last_contact = 0; -// -// for(uint32_t i=0;ichild_node_indices.size();++i) -// last_contact = std::max(last_contact, mLocations[prof->child_node_indices[i]].node_info.lastConnect); -// -// return QVariant(last_contact); -// } -// break; -// default: -// return QVariant(); -// } -// } -// break; + case COLUMN_THREAD_REPUTATION: return decorationRole(entry,column); + case COLUMN_THREAD_ID: + case COLUMN_THREAD_OWNER: + case COLUMN_THREAD_NAME: [[__fallthrough__]]; default: - return displayRole(entry,column); + return displayRole(entry,column); } } @@ -653,7 +632,10 @@ QVariant RsIdentityListModel::displayRole(const EntryIndex& e, int col) const { case COLUMN_THREAD_NAME: return QVariant(QString::fromUtf8(det.mNickname.c_str())); case COLUMN_THREAD_ID: return QVariant(QString::fromStdString(det.mId.toStdString()) ); - case COLUMN_THREAD_OWNER: return QVariant(QString::fromStdString(det.mPgpId.toStdString()) ); + case COLUMN_THREAD_OWNER: if(det.mPgpId.isNull()) + return QVariant(); + else + return QVariant(QString::fromStdString(det.mPgpId.toStdString()) ); default: return QVariant(); } From 2644a0ccb79188b69da8fee7e0272020c02ba483 Mon Sep 17 00:00:00 2001 From: defnax Date: Wed, 26 Feb 2025 17:56:38 +0100 Subject: [PATCH 34/84] Added for search list update fontsize --- .../src/gui/FileTransfer/SearchDialog.cpp | 38 ++++++++++++++++--- .../src/gui/FileTransfer/SearchDialog.h | 5 +++ 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/retroshare-gui/src/gui/FileTransfer/SearchDialog.cpp b/retroshare-gui/src/gui/FileTransfer/SearchDialog.cpp index b3d74d6c4..db11ab613 100644 --- a/retroshare-gui/src/gui/FileTransfer/SearchDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/SearchDialog.cpp @@ -38,6 +38,7 @@ #include "gui/common/RSTreeWidgetItem.h" #include "util/QtVersion.h" #include "util/qtthreadsutils.h" +#include "util/misc.h" #include #include @@ -167,8 +168,8 @@ SearchDialog::SearchDialog(QWidget *parent) // To allow a proper sorting, be careful to pad at right with spaces. This // is achieved by using QString("%1").arg(number,15,10). // - ui.searchResultWidget->setItemDelegateForColumn(SR_SIZE_COL, mSizeColumnDelegate=new RSHumanReadableSizeDelegate()) ; - ui.searchResultWidget->setItemDelegateForColumn(SR_AGE_COL, mAgeColumnDelegate=new RSHumanReadableAgeDelegate()) ; + //ui.searchResultWidget->setItemDelegateForColumn(SR_SIZE_COL, mSizeColumnDelegate=new RSHumanReadableSizeDelegate()) ; + //ui.searchResultWidget->setItemDelegateForColumn(SR_AGE_COL, mAgeColumnDelegate=new RSHumanReadableAgeDelegate()) ; /* make it extended selection */ ui.searchResultWidget -> setSelectionMode(QAbstractItemView::ExtendedSelection); @@ -255,8 +256,8 @@ SearchDialog::~SearchDialog() delete mSizeColumnDelegate; delete mAgeColumnDelegate; - ui.searchResultWidget->setItemDelegateForColumn(SR_SIZE_COL, nullptr); - ui.searchResultWidget->setItemDelegateForColumn(SR_AGE_COL, nullptr); + //ui.searchResultWidget->setItemDelegateForColumn(SR_SIZE_COL, nullptr); + //ui.searchResultWidget->setItemDelegateForColumn(SR_AGE_COL, nullptr); rsEvents->unregisterEventsHandler(mEventHandlerId); } @@ -1325,11 +1326,13 @@ void SearchDialog::insertFile(qulonglong searchId, const FileDetail& file, int s * to facilitate downloads we need to save the file size too */ - item->setText(SR_SIZE_COL, QString::number(file.size)); + item->setText(SR_SIZE_COL, misc::friendlyUnit(file.size)); item->setData(SR_SIZE_COL, ROLE_SORT, (qulonglong) file.size); - item->setText(SR_AGE_COL, QString::number(file.mtime)); + item->setText(SR_AGE_COL, misc::timeRelativeToNow(file.mtime)); item->setData(SR_AGE_COL, ROLE_SORT, file.mtime); item->setTextAlignment( SR_SIZE_COL, Qt::AlignRight ); + item->setTextAlignment( SR_AGE_COL, Qt::AlignCenter ); + int friendSource = 0; int anonymousSource = 0; if(searchType == FRIEND_SEARCH) @@ -1627,3 +1630,26 @@ void SearchDialog::openFolderSearch() } } } + +void SearchDialog::showEvent(QShowEvent *event) +{ + if (!event->spontaneous()) { + updateFontSize(); + } +} + +void SearchDialog::updateFontSize() +{ +#if defined(Q_OS_DARWIN) + int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 13).toInt(); +#else + int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 12).toInt(); +#endif + QFont newFont = ui.searchSummaryWidget->font(); + if (newFont.pointSize() != customFontSize) { + newFont.setPointSize(customFontSize); + QFontMetricsF fontMetrics(newFont); + ui.searchSummaryWidget->setFont(newFont); + ui.searchResultWidget->setFont(newFont); + } +} diff --git a/retroshare-gui/src/gui/FileTransfer/SearchDialog.h b/retroshare-gui/src/gui/FileTransfer/SearchDialog.h index 8aa7bac64..aa5c4e2b4 100644 --- a/retroshare-gui/src/gui/FileTransfer/SearchDialog.h +++ b/retroshare-gui/src/gui/FileTransfer/SearchDialog.h @@ -66,6 +66,9 @@ public: void updateFiles(qulonglong request_id, const FileDetail& file) ; +protected: + virtual void showEvent(QShowEvent *) override; + private slots: /** Create the context popup menu and it's submenus */ @@ -116,6 +119,8 @@ private slots: void filterItems(); + void updateFontSize(); + private: /** render the results to the tree widget display */ void initSearchResult(const QString& txt,qulonglong searchId, int fileType, bool advanced) ; From 95ea588c9fa6587200a5bc6e755546e6b19ddc76 Mon Sep 17 00:00:00 2001 From: defnax Date: Fri, 28 Feb 2025 17:38:14 +0100 Subject: [PATCH 35/84] Fixed Subject column fonts --- retroshare-gui/src/gui/msgs/MessagesDialog.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/retroshare-gui/src/gui/msgs/MessagesDialog.cpp b/retroshare-gui/src/gui/msgs/MessagesDialog.cpp index 5cf408267..196012070 100644 --- a/retroshare-gui/src/gui/msgs/MessagesDialog.cpp +++ b/retroshare-gui/src/gui/msgs/MessagesDialog.cpp @@ -163,9 +163,9 @@ MessagesDialog::MessagesDialog(QWidget *parent) changeBox(0); // set to inbox - RSElidedItemDelegate *itemDelegate = new RSElidedItemDelegate(this); - itemDelegate->setSpacing(QSize(0, 2)); - ui.messageTreeWidget->setItemDelegateForColumn(RsMessageModel::COLUMN_THREAD_SUBJECT,itemDelegate); + //RSElidedItemDelegate *itemDelegate = new RSElidedItemDelegate(this); + //itemDelegate->setSpacing(QSize(0, 2)); + //ui.messageTreeWidget->setItemDelegateForColumn(RsMessageModel::COLUMN_THREAD_SUBJECT,itemDelegate); ui.messageTreeWidget->setItemDelegateForColumn(RsMessageModel::COLUMN_THREAD_AUTHOR,new GxsIdTreeItemDelegate()) ; ui.messageTreeWidget->setItemDelegateForColumn(RsMessageModel::COLUMN_THREAD_TO,new GxsIdTreeItemDelegate()) ; @@ -1679,9 +1679,13 @@ void MessagesDialog::updateFontSize() if (newFont.pointSize() != customFontSize) { newFont.setPointSize(customFontSize); QFontMetricsF fontMetrics(newFont); + int iconHeight = fontMetrics.height()*1.5; ui.listWidget->setFont(newFont); ui.quickViewWidget->setFont(newFont); ui.messageTreeWidget->setFont(newFont); + ui.listWidget->setIconSize(QSize(iconHeight, iconHeight)); + ui.quickViewWidget->setIconSize(QSize(iconHeight, iconHeight)); + ui.messageTreeWidget->setIconSize(QSize(iconHeight, iconHeight)); } } From e369ba3504c5e73b6a10515ac234c74b485c2d5a Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 1 Mar 2025 20:38:05 +0100 Subject: [PATCH 36/84] added new column for owner name/ID --- retroshare-gui/src/gui/Identity/IdDialog.cpp | 24 +++++++++-------- .../src/gui/Identity/IdentityListModel.cpp | 26 +++++++++++++------ .../src/gui/Identity/IdentityListModel.h | 7 ++--- 3 files changed, 35 insertions(+), 22 deletions(-) diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index f35f3fb65..8bbcd39d5 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -398,7 +398,8 @@ IdDialog::IdDialog(QWidget *parent) /* Setup tree */ //ui->idTreeWidget->sortByColumn(RsIdentityListModel::COLUMN_THREAD_NAME, Qt::AscendingOrder); - ui->idTreeWidget->setColumnHidden(RsIdentityListModel::COLUMN_THREAD_OWNER, true); + ui->idTreeWidget->setColumnHidden(RsIdentityListModel::COLUMN_THREAD_OWNER_ID, true); + ui->idTreeWidget->setColumnHidden(RsIdentityListModel::COLUMN_THREAD_OWNER_NAME, true); ui->idTreeWidget->setColumnHidden(RsIdentityListModel::COLUMN_THREAD_ID, true); ui->idTreeWidget->setItemDelegate(new RSElidedItemDelegate()); @@ -2054,7 +2055,8 @@ void IdDialog::headerContextMenuRequested(QPoint) }; addEntry(tr("Id"),RsIdentityListModel::COLUMN_THREAD_ID); - addEntry(tr("Owner"),RsIdentityListModel::COLUMN_THREAD_OWNER); + addEntry(tr("Owner Id"),RsIdentityListModel::COLUMN_THREAD_OWNER_ID); + addEntry(tr("Owner Name"),RsIdentityListModel::COLUMN_THREAD_OWNER_NAME); addEntry(tr("Reputation"),RsIdentityListModel::COLUMN_THREAD_REPUTATION); //addEntry(tr("Name"),RsIdentityListModel::COLUMN_THREAD_NAME); @@ -2357,7 +2359,7 @@ void IdDialog::sendMsg() for(const auto& id : lst) nMsgDialog->addRecipient(MessageComposer::TO, id); - nMsgDialog->show(); + nMsgDialog->show(); nMsgDialog->activateWindow(); /* window will destroy itself! */ @@ -2393,8 +2395,8 @@ void IdDialog::negativePerson() for(const auto& id : lst) rsReputations->setOwnOpinion(id, RsOpinion::NEGATIVE); - updateIdentity(); - updateIdList(); + updateIdentity(); + updateIdList(); } void IdDialog::neutralPerson() @@ -2404,8 +2406,8 @@ void IdDialog::neutralPerson() for(const auto& id : lst) rsReputations->setOwnOpinion(id, RsOpinion::NEUTRAL); - updateIdentity(); - updateIdList(); + updateIdentity(); + updateIdList(); } void IdDialog::positivePerson() { @@ -2414,8 +2416,8 @@ void IdDialog::positivePerson() for(const auto& id : lst) rsReputations->setOwnOpinion(id, RsOpinion::POSITIVE); - updateIdentity(); - updateIdList(); + updateIdentity(); + updateIdList(); } void IdDialog::addtoContacts() @@ -2425,7 +2427,7 @@ void IdDialog::addtoContacts() for(const auto& id : lst) rsIdentity->setAsRegularContact(id,true); - updateIdList(); + updateIdList(); } void IdDialog::removefromContacts() @@ -2435,7 +2437,7 @@ void IdDialog::removefromContacts() for(const auto& id : lst) rsIdentity->setAsRegularContact(id,false); - updateIdList(); + updateIdList(); } void IdDialog::on_closeInfoFrameButton_Invite_clicked() diff --git a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp index 2a1cd193f..73c87ad58 100644 --- a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp +++ b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp @@ -300,13 +300,16 @@ QVariant RsIdentityListModel::headerData(int section, Qt::Orientation /*orientat { case COLUMN_THREAD_NAME: return tr("Name"); case COLUMN_THREAD_ID: return tr("Id"); - case COLUMN_THREAD_REPUTATION: return tr("Reputation"); - case COLUMN_THREAD_OWNER: return tr("Owner"); - default: + case COLUMN_THREAD_REPUTATION: return QVariant(); + case COLUMN_THREAD_OWNER_ID: return tr("Owner Id"); + case COLUMN_THREAD_OWNER_NAME: return tr("Owner"); + default: return QVariant(); } + if(role == Qt::DecorationRole && section == COLUMN_THREAD_REPUTATION) + return QIcon(":/icons/flag-green.png"); - return QVariant(); + return QVariant(); } QVariant RsIdentityListModel::data(const QModelIndex &index, int role) const @@ -480,11 +483,12 @@ QVariant RsIdentityListModel::sizeHintRole(const EntryIndex& e,int col) const case COLUMN_THREAD_NAME: return QVariant( QSize(x_factor * 70 , y_factor*14*1.1f )); case COLUMN_THREAD_ID: return QVariant( QSize(x_factor * 175, y_factor*14*1.1f )); case COLUMN_THREAD_REPUTATION: return QVariant( QSize(x_factor * 20 , y_factor*14*1.1f )); - case COLUMN_THREAD_OWNER: return QVariant( QSize(x_factor * 70 , y_factor*14*1.1f )); + case COLUMN_THREAD_OWNER_NAME: return QVariant( QSize(x_factor * 70 , y_factor*14*1.1f )); + case COLUMN_THREAD_OWNER_ID: return QVariant( QSize(x_factor * 70 , y_factor*14*1.1f )); } } -QVariant RsIdentityListModel::treePathRole(const EntryIndex& entry,int column) const +QVariant RsIdentityListModel::treePathRole(const EntryIndex& entry,int /*column*/) const { if(entry.type == ENTRY_TYPE_CATEGORY) return QString::number((int)entry.category_index); @@ -498,7 +502,8 @@ QVariant RsIdentityListModel::sortRole(const EntryIndex& entry,int column) const case COLUMN_THREAD_REPUTATION: return decorationRole(entry,column); case COLUMN_THREAD_ID: - case COLUMN_THREAD_OWNER: + case COLUMN_THREAD_OWNER_ID: + case COLUMN_THREAD_OWNER_NAME: case COLUMN_THREAD_NAME: [[__fallthrough__]]; default: return displayRole(entry,column); @@ -632,7 +637,12 @@ QVariant RsIdentityListModel::displayRole(const EntryIndex& e, int col) const { case COLUMN_THREAD_NAME: return QVariant(QString::fromUtf8(det.mNickname.c_str())); case COLUMN_THREAD_ID: return QVariant(QString::fromStdString(det.mId.toStdString()) ); - case COLUMN_THREAD_OWNER: if(det.mPgpId.isNull()) + case COLUMN_THREAD_OWNER_NAME: if(det.mPgpId.isNull()) + return QVariant(); + else + return QVariant(QString::fromStdString(rsPeers->getGPGName(det.mPgpId)) ); + + case COLUMN_THREAD_OWNER_ID: if(det.mPgpId.isNull()) return QVariant(); else return QVariant(QString::fromStdString(det.mPgpId.toStdString()) ); diff --git a/retroshare-gui/src/gui/Identity/IdentityListModel.h b/retroshare-gui/src/gui/Identity/IdentityListModel.h index 9c5d8eb27..74cea02a9 100644 --- a/retroshare-gui/src/gui/Identity/IdentityListModel.h +++ b/retroshare-gui/src/gui/Identity/IdentityListModel.h @@ -45,9 +45,10 @@ public: enum Columns { COLUMN_THREAD_NAME = 0x00, COLUMN_THREAD_ID = 0x01, - COLUMN_THREAD_OWNER = 0x02, - COLUMN_THREAD_REPUTATION = 0x03, - COLUMN_THREAD_NB_COLUMNS = 0x04 + COLUMN_THREAD_OWNER_NAME = 0x02, + COLUMN_THREAD_OWNER_ID = 0x03, + COLUMN_THREAD_REPUTATION = 0x04, + COLUMN_THREAD_NB_COLUMNS = 0x05 }; enum Roles{ SortRole = Qt::UserRole+1, From 06d9ea2398c1b75dae2bccd7e16ae0186fac6650 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 1 Mar 2025 20:57:32 +0100 Subject: [PATCH 37/84] enabled processSettings --- retroshare-gui/src/gui/Identity/IdDialog.cpp | 71 ++++++++++--------- .../src/gui/Identity/IdentityListModel.cpp | 27 ++++--- .../src/gui/Identity/IdentityListModel.h | 9 +-- 3 files changed, 54 insertions(+), 53 deletions(-) diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index 8bbcd39d5..b6a365ab7 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -1297,41 +1297,42 @@ static QString getHumanReadableDuration(uint32_t seconds) void IdDialog::processSettings(bool load) { -#warning TODO -// Settings->beginGroup("IdDialog"); -// -// // state of peer tree -// ui->idTreeWidget->processSettings(load); -// -// if (load) { -// // load settings -// -// // filterColumn -// ui->filterLineEdit->setCurrentFilter(Settings->value("filterColumn", RSID_COL_NICKNAME).toInt()); -// -// // state of splitter -// ui->mainSplitter->restoreState(Settings->value("splitter").toByteArray()); -// -// //Restore expanding -// allItem->setExpanded(Settings->value("ExpandAll", QVariant(true)).toBool()); -// ownItem->setExpanded(Settings->value("ExpandOwn", QVariant(true)).toBool()); -// contactsItem->setExpanded(Settings->value("ExpandContacts", QVariant(true)).toBool()); -// } else { -// // save settings -// -// // filterColumn -// Settings->setValue("filterColumn", ui->filterLineEdit->currentFilter()); -// -// // state of splitter -// Settings->setValue("splitter", ui->mainSplitter->saveState()); -// -// //save expanding -// Settings->setValue("ExpandAll", allItem->isExpanded()); -// Settings->setValue("ExpandContacts", contactsItem->isExpanded()); -// Settings->setValue("ExpandOwn", ownItem->isExpanded()); -// } -// -// Settings->endGroup(); + Settings->beginGroup("IdDialog"); + + // state of peer tree + // ui->idTreeWidget->processSettings(load); + + if (load) { + // load settings + + // filterColumn + ui->filterLineEdit->setCurrentFilter(Settings->value("filterColumn", RsIdentityListModel::COLUMN_THREAD_NAME).toInt()); + + // state of splitter + ui->mainSplitter->restoreState(Settings->value("splitter").toByteArray()); + + //Restore expanding + ui->idTreeWidget->setExpanded(mIdListModel->getIndexOfCategory(RsIdentityListModel::CATEGORY_ALL),Settings->value("ExpandAll", QVariant(true)).toBool()); + ui->idTreeWidget->setExpanded(mIdListModel->getIndexOfCategory(RsIdentityListModel::CATEGORY_OWN),Settings->value("ExpandOwn", QVariant(true)).toBool()); + ui->idTreeWidget->setExpanded(mIdListModel->getIndexOfCategory(RsIdentityListModel::CATEGORY_CTS),Settings->value("ExpandContacts", QVariant(true)).toBool()); + } + else + { + // save settings + + // filterColumn + Settings->setValue("filterColumn", ui->filterLineEdit->currentFilter()); + + // state of splitter + Settings->setValue("splitter", ui->mainSplitter->saveState()); + + //save expanding + Settings->setValue("ExpandAll", ui->idTreeWidget->isExpanded(mIdListModel->getIndexOfCategory(RsIdentityListModel::CATEGORY_ALL))); + Settings->setValue("ExpandContacts", ui->idTreeWidget->isExpanded(mIdListModel->getIndexOfCategory(RsIdentityListModel::CATEGORY_OWN))); + Settings->setValue("ExpandOwn", ui->idTreeWidget->isExpanded(mIdListModel->getIndexOfCategory(RsIdentityListModel::CATEGORY_CTS))); + } + + Settings->endGroup(); } void IdDialog::filterChanged(const QString& /*text*/) diff --git a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp index 73c87ad58..e97a0d1dc 100644 --- a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp +++ b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp @@ -527,6 +527,18 @@ QModelIndex RsIdentityListModel::getIndexOfIdentity(const RsGxsId& id) const } return QModelIndex(); } + +QModelIndex RsIdentityListModel::getIndexOfCategory(Category id) const +{ + EntryIndex e; + e.category_index = id; + e.type = ENTRY_TYPE_CATEGORY; + + quintptr idx; + convertIndexToInternalId(e,idx); + + return createIndex((int)id,0,idx); +} QVariant RsIdentityListModel::foregroundRole(const EntryIndex& e, int /*col*/) const { auto it = getIdentityInfo(e); @@ -900,18 +912,5 @@ void RsIdentityListModel::expandItem(const QModelIndex& index) emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mCategories.size()-1,columnCount()-1,(void*)NULL)); } -bool RsIdentityListModel::isCategoryExpanded(const EntryIndex& e) const -{ - return true; -#warning TODO -// if(e.type != ENTRY_TYPE_CATEGORY) -// return false; -// -// EntryIndex entry; -// -// if(!convertInternalIdToIndex(e.internalId(),entry)) -// return false; -// -// return mExpandedCategories[entry.category_index]; -} + diff --git a/retroshare-gui/src/gui/Identity/IdentityListModel.h b/retroshare-gui/src/gui/Identity/IdentityListModel.h index 74cea02a9..00b346803 100644 --- a/retroshare-gui/src/gui/Identity/IdentityListModel.h +++ b/retroshare-gui/src/gui/Identity/IdentityListModel.h @@ -69,9 +69,10 @@ public: ENTRY_TYPE_INVALID = 0x03 }; - static const int CATEGORY_OWN = 0x00; - static const int CATEGORY_CTS = 0x01; - static const int CATEGORY_ALL = 0x02; + enum Category{ CATEGORY_OWN = 0x00, + CATEGORY_CTS = 0x01, + CATEGORY_ALL = 0x02 + }; struct HierarchicalCategoryInformation { @@ -107,6 +108,7 @@ public: QModelIndex root() const{ return createIndex(0,0,(void*)NULL) ;} QModelIndex getIndexOfIdentity(const RsGxsId& id) const; + QModelIndex getIndexOfCategory(Category id) const; void updateIdentityList(); @@ -146,7 +148,6 @@ private: const HierarchicalCategoryInformation *getCategoryInfo (const EntryIndex&) const; const HierarchicalIdentityInformation *getIdentityInfo(const EntryIndex&) const; - bool isCategoryExpanded(const EntryIndex& e) const; void checkIdentity(HierarchicalIdentityInformation& node); QVariant sizeHintRole (const EntryIndex& e, int col) const; From 7c5a45335a4059f162140877be905faf749b7d6c Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 1 Mar 2025 21:26:29 +0100 Subject: [PATCH 38/84] fixed load/save of visible columns --- retroshare-gui/src/gui/Identity/IdDialog.cpp | 29 +++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index b6a365ab7..b80dae798 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -1312,9 +1312,16 @@ void IdDialog::processSettings(bool load) ui->mainSplitter->restoreState(Settings->value("splitter").toByteArray()); //Restore expanding - ui->idTreeWidget->setExpanded(mIdListModel->getIndexOfCategory(RsIdentityListModel::CATEGORY_ALL),Settings->value("ExpandAll", QVariant(true)).toBool()); - ui->idTreeWidget->setExpanded(mIdListModel->getIndexOfCategory(RsIdentityListModel::CATEGORY_OWN),Settings->value("ExpandOwn", QVariant(true)).toBool()); - ui->idTreeWidget->setExpanded(mIdListModel->getIndexOfCategory(RsIdentityListModel::CATEGORY_CTS),Settings->value("ExpandContacts", QVariant(true)).toBool()); + ui->idTreeWidget->setExpanded(mProxyModel->mapFromSource(mIdListModel->getIndexOfCategory(RsIdentityListModel::CATEGORY_ALL)),Settings->value("ExpandAll", QVariant(true)).toBool()); + ui->idTreeWidget->setExpanded(mProxyModel->mapFromSource(mIdListModel->getIndexOfCategory(RsIdentityListModel::CATEGORY_OWN)),Settings->value("ExpandOwn", QVariant(true)).toBool()); + ui->idTreeWidget->setExpanded(mProxyModel->mapFromSource(mIdListModel->getIndexOfCategory(RsIdentityListModel::CATEGORY_CTS)),Settings->value("ExpandContacts", QVariant(true)).toBool()); + + // visible columns + + int v = Settings->value("columnVisibility",(1 << RsIdentityListModel::COLUMN_THREAD_NAME)+(1 << RsIdentityListModel::COLUMN_THREAD_REPUTATION)).toInt(); + + for(int i=0;icolumnCount();++i) + ui->idTreeWidget->setColumnHidden(i,!(v & (1<setValue("splitter", ui->mainSplitter->saveState()); //save expanding - Settings->setValue("ExpandAll", ui->idTreeWidget->isExpanded(mIdListModel->getIndexOfCategory(RsIdentityListModel::CATEGORY_ALL))); - Settings->setValue("ExpandContacts", ui->idTreeWidget->isExpanded(mIdListModel->getIndexOfCategory(RsIdentityListModel::CATEGORY_OWN))); - Settings->setValue("ExpandOwn", ui->idTreeWidget->isExpanded(mIdListModel->getIndexOfCategory(RsIdentityListModel::CATEGORY_CTS))); + Settings->setValue("ExpandAll", ui->idTreeWidget->isExpanded(mProxyModel->mapFromSource(mIdListModel->getIndexOfCategory(RsIdentityListModel::CATEGORY_ALL)))); + Settings->setValue("ExpandContacts", ui->idTreeWidget->isExpanded(mProxyModel->mapFromSource(mIdListModel->getIndexOfCategory(RsIdentityListModel::CATEGORY_CTS)))); + Settings->setValue("ExpandOwn", ui->idTreeWidget->isExpanded(mProxyModel->mapFromSource(mIdListModel->getIndexOfCategory(RsIdentityListModel::CATEGORY_OWN)))); + + int v = 0; + for(int i=0;icolumnCount();++i) + if(!ui->idTreeWidget->isColumnHidden(i)) + v += (1 << i); + + Settings->setValue("columnVisibility",v); } Settings->endGroup(); @@ -1930,9 +1944,10 @@ void IdDialog::navigate(const RsGxsId& gxs_id) std::cerr << "IdDialog::navigate to " << gxs_id.toStdString() << std::endl; #endif - QModelIndex indx = mIdListModel->getIndexOfIdentity(gxs_id); + QModelIndex indx = mProxyModel->mapFromSource(mIdListModel->getIndexOfIdentity(gxs_id)); // in order to do this, we just select the correct ID in the ID list + if (!gxs_id.isNull()) { if(!indx.isValid()) From 6fde55217cfabfe10e8a582fc23eded126d35f26 Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 4 Mar 2025 16:52:29 +0100 Subject: [PATCH 39/84] added async update of ID list --- retroshare-gui/src/gui/Identity/IdDialog.cpp | 69 ++++++++++++------- retroshare-gui/src/gui/Identity/IdDialog.h | 3 +- .../src/gui/Identity/IdentityListModel.h | 3 +- 3 files changed, 50 insertions(+), 25 deletions(-) diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index b80dae798..de1f4b977 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -463,21 +463,14 @@ void IdDialog::handleEvent_main_thread(std::shared_ptr event) mId.clear(); updateIdentity(); } - updateIdList(); + updateIdListRequest(); break; case RsGxsIdentityEventCode::NEW_IDENTITY: case RsGxsIdentityEventCode::UPDATED_IDENTITY: if (isVisible()) - { - if(rsIdentity->isOwnId(RsGxsId(e->mIdentityId))) - updateIdList(); - else - updateIdTimer.start(3000); // use a timer for events not generated by local changes which generally - // come in large herds. Allows to group multiple changes into a single UI update. - } - else - needUpdateIdsOnNextShow = true; + updateIdListRequest(); // use a timer for events not generated by local changes which generally + // come in large herds. Allows to group multiple changes into a single UI update. if(!mId.isNull() && mId == e->mIdentityId) updateIdentity(); @@ -537,7 +530,7 @@ void IdDialog::toggleAutoBanIdentities(bool b) if(!id.isNull()) { rsReputations->banNode(id,b) ; - updateIdList(); + updateIdListRequest(); } } @@ -977,7 +970,7 @@ bool IdDialog::getItemCircleId(QTreeWidgetItem *item,RsGxsCircleId& id) void IdDialog::showEvent(QShowEvent *s) { if (needUpdateIdsOnNextShow) - updateIdList(); + updateIdListRequest(); if (needUpdateCirclesOnNextShow) updateCircles(); @@ -1360,7 +1353,7 @@ void IdDialog::filterToggled(const bool &value) QAction *source = qobject_cast(QObject::sender()); if (source) { filter = source->data().toInt(); - updateIdList(); + updateIdListRequest(); } } } @@ -1377,19 +1370,49 @@ void IdDialog::updateSelection() } } +void IdDialog::updateIdListRequest() +{ + if(updateIdTimer.isActive()) + { + std::cerr << "updateIdListRequest(): restarting timer"<< std::endl; + updateIdTimer.stop(); + updateIdTimer.start(1000); + } + else + { + std::cerr << "updateIdListRequest(): starting timer"<< std::endl; + updateIdTimer.start(1000); + } +} + void IdDialog::updateIdList() { - std::cerr << "Updating identity list in widget: stack is:" << std::endl; + std::cerr << "Updating identity list in widget." << std::endl; //print_stacktrace(); - applyWhileKeepingTree( [this]() { + RsThread::async([this]() + { + std::list *ids = new std::list(); - mIdListModel->updateIdentityList(); + if(!rsIdentity->getIdentitiesSummaries(*ids)) + { + std::cerr << __PRETTY_FUNCTION__ << " failed to retrieve identity metadata." << std::endl; + return; + } - } + RsQThreadUtils::postToObject( [ids,this]() + { - ); + applyWhileKeepingTree( [ids,this]() { + + mIdListModel->setIdentities(*ids) ; + delete ids; + + }); + }); + }); } + #ifdef TO_REMOVE bool IdDialog::fillIdListItem(const RsGxsIdGroup& data, QTreeWidgetItem *&item, const RsPgpId &ownPgpId, int accept) { @@ -2412,7 +2435,7 @@ void IdDialog::negativePerson() rsReputations->setOwnOpinion(id, RsOpinion::NEGATIVE); updateIdentity(); - updateIdList(); + updateIdListRequest(); } void IdDialog::neutralPerson() @@ -2423,7 +2446,7 @@ void IdDialog::neutralPerson() rsReputations->setOwnOpinion(id, RsOpinion::NEUTRAL); updateIdentity(); - updateIdList(); + updateIdListRequest(); } void IdDialog::positivePerson() { @@ -2433,7 +2456,7 @@ void IdDialog::positivePerson() rsReputations->setOwnOpinion(id, RsOpinion::POSITIVE); updateIdentity(); - updateIdList(); + updateIdListRequest(); } void IdDialog::addtoContacts() @@ -2443,7 +2466,7 @@ void IdDialog::addtoContacts() for(const auto& id : lst) rsIdentity->setAsRegularContact(id,true); - updateIdList(); + updateIdListRequest(); } void IdDialog::removefromContacts() @@ -2453,7 +2476,7 @@ void IdDialog::removefromContacts() for(const auto& id : lst) rsIdentity->setAsRegularContact(id,false); - updateIdList(); + updateIdListRequest(); } void IdDialog::on_closeInfoFrameButton_Invite_clicked() diff --git a/retroshare-gui/src/gui/Identity/IdDialog.h b/retroshare-gui/src/gui/Identity/IdDialog.h index 811e4424f..3ba384960 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.h +++ b/retroshare-gui/src/gui/Identity/IdDialog.h @@ -61,6 +61,7 @@ protected: void loadIdentity(RsGxsIdGroup id_data); void loadCircles(const std::list& circle_metas); + void updateIdListRequest(); //void requestCircleGroupData(const RsGxsCircleId& circle_id); bool getItemCircleId(QTreeWidgetItem *item,RsGxsCircleId& id) ; @@ -70,7 +71,7 @@ protected: private slots: void updateIdList(); - void updateCircles(); + void updateCircles(); void createExternalCircle(); void showEditExistingCircle(); void updateCirclesDisplay(); diff --git a/retroshare-gui/src/gui/Identity/IdentityListModel.h b/retroshare-gui/src/gui/Identity/IdentityListModel.h index 00b346803..4aab1c0a8 100644 --- a/retroshare-gui/src/gui/Identity/IdentityListModel.h +++ b/retroshare-gui/src/gui/Identity/IdentityListModel.h @@ -144,6 +144,8 @@ public: QColor mTextColorGroup; QColor mTextColorStatus[RS_STATUS_COUNT]; + void setIdentities(const std::list& identities_meta); + private: const HierarchicalCategoryInformation *getCategoryInfo (const EntryIndex&) const; const HierarchicalIdentityInformation *getIdentityInfo(const EntryIndex&) const; @@ -178,7 +180,6 @@ signals: void dataAboutToLoad(); private: - void setIdentities(const std::list& identities_meta); bool passesFilter(const EntryIndex &e, int column) const; void preMods() ; From 60750812d9e94d76d7278628611c32eb6e88bc1b Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 6 Mar 2025 20:39:29 +0100 Subject: [PATCH 40/84] fixed a few bugs --- retroshare-gui/src/gui/Identity/IdDialog.cpp | 168 +++++------------- .../src/gui/Identity/IdentityListModel.cpp | 32 +++- .../src/gui/Identity/IdentityListModel.h | 1 + 3 files changed, 74 insertions(+), 127 deletions(-) diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index de1f4b977..04762e104 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -1963,26 +1963,36 @@ void IdDialog::modifyReputation() void IdDialog::navigate(const RsGxsId& gxs_id) { -#ifdef ID_DEBUG +#ifndef ID_DEBUG std::cerr << "IdDialog::navigate to " << gxs_id.toStdString() << std::endl; #endif - QModelIndex indx = mProxyModel->mapFromSource(mIdListModel->getIndexOfIdentity(gxs_id)); + if(gxs_id.isNull()) + return; + + auto indx = mIdListModel->getIndexOfIdentity(gxs_id); + + if(!indx.isValid()) + { + RsErr() << "Invalid index found for identity " << gxs_id << std::endl; + return; + } + std::cerr << "Obtained index " << indx << ": id of that index is " << mIdListModel->getIdentity(indx) << std::endl; + + QModelIndex proxy_indx = mProxyModel->mapFromSource(indx); + + std::cerr << "Obtained proxy index " << proxy_indx << std::endl; // in order to do this, we just select the correct ID in the ID list - if (!gxs_id.isNull()) - { - if(!indx.isValid()) - { - mIdToNavigate = RsGxsGroupId(gxs_id); - std::cerr << "Cannot find item with ID " << gxs_id << " in ID list." << std::endl; - return; - } - ui->idTreeWidget->selectionModel()->select(indx,QItemSelectionModel::ClearAndSelect); - } - - mIdToNavigate = RsGxsGroupId(); + if(!proxy_indx.isValid()) + { + std::cerr << "Cannot find item with ID " << gxs_id << " in ID list." << std::endl; + return; + } + ui->idTreeWidget->selectionModel()->setCurrentIndex(proxy_indx,QItemSelectionModel::ClearAndSelect); + ui->idTreeWidget->scrollTo(proxy_indx);//May change if model reloaded + ui->idTreeWidget->setFocus(); } void IdDialog::updateDisplay(bool complete) @@ -2532,98 +2542,6 @@ void IdDialog::restoreExpandedCircleItems(const std::vector& expanded_root restoreTopLevel(mMyCircleItem,2); } -#ifdef TO_REMOVE -void IdDialog::saveExpandedPathsAndSelection_idTreeView(std::set& expanded_indexes, - std::set >& selected_indices) -{ - std::cerr << "Saving expended paths and selection... thread " << (void*)pthread_self() << std::endl; - - QModelIndexList selectedIndexes = ui->idTreeWidget->selectionModel()->selectedIndexes(); - - // convert all selected indices into something that is not QModelIndex-related, so that we can find it again after refreshing the list - - for(auto m:selectedIndexes) - if(m.column()==RsIdentityListModel::COLUMN_THREAD_ID) - { - auto t = mIdListModel->getType(m); - QString s ; - - if(t==RsIdentityListModel::ENTRY_TYPE_CATEGORY) - s = QString::number(mIdListModel->getCategory(mProxyModel->mapToSource(m))); - else - s = QString::fromStdString(mIdListModel->getIdentity(mProxyModel->mapToSource(m)).toStdString()); - - selected_indices.insert(std::make_pair(t,s)); - - std::cerr << "added " << s.toStdString() << " to selection save" << std::endl; - } - - for(int row = 0; row < mProxyModel->rowCount(); ++row) - { - auto m = mProxyModel->index(row,0); - - if(ui->idTreeWidget->isExpanded( m )) - { - auto str = QString::number(mIdListModel->getCategory(mProxyModel->mapToSource(m))); - expanded_indexes.insert( str ); - std::cerr << "added " << m << " cat " << str.toStdString() << " to expanded save" << std::endl; - } - } - -#ifdef DEBUG_NEW_FRIEND_LIST - std::cerr << " selected index: \"" << sel.toStdString() << "\"" << std::endl; -#endif -} - -void IdDialog::restoreExpandedPathsAndSelection_idTreeView(const std::set& expanded_indexes, - const std::set >& selected_indices) -{ - std::cerr << "Restoring expended paths and selection..." << std::endl; - ui->idTreeWidget->blockSignals(true) ; - ui->idTreeWidget->selectionModel()->blockSignals(true); - - for(auto it:selected_indices) - { - if(it.first==RsIdentityListModel::ENTRY_TYPE_CATEGORY) - ui->idTreeWidget->selectionModel()->select(mProxyModel->mapFromSource(mIdListModel->index(it.first,0,QModelIndex())),QItemSelectionModel::Select | QItemSelectionModel::Rows); - else if(it.first==RsIdentityListModel::ENTRY_TYPE_IDENTITY) - { - auto indx = mProxyModel->mapFromSource(mIdListModel->getIndexOfIdentity(RsGxsId(it.second.toStdString()))); - - if(indx.isValid()) - { - std::cerr << "trying to restore selection of id " << it.second.toStdString() << std::endl; - ui->idTreeWidget->selectionModel()->select(indx,QItemSelectionModel::Select | QItemSelectionModel::Rows); - } - else - std::cerr << "Index is invalid!" << std::endl; - } - } - //ui->idTreeWidget->selectionModel()->select(index, QItemSelectionModel::Select | QItemSelectionModel::Rows); - - #ifdef DEBUG_NEW_FRIEND_LIST - std::cerr << " index to select: \"" << index_to_select.toStdString() << "\"" << std::endl; -#endif - for(int row = 0; row < mIdListModel->rowCount(); ++row) - { - auto m = ui->idTreeWidget->model()->index(row,0); - - std::cerr << " index category = " << mIdListModel->getCategory(m) << std::endl; - - if(expanded_indexes.find(QString::number(mIdListModel->getCategory(m))) != expanded_indexes.end()) - { - std::cerr << "Restoring expanded index " << QString::number(mIdListModel->getCategory(m)).toStdString() << std::endl; - std::cerr << "Calling setExpanded " << m << std::endl; - ui->idTreeWidget->setExpanded(m,true); - } - else - ui->idTreeWidget->setExpanded(m,false); - } - ui->idTreeWidget->blockSignals(false) ; - ui->idTreeWidget->selectionModel()->blockSignals(false); -} -#endif - void IdDialog::applyWhileKeepingTree(std::function predicate) { std::set expanded,selected; @@ -2696,37 +2614,40 @@ void IdDialog::saveExpandedPathsAndSelection_idTreeView(std::set& e void IdDialog::restoreExpandedPathsAndSelection_idTreeView(const std::set& expanded, const std::set& selected) { - whileBlocking(ui->idTreeWidget)->clearSelection(); - ui->idTreeWidget->blockSignals(true) ; + ui->idTreeWidget->selectionModel()->blockSignals(true) ; + + ui->idTreeWidget->clearSelection(); for(int row = 0; row < mProxyModel->rowCount(); ++row) recursRestoreExpandedItems_idTreeView(mProxyModel->index(row,0),QStringList(),expanded,selected); + ui->idTreeWidget->selectionModel()->blockSignals(false) ; ui->idTreeWidget->blockSignals(false) ; } -void IdDialog::recursSaveExpandedItems_idTreeView(const QModelIndex& index,const QStringList& parent_path,std::set& expanded,std::set& selected) +void IdDialog::recursSaveExpandedItems_idTreeView(const QModelIndex& proxy_index,const QStringList& parent_path,std::set& expanded,std::set& selected) { QStringList local_path = parent_path; - local_path.push_back(index.sibling(index.row(),RsIdentityListModel::COLUMN_THREAD_NAME).data(RsIdentityListModel::TreePathRole).toString()) ; - if(ui->idTreeWidget->isExpanded(index)) + local_path.push_back(mIdListModel->indexIdentifier(mProxyModel->mapToSource(proxy_index))); + + if(ui->idTreeWidget->isExpanded(proxy_index)) { #ifdef DEBUG_ID_DIALOG std::cerr << "Adding expanded path "; for(auto L:local_path) std::cerr << "\"" << L.toStdString() << "\" " ; std::cerr << std::endl; #endif - if(index.isValid()) + if(proxy_index.isValid()) expanded.insert(local_path) ; - for(int row=0;rowrowCount(index);++row) - recursSaveExpandedItems_idTreeView(index.child(row,0),local_path,expanded,selected) ; + for(int row=0;rowrowCount(proxy_index);++row) + recursSaveExpandedItems_idTreeView(proxy_index.child(row,0),local_path,expanded,selected) ; } - if(ui->idTreeWidget->selectionModel()->isSelected(index)) + if(ui->idTreeWidget->selectionModel()->isSelected(proxy_index)) { -#ifdef DEBUG_ID_DIALOG +#ifndef DEBUG_ID_DIALOG std::cerr << "Adding selected path "; for(auto L:local_path) std::cerr << "\"" << L.toStdString() << "\" " ; std::cerr << std::endl; #endif @@ -2734,10 +2655,10 @@ void IdDialog::recursSaveExpandedItems_idTreeView(const QModelIndex& index,const } } -void IdDialog::recursRestoreExpandedItems_idTreeView(const QModelIndex& index,const QStringList& parent_path,const std::set& expanded,const std::set& selected) +void IdDialog::recursRestoreExpandedItems_idTreeView(const QModelIndex& proxy_index,const QStringList& parent_path,const std::set& expanded,const std::set& selected) { QStringList local_path = parent_path; - local_path.push_back(index.sibling(index.row(),RsIdentityListModel::COLUMN_THREAD_NAME).data(RsIdentityListModel::TreePathRole).toString()) ; + local_path.push_back(mIdListModel->indexIdentifier(mProxyModel->mapToSource(proxy_index))); if(expanded.find(local_path) != expanded.end()) { @@ -2746,21 +2667,22 @@ void IdDialog::recursRestoreExpandedItems_idTreeView(const QModelIndex& index,co for(auto L:local_path) std::cerr << "\"" << L.toStdString() << "\" " ; std::cerr << std::endl; #endif - ui->idTreeWidget->setExpanded(index,true) ; + ui->idTreeWidget->setExpanded(proxy_index,true) ; - for(int row=0;rowrowCount(index);++row) - recursRestoreExpandedItems_idTreeView(index.child(row,0),local_path,expanded,selected) ; + for(int row=0;rowrowCount(proxy_index);++row) + recursRestoreExpandedItems_idTreeView(proxy_index.child(row,0),local_path,expanded,selected) ; } if(selected.find(local_path) != selected.end()) { -#ifdef DEBUG_ID_DIALOG +#ifndef DEBUG_ID_DIALOG std::cerr << "Restoring selected path "; for(auto L:local_path) std::cerr << "\"" << L.toStdString() << "\" " ; std::cerr << std::endl; #endif - ui->idTreeWidget->selectionModel()->select(index, QItemSelectionModel::Select | QItemSelectionModel::Rows); + ui->idTreeWidget->selectionModel()->select(proxy_index, QItemSelectionModel::Select);// | QItemSelectionModel::Rows); } } + void IdDialog::sortColumn(int col,Qt::SortOrder so) { #ifdef DEBUG_NEW_FRIEND_LIST diff --git a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp index e97a0d1dc..71fbd556a 100644 --- a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp +++ b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp @@ -60,7 +60,6 @@ RsIdentityListModel::RsIdentityListModel(QObject *parent) void RsIdentityListModel::timerUpdate() { - std::cerr << "updating indices" << std::endl; emit dataChanged(index(0,0,QModelIndex()),index(2,0,QModelIndex())); } RsIdentityListModel::EntryIndex::EntryIndex() @@ -439,7 +438,7 @@ QVariant RsIdentityListModel::toolTipRole(const EntryIndex& fmpe,int /*column*/) { case ENTRY_TYPE_IDENTITY: { - RsGxsId id(mIdentities[mCategories[fmpe.category_index].child_identity_indices[fmpe.identity_index]].id); + const RsGxsId& id(mIdentities[mCategories[fmpe.category_index].child_identity_indices[fmpe.identity_index]].id); if(rsIdentity->isOwnId(id)) return QVariant(tr("This identity is owned by you")); @@ -488,12 +487,34 @@ QVariant RsIdentityListModel::sizeHintRole(const EntryIndex& e,int col) const } } +QString RsIdentityListModel::indexIdentifier(QModelIndex index) +{ + quintptr ref = (index.isValid())?index.internalId():0 ; + +#ifdef DEBUG_MESSAGE_MODEL + std::cerr << "data(" << index << ")" ; +#endif + + if(!ref) + { +#ifdef DEBUG_MESSAGE_MODEL + std::cerr << " [empty]" << std::endl; +#endif + return QString(); + } + + EntryIndex entry; + if(!convertInternalIdToIndex(ref,entry)) + return QString(); + + return treePathRole(entry,0).toString(); +} QVariant RsIdentityListModel::treePathRole(const EntryIndex& entry,int /*column*/) const { if(entry.type == ENTRY_TYPE_CATEGORY) return QString::number((int)entry.category_index); else - return QString::fromStdString(mIdentities[entry.identity_index].id.toStdString()); + return QString::fromStdString(mIdentities[mCategories[entry.category_index].child_identity_indices[entry.identity_index]].id.toStdString()); } QVariant RsIdentityListModel::sortRole(const EntryIndex& entry,int column) const { @@ -701,7 +722,10 @@ const RsIdentityListModel::HierarchicalIdentityInformation *RsIdentityListModel: if(e.identity_index < mCategories[e.category_index].child_identity_indices.size()) return &mIdentities[mCategories[e.category_index].child_identity_indices[e.identity_index]]; else - return &mIdentities[e.identity_index]; + { + RsErr() << "Inconsistent identity index!" ; + return nullptr; + } } QVariant RsIdentityListModel::decorationRole(const EntryIndex& entry,int col) const diff --git a/retroshare-gui/src/gui/Identity/IdentityListModel.h b/retroshare-gui/src/gui/Identity/IdentityListModel.h index 4aab1c0a8..62dc1a7d2 100644 --- a/retroshare-gui/src/gui/Identity/IdentityListModel.h +++ b/retroshare-gui/src/gui/Identity/IdentityListModel.h @@ -139,6 +139,7 @@ public: QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; void clear() ; + QString indexIdentifier(QModelIndex i); /* Color definitions (for standard see default.qss) */ QColor mTextColorGroup; From e77b4271fc7d5c52c36fdec10802292b79b54d6b Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 9 Mar 2025 15:34:19 +0100 Subject: [PATCH 41/84] limiting calls to getIdDetails to the bare minimum --- retroshare-gui/src/gui/Identity/IdDialog.cpp | 4 +- .../src/gui/Identity/IdentityListModel.cpp | 85 ++++++++++--------- .../src/gui/Identity/IdentityListModel.h | 9 +- 3 files changed, 52 insertions(+), 46 deletions(-) diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index 04762e104..889e1fd16 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -1990,7 +1990,7 @@ void IdDialog::navigate(const RsGxsId& gxs_id) std::cerr << "Cannot find item with ID " << gxs_id << " in ID list." << std::endl; return; } - ui->idTreeWidget->selectionModel()->setCurrentIndex(proxy_indx,QItemSelectionModel::ClearAndSelect); + ui->idTreeWidget->selectionModel()->setCurrentIndex(proxy_indx,QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); ui->idTreeWidget->scrollTo(proxy_indx);//May change if model reloaded ui->idTreeWidget->setFocus(); } @@ -2679,7 +2679,7 @@ void IdDialog::recursRestoreExpandedItems_idTreeView(const QModelIndex& proxy_in std::cerr << "Restoring selected path "; for(auto L:local_path) std::cerr << "\"" << L.toStdString() << "\" " ; std::cerr << std::endl; #endif - ui->idTreeWidget->selectionModel()->select(proxy_index, QItemSelectionModel::Select);// | QItemSelectionModel::Rows); + ui->idTreeWidget->selectionModel()->select(proxy_index, QItemSelectionModel::Select | QItemSelectionModel::Rows); } } diff --git a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp index 71fbd556a..ee00be41e 100644 --- a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp +++ b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp @@ -47,7 +47,7 @@ const QString RsIdentityListModel::FilterString("filtered"); const uint32_t MAX_INTERNAL_DATA_UPDATE_DELAY = 300 ; // re-update the internal data every 5 mins. Should properly cover sleep/wake-up changes. const uint32_t MAX_NODE_UPDATE_DELAY = 10 ; // re-update the internal data every 5 mins. Should properly cover sleep/wake-up changes. -static const uint32_t NODE_DETAILS_UPDATE_DELAY = 5; // update each node every 5 secs. +static const uint32_t ID_DETAILS_UPDATE_DELAY = 5; // update each node every 5 secs. RsIdentityListModel::RsIdentityListModel(QObject *parent) : QAbstractItemModel(parent) @@ -420,41 +420,28 @@ void RsIdentityListModel::setFilter(FilterType filter_type, const QStringList& s postMods(); } -bool RsIdentityListModel::requestIdentityDetails(const RsGxsId& id,RsIdentityDetails& det) const -{ - if(!rsIdentity->getIdDetails(id,det)) - { - mIdentityUpdateTimer->stop(); - mIdentityUpdateTimer->setSingleShot(true); - mIdentityUpdateTimer->start(500); - return false; - } - - return true; -} QVariant RsIdentityListModel::toolTipRole(const EntryIndex& fmpe,int /*column*/) const { switch(fmpe.type) { case ENTRY_TYPE_IDENTITY: { - const RsGxsId& id(mIdentities[mCategories[fmpe.category_index].child_identity_indices[fmpe.identity_index]].id); + auto id_info = getIdentityInfo(fmpe); - if(rsIdentity->isOwnId(id)) - return QVariant(tr("This identity is owned by you")); - - RsIdentityDetails det; - if(!requestIdentityDetails(id,det)) + if(!id_info) return QVariant(); - if(det.mPgpId.isNull()) + if(rsIdentity->isOwnId(id_info->id)) + return QVariant(tr("This identity is owned by you")); + + if(id_info->owner.isNull()) return QVariant("Anonymous identity"); else { RsPeerDetails dd; - rsPeers->getGPGDetails(det.mPgpId,dd); + rsPeers->getGPGDetails(id_info->owner,dd); - return QVariant("Identity owned by profile \""+ QString::fromUtf8(dd.name.c_str()) +"\" ("+QString::fromStdString(det.mPgpId.toStdString())); + return QVariant("Identity owned by profile \""+ QString::fromUtf8(dd.name.c_str()) +"\" ("+QString::fromStdString(id_info->owner.toStdString())); } } @@ -565,13 +552,8 @@ QVariant RsIdentityListModel::foregroundRole(const EntryIndex& e, int /*col*/) c auto it = getIdentityInfo(e); if(!it) return QVariant(); - RsGxsId id(it->id); - RsIdentityDetails det; - if(!requestIdentityDetails(id,det)) - return QVariant(); - - if(det.mFlags & RS_IDENTITY_FLAGS_IS_DEPRECATED) + if(it->flags & RS_IDENTITY_FLAGS_IS_DEPRECATED) return QVariant(QColor(Qt::red)); return QVariant(); @@ -658,27 +640,22 @@ QVariant RsIdentityListModel::displayRole(const EntryIndex& e, int col) const if(!idinfo) return QVariant(); - RsIdentityDetails det; - - if(!requestIdentityDetails(idinfo->id,det)) - return QVariant(); - #ifdef DEBUG_MODEL_INDEX std::cerr << profile->profile_info.name.c_str() ; #endif switch(col) { - case COLUMN_THREAD_NAME: return QVariant(QString::fromUtf8(det.mNickname.c_str())); - case COLUMN_THREAD_ID: return QVariant(QString::fromStdString(det.mId.toStdString()) ); - case COLUMN_THREAD_OWNER_NAME: if(det.mPgpId.isNull()) + case COLUMN_THREAD_NAME: return QVariant(QString::fromUtf8(idinfo->nickname.c_str())); + case COLUMN_THREAD_ID: return QVariant(QString::fromStdString(idinfo->id.toStdString()) ); + case COLUMN_THREAD_OWNER_NAME: if(idinfo->owner.isNull()) return QVariant(); else - return QVariant(QString::fromStdString(rsPeers->getGPGName(det.mPgpId)) ); + return QVariant(QString::fromStdString(rsPeers->getGPGName(idinfo->owner)) ); - case COLUMN_THREAD_OWNER_ID: if(det.mPgpId.isNull()) + case COLUMN_THREAD_OWNER_ID: if(idinfo->owner.isNull()) return QVariant(); else - return QVariant(QString::fromStdString(det.mPgpId.toStdString()) ); + return QVariant(QString::fromStdString(idinfo->owner.toStdString()) ); default: return QVariant(); } @@ -720,7 +697,23 @@ const RsIdentityListModel::HierarchicalIdentityInformation *RsIdentityListModel: return NULL ; if(e.identity_index < mCategories[e.category_index].child_identity_indices.size()) - return &mIdentities[mCategories[e.category_index].child_identity_indices[e.identity_index]]; + { + auto& it(mIdentities[mCategories[e.category_index].child_identity_indices[e.identity_index]]); + rstime_t now = time(nullptr); + + if(now > it.last_update_TS + ID_DETAILS_UPDATE_DELAY) + { + RsIdentityDetails det; + if(rsIdentity->getIdDetails(it.id,det)) + { + it.last_update_TS = now; + it.nickname = det.mNickname; + it.owner = det.mPgpId; + it.flags = det.mFlags; + } + } + return ⁢ + } else { RsErr() << "Inconsistent identity index!" ; @@ -747,9 +740,16 @@ QVariant RsIdentityListModel::decorationRole(const EntryIndex& entry,int col) co else if(col == COLUMN_THREAD_NAME) { QPixmap sslAvatar; - AvatarDefs::getAvatarFromGxsId(hn->id, sslAvatar); - return QVariant(QIcon(sslAvatar)); + if(! AvatarDefs::getAvatarFromGxsId(hn->id, sslAvatar)) + { + mIdentityUpdateTimer->stop(); + mIdentityUpdateTimer->setSingleShot(true); + mIdentityUpdateTimer->start(500); + return QVariant(); + } + else + return QVariant(QIcon(sslAvatar)); } else return QVariant(); @@ -863,6 +863,7 @@ void RsIdentityListModel::setIdentities(const std::list& identi { HierarchicalIdentityInformation idinfo; idinfo.id = RsGxsId(id.mGroupId); + idinfo.last_update_TS = 0;// forces update if(rsIdentity->isOwnId(idinfo.id)) mCategories[CATEGORY_OWN].child_identity_indices.push_back(mIdentities.size()); diff --git a/retroshare-gui/src/gui/Identity/IdentityListModel.h b/retroshare-gui/src/gui/Identity/IdentityListModel.h index 62dc1a7d2..4eb191aa7 100644 --- a/retroshare-gui/src/gui/Identity/IdentityListModel.h +++ b/retroshare-gui/src/gui/Identity/IdentityListModel.h @@ -79,9 +79,16 @@ public: QString category_name; std::vector child_identity_indices; // index in the array of hierarchical profiles }; + + // This stores all the info that is useful avoiding a call to the more expensive getIdDetails() + // struct HierarchicalIdentityInformation { + rstime_t last_update_TS; RsGxsId id; + RsPgpId owner; + uint32_t flags; + std::string nickname; }; // This structure encodes the position of a node in the hierarchy. The type tells which of the index fields are valid. @@ -190,8 +197,6 @@ private: void *getChildRef(void *ref,int row) const; int getChildrenCount(void *ref) const; - bool requestIdentityDetails(const RsGxsId& id,RsIdentityDetails& det) const; - static bool convertIndexToInternalId(const EntryIndex& e,quintptr& ref); static bool convertInternalIdToIndex(quintptr ref, EntryIndex& e); From 92290015eb4900d0fd629d3917d50aeb470c1e9b Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 15 Mar 2025 15:01:00 +0100 Subject: [PATCH 42/84] added [Loading...] string when loading info in the item model --- .../src/gui/Identity/IdentityListModel.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp index ee00be41e..7bb228a7b 100644 --- a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp +++ b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp @@ -636,17 +636,20 @@ QVariant RsIdentityListModel::displayRole(const EntryIndex& e, int col) const case ENTRY_TYPE_IDENTITY: { const HierarchicalIdentityInformation *idinfo = getIdentityInfo(e); - - if(!idinfo) - return QVariant(); + const QString loading_string = "["+tr("Loading...")+"]"; #ifdef DEBUG_MODEL_INDEX std::cerr << profile->profile_info.name.c_str() ; #endif + if(col == COLUMN_THREAD_ID) return QVariant(QString::fromStdString(idinfo->id.toStdString()) ); + if(col == COLUMN_THREAD_REPUTATION) return QVariant(); + + if(idinfo->nickname.empty()) + return loading_string; + switch(col) { case COLUMN_THREAD_NAME: return QVariant(QString::fromUtf8(idinfo->nickname.c_str())); - case COLUMN_THREAD_ID: return QVariant(QString::fromStdString(idinfo->id.toStdString()) ); case COLUMN_THREAD_OWNER_NAME: if(idinfo->owner.isNull()) return QVariant(); else @@ -691,10 +694,10 @@ const RsIdentityListModel::HierarchicalIdentityInformation *RsIdentityListModel: // First look into the relevant group, then for the correct profile in this group. if(e.type != ENTRY_TYPE_IDENTITY) - return NULL ; + return nullptr ; if(e.category_index >= mCategories.size()) - return NULL ; + return nullptr ; if(e.identity_index < mCategories[e.category_index].child_identity_indices.size()) { @@ -706,10 +709,10 @@ const RsIdentityListModel::HierarchicalIdentityInformation *RsIdentityListModel: RsIdentityDetails det; if(rsIdentity->getIdDetails(it.id,det)) { - it.last_update_TS = now; it.nickname = det.mNickname; it.owner = det.mPgpId; it.flags = det.mFlags; + it.last_update_TS = now; } } return ⁢ From 8c2c3188efd5963efbbc2117eb64e216d910212e Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 15 Mar 2025 16:07:48 +0100 Subject: [PATCH 43/84] fixed sizeHint role --- .../src/gui/Identity/IdentityListModel.cpp | 7 +++++-- retroshare-gui/src/gui/gxs/GxsIdDetails.cpp | 13 +++++++++---- retroshare-gui/src/gui/gxs/GxsIdDetails.h | 3 ++- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp index 7bb228a7b..a939fbe2d 100644 --- a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp +++ b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp @@ -468,7 +468,7 @@ QVariant RsIdentityListModel::sizeHintRole(const EntryIndex& e,int col) const default: case COLUMN_THREAD_NAME: return QVariant( QSize(x_factor * 70 , y_factor*14*1.1f )); case COLUMN_THREAD_ID: return QVariant( QSize(x_factor * 175, y_factor*14*1.1f )); - case COLUMN_THREAD_REPUTATION: return QVariant( QSize(x_factor * 20 , y_factor*14*1.1f )); + case COLUMN_THREAD_REPUTATION: return QVariant( QSize(x_factor * 14 , y_factor*14*1.1f )); case COLUMN_THREAD_OWNER_NAME: return QVariant( QSize(x_factor * 70 , y_factor*14*1.1f )); case COLUMN_THREAD_OWNER_ID: return QVariant( QSize(x_factor * 70 , y_factor*14*1.1f )); } @@ -743,14 +743,17 @@ QVariant RsIdentityListModel::decorationRole(const EntryIndex& entry,int col) co else if(col == COLUMN_THREAD_NAME) { QPixmap sslAvatar; + RsIdentityDetails details ; - if(! AvatarDefs::getAvatarFromGxsId(hn->id, sslAvatar)) + if(!rsIdentity->getIdDetails(hn->id, details)) { mIdentityUpdateTimer->stop(); mIdentityUpdateTimer->setSingleShot(true); mIdentityUpdateTimer->start(500); return QVariant(); } + else if(details.mAvatar.mSize == 0 || !GxsIdDetails::loadPixmapFromData(details.mAvatar.mData, details.mAvatar.mSize, sslAvatar,GxsIdDetails::LARGE)) + return QVariant(QIcon(GxsIdDetails::makeDefaultIcon(hn->id,GxsIdDetails::SMALL))); else return QVariant(QIcon(sslAvatar)); } diff --git a/retroshare-gui/src/gui/gxs/GxsIdDetails.cpp b/retroshare-gui/src/gui/gxs/GxsIdDetails.cpp index d854b1f76..5c1c11b49 100644 --- a/retroshare-gui/src/gui/gxs/GxsIdDetails.cpp +++ b/retroshare-gui/src/gui/gxs/GxsIdDetails.cpp @@ -85,14 +85,14 @@ void ReputationItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem { Q_ASSERT(index.isValid()); - QStyleOptionViewItemV4 opt = option; + QStyleOptionViewItem opt(option); initStyleOption(&opt, index); // disable default icon opt.icon = QIcon(); // draw default item QApplication::style()->drawControl(QStyle::CE_ItemViewItem, &opt, painter, 0); - const QRect r = option.rect; + const QRect r = option.rect; // get pixmap auto v = index.data(Qt::DecorationRole); @@ -105,8 +105,7 @@ void ReputationItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem if(icon_index > mMaxLevelToDisplay) return ; - QIcon icon = GxsIdDetails::getReputationIcon( - RsReputationLevel(icon_index), 0xff ); + QIcon icon = GxsIdDetails::getReputationIcon( RsReputationLevel(icon_index), 0xff ); QPixmap pix = icon.pixmap(r.size()); @@ -115,6 +114,12 @@ void ReputationItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem painter->drawPixmap(r.topLeft() + p, pix); } +QSize ReputationItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex & /*index*/) const +{ + int s = 1.5*QFontMetricsF(option.font).height(); + + return QSize(s,s); +} /* The global object */ GxsIdDetails *GxsIdDetails::mInstance = NULL ; diff --git a/retroshare-gui/src/gui/gxs/GxsIdDetails.h b/retroshare-gui/src/gui/gxs/GxsIdDetails.h index 05568aa3a..122b5e089 100644 --- a/retroshare-gui/src/gui/gxs/GxsIdDetails.h +++ b/retroshare-gui/src/gui/gxs/GxsIdDetails.h @@ -52,7 +52,8 @@ public: ReputationItemDelegate(RsReputationLevel max_level_to_display) : mMaxLevelToDisplay(static_cast(max_level_to_display)) {} - virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; + virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; + virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex & /*index*/) const override; private: uint32_t mMaxLevelToDisplay ; From 417f80d752f3c4ed08c56147ce4d909c35bc5b9d Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 23 Mar 2025 17:17:08 +0100 Subject: [PATCH 44/84] added some debug info --- retroshare-gui/src/gui/Identity/IdDialog.cpp | 53 +++++++++++++++---- retroshare-gui/src/gui/Identity/IdDialog.h | 3 +- .../src/gui/Identity/IdentityListModel.cpp | 12 ++++- .../src/gui/Identity/IdentityListModel.h | 15 +++++- 4 files changed, 70 insertions(+), 13 deletions(-) diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index 889e1fd16..56958e932 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -231,6 +231,7 @@ IdDialog::IdDialog(QWidget *parent) mProxyModel->setFilterRegExp(QRegExp(RsIdentityListModel::FilterString)); ui->idTreeWidget->setModel(mProxyModel); + //ui->idTreeWidget->setSelectionModel(new QItemSelectionModel(mProxyModel));// useless in Qt5. ui->treeWidget_membership->clear(); ui->treeWidget_membership->setItemDelegateForColumn(CIRCLEGROUP_CIRCLE_COL_GROUPNAME,new GxsIdTreeItemDelegate()); @@ -290,7 +291,7 @@ IdDialog::IdDialog(QWidget *parent) connect(ui->editIdentity, SIGNAL(triggered()), this, SLOT(editIdentity())); connect(ui->chatIdentity, SIGNAL(triggered()), this, SLOT(chatIdentity())); - connect(ui->idTreeWidget->selectionModel(),SIGNAL(selectionChanged(const QItemSelection&,const QItemSelection&)),this,SLOT(updateSelection())); + connect(ui->idTreeWidget->selectionModel(),SIGNAL(selectionChanged(const QItemSelection&,const QItemSelection&)),this,SLOT(updateSelection(const QItemSelection&,const QItemSelection&))); connect(ui->idTreeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(IdListCustomPopupMenu(QPoint))); ui->idTreeWidget->header()->setContextMenuPolicy(Qt::CustomContextMenu); @@ -1358,8 +1359,13 @@ void IdDialog::filterToggled(const bool &value) } } -void IdDialog::updateSelection() +void IdDialog::updateSelection(const QItemSelection& new_sel,const QItemSelection& old_sel) { + std::cerr << "Got selectionChanged signal. Old selection is: " << std::endl; + for(auto i:old_sel.indexes()) std::cerr << " " << i << std::endl; + std::cerr << "Got selectionChanged signal. New selection is: " << std::endl; + for(auto i:new_sel.indexes()) std::cerr << " " << i << std::endl; + auto id = RsGxsGroupId(getSelectedIdentity()); std::cerr << "updating selection to id " << id << std::endl; @@ -1963,6 +1969,7 @@ void IdDialog::modifyReputation() void IdDialog::navigate(const RsGxsId& gxs_id) { + mIdListModel->debug_dump(); #ifndef ID_DEBUG std::cerr << "IdDialog::navigate to " << gxs_id.toStdString() << std::endl; #endif @@ -1984,15 +1991,32 @@ void IdDialog::navigate(const RsGxsId& gxs_id) std::cerr << "Obtained proxy index " << proxy_indx << std::endl; // in order to do this, we just select the correct ID in the ID list + Q_ASSERT(ui->idTreeWidget->model() == mProxyModel); if(!proxy_indx.isValid()) { std::cerr << "Cannot find item with ID " << gxs_id << " in ID list." << std::endl; return; } - ui->idTreeWidget->selectionModel()->setCurrentIndex(proxy_indx,QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); + std::cerr << "Row hidden? " << ui->idTreeWidget->isRowHidden(proxy_indx.row(),proxy_indx.parent()) << std::endl; + + { + auto ii = mProxyModel->mapToSource(proxy_indx); + std::cerr << "Remapping index to source: " << ii << std::endl; + } + ui->idTreeWidget->selectionModel()->select(proxy_indx,QItemSelectionModel::Current|QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); + { + auto lst = ui->idTreeWidget->selectionModel()->selectedIndexes(); + std::cerr << "Just after calling select(), the selected index list has size " << lst.size() << std::endl; + } ui->idTreeWidget->scrollTo(proxy_indx);//May change if model reloaded ui->idTreeWidget->setFocus(); + + // This has to be done manually because for some reason the proxy model doesn't work with the selection model + // No signal is emitted when calling setCurrentIndex() above. + + //mId = RsGxsGroupId(gxs_id); + //updateIdentity(); } void IdDialog::updateDisplay(bool complete) @@ -2012,16 +2036,24 @@ void IdDialog::updateDisplay(bool complete) std::list IdDialog::getSelectedIdentities() const { - QModelIndexList selectedIndexes = ui->idTreeWidget->selectionModel()->selectedIndexes(); + QModelIndexList selectedIndexes_proxy = ui->idTreeWidget->selectionModel()->selectedIndexes(); std::list res; - for(auto indx:selectedIndexes) + std::cerr << "Parsing selected index list: " << std::endl; + for(auto indx_proxy:selectedIndexes_proxy) { RsGxsId id; - if(indx.column() == RsIdentityListModel::COLUMN_THREAD_NAME) // this removes duplicates - if( !(id = mIdListModel->getIdentity(mProxyModel->mapToSource(indx))).isNull() ) + if(indx_proxy.column() == RsIdentityListModel::COLUMN_THREAD_ID) // this removes duplicates + { + auto indx = mProxyModel->mapToSource(indx_proxy); + auto id = mIdListModel->getIdentity(indx); + + std::cerr << " indx: " << indx_proxy << " original indx: " << indx << " identity: " << id << std::endl; + + if( !id.isNull() ) res.push_back(id); + } } return res; @@ -2031,6 +2063,8 @@ RsGxsId IdDialog::getSelectedIdentity() const { auto lst = getSelectedIdentities(); + std::cerr << "Selected identities has size " << lst.size() << std::endl; + if(lst.size() != 1) return RsGxsId(); else @@ -2573,13 +2607,14 @@ void IdDialog::applyWhileKeepingTree(std::function predicate) #ifdef DEBUG_NEW_FRIEND_LIST std::cerr << "Applying predicate..." << std::endl; #endif - mProxyModel->setSourceModel(nullptr); #endif + mProxyModel->setSourceModel(nullptr); + predicate(); restoreExpandedPathsAndSelection_idTreeView(expanded,selected); -// mProxyModel->setSourceModel(mIdListModel); + mProxyModel->setSourceModel(mIdListModel); // restore hidden columns for(uint32_t i=0;i Date: Mon, 24 Mar 2025 23:24:08 +0100 Subject: [PATCH 45/84] Added set and get of font size on RshareSettings --- .../src/gui/settings/AppearancePage.cpp | 16 +++------- .../src/gui/settings/AppearancePage.ui | 2 +- .../src/gui/settings/MessagePage.cpp | 28 ++++++++-------- .../src/gui/settings/MessagePage.ui | 19 ++++++++--- .../src/gui/settings/rsharesettings.cpp | 32 +++++++++++++++++++ .../src/gui/settings/rsharesettings.h | 6 ++++ 6 files changed, 72 insertions(+), 31 deletions(-) diff --git a/retroshare-gui/src/gui/settings/AppearancePage.cpp b/retroshare-gui/src/gui/settings/AppearancePage.cpp index c471649cb..2aecd6024 100755 --- a/retroshare-gui/src/gui/settings/AppearancePage.cpp +++ b/retroshare-gui/src/gui/settings/AppearancePage.cpp @@ -362,20 +362,12 @@ void AppearancePage::load() whileBlocking(ui.checkBoxShowToasterDisable)->setChecked(Settings->valueFromGroup("StatusBar", "ShowToaster", QVariant(true)).toBool()); whileBlocking(ui.checkBoxShowSystrayOnStatus)->setChecked(Settings->valueFromGroup("StatusBar", "ShowSysTrayOnStatusBar", QVariant(false)).toBool()); - Settings->beginGroup(QString("File")); -#if defined(Q_OS_DARWIN) - whileBlocking(ui.minimumFontSize_SB)->setValue( Settings->value("MinimumFontSize", 13 ).toInt()); -#else - whileBlocking(ui.minimumFontSize_SB)->setValue( Settings->value("MinimumFontSize", 11 ).toInt()); -#endif - Settings->endGroup(); + whileBlocking(ui.minimumFontSize_SB)->setValue(Settings->getFontSize()); } void AppearancePage::updateFontSize() { - Settings->beginGroup(QString("File")); - Settings->setValue("MinimumFontSize", ui.minimumFontSize_SB->value()); - Settings->endGroup(); - + Settings->setFontSize(ui.minimumFontSize_SB->value()); + NotifyQt::getInstance()->notifySettingsChanged(); -} \ No newline at end of file +} diff --git a/retroshare-gui/src/gui/settings/AppearancePage.ui b/retroshare-gui/src/gui/settings/AppearancePage.ui index 592113e01..13dc7a48e 100755 --- a/retroshare-gui/src/gui/settings/AppearancePage.ui +++ b/retroshare-gui/src/gui/settings/AppearancePage.ui @@ -260,7 +260,7 @@ - 11 + 5 64 diff --git a/retroshare-gui/src/gui/settings/MessagePage.cpp b/retroshare-gui/src/gui/settings/MessagePage.cpp index de4908088..be8b515ff 100644 --- a/retroshare-gui/src/gui/settings/MessagePage.cpp +++ b/retroshare-gui/src/gui/settings/MessagePage.cpp @@ -18,6 +18,8 @@ * * *******************************************************************************/ +#include + #include "rshare.h" #include "rsharesettings.h" #include "retroshare/rsmsgs.h" @@ -28,6 +30,7 @@ #include #include "NewTag.h" #include "util/qtthreadsutils.h" +#include "gui/notifyqt.h" MessagePage::MessagePage(QWidget * parent, Qt::WindowFlags flags) : ConfigPage(parent, flags) @@ -48,14 +51,20 @@ MessagePage::MessagePage(QWidget * parent, Qt::WindowFlags flags) ui.openComboBox->addItem(tr("A new tab"), RshareSettings::MSG_OPEN_TAB); ui.openComboBox->addItem(tr("A new window"), RshareSettings::MSG_OPEN_WINDOW); - + + // Font size + QFontDatabase db; + foreach(int size, db.standardSizes()) { + ui.minimumFontSize->addItem(QString::number(size), size); + } + connect(ui.comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(distantMsgsComboBoxChanged(int))); connect(ui.setMsgToReadOnActivate,SIGNAL(toggled(bool)), this,SLOT(updateMsgToReadOnActivate())); connect(ui.loadEmbeddedImages, SIGNAL(toggled(bool)), this,SLOT(updateLoadEmbededImages() )); connect(ui.openComboBox, SIGNAL(currentIndexChanged(int)),this,SLOT(updateMsgOpen() )); connect(ui.emoticonscheckBox, SIGNAL(toggled(bool)), this,SLOT(updateLoadEmoticons() )); - connect(ui.minimumFontSize_SB, SIGNAL(valueChanged(int)), this, SLOT(updateFontSize())) ; + connect(ui.minimumFontSize, SIGNAL(activated(QString)), this, SLOT(updateFontSize())) ; mTagEventHandlerId = 0; rsEvents->registerEventsHandler( [this](std::shared_ptr event) { RsQThreadUtils::postToObject( [this,event]() { handleEvent_main_thread(event); }); }, mTagEventHandlerId, RsEventType::MAIL_TAG ); @@ -117,17 +126,11 @@ void MessagePage::updateMsgTags() void MessagePage::load() { - Settings->beginGroup(QString("Messages")); whileBlocking(ui.setMsgToReadOnActivate)->setChecked(Settings->getMsgSetToReadOnActivate()); whileBlocking(ui.loadEmbeddedImages)->setChecked(Settings->getMsgLoadEmbeddedImages()); whileBlocking(ui.openComboBox)->setCurrentIndex(ui.openComboBox->findData(Settings->getMsgOpen())); whileBlocking(ui.emoticonscheckBox)->setChecked(Settings->value("Emoticons", true).toBool()); -#if defined(Q_OS_DARWIN) - whileBlocking(ui.minimumFontSize_SB)->setValue( Settings->value("MinimumFontSize", 13 ).toInt()); -#else - whileBlocking(ui.minimumFontSize_SB)->setValue( Settings->value("MinimumFontSize", 12 ).toInt()); -#endif - Settings->endGroup(); + whileBlocking(ui.minimumFontSize)->setCurrentIndex(ui.minimumFontSize->findData(Settings->getMessageFontSize())); // state of filter combobox @@ -306,8 +309,7 @@ void MessagePage::currentRowChangedTag(int row) void MessagePage::updateFontSize() { - Settings->beginGroup(QString("Messages")); - Settings->setValue("MinimumFontSize", ui.minimumFontSize_SB->value()); - Settings->endGroup(); -} + Settings->setMessageFontSize(ui.minimumFontSize->currentData().toInt()); + NotifyQt::getInstance()->notifySettingsChanged(); +} diff --git a/retroshare-gui/src/gui/settings/MessagePage.ui b/retroshare-gui/src/gui/settings/MessagePage.ui index a0579ab69..3e5ab3842 100644 --- a/retroshare-gui/src/gui/settings/MessagePage.ui +++ b/retroshare-gui/src/gui/settings/MessagePage.ui @@ -203,12 +203,21 @@ - - - 10 + + + + MS Sans Serif + 10 + - - 64 + + Qt::ClickFocus + + + Font size + + + true diff --git a/retroshare-gui/src/gui/settings/rsharesettings.cpp b/retroshare-gui/src/gui/settings/rsharesettings.cpp index e811acd4a..119ea9566 100644 --- a/retroshare-gui/src/gui/settings/rsharesettings.cpp +++ b/retroshare-gui/src/gui/settings/rsharesettings.cpp @@ -1190,6 +1190,38 @@ void RshareSettings::setPageAlreadyDisplayed(const QString& page_name,bool b) return setValueToGroup("PageAlreadyDisplayed",page_name,b); } +int RshareSettings::getFontSize() +{ +#if defined(Q_OS_DARWIN) + int defaultFontSize = 13; +#else + int defaultFontSize = 9; +#endif + + return value("FontSize", defaultFontSize).toInt(); +} + +void RshareSettings::setFontSize(int value) +{ + setValue("FontSize", value); +} + +int RshareSettings::getMessageFontSize() +{ +#if defined(Q_OS_DARWIN) + int defaultFontSize = 12; +#else + int defaultFontSize = 9; +#endif + + return valueFromGroup("Message", "FontSize", defaultFontSize).toInt(); +} + +void RshareSettings::setMessageFontSize(int value) +{ + setValueToGroup("Message", "FontSize", value); +} + #ifdef RS_JSONAPI bool RshareSettings::getJsonApiEnabled() { diff --git a/retroshare-gui/src/gui/settings/rsharesettings.h b/retroshare-gui/src/gui/settings/rsharesettings.h index 362e52606..317dedb56 100644 --- a/retroshare-gui/src/gui/settings/rsharesettings.h +++ b/retroshare-gui/src/gui/settings/rsharesettings.h @@ -343,6 +343,12 @@ public: bool getPageAlreadyDisplayed(const QString& page_code) ; void setPageAlreadyDisplayed(const QString& page_code,bool b) ; + int getFontSize(); + void setFontSize(int value); + + int getMessageFontSize(); + void setMessageFontSize(int value); + #ifdef RS_JSONAPI bool getJsonApiEnabled(); void setJsonApiEnabled(bool enabled); From 93154fddc4b0a10fd29fde38824066dd64d6b5f5 Mon Sep 17 00:00:00 2001 From: thunder2 Date: Wed, 26 Mar 2025 01:20:54 +0100 Subject: [PATCH 46/84] Added new class FontSizeHandler to set font size from settings --- retroshare-gui/src/retroshare-gui.pro | 2 + retroshare-gui/src/util/FontSizeHandler.cpp | 210 ++++++++++++++++++++ retroshare-gui/src/util/FontSizeHandler.h | 71 +++++++ 3 files changed, 283 insertions(+) create mode 100644 retroshare-gui/src/util/FontSizeHandler.cpp create mode 100644 retroshare-gui/src/util/FontSizeHandler.h diff --git a/retroshare-gui/src/retroshare-gui.pro b/retroshare-gui/src/retroshare-gui.pro index d73117b84..e88d931f6 100644 --- a/retroshare-gui/src/retroshare-gui.pro +++ b/retroshare-gui/src/retroshare-gui.pro @@ -451,6 +451,7 @@ HEADERS += rshare.h \ util/qtthreadsutils.h \ util/ClickableLabel.h \ util/AspectRatioPixmapLabel.h \ + util/FontSizeHandler.h \ gui/profile/ProfileWidget.h \ gui/profile/ProfileManager.h \ gui/profile/StatusMessage.h \ @@ -817,6 +818,7 @@ SOURCES += main.cpp \ util/RichTextEdit.cpp \ util/ClickableLabel.cpp \ util/AspectRatioPixmapLabel.cpp \ + util/FontSizeHandler.cpp \ gui/profile/ProfileWidget.cpp \ gui/profile/StatusMessage.cpp \ gui/profile/ProfileManager.cpp \ diff --git a/retroshare-gui/src/util/FontSizeHandler.cpp b/retroshare-gui/src/util/FontSizeHandler.cpp new file mode 100644 index 000000000..c184da0de --- /dev/null +++ b/retroshare-gui/src/util/FontSizeHandler.cpp @@ -0,0 +1,210 @@ +/******************************************************************************* + * util/FontSizeHandler.cpp * + * * + * Copyright (C) 2025, Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + +#include +#include +#include + +#include "rshare.h" +#include "FontSizeHandler.h" +#include "gui/settings/rsharesettings.h" +#include "gui/notifyqt.h" + +// Data for QAbstractItemView +struct FontSizeHandlerWidgetData +{ + std::function callback; +}; + +// Data for QWidget +struct FontSizeHandlerViewData +{ + float iconHeightFactor; + std::function callback; +}; + +class FontSizeHandlerObject : public QObject +{ +public: + FontSizeHandlerObject(FontSizeHandlerBase *fontSizeHandler): QObject() + { + mFontSizeHandlerBase = fontSizeHandler; + } + + bool eventFilter(QObject* object, QEvent* event) + { + if (event->type() == QEvent::StyleChange) { + QMap::iterator itView = mView.find((QAbstractItemView*) object); + if (itView != mView.end()) { + mFontSizeHandlerBase->updateFontSize(itView.key(), itView.value().iconHeightFactor, itView.value().callback); + } + + QMap::iterator itWidget = mWidget.find((QWidget*) object); + if (itWidget != mWidget.end()) { + mFontSizeHandlerBase->updateFontSize(itWidget.key(), itWidget.value().callback); + } + } + + return false; + } + + void registerFontSize(QWidget *widget, std::function callback) + { + FontSizeHandlerWidgetData data; + data.callback = callback; + mWidget.insert(widget, data); + + QObject::connect(NotifyQt::getInstance(), &NotifyQt::settingsChanged, widget, [this, widget, callback]() { + mFontSizeHandlerBase->updateFontSize(widget, callback); + }); + + widget->installEventFilter(this); + QObject::connect(widget, &QObject::destroyed, this, [this, widget](QObject *object) { + if (widget == object) { + mWidget.remove(widget); + widget->removeEventFilter(this); + } + }); + + mFontSizeHandlerBase->updateFontSize(widget, callback, true); + } + + void registerFontSize(QAbstractItemView *view, float iconHeightFactor, std::function callback) + { + FontSizeHandlerViewData data; + data.iconHeightFactor = iconHeightFactor; + data.callback = callback; + mView.insert(view, data); + + QObject::connect(NotifyQt::getInstance(), &NotifyQt::settingsChanged, view, [this, view, iconHeightFactor, callback]() { + mFontSizeHandlerBase->updateFontSize(view, iconHeightFactor, callback); + }); + + view->installEventFilter(this); + QObject::connect(view, &QObject::destroyed, this, [this, view](QObject *object) { + if (view == object) { + mView.remove(view); + view->removeEventFilter(this); + } + }); + + mFontSizeHandlerBase->updateFontSize(view, iconHeightFactor, callback, true); + } + +private: + FontSizeHandlerBase *mFontSizeHandlerBase; + QMap mView; + QMap mWidget; +}; + +FontSizeHandlerBase::FontSizeHandlerBase(Type type) +{ + mType = type; + mObject = nullptr; +} + +FontSizeHandlerBase::~FontSizeHandlerBase() +{ + if (mObject) { + mObject->deleteLater(); + mObject = nullptr; + } +} + +int FontSizeHandlerBase::getFontSize() +{ + switch (mType) { + case FONT_SIZE: + return Settings->getFontSize(); + + case MESSAGE_FONT_SIZE: + return Settings->getMessageFontSize(); + } + + return 0; +} + +void FontSizeHandlerBase::registerFontSize(QWidget *widget, std::function callback) +{ + if (!widget) { + return; + } + + if (!mObject) { + mObject = new FontSizeHandlerObject(this); + } + + mObject->registerFontSize(widget, callback); +} + +void FontSizeHandlerBase::registerFontSize(QAbstractItemView *view, float iconHeightFactor, std::function callback) +{ + if (!view) { + return; + } + + if (!mObject) { + mObject = new FontSizeHandlerObject(this); + } + + mObject->registerFontSize(view, iconHeightFactor, callback); +} + +void FontSizeHandlerBase::updateFontSize(QWidget *widget, std::function callback, bool force) +{ + if (!widget) { + return; + } + + int fontSize = getFontSize(); + QFont font = widget->font(); + if (force || font.pointSize() != fontSize) { + font.setPointSize(fontSize); + widget->setFont(font); + + if (callback) { + callback(widget, fontSize); + } + } +} + +void FontSizeHandlerBase::updateFontSize(QAbstractItemView *view, float iconHeightFactor, std::function callback, bool force) +{ + if (!view) { + return; + } + + int fontSize = getFontSize(); + QFont font = view->font(); + if (force || font.pointSize() != fontSize) { + font.setPointSize(fontSize); + view->setFont(font); + + if (iconHeightFactor) { + QFontMetricsF fontMetrics(font); + int iconHeight = fontMetrics.height() * iconHeightFactor; + view->setIconSize(QSize(iconHeight, iconHeight)); + } + + if (callback) { + callback(view, fontSize); + } + } +} diff --git a/retroshare-gui/src/util/FontSizeHandler.h b/retroshare-gui/src/util/FontSizeHandler.h new file mode 100644 index 000000000..19859227d --- /dev/null +++ b/retroshare-gui/src/util/FontSizeHandler.h @@ -0,0 +1,71 @@ +/******************************************************************************* + * util/FontSizeHandler.h * + * * + * Copyright (C) 2025, Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + +#ifndef _FONTSIZEHANDLER_H +#define _FONTSIZEHANDLER_H + +class QWidget; +class QAbstractItemView; +class FontSizeHandlerObject; + +// Class to handle font size and message font size setting +class FontSizeHandlerBase +{ + friend class FontSizeHandlerObject; + +public: + virtual ~FontSizeHandlerBase(); + + int getFontSize(); + + void registerFontSize(QWidget *widget, std::function callback = nullptr); + void registerFontSize(QAbstractItemView *view, float iconHeightFactor = 0.0f, std::function callback = nullptr); + + void updateFontSize(QWidget *widget, std::function callback = nullptr, bool force = false); + void updateFontSize(QAbstractItemView *view, float iconHeightFactor, std::function callback, bool force = false); + +protected: + enum Type { + FONT_SIZE, + MESSAGE_FONT_SIZE + }; + + FontSizeHandlerBase(Type type); + +private: + Type mType; + FontSizeHandlerObject *mObject; +}; + +// Class to handle font size setting +class FontSizeHandler : public FontSizeHandlerBase +{ +public: + FontSizeHandler() : FontSizeHandlerBase(FONT_SIZE) {} +}; + +// Class to handle message font size setting +class MessageFontSizeHandler : public FontSizeHandlerBase +{ +public: + MessageFontSizeHandler() : FontSizeHandlerBase(MESSAGE_FONT_SIZE) {} +}; + +#endif // FONTSIZEHANDLER From 973246624f5032a0375163512e4250f87fe13523 Mon Sep 17 00:00:00 2001 From: thunder2 Date: Wed, 26 Mar 2025 01:24:14 +0100 Subject: [PATCH 47/84] Replaced font handling by FontSizeHandler and reenabled deactivated item delegates --- retroshare-gui/src/gui/ChatLobbyWidget.cpp | 25 +------ retroshare-gui/src/gui/ChatLobbyWidget.h | 6 +- .../src/gui/FileTransfer/SearchDialog.cpp | 45 +++---------- .../src/gui/FileTransfer/SearchDialog.h | 8 +-- retroshare-gui/src/gui/Identity/IdDialog.cpp | 67 +++++++++++-------- retroshare-gui/src/gui/Identity/IdDialog.h | 5 +- retroshare-gui/src/gui/MainWindow.cpp | 22 +----- retroshare-gui/src/gui/MainWindow.h | 4 +- .../src/gui/RSHumanReadableDelegate.h | 15 ++++- .../src/gui/chat/ChatLobbyDialog.cpp | 24 +------ retroshare-gui/src/gui/chat/ChatLobbyDialog.h | 6 +- .../src/gui/common/FriendSelectionWidget.cpp | 20 +----- .../src/gui/common/FriendSelectionWidget.h | 4 +- .../src/gui/common/GroupTreeWidget.cpp | 49 +++++--------- .../src/gui/common/GroupTreeWidget.h | 5 +- .../src/gui/common/NewFriendList.cpp | 27 +------- retroshare-gui/src/gui/common/NewFriendList.h | 5 +- .../src/gui/gxsforums/GxsForumModel.cpp | 18 +++-- .../src/gui/gxsforums/GxsForumModel.h | 3 + .../gui/gxsforums/GxsForumThreadWidget.cpp | 43 +++--------- .../src/gui/gxsforums/GxsForumThreadWidget.h | 6 +- .../src/gui/msgs/MessageComposer.cpp | 29 ++------ retroshare-gui/src/gui/msgs/MessageComposer.h | 5 +- retroshare-gui/src/gui/msgs/MessageModel.cpp | 14 +++- retroshare-gui/src/gui/msgs/MessageModel.h | 3 + .../src/gui/msgs/MessagesDialog.cpp | 52 ++++++-------- retroshare-gui/src/gui/msgs/MessagesDialog.h | 6 +- .../src/gui/settings/rsettingswin.cpp | 24 +------ .../src/gui/settings/rsettingswin.h | 5 +- retroshare-gui/src/util/RichTextEdit.cpp | 28 ++------ retroshare-gui/src/util/RichTextEdit.h | 6 +- 31 files changed, 196 insertions(+), 383 deletions(-) diff --git a/retroshare-gui/src/gui/ChatLobbyWidget.cpp b/retroshare-gui/src/gui/ChatLobbyWidget.cpp index 75894fea1..4caa97706 100644 --- a/retroshare-gui/src/gui/ChatLobbyWidget.cpp +++ b/retroshare-gui/src/gui/ChatLobbyWidget.cpp @@ -230,7 +230,8 @@ ChatLobbyWidget::ChatLobbyWidget(QWidget *parent, Qt::WindowFlags flags) int ltwH = misc::getFontSizeFactor("LobbyTreeWidget", 1.5).height(); ui.lobbyTreeWidget->setIconSize(QSize(ltwH,ltwH)); - updateFontSize(); + + mFontSizeHandler.registerFontSize(ui.lobbyTreeWidget); } ChatLobbyWidget::~ChatLobbyWidget() @@ -1369,25 +1370,3 @@ int ChatLobbyWidget::getNumColVisible() } return iNumColVis; } - -void ChatLobbyWidget::showEvent(QShowEvent *event) -{ - if (!event->spontaneous()) { - updateFontSize(); - } -} - -void ChatLobbyWidget::updateFontSize() -{ -#if defined(Q_OS_DARWIN) - int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 13).toInt(); -#else - int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 11).toInt(); -#endif - QFont newFont = ui.lobbyTreeWidget->font(); - if (newFont.pointSize() != customFontSize) { - newFont.setPointSize(customFontSize); - QFontMetricsF fontMetrics(newFont); - ui.lobbyTreeWidget->setFont(newFont); - } -} diff --git a/retroshare-gui/src/gui/ChatLobbyWidget.h b/retroshare-gui/src/gui/ChatLobbyWidget.h index ce451fe04..424780dac 100644 --- a/retroshare-gui/src/gui/ChatLobbyWidget.h +++ b/retroshare-gui/src/gui/ChatLobbyWidget.h @@ -25,6 +25,7 @@ #include "chat/ChatLobbyUserNotify.h" #include "gui/gxs/GxsIdChooser.h" +#include "util/FontSizeHandler.h" #include @@ -76,8 +77,6 @@ public: uint unreadCount(); - virtual void showEvent(QShowEvent *) ; - signals: void unreadCountChanged(uint unreadCount); @@ -114,7 +113,6 @@ private slots: void updateNotify(ChatLobbyId id, unsigned int count) ; void idChooserCurrentIndexChanged(int index); - void updateFontSize(); private: void autoSubscribeLobby(QTreeWidgetItem *item); @@ -149,6 +147,8 @@ private: QAbstractButton* myInviteYesButton; GxsIdChooser* myInviteIdChooser; + FontSizeHandler mFontSizeHandler; + /* UI - from Designer */ Ui::ChatLobbyWidget ui; }; diff --git a/retroshare-gui/src/gui/FileTransfer/SearchDialog.cpp b/retroshare-gui/src/gui/FileTransfer/SearchDialog.cpp index db11ab613..2d00b3e5b 100644 --- a/retroshare-gui/src/gui/FileTransfer/SearchDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/SearchDialog.cpp @@ -168,8 +168,8 @@ SearchDialog::SearchDialog(QWidget *parent) // To allow a proper sorting, be careful to pad at right with spaces. This // is achieved by using QString("%1").arg(number,15,10). // - //ui.searchResultWidget->setItemDelegateForColumn(SR_SIZE_COL, mSizeColumnDelegate=new RSHumanReadableSizeDelegate()) ; - //ui.searchResultWidget->setItemDelegateForColumn(SR_AGE_COL, mAgeColumnDelegate=new RSHumanReadableAgeDelegate()) ; + ui.searchResultWidget->setItemDelegateForColumn(SR_SIZE_COL, mSizeColumnDelegate=new RSHumanReadableSizeDelegate()) ; + ui.searchResultWidget->setItemDelegateForColumn(SR_AGE_COL, mAgeColumnDelegate=new RSHumanReadableAgeDelegate()) ; /* make it extended selection */ ui.searchResultWidget -> setSelectionMode(QAbstractItemView::ExtendedSelection); @@ -202,10 +202,6 @@ SearchDialog::SearchDialog(QWidget *parent) ui.searchResultWidget->sortItems(SR_NAME_COL, Qt::AscendingOrder); - QFontMetricsF fontMetrics(ui.searchResultWidget->font()); - int iconHeight = fontMetrics.height() * 1.4; - ui.searchResultWidget->setIconSize(QSize(iconHeight, iconHeight)); - /* Set initial size the splitter */ QList sizes; sizes << 250 << width(); // Qt calculates the right sizes @@ -240,6 +236,8 @@ SearchDialog::SearchDialog(QWidget *parent) RsQThreadUtils::postToObject([=](){ handleEvent_main_thread(event); }, this ); }, mEventHandlerId, RsEventType::FILE_TRANSFER ); + mFontSizeHandler.registerFontSize(ui.searchSummaryWidget); + mFontSizeHandler.registerFontSize(ui.searchResultWidget, 1.4f); } SearchDialog::~SearchDialog() @@ -256,8 +254,8 @@ SearchDialog::~SearchDialog() delete mSizeColumnDelegate; delete mAgeColumnDelegate; - //ui.searchResultWidget->setItemDelegateForColumn(SR_SIZE_COL, nullptr); - //ui.searchResultWidget->setItemDelegateForColumn(SR_AGE_COL, nullptr); + ui.searchResultWidget->setItemDelegateForColumn(SR_SIZE_COL, nullptr); + ui.searchResultWidget->setItemDelegateForColumn(SR_AGE_COL, nullptr); rsEvents->unregisterEventsHandler(mEventHandlerId); } @@ -1042,7 +1040,7 @@ void SearchDialog::insertDirectory(const QString &txt, qulonglong searchId, cons child->setText(SR_SOURCES_COL, QString::number(1)); child->setData(SR_SOURCES_COL, ROLE_SORT, 1); - child->setTextAlignment( SR_SOURCES_COL, Qt::AlignRight ); + child->setTextAlignment( SR_SOURCES_COL, Qt::AlignRight | Qt::AlignVCenter ); child->setText(SR_SEARCH_ID_COL, sid_hexa); setIconAndType(child, QString::fromUtf8(dir.name.c_str())); @@ -1067,7 +1065,7 @@ void SearchDialog::insertDirectory(const QString &txt, qulonglong searchId, cons child->setTextAlignment( SR_SIZE_COL, Qt::AlignRight ); child->setText(SR_SOURCES_COL, QString::number(1)); child->setData(SR_SOURCES_COL, ROLE_SORT, 1); - child->setTextAlignment( SR_SOURCES_COL, Qt::AlignRight ); + child->setTextAlignment( SR_SOURCES_COL, Qt::AlignRight | Qt::AlignVCenter ); child->setText(SR_SEARCH_ID_COL, sid_hexa); child->setText(SR_TYPE_COL, tr("Folder")); @@ -1136,7 +1134,7 @@ void SearchDialog::insertDirectory(const QString &txt, qulonglong searchId, cons child->setTextAlignment( SR_SIZE_COL, Qt::AlignRight ); child->setText(SR_SOURCES_COL, QString::number(1)); child->setData(SR_SOURCES_COL, ROLE_SORT, 1); - child->setTextAlignment( SR_SOURCES_COL, Qt::AlignRight ); + child->setTextAlignment( SR_SOURCES_COL, Qt::AlignRight | Qt::AlignVCenter ); child->setText(SR_SEARCH_ID_COL, sid_hexa); child->setText(SR_TYPE_COL, tr("Folder")); @@ -1351,7 +1349,7 @@ void SearchDialog::insertFile(qulonglong searchId, const FileDetail& file, int s item->setText(SR_SOURCES_COL,modifiedResult); item->setToolTip(SR_SOURCES_COL, tr("Obtained via ")+QString::fromStdString(rsPeers->getPeerName(file.id)) ); item->setData(SR_SOURCES_COL, ROLE_SORT, fltRes); - item->setTextAlignment( SR_SOURCES_COL, Qt::AlignRight ); + item->setTextAlignment( SR_SOURCES_COL, Qt::AlignRight | Qt::AlignVCenter ); item->setText(SR_SEARCH_ID_COL, sid_hexa); QColor foreground; @@ -1630,26 +1628,3 @@ void SearchDialog::openFolderSearch() } } } - -void SearchDialog::showEvent(QShowEvent *event) -{ - if (!event->spontaneous()) { - updateFontSize(); - } -} - -void SearchDialog::updateFontSize() -{ -#if defined(Q_OS_DARWIN) - int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 13).toInt(); -#else - int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 12).toInt(); -#endif - QFont newFont = ui.searchSummaryWidget->font(); - if (newFont.pointSize() != customFontSize) { - newFont.setPointSize(customFontSize); - QFontMetricsF fontMetrics(newFont); - ui.searchSummaryWidget->setFont(newFont); - ui.searchResultWidget->setFont(newFont); - } -} diff --git a/retroshare-gui/src/gui/FileTransfer/SearchDialog.h b/retroshare-gui/src/gui/FileTransfer/SearchDialog.h index aa5c4e2b4..0af53662b 100644 --- a/retroshare-gui/src/gui/FileTransfer/SearchDialog.h +++ b/retroshare-gui/src/gui/FileTransfer/SearchDialog.h @@ -25,6 +25,7 @@ #include "retroshare/rsevents.h" #include "ui_SearchDialog.h" #include "retroshare-gui/mainpage.h" +#include "util/FontSizeHandler.h" class AdvancedSearchDialog; class RSTreeWidgetItemCompareRole; @@ -66,9 +67,6 @@ public: void updateFiles(qulonglong request_id, const FileDetail& file) ; -protected: - virtual void showEvent(QShowEvent *) override; - private slots: /** Create the context popup menu and it's submenus */ @@ -119,8 +117,6 @@ private slots: void filterItems(); - void updateFontSize(); - private: /** render the results to the tree widget display */ void initSearchResult(const QString& txt,qulonglong searchId, int fileType, bool advanced) ; @@ -178,6 +174,8 @@ private: QAction *collViewAct; QAction *collOpenAct; + FontSizeHandler mFontSizeHandler; + /** Qt Designer generated object */ Ui::SearchDialog ui; diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index c69b71647..834fbbbe0 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -170,17 +170,14 @@ IdDialog::IdDialog(QWidget *parent) ownItem = new QTreeWidgetItem(); ownItem->setText(RSID_COL_NICKNAME, tr("My own identities")); - ownItem->setFont(RSID_COL_NICKNAME, ui->idTreeWidget->font()); ownItem->setData(RSID_COL_VOTES, Qt::DecorationRole,0xff); // this is in order to prevent displaying a reputaiton icon next to these items. allItem = new QTreeWidgetItem(); allItem->setText(RSID_COL_NICKNAME, tr("All")); - allItem->setFont(RSID_COL_NICKNAME, ui->idTreeWidget->font()); allItem->setData(RSID_COL_VOTES, Qt::DecorationRole,0xff); contactsItem = new QTreeWidgetItem(); contactsItem->setText(RSID_COL_NICKNAME, tr("My contacts")); - contactsItem->setFont(RSID_COL_NICKNAME, ui->idTreeWidget->font()); contactsItem->setData(RSID_COL_VOTES, Qt::DecorationRole,0xff); @@ -415,6 +412,45 @@ IdDialog::IdDialog(QWidget *parent) updateIdTimer.setSingleShot(true); connect(&updateIdTimer, SIGNAL(timeout()), this, SLOT(updateIdList())); + + mFontSizeHandler.registerFontSize(ui->idTreeWidget, 0, [this] (QAbstractItemView*, int fontSize) { + // Set new font size on all items + QTreeWidgetItemIterator it(ui->idTreeWidget); + while (*it) { + QTreeWidgetItem *item = *it; + if (item->parent()) { + QFont font = item->font(CIRCLEGROUP_CIRCLE_COL_GROUPNAME); + font.setPointSize(fontSize); + + item->setFont(CIRCLEGROUP_CIRCLE_COL_GROUPNAME, font); + item->setFont(CIRCLEGROUP_CIRCLE_COL_GROUPID, font); + item->setFont(CIRCLEGROUP_CIRCLE_COL_GROUPFLAGS, font); + } + ++it; + } + }); + mFontSizeHandler.registerFontSize(ui->treeWidget_membership, 0, [this] (QAbstractItemView*, int fontSize) { + // Set new font size on all items + QTreeWidgetItemIterator it(ui->treeWidget_membership); + while (*it) { + QTreeWidgetItem *item = *it; +#ifdef CIRCLE_MEMBERSHIP_CATEGORIES + if (item->parent()) + { +#endif + QFont font = item->font(CIRCLEGROUP_CIRCLE_COL_GROUPNAME); + font.setPointSize(fontSize); + + item->setFont(CIRCLEGROUP_CIRCLE_COL_GROUPNAME, font); + item->setFont(CIRCLEGROUP_CIRCLE_COL_GROUPID, font); + item->setFont(CIRCLEGROUP_CIRCLE_COL_GROUPFLAGS, font); + +#ifdef CIRCLE_MEMBERSHIP_CATEGORIES + } +#endif + ++it; + } + }); } void IdDialog::handleEvent_main_thread(std::shared_ptr event) @@ -664,7 +700,6 @@ void IdDialog::loadCircles(const std::list& groupInfo) { mExternalOtherCircleItem = new QTreeWidgetItem(); mExternalOtherCircleItem->setText(CIRCLEGROUP_CIRCLE_COL_GROUPNAME, tr("Other circles")); - mExternalOtherCircleItem->setFont(CIRCLEGROUP_CIRCLE_COL_GROUPNAME, ui->treeWidget_membership->font()); ui->treeWidget_membership->addTopLevelItem(mExternalOtherCircleItem); } @@ -672,7 +707,6 @@ void IdDialog::loadCircles(const std::list& groupInfo) { mExternalBelongingCircleItem = new QTreeWidgetItem(); mExternalBelongingCircleItem->setText(CIRCLEGROUP_CIRCLE_COL_GROUPNAME, tr("Circles I belong to")); - mExternalBelongingCircleItem->setFont(CIRCLEGROUP_CIRCLE_COL_GROUPNAME, ui->treeWidget_membership->font()); ui->treeWidget_membership->addTopLevelItem(mExternalBelongingCircleItem); } #endif @@ -956,10 +990,6 @@ void IdDialog::showEvent(QShowEvent *s) needUpdateCirclesOnNextShow = false; MainPage::showEvent(s); - - if (!s->spontaneous()) { - updateFontSize(); - } } void IdDialog::createExternalCircle() @@ -2603,22 +2633,3 @@ void IdDialog::restoreExpandedCircleItems(const std::vector& expanded_root restoreTopLevel(mExternalOtherCircleItem,1); restoreTopLevel(mMyCircleItem,2); } - -void IdDialog::updateFontSize() -{ -#if defined(Q_OS_DARWIN) - int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 13).toInt(); -#else - int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 11).toInt(); -#endif - QFont newFont = ui->idTreeWidget->font(); - if (newFont.pointSize() != customFontSize) { - newFont.setPointSize(customFontSize); - QFontMetricsF fontMetrics(newFont); - ui->idTreeWidget->setFont(newFont); - ui->treeWidget_membership->setFont(newFont); - contactsItem->setFont(RSID_COL_NICKNAME, newFont); - allItem->setFont(RSID_COL_NICKNAME, newFont); - ownItem->setFont(RSID_COL_NICKNAME, newFont); - } -} diff --git a/retroshare-gui/src/gui/Identity/IdDialog.h b/retroshare-gui/src/gui/Identity/IdDialog.h index ea6095d63..9b51cb933 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.h +++ b/retroshare-gui/src/gui/Identity/IdDialog.h @@ -22,6 +22,7 @@ #define IDENTITYDIALOG_H #include "gui/gxs/RsGxsUpdateBroadcastPage.h" +#include "util/FontSizeHandler.h" #include @@ -113,8 +114,6 @@ private slots: static QString inviteMessage(); void sendInvite(); - void updateFontSize(); - private: void processSettings(bool load); QString createUsageString(const RsIdentityUsage& u) const; @@ -159,6 +158,8 @@ private: bool needUpdateIdsOnNextShow; bool needUpdateCirclesOnNextShow; + FontSizeHandler mFontSizeHandler; + /* UI - Designer */ Ui::IdDialog *ui; }; diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index 69ba1494e..829050514 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -67,7 +67,6 @@ #include "notifyqt.h" #include "common/UserNotify.h" #include "gui/ServicePermissionDialog.h" -#include "gui/settings/rsharesettings.h" #ifdef UNFINISHED #include "unfinished/ApplicationWindow.h" @@ -361,6 +360,8 @@ MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags flags) connect(NotifyQt::getInstance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged())); settingsChanged(); + + mFontSizeHandler.registerFontSize(ui->listWidget, 1.5f); } /** Destructor. */ @@ -1642,8 +1643,6 @@ void MainWindow::settingsChanged() ui->toolBarAction->setIconSize(QSize(toolSize,toolSize)); int itemSize = Settings->getListItemIconSize(); ui->listWidget->setIconSize(QSize(itemSize,itemSize)); - - updateFontSize(); } void MainWindow::externalLinkActivated(const QUrl &url) @@ -1823,23 +1822,6 @@ void MainWindow::setCompactStatusMode(bool compact) //opModeStatus: TODO Show only ??? } -void MainWindow::updateFontSize() -{ -#if defined(Q_OS_DARWIN) - int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 13).toInt(); -#else - int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 11).toInt(); -#endif - QFont newFont = ui->listWidget->font(); - if (newFont.pointSize() != customFontSize) { - newFont.setPointSize(customFontSize); - QFontMetricsF fontMetrics(newFont); - int iconHeight = fontMetrics.height()*1.5; - ui->listWidget->setFont(newFont); - ui->listWidget->setIconSize(QSize(iconHeight, iconHeight)); - } -} - Gui_InputDialogReturn MainWindow::guiInputDialog(const QString& windowTitle, const QString& labelText, QLineEdit::EchoMode textEchoMode, bool modal) { diff --git a/retroshare-gui/src/gui/MainWindow.h b/retroshare-gui/src/gui/MainWindow.h index 56745d7d6..b435524f0 100644 --- a/retroshare-gui/src/gui/MainWindow.h +++ b/retroshare-gui/src/gui/MainWindow.h @@ -27,6 +27,7 @@ #include "gui/common/rwindow.h" #include "gui/common/RSComboBox.h" +#include "util/FontSizeHandler.h" namespace Ui { class MainWindow; @@ -307,7 +308,6 @@ private slots: void doQuit(); void updateTrayCombine(); - void updateFontSize(); private: void initStackedPage(); @@ -372,6 +372,8 @@ private: void setIdle(bool Idle); bool isIdle; + FontSizeHandler mFontSizeHandler; + Ui::MainWindow *ui ; }; diff --git a/retroshare-gui/src/gui/RSHumanReadableDelegate.h b/retroshare-gui/src/gui/RSHumanReadableDelegate.h index 18943c1dc..1b3995cd7 100644 --- a/retroshare-gui/src/gui/RSHumanReadableDelegate.h +++ b/retroshare-gui/src/gui/RSHumanReadableDelegate.h @@ -88,11 +88,16 @@ class RSHumanReadableAgeDelegate: public RSHumanReadableDelegate public: virtual void paint(QPainter *painter,const QStyleOptionViewItem & option, const QModelIndex & index) const { + painter->save(); QStyleOptionViewItem opt(option) ; setPainterOptions(painter,opt,index) ; - if(index.data().toLongLong() > 0) // no date is present. - painter->drawText(opt.rect, Qt::AlignCenter, misc::timeRelativeToNow(index.data().toLongLong())) ; + if(index.data().toLongLong() > 0) { // no date is present. + painter->setFont(opt.font); + painter->drawText(opt.rect, opt.displayAlignment, misc::timeRelativeToNow(index.data().toLongLong())) ; + } + + painter->restore(); } }; @@ -101,10 +106,14 @@ class RSHumanReadableSizeDelegate: public RSHumanReadableDelegate public: virtual void paint(QPainter *painter,const QStyleOptionViewItem & option, const QModelIndex & index) const { + painter->save(); QStyleOptionViewItem opt(option) ; setPainterOptions(painter,opt,index) ; - painter->drawText(opt.rect, Qt::AlignRight, misc::friendlyUnit(index.data().toULongLong())); + painter->setFont(opt.font); + painter->drawText(opt.rect, opt.displayAlignment, misc::friendlyUnit(index.data().toULongLong())); + + painter->restore(); } }; diff --git a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp index 56feb5f2f..dd4a128a4 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp +++ b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp @@ -208,6 +208,8 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi connect(unsubscribeButton, SIGNAL(clicked()), this , SLOT(leaveLobby())); getChatWidget()->addTitleBarWidget(unsubscribeButton) ; + + mFontSizeHandler.registerFontSize(ui.participantsList); } void ChatLobbyDialog::leaveLobby() @@ -1017,25 +1019,3 @@ void ChatLobbyDialog::setWindowed(bool windowed) if (chatLobbyPage)// If not defined, we are on autosubscribe loop of lobby widget constructor. So don't recall it. showDialog(RS_CHAT_FOCUS); } - -void ChatLobbyDialog::showEvent(QShowEvent *event) -{ - if (!event->spontaneous()) { - updateFontSize(); - } -} - -void ChatLobbyDialog::updateFontSize() -{ -#if defined(Q_OS_DARWIN) - int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 13).toInt(); -#else - int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 11).toInt(); -#endif - QFont newFont = ui.participantsList->font(); - if (newFont.pointSize() != customFontSize) { - newFont.setPointSize(customFontSize); - QFontMetricsF fontMetrics(newFont); - ui.participantsList->setFont(newFont); - } -} diff --git a/retroshare-gui/src/gui/chat/ChatLobbyDialog.h b/retroshare-gui/src/gui/chat/ChatLobbyDialog.h index 7df0f01b9..c3572cc4b 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyDialog.h +++ b/retroshare-gui/src/gui/chat/ChatLobbyDialog.h @@ -26,6 +26,7 @@ #include "gui/common/RSTreeWidgetItem.h" #include "ChatDialog.h" #include "PopupChatWindow.h" +#include "util/FontSizeHandler.h" // Q_DECLARE_METATYPE(RsGxsId) // Q_DECLARE_METATYPE(QList) @@ -54,8 +55,6 @@ public: inline bool isWindowed() const { return dynamic_cast(this->window()) != nullptr; } - virtual void showEvent(QShowEvent *) ; - public slots: void leaveLobby() ; private slots: @@ -66,7 +65,6 @@ private slots: void showInPeopleTab(); void toggleWindowed(){setWindowed(!isWindowed());} void setWindowed(bool windowed); - void updateFontSize(); signals: void typingEventReceived(ChatLobbyId) ; @@ -118,6 +116,8 @@ private: bool mWindowedSetted; PopupChatWindow* mPCWindow; + FontSizeHandler mFontSizeHandler; + /** Qt Designer generated object */ Ui::ChatLobbyDialog ui; diff --git a/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp b/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp index 2d42726c8..d9fc4b8dc 100644 --- a/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp +++ b/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp @@ -28,7 +28,6 @@ #include "gui/notifyqt.h" #include "gui/common/RSTreeWidgetItem.h" #include "gui/common/StatusDefs.h" -#include "gui/settings/rsharesettings.h" #include "util/qtthreadsutils.h" #include "gui/common/PeerDefs.h" #include "gui/common/GroupDefs.h" @@ -136,6 +135,8 @@ FriendSelectionWidget::FriendSelectionWidget(QWidget *parent) mEventHandlerId_peers = 0; rsEvents->registerEventsHandler( [this](std::shared_ptr event) { RsQThreadUtils::postToObject( [this,event]() { handleEvent_main_thread(event); }) ;}, mEventHandlerId_peers, RsEventType::PEER_CONNECTION ); + + mFontSizeHandler.registerFontSize(ui->friendList); } void FriendSelectionWidget::handleEvent_main_thread(std::shared_ptr event) @@ -224,8 +225,6 @@ void FriendSelectionWidget::showEvent(QShowEvent */*e*/) { if(gxsIds.empty()) loadIdentities(); - - updateFontSize(); } void FriendSelectionWidget::start() { @@ -1274,18 +1273,3 @@ bool FriendSelectionWidget::isFilterConnected() { return mActionFilterConnected->isChecked(); } - -void FriendSelectionWidget::updateFontSize() -{ -#if defined(Q_OS_DARWIN) - int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 13).toInt(); -#else - int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 11).toInt(); -#endif - QFont newFont = ui->friendList->font(); - if (newFont.pointSize() != customFontSize) { - newFont.setPointSize(customFontSize); - QFontMetricsF fontMetrics(newFont); - ui->friendList->setFont(newFont); - } -} diff --git a/retroshare-gui/src/gui/common/FriendSelectionWidget.h b/retroshare-gui/src/gui/common/FriendSelectionWidget.h index cde084ede..425e16774 100644 --- a/retroshare-gui/src/gui/common/FriendSelectionWidget.h +++ b/retroshare-gui/src/gui/common/FriendSelectionWidget.h @@ -26,6 +26,7 @@ #include "retroshare/rsevents.h" #include +#include "util/FontSizeHandler.h" namespace Ui { class FriendSelectionWidget; @@ -144,7 +145,6 @@ private slots: void itemChanged(QTreeWidgetItem *item, int column); void selectAll() ; void deselectAll() ; - void updateFontSize(); private: void fillList(); @@ -179,6 +179,8 @@ private: std::set mPreSelectedIds; // because loading of GxsIds is asynchroneous we keep selected Ids from the client in a list here and use it to initialize after loading them. + FontSizeHandler mFontSizeHandler; + RsEventsHandlerId_t mEventHandlerId_identities; RsEventsHandlerId_t mEventHandlerId_peers; }; diff --git a/retroshare-gui/src/gui/common/GroupTreeWidget.cpp b/retroshare-gui/src/gui/common/GroupTreeWidget.cpp index 3945037dd..43861c4c6 100644 --- a/retroshare-gui/src/gui/common/GroupTreeWidget.cpp +++ b/retroshare-gui/src/gui/common/GroupTreeWidget.cpp @@ -30,12 +30,10 @@ #include "gui/settings/rsharesettings.h" #include "util/QtVersion.h" #include "util/DateTime.h" -#include "gui/notifyqt.h" #include #include #include -#include #include @@ -69,8 +67,6 @@ GroupTreeWidget::GroupTreeWidget(QWidget *parent) : connect(ui->treeWidget, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(itemActivated(QTreeWidgetItem*,int))); } - updateFontSize(); - int H = QFontMetricsF(ui->treeWidget->font()).height() ; #if QT_VERSION < QT_VERSION_CHECK(5,11,0) int W = QFontMetricsF(ui->treeWidget->font()).width("_") ; @@ -152,7 +148,19 @@ GroupTreeWidget::GroupTreeWidget(QWidget *parent) : connect(ui->distantSearchLineEdit,SIGNAL(returnPressed()),this,SLOT(distantSearch())) ; - ui->treeWidget->setIconSize(QSize(H*1.8,H*1.8)); + mFontSizeHandler.registerFontSize(ui->treeWidget, 1.8f, [this] (QAbstractItemView*, int fontSize) { + // Set new font size on all items + QTreeWidgetItemIterator it(ui->treeWidget); + while (*it) { + QTreeWidgetItem *item = *it; + + QFont font = item->font(GTW_COLUMN_NAME); + font.setPointSize(fontSize); + item->setFont(GTW_COLUMN_NAME, font); + + ++it; + } + }); } GroupTreeWidget::~GroupTreeWidget() @@ -258,8 +266,8 @@ QTreeWidgetItem *GroupTreeWidget::addCategoryItem(const QString &name, const QIc RSTreeWidgetItem *item = new RSTreeWidgetItem(); ui->treeWidget->addTopLevelItem(item); // To get StyleSheet for Items - ui->treeWidget->style()->unpolish(ui->treeWidget); - ui->treeWidget->style()->polish(ui->treeWidget); +// ui->treeWidget->style()->unpolish(ui->treeWidget); +// ui->treeWidget->style()->polish(ui->treeWidget); item->setText(GTW_COLUMN_NAME, name); item->setData(GTW_COLUMN_DATA, ROLE_NAME, name); @@ -394,7 +402,7 @@ void GroupTreeWidget::fillGroupItems(QTreeWidgetItem *categoryItem, const QList< if (item == NULL) { item = new RSTreeWidgetItem(compareRole); item->setData(GTW_COLUMN_DATA, ROLE_ID, itemInfo.id); - item->setFont(GTW_COLUMN_DATA, ui->treeWidget->font()); + item->setFont(GTW_COLUMN_NAME, ui->treeWidget->font()); //static_cast(item)->setNoDataAsLast(true); //Uncomment this to sort data with QVariant() always at end. categoryItem->addChild(item); } @@ -671,28 +679,3 @@ void GroupTreeWidget::sort() { ui->treeWidget->resort(); } - -void GroupTreeWidget::showEvent(QShowEvent *event) -{ - if (!event->spontaneous()) { - updateFontSize(); - } -} - -void GroupTreeWidget::updateFontSize() -{ -#if defined(Q_OS_DARWIN) - int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 13).toInt(); -#else - int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 11).toInt(); -#endif - QFont newFont = ui->treeWidget->font(); - if (newFont.pointSize() != customFontSize) { - newFont.setPointSize(customFontSize); - QFontMetricsF fontMetrics(newFont); - ui->treeWidget->setFont(newFont); - int H = QFontMetricsF(ui->treeWidget->font()).height() ; - ui->treeWidget->setIconSize(QSize(H*1.8,H*1.8)); - } -} - diff --git a/retroshare-gui/src/gui/common/GroupTreeWidget.h b/retroshare-gui/src/gui/common/GroupTreeWidget.h index 7c95ec757..4aadb1c51 100644 --- a/retroshare-gui/src/gui/common/GroupTreeWidget.h +++ b/retroshare-gui/src/gui/common/GroupTreeWidget.h @@ -25,12 +25,12 @@ #include #include +#include "util/FontSizeHandler.h" class QToolButton; class RshareSettings; class RSTreeWidgetItemCompareRole; class RSTreeWidget; -class QShowEvent; #define GROUPTREEWIDGET_COLOR_STANDARD -1 #define GROUPTREEWIDGET_COLOR_CATEGORY 0 @@ -143,7 +143,6 @@ signals: protected: void changeEvent(QEvent *e); - virtual void showEvent(QShowEvent *) override; private slots: void customContextMenuRequested(const QPoint &pos); @@ -153,7 +152,6 @@ private slots: void distantSearch(); void sort(); - void updateFontSize(); private: void calculateScore(QTreeWidgetItem *item, const QString &filterText); @@ -166,6 +164,7 @@ private: // Compare role used for each column RSTreeWidgetItemCompareRole *compareRole; + FontSizeHandler mFontSizeHandler; Ui::GroupTreeWidget *ui; }; diff --git a/retroshare-gui/src/gui/common/NewFriendList.cpp b/retroshare-gui/src/gui/common/NewFriendList.cpp index 9e5039f76..38e141e86 100644 --- a/retroshare-gui/src/gui/common/NewFriendList.cpp +++ b/retroshare-gui/src/gui/common/NewFriendList.cpp @@ -55,7 +55,6 @@ #include "gui/connect/ConnectProgressDialog.h" #include "gui/common/ElidedLabel.h" #include "gui/notifyqt.h" -#include "gui/settings/rsharesettings.h" #include "NewFriendList.h" #include "ui_NewFriendList.h" @@ -274,6 +273,8 @@ NewFriendList::NewFriendList(QWidget */*parent*/) : /* RsAutoUpdatePage(5000,par connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterItems(QString)),Qt::QueuedConnection); connect(h, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(headerContextMenuRequested(QPoint))); + mFontSizeHandler.registerFontSize(ui->peerTreeWidget,1.5f); + // #ifdef RS_DIRECT_CHAT // connect(ui->peerTreeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, SLOT(chatNode())); // #endif @@ -1694,27 +1695,3 @@ void NewFriendList::expandGroup(const RsNodeGroupId& gid) QModelIndex index = mProxyModel->mapFromSource(mModel->getIndexOfGroup(gid)); ui->peerTreeWidget->setExpanded(index,true) ; } - -void NewFriendList::showEvent(QShowEvent *event) -{ - if (!event->spontaneous()) { - updateFontSize(); - } -} - -void NewFriendList::updateFontSize() -{ -#if defined(Q_OS_DARWIN) - int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 13).toInt(); -#else - int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 11).toInt(); -#endif - QFont newFont = ui->peerTreeWidget->font(); - if (newFont.pointSize() != customFontSize) { - newFont.setPointSize(customFontSize); - QFontMetricsF fontMetrics(newFont); - int iconHeight = fontMetrics.height()*1.5; - ui->peerTreeWidget->setFont(newFont); - ui->peerTreeWidget->setIconSize(QSize(iconHeight, iconHeight)); - } -} diff --git a/retroshare-gui/src/gui/common/NewFriendList.h b/retroshare-gui/src/gui/common/NewFriendList.h index 4679b7804..cf4c68e6f 100644 --- a/retroshare-gui/src/gui/common/NewFriendList.h +++ b/retroshare-gui/src/gui/common/NewFriendList.h @@ -29,6 +29,7 @@ #include "FriendListModel.h" #include "retroshare/rsstatus.h" +#include "util/FontSizeHandler.h" namespace Ui { class NewFriendList; @@ -54,8 +55,6 @@ public: explicit NewFriendList(QWidget *parent = 0); ~NewFriendList(); - virtual void showEvent(QShowEvent *) ; - // Add a tool button to the tool area void addToolButton(QToolButton *toolButton); void processSettings(bool load); @@ -97,7 +96,6 @@ private slots: void sortColumn(int col,Qt::SortOrder so); void itemExpanded(const QModelIndex&); void itemCollapsed(const QModelIndex&); - void updateFontSize(); protected: void changeEvent(QEvent *e); @@ -107,6 +105,7 @@ private: Ui::NewFriendList *ui; RsFriendListModel *mModel; QAction *mActionSortByState; + FontSizeHandler mFontSizeHandler; void applyWhileKeepingTree(std::function predicate); diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp index b68a50173..18f518749 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp @@ -46,6 +46,7 @@ RsGxsForumModel::RsGxsForumModel(QObject *parent) : QAbstractItemModel(parent), mUseChildTS(false),mFilteringEnabled(false),mTreeMode(TREE_MODE_TREE) { initEmptyHierarchy(mPosts); + mFont = QApplication::font(); } void RsGxsForumModel::preMods() @@ -399,7 +400,7 @@ QVariant RsGxsForumModel::data(const QModelIndex &index, int role) const if(role == Qt::FontRole) { - QFont font ; + QFont font = mFont; font.setBold( (fmpe.mPostFlags & ForumModelPostEntry::FLAG_POST_HAS_UNREAD_CHILDREN) || IS_MSG_UNREAD(fmpe.mMsgStatus)); return QVariant(font); } @@ -533,6 +534,15 @@ void RsGxsForumModel::setFilter(int column,const QStringList& strings,uint32_t& postMods(); } +void RsGxsForumModel::setFont(const QFont &font) +{ + preMods(); + + mFont = font; + + postMods(); +} + QVariant RsGxsForumModel::missingRole(const ForumModelPostEntry& fmpe,int /*column*/) const { if(fmpe.mPostFlags & ForumModelPostEntry::FLAG_POST_IS_MISSING) @@ -562,7 +572,7 @@ QVariant RsGxsForumModel::toolTipRole(const ForumModelPostEntry& fmpe,int column if(!GxsIdDetails::MakeIdDesc(fmpe.mAuthorId, true, str, icons, comment,GxsIdDetails::ICON_TYPE_AVATAR)) return QVariant(); - int S = QFontMetricsF(QApplication::font()).height(); + int S = QFontMetricsF(mFont).height(); QImage pix( (*icons.begin()).pixmap(QSize(5*S,5*S)).toImage()); QString embeddedImage; @@ -599,7 +609,7 @@ QVariant RsGxsForumModel::backgroundRole(const ForumModelPostEntry& fmpe,int /*c QVariant RsGxsForumModel::sizeHintRole(int col) const { - float factor = QFontMetricsF(QApplication::font()).height()/14.0f ; + float factor = QFontMetricsF(mFont).height()/14.0f ; switch(col) { @@ -650,7 +660,7 @@ QVariant RsGxsForumModel::displayRole(const ForumModelPostEntry& fmpe,int col) c case COLUMN_THREAD_TITLE: if(fmpe.mPostFlags & ForumModelPostEntry::FLAG_POST_IS_REDACTED) return QVariant(tr("[ ... Redacted message ... ]")); // else if(fmpe.mPostFlags & ForumModelPostEntry::FLAG_POST_IS_PINNED) -// return QVariant( QString("").arg(QFontMetricsF(QFont()).height()) +// return QVariant( QString("").arg(QFontMetricsF(mFont).height()) // + QString::fromUtf8(fmpe.mTitle.c_str())); else return QVariant(QString::fromUtf8(fmpe.mTitle.c_str())); diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumModel.h b/retroshare-gui/src/gui/gxsforums/GxsForumModel.h index c69013c3e..10248101f 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumModel.h +++ b/retroshare-gui/src/gui/gxsforums/GxsForumModel.h @@ -22,6 +22,7 @@ #include "retroshare/rsgxsifacetypes.h" #include #include +#include struct ForumModelPostEntry: public ForumPostEntry { @@ -76,6 +77,7 @@ public: QModelIndex getIndexOfMessage(const RsGxsMessageId& mid) const; static const QString FilterString ; + void setFont(const QFont &font); std::vector > getPostVersions(const RsGxsMessageId& mid) const; @@ -185,6 +187,7 @@ private: QColor mBackgroundColorPinned; QColor mBackgroundColorFiltered; + QFont mFont; friend class const_iterator; }; diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp index 8a0357303..fd293560f 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp @@ -250,7 +250,6 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget ui->setupUi(this); //setUpdateWhenInvisible(true); - updateFontSize(); //mUpdating = false; mUnreadCount = 0; @@ -308,10 +307,10 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget connect(ui->latestPostInThreadView_TB, SIGNAL(toggled(bool)), this, SLOT(toggleLstPostInThreadView(bool))); /* Set own item delegate */ - //RSElidedItemDelegate *itemDelegate = new RSElidedItemDelegate(this); - //itemDelegate->setSpacing(QSize(0, 2)); - //itemDelegate->setOnlyPlainText(true); - //ui->threadTreeWidget->setItemDelegate(itemDelegate); + RSElidedItemDelegate *itemDelegate = new RSElidedItemDelegate(this); + itemDelegate->setSpacing(QSize(0, 2)); + itemDelegate->setOnlyPlainText(true); + ui->threadTreeWidget->setItemDelegate(itemDelegate); /* add filter actions */ ui->filterLineEdit->addFilter(QIcon(), tr("Title"), RsGxsForumModel::COLUMN_THREAD_TITLE, tr("Search Title")); @@ -322,10 +321,6 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget float f = QFontMetricsF(font()).height()/14.0f ; - QFontMetricsF fontMetrics(ui->threadTreeWidget->font()); - int iconHeight = fontMetrics.height() * 1.4; - ui->threadTreeWidget->setIconSize(QSize(iconHeight, iconHeight)); - /* Set header resize modes and initial section sizes */ QHeaderView * ttheader = ui->threadTreeWidget->header () ; @@ -368,8 +363,6 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget blankPost(); - - ui->subscribeToolButton->setToolTip(tr( "

Subscribing to the forum will gather \ available posts from your subscribed friends, and make the \ forum visible to all other friends.

Afterwards you can unsubscribe from the context menu of the forum list at left.

")); @@ -383,6 +376,10 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget [this](std::shared_ptr event) { RsQThreadUtils::postToObject([=](){ handleEvent_main_thread(event); }, this ); }, mEventHandlerId, RsEventType::GXS_FORUMS ); + + mFontSizeHandler.registerFontSize(ui->threadTreeWidget, 1.4f, [this](QAbstractItemView *view, int) { + mThreadModel->setFont(view->font()); + }); } void GxsForumThreadWidget::handleEvent_main_thread(std::shared_ptr event) @@ -2102,27 +2099,3 @@ void GxsForumThreadWidget::showAuthorInPeople(const RsGxsForumMsg& msg) MainWindow::showWindow(MainWindow::People); idDialog->navigate(RsGxsId(msg.mMeta.mAuthorId)); } - -void GxsForumThreadWidget::showEvent(QShowEvent *event) -{ - if (!event->spontaneous()) { - updateFontSize(); - } -} - -void GxsForumThreadWidget::updateFontSize() -{ -#if defined(Q_OS_DARWIN) - int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 13).toInt(); -#else - int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 12).toInt(); -#endif - QFont newFont = ui->threadTreeWidget->font(); - if (newFont.pointSize() != customFontSize) { - newFont.setPointSize(customFontSize); - QFontMetricsF fontMetrics(newFont); - ui->threadTreeWidget->setFont(newFont); - int iconHeight = fontMetrics.height() * 1.4; - ui->threadTreeWidget->setIconSize(QSize(iconHeight, iconHeight)); - } -} diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h index b867c2399..8e6b1c01b 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h @@ -26,6 +26,7 @@ #include "gui/gxs/GxsMessageFrameWidget.h" #include #include "gui/gxs/GxsIdDetails.h" +#include "util/FontSizeHandler.h" class QSortFilterProxyModel; class QTreeWidgetItem; @@ -97,7 +98,6 @@ public: protected: //bool eventFilter(QObject *obj, QEvent *ev); //void changeEvent(QEvent *e); - virtual void showEvent(QShowEvent *) override; /* RsGxsUpdateBroadcastWidget */ virtual void updateDisplay(bool complete); @@ -161,8 +161,6 @@ private slots: void filterColumnChanged(int column); void filterItems(const QString &text); - void updateFontSize(); - #if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0) void expandSubtree(); #endif @@ -237,6 +235,8 @@ private: QSortFilterProxyModel *mThreadProxyModel; QList mSavedExpandedMessages; + FontSizeHandler mFontSizeHandler; + Ui::GxsForumThreadWidget *ui; RsEventsHandlerId_t mEventHandlerId; }; diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.cpp b/retroshare-gui/src/gui/msgs/MessageComposer.cpp index bbca45bd3..0ee408685 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.cpp +++ b/retroshare-gui/src/gui/msgs/MessageComposer.cpp @@ -299,7 +299,7 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WindowFlags flags) QFontDatabase db; foreach(int size, db.standardSizes()) - ui.comboSize->addItem(QString::number(size)); + ui.comboSize->addItem(QString::number(size), size); QStyleOptionComboBox opt; QSize sh; opt.initFrom(ui.comboSize); @@ -408,6 +408,10 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WindowFlags flags) ui.hashBox->setDropWidget(this); ui.hashBox->setAutoHide(true); + mMessageFontSizeHandler.registerFontSize(ui.msgText, [this, db] (QWidget*, int fontSize) { + ui.comboSize->setCurrentIndex(ui.comboSize->findData(fontSize)); + }); + #if QT_VERSION < 0x040700 // embedded images are not supported before QT 4.7.0 ui.imagebtn->setVisible(false); @@ -2933,26 +2937,3 @@ void MessageComposer::checkLength() ui.actionSend->setEnabled(true); } } - -void MessageComposer::showEvent(QShowEvent *event) -{ - if (!event->spontaneous()) { - updateFontSize(); - } -} - -void MessageComposer::updateFontSize() -{ -#if defined(Q_OS_DARWIN) - int customFontSize = Settings->valueFromGroup("Messages", "MinimumFontSize", 13).toInt(); -#else - int customFontSize = Settings->valueFromGroup("Messages", "MinimumFontSize", 12).toInt(); -#endif - QFont newFont = ui.msgText->font(); - if (newFont.pointSize() != customFontSize) { - newFont.setPointSize(customFontSize); - QFontMetricsF fontMetrics(newFont); - ui.msgText->setFont(newFont); - ui.comboSize->setCurrentIndex(ui.comboSize->findText(QString::number(newFont.pointSize()))); - } -} \ No newline at end of file diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.h b/retroshare-gui/src/gui/msgs/MessageComposer.h index d89aecda5..27bf28458 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.h +++ b/retroshare-gui/src/gui/msgs/MessageComposer.h @@ -28,6 +28,7 @@ #include "ui_MessageComposer.h" #include "gui/msgs/MessageInterface.h" +#include "util/FontSizeHandler.h" class QAction; struct RsIdentityDetails; @@ -95,7 +96,6 @@ public slots: protected: void closeEvent (QCloseEvent * event); bool eventFilter(QObject *obj, QEvent *ev); - virtual void showEvent(QShowEvent *) ; private slots: /* toggle Contacts DockWidget */ @@ -170,7 +170,6 @@ private slots: static QString inviteMessage(); void checkLength(); - void updateFontSize(); private: static QString buildReplyHeader(const MessageInfo &msgInfo); @@ -269,6 +268,8 @@ private: bool has_gxs; bool mAlreadySent; // prevents a Qt bug that calls the same action twice. + MessageFontSizeHandler mMessageFontSizeHandler; + /** Qt Designer generated object */ Ui::MessageComposer ui; diff --git a/retroshare-gui/src/gui/msgs/MessageModel.cpp b/retroshare-gui/src/gui/msgs/MessageModel.cpp index 14b15479c..dc2f16c7c 100644 --- a/retroshare-gui/src/gui/msgs/MessageModel.cpp +++ b/retroshare-gui/src/gui/msgs/MessageModel.cpp @@ -57,6 +57,7 @@ RsMessageModel::RsMessageModel(QObject *parent) mQuickViewFilter = QUICK_VIEW_ALL; mFilterType = FILTER_TYPE_NONE; mFilterStrings.clear(); + mFont = QApplication::font(); } void RsMessageModel::preMods() @@ -248,7 +249,7 @@ QVariant RsMessageModel::data(const QModelIndex &index, int role) const if(role == Qt::FontRole) { - QFont font ; + QFont font = mFont; font.setBold(fmpe.msgflags & (RS_MSG_NEW | RS_MSG_UNREAD_BY_USER)); return QVariant(font); @@ -404,6 +405,15 @@ void RsMessageModel::setFilter(FilterType filter_type, const QStringList& string emit dataChanged(createIndex(0,0),createIndex(rowCount()-1,RsMessageModel::columnCount()-1)); } +void RsMessageModel::setFont(const QFont &font) +{ + mFont = font; + + if (rowCount() > 0) { + emit dataChanged(createIndex(0,0), createIndex(rowCount() - 1, RsMessageModel::columnCount() - 1)); + } +} + QVariant RsMessageModel::toolTipRole(const Rs::Msgs::MsgInfoSummary& fmpe,int column) const { if(column == COLUMN_THREAD_AUTHOR || column == COLUMN_THREAD_TO) @@ -440,7 +450,7 @@ QVariant RsMessageModel::backgroundRole(const Rs::Msgs::MsgInfoSummary &/*fmpe*/ QVariant RsMessageModel::sizeHintRole(int col) const { - float factor = QFontMetricsF(QApplication::font()).height()/14.0f ; + float factor = QFontMetricsF(mFont).height()/14.0f ; switch(col) { diff --git a/retroshare-gui/src/gui/msgs/MessageModel.h b/retroshare-gui/src/gui/msgs/MessageModel.h index d23b21f86..3bbd6ee31 100644 --- a/retroshare-gui/src/gui/msgs/MessageModel.h +++ b/retroshare-gui/src/gui/msgs/MessageModel.h @@ -22,6 +22,7 @@ #include #include +#include #include "retroshare/rsmsgs.h" @@ -104,6 +105,7 @@ public: void setQuickViewFilter(QuickViewFilter fn) ; void setFilter(FilterType filter_type, const QStringList& strings) ; + void setFont(const QFont &font); int rowCount(const QModelIndex& parent = QModelIndex()) const override; int columnCount(const QModelIndex &parent = QModelIndex()) const override; @@ -184,6 +186,7 @@ private: QuickViewFilter mQuickViewFilter ; QStringList mFilterStrings; FilterType mFilterType; + QFont mFont; std::vector mMessages; std::map mMessagesMap; diff --git a/retroshare-gui/src/gui/msgs/MessagesDialog.cpp b/retroshare-gui/src/gui/msgs/MessagesDialog.cpp index 196012070..8f573c6b7 100644 --- a/retroshare-gui/src/gui/msgs/MessagesDialog.cpp +++ b/retroshare-gui/src/gui/msgs/MessagesDialog.cpp @@ -163,9 +163,9 @@ MessagesDialog::MessagesDialog(QWidget *parent) changeBox(0); // set to inbox - //RSElidedItemDelegate *itemDelegate = new RSElidedItemDelegate(this); - //itemDelegate->setSpacing(QSize(0, 2)); - //ui.messageTreeWidget->setItemDelegateForColumn(RsMessageModel::COLUMN_THREAD_SUBJECT,itemDelegate); + RSElidedItemDelegate *itemDelegate = new RSElidedItemDelegate(this); + itemDelegate->setSpacing(QSize(0, 2)); + ui.messageTreeWidget->setItemDelegateForColumn(RsMessageModel::COLUMN_THREAD_SUBJECT,itemDelegate); ui.messageTreeWidget->setItemDelegateForColumn(RsMessageModel::COLUMN_THREAD_AUTHOR,new GxsIdTreeItemDelegate()) ; ui.messageTreeWidget->setItemDelegateForColumn(RsMessageModel::COLUMN_THREAD_TO,new GxsIdTreeItemDelegate()) ; @@ -306,6 +306,23 @@ MessagesDialog::MessagesDialog(QWidget *parent) mTagEventHandlerId = 0; rsEvents->registerEventsHandler( [this](std::shared_ptr event) { RsQThreadUtils::postToObject( [this,event]() { handleTagEvent_main_thread(event); }); }, mEventHandlerId, RsEventType::MAIL_TAG ); + + mFontSizeHandler.registerFontSize(ui.listWidget, 1.5f, [this] (QAbstractItemView*, int fontSize) { + // Set new font size on all items + QList rows; + rows << ROW_INBOX << ROW_OUTBOX << ROW_DRAFTBOX; + + foreach (int row, rows) { + QListWidgetItem *item = ui.listWidget->item(row); + QFont font = item->font(); + font.setPointSize(fontSize); + item->setFont(font); + } + }); + mFontSizeHandler.registerFontSize(ui.quickViewWidget, 1.5f); + mFontSizeHandler.registerFontSize(ui.messageTreeWidget, 1.5f, [this] (QAbstractItemView *view, int) { + mMessageModel->setFont(view->font()); + }); } void MessagesDialog::handleEvent_main_thread(std::shared_ptr event) @@ -1660,32 +1677,3 @@ void MessagesDialog::updateInterface() ui.tabWidget->setTabIcon(0, FilesDefs::getIconFromQtResourcePath(":/icons/warning_yellow_128.png")); } } - -void MessagesDialog::showEvent(QShowEvent *event) -{ - if (!event->spontaneous()) { - updateFontSize(); - } -} - -void MessagesDialog::updateFontSize() -{ -#if defined(Q_OS_DARWIN) - int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 13).toInt(); -#else - int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 11).toInt(); -#endif - QFont newFont = ui.listWidget->font(); - if (newFont.pointSize() != customFontSize) { - newFont.setPointSize(customFontSize); - QFontMetricsF fontMetrics(newFont); - int iconHeight = fontMetrics.height()*1.5; - ui.listWidget->setFont(newFont); - ui.quickViewWidget->setFont(newFont); - ui.messageTreeWidget->setFont(newFont); - ui.listWidget->setIconSize(QSize(iconHeight, iconHeight)); - ui.quickViewWidget->setIconSize(QSize(iconHeight, iconHeight)); - ui.messageTreeWidget->setIconSize(QSize(iconHeight, iconHeight)); - } -} - diff --git a/retroshare-gui/src/gui/msgs/MessagesDialog.h b/retroshare-gui/src/gui/msgs/MessagesDialog.h index 753f910dd..7f9573f81 100644 --- a/retroshare-gui/src/gui/msgs/MessagesDialog.h +++ b/retroshare-gui/src/gui/msgs/MessagesDialog.h @@ -25,6 +25,7 @@ #include #include +#include "util/FontSizeHandler.h" #include "ui_MessagesDialog.h" @@ -54,7 +55,6 @@ public: // replaced by shortcut // virtual void keyPressEvent(QKeyEvent *) ; - virtual void showEvent(QShowEvent *) ; QColor textColorInbox() const { return mTextColorInbox; } @@ -111,8 +111,6 @@ private slots: void tabChanged(int tab); void tabCloseRequested(int tab); - void updateFontSize(); - private: void handleEvent_main_thread(std::shared_ptr event); void handleTagEvent_main_thread(std::shared_ptr event); @@ -169,6 +167,8 @@ private: RsEventsHandlerId_t mEventHandlerId; RsEventsHandlerId_t mTagEventHandlerId; + + FontSizeHandler mFontSizeHandler; }; #endif diff --git a/retroshare-gui/src/gui/settings/rsettingswin.cpp b/retroshare-gui/src/gui/settings/rsettingswin.cpp index 663cc7d03..a9fab8895 100644 --- a/retroshare-gui/src/gui/settings/rsettingswin.cpp +++ b/retroshare-gui/src/gui/settings/rsettingswin.cpp @@ -93,6 +93,8 @@ SettingsPage::SettingsPage(QWidget *parent) connect(ui.listWidget, SIGNAL(currentRowChanged(int)), this, SLOT(setNewPage(int))); connect(this, SIGNAL(finished(int)), this, SLOT(dialogFinished(int))); + + mFontSizeHandler.registerFontSize(ui.listWidget); } SettingsPage::~SettingsPage() @@ -239,25 +241,3 @@ void SettingsPage::notifySettingsChanged() if (NotifyQt::getInstance()) NotifyQt::getInstance()->notifySettingsChanged(); } - -void SettingsPage::showEvent(QShowEvent *event) -{ - if (!event->spontaneous()) { - updateFontSize(); - } -} - -void SettingsPage::updateFontSize() -{ -#if defined(Q_OS_DARWIN) - int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 13).toInt(); -#else - int customFontSize = Settings->valueFromGroup("File", "MinimumFontSize", 11).toInt(); -#endif - QFont newFont = ui.listWidget->font(); - if (newFont.pointSize() != customFontSize) { - newFont.setPointSize(customFontSize); - QFontMetricsF fontMetrics(newFont); - ui.listWidget->setFont(newFont); - } -} diff --git a/retroshare-gui/src/gui/settings/rsettingswin.h b/retroshare-gui/src/gui/settings/rsettingswin.h index 64d8ebb52..47eb33e4b 100755 --- a/retroshare-gui/src/gui/settings/rsettingswin.h +++ b/retroshare-gui/src/gui/settings/rsettingswin.h @@ -27,6 +27,7 @@ #include #include "ui_settingsw.h" +#include "util/FontSizeHandler.h" class FloatingHelpBrowser; @@ -53,7 +54,6 @@ protected: ~SettingsPage(); void addPage(ConfigPage*) ; - virtual void showEvent(QShowEvent *) override; public slots: //! Go to a specific part of the control panel. @@ -68,12 +68,13 @@ private slots: private: void initStackedWidget(); - void updateFontSize(); private: FloatingHelpBrowser *mHelpBrowser; static int lastPage; + FontSizeHandler mFontSizeHandler; + /* UI - from Designer */ Ui::Settings ui; }; diff --git a/retroshare-gui/src/util/RichTextEdit.cpp b/retroshare-gui/src/util/RichTextEdit.cpp index 9d88d989f..020b13db9 100644 --- a/retroshare-gui/src/util/RichTextEdit.cpp +++ b/retroshare-gui/src/util/RichTextEdit.cpp @@ -167,7 +167,7 @@ RichTextEdit::RichTextEdit(QWidget *parent) : QWidget(parent) { QFontDatabase db; foreach(int size, db.standardSizes()) - f_fontsize->addItem(QString::number(size)); + f_fontsize->addItem(QString::number(size), size); connect(f_fontsize, SIGNAL(activated(QString)), this, SLOT(textSize(QString))); @@ -195,6 +195,9 @@ RichTextEdit::RichTextEdit(QWidget *parent) : QWidget(parent) { // check message length connect(f_textedit, SIGNAL(textChanged()), this, SLOT(checkLength())); + mMessageFontSizeHandler.registerFontSize(f_textedit, [this] (QWidget*, int fontSize) { + f_fontsize->setCurrentIndex(f_fontsize->findData(fontSize)); + }); } @@ -614,26 +617,3 @@ void RichTextEdit::checkLength(){ void RichTextEdit::setPlaceHolderTextPosted() { f_textedit->setPlaceholderText(tr("Text (optional)")); } - -void RichTextEdit::showEvent(QShowEvent *event) -{ - if (!event->spontaneous()) { - updateFontSize(); - } -} - -void RichTextEdit::updateFontSize() -{ -#if defined(Q_OS_DARWIN) - int customFontSize = Settings->valueFromGroup("Messages", "MinimumFontSize", 13).toInt(); -#else - int customFontSize = Settings->valueFromGroup("Messages", "MinimumFontSize", 12).toInt(); -#endif - QFont newFont = f_textedit->font(); - if (newFont.pointSize() != customFontSize) { - newFont.setPointSize(customFontSize); - QFontMetricsF fontMetrics(newFont); - f_textedit->setFont(newFont); - f_fontsize->setCurrentIndex(f_fontsize->findText(QString::number(newFont.pointSize()))); - } -} diff --git a/retroshare-gui/src/util/RichTextEdit.h b/retroshare-gui/src/util/RichTextEdit.h index a621a8514..6e4869838 100644 --- a/retroshare-gui/src/util/RichTextEdit.h +++ b/retroshare-gui/src/util/RichTextEdit.h @@ -23,6 +23,7 @@ #include #include "ui_RichTextEdit.h" +#include "util/FontSizeHandler.h" /** * @Brief A simple rich-text editor @@ -69,7 +70,6 @@ signals: void insertImage(); void textSource(); void checkLength(); - void updateFontSize(); protected: void mergeFormatOnWordOrSelection(const QTextCharFormat &format); @@ -79,7 +79,6 @@ signals: void list(bool checked, QTextListFormat::Style style); void indent(int delta); void focusInEvent(QFocusEvent *event); - virtual void showEvent(QShowEvent *); QStringList m_paragraphItems; int m_fontsize_h1; @@ -95,6 +94,9 @@ signals: ParagraphMonospace }; QPointer m_lastBlockList; + +private: + MessageFontSizeHandler mMessageFontSizeHandler; }; #endif From c8f71072b060cdcc1e3f3e1331e9a35c354ac3a0 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 29 Mar 2025 15:37:18 +0100 Subject: [PATCH 48/84] removed test line --- retroshare-gui/src/gui/Identity/IdentityListModel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp index f5d99545c..679514325 100644 --- a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp +++ b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp @@ -166,7 +166,7 @@ int RsIdentityListModel::columnCount(const QModelIndex &/*parent*/) const bool RsIdentityListModel::hasChildren(const QModelIndex &parent) const { if(!parent.isValid()) - return false; + return true; EntryIndex parent_index ; convertInternalIdToIndex(parent.internalId(),parent_index); From 59d659285551a36ddf63b1ea1e4ce05f0e84cac7 Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 31 Mar 2025 21:29:43 +0200 Subject: [PATCH 49/84] fixed show in people tab --- retroshare-gui/src/gui/Identity/IdentityListModel.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp index 679514325..945b7359d 100644 --- a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp +++ b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp @@ -240,9 +240,9 @@ uint32_t RsIdentityListModel::EntryIndex::parentRow() const switch(type) { default: - case ENTRY_TYPE_TOP_LEVEL: return 0; - case ENTRY_TYPE_CATEGORY : return category_index; - case ENTRY_TYPE_IDENTITY : return identity_index; + case ENTRY_TYPE_TOP_LEVEL: return -1; + case ENTRY_TYPE_CATEGORY : return -1; + case ENTRY_TYPE_IDENTITY : return category_index; } } From c9d5a9ba30b2ef68815f8931c22f8cf33eaf2c39 Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 31 Mar 2025 22:09:55 +0200 Subject: [PATCH 50/84] fixed preserving of selection and expanded items --- retroshare-gui/src/gui/Identity/IdDialog.cpp | 39 ++++++++++++++------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index 56958e932..d0c81c211 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -1359,16 +1359,20 @@ void IdDialog::filterToggled(const bool &value) } } -void IdDialog::updateSelection(const QItemSelection& new_sel,const QItemSelection& old_sel) +void IdDialog::updateSelection(const QItemSelection& /* new_sel */,const QItemSelection& /* old_sel */) { +#ifdef DEBUG_ID_DIALOG std::cerr << "Got selectionChanged signal. Old selection is: " << std::endl; for(auto i:old_sel.indexes()) std::cerr << " " << i << std::endl; std::cerr << "Got selectionChanged signal. New selection is: " << std::endl; for(auto i:new_sel.indexes()) std::cerr << " " << i << std::endl; +#endif auto id = RsGxsGroupId(getSelectedIdentity()); +#ifdef DEBUG_ID_DIALOG std::cerr << "updating selection to id " << id << std::endl; +#endif if(id != mId) { mId = id; @@ -1393,7 +1397,6 @@ void IdDialog::updateIdListRequest() void IdDialog::updateIdList() { - std::cerr << "Updating identity list in widget." << std::endl; //print_stacktrace(); RsThread::async([this]() @@ -1409,8 +1412,10 @@ void IdDialog::updateIdList() RsQThreadUtils::postToObject( [ids,this]() { + std::cerr << "Updating identity list in widget." << std::endl; applyWhileKeepingTree( [ids,this]() { + std::cerr << "setting new identity in model." << std::endl; mIdListModel->setIdentities(*ids) ; delete ids; @@ -1595,9 +1600,6 @@ void IdDialog::updateIdentity() * thread, for example to update the data model with new information * after a blocking call to RetroShare API complete */ - std::set expanded_indexes; - std::set > selected_indices; - loadIdentity(group); }, this ); @@ -2039,7 +2041,9 @@ std::list IdDialog::getSelectedIdentities() const QModelIndexList selectedIndexes_proxy = ui->idTreeWidget->selectionModel()->selectedIndexes(); std::list res; +#ifdef DEBUG_ID_DIALOG std::cerr << "Parsing selected index list: " << std::endl; +#endif for(auto indx_proxy:selectedIndexes_proxy) { RsGxsId id; @@ -2049,7 +2053,9 @@ std::list IdDialog::getSelectedIdentities() const auto indx = mProxyModel->mapToSource(indx_proxy); auto id = mIdListModel->getIdentity(indx); +#ifdef DEBUG_ID_DIALOG std::cerr << " indx: " << indx_proxy << " original indx: " << indx << " identity: " << id << std::endl; +#endif if( !id.isNull() ) res.push_back(id); @@ -2063,7 +2069,9 @@ RsGxsId IdDialog::getSelectedIdentity() const { auto lst = getSelectedIdentities(); +#ifdef DEBUG_ID_DIALOG std::cerr << "Selected identities has size " << lst.size() << std::endl; +#endif if(lst.size() != 1) return RsGxsId(); @@ -2584,7 +2592,7 @@ void IdDialog::applyWhileKeepingTree(std::function predicate) #ifdef DEBUG_NEW_FRIEND_LIST std::cerr << "After collecting selection, selected paths is: \"" << selected.toStdString() << "\", " ; std::cerr << "expanded paths are: " << std::endl; - for(auto path:expanded_indexes) + for(auto path:expanded) std::cerr << " \"" << path.toStdString() << "\"" << std::endl; std::cerr << "Current sort column is: " << mLastSortColumn << " and order is " << mLastSortOrder << std::endl; #endif @@ -2609,12 +2617,10 @@ void IdDialog::applyWhileKeepingTree(std::function predicate) #endif #endif mProxyModel->setSourceModel(nullptr); - predicate(); + mProxyModel->setSourceModel(mIdListModel); restoreExpandedPathsAndSelection_idTreeView(expanded,selected); - - mProxyModel->setSourceModel(mIdListModel); // restore hidden columns for(uint32_t i=0;i& e void IdDialog::restoreExpandedPathsAndSelection_idTreeView(const std::set& expanded, const std::set& selected) { +#ifdef DEBUG_ID_DIALOG + std::cerr << "Restoring expanded paths and selection..." << std::endl; + std::cerr << " expanded: " << expanded.size() << " items" << std::endl; + std::cerr << " selected: " << selected.size() << " items" << std::endl; +#endif ui->idTreeWidget->blockSignals(true) ; ui->idTreeWidget->selectionModel()->blockSignals(true) ; @@ -2682,7 +2693,7 @@ void IdDialog::recursSaveExpandedItems_idTreeView(const QModelIndex& proxy_index if(ui->idTreeWidget->selectionModel()->isSelected(proxy_index)) { -#ifndef DEBUG_ID_DIALOG +#ifdef DEBUG_ID_DIALOG std::cerr << "Adding selected path "; for(auto L:local_path) std::cerr << "\"" << L.toStdString() << "\" " ; std::cerr << std::endl; #endif @@ -2695,6 +2706,10 @@ void IdDialog::recursRestoreExpandedItems_idTreeView(const QModelIndex& proxy_in QStringList local_path = parent_path; local_path.push_back(mIdListModel->indexIdentifier(mProxyModel->mapToSource(proxy_index))); +#ifdef DEBUG_ID_DIALOG + std::cerr << "Local path = " ; for(auto L:local_path) std::cerr << "\"" << L.toStdString() << "\" " ; std::cerr << std::endl; +#endif + if(expanded.find(local_path) != expanded.end()) { #ifdef DEBUG_ID_DIALOG @@ -2710,11 +2725,11 @@ void IdDialog::recursRestoreExpandedItems_idTreeView(const QModelIndex& proxy_in if(selected.find(local_path) != selected.end()) { -#ifndef DEBUG_ID_DIALOG +#ifdef DEBUG_ID_DIALOG std::cerr << "Restoring selected path "; for(auto L:local_path) std::cerr << "\"" << L.toStdString() << "\" " ; std::cerr << std::endl; #endif - ui->idTreeWidget->selectionModel()->select(proxy_index, QItemSelectionModel::Select | QItemSelectionModel::Rows); + ui->idTreeWidget->selectionModel()->select(proxy_index, QItemSelectionModel::Current|QItemSelectionModel::Select | QItemSelectionModel::Rows); } } From 85f411463bec28a86a34b4b2b6a85d0621b848d9 Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 1 Apr 2025 20:39:44 +0200 Subject: [PATCH 51/84] fixed display of total number of identities --- retroshare-gui/src/gui/Identity/IdDialog.cpp | 1 + retroshare-gui/src/gui/Identity/IdentityListModel.h | 2 ++ 2 files changed, 3 insertions(+) diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index d0c81c211..eccfd7f9a 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -1419,6 +1419,7 @@ void IdDialog::updateIdList() mIdListModel->setIdentities(*ids) ; delete ids; + ui->label_count->setText("("+QString::number(mIdListModel->count())+")"); }); }); }); diff --git a/retroshare-gui/src/gui/Identity/IdentityListModel.h b/retroshare-gui/src/gui/Identity/IdentityListModel.h index c83f7d2bb..518c503ab 100644 --- a/retroshare-gui/src/gui/Identity/IdentityListModel.h +++ b/retroshare-gui/src/gui/Identity/IdentityListModel.h @@ -132,6 +132,8 @@ public: void updateIdentityList(); + int count() const { return mIdentities.size() ; } // total number of identities + static const QString FilterString ; // This method will asynchroneously update the data From e87566ef92576b4e560b26580b6ccf08b7fac407 Mon Sep 17 00:00:00 2001 From: defnax Date: Tue, 1 Apr 2025 21:26:54 +0200 Subject: [PATCH 52/84] set default font size to 11 --- retroshare-gui/src/gui/settings/rsharesettings.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/retroshare-gui/src/gui/settings/rsharesettings.cpp b/retroshare-gui/src/gui/settings/rsharesettings.cpp index 119ea9566..d878d6c99 100644 --- a/retroshare-gui/src/gui/settings/rsharesettings.cpp +++ b/retroshare-gui/src/gui/settings/rsharesettings.cpp @@ -1195,7 +1195,7 @@ int RshareSettings::getFontSize() #if defined(Q_OS_DARWIN) int defaultFontSize = 13; #else - int defaultFontSize = 9; + int defaultFontSize = 11; #endif return value("FontSize", defaultFontSize).toInt(); @@ -1211,7 +1211,7 @@ int RshareSettings::getMessageFontSize() #if defined(Q_OS_DARWIN) int defaultFontSize = 12; #else - int defaultFontSize = 9; + int defaultFontSize = 11; #endif return valueFromGroup("Message", "FontSize", defaultFontSize).toInt(); From aa268c87454b65c11516e7f1e6417f878826649e Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 1 Apr 2025 22:34:13 +0200 Subject: [PATCH 53/84] made identity list searchable by whatever is displayed --- retroshare-gui/src/gui/Identity/IdDialog.cpp | 25 ++++++------- retroshare-gui/src/gui/Identity/IdDialog.ui | 15 ++++---- .../src/gui/Identity/IdentityListModel.cpp | 36 +++++++++---------- .../src/gui/Identity/IdentityListModel.h | 13 ++++--- 4 files changed, 41 insertions(+), 48 deletions(-) diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index eccfd7f9a..fbe83212d 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -298,7 +298,7 @@ IdDialog::IdDialog(QWidget *parent) connect(ui->idTreeWidget->header(), SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(headerContextMenuRequested(QPoint))); connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString))); - connect(ui->ownOpinion_CB, SIGNAL(currentIndexChanged(int)), this, SLOT(modifyReputation())); + //connect(ui->ownOpinion_CB, SIGNAL(currentIndexChanged(int)), this, SLOT(modifyReputation())); connect(ui->inviteButton, SIGNAL(clicked()), this, SLOT(sendInvite())); connect(ui->editButton, SIGNAL(clicked()), this, SLOT(editIdentity())); @@ -388,8 +388,8 @@ IdDialog::IdDialog(QWidget *parent) ui->toolButton_New->setMenu(menu); /* Add filter actions */ - ui->filterLineEdit->addFilter(QIcon(), tr("Name"), RsIdentityListModel::COLUMN_THREAD_NAME, QString("%1 %2").arg(tr("Search"), tr("Search name"))); - ui->filterLineEdit->addFilter(QIcon(), tr("ID"), RsIdentityListModel::COLUMN_THREAD_ID, tr("Search ID")); + //ui->filterLineEdit->addFilter(QIcon(), tr("Name"), RsIdentityListModel::COLUMN_THREAD_NAME, QString("%1 %2").arg(tr("Search"), tr("Search name"))); + //ui->filterLineEdit->addFilter(QIcon(), tr("ID"), RsIdentityListModel::COLUMN_THREAD_ID, tr("Search ID")); /* Set initial section sizes */ QHeaderView * circlesheader = ui->treeWidget_membership->header () ; @@ -1300,7 +1300,7 @@ void IdDialog::processSettings(bool load) // load settings // filterColumn - ui->filterLineEdit->setCurrentFilter(Settings->value("filterColumn", RsIdentityListModel::COLUMN_THREAD_NAME).toInt()); + //ui->filterLineEdit->setCurrentFilter(Settings->value("filterColumn", RsIdentityListModel::COLUMN_THREAD_NAME).toInt()); // state of splitter ui->mainSplitter->restoreState(Settings->value("splitter").toByteArray()); @@ -1322,7 +1322,7 @@ void IdDialog::processSettings(bool load) // save settings // filterColumn - Settings->setValue("filterColumn", ui->filterLineEdit->currentFilter()); + //Settings->setValue("filterColumn", ui->filterLineEdit->currentFilter()); // state of splitter Settings->setValue("splitter", ui->mainSplitter->saveState()); @@ -2112,20 +2112,15 @@ void IdDialog::editIdentity() void IdDialog::filterIds() { - int filterColumn = ui->filterLineEdit->currentFilter(); QString text = ui->filterLineEdit->text(); - RsIdentityListModel::FilterType ft; + int8_t ft=0; - switch(filterColumn) - { - case RsIdentityListModel::COLUMN_THREAD_ID: ft = RsIdentityListModel::FILTER_TYPE_ID; - break; - default: - case RsIdentityListModel::COLUMN_THREAD_NAME: ft = RsIdentityListModel::FILTER_TYPE_NAME; - break; + if(!ui->idTreeWidget->isColumnHidden(RsIdentityListModel::COLUMN_THREAD_ID)) ft |= RsIdentityListModel::FILTER_TYPE_ID; + if(!ui->idTreeWidget->isColumnHidden(RsIdentityListModel::COLUMN_THREAD_NAME)) ft |= RsIdentityListModel::FILTER_TYPE_NAME; + if(!ui->idTreeWidget->isColumnHidden(RsIdentityListModel::COLUMN_THREAD_OWNER_NAME)) ft |= RsIdentityListModel::FILTER_TYPE_OWNER_NAME; + if(!ui->idTreeWidget->isColumnHidden(RsIdentityListModel::COLUMN_THREAD_OWNER_ID)) ft |= RsIdentityListModel::FILTER_TYPE_OWNER_ID; - } mIdListModel->setFilter(ft,{ text }); } diff --git a/retroshare-gui/src/gui/Identity/IdDialog.ui b/retroshare-gui/src/gui/Identity/IdDialog.ui index faab8a48b..b60f24854 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.ui +++ b/retroshare-gui/src/gui/Identity/IdDialog.ui @@ -127,7 +127,7 @@ Qt::NoFocus - + :/icons/help_64.png:/icons/help_64.png @@ -173,7 +173,11 @@ 1 - + + + Search... + + @@ -1037,11 +1041,6 @@ border-image: url(:/images/closepressed.png) - - LineEditClear - QLineEdit -
gui/common/LineEditClear.h
-
RSComboBox QComboBox @@ -1063,8 +1062,8 @@ border-image: url(:/images/closepressed.png) idTreeWidget - + diff --git a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp index 945b7359d..3cea16668 100644 --- a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp +++ b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp @@ -367,29 +367,25 @@ QVariant RsIdentityListModel::data(const QModelIndex &index, int role) const bool RsIdentityListModel::passesFilter(const EntryIndex& e,int /*column*/) const { QString s ; - bool passes_strings = true ; - if(e.type == ENTRY_TYPE_IDENTITY && !mFilterStrings.empty()) - { - switch(mFilterType) - { - case FILTER_TYPE_ID: s = displayRole(e,COLUMN_THREAD_ID).toString(); - break; + if(mFilterStrings.empty() || e.type != ENTRY_TYPE_IDENTITY) + return true; - case FILTER_TYPE_NAME: s = displayRole(e,COLUMN_THREAD_NAME).toString(); - if(s.isNull()) - passes_strings = false; - break; - case FILTER_TYPE_NONE: - RS_ERR("None Type for Filter."); - }; - } + auto passes_strings = [&](const QString& s) -> bool { + bool res = true; - if(!s.isNull()) - for(auto iter(mFilterStrings.begin()); iter != mFilterStrings.end(); ++iter) - passes_strings = passes_strings && s.contains(*iter,Qt::CaseInsensitive); + for(auto iter(mFilterStrings.begin()); iter != mFilterStrings.end(); ++iter) + res = res && s.contains(*iter,Qt::CaseInsensitive); - return passes_strings; + return res; + }; + + if((mFilterType & FilterType::FILTER_TYPE_ID) && passes_strings(displayRole(e,COLUMN_THREAD_ID ).toString())) return true; + if((mFilterType & FilterType::FILTER_TYPE_NAME) && passes_strings(displayRole(e,COLUMN_THREAD_NAME ).toString())) return true; + if((mFilterType & FilterType::FILTER_TYPE_OWNER_ID) && passes_strings(displayRole(e,COLUMN_THREAD_OWNER_ID ).toString())) return true; + if((mFilterType & FilterType::FILTER_TYPE_OWNER_NAME) && passes_strings(displayRole(e,COLUMN_THREAD_OWNER_NAME).toString())) return true; + + return false; } QVariant RsIdentityListModel::filterRole(const EntryIndex& e,int column) const @@ -406,7 +402,7 @@ uint32_t RsIdentityListModel::updateFilterStatus(ForumModelIndex /*i*/,int /*col } -void RsIdentityListModel::setFilter(FilterType filter_type, const QStringList& strings) +void RsIdentityListModel::setFilter(uint8_t filter_type, const QStringList& strings) { #ifdef DEBUG_MODEL std::cerr << "Setting filter to filter_type=" << int(filter_type) << " and strings to " ; diff --git a/retroshare-gui/src/gui/Identity/IdentityListModel.h b/retroshare-gui/src/gui/Identity/IdentityListModel.h index 518c503ab..f92949f2c 100644 --- a/retroshare-gui/src/gui/Identity/IdentityListModel.h +++ b/retroshare-gui/src/gui/Identity/IdentityListModel.h @@ -58,9 +58,11 @@ public: TreePathRole = Qt::UserRole+5, }; - enum FilterType{ FILTER_TYPE_NONE = 0x00, - FILTER_TYPE_ID = 0x01, - FILTER_TYPE_NAME = 0x02 + enum FilterType{ FILTER_TYPE_NONE = 0x00, + FILTER_TYPE_ID = 0x01, + FILTER_TYPE_NAME = 0x02, + FILTER_TYPE_OWNER_NAME = 0x04, + FILTER_TYPE_OWNER_ID = 0x08 }; enum EntryType{ ENTRY_TYPE_TOP_LEVEL = 0x00, @@ -142,7 +144,7 @@ public: RsGxsId getIdentity(const QModelIndex&) const; int getCategory(const QModelIndex&) const; - void setFilter(FilterType filter_type, const QStringList& strings) ; + void setFilter(uint8_t filter_type, const QStringList& strings) ; void expandItem(const QModelIndex&) ; void collapseItem(const QModelIndex&) ; @@ -218,7 +220,7 @@ private: uint32_t updateFilterStatus(ForumModelIndex i,int column,const QStringList& strings); QStringList mFilterStrings; - FilterType mFilterType; + uint8_t mFilterType; rstime_t mLastInternalDataUpdate; rstime_t mLastNodeUpdate;; @@ -245,3 +247,4 @@ private: mutable QTimer *mIdentityUpdateTimer; }; + From f4364bcaa6bc63fe73ee231d1d9306d5f1adc370 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 3 Apr 2025 20:48:01 +0200 Subject: [PATCH 54/84] fixed missing clear button in IDDialog search --- retroshare-gui/src/gui/Identity/IdDialog.ui | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/Identity/IdDialog.ui b/retroshare-gui/src/gui/Identity/IdDialog.ui index b60f24854..b5876c19c 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.ui +++ b/retroshare-gui/src/gui/Identity/IdDialog.ui @@ -173,7 +173,7 @@ 1 - + Search... @@ -1041,6 +1041,11 @@ border-image: url(:/images/closepressed.png) + + LineEditClear + QLineEdit +
gui/common/LineEditClear.h
+
RSComboBox QComboBox From a596acbcec6dd39857a1ac9fbf3493afe8b15d02 Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 9 Apr 2025 16:54:35 +0200 Subject: [PATCH 55/84] removed uninitialized memory read causing random crashes --- retroshare-gui/src/gui/Identity/IdDialog.cpp | 23 ++++++++++++------- retroshare-gui/src/gui/Identity/IdDialog.ui | 3 +++ .../src/gui/Identity/IdentityListModel.cpp | 9 ++++---- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index fbe83212d..53cb8145f 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -205,6 +205,8 @@ IdDialog::IdDialog(QWidget *parent) , mExternalBelongingCircleItem(NULL) , mExternalOtherCircleItem(NULL ) , mMyCircleItem(NULL) + , mLastSortColumn(RsIdentityListModel::COLUMN_THREAD_NAME) + , mLastSortOrder(Qt::SortOrder::AscendingOrder) , needUpdateIdsOnNextShow(true), needUpdateCirclesOnNextShow(true) // Update Ids and Circles on first show , ui(new Ui::IdDialog) { @@ -387,10 +389,6 @@ IdDialog::IdDialog(QWidget *parent) menu->addAction(CreateCircleAction); ui->toolButton_New->setMenu(menu); - /* Add filter actions */ - //ui->filterLineEdit->addFilter(QIcon(), tr("Name"), RsIdentityListModel::COLUMN_THREAD_NAME, QString("%1 %2").arg(tr("Search"), tr("Search name"))); - //ui->filterLineEdit->addFilter(QIcon(), tr("ID"), RsIdentityListModel::COLUMN_THREAD_ID, tr("Search ID")); - /* Set initial section sizes */ QHeaderView * circlesheader = ui->treeWidget_membership->header () ; circlesheader->resizeSection (CIRCLEGROUP_CIRCLE_COL_GROUPNAME, QFontMetricsF(ui->idTreeWidget->font()).width("Circle name")*1.5) ; @@ -404,19 +402,22 @@ IdDialog::IdDialog(QWidget *parent) ui->idTreeWidget->setColumnHidden(RsIdentityListModel::COLUMN_THREAD_ID, true); ui->idTreeWidget->setItemDelegate(new RSElidedItemDelegate()); - //ui->idTreeWidget->setItemDelegateForColumn( RsIdentityListModel::COLUMN_THREAD_NAME, new GxsIdTreeItemDelegate()); ui->idTreeWidget->setItemDelegateForColumn( RsIdentityListModel::COLUMN_THREAD_REPUTATION, new ReputationItemDelegate(RsReputationLevel(0xff))); /* Set header resize modes and initial section sizes */ QHeaderView * idheader = ui->idTreeWidget->header(); + QHeaderView_setSectionResizeModeColumn(idheader, RsIdentityListModel::COLUMN_THREAD_NAME, QHeaderView::ResizeToContents); + QHeaderView_setSectionResizeModeColumn(idheader, RsIdentityListModel::COLUMN_THREAD_ID, QHeaderView::ResizeToContents); + QHeaderView_setSectionResizeModeColumn(idheader, RsIdentityListModel::COLUMN_THREAD_OWNER_ID, QHeaderView::ResizeToContents); + QHeaderView_setSectionResizeModeColumn(idheader, RsIdentityListModel::COLUMN_THREAD_OWNER_NAME, QHeaderView::ResizeToContents); QHeaderView_setSectionResizeModeColumn(idheader, RsIdentityListModel::COLUMN_THREAD_REPUTATION, QHeaderView::ResizeToContents); - idheader->setStretchLastSection(true); + idheader->setStretchLastSection(true); - mStateHelper->setActive(IDDIALOG_IDDETAILS, false); + mStateHelper->setActive(IDDIALOG_IDDETAILS, false); mStateHelper->setActive(IDDIALOG_REPLIST, false); int H = misc::getFontSizeFactor("HelpButton").height(); - QString hlp_str = tr( + QString hlp_str = tr( "

  Identities

" "

In this tab you can create/edit pseudo-anonymous identities, and circles.

" "

Identities are used to securely identify your data: sign messages in chat lobbies, forum and channel posts," @@ -1420,6 +1421,12 @@ void IdDialog::updateIdList() delete ids; ui->label_count->setText("("+QString::number(mIdListModel->count())+")"); + + ui->idTreeWidget->resizeColumnToContents(RsIdentityListModel::COLUMN_THREAD_REPUTATION); + ui->idTreeWidget->resizeColumnToContents(RsIdentityListModel::COLUMN_THREAD_ID); + ui->idTreeWidget->resizeColumnToContents(RsIdentityListModel::COLUMN_THREAD_NAME); + ui->idTreeWidget->resizeColumnToContents(RsIdentityListModel::COLUMN_THREAD_OWNER_ID); + ui->idTreeWidget->resizeColumnToContents(RsIdentityListModel::COLUMN_THREAD_OWNER_NAME); }); }); }); diff --git a/retroshare-gui/src/gui/Identity/IdDialog.ui b/retroshare-gui/src/gui/Identity/IdDialog.ui index b5876c19c..37522524e 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.ui +++ b/retroshare-gui/src/gui/Identity/IdDialog.ui @@ -240,6 +240,9 @@ true + + true + diff --git a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp index 3cea16668..0b6c6be22 100644 --- a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp +++ b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp @@ -465,11 +465,12 @@ QVariant RsIdentityListModel::sizeHintRole(const EntryIndex& e,int col) const switch(col) { default: - case COLUMN_THREAD_NAME: return QVariant( QSize(x_factor * 70 , y_factor*14*1.1f )); - case COLUMN_THREAD_ID: return QVariant( QSize(x_factor * 175, y_factor*14*1.1f )); case COLUMN_THREAD_REPUTATION: return QVariant( QSize(x_factor * 14 , y_factor*14*1.1f )); - case COLUMN_THREAD_OWNER_NAME: return QVariant( QSize(x_factor * 70 , y_factor*14*1.1f )); - case COLUMN_THREAD_OWNER_ID: return QVariant( QSize(x_factor * 70 , y_factor*14*1.1f )); + + case COLUMN_THREAD_NAME: + case COLUMN_THREAD_ID: + case COLUMN_THREAD_OWNER_NAME: + case COLUMN_THREAD_OWNER_ID: return QFontMetricsF(QApplication::font()).boundingRect(displayRole(e,col).toString()).size(); } } From f2bf2f04ccdfb1f5c4f351f2cfff39a9513822c4 Mon Sep 17 00:00:00 2001 From: thunder2 Date: Thu, 10 Apr 2025 10:23:25 +0200 Subject: [PATCH 56/84] Added missing include for std::function in FontSizeHandler.h --- retroshare-gui/src/util/FontSizeHandler.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/retroshare-gui/src/util/FontSizeHandler.h b/retroshare-gui/src/util/FontSizeHandler.h index 19859227d..bf9c8058b 100644 --- a/retroshare-gui/src/util/FontSizeHandler.h +++ b/retroshare-gui/src/util/FontSizeHandler.h @@ -21,6 +21,8 @@ #ifndef _FONTSIZEHANDLER_H #define _FONTSIZEHANDLER_H +#include + class QWidget; class QAbstractItemView; class FontSizeHandlerObject; From 2b13abe2a91a5f0fb36272b3642567f9d88e5b02 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 10 Apr 2025 21:11:28 +0200 Subject: [PATCH 57/84] fixed sizes in idTreeWidget --- retroshare-gui/src/gui/Identity/IdDialog.cpp | 35 ++++++++++--------- retroshare-gui/src/gui/Identity/IdDialog.h | 5 +++ .../src/gui/Identity/IdentityListModel.cpp | 1 + 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index 53cb8145f..e4cf13f10 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -389,9 +389,11 @@ IdDialog::IdDialog(QWidget *parent) menu->addAction(CreateCircleAction); ui->toolButton_New->setMenu(menu); + QFontMetricsF fm(ui->idTreeWidget->font()) ; + /* Set initial section sizes */ QHeaderView * circlesheader = ui->treeWidget_membership->header () ; - circlesheader->resizeSection (CIRCLEGROUP_CIRCLE_COL_GROUPNAME, QFontMetricsF(ui->idTreeWidget->font()).width("Circle name")*1.5) ; + circlesheader->resizeSection (CIRCLEGROUP_CIRCLE_COL_GROUPNAME, fm.width("Circle name")*1.5) ; ui->treeWidget_membership->setColumnWidth(CIRCLEGROUP_CIRCLE_COL_GROUPNAME, 270); /* Setup tree */ @@ -406,12 +408,13 @@ IdDialog::IdDialog(QWidget *parent) /* Set header resize modes and initial section sizes */ QHeaderView * idheader = ui->idTreeWidget->header(); - QHeaderView_setSectionResizeModeColumn(idheader, RsIdentityListModel::COLUMN_THREAD_NAME, QHeaderView::ResizeToContents); - QHeaderView_setSectionResizeModeColumn(idheader, RsIdentityListModel::COLUMN_THREAD_ID, QHeaderView::ResizeToContents); - QHeaderView_setSectionResizeModeColumn(idheader, RsIdentityListModel::COLUMN_THREAD_OWNER_ID, QHeaderView::ResizeToContents); - QHeaderView_setSectionResizeModeColumn(idheader, RsIdentityListModel::COLUMN_THREAD_OWNER_NAME, QHeaderView::ResizeToContents); - QHeaderView_setSectionResizeModeColumn(idheader, RsIdentityListModel::COLUMN_THREAD_REPUTATION, QHeaderView::ResizeToContents); - idheader->setStretchLastSection(true); + QHeaderView_setSectionResizeModeColumn(idheader, RsIdentityListModel::COLUMN_THREAD_NAME, QHeaderView::Stretch); + QHeaderView_setSectionResizeModeColumn(idheader, RsIdentityListModel::COLUMN_THREAD_ID, QHeaderView::Stretch); + QHeaderView_setSectionResizeModeColumn(idheader, RsIdentityListModel::COLUMN_THREAD_OWNER_ID, QHeaderView::Stretch); + QHeaderView_setSectionResizeModeColumn(idheader, RsIdentityListModel::COLUMN_THREAD_OWNER_NAME, QHeaderView::Stretch); + QHeaderView_setSectionResizeModeColumn(idheader, RsIdentityListModel::COLUMN_THREAD_REPUTATION, QHeaderView::Fixed); + ui->idTreeWidget->setColumnWidth(RsIdentityListModel::COLUMN_THREAD_REPUTATION,fm.height()); + idheader->setStretchLastSection(false); mStateHelper->setActive(IDDIALOG_IDDETAILS, false); mStateHelper->setActive(IDDIALOG_REPLIST, false); @@ -1294,12 +1297,12 @@ void IdDialog::processSettings(bool load) { Settings->beginGroup("IdDialog"); - // state of peer tree - // ui->idTreeWidget->processSettings(load); - if (load) { // load settings + ui->idTreeWidget->header()->restoreState(Settings->value(objectName()).toByteArray()); + ui->idTreeWidget->header()->setHidden(Settings->value(objectName()+"HiddenHeader", false).toBool()); + // filterColumn //ui->filterLineEdit->setCurrentFilter(Settings->value("filterColumn", RsIdentityListModel::COLUMN_THREAD_NAME).toInt()); @@ -1322,6 +1325,9 @@ void IdDialog::processSettings(bool load) { // save settings + Settings->setValue(objectName(), ui->idTreeWidget->header()->saveState()); + Settings->setValue(objectName()+"HiddenHeader", ui->idTreeWidget->header()->isHidden()); + // filterColumn //Settings->setValue("filterColumn", ui->filterLineEdit->currentFilter()); @@ -1414,19 +1420,14 @@ void IdDialog::updateIdList() { std::cerr << "Updating identity list in widget." << std::endl; - applyWhileKeepingTree( [ids,this]() { + applyWhileKeepingTree( [ids,this]() + { std::cerr << "setting new identity in model." << std::endl; mIdListModel->setIdentities(*ids) ; delete ids; ui->label_count->setText("("+QString::number(mIdListModel->count())+")"); - - ui->idTreeWidget->resizeColumnToContents(RsIdentityListModel::COLUMN_THREAD_REPUTATION); - ui->idTreeWidget->resizeColumnToContents(RsIdentityListModel::COLUMN_THREAD_ID); - ui->idTreeWidget->resizeColumnToContents(RsIdentityListModel::COLUMN_THREAD_NAME); - ui->idTreeWidget->resizeColumnToContents(RsIdentityListModel::COLUMN_THREAD_OWNER_ID); - ui->idTreeWidget->resizeColumnToContents(RsIdentityListModel::COLUMN_THREAD_OWNER_NAME); }); }); }); diff --git a/retroshare-gui/src/gui/Identity/IdDialog.h b/retroshare-gui/src/gui/Identity/IdDialog.h index 938abdee3..c9c1df995 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.h +++ b/retroshare-gui/src/gui/Identity/IdDialog.h @@ -35,6 +35,7 @@ class IdDialog; } class UIStateHelper; +class QStyledItemDelegate; class QTreeWidgetItem; class RsIdentityListModel; class IdListSortFilterProxyModel; @@ -166,6 +167,10 @@ private: RsGxsGroupId mId; RsGxsGroupId mIdToNavigate; int filter; + bool mColumnSizeAlreadySet; // remembers if we already did some size set. If not, automatically stretch to content. + + QStyledItemDelegate *mElidedLabelDelegate; + QStyledItemDelegate *mReputationDelegate; RsIdentityListModel *mIdListModel; IdListSortFilterProxyModel *mProxyModel; diff --git a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp index 0b6c6be22..2726d5a32 100644 --- a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp +++ b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp @@ -462,6 +462,7 @@ QVariant RsIdentityListModel::sizeHintRole(const EntryIndex& e,int col) const if(e.type == ENTRY_TYPE_CATEGORY) y_factor *= 1.5; + std::cerr << "sizeHintRole()" << std::endl; switch(col) { default: From bd7dfe957f94070b2a3824306545d5a1f239e7eb Mon Sep 17 00:00:00 2001 From: thunder2 Date: Sat, 12 Apr 2025 15:50:43 +0200 Subject: [PATCH 58/84] FeedReader: Added FontSizeHandler --- plugins/FeedReader/gui/FeedReaderDialog.cpp | 2 ++ plugins/FeedReader/gui/FeedReaderDialog.h | 3 +++ plugins/FeedReader/gui/FeedReaderMessageWidget.cpp | 2 ++ plugins/FeedReader/gui/FeedReaderMessageWidget.h | 3 +++ 4 files changed, 10 insertions(+) diff --git a/plugins/FeedReader/gui/FeedReaderDialog.cpp b/plugins/FeedReader/gui/FeedReaderDialog.cpp index 08f390a09..87db9cf9c 100644 --- a/plugins/FeedReader/gui/FeedReaderDialog.cpp +++ b/plugins/FeedReader/gui/FeedReaderDialog.cpp @@ -129,6 +129,8 @@ FeedReaderDialog::FeedReaderDialog(RsFeedReader *feedReader, FeedReaderNotify *n settingsChanged(); feedTreeItemActivated(NULL); + + mFontSizeHandler.registerFontSize(ui->feedTreeWidget); } FeedReaderDialog::~FeedReaderDialog() diff --git a/plugins/FeedReader/gui/FeedReaderDialog.h b/plugins/FeedReader/gui/FeedReaderDialog.h index 12e11ee7f..a9672bc76 100644 --- a/plugins/FeedReader/gui/FeedReaderDialog.h +++ b/plugins/FeedReader/gui/FeedReaderDialog.h @@ -23,6 +23,7 @@ #include #include "interface/rsFeedReader.h" +#include "util/FontSizeHandler.h" namespace Ui { class FeedReaderDialog; @@ -98,6 +99,8 @@ private: RsFeedReader *mFeedReader; FeedReaderNotify *mNotify; + FontSizeHandler mFontSizeHandler; + /** Qt Designer generated object */ Ui::FeedReaderDialog *ui; }; diff --git a/plugins/FeedReader/gui/FeedReaderMessageWidget.cpp b/plugins/FeedReader/gui/FeedReaderMessageWidget.cpp index 59f72103c..ec0e3d0e2 100644 --- a/plugins/FeedReader/gui/FeedReaderMessageWidget.cpp +++ b/plugins/FeedReader/gui/FeedReaderMessageWidget.cpp @@ -154,6 +154,8 @@ FeedReaderMessageWidget::FeedReaderMessageWidget(uint32_t feedId, RsFeedReader * ui->msgTreeWidget->installEventFilter(this); setFeedId(feedId); + + mFontSizeHandler.registerFontSize(ui->msgTreeWidget); } FeedReaderMessageWidget::~FeedReaderMessageWidget() diff --git a/plugins/FeedReader/gui/FeedReaderMessageWidget.h b/plugins/FeedReader/gui/FeedReaderMessageWidget.h index 1223b3b4e..40f16e29f 100644 --- a/plugins/FeedReader/gui/FeedReaderMessageWidget.h +++ b/plugins/FeedReader/gui/FeedReaderMessageWidget.h @@ -24,6 +24,7 @@ #include #include "interface/rsFeedReader.h" +#include "util/FontSizeHandler.h" namespace Ui { class FeedReaderMessageWidget; @@ -107,6 +108,8 @@ private: RsFeedReader *mFeedReader; FeedReaderNotify *mNotify; + FontSizeHandler mFontSizeHandler; + Ui::FeedReaderMessageWidget *ui; }; From 0b3f4a69b9f25bb92e90083143d38840539a1726 Mon Sep 17 00:00:00 2001 From: defnax Date: Sat, 12 Apr 2025 18:01:38 +0200 Subject: [PATCH 59/84] Fix size & age column --- retroshare-gui/src/gui/FileTransfer/SearchDialog.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/retroshare-gui/src/gui/FileTransfer/SearchDialog.cpp b/retroshare-gui/src/gui/FileTransfer/SearchDialog.cpp index 2d00b3e5b..c5b7ba04d 100644 --- a/retroshare-gui/src/gui/FileTransfer/SearchDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/SearchDialog.cpp @@ -1324,10 +1324,10 @@ void SearchDialog::insertFile(qulonglong searchId, const FileDetail& file, int s * to facilitate downloads we need to save the file size too */ - item->setText(SR_SIZE_COL, misc::friendlyUnit(file.size)); + item->setText(SR_SIZE_COL, QString::number(file.size)); item->setData(SR_SIZE_COL, ROLE_SORT, (qulonglong) file.size); - item->setText(SR_AGE_COL, misc::timeRelativeToNow(file.mtime)); - item->setData(SR_AGE_COL, ROLE_SORT, file.mtime); + item->setText(SR_AGE_COL, QString::number(file.mtime)); + item->setData(SR_AGE_COL, ROLE_SORT, file.mtime); item->setTextAlignment( SR_SIZE_COL, Qt::AlignRight ); item->setTextAlignment( SR_AGE_COL, Qt::AlignCenter ); From 71eba47fe7ff0ac43220f60c0622c0a88acff962 Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 16 Apr 2025 13:36:01 +0200 Subject: [PATCH 60/84] fixed voting not working on right panel of People --- retroshare-gui/src/gui/Identity/IdDialog.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index e4cf13f10..fbfa60fab 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -300,7 +300,7 @@ IdDialog::IdDialog(QWidget *parent) connect(ui->idTreeWidget->header(), SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(headerContextMenuRequested(QPoint))); connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString))); - //connect(ui->ownOpinion_CB, SIGNAL(currentIndexChanged(int)), this, SLOT(modifyReputation())); + connect(ui->ownOpinion_CB, SIGNAL(currentIndexChanged(int)), this, SLOT(modifyReputation())); connect(ui->inviteButton, SIGNAL(clicked()), this, SLOT(sendInvite())); connect(ui->editButton, SIGNAL(clicked()), this, SLOT(editIdentity())); @@ -1972,8 +1972,8 @@ void IdDialog::modifyReputation() // trigger refresh when finished. // basic / anstype are not needed. - updateIdentity(); - updateIdList(); + //updateIdentity(); + //updateIdList(); return; } From 9810008fc1fc691d348f0f44194d5db4a7529e2c Mon Sep 17 00:00:00 2001 From: defnax <9952056+defnax@users.noreply.github.com> Date: Wed, 16 Apr 2025 20:29:39 +0200 Subject: [PATCH 61/84] Revert "Moved background image to standard light" --- .../src/gui/qss/stylesheet/Standard_Light.qss | 34 ------------------ .../src/gui/qss/stylesheet/default.qss | 35 +++++++++++++++++++ 2 files changed, 35 insertions(+), 34 deletions(-) diff --git a/retroshare-gui/src/gui/qss/stylesheet/Standard_Light.qss b/retroshare-gui/src/gui/qss/stylesheet/Standard_Light.qss index ec1992f5b..df6b9d51c 100644 --- a/retroshare-gui/src/gui/qss/stylesheet/Standard_Light.qss +++ b/retroshare-gui/src/gui/qss/stylesheet/Standard_Light.qss @@ -2712,37 +2712,3 @@ PhotoItem QFrame#photoFrame { PhotoItem QWidget:hover { background-color: #7ecbfb; } - - -/* StartDialog - To get the same style for all user and not use last connected one. */ - -StartDialog QFrame#loginframe{ - border-image: url(:/images/logo/background_lessblue.png) 0 0 0 0 stretch stretch; - border-width: 0px; -} -StartDialog QFrame#loginframe QCheckBox, -StartDialog QFrame#loginframe QLabel { - background: transparent; -} -StartDialog QGroupBox#profilGBox { - background: rgba(0,0,0,10%); - border-radius: 3px; - border-width: 0px; -} - -StartDialog QGroupBox#profilGBox * { - background-color: white; - color: black; -} - -StartDialog QPushButton#loadButton { - background: transparent; - border-image: url(:/images/btn_blue.png) 4; - border-width: 4; - color: white; -} -StartDialog QPushButton#loadButton:hover { - background: transparent; - border-image: url(:/images/btn_blue_hover.png) 4; -} diff --git a/retroshare-gui/src/gui/qss/stylesheet/default.qss b/retroshare-gui/src/gui/qss/stylesheet/default.qss index 3a3bfeb5c..defcc82f8 100644 --- a/retroshare-gui/src/gui/qss/stylesheet/default.qss +++ b/retroshare-gui/src/gui/qss/stylesheet/default.qss @@ -141,6 +141,41 @@ QLabel#newLabel:enabled { } +/* StartDialog + To get the same style for all user and not use last connected one. */ + +StartDialog QFrame#loginframe{ + border-image: url(:/images/logo/background_lessblue.png) 0 0 0 0 stretch stretch; + border-width: 0px; +} +StartDialog QFrame#loginframe QCheckBox, +StartDialog QFrame#loginframe QLabel { + background: transparent; +} +StartDialog QGroupBox#profilGBox { + background: rgba(0,0,0,10%); + border-radius: 3px; + border-width: 0px; +} + +StartDialog QGroupBox#profilGBox * { + background-color: white; + color: black; +} + +StartDialog QPushButton#loadButton { + background: transparent; + border-image: url(:/images/btn_blue.png) 4; + border-width: 4; + color: white; +} +StartDialog QPushButton#loadButton:hover { + background: transparent; + border-image: url(:/images/btn_blue_hover.png) 4; +} + + + /* GenCertDialog Change colors here because GUI is not started yet so no user StyleSheet loads */ From 2f02f6cd2dcd4df158037084761a1f0a9d563307 Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 16 Apr 2025 22:10:58 +0200 Subject: [PATCH 62/84] fixed coloring for insecure identities --- retroshare-gui/src/gui/Identity/IdentityListModel.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp index 2726d5a32..4768fe54d 100644 --- a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp +++ b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp @@ -430,6 +430,9 @@ QVariant RsIdentityListModel::toolTipRole(const EntryIndex& fmpe,int /*column*/) if(!id_info) return QVariant(); + if(id_info->flags & RS_IDENTITY_FLAGS_IS_DEPRECATED) + return QVariant( tr("\nThis identity has a insecure fingerprint (It's probably quite old).\nYou should get rid of it now and use a new one.\nThese identities are not supported anymore.") ) ; + if(rsIdentity->isOwnId(id_info->id)) return QVariant(tr("This identity is owned by you")); @@ -438,9 +441,10 @@ QVariant RsIdentityListModel::toolTipRole(const EntryIndex& fmpe,int /*column*/) else { RsPeerDetails dd; - rsPeers->getGPGDetails(id_info->owner,dd); - - return QVariant("Identity owned by profile \""+ QString::fromUtf8(dd.name.c_str()) +"\" ("+QString::fromStdString(id_info->owner.toStdString())); + if(rsPeers->getGPGDetails(id_info->owner,dd)) + return QVariant(tr("Identity owned by profile")+" \""+ QString::fromUtf8(dd.name.c_str()) +"\" ("+QString::fromStdString(id_info->owner.toStdString())); + else + return QVariant(tr("Identity possibly owned by unknown profile")+" \""+ QString::fromUtf8(dd.name.c_str()) +"\" ("+QString::fromStdString(id_info->owner.toStdString())); } } From 39b062fecf7922636623dbd591c67691b35bf31e Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 17 Apr 2025 20:31:18 +0200 Subject: [PATCH 63/84] fixed compilation --- retroshare-gui/src/gui/Identity/IdDialog.cpp | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index b1f045873..e5f88541b 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -450,22 +450,6 @@ IdDialog::IdDialog(QWidget *parent) updateIdTimer.setSingleShot(true); connect(&updateIdTimer, SIGNAL(timeout()), this, SLOT(updateIdList())); - mFontSizeHandler.registerFontSize(ui->idTreeWidget, 0, [this] (QAbstractItemView*, int fontSize) { - // Set new font size on all items - QTreeWidgetItemIterator it(ui->idTreeWidget); - while (*it) { - QTreeWidgetItem *item = *it; - if (item->parent()) { - QFont font = item->font(CIRCLEGROUP_CIRCLE_COL_GROUPNAME); - font.setPointSize(fontSize); - - item->setFont(CIRCLEGROUP_CIRCLE_COL_GROUPNAME, font); - item->setFont(CIRCLEGROUP_CIRCLE_COL_GROUPID, font); - item->setFont(CIRCLEGROUP_CIRCLE_COL_GROUPFLAGS, font); - } - ++it; - } - }); mFontSizeHandler.registerFontSize(ui->treeWidget_membership, 0, [this] (QAbstractItemView*, int fontSize) { // Set new font size on all items QTreeWidgetItemIterator it(ui->treeWidget_membership); From 1720a94a80c9b67df8fc2bbace114912bd10738d Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 17 Apr 2025 20:49:30 +0200 Subject: [PATCH 64/84] added fontSizeHandler for Identity list --- retroshare-gui/src/gui/Identity/IdDialog.cpp | 8 ++++- .../src/gui/Identity/IdentityListModel.cpp | 31 +++++++++++++------ .../src/gui/Identity/IdentityListModel.h | 2 ++ 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index e5f88541b..a2d588d3e 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -450,7 +450,13 @@ IdDialog::IdDialog(QWidget *parent) updateIdTimer.setSingleShot(true); connect(&updateIdTimer, SIGNAL(timeout()), this, SLOT(updateIdList())); - mFontSizeHandler.registerFontSize(ui->treeWidget_membership, 0, [this] (QAbstractItemView*, int fontSize) { + mFontSizeHandler.registerFontSize(ui->idTreeWidget, 0, [this] (QAbstractItemView*, int fontSize) { + // Set new font size on all items + + mIdListModel->setFontSize(fontSize); + }); + + mFontSizeHandler.registerFontSize(ui->treeWidget_membership, 0, [this] (QAbstractItemView*, int fontSize) { // Set new font size on all items QTreeWidgetItemIterator it(ui->treeWidget_membership); while (*it) { diff --git a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp index 4768fe54d..b55d9c160 100644 --- a/retroshare-gui/src/gui/Identity/IdentityListModel.cpp +++ b/retroshare-gui/src/gui/Identity/IdentityListModel.cpp @@ -53,6 +53,8 @@ RsIdentityListModel::RsIdentityListModel(QObject *parent) : QAbstractItemModel(parent) , mLastInternalDataUpdate(0), mLastNodeUpdate(0) { + mFontSize = QApplication::font().pointSize(); + mFilterStrings.clear(); mIdentityUpdateTimer = new QTimer(); connect(mIdentityUpdateTimer,SIGNAL(timeout()),this,SLOT(timerUpdate())); @@ -565,19 +567,28 @@ QVariant RsIdentityListModel::foregroundRole(const EntryIndex& e, int /*col*/) c } QVariant RsIdentityListModel::fontRole(const EntryIndex& e, int /*col*/) const { - auto it = getIdentityInfo(e); - if(!it) - return QVariant(); - RsGxsId id(it->id); + QFont f; + f.setPointSize(mFontSize); - if(rsIdentity->isOwnId(id)) + auto it = getIdentityInfo(e); + + if(it) { - QFont f; - f.setBold(true); - return QVariant(f); + RsGxsId id(it->id); + + if(rsIdentity->isOwnId(id)) + f.setBold(true); + } + + return QVariant(f); +} +void RsIdentityListModel::setFontSize(int s) +{ + if(s != mFontSize) + { + mFontSize = s; + emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mCategories.size()-1,columnCount()-1,(void*)NULL)); } - else - return QVariant(); } #ifdef DEBUG_MODEL_INDEX diff --git a/retroshare-gui/src/gui/Identity/IdentityListModel.h b/retroshare-gui/src/gui/Identity/IdentityListModel.h index f92949f2c..4c3cb43e2 100644 --- a/retroshare-gui/src/gui/Identity/IdentityListModel.h +++ b/retroshare-gui/src/gui/Identity/IdentityListModel.h @@ -143,6 +143,7 @@ public: EntryType getType(const QModelIndex&) const; RsGxsId getIdentity(const QModelIndex&) const; int getCategory(const QModelIndex&) const; + void setFontSize(int s); void setFilter(uint8_t filter_type, const QStringList& strings) ; @@ -221,6 +222,7 @@ private: QStringList mFilterStrings; uint8_t mFilterType; + int mFontSize; rstime_t mLastInternalDataUpdate; rstime_t mLastNodeUpdate;; From e5273fb88742c3f2edbd80b7d061d00f2693a0cb Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 29 Apr 2025 21:10:27 +0200 Subject: [PATCH 65/84] fixed wrong implementation of parentRow causing loss of selected elements --- retroshare-gui/src/gui/common/FriendListModel.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/retroshare-gui/src/gui/common/FriendListModel.cpp b/retroshare-gui/src/gui/common/FriendListModel.cpp index 9ea271f86..45c054698 100644 --- a/retroshare-gui/src/gui/common/FriendListModel.cpp +++ b/retroshare-gui/src/gui/common/FriendListModel.cpp @@ -304,10 +304,10 @@ uint32_t RsFriendListModel::EntryIndex::parentRow(uint32_t nb_groups) const switch(type) { default: - case ENTRY_TYPE_UNKNOWN : return 0; - case ENTRY_TYPE_GROUP : return group_index; - case ENTRY_TYPE_PROFILE : return (group_index==UNDEFINED_GROUP_INDEX_VALUE)?(profile_index+nb_groups):profile_index; - case ENTRY_TYPE_NODE : return node_index; + case ENTRY_TYPE_UNKNOWN : return -1; + case ENTRY_TYPE_GROUP : return -1; + case ENTRY_TYPE_PROFILE : return (group_index==UNDEFINED_GROUP_INDEX_VALUE)?(-1):group_index; + case ENTRY_TYPE_NODE : return (group_index==UNDEFINED_GROUP_INDEX_VALUE)?(profile_index+nb_groups):profile_index; } } From 6fe7f7842be2a9df115d09d3aa2e828ecb67c6b5 Mon Sep 17 00:00:00 2001 From: Christoph Johannes Kleine Date: Wed, 28 May 2025 12:48:09 +0200 Subject: [PATCH 66/84] fix typo Stared -> Starred --- retroshare-gui/src/gui/msgs/MessagesDialog.cpp | 2 +- retroshare-gui/src/lang/retroshare_bg.ts | 2 +- retroshare-gui/src/lang/retroshare_ca_ES.ts | 2 +- retroshare-gui/src/lang/retroshare_cs.ts | 2 +- retroshare-gui/src/lang/retroshare_da.ts | 2 +- retroshare-gui/src/lang/retroshare_de.ts | 2 +- retroshare-gui/src/lang/retroshare_el.ts | 2 +- retroshare-gui/src/lang/retroshare_en.ts | 2 +- retroshare-gui/src/lang/retroshare_es.ts | 2 +- retroshare-gui/src/lang/retroshare_fi.ts | 2 +- retroshare-gui/src/lang/retroshare_fr.ts | 2 +- retroshare-gui/src/lang/retroshare_hu.ts | 2 +- retroshare-gui/src/lang/retroshare_it.ts | 2 +- retroshare-gui/src/lang/retroshare_ja_JP.ts | 2 +- retroshare-gui/src/lang/retroshare_ko.ts | 2 +- retroshare-gui/src/lang/retroshare_nl.ts | 2 +- retroshare-gui/src/lang/retroshare_pl.ts | 2 +- retroshare-gui/src/lang/retroshare_pt.ts | 2 +- retroshare-gui/src/lang/retroshare_ru.ts | 2 +- retroshare-gui/src/lang/retroshare_sl.ts | 2 +- retroshare-gui/src/lang/retroshare_sr.ts | 2 +- retroshare-gui/src/lang/retroshare_sv.ts | 2 +- retroshare-gui/src/lang/retroshare_tr.ts | 2 +- retroshare-gui/src/lang/retroshare_zh_CN.ts | 2 +- retroshare-gui/src/lang/retroshare_zh_TW.ts | 2 +- 25 files changed, 25 insertions(+), 25 deletions(-) diff --git a/retroshare-gui/src/gui/msgs/MessagesDialog.cpp b/retroshare-gui/src/gui/msgs/MessagesDialog.cpp index 8f573c6b7..7cddc1b7d 100644 --- a/retroshare-gui/src/gui/msgs/MessagesDialog.cpp +++ b/retroshare-gui/src/gui/msgs/MessagesDialog.cpp @@ -528,7 +528,7 @@ void MessagesDialog::fillQuickView() ui.quickViewWidget->clear(); // add static items - item = new QListWidgetItem(tr("Stared"), ui.quickViewWidget); + item = new QListWidgetItem(tr("Starred"), ui.quickViewWidget); item->setIcon(FilesDefs::getIconFromQtResourcePath(IMAGE_STAR_ON)); item->setData(ROLE_QUICKVIEW_TYPE, QUICKVIEW_TYPE_STATIC); item->setData(ROLE_QUICKVIEW_ID, QUICKVIEW_STATIC_ID_STARRED); diff --git a/retroshare-gui/src/lang/retroshare_bg.ts b/retroshare-gui/src/lang/retroshare_bg.ts index 7bb75556d..c57ad6a7a 100644 --- a/retroshare-gui/src/lang/retroshare_bg.ts +++ b/retroshare-gui/src/lang/retroshare_bg.ts @@ -14303,7 +14303,7 @@ Do you want to save message ? - Stared + Starred diff --git a/retroshare-gui/src/lang/retroshare_ca_ES.ts b/retroshare-gui/src/lang/retroshare_ca_ES.ts index ef5261f6a..1e88b2136 100644 --- a/retroshare-gui/src/lang/retroshare_ca_ES.ts +++ b/retroshare-gui/src/lang/retroshare_ca_ES.ts @@ -14370,7 +14370,7 @@ Voleu desar el missatge? - Stared + Starred diff --git a/retroshare-gui/src/lang/retroshare_cs.ts b/retroshare-gui/src/lang/retroshare_cs.ts index b0c0c123b..9ddff2a55 100644 --- a/retroshare-gui/src/lang/retroshare_cs.ts +++ b/retroshare-gui/src/lang/retroshare_cs.ts @@ -14334,7 +14334,7 @@ Do you want to save message ? - Stared + Starred diff --git a/retroshare-gui/src/lang/retroshare_da.ts b/retroshare-gui/src/lang/retroshare_da.ts index ffd7a7c0e..4cb8c0823 100644 --- a/retroshare-gui/src/lang/retroshare_da.ts +++ b/retroshare-gui/src/lang/retroshare_da.ts @@ -14303,7 +14303,7 @@ Do you want to save message ? - Stared + Starred diff --git a/retroshare-gui/src/lang/retroshare_de.ts b/retroshare-gui/src/lang/retroshare_de.ts index b2b9f2ea3..e37c020a9 100644 --- a/retroshare-gui/src/lang/retroshare_de.ts +++ b/retroshare-gui/src/lang/retroshare_de.ts @@ -14360,7 +14360,7 @@ Möchtest du die Nachricht speichern ? - Stared + Starred Markiert diff --git a/retroshare-gui/src/lang/retroshare_el.ts b/retroshare-gui/src/lang/retroshare_el.ts index 82ed18b46..1b43e7f05 100644 --- a/retroshare-gui/src/lang/retroshare_el.ts +++ b/retroshare-gui/src/lang/retroshare_el.ts @@ -14332,7 +14332,7 @@ Do you want to save message ? - Stared + Starred diff --git a/retroshare-gui/src/lang/retroshare_en.ts b/retroshare-gui/src/lang/retroshare_en.ts index 0f9c08da7..74a7b83b3 100644 --- a/retroshare-gui/src/lang/retroshare_en.ts +++ b/retroshare-gui/src/lang/retroshare_en.ts @@ -14303,7 +14303,7 @@ Do you want to save message ? - Stared + Starred diff --git a/retroshare-gui/src/lang/retroshare_es.ts b/retroshare-gui/src/lang/retroshare_es.ts index 358668fc3..cc21a60c3 100644 --- a/retroshare-gui/src/lang/retroshare_es.ts +++ b/retroshare-gui/src/lang/retroshare_es.ts @@ -14369,7 +14369,7 @@ Do you want to save message ? - Stared + Starred diff --git a/retroshare-gui/src/lang/retroshare_fi.ts b/retroshare-gui/src/lang/retroshare_fi.ts index 035f64f23..2a52e18a6 100644 --- a/retroshare-gui/src/lang/retroshare_fi.ts +++ b/retroshare-gui/src/lang/retroshare_fi.ts @@ -14374,7 +14374,7 @@ Haluatko tallentaa viestin? - Stared + Starred diff --git a/retroshare-gui/src/lang/retroshare_fr.ts b/retroshare-gui/src/lang/retroshare_fr.ts index 876414b16..127c0fdd7 100644 --- a/retroshare-gui/src/lang/retroshare_fr.ts +++ b/retroshare-gui/src/lang/retroshare_fr.ts @@ -14385,7 +14385,7 @@ Voulez-vous enregistrer votre message ? - Stared + Starred diff --git a/retroshare-gui/src/lang/retroshare_hu.ts b/retroshare-gui/src/lang/retroshare_hu.ts index c2e111012..d5967ea59 100644 --- a/retroshare-gui/src/lang/retroshare_hu.ts +++ b/retroshare-gui/src/lang/retroshare_hu.ts @@ -14358,7 +14358,7 @@ Szeretnéd menteni az üzenetet? - Stared + Starred diff --git a/retroshare-gui/src/lang/retroshare_it.ts b/retroshare-gui/src/lang/retroshare_it.ts index 4cfb28a4d..ade137565 100644 --- a/retroshare-gui/src/lang/retroshare_it.ts +++ b/retroshare-gui/src/lang/retroshare_it.ts @@ -14352,7 +14352,7 @@ ricerca - Stared + Starred diff --git a/retroshare-gui/src/lang/retroshare_ja_JP.ts b/retroshare-gui/src/lang/retroshare_ja_JP.ts index 89bf9c9f2..5f2256dd5 100644 --- a/retroshare-gui/src/lang/retroshare_ja_JP.ts +++ b/retroshare-gui/src/lang/retroshare_ja_JP.ts @@ -14304,7 +14304,7 @@ Do you want to save message ? - Stared + Starred diff --git a/retroshare-gui/src/lang/retroshare_ko.ts b/retroshare-gui/src/lang/retroshare_ko.ts index 8867098a1..927baa9e7 100644 --- a/retroshare-gui/src/lang/retroshare_ko.ts +++ b/retroshare-gui/src/lang/retroshare_ko.ts @@ -14312,7 +14312,7 @@ Do you want to save message ? - Stared + Starred diff --git a/retroshare-gui/src/lang/retroshare_nl.ts b/retroshare-gui/src/lang/retroshare_nl.ts index 6d7c25195..bb4fef66a 100644 --- a/retroshare-gui/src/lang/retroshare_nl.ts +++ b/retroshare-gui/src/lang/retroshare_nl.ts @@ -14331,7 +14331,7 @@ Wil je het bericht bewaren? - Stared + Starred diff --git a/retroshare-gui/src/lang/retroshare_pl.ts b/retroshare-gui/src/lang/retroshare_pl.ts index 46abcec56..637121e24 100644 --- a/retroshare-gui/src/lang/retroshare_pl.ts +++ b/retroshare-gui/src/lang/retroshare_pl.ts @@ -14434,7 +14434,7 @@ Czy chcesz zapisać wiadomość ? - Stared + Starred diff --git a/retroshare-gui/src/lang/retroshare_pt.ts b/retroshare-gui/src/lang/retroshare_pt.ts index a760d3920..842fde2d7 100644 --- a/retroshare-gui/src/lang/retroshare_pt.ts +++ b/retroshare-gui/src/lang/retroshare_pt.ts @@ -14303,7 +14303,7 @@ Do you want to save message ? - Stared + Starred diff --git a/retroshare-gui/src/lang/retroshare_ru.ts b/retroshare-gui/src/lang/retroshare_ru.ts index 197a77c4f..20b2f9e16 100644 --- a/retroshare-gui/src/lang/retroshare_ru.ts +++ b/retroshare-gui/src/lang/retroshare_ru.ts @@ -14373,7 +14373,7 @@ Do you want to save message ? - Stared + Starred diff --git a/retroshare-gui/src/lang/retroshare_sl.ts b/retroshare-gui/src/lang/retroshare_sl.ts index bb6973983..581ac731c 100644 --- a/retroshare-gui/src/lang/retroshare_sl.ts +++ b/retroshare-gui/src/lang/retroshare_sl.ts @@ -14303,7 +14303,7 @@ Do you want to save message ? - Stared + Starred diff --git a/retroshare-gui/src/lang/retroshare_sr.ts b/retroshare-gui/src/lang/retroshare_sr.ts index 208c6f3e6..01e51db3d 100644 --- a/retroshare-gui/src/lang/retroshare_sr.ts +++ b/retroshare-gui/src/lang/retroshare_sr.ts @@ -14304,7 +14304,7 @@ Do you want to save message ? - Stared + Starred diff --git a/retroshare-gui/src/lang/retroshare_sv.ts b/retroshare-gui/src/lang/retroshare_sv.ts index ee425491b..754e79479 100644 --- a/retroshare-gui/src/lang/retroshare_sv.ts +++ b/retroshare-gui/src/lang/retroshare_sv.ts @@ -14332,7 +14332,7 @@ Vill du spara meddelandet? - Stared + Starred diff --git a/retroshare-gui/src/lang/retroshare_tr.ts b/retroshare-gui/src/lang/retroshare_tr.ts index cd2651115..1163f7149 100644 --- a/retroshare-gui/src/lang/retroshare_tr.ts +++ b/retroshare-gui/src/lang/retroshare_tr.ts @@ -14374,7 +14374,7 @@ Do you want to save message ? - Stared + Starred diff --git a/retroshare-gui/src/lang/retroshare_zh_CN.ts b/retroshare-gui/src/lang/retroshare_zh_CN.ts index d35ab9a92..82bafc9e1 100644 --- a/retroshare-gui/src/lang/retroshare_zh_CN.ts +++ b/retroshare-gui/src/lang/retroshare_zh_CN.ts @@ -14361,7 +14361,7 @@ Do you want to save message ? - Stared + Starred diff --git a/retroshare-gui/src/lang/retroshare_zh_TW.ts b/retroshare-gui/src/lang/retroshare_zh_TW.ts index d81166627..2acc19ab2 100644 --- a/retroshare-gui/src/lang/retroshare_zh_TW.ts +++ b/retroshare-gui/src/lang/retroshare_zh_TW.ts @@ -14303,7 +14303,7 @@ Do you want to save message ? - Stared + Starred From d6228f381d30f135cfd10fe47d0bdebc36745516 Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 30 May 2025 20:54:40 +0200 Subject: [PATCH 67/84] updated submodules to latest commit --- libretroshare | 2 +- openpgpsdk | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libretroshare b/libretroshare index 2a4df811f..ac83e00ea 160000 --- a/libretroshare +++ b/libretroshare @@ -1 +1 @@ -Subproject commit 2a4df811f6bfe1904bc3956f285aa0fc891f9fd4 +Subproject commit ac83e00ea7a26cd6cf57cefef745d6dcfd07e5da diff --git a/openpgpsdk b/openpgpsdk index df542663d..178aa8ebc 160000 --- a/openpgpsdk +++ b/openpgpsdk @@ -1 +1 @@ -Subproject commit df542663d8bd698a8b5541fc6db07da6c59f1c3a +Subproject commit 178aa8ebcef47e3271d5a5ca5c07e45d3b71c81d From a0646c1b66ca4eb698391ed8def44acc7ad882ef Mon Sep 17 00:00:00 2001 From: Christoph Johannes Kleine Date: Sat, 31 May 2025 18:28:47 +0200 Subject: [PATCH 68/84] Desktop file remove 'Application' --- data/retroshare.desktop | 2 +- retroshare-service/data/retroshare-service.desktop | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/data/retroshare.desktop b/data/retroshare.desktop index 2cfe1f12e..95056d54a 100644 --- a/data/retroshare.desktop +++ b/data/retroshare.desktop @@ -7,5 +7,5 @@ Exec=/usr/bin/retroshare %U Icon=/usr/share/pixmaps/retroshare.xpm Terminal=false Type=Application -Categories=Application;Network;Email;InstantMessaging;Chat;Feed;FileTransfer;P2P +Categories=Network;Email;InstantMessaging;Chat;Feed;FileTransfer;P2P MimeType=x-scheme-handler/retroshare; diff --git a/retroshare-service/data/retroshare-service.desktop b/retroshare-service/data/retroshare-service.desktop index 5d077597b..fc8135e05 100644 --- a/retroshare-service/data/retroshare-service.desktop +++ b/retroshare-service/data/retroshare-service.desktop @@ -7,4 +7,4 @@ Exec=retroshare-service %U Icon=retroshare-service Terminal=false Type=Application -Categories=Application;Network; +Categories=Network; From d0c4827335a4d7dea2aa52bf187cef0391645ce4 Mon Sep 17 00:00:00 2001 From: Christoph Johannes Kleine Date: Sat, 31 May 2025 18:32:58 +0200 Subject: [PATCH 69/84] change .desktop file in build_scripts --- build_scripts/RedHat+Fedora/data/retroshare.desktop | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/build_scripts/RedHat+Fedora/data/retroshare.desktop b/build_scripts/RedHat+Fedora/data/retroshare.desktop index 7b93b4fa5..95056d54a 100644 --- a/build_scripts/RedHat+Fedora/data/retroshare.desktop +++ b/build_scripts/RedHat+Fedora/data/retroshare.desktop @@ -1,10 +1,11 @@ [Desktop Entry] +Encoding=UTF-8 Version=1.0 Name=RetroShare -Comment=Securely share files with your friends +Comment=Securely communicate with your friends Exec=/usr/bin/retroshare %U Icon=/usr/share/pixmaps/retroshare.xpm Terminal=false Type=Application -Categories=Network;P2P; +Categories=Network;Email;InstantMessaging;Chat;Feed;FileTransfer;P2P MimeType=x-scheme-handler/retroshare; From 12959c60cbcbb66d5e93ce1ae7814611c4dac784 Mon Sep 17 00:00:00 2001 From: defnax <9952056+defnax@users.noreply.github.com> Date: Wed, 4 Jun 2025 21:13:22 +0200 Subject: [PATCH 70/84] Added deepwiki badge --- README.asciidoc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.asciidoc b/README.asciidoc index e1f41e74d..6e5c52ce9 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -7,6 +7,9 @@ RetroShare is a decentralized, private, secure, cross-platform, communication toolkit. RetroShare provides file sharing, chat, messages, forums, channels and more. +|=============================================================================== +| Developer Documentation | image:https://deepwiki.com/badge.svg[link="https://deepwiki.com/RetroShare/RetroShare",title="Ask DeepWiki"] +|=============================================================================== .Build Status |=============================================================================== |GNU/Linux (via Gitlab CI) | image:https://gitlab.com/RetroShare/RetroShare/badges/master/pipeline.svg[link="https://gitlab.com/RetroShare/RetroShare/-/commits/master",title="pipeline status"] From 553761fb7c792d69ee795482e02ba968c15cf2b1 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 5 Jun 2025 23:15:24 +0200 Subject: [PATCH 71/84] updated submodules to latest --- supportlibs/cmark | 2 +- supportlibs/rapidjson | 2 +- supportlibs/restbed | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/supportlibs/cmark b/supportlibs/cmark index b9c7a496b..3460cd809 160000 --- a/supportlibs/cmark +++ b/supportlibs/cmark @@ -1 +1 @@ -Subproject commit b9c7a496ba7dd9c3495bae2ff2855899e47b245d +Subproject commit 3460cd809b6dd311b58e92733ece2fc956224fd2 diff --git a/supportlibs/rapidjson b/supportlibs/rapidjson index f54b0e47a..24b5e7a8b 160000 --- a/supportlibs/rapidjson +++ b/supportlibs/rapidjson @@ -1 +1 @@ -Subproject commit f54b0e47a08782a6131cc3d60f94d038fa6e0a51 +Subproject commit 24b5e7a8b27f42fa16b96fc70aade9106cf7102f diff --git a/supportlibs/restbed b/supportlibs/restbed index c27c6726d..8b99a9699 160000 --- a/supportlibs/restbed +++ b/supportlibs/restbed @@ -1 +1 @@ -Subproject commit c27c6726d28c42e2e1b7537ba63eeb23e944789d +Subproject commit 8b99a9699172cc718e164964f48a1ba27551c86d From 5361bed037cc0401b4ad01b4e68bfe81e829aba2 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 5 Jun 2025 23:22:57 +0200 Subject: [PATCH 72/84] updated submodules to latest --- .gitmodules | 2 ++ supportlibs/libsam3 | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 9a68ca0cb..273336f84 100644 --- a/.gitmodules +++ b/.gitmodules @@ -36,6 +36,8 @@ [submodule "retroshare-webui"] path = retroshare-webui url = https://github.com/RetroShare/RSNewWebUI.git + branch = master [submodule "supportlibs/librnp"] path = supportlibs/librnp url = https://github.com/rnpgp/rnp.git + branch = main diff --git a/supportlibs/libsam3 b/supportlibs/libsam3 index ea52a3251..f90555ba4 160000 --- a/supportlibs/libsam3 +++ b/supportlibs/libsam3 @@ -1 +1 @@ -Subproject commit ea52a3251d60906d67f9a1031a6ed7642753f94f +Subproject commit f90555ba4d6f9fadb6f0fbb1e2253e13557aad34 From 97304269a21d8fb7b59092b0d77382e3b25c07c0 Mon Sep 17 00:00:00 2001 From: defnax Date: Sun, 8 Jun 2025 17:32:30 +0200 Subject: [PATCH 73/84] Added for Dark Style new home logo --- retroshare-gui/src/gui/HomePage.cpp | 12 ++++++++++++ retroshare-gui/src/gui/HomePage.h | 3 ++- retroshare-gui/src/gui/images.qrc | 1 + .../images/logo/logo_web_nobackground_black.png | Bin 0 -> 12042 bytes 4 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 retroshare-gui/src/gui/images/logo/logo_web_nobackground_black.png diff --git a/retroshare-gui/src/gui/HomePage.cpp b/retroshare-gui/src/gui/HomePage.cpp index ff7622b4b..0f153c8a6 100644 --- a/retroshare-gui/src/gui/HomePage.cpp +++ b/retroshare-gui/src/gui/HomePage.cpp @@ -27,11 +27,13 @@ #include "util/misc.h" #include "gui/notifyqt.h" +#include "gui/common/FilesDefs.h" #include "gui/msgs/MessageComposer.h" #include "gui/connect/ConnectFriendWizard.h" #include "gui/connect/ConfCertDialog.h" #include #include "gui/connect/FriendRecommendDialog.h" +#include "settings/rsharesettings.h" #if QT_VERSION >= QT_VERSION_CHECK(5,0,0) #include @@ -135,6 +137,8 @@ HomePage::HomePage(QWidget *parent) : rsEvents->registerEventsHandler( [this](std::shared_ptr event) { handleEvent(event); }, mEventHandlerId, RsEventType::NETWORK ); updateOwnCert(); + + updateHomeLogo(); } void HomePage::handleEvent(std::shared_ptr e) @@ -377,3 +381,11 @@ void HomePage::openWebHelp() { QDesktopServices::openUrl(QUrl(QString("https://retrosharedocs.readthedocs.io/en/latest/"))); } + +void HomePage::updateHomeLogo() +{ + if (Settings->getSheetName() == ":Standard_Dark") + ui->label->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":images/logo/logo_web_nobackground_black.png")); + else + ui->label->setPixmap(FilesDefs::getPixmapFromQtResourcePath(":images/logo/logo_web_nobackground.png")); +} diff --git a/retroshare-gui/src/gui/HomePage.h b/retroshare-gui/src/gui/HomePage.h index aa77ed1a3..3660bdbe7 100644 --- a/retroshare-gui/src/gui/HomePage.h +++ b/retroshare-gui/src/gui/HomePage.h @@ -63,7 +63,8 @@ private slots: void addFriend(); void webMail(); void openWebHelp() ; - void recommendFriends(); + void recommendFriends(); + void updateHomeLogo(); private: Ui::HomePage *ui; diff --git a/retroshare-gui/src/gui/images.qrc b/retroshare-gui/src/gui/images.qrc index de468d270..473fd4844 100644 --- a/retroshare-gui/src/gui/images.qrc +++ b/retroshare-gui/src/gui/images.qrc @@ -208,6 +208,7 @@ images/logo/logo_info.png images/logo/logo_splash.png images/logo/logo_web_nobackground.png + images/logo/logo_web_nobackground_black.png images/mail-signed.png images/mail-signature-unknown.png images/mailforward24-hover.png diff --git a/retroshare-gui/src/gui/images/logo/logo_web_nobackground_black.png b/retroshare-gui/src/gui/images/logo/logo_web_nobackground_black.png new file mode 100644 index 0000000000000000000000000000000000000000..1be6fbdc02e84c942f5c22cd796ee43db10259ac GIT binary patch literal 12042 zcmXYX1yCJL)9&K#E(bUqEV#S71qm*}Eg?7rx8QEU-CY6!LU0N01Pku&?*Dned#7r4 zx3;FHdwP0$TAm0s6*&x4Qd9r{FcjpaKL7ws9Q0ck8S%eAbKZT>7mB02o(ljl^!(Rh zLPC680RUC?la!R2nvH|2gNu!WBb9=b6qTd1gVm=mmH^=KFI&S}Q{#Y8H^X>xF9yD zFg$YjX~VnFcCPJickH!sUUaYOD!X9VI z0AKb}NBDxN278YYDyj5(;T9SJnLq<%7AGVf9aaj4aRnkKd|p#n(+qLe9?x_V&OmOg z^{Y_;$V(uAuJ-E1V;r+)e4ID73DcP6uoLl(+RSY0b!Vc|Q5*m^T>YkAnb{gh1B4I* z>|P6KPvLEh(DK~wqO9t%#2bOUgMT_#j{nImZa(Hk;IlnwFn@0HhEX|O_CvWtPaFz!uD4j#NDNC6Po0R$=aj!3sb}q z>(LZBr<ShfId(!!M^BaSdHbJF=I zsYo<${@!Gz4c5OnQK_LJ6WSHZPL+?Y@N zaEHeYl<7j@g?E>vGNq7^*HzY4S&%QIBB$ZT`G>-X0vD{_LrAlfES$R^dmH<}~iK?6my{$N_VCCbv8(Bx&fMg>5~O zz;|XUrooWy?Csudu5Gey@TCE2wwbt7(Y?kd!-wI|iX=POJKQ^nmT8<4T7?-OR?6}< zad_hNC9CtBKGdp*mEm!_WeAJ~5h^GZR~IDDklGO0+imrTaUrdeK5Qn6Zrrgfz?q8V3iq~Tj5tHq_URgUsErBbURTkS}LOvAcds4T3) zy39dStjJIAB?3{eSGiYJsz^QWhw)ZhKNXreNrMM7*cPKQ)Gd&wkM76VqR&^x*0dK; zYm`VudA@)Ymm-%=!-uQyR$@q7X-@Z9t|};d45g`8evzyAXYV%Ok(F>Ow{Tb*+E%2b zrs!76SE^Ua9kuh;oRnslw9B;WJq2P)3@FkY(#u)LjU#05X)J22l%kdrz84X^sbQ_K zEhfuvm3Hs6FFj4m=`ae&QFbU@^=#jJB===|(R{IcEWMFK*F|hVr$JmoA14<6!{g*2 z3}PEtx=@$;*efnoY?^GEx)GevG9_F%D;pz=75%B-aEoTkuHUY|kPeX!OsDkz@cn7V zhxaWd?@EM}g_H-zM#l=q=F)jGML6a;_cHe~=QG!uP4qqVnVZU*epxEiZ|j%noi?@E zhv*CF73*s0e{7Jg&aS4NYprfA#VKu3Nm8lInX~S#yJ#9}DsLvK+gU(ds%f%o@-?+K zBeHJ(Q`38z)Sl$~+c)M#1PLQ-5wjAc5At*Q>5MO^Ex4L7o^>kb`{z34fX!NW0()YC zYpV%wmtrIcp;87MGx_@Tdr-ZzHU!qO6%@{VRj*+lsC?P9HbCrf;${8!~%N z%9d(Rc~3u`hAroga_7Fw(c^NN>>ZR^SKpZuL(5HOw_U69QA+?k#ciQbAj=WdB^3G=OTuId?&@^v*2Hjk+GI^-CKtV#Jp-Ynj{-ll-k09qJp zxQIZBKm*vPdoLewXRMgulI3mv;)z6bUW){QMBKOPZ#&)9V4K0?_-gRoUfOuV_$SN| zHNXA2NhH%<)2LoQbo!965S>u5SjTW((kYHq9`~tbDVH_rN9h#l)l6#+Re@R-MIJ`c z3f9lU|M-4${}$_KwbC1%)y>vb_@YEEz{*&|YyYKV?fK*?Y%_ZkZOfY|jcxFwqi6nj z&vi&CVL2-4^?J*Yr{lr+){&{k9E3?Fw zI>xZn8q_4!QrIc{tIe`>XnagaOtVPyTJuqp_jG!t(RBXae(IFWyX}_ycy`I4?e0Z% zsAEYBM(h2o)vV={!c)VYSWQI5!F|e;-N$MbJExNYxM{c-BnW2He9PZi(6or=hqyVW zBRR|g%8u9UGj|pYUJR|6to}`iqqOJt!5zxl9R-Hqzpv5WRU1e%lwU#CAhyqv8J8Kd znHm{S24)7oRYygq<_=fAp5>M(v9h>@^*j}?G>1O@JNPz}WPLdiot>QR>&N=AY_e3) z&CRqThyLVo6xx70ic2S{L2v zPpjKh+l;TpPb3zlR>Ee*3|^NP&X)Z@ce&?XO)bmaA%+A^ye8blVM!sxrN@ngVuT*$ z@QVrvY>GL*96XmwO;}9OPo+)er(UKeb=vt9zZ`ZQk<>2r z_w-YA40&*I7+q^Wopie|yMxXO*RWK#eW?5y-fSLz+-OXeJ|&SPCB4DJrCmLnbFnNz z{Y@%!`48^_z>5|D0)hbG;SKse001|305~)O0Kqf>AaY1F{v!(jG&~B@5}F?Wj(xp- zG-q3G8}4X=9Vu&^33^z>rA_M);F$z3$_B6qvOPp7L`sq>JS6_n{mXn2&Y^qhm@ukp zjJVLPY~+Z_@%oFi-(5zqlYiEct45C`)YZUNJz znFv)HIWRalxNi~h4;-g5f+IqJ48RJ<{4AZSzsHIl9ZI(9Hoov2JB%S z=>wFe9mO!ZWPwhYbD_g(`OA1{41-P|EH`8h z6EJ{-rRs@58XyLDzXpiLZ-b$219X{&uucM830J{MiX`j+ukZdxtzd7^oXT!$EiMO5 zRj;7dpP}TV7eW7cS_}?eNuR7rnzPN|Ajgwt?r$~?EwQV2+bg_{I&M?aJ7qLjC@3fq ze-q_IH$gLdo{f{{toNv_OwWWRqn)tn>FMY1P<<+{rbfKQyCCL3YX9UxZo&J&fZ<`;!%?r>6YIRAp3erRNFWyPazx9-mO{}EE47}^r< zd%_^}YRrR_jQ1r@r>;{9)Q~BZeH?@>DN4*|T=J=Ko{cg8-kvB-LqjvJ^=kvH4Ajky z^l^M~rm%lpJlYpCLq|qN&Zm3?Q2{Ti*l+)K#I8O<(j)@hE59b7)IZ8Y+oe3ZCol(- zc03DvOCn4@|F*_xaYJSyk9^F#9}9c%JV05B6RqQOzh&?wPpKCIr9|V&-zy9p!9-tv zIlxEI5q{*Zf9d^#6Go7}-+_W5GxjB7qqH7X;lH`-;z$5(fOvhU=e@2YPyffZ!Re%Z zWXm6K2up%0`+Xv{Cy)k9og$-{~;*5REQd2jj zf6jgNV*W=w%^V2$3~aR-)#YngnVlC2Ye?>I$}FIp|5##py-Akkl+>n$Zj=H=|2^&I zk(~#{p0RVxi5~_|x~s@IRWyN|tSp-$ePtq4HCuwwkp@=L)^E9rO?pelPPt!EfBVr( z*Hs@msWGH80C~u9Gx-3~a0LxipN0yBtYAG3l^GYhek5(C7?}!3U~bi>;mW1j6$z!g z26y3md44;H800^Bu-gH8Sn-=-#UTOz9(&qITj_VS=Lp~!-cLaW_bi91tCSw1haP)` zLt3rl4i~yzfB-YVuN!O$6ab8eXjcXHs|FAncq$}uWN~pvd5jnCibz~154#S(*|NyQ z+@dxg(6A0cF@7cH1k_ugj0OgxOk;6N7X1B{l1)3oO+$55Co7*`!Jy7ID-aW} z56Dy$cdZW2L}#5d^6&-MOw&~Q~2R^nMy@BpI;-QY1Np;2%`RxFg! zikp-+v{1JF;4YiAl8n&uWljrgnm{#NjEw!Jo=P_rh(#=sFhuIo!xw94sr4wSGbW4O z6T9%-zAqogWIcRJSM8iK&3(q-CVP8IR#-8Pm?|f6ooN0&9Fm z#&Wh%4d}TU_Snq3t0{ik1sKHJ;Iy`39$2E)#ZAJgD+q4VJ ze+RQ87_2(xQH5hDSW+t(2r3GQ=L8OAZW(?Pw=zol_%B4E_RW(`Y)3#!(sAVW9E@vM ze|>$3b9^aOl~8|wTwYNy|G>q*ULhH6s2!1&TRo6wIbpg#dq?H{9F2K_JEUM~|15)t zR6UdAI<972gJ81M&jYYybYY0ttbYdZQP7pJaYZW34_nSdTXDLwpmu^2=`QXs(eC@A zYKsJ-^`c@>e*aK}1QRySAPI5(rqJ*Wj^!5yhHVr$5WSmf$NWd;)=O34Fb^aF>Aw6V zsW2pJD$Lu37CwK_+hrG4>#F0Rjm4Ppw^#R6(}g%~)BR@S{;ogJi2uf{Yknl1UShNj zk!x$Bi2ldM5V0LxzzNyB$r=5U8%k%;-&!<>f0DaK0M)~NlQgbi35CRu0DfGGNj2lN zR5q%3HG9kKbcv1j9BK1MT5Ca1-I}fjkY0o z>VqE`@4S*w?(}hb{+6z{|0GUZFBO+RFC)R=i}-JXNd^UGWp0gK@w3guz57JQ(P*pQ z#j>hy@)+#-EQMc5W1_Hd@m9QvzdBR{>Oo^Nut6V=*Pr|0G4voheqtv+q8e?OVsaGf zRbqr; z1?;)~T=$-u>^qT;!C8ek)V&>6+xd(h@Ll4~5mIX@CzPR{?tMa&25a7U|Aq?p2Qhc* zFX%Hu_e&{Fy=U3ful8B)M<9H8FV~;CTcqWYSG0-#ijbcg8Oz4y`8<52(r=z>X$A%l zBf=DoPow(nx58Rpm0X3+y6>-Cz5OqZ=K)Q=?6(sJO6}dONr}gxZ9q_5-ff|fG zQqRc;+BPC{ZhT$t4;2})J%aS&?Z|Um6$I!5J2%@Qu`WLdqX)*n{B&4sI zg!QJgw!l*{gJJaBKGVbBM5rHo?ZWW_z0 zaf+2WTEqD3yed0M^;feJ=RPT)xo*B{UIg_k5Cfvj1 z7ro}@|;mHku{?U|gxyBNlItGV++snBqlKu8^iy@98cwR8NIrZ_8`pJaS16L-zYYnFNEW$gdGuGsJ3CP zm@J(E)aUf89L7QH4S&^pOJdr zbEL!p0=)Gd^+VVrpTdha(eIS+Csq6U06805V=+-V2+cNkW!+MLCQ75{X8ZUgGD%5s zAir5~-rN4TyMhn}0wU&78o?BWNVo=NXWSepbF%(Qq%YPtClPi)U)6ksNp-7NUVv`2 z6&G*UD3F7Tt$%$AZ?aW2*F*RC?>qAQDvGDCU%JEmV@&2#V&wC>e;`pQtq2b2Ddk6CgpqMt(k1h1AD48Hj?7&)c-eF{rSG=VE` zyf{IadwTxU{m>~xCF>q;K(?4%EJ(uk8ZgUki)+fx#1{I+v=cJcaV0l-JGXV+T1!3m zl{B~JW1#AM&Hh5}tOKAzDYiRz!g`o*txqk2S#C}SMi${NF103lZ^ccW$QTn(+Q)U| zC3;aprAgE%;V0|~y;hyQ9Ce)|=09v$+rZP{ut~belV`|cn?Jr&(H2gd`^E@0n{M6n z0eTV^AHS06zx_b9GpNK_YR9l~Kmhn6;DC~nA0C$BaoY+_&c)mun#KW1tX9v}i<*AG(dRpjGO3<~bqE`i*J@1qAjDDI`< z((M-X?1T8te)E}0l9Ph@zvh+i={j#RTU-xEhUFrn2cAvCUK{BG1&xreCPY8kFav(( zNZO9o;ymq*=TKv5Y}wUeN+XDKU`7X^M}(N~d!TPT!VfIkrvx^6(HGcS+YpPxfn*ssSU{zaVt6rU z#>1~t->ha?^1KdGG)6`m>ORRe8WgdR{@981i#a3*RUEy)42L=Tf;F)t-yhB|y{Z@u zARVrr>0Pcz1UmF#wA(h0Kh%2v@Dl2_JI% zfC>&C($%N81vlrTRO&6lVgeRMcKf~2=nZ_la5BMNAZRN^2o)S4nCg=#VXBdiRZ#>7f&EZ=! zIb#wbHT!SsU)@eL80&Ku^}eWc-*}Jse`dKk>w|qT(L2wJ>?$5a+u*;yNro>na9ps> z6kT%=&ps7%uMvP`k00*z5dw;58r&U>)EifC8JJ?O#M8{p=^*u&r@FBu&7xVilDCPj^E=D$7g{q0-OHvTY5M6KD#)2mW!(9EwR z>lv=0ftmb3$u_v#I5-~q8#!ezM*6qS<{V{fVjZqGat^iJV9X$OZE`25-*Ub>e7!^| zaXNO8xs~9y>TyjWIQ*U8r{dep%~|p0E&cQ)XDsQjmSRqy9THF~aNdIa|fCTfF({}~v>zFIwi7FzQA z1Ncpn_~nT*6ItFOBwhZ%{3V9{h8nQSIe&NK3d)nlL?mO z*K&5ZWFEBPwie-xR#(|#W6R;wCC!(CH_s@=eG+p|unA9?$_an&Gqqh;p(j$&W$Fiu ziS3}tOm)ysbj%-`ar${&qx9#b^IF_S26OEuAod9DN|EYxly$7S3Ie^r{uCT-YtQXW`eq`88pw6b zE@KL&igTY8DME@QAVs(a%Ye2LkfDd*K|&TM17xH#ns2DC)A@X+3*!L z!-bs=+>krruWsf0w%Y6Iv<(;iccfEjB~58BAMEzH~xhA7ukGvIAMOL z!I`P1&oN3Gc=f~S5k@bF#IbeL&Djeb90bh{aCK~B{VdeZwNt*DvC>!vzn~!-u&Mi% znq@;kWlpM8)*f?NPri(q;33fvSq}kWdtaN^aLVn&DU4bz)Z^nh^7M%wPiEP~qMnNd z&DNUB-5d=buOLB6#`^Pq;3X_N0OA1}0~t6gHyj16?ghzo1k3HG6KSPnyh{GYjq?m&bZ#qRZ=UNY-Z4_-F)OMNA_iSZF9W|OE4S`kgo!f4X122G#j7E zl5@Z~?fWvB+xuXfr~En!M9=Yzu$1%kzVgdz((UJ!I6jU*Qk0@E7@u(#cpMfItYI6C znj_jxo}4to>HBdKt1Y@B29+t>T8wPK|02B6{2cj+5SXgTvsy;Q4xI>y3}~kgIdG?_ z@GUU0qi+1>?>>_#T{|i(OMXR}=&0ZQyXe<{ZlJz=lyIr7N4X3mf6}Kl54wY=r}`(e z?yE*MpN?MxFe@|R1FkoA&}w#m{$*?Vgh{aWg*5;QMr2##xBY2%+V zyC0b7h-g1+o3fNn!ExH}3^R783}xwHEBD4q|4$?>71-n}DTxmt(g1gh8)!a_-yos; z#gC}#6QF00E59Vt_iqrN(28hd|- z*LpPdwMu}%YXx;Zyvhi=fW62)C){_)&DboVClfwoPxG%+giiaWH4<;me28qG3l}e5 zSQLSQ=JaF}%%y9El+{YfMmi%Ev|z9kYXTDR{EmQ+S|42~m!-ek{S80&2@G{o^UQt4 zUss4d+8Z?KdfD`C1bYOVs>hgr7U7n}jNnmB`{os8XJMJnO{jPXAF z4BH#)b?3Mr=btMpwx7ogI{yqVWPBB6$xmV98JHe$auxJr?u8Sq`UWJ$+h>v1&jv(J~F3y$g~^I!GA@!a;;pVl(|W`iW(ja>0DJ|^)Mw%fAs-D zvxg9koTqT*iu?HO@BZ@R{$H6$o<{uRrzXCDA^tx?qCFnZiq1BXs%mQ)EH0E9i%cx> zP^!OB=M#7jzGu3PCtLd`mD1K2wtPNk@7$Z&Iz+4b%&WEYWJ=US(>GKaiTz>tc~u$t zV&<%v2J`mb%1R6wyt6Do6};^@kc?JS=#T8q3J%7fIfL=aW;`V~sv&0#QYSeXEITU5 z5-JJwdxmYv#5kQdQ8SXfyI6`k=wNqu&?Y*jXJBB%`7Y;gBtZAur2?Y8YG!Xx-tDrz zgFS>zxG%sw8Rf?!c>_dU_7og{dB_@68#NqpP*XjbTMX!KxJA33pd?y9{FZE}_07E| zk|~#LqK9p=G5I)!ayCHNNU^w8>L>B7@EvgmU)#HLepj|&15_Qz;P2Ja)uuKpk3xb_&H0s+t$d?XUiOnuAlcPP++NumwrybbN`WbfueD;ab}OW zXz82b!|0{J58G&Igd81#S>NwMrQc4s8V-4eRAAJ)ZJ?j z4pMMm{@Zxlv&wZwbKm*zLfBM&+%Q!I63;65a|PTzKF)mHZ1PdHzLqW7(AKWvOBqvP zw14ufG*sqk6nF%h=dz~=*BTZoz&k5O)>q({0~rYq+p4@pc7*uu^`4p7$h$ z7Pnc7%C{jTQmmh=!jZL8m41pRCq=g+C=ABSi||x5;Cvp0Blpy#QNNRM=9#u7y>YMzB|Mvw8G;!M4ym5Um&GQk>j{%vO`;cZNl2OPT8(+W@z5h**qP{g1PLd{GuL9yM(?wZ_#PWWAz_C!F4fPSOZT-wy<1#w9M$41r9q0ZzK9A zs6y_y>?r)LJ*2T%zuDXt&_>Gv*`~c*Yh+5V@FiA89~?zHODF6%Fy!y0(B%gO4@v2) zzq(=%b{qQ>4e(YU|I-`Ckvr~F&+@nx%`&<`gXUKBUXV;z`TPQeDw@_S=>3DD>^ms; zCNK&nfXZK+;gPy8|`C{dN7$Q0w@sWWR?cU*@ZetZ)NI8 z7I}QG#Zf=EkPxvh@UU>SyFG{yTvCTZLaqd zQHZ*eK-nIQTKf}$^*WvImI{u&-G|A#U;G%(V-Eu;w_nmNzfL2LcI^0FlW{I{O8+?% z^0aYaRJ;gQnlG0T*87OyoA(^WpYXu#ytk;AD)?Cq{DLT3|IH~xiZ1kh>N_*_Ch|-{ zWa4F}Fx%`MwU!&6iXhE#@|xl_2*2E!95Nbu@LHg{12=z30%>p_T+nA7Ij_MAa@Tay zsJ*SCSD4K&t$wG(9c{F(#w~E>Me~^g3WIr44ju@0huu};KKnzJOmlgJt--QtW#p`fQ)ceM)uJU2aNlZSN$ZxeG_cS$+s}1{n z9%CvfkJR~lF%FuLf zvD97LAcPimQp9MqBmS#}g$S&=?w`Ry9d?!%&M0j+h&4?QA)DIYE-J+LMkc&ITAyd~ z7H8GNQ`GZwVWC+`0_93gO}WCXoab+Qlp(*~deLK)NwS84aT~#p6Vce4n>7SJKTxXhu_Ea!8w|7ihM?CTi_jhQXVb~+2iQl_+20AME(71W5LK|w_N#lz z=|uIdrl@Cy0;|o+cj#C^LY&%a0#O3yx+)WK#2)yM;W$j~2m-#qW@CZpBAl`kD^fOS z6DP_gO1Z6F+I3s*?v-Q;0B$M#GQl`=24*O#x%8SQrt)sM=k)6cGI-wu?{0^`%xN?T zj(F7*VD@PSIU4U%T_t!z_O6t(4zri?gTHqFro$iMLpLD2%m3>ok&#*(gO z8TGSs`H76~mj|vE2EKC%Xo;;k`W)okaEWa->W9gR~>??&hpf}WI95pWor^8z4K2$ayim{6o z^6Rct!V%Q!tmX6@nJy3MRSzEFDwLFb(EiBWJ>~!hXaa~MTqU&fEpFfh+|bQgpBYb| zXBEXS0s~yDfCba6#WkwzBlk&!k+Hd}Nwbsi;HwKyDapdxIT&5|B$5Yb5ol36q5E{9G?|)PR1RrpMcy7lVxa4&v(j)-V6tDhy1~NNBdua8u1dKjY~ej zcYL+G%fJgzG8&Aoba1K&q!UYn;xUyg!SvD(oit!6eKL)S*KK{lp;G|DFeuZOq+~#LWScP@On&xrU z`wv^dOpOKbE23CfGlq}}eDeA%j1lD9OQ+0(xAzA3i=;lt5IU$}iF8+`j;PD$A8Bqb z>PCJ2Q&%Zt9>l)2N=gNJ^C&4uFVk=>Y&`$h%J@t(%J>nV#jga0PMNl#w)fg3|A}II z5H1``rychqJx!;T#jy7HnBQ|>x;p{RM1?MNk0f5L>gK0>bS^{`M=fbq21=0{lP^&y z8*l^#zoH~c2mh3e)=a@P8qh4rYVJU3>2YzszznYvvT*m<%;5=Zuu=!Yj zza^b~6v5(Bg{vbd;1oI=w5B|2UXAd0>(|zk`L96!Vav151Fh=|Q27xY7wW}8lak^| zQ5xqP*qeJo1LVjFi~OX){EumFsC#}41I1)J7uMe%PI?1^0_W0$a$fo^I`G zMHG?skn^y+ob-79n|WG^qKYUn%)?k-seowl{86c9Z0Ecjl@tB;Ju34roS|BH256n! zNkv>?#y1r17gkpqLz*?9`yBYZ3lK#b7oF5$Hx_)@%QmG|_MN1Xxf1%YX z1PdgGt;)zx(gh22!k)LxDlGA}2l3Qu3u3A-F5mUF&(zNkR!~8CGNp_}vQUFDL|%7( z)B{Wa|9CbC+**|fhRY?9`xos;=ACeKga08J ze-wHeZY;U7IqY&M>rms~~li{I>!XfEyf9trr5Hx(+Vl+dA z|Djj5H(;HfnP^fGz4VWsbD zTp%N#!cGoMhrotR>rNR6p|}L7Ki@-I9m@(N|KDJSX(UwH173EMIT*9y3L0& zQs6HRf^EH4+ij=pJ9_Ufjl@P}=mDteeM1Kd&`)oFNRzBX!A5|BjEZ!Pq{+Ac101`; AXaE2J literal 0 HcmV?d00001 From 751cc660a6b50da6c60a8d10d26256abb53fa7ee Mon Sep 17 00:00:00 2001 From: defnax <9952056+defnax@users.noreply.github.com> Date: Sat, 14 Jun 2025 14:39:12 +0200 Subject: [PATCH 74/84] Update MacOS_X_InstallGuide.md --- build_scripts/OSX/MacOS_X_InstallGuide.md | 33 +++++------------------ 1 file changed, 7 insertions(+), 26 deletions(-) diff --git a/build_scripts/OSX/MacOS_X_InstallGuide.md b/build_scripts/OSX/MacOS_X_InstallGuide.md index 4b3f6a8c5..1d3b2faff 100644 --- a/build_scripts/OSX/MacOS_X_InstallGuide.md +++ b/build_scripts/OSX/MacOS_X_InstallGuide.md @@ -2,13 +2,15 @@ ## Qt Installation -Install Qt via: [Qt Download](http://www.qt.io/download/) +Qt 5.15 is not available as install package. -Use default options. And add Qt Script support. +Download Qt 5.15.x from here: [Qt 5.15.17](https://download.qt.io/archive/qt/5.15/5.15.17/single/qt-everywhere-opensource-src-5.15.17.tar.xz) +Instruction howto Build Qt 5.15.x on macOS: [macOS Building](https://doc.qt.io/archives/qt-5.15/macos-building.html) +## Set the Environment Variables Add to the PATH environment variable by editing your *~/.profile* file. - export PATH="/users/$USER/Qt/5.14.1/clang_64/bin:$PATH" + export PATH="/users/$USER/Qt/5.15.17/clang_64/bin:$PATH" Depends on which version of Qt you use. @@ -32,11 +34,9 @@ In GitHub Desktop -> Clone Repository -> URL ## ***Get XCode & MacOSX SDK*** -Install XCode following this guide: [XCode](http://guide.macports.org/#installing.xcode) - To identify the correct version of Xcode to install, you need to know which OS you are running. Go to the [x] menu -> "About This Mac" and read the macOS version number. -If you are running the macOS Catalina >= 10.15, you can install Xcode directly from App Store using the instructions below. +If you are running macOS Ventura 13.5 or later, you can install Xcode directly from App Store using the instructions below. You can find older versions of Xcode at [Apple Developer Downloads](https://developer.apple.com/downloads/). Find the appropriate .xip file for your macOS version @@ -53,26 +53,7 @@ Install XCode command line developer tools: Start XCode to get it updated and to able C compiler to create executables. -Get Your MacOSX SDK if missing: [MacOSX-SDKs](https://github.com/phracker/MacOSX-SDKs) - -## ***Choose if you use MacPort or HomeBrew*** - -### MacPort Installation - -Install MacPort following this guide: [MacPort](http://guide.macports.org/#installing.xcode) - -#### Install libraries - - $ sudo port -v selfupdate - $ sudo port install openssl - $ sudo port install miniupnpc - -For VOIP Plugin: - - $ sudo port install speex-devel - $ sudo port install opencv - $ sudo port install ffmpeg - +Older MacOSX SDK is available from here: [MacOSX-SDKs](https://github.com/phracker/MacOSX-SDKs) ### HOMEBREW Installation From e146706a97ed86724233a726a553a3ea45fd2b35 Mon Sep 17 00:00:00 2001 From: defnax <9952056+defnax@users.noreply.github.com> Date: Sat, 14 Jun 2025 16:21:32 +0200 Subject: [PATCH 75/84] Update macports --- build_scripts/OSX/MacOS_X_InstallGuide.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build_scripts/OSX/MacOS_X_InstallGuide.md b/build_scripts/OSX/MacOS_X_InstallGuide.md index 1d3b2faff..b63b12185 100644 --- a/build_scripts/OSX/MacOS_X_InstallGuide.md +++ b/build_scripts/OSX/MacOS_X_InstallGuide.md @@ -55,6 +55,10 @@ Start XCode to get it updated and to able C compiler to create executables. Older MacOSX SDK is available from here: [MacOSX-SDKs](https://github.com/phracker/MacOSX-SDKs) +### MacPort Installation + +Install MacPort following this guide: [MacPort](http://guide.macports.org/#installing.xcode) + ### HOMEBREW Installation Install HomeBrew following this guide: [HomeBrew](http://brew.sh/) From 1d4e997df213b2cd9cc8be6f33ecb324f6b74d07 Mon Sep 17 00:00:00 2001 From: defnax Date: Sat, 14 Jun 2025 17:20:19 +0200 Subject: [PATCH 76/84] Fixed frame to get styled on system theme --- retroshare-gui/src/gui/FriendsDialog.ui | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/retroshare-gui/src/gui/FriendsDialog.ui b/retroshare-gui/src/gui/FriendsDialog.ui index 02408e382..a8e8217fc 100644 --- a/retroshare-gui/src/gui/FriendsDialog.ui +++ b/retroshare-gui/src/gui/FriendsDialog.ui @@ -102,7 +102,7 @@ Qt::NoFocus - + :/icons/help_64.png:/icons/help_64.png @@ -132,10 +132,10 @@ - QFrame::Box + QFrame::StyledPanel - QFrame::Sunken + QFrame::Raised @@ -401,8 +401,8 @@ - + From 1190e45e6b84b53d0ef60f9e80f9df9dfe4bf355 Mon Sep 17 00:00:00 2001 From: defnax Date: Tue, 17 Jun 2025 21:45:14 +0200 Subject: [PATCH 77/84] Fixed green color get more contrast on dark style --- retroshare-gui/src/gui/ChatLobbyWidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/ChatLobbyWidget.cpp b/retroshare-gui/src/gui/ChatLobbyWidget.cpp index 4caa97706..60ed255a8 100644 --- a/retroshare-gui/src/gui/ChatLobbyWidget.cpp +++ b/retroshare-gui/src/gui/ChatLobbyWidget.cpp @@ -422,7 +422,7 @@ static void updateItem(QTreeWidget *treeWidget, QTreeWidgetItem *item, ChatLobby if(lobby_flags & RS_CHAT_LOBBY_FLAGS_PGP_SIGNED) { tooltipstr += QObject::tr("\nSecurity: no anonymous IDs") ; - QColor foreground = QColor(0, 128, 0); // green + QColor foreground = QColor(16, 157, 0); // green for (int column = 0; column < COLUMN_COUNT; ++column) item->setData(column, Qt::ForegroundRole, foreground); } From 915bf59d2e1823acee68b13125cd88feeba2a457 Mon Sep 17 00:00:00 2001 From: defnax Date: Thu, 19 Jun 2025 18:33:51 +0200 Subject: [PATCH 78/84] Fixed frames to get styles on system style --- retroshare-gui/src/gui/Posted/PostedItem.ui | 18 +++++++++--------- .../src/gui/feeds/ChannelsCommentsItem.ui | 8 ++++---- .../src/gui/feeds/GxsChannelGroupItem.ui | 6 +++--- .../src/gui/feeds/GxsChannelPostItem.ui | 6 +++--- retroshare-gui/src/gui/feeds/GxsCircleItem.ui | 8 ++++---- .../src/gui/feeds/GxsForumGroupItem.ui | 4 ++-- .../src/gui/feeds/GxsForumMsgItem.ui | 4 ++-- retroshare-gui/src/gui/feeds/MsgItem.ui | 8 ++++---- retroshare-gui/src/gui/feeds/PeerItem.ui | 6 +++--- .../src/gui/feeds/PostedGroupItem.ui | 6 +++--- retroshare-gui/src/gui/feeds/SecurityIpItem.ui | 6 +++--- retroshare-gui/src/gui/feeds/SecurityItem.ui | 6 +++--- retroshare-gui/src/gui/feeds/SubFileItem.ui | 4 ++-- 13 files changed, 45 insertions(+), 45 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/PostedItem.ui b/retroshare-gui/src/gui/Posted/PostedItem.ui index cbf5ae7f4..ad37a936c 100644 --- a/retroshare-gui/src/gui/Posted/PostedItem.ui +++ b/retroshare-gui/src/gui/Posted/PostedItem.ui @@ -44,10 +44,10 @@ false - QFrame::Box + QFrame::StyledPanel - QFrame::Sunken + QFrame::Raised @@ -725,17 +725,17 @@ + + GxsIdLabel + QLabel +

gui/gxs/GxsIdLabel.h
+
ElidedLabel QLabel
gui/common/ElidedLabel.h
1
- - GxsIdLabel - QLabel -
gui/gxs/GxsIdLabel.h
-
ZoomableLabel QLabel @@ -743,9 +743,9 @@
- - + + diff --git a/retroshare-gui/src/gui/feeds/ChannelsCommentsItem.ui b/retroshare-gui/src/gui/feeds/ChannelsCommentsItem.ui index cd0265c1d..db4ac6b1a 100644 --- a/retroshare-gui/src/gui/feeds/ChannelsCommentsItem.ui +++ b/retroshare-gui/src/gui/feeds/ChannelsCommentsItem.ui @@ -6,8 +6,8 @@ 0 0 - 755 - 157 + 836 + 160 @@ -35,10 +35,10 @@ true - QFrame::Box + QFrame::StyledPanel - QFrame::Sunken + QFrame::Raised diff --git a/retroshare-gui/src/gui/feeds/GxsChannelGroupItem.ui b/retroshare-gui/src/gui/feeds/GxsChannelGroupItem.ui index e17f53c48..43537d061 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelGroupItem.ui +++ b/retroshare-gui/src/gui/feeds/GxsChannelGroupItem.ui @@ -7,7 +7,7 @@ 0 0 618 - 176 + 189 @@ -134,10 +134,10 @@ true - QFrame::Box + QFrame::StyledPanel - QFrame::Sunken + QFrame::Raised diff --git a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.ui b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.ui index 578fa1637..d4d41dc06 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.ui +++ b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.ui @@ -7,7 +7,7 @@ 0 0 1092 - 231 + 255 @@ -41,10 +41,10 @@ true - QFrame::Box + QFrame::StyledPanel - QFrame::Sunken + QFrame::Raised diff --git a/retroshare-gui/src/gui/feeds/GxsCircleItem.ui b/retroshare-gui/src/gui/feeds/GxsCircleItem.ui index 7a77f5bda..374e8f84d 100644 --- a/retroshare-gui/src/gui/feeds/GxsCircleItem.ui +++ b/retroshare-gui/src/gui/feeds/GxsCircleItem.ui @@ -7,7 +7,7 @@ 0 0 618 - 108 + 128 @@ -126,10 +126,10 @@ true - QFrame::Box + QFrame::StyledPanel - QFrame::Sunken + QFrame::Raised @@ -317,7 +317,7 @@ Revoke - + :/images/cancel.png:/images/cancel.png
diff --git a/retroshare-gui/src/gui/feeds/GxsForumGroupItem.ui b/retroshare-gui/src/gui/feeds/GxsForumGroupItem.ui index 152d4951d..aee325282 100644 --- a/retroshare-gui/src/gui/feeds/GxsForumGroupItem.ui +++ b/retroshare-gui/src/gui/feeds/GxsForumGroupItem.ui @@ -126,10 +126,10 @@ true - QFrame::Box + QFrame::StyledPanel - QFrame::Sunken + QFrame::Raised diff --git a/retroshare-gui/src/gui/feeds/GxsForumMsgItem.ui b/retroshare-gui/src/gui/feeds/GxsForumMsgItem.ui index 89aec4e1b..4a080effb 100644 --- a/retroshare-gui/src/gui/feeds/GxsForumMsgItem.ui +++ b/retroshare-gui/src/gui/feeds/GxsForumMsgItem.ui @@ -99,10 +99,10 @@ true - QFrame::Box + QFrame::StyledPanel - QFrame::Sunken + QFrame::Raised diff --git a/retroshare-gui/src/gui/feeds/MsgItem.ui b/retroshare-gui/src/gui/feeds/MsgItem.ui index b195e80c6..cf0a3ac08 100644 --- a/retroshare-gui/src/gui/feeds/MsgItem.ui +++ b/retroshare-gui/src/gui/feeds/MsgItem.ui @@ -6,8 +6,8 @@ 0 0 - 707 - 180 + 777 + 234 @@ -35,10 +35,10 @@ true - QFrame::Box + QFrame::StyledPanel - QFrame::Sunken + QFrame::Raised diff --git a/retroshare-gui/src/gui/feeds/PeerItem.ui b/retroshare-gui/src/gui/feeds/PeerItem.ui index 603002f7f..2433cdf09 100644 --- a/retroshare-gui/src/gui/feeds/PeerItem.ui +++ b/retroshare-gui/src/gui/feeds/PeerItem.ui @@ -7,7 +7,7 @@ 0 0 476 - 283 + 328 @@ -38,10 +38,10 @@ true - QFrame::Box + QFrame::StyledPanel - QFrame::Sunken + QFrame::Raised diff --git a/retroshare-gui/src/gui/feeds/PostedGroupItem.ui b/retroshare-gui/src/gui/feeds/PostedGroupItem.ui index b525facb9..6c043972f 100644 --- a/retroshare-gui/src/gui/feeds/PostedGroupItem.ui +++ b/retroshare-gui/src/gui/feeds/PostedGroupItem.ui @@ -7,7 +7,7 @@ 0 0 618 - 161 + 195 @@ -126,10 +126,10 @@ true - QFrame::Box + QFrame::StyledPanel - QFrame::Sunken + QFrame::Raised diff --git a/retroshare-gui/src/gui/feeds/SecurityIpItem.ui b/retroshare-gui/src/gui/feeds/SecurityIpItem.ui index 11a742880..53f4172b9 100644 --- a/retroshare-gui/src/gui/feeds/SecurityIpItem.ui +++ b/retroshare-gui/src/gui/feeds/SecurityIpItem.ui @@ -7,7 +7,7 @@ 0 0 763 - 185 + 205 @@ -38,10 +38,10 @@ true - QFrame::Box + QFrame::StyledPanel - QFrame::Sunken + QFrame::Raised diff --git a/retroshare-gui/src/gui/feeds/SecurityItem.ui b/retroshare-gui/src/gui/feeds/SecurityItem.ui index bc0524d18..585c18e00 100644 --- a/retroshare-gui/src/gui/feeds/SecurityItem.ui +++ b/retroshare-gui/src/gui/feeds/SecurityItem.ui @@ -7,7 +7,7 @@ 0 0 1015 - 246 + 326 @@ -35,10 +35,10 @@ true - QFrame::Box + QFrame::StyledPanel - QFrame::Sunken + QFrame::Raised diff --git a/retroshare-gui/src/gui/feeds/SubFileItem.ui b/retroshare-gui/src/gui/feeds/SubFileItem.ui index 8fdd8230d..d869fc7b8 100644 --- a/retroshare-gui/src/gui/feeds/SubFileItem.ui +++ b/retroshare-gui/src/gui/feeds/SubFileItem.ui @@ -29,10 +29,10 @@ - QFrame::Box + QFrame::StyledPanel - QFrame::Sunken + QFrame::Raised From c05f6f5e52c1c3ab715c2d7710d1f7211fb299c7 Mon Sep 17 00:00:00 2001 From: defnax Date: Sun, 22 Jun 2025 22:41:35 +0200 Subject: [PATCH 79/84] Moved background image to light skin *Moved backgrund image from login & profile creation page to light skin --- retroshare-gui/src/gui/StartDialog.ui | 2 +- .../src/gui/qss/stylesheet/Standard_Light.qss | 80 +++++++++++++ .../src/gui/qss/stylesheet/default.qss | 106 ++++-------------- 3 files changed, 105 insertions(+), 83 deletions(-) diff --git a/retroshare-gui/src/gui/StartDialog.ui b/retroshare-gui/src/gui/StartDialog.ui index dd037adf4..39287a797 100644 --- a/retroshare-gui/src/gui/StartDialog.ui +++ b/retroshare-gui/src/gui/StartDialog.ui @@ -346,7 +346,7 @@ The current identities/locations will not be affected. <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'Sans'; font-size:13pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="Create new Profile..."><span style=" font-family:'MS Shell Dlg 2'; font-size:14pt; text-decoration: underline; color:#0000ff;">New Profile/Node</span></a></p></body></html> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="Create new Profile..."><span style=" font-family:'MS Shell Dlg 2'; font-size:14pt; text-decoration: underline; color:#366fe0;">New Profile/Node</span></a></p></body></html> diff --git a/retroshare-gui/src/gui/qss/stylesheet/Standard_Light.qss b/retroshare-gui/src/gui/qss/stylesheet/Standard_Light.qss index df6b9d51c..77f53c191 100644 --- a/retroshare-gui/src/gui/qss/stylesheet/Standard_Light.qss +++ b/retroshare-gui/src/gui/qss/stylesheet/Standard_Light.qss @@ -2712,3 +2712,83 @@ PhotoItem QFrame#photoFrame { PhotoItem QWidget:hover { background-color: #7ecbfb; } + +/* GenCertDialog + Change colors here because GUI is not started yet so no user StyleSheet loads */ + +GenCertDialog QFrame#profileframe{ + border-image: url(:/images/logo/background.png) 0 0 0 0 stretch stretch; + border-width: 0px; +} +GenCertDialog QFrame#profileframe QCheckBox, +GenCertDialog QFrame#profileframe QLabel { + background: transparent; +} + +GenCertDialog QLabel#info_Label:enabled { + color: black; + border: 1px solid #DCDC41; + border-radius: 6px; + background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #FFFFD7, stop:1 #FFFFB2); +} + +GenCertDialog QGroupBox#groupBox, +GenCertDialog QGroupBox#profile_groupBox { + background: rgba(0,0,0,10%); +} +GenCertDialog QGroupBox#profile_groupBox QComboBox, +GenCertDialog QGroupBox#profile_groupBox QSpinBox, +GenCertDialog QGroupBox#profile_groupBox QLineEdit, +GenCertDialog QComboBox#genPGPuser { + border: 2px solid #0099cc; + border-radius: 6px; + background: white; + color: black; +} + +GenCertDialog QPushButton#genButton { + border-image: url(:/images/btn_blue.png) 4; + border-width: 4; + color: white; +} +GenCertDialog QPushButton#genButton:hover { + border-image: url(:/images/btn_blue_hover.png) 4; +} +GenCertDialog QPushButton#genButton:disabled { + border-image: url(:/images/btn_27.png) 4; + color: black; +} + +/* StartDialog + To get the same style for all user and not use last connected one. */ + +StartDialog QFrame#loginframe{ + border-image: url(:/images/logo/background_lessblue.png) 0 0 0 0 stretch stretch; + border-width: 0px; +} + +StartDialog QFrame#loginframe QCheckBox, +StartDialog QFrame#loginframe QLabel { + background: transparent; +} +StartDialog QGroupBox#profilGBox { + background: rgba(0,0,0,10%); + border-radius: 3px; + border-width: 0px; +} + +StartDialog QGroupBox#profilGBox * { + background-color: white; + color: black; +} + +StartDialog QPushButton#loadButton { + background: transparent; + border-image: url(:/images/btn_blue.png) 4; + border-width: 4; + color: white; +} +StartDialog QPushButton#loadButton:hover { + background: transparent; + border-image: url(:/images/btn_blue_hover.png) 4; +} diff --git a/retroshare-gui/src/gui/qss/stylesheet/default.qss b/retroshare-gui/src/gui/qss/stylesheet/default.qss index defcc82f8..4b8d1645f 100644 --- a/retroshare-gui/src/gui/qss/stylesheet/default.qss +++ b/retroshare-gui/src/gui/qss/stylesheet/default.qss @@ -141,88 +141,6 @@ QLabel#newLabel:enabled { } -/* StartDialog - To get the same style for all user and not use last connected one. */ - -StartDialog QFrame#loginframe{ - border-image: url(:/images/logo/background_lessblue.png) 0 0 0 0 stretch stretch; - border-width: 0px; -} -StartDialog QFrame#loginframe QCheckBox, -StartDialog QFrame#loginframe QLabel { - background: transparent; -} -StartDialog QGroupBox#profilGBox { - background: rgba(0,0,0,10%); - border-radius: 3px; - border-width: 0px; -} - -StartDialog QGroupBox#profilGBox * { - background-color: white; - color: black; -} - -StartDialog QPushButton#loadButton { - background: transparent; - border-image: url(:/images/btn_blue.png) 4; - border-width: 4; - color: white; -} -StartDialog QPushButton#loadButton:hover { - background: transparent; - border-image: url(:/images/btn_blue_hover.png) 4; -} - - - -/* GenCertDialog - Change colors here because GUI is not started yet so no user StyleSheet loads */ - -GenCertDialog QFrame#profileframe{ - border-image: url(:/images/logo/background.png) 0 0 0 0 stretch stretch; - border-width: 0px; -} -GenCertDialog QFrame#profileframe QCheckBox, -GenCertDialog QFrame#profileframe QLabel { - background: transparent; -} - -GenCertDialog QLabel#info_Label:enabled { - color: black; - border: 1px solid #DCDC41; - border-radius: 6px; - background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #FFFFD7, stop:1 #FFFFB2); -} - -GenCertDialog QGroupBox#groupBox, -GenCertDialog QGroupBox#profile_groupBox { - background: rgba(0,0,0,10%); -} -GenCertDialog QGroupBox#profile_groupBox QComboBox, -GenCertDialog QGroupBox#profile_groupBox QSpinBox, -GenCertDialog QGroupBox#profile_groupBox QLineEdit, -GenCertDialog QComboBox#genPGPuser { - border: 2px solid #0099cc; - border-radius: 6px; - background: white; - color: black; -} - -GenCertDialog QPushButton#genButton { - border-image: url(:/images/btn_blue.png) 4; - border-width: 4; - color: white; -} -GenCertDialog QPushButton#genButton:hover { - border-image: url(:/images/btn_blue_hover.png) 4; -} -GenCertDialog QPushButton#genButton:disabled { - border-image: url(:/images/btn_27.png) 4; - color: black; -} - - /* AvatarWidget */ AvatarWidget{border-width: 10px;} @@ -418,3 +336,27 @@ OpModeStatus[opMode="Minimal"] { [WrongValue="true"] { background-color: #FF8080; } + +GenCertDialog QPushButton#genButton { + border-image: url(:/images/btn_blue.png) 4; + border-width: 4; + color: white; +} +GenCertDialog QPushButton#genButton:hover { + border-image: url(:/images/btn_blue_hover.png) 4; +} +GenCertDialog QPushButton#genButton:disabled { + border-image: url(:/images/btn_27.png) 4; + color: black; +} + +StartDialog QPushButton#loadButton { + background: transparent; + border-image: url(:/images/btn_blue.png) 4; + border-width: 4; + color: white; +} +StartDialog QPushButton#loadButton:hover { + background: transparent; + border-image: url(:/images/btn_blue_hover.png) 4; +} From adc4bf90b59a9b25d3159c834c7777b3a5b8d333 Mon Sep 17 00:00:00 2001 From: defnax Date: Wed, 25 Jun 2025 20:02:19 +0200 Subject: [PATCH 80/84] Fix light skin issues --- .../src/gui/qss/stylesheet/Standard_Light.qss | 169 +++--------------- 1 file changed, 23 insertions(+), 146 deletions(-) diff --git a/retroshare-gui/src/gui/qss/stylesheet/Standard_Light.qss b/retroshare-gui/src/gui/qss/stylesheet/Standard_Light.qss index 77f53c191..40fe0b78c 100644 --- a/retroshare-gui/src/gui/qss/stylesheet/Standard_Light.qss +++ b/retroshare-gui/src/gui/qss/stylesheet/Standard_Light.qss @@ -231,7 +231,7 @@ https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qgroupbox --------------------------------------------------------------------------- */ QGroupBox { font-weight: bold; - border: 1px solid #C9CDD0; + border: 1px solid #C0C4C8; border-radius: 4px; padding: 2px; margin-top: 6px; @@ -1234,7 +1234,7 @@ https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qcombobox --------------------------------------------------------------------------- */ QComboBox { - border: 1px solid #C9CDD0; + border: 1px solid #C0C4C8; border-radius: 4px; selection-background-color: #9FCBFF; padding-left: 4px; @@ -1250,7 +1250,7 @@ QComboBox { } QComboBox QAbstractItemView { - border: 1px solid #C9CDD0; + border: 1px solid #C0C4C8; border-radius: 0; background-color: #FAFAFA; selection-background-color: #9FCBFF; @@ -1263,7 +1263,7 @@ QComboBox QAbstractItemView:hover { QComboBox QAbstractItemView:selected { background: #9FCBFF; - color: #C9CDD0; + color: #C0C4C8; } QComboBox QAbstractItemView:alternate { @@ -1301,6 +1301,18 @@ QComboBox::indicator:alternate { background: #FAFAFA; } +QComboBox::item { + /* Remove to fix #282, #285 and MR #288*/ + /*&:checked { + font-weight: bold; + } + + &:selected { + border: 0px solid transparent; + } + */ +} + QComboBox::item:alternate { background: #FAFAFA; } @@ -1433,14 +1445,14 @@ QLineEdit { padding-left: 4px; padding-right: 4px; border-style: solid; - border: 1px solid #C9CDD0; + border: 1px solid #C0C4C8; border-radius: 4px; color: #19232D; } QLineEdit:disabled { background-color: #FAFAFA; - color: #788D9C; + color: #9DA9B5; } QLineEdit:hover { @@ -2151,12 +2163,12 @@ QSplitter::handle:hover { } QSplitter::handle:horizontal { - width: 5px; + width: 2px; image: url(":/standard_light/rc/line_vertical.png"); } QSplitter::handle:vertical { - height: 5px; + height: 2px; image: url(":/standard_light/rc/line_horizontal.png"); } @@ -2350,51 +2362,6 @@ QFrame#titleBarFrame QTextEdit { background: white; } -/**** Special Page tweak ****/ - - -/* ConnectFriendWizard */ - -ConnectFriendWizard QPlainTextEdit#friendCertEdit { - border: none; - background: white; - color: black; -} - -ConnectFriendWizard QFrame#friendFrame { - border: 2px solid #0099cc; - border-radius: 6px; - background: white; -} - -ConnectFriendWizard QWizardPage#ConclusionPage > QGroupBox#peerDetailsFrame { - border: 2px solid #039bd5; - border-radius:6px; - background: white; - color: black; - padding: 12 12px; -} - -ConnectFriendWizard QGroupBox::title#peerDetailsFrame -{ - padding: 4 12px; - background: transparent; - padding: 4 12px; - background: #039bd5; - color: white; -} - - -/* GetStartedDialog */ - -GetStartedDialog QTextEdit { - border: 1px solid #B8B6B1; - border-radius: 6px; - background: white; - color: black; -} - - /* HomePage */ HomePage QLabel#userCertLabel { @@ -2509,7 +2476,7 @@ GxsGroupDialog QLabel#groupLogo{ /* Settings */ -PluginItem > QFrame#pluginFrame { +PluginItem QFrame#pluginFrame { border: 2px solid #A8B8D1; background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #FCFDFE, stop: 1 #E2E8EF); border-radius: 0px @@ -2521,7 +2488,7 @@ PluginItem QLabel#infoLabel { /* Feeds */ -AttachFileItem > QFrame#frame { +AttachFileItem QFrame#frame { border: 2px solid black; background: white; } @@ -2627,92 +2594,6 @@ BoardPostDisplayWidget_card QLabel#siteBoldLabel { color: #787c7e; } - -/* MessengerWindow */ - -MessengerWindow QFrame#messengerframetop{ - background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #9BDBF9, stop:1 #1592CD); - border: 0px; -} - - -/*************** Optional ***************/ - -/**** WikiPoos ****/ -WikiEditDialog QPushButton#pushButton_History { - color: white; - background: #5bb62b; - border-radius: 4px; - max-height: 20px; - min-width: 4em; - padding: 2px; - padding-left: 6px; - padding-right: 6px; -} - -WikiEditDialog QPushButton#pushButton_History:hover { - background: #57af29; -} - - -/**** The Wire ****/ - -WireGroupItem QFrame#wire_frame:hover { - background-color: #7ecbfb; -} -WireGroupItem QFrame#wire_frame > QLabel { - background: transparent; -} - -PulseTopLevel QFrame#plainFrame, -PulseViewGroup QFrame#plainFrame, -PulseReply QFrame#plainFrame { - border: 2px solid #c4cfd6; - background: white; -} - -PulseAddDialog QTextEdit#textEdit_Pulse { - border: 2px solid #c4cfd6; - border-radius: 6px; - background: white; - color: black; -} - -PulseReply #line_replyLine, -PulseMessage #line{ - color: #c4cfd6; -} - -PulseReply QLabel#label_groupName{ - color: #5b7083; -} - -PulseReplySeperator QFrame#frame { - border: 2px solid #CCCCCC; - background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #EEEEEE, stop: 1 #CCCCCC); - border-radius: 10px} -} - -QLabel#label_masthead{ - border: 2px solid #CCCCCC; - border-radius: 4px; -} - -/**** PhotoShare ****/ -AlbumItem QFrame#albumFrame { - border: 2px solid #CCCCCC; - border-radius: 10px -} - -PhotoItem QFrame#photoFrame { - border: 2px solid #CCCCCC; - border-radius: 10px -} - -PhotoItem QWidget:hover { - background-color: #7ecbfb; -} - /* GenCertDialog Change colors here because GUI is not started yet so no user StyleSheet loads */ @@ -2720,6 +2601,7 @@ GenCertDialog QFrame#profileframe{ border-image: url(:/images/logo/background.png) 0 0 0 0 stretch stretch; border-width: 0px; } + GenCertDialog QFrame#profileframe QCheckBox, GenCertDialog QFrame#profileframe QLabel { background: transparent; @@ -2777,11 +2659,6 @@ StartDialog QGroupBox#profilGBox { border-width: 0px; } -StartDialog QGroupBox#profilGBox * { - background-color: white; - color: black; -} - StartDialog QPushButton#loadButton { background: transparent; border-image: url(:/images/btn_blue.png) 4; From 829a1db710393b045b87432ba4552523ae7dac94 Mon Sep 17 00:00:00 2001 From: defnax Date: Tue, 1 Jul 2025 18:10:00 +0200 Subject: [PATCH 81/84] Fix system dark style issues --- retroshare-gui/src/gui/chat/ChatLobbyDialog.ui | 4 ++-- .../src/gui/gxsforums/CreateGxsForumMsg.ui | 13 ++++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/retroshare-gui/src/gui/chat/ChatLobbyDialog.ui b/retroshare-gui/src/gui/chat/ChatLobbyDialog.ui index 0851eba15..e00790f83 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyDialog.ui +++ b/retroshare-gui/src/gui/chat/ChatLobbyDialog.ui @@ -80,10 +80,10 @@ - QFrame::Box + QFrame::StyledPanel - QFrame::Sunken + QFrame::Raised diff --git a/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.ui b/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.ui index 683c8f07d..bae7223e3 100644 --- a/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.ui +++ b/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.ui @@ -34,7 +34,14 @@ 0 - + + + QFrame::StyledPanel + + + QFrame::Raised + + @@ -150,10 +157,10 @@ p, li { white-space: pre-wrap; } - QFrame::Box + QFrame::StyledPanel - QFrame::Sunken + QFrame::Raised From ad82a94cc7795dcdac2852035022003b988c7781 Mon Sep 17 00:00:00 2001 From: defnax Date: Thu, 3 Jul 2025 18:46:24 +0200 Subject: [PATCH 82/84] Fix to load the right logo without restart too --- retroshare-gui/src/gui/HomePage.cpp | 7 +++++++ retroshare-gui/src/gui/HomePage.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/retroshare-gui/src/gui/HomePage.cpp b/retroshare-gui/src/gui/HomePage.cpp index 0f153c8a6..914fde3e9 100644 --- a/retroshare-gui/src/gui/HomePage.cpp +++ b/retroshare-gui/src/gui/HomePage.cpp @@ -382,6 +382,13 @@ void HomePage::openWebHelp() QDesktopServices::openUrl(QUrl(QString("https://retrosharedocs.readthedocs.io/en/latest/"))); } +void HomePage::showEvent(QShowEvent *event) +{ + if (!event->spontaneous()) { + updateHomeLogo(); + } +} + void HomePage::updateHomeLogo() { if (Settings->getSheetName() == ":Standard_Dark") diff --git a/retroshare-gui/src/gui/HomePage.h b/retroshare-gui/src/gui/HomePage.h index 3660bdbe7..e9563e151 100644 --- a/retroshare-gui/src/gui/HomePage.h +++ b/retroshare-gui/src/gui/HomePage.h @@ -51,6 +51,8 @@ public: void getOwnCert(QString& invite,QString& description) const; RetroshareInviteFlags currentInviteFlags() const ; + virtual void showEvent(QShowEvent *) ; + private slots: #ifdef DEAD_CODE void certContextMenu(QPoint); From 63d3dd1c08de4c0307df38ac9ed2a48b0be842ef Mon Sep 17 00:00:00 2001 From: defnax <9952056+defnax@users.noreply.github.com> Date: Sat, 5 Jul 2025 13:24:25 +0200 Subject: [PATCH 83/84] Added override --- retroshare-gui/src/gui/HomePage.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/HomePage.h b/retroshare-gui/src/gui/HomePage.h index e9563e151..2dfc62f82 100644 --- a/retroshare-gui/src/gui/HomePage.h +++ b/retroshare-gui/src/gui/HomePage.h @@ -51,7 +51,7 @@ public: void getOwnCert(QString& invite,QString& description) const; RetroshareInviteFlags currentInviteFlags() const ; - virtual void showEvent(QShowEvent *) ; + virtual void showEvent(QShowEvent *) override; private slots: #ifdef DEAD_CODE From c3640306bdb5fdd119564cfe0066c5514ad4ffd8 Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 7 Jul 2025 23:37:29 +0200 Subject: [PATCH 84/84] fixed restbed to stick to commit 6001a322809b5005b8bcccdf593fdda6f0173691 --- supportlibs/restbed | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/supportlibs/restbed b/supportlibs/restbed index 8b99a9699..6001a3228 160000 --- a/supportlibs/restbed +++ b/supportlibs/restbed @@ -1 +1 @@ -Subproject commit 8b99a9699172cc718e164964f48a1ba27551c86d +Subproject commit 6001a322809b5005b8bcccdf593fdda6f0173691