mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 07:18:08 +00:00
Add "Auto resize columns" functionality
This commit is contained in:
parent
208234b934
commit
7ae68b20e7
@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
#include <QAction>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
@ -235,7 +236,11 @@ AddNewTorrentDialog::AddNewTorrentDialog(const BitTorrent::AddTorrentParams &inP
|
|||||||
if (category != defaultCategory && category != m_torrentParams.category)
|
if (category != defaultCategory && category != m_torrentParams.category)
|
||||||
m_ui->categoryComboBox->addItem(category);
|
m_ui->categoryComboBox->addItem(category);
|
||||||
|
|
||||||
|
m_ui->contentTreeView->header()->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
m_ui->contentTreeView->header()->setSortIndicator(0, Qt::AscendingOrder);
|
m_ui->contentTreeView->header()->setSortIndicator(0, Qt::AscendingOrder);
|
||||||
|
|
||||||
|
connect(m_ui->contentTreeView->header(), &QWidget::customContextMenuRequested, this, &AddNewTorrentDialog::displayColumnHeaderMenu);
|
||||||
|
|
||||||
loadState();
|
loadState();
|
||||||
// Signal / slots
|
// Signal / slots
|
||||||
connect(m_ui->doNotDeleteTorrentCheckBox, &QCheckBox::clicked, this, &AddNewTorrentDialog::doNotDeleteTorrentClicked);
|
connect(m_ui->doNotDeleteTorrentCheckBox, &QCheckBox::clicked, this, &AddNewTorrentDialog::doNotDeleteTorrentClicked);
|
||||||
@ -705,6 +710,7 @@ void AddNewTorrentDialog::displayContentTreeMenu(const QPoint &)
|
|||||||
|
|
||||||
QMenu *menu = new QMenu(this);
|
QMenu *menu = new QMenu(this);
|
||||||
menu->setAttribute(Qt::WA_DeleteOnClose);
|
menu->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
|
||||||
if (selectedRows.size() == 1)
|
if (selectedRows.size() == 1)
|
||||||
{
|
{
|
||||||
menu->addAction(UIThemeManager::instance()->getIcon("edit-rename"), tr("Rename..."), this, &AddNewTorrentDialog::renameSelectedFile);
|
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());
|
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()
|
void AddNewTorrentDialog::accept()
|
||||||
{
|
{
|
||||||
// TODO: Check if destination actually exists
|
// TODO: Check if destination actually exists
|
||||||
|
@ -28,9 +28,11 @@
|
|||||||
|
|
||||||
#include "previewselectdialog.h"
|
#include "previewselectdialog.h"
|
||||||
|
|
||||||
|
#include <QAction>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
|
#include <QMenu>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QShowEvent>
|
#include <QShowEvent>
|
||||||
@ -104,9 +106,12 @@ PreviewSelectDialog::PreviewSelectDialog(QWidget *parent, const BitTorrent::Torr
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_previewListModel->sort(NAME);
|
m_previewListModel->sort(NAME);
|
||||||
|
m_ui->previewList->header()->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
m_ui->previewList->header()->setSortIndicator(0, Qt::AscendingOrder);
|
m_ui->previewList->header()->setSortIndicator(0, Qt::AscendingOrder);
|
||||||
m_ui->previewList->selectionModel()->select(m_previewListModel->index(0, NAME), QItemSelectionModel::Select | QItemSelectionModel::Rows);
|
m_ui->previewList->selectionModel()->select(m_previewListModel->index(0, NAME), QItemSelectionModel::Select | QItemSelectionModel::Rows);
|
||||||
|
|
||||||
|
connect(m_ui->previewList->header(), &QWidget::customContextMenuRequested, this, &PreviewSelectDialog::displayColumnHeaderMenu);
|
||||||
|
|
||||||
// Restore dialog state
|
// Restore dialog state
|
||||||
loadWindowState();
|
loadWindowState();
|
||||||
}
|
}
|
||||||
@ -145,6 +150,25 @@ void PreviewSelectDialog::previewButtonClicked()
|
|||||||
accept();
|
accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PreviewSelectDialog::displayColumnHeaderMenu()
|
||||||
|
{
|
||||||
|
auto 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->previewList->header()->count(); i < count; ++i)
|
||||||
|
{
|
||||||
|
if (!m_ui->previewList->isColumnHidden(i))
|
||||||
|
m_ui->previewList->resizeColumnToContents(i);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
resizeAction->setToolTip(tr("Resize all non-hidden columns to the size of their contents"));
|
||||||
|
|
||||||
|
menu->popup(QCursor::pos());
|
||||||
|
}
|
||||||
|
|
||||||
void PreviewSelectDialog::saveWindowState()
|
void PreviewSelectDialog::saveWindowState()
|
||||||
{
|
{
|
||||||
// Persist dialog size
|
// Persist dialog size
|
||||||
|
@ -68,6 +68,7 @@ signals:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void previewButtonClicked();
|
void previewButtonClicked();
|
||||||
|
void displayColumnHeaderMenu();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void showEvent(QShowEvent *event) override;
|
void showEvent(QShowEvent *event) override;
|
||||||
|
@ -182,6 +182,7 @@ void PeerListWidget::displayColumnHeaderMenu()
|
|||||||
QMenu *menu = new QMenu(this);
|
QMenu *menu = new QMenu(this);
|
||||||
menu->setAttribute(Qt::WA_DeleteOnClose);
|
menu->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
menu->setTitle(tr("Column visibility"));
|
menu->setTitle(tr("Column visibility"));
|
||||||
|
menu->setToolTipsVisible(true);
|
||||||
|
|
||||||
for (int i = 0; i < PeerListColumns::IP_HIDDEN; ++i)
|
for (int i = 0; i < PeerListColumns::IP_HIDDEN; ++i)
|
||||||
{
|
{
|
||||||
@ -205,6 +206,18 @@ void PeerListWidget::displayColumnHeaderMenu()
|
|||||||
action->setChecked(!isColumnHidden(i));
|
action->setChecked(!isColumnHidden(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
menu->addSeparator();
|
||||||
|
QAction *resizeAction = menu->addAction(tr("Resize columns"), this, [this]()
|
||||||
|
{
|
||||||
|
for (int i = 0, count = header()->count(); i < count; ++i)
|
||||||
|
{
|
||||||
|
if (!isColumnHidden(i))
|
||||||
|
resizeColumnToContents(i);
|
||||||
|
}
|
||||||
|
saveSettings();
|
||||||
|
});
|
||||||
|
resizeAction->setToolTip(tr("Resize all non-hidden columns to the size of their contents"));
|
||||||
|
|
||||||
menu->popup(QCursor::pos());
|
menu->popup(QCursor::pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,6 +182,7 @@ void PropertiesWidget::displayColumnHeaderMenu()
|
|||||||
QMenu *menu = new QMenu(this);
|
QMenu *menu = new QMenu(this);
|
||||||
menu->setAttribute(Qt::WA_DeleteOnClose);
|
menu->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
menu->setTitle(tr("Column visibility"));
|
menu->setTitle(tr("Column visibility"));
|
||||||
|
menu->setToolTipsVisible(true);
|
||||||
|
|
||||||
for (int i = 0; i < TorrentContentModelItem::TreeItemColumns::NB_COL; ++i)
|
for (int i = 0; i < TorrentContentModelItem::TreeItemColumns::NB_COL; ++i)
|
||||||
{
|
{
|
||||||
@ -202,6 +203,18 @@ void PropertiesWidget::displayColumnHeaderMenu()
|
|||||||
action->setEnabled(false);
|
action->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
menu->addSeparator();
|
||||||
|
QAction *resizeAction = menu->addAction(tr("Resize columns"), this, [this]()
|
||||||
|
{
|
||||||
|
for (int i = 0, count = m_ui->filesList->header()->count(); i < count; ++i)
|
||||||
|
{
|
||||||
|
if (!m_ui->filesList->isColumnHidden(i))
|
||||||
|
m_ui->filesList->resizeColumnToContents(i);
|
||||||
|
}
|
||||||
|
saveSettings();
|
||||||
|
});
|
||||||
|
resizeAction->setToolTip(tr("Resize all non-hidden columns to the size of their contents"));
|
||||||
|
|
||||||
menu->popup(QCursor::pos());
|
menu->popup(QCursor::pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -656,6 +656,7 @@ void TrackerListWidget::displayColumnHeaderMenu()
|
|||||||
QMenu *menu = new QMenu(this);
|
QMenu *menu = new QMenu(this);
|
||||||
menu->setAttribute(Qt::WA_DeleteOnClose);
|
menu->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
menu->setTitle(tr("Column visibility"));
|
menu->setTitle(tr("Column visibility"));
|
||||||
|
menu->setToolTipsVisible(true);
|
||||||
|
|
||||||
for (int i = 0; i < COL_COUNT; ++i)
|
for (int i = 0; i < COL_COUNT; ++i)
|
||||||
{
|
{
|
||||||
@ -675,5 +676,17 @@ void TrackerListWidget::displayColumnHeaderMenu()
|
|||||||
action->setChecked(!isColumnHidden(i));
|
action->setChecked(!isColumnHidden(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
menu->addSeparator();
|
||||||
|
QAction *resizeAction = menu->addAction(tr("Resize columns"), this, [this]()
|
||||||
|
{
|
||||||
|
for (int i = 0, count = header()->count(); i < count; ++i)
|
||||||
|
{
|
||||||
|
if (!isColumnHidden(i))
|
||||||
|
resizeColumnToContents(i);
|
||||||
|
}
|
||||||
|
saveSettings();
|
||||||
|
});
|
||||||
|
resizeAction->setToolTip(tr("Resize all non-hidden columns to the size of their contents"));
|
||||||
|
|
||||||
menu->popup(QCursor::pos());
|
menu->popup(QCursor::pos());
|
||||||
}
|
}
|
||||||
|
@ -469,6 +469,7 @@ void SearchJobWidget::displayColumnHeaderMenu()
|
|||||||
auto menu = new QMenu(this);
|
auto menu = new QMenu(this);
|
||||||
menu->setAttribute(Qt::WA_DeleteOnClose);
|
menu->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
menu->setTitle(tr("Column visibility"));
|
menu->setTitle(tr("Column visibility"));
|
||||||
|
menu->setToolTipsVisible(true);
|
||||||
|
|
||||||
for (int i = 0; i < SearchSortModel::DL_LINK; ++i)
|
for (int i = 0; i < SearchSortModel::DL_LINK; ++i)
|
||||||
{
|
{
|
||||||
@ -489,6 +490,18 @@ void SearchJobWidget::displayColumnHeaderMenu()
|
|||||||
action->setChecked(!m_ui->resultsBrowser->isColumnHidden(i));
|
action->setChecked(!m_ui->resultsBrowser->isColumnHidden(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
menu->addSeparator();
|
||||||
|
QAction *resizeAction = menu->addAction(tr("Resize columns"), this, [this]()
|
||||||
|
{
|
||||||
|
for (int i = 0, count = m_ui->resultsBrowser->header()->count(); i < count; ++i)
|
||||||
|
{
|
||||||
|
if (!m_ui->resultsBrowser->isColumnHidden(i))
|
||||||
|
m_ui->resultsBrowser->resizeColumnToContents(i);
|
||||||
|
}
|
||||||
|
saveSettings();
|
||||||
|
});
|
||||||
|
resizeAction->setToolTip(tr("Resize all non-hidden columns to the size of their contents"));
|
||||||
|
|
||||||
menu->popup(QCursor::pos());
|
menu->popup(QCursor::pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -643,6 +643,7 @@ void TransferListWidget::displayColumnHeaderMenu()
|
|||||||
auto menu = new QMenu(this);
|
auto menu = new QMenu(this);
|
||||||
menu->setAttribute(Qt::WA_DeleteOnClose);
|
menu->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
menu->setTitle(tr("Column visibility"));
|
menu->setTitle(tr("Column visibility"));
|
||||||
|
menu->setToolTipsVisible(true);
|
||||||
|
|
||||||
for (int i = 0; i < TransferListModel::NB_COLUMNS; ++i)
|
for (int i = 0; i < TransferListModel::NB_COLUMNS; ++i)
|
||||||
{
|
{
|
||||||
@ -666,6 +667,18 @@ void TransferListWidget::displayColumnHeaderMenu()
|
|||||||
action->setChecked(!isColumnHidden(i));
|
action->setChecked(!isColumnHidden(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
menu->addSeparator();
|
||||||
|
QAction *resizeAction = menu->addAction(tr("Resize columns"), this, [this]()
|
||||||
|
{
|
||||||
|
for (int i = 0, count = header()->count(); i < count; ++i)
|
||||||
|
{
|
||||||
|
if (!isColumnHidden(i))
|
||||||
|
resizeColumnToContents(i);
|
||||||
|
}
|
||||||
|
saveSettings();
|
||||||
|
});
|
||||||
|
resizeAction->setToolTip(tr("Resize all non-hidden columns to the size of their contents"));
|
||||||
|
|
||||||
menu->popup(QCursor::pos());
|
menu->popup(QCursor::pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user