mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-27 02:11:27 -05:00
added means to select download directory in RsCollectionDialog
This commit is contained in:
parent
ee2120a5bc
commit
6a0ccc4444
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QMenu>
|
||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
@ -50,6 +51,7 @@
|
|||||||
|
|
||||||
#define MAX_FILE_ADDED_BEFORE_ASK 500 //Number of file added in Recursive mode before asking to continue
|
#define MAX_FILE_ADDED_BEFORE_ASK 500 //Number of file added in Recursive mode before asking to continue
|
||||||
|
|
||||||
|
#define IMAGE_SEARCH ":/icons/svg/magnifying-glass.svg"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The FSMSortFilterProxyModel class sort directory before file.
|
* @brief The FSMSortFilterProxyModel class sort directory before file.
|
||||||
@ -140,9 +142,21 @@ RsCollectionDialog::RsCollectionDialog(const QString& collectionFileName
|
|||||||
ui.headerFrame->setHeaderImage(QPixmap(":/images/library64.png"));
|
ui.headerFrame->setHeaderImage(QPixmap(":/images/library64.png"));
|
||||||
|
|
||||||
if(creation)
|
if(creation)
|
||||||
|
{
|
||||||
ui.headerFrame->setHeaderText(tr("Collection Editor"));
|
ui.headerFrame->setHeaderText(tr("Collection Editor"));
|
||||||
|
ui.downloadFolder_LE->hide();
|
||||||
|
ui.downloadFolder_LB->hide();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
ui.headerFrame->setHeaderText(tr("Download files"));
|
ui.headerFrame->setHeaderText(tr("Download files"));
|
||||||
|
ui.downloadFolder_LE->show();
|
||||||
|
ui.downloadFolder_LB->show();
|
||||||
|
|
||||||
|
ui.downloadFolder_LE->setText(QString::fromUtf8(rsFiles->getDownloadDirectory().c_str())) ;
|
||||||
|
|
||||||
|
QObject::connect(ui.downloadFolder_LE,SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(openDestinationDirectoryMenu(QPoint)));
|
||||||
|
}
|
||||||
|
|
||||||
// 1 - add all elements to the list.
|
// 1 - add all elements to the list.
|
||||||
|
|
||||||
@ -213,6 +227,46 @@ RsCollectionDialog::RsCollectionDialog(const QString& collectionFileName
|
|||||||
QMessageBox::warning(NULL,tr("Bad filenames have been cleaned"),tr("Some filenames or directory names contained forbidden characters.\nCharacters <b>\",|,/,\\,<,>,*,?</b> will be replaced by '_'.\n Concerned files are listed in red.")) ;
|
QMessageBox::warning(NULL,tr("Bad filenames have been cleaned"),tr("Some filenames or directory names contained forbidden characters.\nCharacters <b>\",|,/,\\,<,>,*,?</b> will be replaced by '_'.\n Concerned files are listed in red.")) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RsCollectionDialog::openDestinationDirectoryMenu(QPoint)
|
||||||
|
{
|
||||||
|
QMenu contextMnu( this );
|
||||||
|
|
||||||
|
// pop a menu with existing entries and also a custom entry
|
||||||
|
// Now get the list of existing directories.
|
||||||
|
|
||||||
|
std::list< SharedDirInfo> dirs ;
|
||||||
|
rsFiles->getSharedDirectories( dirs) ;
|
||||||
|
|
||||||
|
for (std::list<SharedDirInfo>::const_iterator it(dirs.begin());it!=dirs.end();++it){
|
||||||
|
// Check for existence of directory name
|
||||||
|
QFile directory( QString::fromUtf8((*it).filename.c_str())) ;
|
||||||
|
|
||||||
|
if (!directory.exists()) continue ;
|
||||||
|
if (!(directory.permissions() & QFile::WriteOwner)) continue ;
|
||||||
|
|
||||||
|
contextMnu.addAction(QString::fromUtf8((*it).filename.c_str()), this, SLOT(setDestinationDirectory()))->setData(QString::fromUtf8( (*it).filename.c_str() ) ) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
contextMnu.addAction( QIcon(IMAGE_SEARCH),tr("Specify..."),this,SLOT(chooseDestinationDirectory()));
|
||||||
|
|
||||||
|
contextMnu.exec(QCursor::pos()) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RsCollectionDialog::setDestinationDirectory()
|
||||||
|
{
|
||||||
|
QString dest_dir(qobject_cast<QAction*>(sender())->data().toString()) ;
|
||||||
|
ui.downloadFolder_LE->setText(dest_dir) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RsCollectionDialog::chooseDestinationDirectory()
|
||||||
|
{
|
||||||
|
QString dest_dir = QFileDialog::getExistingDirectory(this,tr("Choose directory")) ;
|
||||||
|
|
||||||
|
if(dest_dir.isNull())
|
||||||
|
return ;
|
||||||
|
|
||||||
|
ui.downloadFolder_LE->setText(dest_dir) ;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @brief RsCollectionDialog::~RsCollectionDialog
|
* @brief RsCollectionDialog::~RsCollectionDialog
|
||||||
*/
|
*/
|
||||||
@ -1226,7 +1280,7 @@ void RsCollectionDialog::download()
|
|||||||
{
|
{
|
||||||
std::cerr << "Downloading!" << std::endl;
|
std::cerr << "Downloading!" << std::endl;
|
||||||
|
|
||||||
QString dldir = QString::fromUtf8(rsFiles->getDownloadDirectory().c_str()) ;
|
QString dldir = ui.downloadFolder_LE->text();
|
||||||
|
|
||||||
std::cerr << "downloading all these files:" << std::endl;
|
std::cerr << "downloading all these files:" << std::endl;
|
||||||
|
|
||||||
|
@ -49,6 +49,9 @@ private slots:
|
|||||||
void add() ;
|
void add() ;
|
||||||
void addRecursive() ;
|
void addRecursive() ;
|
||||||
void remove() ;
|
void remove() ;
|
||||||
|
void chooseDestinationDirectory();
|
||||||
|
void setDestinationDirectory();
|
||||||
|
void openDestinationDirectoryMenu(QPoint pt);
|
||||||
void processItem(QMap<QString, QString> &dirToAdd
|
void processItem(QMap<QString, QString> &dirToAdd
|
||||||
, int &index
|
, int &index
|
||||||
, ColFileInfo &parent
|
, ColFileInfo &parent
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>693</width>
|
<width>969</width>
|
||||||
<height>525</height>
|
<height>778</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -67,19 +67,7 @@
|
|||||||
<property name="frameShadow">
|
<property name="frameShadow">
|
||||||
<enum>QFrame::Plain</enum>
|
<enum>QFrame::Plain</enum>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<property name="leftMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QFrame" name="_frameInfo">
|
<widget class="QFrame" name="_frameInfo">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@ -403,7 +391,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="_removeDuplicate_CB">
|
<widget class="QCheckBox" name="_removeDuplicate_CB">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -424,6 +412,26 @@
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="downloadFolder_LB">
|
||||||
|
<property name="text">
|
||||||
|
<string>Destination:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="downloadFolder_LE">
|
||||||
|
<property name="contextMenuPolicy">
|
||||||
|
<enum>Qt::PreventContextMenu</enum>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Right click to change download directory</string>
|
||||||
|
</property>
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="_cancel_PB">
|
<widget class="QPushButton" name="_cancel_PB">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user