mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-23 13:04:23 +00:00
Ensure that at least one column in the tranferlist is always visible. Closes #1165.
This commit is contained in:
parent
fce950b788
commit
ed54f0f7c3
@ -127,6 +127,17 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *main_window,
|
|||||||
setColumnHidden(TorrentModelItem::TR_SAVE_PATH, true);
|
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
|
//When adding/removing columns between versions some may
|
||||||
//end up being size 0 when the new version is launched with
|
//end up being size 0 when the new version is launched with
|
||||||
//a conf file from the previous version.
|
//a conf file from the previous version.
|
||||||
@ -558,11 +569,23 @@ void TransferListWidget::displayDLHoSMenu(const QPoint&) {
|
|||||||
myAct->setChecked(!isColumnHidden(i));
|
myAct->setChecked(!isColumnHidden(i));
|
||||||
actions.append(myAct);
|
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
|
// Call menu
|
||||||
QAction *act = hideshowColumn.exec(QCursor::pos());
|
QAction *act = hideshowColumn.exec(QCursor::pos());
|
||||||
if (act) {
|
if (act) {
|
||||||
int col = actions.indexOf(act);
|
int col = actions.indexOf(act);
|
||||||
Q_ASSERT(col >= 0);
|
Q_ASSERT(col >= 0);
|
||||||
|
Q_ASSERT(visibleCols > 0);
|
||||||
|
if (!isColumnHidden(col) && visibleCols == 1)
|
||||||
|
return;
|
||||||
qDebug("Toggling column %d visibility", col);
|
qDebug("Toggling column %d visibility", col);
|
||||||
setColumnHidden(col, !isColumnHidden(col));
|
setColumnHidden(col, !isColumnHidden(col));
|
||||||
if (!isColumnHidden(col) && columnWidth(col) <= 5)
|
if (!isColumnHidden(col) && columnWidth(col) <= 5)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user