From 2e4ed0347b142e4daf0c55c94099750c962b09fd Mon Sep 17 00:00:00 2001 From: evgeny Date: Fri, 9 Oct 2026 22:58:01 +0200 Subject: [PATCH] Add own files button to the channel list footer --- tools/chatgui/src/channellist.cpp | 18 ++++++++++++++++++ tools/chatgui/src/channellist.h | 3 +++ tools/chatgui/src/mainwindow.cpp | 11 +++++++++++ 3 files changed, 32 insertions(+) diff --git a/tools/chatgui/src/channellist.cpp b/tools/chatgui/src/channellist.cpp index bbb33796..24c2040a 100644 --- a/tools/chatgui/src/channellist.cpp +++ b/tools/chatgui/src/channellist.cpp @@ -12,6 +12,7 @@ #include #include #include +#include extern "C" { #include "../../lib/debug_config.h" @@ -188,6 +189,21 @@ ChannelList::ChannelList(DbManager* db, QWidget *parent) connect(gearBtn, &QPushButton::clicked, this, [this] { emit settingsRequested(); }); + m_ownFilesButton = new QPushButton(footer); + m_ownFilesButton->setObjectName("ownFilesButton"); + m_ownFilesButton->setIcon(style()->standardIcon(QStyle::SP_DirOpenIcon)); + m_ownFilesButton->setFixedSize(28, 28); + m_ownFilesButton->setToolTip(QCoreApplication::translate("ChatGui", "My files in the selected group")); + m_ownFilesButton->setAccessibleName(m_ownFilesButton->toolTip()); + m_ownFilesButton->setStyleSheet( + "QPushButton { border: none; background: transparent; }" + "QPushButton:hover { background: rgba(51,144,236,20); border-radius: 14px; }"); + m_ownFilesButton->setEnabled(false); + fl->addWidget(m_ownFilesButton); + connect(m_ownFilesButton, &QPushButton::clicked, this, [this] { + emit ownFilesRequested(m_listView->currentIndex().data(ChannelChannelIdRole).toString()); + }); + auto *monitorBtn = new QPushButton(QString::fromUtf8("\xF0\x9F\x94\x8D"), footer); /* 🔍 */ monitorBtn->setFixedSize(28, 28); monitorBtn->setToolTip(QCoreApplication::translate("ChatGui", "Connection Monitor")); @@ -227,6 +243,7 @@ ChannelList::ChannelList(DbManager* db, QWidget *parent) connect(m_listView->selectionModel(), &QItemSelectionModel::currentChanged, this, [this](const QModelIndex ¤t, const QModelIndex &) { + m_ownFilesButton->setEnabled(current.data(ChannelChannelIdRole).toString().toULongLong() != 0); if (current.isValid()) { QString cid = current.data(ChannelChannelIdRole).toString(); emit channelSelected(cid); @@ -363,6 +380,7 @@ void ChannelList::loadChannels() { sel->select(idx, QItemSelectionModel::ClearAndSelect); sel->setCurrentIndex(idx, QItemSelectionModel::NoUpdate); } + m_ownFilesButton->setEnabled(m_listView->currentIndex().data(ChannelChannelIdRole).toString().toULongLong() != 0); } void ChannelList::selectChannel(const QString& channelId) { diff --git a/tools/chatgui/src/channellist.h b/tools/chatgui/src/channellist.h index c6568d91..61f9e602 100644 --- a/tools/chatgui/src/channellist.h +++ b/tools/chatgui/src/channellist.h @@ -10,6 +10,7 @@ #include class DbManager; +class QPushButton; class ChannelList : public QWidget { Q_OBJECT @@ -32,6 +33,7 @@ signals: void inviteByLinkRequested(const QString& channelId); void channelSettingsRequested(const QString& channelId); void filesRequested(const QString& channelId); + void ownFilesRequested(const QString& channelId); void joinRequested(); void createGroupRequested(); void settingsRequested(); @@ -41,6 +43,7 @@ private: QListView *m_listView; QStandardItemModel *m_model; DbManager *m_db; + QPushButton *m_ownFilesButton; bool m_autoConnectActive = false; QHash m_dmOnline; QTimer* m_dmPresenceTimer; diff --git a/tools/chatgui/src/mainwindow.cpp b/tools/chatgui/src/mainwindow.cpp index 6ed54ff4..73c1e496 100644 --- a/tools/chatgui/src/mainwindow.cpp +++ b/tools/chatgui/src/mainwindow.cpp @@ -610,6 +610,17 @@ void MainWindow::setupConnects() { m_messageList, &MessageList::reloadLocalNicks); connect(m_accountList, &AccountList::filesRequested, this, &MainWindow::showMemberFiles); connect(m_channelList, &ChannelList::filesRequested, this, [this](const QString& channel) { showMemberFiles(channel); }); + connect(m_channelList, &ChannelList::ownFilesRequested, this, [this](const QString& channel) { + quint64 owner = m_db ? m_db->myNodeId() : 0; + if (!channel.toULongLong() || !owner) { + DEBUG_WARN(DEBUG_CATEGORY_MEDIA, "file browser: own files unavailable channel=%s owner=%llu", + qPrintable(channel), (unsigned long long)owner); + return; + } + DEBUG_INFO(DEBUG_CATEGORY_MEDIA, "file browser: opening own files channel=%s owner=%llu", + qPrintable(channel), (unsigned long long)owner); + showMemberFiles(channel, owner); + }); connect(m_accountList, &AccountList::callRequested, this, &MainWindow::onCallRequested); connect(m_messageList, &MessageList::callRequested, this, &MainWindow::onCallRequested); connect(m_accountList, &AccountList::pmRequested, this, &MainWindow::onPmRequested);