mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-07-05 16:28:16 +02:00
Qt: fixed bugs with QFileDialog (TSaveDialog), now it works properly.
git-svn-id: trunk@12531 -
This commit is contained in:
parent
a75cc9ff3c
commit
2bc78d0dfd
@ -215,7 +215,7 @@ begin
|
|||||||
ParserState := 0;
|
ParserState := 0;
|
||||||
Position := 1;
|
Position := 1;
|
||||||
TmpFilter := '';
|
TmpFilter := '';
|
||||||
|
|
||||||
for i := 1 to Length(AFileDialog.Filter) do
|
for i := 1 to Length(AFileDialog.Filter) do
|
||||||
begin
|
begin
|
||||||
if Copy(AFileDialog.Filter, i, 1) = '|' then
|
if Copy(AFileDialog.Filter, i, 1) = '|' then
|
||||||
@ -246,7 +246,11 @@ begin
|
|||||||
|
|
||||||
if Pos(strExtensions, TmpFilter) = 0 then
|
if Pos(strExtensions, TmpFilter) = 0 then
|
||||||
TmpFilter := TmpFilter + ' ' + strExtensions;
|
TmpFilter := TmpFilter + ' ' + strExtensions;
|
||||||
Result := GetUtf8String(TmpFilter);
|
|
||||||
|
if (AFileDialog is TSaveDialog) and (trim(TmpFilter)='()') then
|
||||||
|
Result := ''
|
||||||
|
else
|
||||||
|
Result := GetUtf8String(TmpFilter);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class procedure TQtWSFileDialog.UpdateProperties(
|
class procedure TQtWSFileDialog.UpdateProperties(
|
||||||
@ -274,8 +278,6 @@ begin
|
|||||||
QtFileDialog.setFileMode(QFileDialogExistingFile)
|
QtFileDialog.setFileMode(QFileDialogExistingFile)
|
||||||
else
|
else
|
||||||
QtFileDialog.setFileMode(QFileDialogAnyFile);
|
QtFileDialog.setFileMode(QFileDialogAnyFile);
|
||||||
|
|
||||||
QtFileDialog.setLabelText(QFileDialogFileName, GetUtf8String(AFileDialog.FileName));
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class function TQtWSFileDialog.CreateHandle(const ACommonDialog: TCommonDialog): THandle;
|
class function TQtWSFileDialog.CreateHandle(const ACommonDialog: TCommonDialog): THandle;
|
||||||
@ -295,7 +297,8 @@ end;
|
|||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
class procedure TQtWSFileDialog.ShowModal(const ACommonDialog: TCommonDialog);
|
class procedure TQtWSFileDialog.ShowModal(const ACommonDialog: TCommonDialog);
|
||||||
var
|
var
|
||||||
selectedFilter, ReturnText: WideString;
|
selectedFilter, ReturnText,
|
||||||
|
saveFileName, saveTitle, saveFilter: WideString;
|
||||||
FileDialog: TFileDialog;
|
FileDialog: TFileDialog;
|
||||||
ReturnList: QStringListH;
|
ReturnList: QStringListH;
|
||||||
i: integer;
|
i: integer;
|
||||||
@ -306,6 +309,8 @@ begin
|
|||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
ReturnText := '';
|
ReturnText := '';
|
||||||
selectedFilter := '';
|
selectedFilter := '';
|
||||||
|
saveFileName := '';
|
||||||
|
saveTitle := '';
|
||||||
|
|
||||||
FileDialog := TFileDialog(ACommonDialog);
|
FileDialog := TFileDialog(ACommonDialog);
|
||||||
QtFileDialog := TQtFileDialog(FileDialog.Handle);
|
QtFileDialog := TQtFileDialog(FileDialog.Handle);
|
||||||
@ -324,20 +329,35 @@ begin
|
|||||||
if ACommonDialog is TSelectDirectoryDialog then
|
if ACommonDialog is TSelectDirectoryDialog then
|
||||||
QtFileDialog.setFileMode(QFileDialogDirectoryOnly);
|
QtFileDialog.setFileMode(QFileDialogDirectoryOnly);
|
||||||
|
|
||||||
FileDialog.UserChoice := QtDialogCodeToModalResultMap[QDialogDialogCode(QtFileDialog.exec)];
|
if ACommonDialog is TSaveDialog then
|
||||||
ReturnList := QStringList_create;
|
begin
|
||||||
try
|
saveFilter := GetQtFilterString(TSaveDialog(ACommonDialog));
|
||||||
QtFileDialog.selectedFiles(ReturnList);
|
saveFileName := GetUtf8String(FileDialog.InitialDir+FileDialog.Filename);
|
||||||
for i := 0 to QStringList_size(ReturnList) - 1 do
|
saveTitle := GetUTF8String(FileDialog.Title);
|
||||||
|
QFileDialog_getSaveFileName(@ReturnText, QWidget_parentWidget(QtFileDialog.Widget), @SaveTitle, @saveFileName, @saveFilter, {selectedFilter} nil, 0);
|
||||||
|
if ReturnText <> '' then
|
||||||
begin
|
begin
|
||||||
QStringList_at(ReturnList, @ReturnText, i);
|
FileDialog.FileName := UTF8Encode(ReturnText);
|
||||||
FileDialog.Files.Add(UTF8Encode(ReturnText));
|
FileDialog.UserChoice := mrOK;
|
||||||
if i = 0 then
|
end else
|
||||||
FileDialog.FileName := UTF8Encode(ReturnText);
|
FileDialog.UserChoice := mrCancel;
|
||||||
|
end else
|
||||||
|
begin
|
||||||
|
FileDialog.UserChoice := QtDialogCodeToModalResultMap[QDialogDialogCode(QtFileDialog.exec)];
|
||||||
|
ReturnList := QStringList_create;
|
||||||
|
try
|
||||||
|
QtFileDialog.selectedFiles(ReturnList);
|
||||||
|
for i := 0 to QStringList_size(ReturnList) - 1 do
|
||||||
|
begin
|
||||||
|
QStringList_at(ReturnList, @ReturnText, i);
|
||||||
|
FileDialog.Files.Add(UTF8Encode(ReturnText));
|
||||||
|
if i = 0 then
|
||||||
|
FileDialog.FileName := UTF8Encode(ReturnText);
|
||||||
|
end;
|
||||||
|
ReturnText := FileDialog.Files.Text;
|
||||||
|
finally
|
||||||
|
QStringList_destroy(ReturnList);
|
||||||
end;
|
end;
|
||||||
ReturnText := FileDialog.Files.Text;
|
|
||||||
finally
|
|
||||||
QStringList_destroy(ReturnList);
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user