解决导出或另存为对话框,选择文件夹并点击打开,会以文件夹命名保存的问题;BUG-872,BUG-878
This commit is contained in:
parent
a4d4455bf0
commit
0a7841bcdb
|
@ -61,6 +61,7 @@ Dialog_Export::Dialog_Export(int total, const std::vector<int> &selectedIndexs,
|
|||
connect(ui->fileDialog, SIGNAL(accepted()), this, SLOT(on_dialog_accepted()));
|
||||
connect(ui->fileDialog, SIGNAL(rejected()), this, SLOT(close()));
|
||||
connect(ui->fileDialog, SIGNAL(filterSelected(const QString&)), this, SLOT(on_filterSelected(const QString&)));
|
||||
connect(ui->fileDialog, SIGNAL(currentChanged(const QString&)), this, SLOT(on_currentChanged(const QString&)));
|
||||
|
||||
#ifdef USE_FILE_DLG_WITHOUT_PROMPT
|
||||
init_custom_file_dlg(ui->fileDialog);
|
||||
|
@ -191,6 +192,14 @@ void Dialog_Export::on_dialog_accepted()
|
|||
assert(!extName.isEmpty());
|
||||
|
||||
QString selectedFile = ui->fileDialog->selectedFiles()[0];
|
||||
|
||||
QFileInfo selectFile(selectedFile);
|
||||
if (selectFile.isDir())
|
||||
{
|
||||
ui->fileDialog->setDirectory(selectedFile);
|
||||
return;
|
||||
}
|
||||
|
||||
int pos = selectedFile.lastIndexOf('/');
|
||||
if (-1 != pos)
|
||||
{
|
||||
|
@ -261,6 +270,32 @@ void Dialog_Export::on_filterSelected(const QString& filterName)
|
|||
m_saveExt = m_supportType[m_suffix].ext;
|
||||
}
|
||||
|
||||
void Dialog_Export::on_currentChanged(const QString& filePath)
|
||||
{
|
||||
QFileInfo file(filePath);
|
||||
if (file.isDir())
|
||||
{
|
||||
ui->fileDialog->setAcceptMode(QFileDialog::AcceptOpen);
|
||||
ui->fileDialog->setLabelText(QFileDialog::Accept, QFileDialog::tr("&Open"));
|
||||
QObjectList objs(ui->fileDialog->children());
|
||||
for (auto& o : objs)
|
||||
{
|
||||
if ("fileNameEdit" == o->objectName())
|
||||
{
|
||||
QLineEdit* edit = (QLineEdit*)o;
|
||||
QString hhhh = edit->text();
|
||||
edit->setText("");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->fileDialog->setAcceptMode(QFileDialog::AcceptSave);
|
||||
ui->fileDialog->setLabelText(QFileDialog::Accept, QFileDialog::tr("&Save"));
|
||||
}
|
||||
}
|
||||
|
||||
void Dialog_Export::on_btn_option_clicked()
|
||||
{
|
||||
Dialog_WriteSettings dlg(m_suffix, this);
|
||||
|
|
|
@ -53,6 +53,7 @@ public:
|
|||
private slots:
|
||||
void on_dialog_accepted();
|
||||
void on_filterSelected(const QString& filterName);
|
||||
void on_currentChanged(const QString& filePath);
|
||||
void on_btn_option_clicked();
|
||||
void on_radio_nominatedPages_toggled(bool checked);
|
||||
void on_lineEdit_nominatePages_textChanged(const QString& arg1);
|
||||
|
|
|
@ -82,6 +82,7 @@ Dialog_SaveAs::Dialog_SaveAs(bool isSaveAs, QWidget *parent) :
|
|||
connect(ui->fileDialog, SIGNAL(accepted()), this, SLOT(on_dialog_accepted()));
|
||||
connect(ui->fileDialog, SIGNAL(rejected()), this, SLOT(close()));
|
||||
connect(ui->fileDialog, SIGNAL(filterSelected(const QString&)), this, SLOT(on_filterSelected(const QString&)));
|
||||
connect(ui->fileDialog, SIGNAL(currentChanged(const QString&)), this, SLOT(on_currentChanged(const QString&)));
|
||||
|
||||
m_suffix = getCfgValue("saveAs", "suffix", 0);
|
||||
if (m_suffix > 10)
|
||||
|
@ -187,6 +188,14 @@ void Dialog_SaveAs::on_dialog_accepted()
|
|||
assert(!extName.isEmpty());
|
||||
|
||||
QString selectedFile = ui->fileDialog->selectedFiles()[0];
|
||||
|
||||
QFileInfo selectFile(selectedFile);
|
||||
if (selectFile.isDir())
|
||||
{
|
||||
ui->fileDialog->setDirectory(selectedFile);
|
||||
return;
|
||||
}
|
||||
|
||||
int pos = selectedFile.lastIndexOf('/');
|
||||
if (-1 != pos)
|
||||
{
|
||||
|
@ -241,6 +250,32 @@ void Dialog_SaveAs::on_filterSelected(const QString& filterName)
|
|||
ui->btn_option->setEnabled(0 == m_suffix || 6 == m_suffix || 7 == m_suffix || 8 == m_suffix);
|
||||
}
|
||||
|
||||
void Dialog_SaveAs::on_currentChanged(const QString& filePath)
|
||||
{
|
||||
QFileInfo file(filePath);
|
||||
if (file.isDir())
|
||||
{
|
||||
ui->fileDialog->setAcceptMode(QFileDialog::AcceptOpen);
|
||||
ui->fileDialog->setLabelText(QFileDialog::Accept, QFileDialog::tr("&Open"));
|
||||
QObjectList objs(ui->fileDialog->children());
|
||||
for (auto& o : objs)
|
||||
{
|
||||
if ("fileNameEdit" == o->objectName())
|
||||
{
|
||||
QLineEdit* edit = (QLineEdit*)o;
|
||||
QString hhhh = edit->text();
|
||||
edit->setText("");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->fileDialog->setAcceptMode(QFileDialog::AcceptSave);
|
||||
ui->fileDialog->setLabelText(QFileDialog::Accept, QFileDialog::tr("&Save"));
|
||||
}
|
||||
}
|
||||
|
||||
void Dialog_SaveAs::on_btn_option_clicked()
|
||||
{
|
||||
Dialog_WriteSettings dlg(m_suffix, this);
|
||||
|
|
|
@ -39,6 +39,7 @@ public:
|
|||
private slots:
|
||||
void on_dialog_accepted();
|
||||
void on_filterSelected(const QString& filterName);
|
||||
void on_currentChanged(const QString& filePath);
|
||||
void on_btn_option_clicked();
|
||||
void on_editingFinished();
|
||||
|
||||
|
|
Loading…
Reference in New Issue