Skip to content
Snippets Groups Projects
Commit d2d93aa5 authored by gambas's avatar gambas
Browse files

Add 'DirBox.Title' property. Change the syntax of 'FileBox.Filter' property. Update 'FileBox' icon.

[GB.FORM]
* NEW: DirBox: Add a 'Title' property.
* NEW: FileBox: Make 'Filter' property use the same syntax as 'Dialog.Filter' property.
* NEW: FileBox: If the 'Filter' property is set, automatically select the first filter.
* NEW: Update FileBox icon.
parent d8639d9a
Branches
Tags
No related merge requests found
Pipeline #443795100 passed
comp/src/gb.form/.hidden/control/filebox.png

802 B | W: | H:

comp/src/gb.form/.hidden/control/filebox.png

276 B | W: | H:

comp/src/gb.form/.hidden/control/filebox.png
comp/src/gb.form/.hidden/control/filebox.png
comp/src/gb.form/.hidden/control/filebox.png
comp/src/gb.form/.hidden/control/filebox.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -3,7 +3,7 @@
Export
Inherits UserControl
Public Const _Properties As String = "*,Path,Action,Border=True"
Public Const _Properties As String = "*,Path,Action,Title,Border=True"
Public Const _DefaultEvent As String = "Click"
Public Const _DefaultSize As String = "32,4"
Public Const _Similar As String = "TextBox"
......@@ -14,8 +14,10 @@ Event Change
Property Value, Path As String
Property Border As Boolean
Property Title As String
Private $hButtonBox As ButtonBox
Private $sTitle As String
Public Sub _new()
......@@ -53,11 +55,22 @@ End
Public Sub Button_Click()
Dim sSaveTitle As String
Dim bCancel As Boolean
sSaveTitle = Dialog.Title
Dialog.Title = $sTitle
Dialog.Path = $hButtonBox.Text
If Dialog.SelectDirectory() Then Return
bCancel = Dialog.SelectDirectory()
Dialog.Title = sSaveTitle
If Not bCancel Then
$hButtonBox.Text = Dialog.Path
Raise Click
Endif
End
......@@ -67,3 +80,15 @@ Public Sub Button_Change()
End
Private Function Title_Read() As String
Return $sTitle
End
Private Sub Title_Write(Value As String)
$sTitle = Value
End
......@@ -23,21 +23,15 @@ Property Placeholder As String
'' File dialog will be for saving files. (it will give overwrite warnings for existing files)
Property SaveFile As Boolean
'' A space separated list of filters and their names\
'' Filter extensions use wildcards and are seperated with semicolons;\
'' Use doublequotes to use spaces in names.
'' Return or set the optional filters of the file selection dialog.
''
'' [[
'' ==
'' Eg.\
'' "*.png;*.jpg "Image files" *.ico "Icon Files"
'' ]]
'' .
Property Filter As String
Private $sFilter As String
'' The syntax is the same as the [Dialog.Filter](/comp/gb.qt4/dialog/filter) property.
Property Filter As String[]
Private $aFilter As String[]
Private $bSaveFile As Boolean
Private $sTitle As String = "Select file..."
Private $sTitle As String
Private $hButtonBox As ButtonBox
......@@ -53,31 +47,32 @@ End
Public Sub Button_Click()
Dim sTitleBU As String = Dialog.Title
Dim sFilters, sFilterBU As String[]
Dim sSaveTitle As String = Dialog.Title
Dim aSaveFilter As String[]
Dim bCancel As Boolean
If $sFilter Then
sFilterBU = Dialog.Filter
sFilters = Split($sFilter, " ", "\"")
Dialog.Filter = sFilters
If $aFilter Then
aSaveFilter = Dialog.Filter
Dialog.Filter = $aFilter
Endif
Dialog.Path = $hButtonBox.Text
Dialog.Title = $sTitle
If $aFilter And If $aFilter.Count Then Dialog.FilterIndex = 0
If $bSaveFile Then
If Dialog.SaveFile() Then Goto CleanUp
bCancel = Dialog.SaveFile()
Else
If Dialog.OpenFile() Then Goto CleanUp
bCancel = Dialog.OpenFile()
Endif
Dialog.Title = sSaveTitle
If $aFilter Then Dialog.Filter = aSaveFilter
If Not bCancel Then
$hButtonBox.Text = Dialog.Path
Raise Click
CleanUp:
Dialog.Title = sTitleBU
If $sFilter Then Dialog.Filter = sFilterBU
Return
Endif
End
......@@ -135,15 +130,15 @@ Private Sub Title_Write(Value As String)
End
Private Function Filter_Read() As String
Private Function Filter_Read() As String[]
Return $sFilter
Return $aFilter
End
Private Sub Filter_Write(Value As String)
Private Sub Filter_Write(Value As String[])
$sFilter = Value
$aFilter = Value
End
......
......@@ -2,6 +2,9 @@
{ Form Form
MoveScaled(0,0,64,30)
Arrangement = Arrange.Vertical
Spacing = True
Margin = True
{ FileBox1 FileBox
MoveScaled(11,4,32,4)
Path = "/etc/lsb-release"
......@@ -17,7 +20,7 @@
{ FileBox3 FileBox
MoveScaled(11,19,32,4)
Title = ("Open image file")
Filter = "*.png;*.jpg \"Image files\" *.ico \"Icon Files\""
Filter = ["*.jpg;*.png;*.gif;*.ico", "Image files"]
Picture = Picture["icon:/small/insert-image"]
Placeholder = ("Image filters")
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment