mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-29 13:58:51 +03:00
Ensure that at least one column in the tranferlist is always visible. Closes #1165.
This commit is contained in:
parent
fce950b788
commit
ed54f0f7c3
1 changed files with 23 additions and 0 deletions
|
@ -127,6 +127,17 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *main_window,
|
|||
setColumnHidden(TorrentModelItem::TR_SAVE_PATH, true);
|
||||
}
|
||||
|
||||
//Ensure that at least one column is visible at all times
|
||||
bool atLeastOne = false;
|
||||
for (unsigned int i=0; i<TorrentModelItem::NB_COLUMNS; i++) {
|
||||
if (!isColumnHidden(i)) {
|
||||
atLeastOne = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!atLeastOne)
|
||||
setColumnHidden(TorrentModelItem::TR_NAME, false);
|
||||
|
||||
//When adding/removing columns between versions some may
|
||||
//end up being size 0 when the new version is launched with
|
||||
//a conf file from the previous version.
|
||||
|
@ -558,11 +569,23 @@ void TransferListWidget::displayDLHoSMenu(const QPoint&) {
|
|||
myAct->setChecked(!isColumnHidden(i));
|
||||
actions.append(myAct);
|
||||
}
|
||||
int visibleCols = 0;
|
||||
for (unsigned int i=0; i<TorrentModelItem::NB_COLUMNS; i++) {
|
||||
if (!isColumnHidden(i))
|
||||
visibleCols++;
|
||||
|
||||
if (visibleCols > 1)
|
||||
break;
|
||||
}
|
||||
|
||||
// Call menu
|
||||
QAction *act = hideshowColumn.exec(QCursor::pos());
|
||||
if (act) {
|
||||
int col = actions.indexOf(act);
|
||||
Q_ASSERT(col >= 0);
|
||||
Q_ASSERT(visibleCols > 0);
|
||||
if (!isColumnHidden(col) && visibleCols == 1)
|
||||
return;
|
||||
qDebug("Toggling column %d visibility", col);
|
||||
setColumnHidden(col, !isColumnHidden(col));
|
||||
if (!isColumnHidden(col) && columnWidth(col) <= 5)
|
||||
|
|
Loading…
Reference in a new issue