mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-19 21:03:30 -07:00
Add "Auto resize columns" functionality
This commit is contained in:
parent
208234b934
commit
7ae68b20e7
8 changed files with 115 additions and 0 deletions
|
@ -30,6 +30,7 @@
|
|||
|
||||
#include <algorithm>
|
||||
|
||||
#include <QAction>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QFileDialog>
|
||||
|
@ -235,7 +236,11 @@ AddNewTorrentDialog::AddNewTorrentDialog(const BitTorrent::AddTorrentParams &inP
|
|||
if (category != defaultCategory && category != m_torrentParams.category)
|
||||
m_ui->categoryComboBox->addItem(category);
|
||||
|
||||
m_ui->contentTreeView->header()->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
m_ui->contentTreeView->header()->setSortIndicator(0, Qt::AscendingOrder);
|
||||
|
||||
connect(m_ui->contentTreeView->header(), &QWidget::customContextMenuRequested, this, &AddNewTorrentDialog::displayColumnHeaderMenu);
|
||||
|
||||
loadState();
|
||||
// Signal / slots
|
||||
connect(m_ui->doNotDeleteTorrentCheckBox, &QCheckBox::clicked, this, &AddNewTorrentDialog::doNotDeleteTorrentClicked);
|
||||
|
@ -705,6 +710,7 @@ void AddNewTorrentDialog::displayContentTreeMenu(const QPoint &)
|
|||
|
||||
QMenu *menu = new QMenu(this);
|
||||
menu->setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
if (selectedRows.size() == 1)
|
||||
{
|
||||
menu->addAction(UIThemeManager::instance()->getIcon("edit-rename"), tr("Rename..."), this, &AddNewTorrentDialog::renameSelectedFile);
|
||||
|
@ -755,6 +761,25 @@ void AddNewTorrentDialog::displayContentTreeMenu(const QPoint &)
|
|||
menu->popup(QCursor::pos());
|
||||
}
|
||||
|
||||
void AddNewTorrentDialog::displayColumnHeaderMenu()
|
||||
{
|
||||
QMenu *menu = new QMenu(this);
|
||||
menu->setAttribute(Qt::WA_DeleteOnClose);
|
||||
menu->setToolTipsVisible(true);
|
||||
|
||||
QAction *resizeAction = menu->addAction(tr("Resize columns"), this, [this]()
|
||||
{
|
||||
for (int i = 0, count = m_ui->contentTreeView->header()->count(); i < count; ++i)
|
||||
{
|
||||
if (!m_ui->contentTreeView->isColumnHidden(i))
|
||||
m_ui->contentTreeView->resizeColumnToContents(i);
|
||||
}
|
||||
});
|
||||
resizeAction->setToolTip(tr("Resize all non-hidden columns to the size of their contents"));
|
||||
|
||||
menu->popup(QCursor::pos());
|
||||
}
|
||||
|
||||
void AddNewTorrentDialog::accept()
|
||||
{
|
||||
// TODO: Check if destination actually exists
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue