mirror of
https://github.com/august-alt/gpui.git
synced 2025-03-12 04:58:37 +03:00
fix: fix issue #47727
This commit is contained in:
parent
7a667924d6
commit
b0b170a9c4
@ -26,7 +26,7 @@
|
||||
|
||||
namespace gpui
|
||||
{
|
||||
QString FileDialogUtils::getOpenFileName(QWidget *parent, const QString &filter)
|
||||
bool FileDialogUtils::getOpenFileName(QString& fileName, QWidget *parent, const QString &filter)
|
||||
{
|
||||
std::unique_ptr<QFileDialog> fileDialog = std::make_unique<QFileDialog>(parent);
|
||||
|
||||
@ -45,15 +45,17 @@ QString FileDialogUtils::getOpenFileName(QWidget *parent, const QString &filter)
|
||||
|
||||
fileDialog->setWindowTitle(QObject::tr("Open File"));
|
||||
|
||||
if (fileDialog->exec() == QDialog::Accepted)
|
||||
bool dialogState = fileDialog->exec() == QDialog::Accepted;
|
||||
|
||||
if (dialogState)
|
||||
{
|
||||
return fileDialog->selectedUrls()[0].toLocalFile();
|
||||
fileName = fileDialog->selectedUrls()[0].toLocalFile();
|
||||
}
|
||||
|
||||
return QString();
|
||||
return dialogState;
|
||||
}
|
||||
|
||||
QString FileDialogUtils::getOpenDirectoryName(QWidget *parent, const QString &filter)
|
||||
bool FileDialogUtils::getOpenDirectoryName(QString& directoryName, QWidget *parent, const QString &filter)
|
||||
{
|
||||
std::unique_ptr<QFileDialog> fileDialog = std::make_unique<QFileDialog>(parent);
|
||||
|
||||
@ -73,12 +75,14 @@ QString FileDialogUtils::getOpenDirectoryName(QWidget *parent, const QString &fi
|
||||
|
||||
fileDialog->setWindowTitle(QObject::tr("Open Directory"));
|
||||
|
||||
if (fileDialog->exec() == QDialog::Accepted)
|
||||
bool dialogState = fileDialog->exec() == QDialog::Accepted;
|
||||
|
||||
if (dialogState)
|
||||
{
|
||||
return fileDialog->selectedUrls()[0].toLocalFile();
|
||||
directoryName = fileDialog->selectedUrls()[0].toLocalFile();
|
||||
}
|
||||
|
||||
return QString();
|
||||
return dialogState;
|
||||
}
|
||||
|
||||
} // namespace gpui
|
||||
|
@ -30,9 +30,9 @@ namespace gpui
|
||||
class GPUI_GUI_EXPORT FileDialogUtils
|
||||
{
|
||||
public:
|
||||
static QString getOpenFileName(QWidget *parent = nullptr, const QString &filter = QString());
|
||||
static bool getOpenFileName(QString &fileName, QWidget *parent = nullptr, const QString &filter = QString());
|
||||
|
||||
static QString getOpenDirectoryName(QWidget *parent = nullptr, const QString &filter = QString());
|
||||
static bool getOpenDirectoryName(QString &directoryName, QWidget *parent = nullptr, const QString &filter = QString());
|
||||
};
|
||||
|
||||
} // namespace gpui
|
||||
|
@ -75,7 +75,11 @@ void DrivesWidget::on_pathToolButton_clicked()
|
||||
{
|
||||
using namespace gpui;
|
||||
|
||||
ui->pathLineEdit->setText(FileDialogUtils::getOpenDirectoryName(this, QObject::tr("All files (*.*)")));
|
||||
QString newText;
|
||||
if (FileDialogUtils::getOpenDirectoryName(newText, this, QObject::tr("All files (*.*)")))
|
||||
{
|
||||
ui->pathLineEdit->setText(newText);
|
||||
}
|
||||
}
|
||||
|
||||
void DrivesWidget::setDriveRadioButtonText(DrivesWidgetMode mode)
|
||||
|
@ -76,18 +76,30 @@ void FilesWidget::on_actionComboBox_currentIndexChanged(int index)
|
||||
|
||||
void FilesWidget::on_sourceToolButton_clicked()
|
||||
{
|
||||
ui->sourceLineEdit->setText(FileDialogUtils::getOpenFileName(this, QObject::tr("All files (*)")));
|
||||
QString newText;
|
||||
if (FileDialogUtils::getOpenFileName(newText, this, QObject::tr("All files (*)")))
|
||||
{
|
||||
ui->sourceLineEdit->setText(newText);
|
||||
}
|
||||
}
|
||||
|
||||
void FilesWidget::on_destinationToolButton_clicked()
|
||||
{
|
||||
if (fileMode)
|
||||
{
|
||||
ui->destinationLineEdit->setText(FileDialogUtils::getOpenFileName(this, QObject::tr("All files (*)")));
|
||||
QString newText;
|
||||
if (FileDialogUtils::getOpenFileName(newText, this, QObject::tr("All files (*)")))
|
||||
{
|
||||
ui->destinationLineEdit->setText(newText);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->destinationLineEdit->setText(FileDialogUtils::getOpenDirectoryName(this, QObject::tr("All files (*.*)")));
|
||||
QString newText;
|
||||
if (FileDialogUtils::getOpenDirectoryName(newText, this, QObject::tr("All files (*.*)")))
|
||||
{
|
||||
ui->destinationLineEdit->setText(newText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,11 @@ void FolderWidget::on_pathToolButton_clicked()
|
||||
{
|
||||
using namespace gpui;
|
||||
|
||||
ui->pathLineEdit->setText(FileDialogUtils::getOpenDirectoryName(this, QObject::tr("All files (*.*)")));
|
||||
QString newText;
|
||||
if (FileDialogUtils::getOpenDirectoryName(newText, this, QObject::tr("All files (*.*)")))
|
||||
{
|
||||
ui->pathLineEdit->setText(newText);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace preferences
|
||||
|
@ -60,7 +60,11 @@ void IniWidget::on_pathToolButton_clicked()
|
||||
{
|
||||
using namespace gpui;
|
||||
|
||||
ui->pathLineEdit->setText(FileDialogUtils::getOpenFileName(this, QObject::tr("Ini files (*.ini)")));
|
||||
QString newText;
|
||||
if (FileDialogUtils::getOpenFileName(newText, this, QObject::tr("Ini files (*.ini)")))
|
||||
{
|
||||
ui->pathLineEdit->setText(newText);
|
||||
}
|
||||
}
|
||||
|
||||
void IniWidget::on_pathLineEdit_textChanged(const QString &text)
|
||||
|
@ -161,7 +161,11 @@ void SharesWidget::on_folderToolButton_clicked()
|
||||
{
|
||||
using namespace gpui;
|
||||
|
||||
ui->folderPathLineEdit->setText(FileDialogUtils::getOpenDirectoryName(this, QObject::tr("All files (*.*)")));
|
||||
QString newText;
|
||||
if (FileDialogUtils::getOpenDirectoryName(newText, this, QObject::tr("All files (*.*)")))
|
||||
{
|
||||
ui->folderPathLineEdit->setText(newText);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -56,22 +56,38 @@ void ShortcutsWidget::on_locationComboBox_currentIndexChanged(int index)
|
||||
|
||||
void ShortcutsWidget::on_nameToolButton_clicked()
|
||||
{
|
||||
ui->nameLineEdit->setText(openFileOrFolder(true));
|
||||
QString newText = openFileOrFolder(true);
|
||||
if (!newText.isEmpty())
|
||||
{
|
||||
ui->nameLineEdit->setText(newText);
|
||||
}
|
||||
}
|
||||
|
||||
void ShortcutsWidget::on_targetPathToolButton_clicked()
|
||||
{
|
||||
ui->targetPathLineEdit->setText(openFileOrFolder(true));
|
||||
QString newText = openFileOrFolder(true);
|
||||
if (!newText.isEmpty())
|
||||
{
|
||||
ui->targetPathLineEdit->setText(newText);
|
||||
}
|
||||
}
|
||||
|
||||
void ShortcutsWidget::on_iconFilePathToolButton_clicked()
|
||||
{
|
||||
ui->iconFilePathLineEdit->setText(openFileOrFolder(false));
|
||||
QString newText = openFileOrFolder(false);
|
||||
if (!newText.isEmpty())
|
||||
{
|
||||
ui->iconFilePathLineEdit->setText(newText);
|
||||
}
|
||||
}
|
||||
|
||||
void ShortcutsWidget::on_startInToolButton_clicked()
|
||||
{
|
||||
ui->startInLineEdit->setText(openFileOrFolder(true));
|
||||
QString newText = openFileOrFolder(true);
|
||||
if (!newText.isEmpty())
|
||||
{
|
||||
ui->startInLineEdit->setText(newText);
|
||||
}
|
||||
}
|
||||
|
||||
void ShortcutsWidget::on_targetTypeComboBox_currentIndexChanged(int index)
|
||||
|
@ -100,9 +100,9 @@ void AddScriptWidget::on_cancelPushButton_clicked()
|
||||
void AddScriptWidget::on_browsePushButton_clicked()
|
||||
{
|
||||
auto dialog = std::make_unique<gpui::FileDialogUtils>();
|
||||
QString file = dialog->getOpenFileName();
|
||||
QString file;
|
||||
|
||||
if (!file.isEmpty())
|
||||
if (dialog->getOpenFileName(file))
|
||||
{
|
||||
ui->nameLineEdit->setText(file);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user