导出对话框,屏蔽文件名输入框联想功能

This commit is contained in:
gb 2022-05-25 16:52:55 +08:00
parent 7d4de68e18
commit 5dd5b2ba19
3 changed files with 125 additions and 55 deletions

View File

@ -35,6 +35,10 @@ Dialog_Export::Dialog_Export(int total, const std::vector<int> &selectedIndexs,
connect(ui->fileDialog, SIGNAL(rejected()), this, SLOT(close()));
connect(ui->fileDialog, SIGNAL(filterSelected(const QString&)), this, SLOT(on_filterSelected(const QString&)));
#ifdef USE_FILE_DLG_WITHOUT_PROMPT
init_custom_file_dlg(ui->fileDialog);
#endif
QButtonGroup* btn_group = new QButtonGroup(this);
btn_group->addButton(ui->radio_chosenPages, 0);
btn_group->addButton(ui->radio_allPages, 1);
@ -237,6 +241,19 @@ void Dialog_Export::on_lineEdit_nominatePages_textChanged(const QString& arg1)
ui->lab_warning->setText(tr("Input is not valid.\nPage range will be 'Chosen Pages'."));
}
#ifdef USE_FILE_DLG_WITHOUT_PROMPT
void Dialog_Export::on_file_dialog_textChanged(const QString &path)
{
QLineEdit* edit = dynamic_cast<QLineEdit*>(sender());
on_file_name_changed(edit, path);
}
void Dialog_Export::on_file_dialog_returnPressed()
{
on_file_name_press_return();
}
#endif
bool Dialog_Export::isNominatedPagesLegal(const QString& page)
{
if (page.isEmpty())

View File

@ -3,14 +3,22 @@
#include <QDialog>
// u can ONLY comment following line if u want to use filedialog as system present !
#include "custom_file_dialog.h"
namespace Ui {
class Dialog_Export;
}
class Dialog_Export : public QDialog
#ifdef USE_FILE_DLG_WITHOUT_PROMPT
, public custom_file_dlg<Dialog_Export>
#endif
{
Q_OBJECT
public:
explicit Dialog_Export(int total, const std::vector<int> &selectedIndexs, QWidget *parent = nullptr);
~Dialog_Export();
@ -33,6 +41,11 @@ private slots:
void on_radio_nominatedPages_toggled(bool checked);
void on_lineEdit_nominatePages_textChanged(const QString& arg1);
#ifdef USE_FILE_DLG_WITHOUT_PROMPT
void on_file_dialog_textChanged(const QString &path) override;
void on_file_dialog_returnPressed() override;
#endif
private:
bool isNominatedPagesLegal(const QString& page);
void makeSaveIndexs();

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>546</width>
<height>414</height>
<width>650</width>
<height>530</height>
</rect>
</property>
<property name="windowTitle">
@ -17,30 +17,6 @@
<item>
<widget class="QFileDialog" name="fileDialog" native="true"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="btn_option">
<property name="text">
<string>Compression Option</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
@ -50,25 +26,55 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QRadioButton" name="radio_chosenPages">
<property name="text">
<string>Chosen Pages</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radio_allPages">
<property name="text">
<string>All Pages</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radio_nominatedPages">
<property name="text">
<string>Nominate Pages(example:1,3,6 or 3-6)</string>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QRadioButton" name="radio_nominatedPages">
<property name="text">
<string>Nominate Pages(example:1,3,6 or 3-6)</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QRadioButton" name="radio_chosenPages">
<property name="text">
<string>Chosen Pages</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QRadioButton" name="radio_allPages">
<property name="text">
<string>All Pages</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,0,1,0">
@ -91,8 +97,10 @@
<string notr="true">color: rgb(216, 0, 0);</string>
</property>
<property name="text">
<string>Input is not valid.
Page range will be &quot;Chosen Pages&quot;.</string>
<string>
Input is not valid.
Page range will be &quot;Chosen Pages&quot;.
</string>
</property>
<property name="wordWrap">
<bool>true</bool>
@ -114,28 +122,60 @@ Page range will be &quot;Chosen Pages&quot;.</string>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="check_saveAsMulti">
<property name="text">
<string>Save as multipages (TIFF/PDF/OFD)</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="check_saveAsMulti">
<property name="text">
<string>Save as multipages (TIFF/PDF/OFD)</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="btn_option">
<property name="text">
<string>Compression Option</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QFileDialog</class>
<extends>QWidget</extends>
<header>qfiledialog.h</header>
<header location="global">qfiledialog.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>radio_chosenPages</tabstop>
<tabstop>radio_nominatedPages</tabstop>
<tabstop>radio_allPages</tabstop>
<tabstop>lineEdit_nominatePages</tabstop>
<tabstop>check_saveAsMulti</tabstop>
<tabstop>btn_option</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>