yhkylin-backup-tools/kybackup/component/myfileselect.cpp

26 lines
820 B
C++
Executable File

#include "myfileselect.h"
#include <QDialogButtonBox>
#include <QLineEdit>
MyFileSelect::MyFileSelect(QWidget* parent) :
QFileDialog(parent)
{
this->setViewMode(QFileDialog::List);
this->setFileMode(QFileDialog::ExistingFiles);
this->setFilter(QDir::System | QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot);
QDialogButtonBox* button = this->findChild<QDialogButtonBox*>("buttonBox");
disconnect(button, SIGNAL(accepted()), this, SLOT(accept()));
connect(button, SIGNAL(accepted()), this, SLOT(goAccept()));
QLineEdit *fileNameEdit = this->findChild<QLineEdit*>("fileNameEdit");
connect(this, &MyFileSelect::currentChanged, this, [=](const QString& path){
fileNameEdit->setText(path.section('/', -1));
});
}
void MyFileSelect::goAccept()
{
QDialog::accept();
}