Add own files button to the channel list footer

This commit is contained in:
evgeny committed 2026-10-09 22:58:01 +02:00
1 parent 7f3247bfcc
commit 2e4ed0347b
3 files changed
+32

No files matched your search

+18
View File
@@ -12,6 +12,7 @@
#include <QPixmap>
#include <QMouseEvent>
#include <QMenu>
#include <QStyle>
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 &current, 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) {
+3
View File
@@ -10,6 +10,7 @@
#include <QTimer>
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<QString, bool> m_dmOnline;
QTimer* m_dmPresenceTimer;
+11
View File
@@ -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);