Added context menu for Upload list headers to hide/show columns.

This commit is contained in:
Josep-San 2018-09-28 15:38:39 +02:00
parent 359e11433b
commit 4578b4403a
2 changed files with 71 additions and 2 deletions

View File

@ -826,6 +826,9 @@ TransfersDialog::TransfersDialog(QWidget *parent)
QHeaderView *qhvDLList = ui.downloadList->header();
qhvDLList->setContextMenuPolicy(Qt::CustomContextMenu);
connect(qhvDLList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(downloadListHeaderCustomPopupMenu(QPoint)));
QHeaderView *qhvULList = ui.uploadsList->header();
qhvULList->setContextMenuPolicy(Qt::CustomContextMenu);
connect(qhvULList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(uploadsListHeaderCustomPopupMenu(QPoint)));
// Why disable autoscroll ?
// With disabled autoscroll, the treeview doesn't scroll with cursor move
@ -1006,7 +1009,7 @@ TransfersDialog::TransfersDialog(QWidget *parent)
collOpenAct = new QAction(QIcon(IMAGE_COLLOPEN), tr( "Download from collection file..." ), this );
connect(collOpenAct, SIGNAL(triggered()), this, SLOT(collOpen()));
/** Setup the actions for the header context menu */
/** Setup the actions for the download header context menu */
showDLSizeAct= new QAction(tr("Size"),this);
showDLSizeAct->setCheckable(true); showDLSizeAct->setToolTip(tr("Show Size Column"));
connect(showDLSizeAct,SIGNAL(triggered(bool)),this,SLOT(setShowDLSizeColumn(bool))) ;
@ -1044,6 +1047,26 @@ TransfersDialog::TransfersDialog(QWidget *parent)
showDLPath->setCheckable(true); showDLPath->setToolTip(tr("Show Path Column"));
connect(showDLPath,SIGNAL(triggered(bool)),this,SLOT(setShowDLPath(bool))) ;
/** Setup the actions for the upload header context menu */
showULPeerAct= new QAction(tr("Peer"),this);
showULPeerAct->setCheckable(true); showULPeerAct->setToolTip(tr("Show Peer Column"));
connect(showULPeerAct,SIGNAL(triggered(bool)),this,SLOT(setShowULPeerColumn(bool))) ;
showULSizeAct= new QAction(tr("Size"),this);
showULSizeAct->setCheckable(true); showULSizeAct->setToolTip(tr("Show Peer Column"));
connect(showULSizeAct,SIGNAL(triggered(bool)),this,SLOT(setShowULSizeColumn(bool))) ;
showULTransferredAct= new QAction(tr("Transferred"),this);
showULTransferredAct->setCheckable(true); showULTransferredAct->setToolTip(tr("Show Transferred Column"));
connect(showULTransferredAct,SIGNAL(triggered(bool)),this,SLOT(setShowULTransferredColumn(bool))) ;
showULSpeedAct= new QAction(tr("Speed"),this);
showULSpeedAct->setCheckable(true); showULSpeedAct->setToolTip(tr("Show Speed Column"));
connect(showULSpeedAct,SIGNAL(triggered(bool)),this,SLOT(setShowULSpeedColumn(bool))) ;
showULProgressAct= new QAction(tr("Progress"),this);
showULProgressAct->setCheckable(true); showULProgressAct->setToolTip(tr("Show Progress Column"));
connect(showULProgressAct,SIGNAL(triggered(bool)),this,SLOT(setShowULProgressColumn(bool))) ;
showULHashAct= new QAction(tr("Hash"),this);
showULHashAct->setCheckable(true); showULHashAct->setToolTip(tr("Show Hash Column"));
connect(showULHashAct,SIGNAL(triggered(bool)),this,SLOT(setShowULHashColumn(bool))) ;
/** Setup the actions for the upload context menu */
ulOpenFolderAct = new QAction(QIcon(IMAGE_OPENFOLDER), tr("Open Folder"), this);
connect(ulOpenFolderAct, SIGNAL(triggered()), this, SLOT(ulOpenFolder()));
@ -1420,6 +1443,29 @@ void TransfersDialog::uploadsListCustomPopupMenu( QPoint /*point*/ )
contextMnu.exec(QCursor::pos());
}
void TransfersDialog::uploadsListHeaderCustomPopupMenu( QPoint /*point*/ )
{
std::cerr << "TransfersDialog::uploadsListHeaderCustomPopupMenu()" << std::endl;
QMenu contextMnu( this );
showULPeerAct->setChecked(!ui.uploadsList->isColumnHidden(COLUMN_UPEER));
showULSizeAct->setChecked(!ui.uploadsList->isColumnHidden(COLUMN_USIZE));
showULTransferredAct->setChecked(!ui.uploadsList->isColumnHidden(COLUMN_UTRANSFERRED));
showULSpeedAct->setChecked(!ui.uploadsList->isColumnHidden(COLUMN_ULSPEED));
showULProgressAct->setChecked(!ui.uploadsList->isColumnHidden(COLUMN_UPROGRESS));
showULHashAct->setChecked(!ui.uploadsList->isColumnHidden(COLUMN_UHASH));
QMenu *menu = contextMnu.addMenu(tr("Columns"));
menu->addAction(showULPeerAct);
menu->addAction(showULSizeAct);
menu->addAction(showULTransferredAct);
menu->addAction(showULSpeedAct);
menu->addAction(showULProgressAct);
menu->addAction(showULHashAct);
contextMnu.exec(QCursor::pos());
}
void TransfersDialog::chooseDestinationDirectory()
{
QString dest_dir = QFileDialog::getExistingDirectory(this,tr("Choose directory")) ;
@ -2791,6 +2837,13 @@ void TransfersDialog::setShowDLIDColumn (bool show) { ui.downloadList->
void TransfersDialog::setShowDLLastDLColumn (bool show) { ui.downloadList->setColumnHidden(COLUMN_LASTDL, !show); }
void TransfersDialog::setShowDLPath (bool show) { ui.downloadList->setColumnHidden(COLUMN_PATH, !show); }
void TransfersDialog::setShowULPeerColumn (bool show) { ui.uploadsList->setColumnHidden(COLUMN_UPEER, !show); }
void TransfersDialog::setShowULSizeColumn (bool show) { ui.uploadsList->setColumnHidden(COLUMN_USIZE, !show); }
void TransfersDialog::setShowULTransferredColumn(bool show) { ui.uploadsList->setColumnHidden(COLUMN_UTRANSFERRED, !show); }
void TransfersDialog::setShowULSpeedColumn (bool show) { ui.uploadsList->setColumnHidden(COLUMN_ULSPEED, !show); }
void TransfersDialog::setShowULProgressColumn (bool show) { ui.uploadsList->setColumnHidden(COLUMN_UPROGRESS, !show); }
void TransfersDialog::setShowULHashColumn (bool show) { ui.uploadsList->setColumnHidden(COLUMN_UHASH, !show); }
void TransfersDialog::expandAllDL()
{
ui.downloadList->expandAll();

View File

@ -92,6 +92,7 @@ private slots:
void downloadListCustomPopupMenu( QPoint point );
void downloadListHeaderCustomPopupMenu( QPoint point );
void uploadsListCustomPopupMenu( QPoint point );
void uploadsListHeaderCustomPopupMenu (QPoint point );
void cancel();
void forceCheck();
@ -158,6 +159,13 @@ private slots:
void setShowDLLastDLColumn(bool show);
void setShowDLPath(bool show);
void setShowULPeerColumn(bool show);
void setShowULSizeColumn(bool show);
void setShowULTransferredColumn(bool show);
void setShowULSpeedColumn(bool show);
void setShowULProgressColumn(bool show);
void setShowULHashColumn(bool show);
void filterChanged(const QString &text);
signals:
@ -217,7 +225,7 @@ private:
QAction *collViewAct;
QAction *collOpenAct;
/** Defines the actions for the header context menu */
/** Defines the actions for the header context menu in download */
QAction* showDLSizeAct;
QAction* showDLCompleteAct;
QAction* showDLDLSpeedAct;
@ -235,6 +243,14 @@ private:
QAction* ulOpenFolderAct;
QAction* ulCopyLinkAct;
/** Defines the actions for the header context menu in upload*/
QAction* showULPeerAct;
QAction* showULSizeAct;
QAction* showULTransferredAct;
QAction* showULSpeedAct;
QAction* showULProgressAct;
QAction* showULHashAct;
bool m_bProcessSettings;
void processSettings(bool bLoad);