1+ /*
2+ MIT License
3+
4+ Copyright (c) 2024 Mitja Leino
5+
6+ Permission is hereby granted, free of charge, to any person obtaining a copy
7+ of this software and associated documentation files (the "Software"), to deal
8+ in the Software without restriction, including without limitation the rights
9+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+ copies of the Software, and to permit persons to whom the Software is
11+ furnished to do so, subject to the following conditions:
12+
13+ The above copyright notice and this permission notice shall be included in all
14+ copies or substantial portions of the Software.
15+
16+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+ SOFTWARE.
23+ */
124package com.mituuz.fuzzier.components
225
326import com.intellij.openapi.components.service
@@ -9,7 +32,10 @@ import com.intellij.util.ui.FormBuilder
932import com.mituuz.fuzzier.entities.FuzzyContainer.FilenameType
1033import com.mituuz.fuzzier.settings.FuzzierGlobalSettingsService
1134import com.mituuz.fuzzier.settings.FuzzierGlobalSettingsService.RecentFilesMode
35+ import com.mituuz.fuzzier.settings.FuzzierGlobalSettingsService.SearchPosition
1236import java.awt.Component
37+ import javax.swing.Box
38+ import javax.swing.BoxLayout
1339import javax.swing.DefaultListCellRenderer
1440import javax.swing.JButton
1541import javax.swing.JLabel
@@ -37,6 +63,10 @@ class FuzzierGlobalSettingsComponent {
3763 """ .trimIndent(),
3864 false )
3965
66+
67+ // ///////////////////////////////////////////////////////////////
68+ // Popup styling and configuration
69+ // ///////////////////////////////////////////////////////////////
4070 val filenameTypeSelector = SettingsComponent (ComboBox <FilenameType >(), " Filename type" ,
4171 """
4272 Controls how the filename is shown on the file search and selector popups.<br><br>
@@ -73,6 +103,28 @@ class FuzzierGlobalSettingsComponent {
73103 """ .trimIndent(),
74104 false )
75105
106+ val dimensionComponent = JPanel ().apply {
107+ layout = BoxLayout (this , BoxLayout .X_AXIS )
108+ add(JBLabel (" Width: " ))
109+ add(JBIntSpinner (700 , 100 , 4000 ))
110+ add(Box .createHorizontalStrut(10 ))
111+ add(JBLabel (" Height: " ))
112+ add(JBIntSpinner (400 , 100 , 4000 ))
113+ }
114+ val defaultDimension = SettingsComponent (dimensionComponent, " Default dimensions" ,
115+ """
116+ Default dimensions for the finder popup. Affects reset window behaviour.<br><br>
117+ Min: 100, Max: 4000
118+ """ .trimIndent(),
119+ false )
120+
121+ val searchPosition = SettingsComponent (ComboBox <SearchPosition >(), " Search bar location" ,
122+ """
123+ Controls where the search bar is located on the popup.
124+ """ .trimIndent(),
125+ false )
126+
127+
76128 val fileListLimit = SettingsComponent (JBIntSpinner (50 , 1 , 5000 ), " File list limit" ,
77129 """
78130 Controls how many files are shown and listed on the popup.
@@ -159,23 +211,25 @@ class FuzzierGlobalSettingsComponent {
159211 init {
160212 setupComponents()
161213 jPanel = FormBuilder .createFormBuilder()
162- .addComponent(JBLabel (" <html><strong >General settings</strong ></html>" ))
214+ .addComponent(JBLabel (" <html><h2 >General settings</h2 ></html>" ))
163215 .addComponent(newTabSelect)
164216 .addComponent(recentFileModeSelector)
165217 .addComponent(prioritizeShortDirs)
166218 .addComponent(debounceTimerValue)
167219 .addComponent(fileListLimit)
168220
169221 .addSeparator()
170- .addComponent(JBLabel (" <html><strong >Popup styling</strong ></html>" ))
222+ .addComponent(JBLabel (" <html><h2 >Popup styling</h2 ></html>" ))
171223 .addComponent(filenameTypeSelector)
172224 .addComponent(highlightFilename)
173- .addComponent(fileListFontSize)
225+ .addComponent(searchPosition)
226+ .addComponent(defaultDimension)
174227 .addComponent(previewFontSize)
228+ .addComponent(fileListFontSize)
175229 .addComponent(fileListSpacing)
176230
177231 .addSeparator()
178- .addComponent(JBLabel (" <html><strong >Match settings</strong ></html>" ))
232+ .addComponent(JBLabel (" <html><h2 >Match settings</h2 ></html>" ))
179233 .addComponent(tolerance)
180234 .addComponent(multiMatchActive)
181235 .addComponent(matchWeightSingleChar)
@@ -184,11 +238,13 @@ class FuzzierGlobalSettingsComponent {
184238 .addComponent(matchWeightFilename)
185239
186240 .addSeparator()
241+ .addComponent(JBLabel (" <html><h2>Test bench</h2></html>" ))
187242 .addComponent(startTestBench)
188243 .addComponent(testBench)
189244 .addComponentFillVertically(JPanel (), 0 )
190245
191246 .addSeparator()
247+ .addComponent(JBLabel (" <html><h2>Reset window</h2></html>" ))
192248 .addComponent(resetWindowDimension)
193249 .panel
194250 }
@@ -200,6 +256,8 @@ class FuzzierGlobalSettingsComponent {
200256 }
201257 resetWindowDimension.addActionListener {
202258 service<FuzzierGlobalSettingsService >().state.resetWindow = true
259+ // Disable the button to indicate that the press was registered
260+ resetWindowDimension.isEnabled = false
203261 }
204262
205263 recentFileModeSelector.getRecentFilesTypeComboBox().renderer = object : DefaultListCellRenderer () {
@@ -217,6 +275,24 @@ class FuzzierGlobalSettingsComponent {
217275 recentFileModeSelector.getRecentFilesTypeComboBox().addItem(recentFilesMode)
218276 }
219277
278+ searchPosition.getSearchPositionComboBox().renderer = object : DefaultListCellRenderer () {
279+ override fun getListCellRendererComponent (
280+ list : JList <* >? ,
281+ value : Any? ,
282+ index : Int ,
283+ isSelected : Boolean ,
284+ cellHasFocus : Boolean
285+ ): Component ? {
286+ val renderer = super .getListCellRendererComponent(list, value, index, isSelected, cellHasFocus) as JLabel
287+ val position = value as SearchPosition
288+ renderer.text = position.text
289+ return renderer
290+ }
291+ }
292+ for (sp in SearchPosition .entries) {
293+ searchPosition.getSearchPositionComboBox().addItem(sp)
294+ }
295+
220296 filenameTypeSelector.getFilenameTypeComboBox().renderer = object : DefaultListCellRenderer () {
221297 override fun getListCellRendererComponent (
222298 list : JList <* >? ,
0 commit comments