diff --git a/CustomFileWidget.py b/CustomFileWidget.py
index e1b5bf0..02b1bd5 100644
--- a/CustomFileWidget.py
+++ b/CustomFileWidget.py
@@ -18,6 +18,7 @@ def __init__(self, parent=None):
self.parent = parent
self.setAcceptDrops(True)
self.acceptable_extensions = []
+ self.set_correct_placeholder_text()
@property
def dir_only(self) -> bool:
@@ -43,6 +44,16 @@ def suffixFilter(self) -> str:
def suffixFilter(self, value: str) -> None:
self.suffixFilter = value
+ def set_correct_placeholder_text(self) -> None:
+ if self.parent.mStorageMode == CustomFileWidget.GetMultipleFiles:
+ self.setPlaceholderText('Select files..')
+ elif self.parent.mStorageMode == CustomFileWidget.GetFile:
+ self.setPlaceholderText('Select file..')
+ elif self.parent.mStorageMode == CustomFileWidget.SaveFile:
+ self.setPlaceholderText('Save output file..')
+ else:
+ self.setPlaceholderText('Select directory..')
+
def set_filters(self, filters: str) -> None:
self.acceptable_extensions.clear()
if '*.*' in filters:
@@ -114,6 +125,12 @@ def __init__(self, parent=None, default_root=None, dialog_title=''):
super(CustomFileWidget, self).__init__(parent)
main_layout = QHBoxLayout()
main_layout.setContentsMargins(0, 0, 0, 0)
+ self._filePath = ''
+ self._defaultRoot = default_root
+ self._dialogTitle = dialog_title
+ self._filter = ''
+ self._options = QFileDialog.ShowDirsOnly
+ self._mStorageMode = CustomFileWidget.GetMultipleFiles
self.file_lineEdit = QgsFileDropEdit(self)
self.file_lineEdit.setDragEnabled(True)
self.file_lineEdit.setToolTip(
@@ -127,12 +144,6 @@ def __init__(self, parent=None, default_root=None, dialog_title=''):
self.browse_btn.clicked.connect(self.openFileDialog)
main_layout.addWidget(self.browse_btn)
self.setLayout(main_layout)
- self._filePath = ''
- self._defaultRoot = default_root
- self._dialogTitle = dialog_title
- self._filter = ''
- self._options = QFileDialog.ShowDirsOnly
- self._mStorageMode = CustomFileWidget.GetMultipleFiles
@property
def filePath(self) -> str:
diff --git a/UI/main_window.ui b/UI/main_window.ui
index 09e15a3..d9c4f61 100644
--- a/UI/main_window.ui
+++ b/UI/main_window.ui
@@ -77,6 +77,53 @@
QFrame::Raised
+ -
+
+
+
+ Segoe UI
+ 9
+ 50
+ false
+ false
+
+
+
+ Input:
+
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+ Raster file
+
+
+
+ -
+
+
+
+ 120
+ 16777215
+
+
+
+ Select file
+
+
+
+ -
+
+
+
+
+
-
@@ -515,110 +562,105 @@
Options:
-
-
-
-
- Source image data type
-
-
-
- -
-
-
- Resampling
-
-
-
- -
-
-
- NoData
-
-
-
- -
-
+
-
+
-
- average
+ Byte
-
- near
+ Int8
-
- bilinear
+ UInt16
-
- cubic
+ Int16
-
- cubicspline
+ UInt32
-
- lanczos
+ Int32
-
- antialias
+ UInt64
-
- mode
+ Int64
-
- max
+ Float32
-
- min
+ Float64
-
- med
+ CInt16
-
- q1
+ CInt32
-
- q3
+ CFloat32
+
+
+ -
+
+ CFloat64
- -
-
+
-
+
+
+ Same as source SRS
+
+
- -
-
+
-
+
+
+ NoData
+
+
+
+ -
+
- New NoData value
+ Same as source SRS
- -
-
+
-
+
- Output image data type
+ Target coordinate system
@@ -632,8 +674,22 @@
+ -
+
+
+ Source image data type
+
+
+
+ -
+
+
+ Output image data type
+
+
+
-
-
+
-
Byte
@@ -706,90 +762,89 @@
+ -
+
+
+ New NoData value
+
+
+
-
-
-
-
-
- Byte
-
-
+
-
- Int8
+ average
-
- UInt16
+ near
-
- Int16
+ bilinear
-
- UInt32
+ cubic
-
- Int32
+ cubicspline
-
- UInt64
+ lanczos
-
- Int64
+ antialias
-
- Float32
+ mode
-
- Float64
+ max
-
- CInt16
+ min
-
- CInt32
+ med
-
- CFloat32
+ q1
-
- CFloat64
+ q3
- -
-
+
-
+
- Target coordinate system
+ Resampling
- -
-
-
@@ -1561,7 +1616,7 @@
-
- SRS
+ Source SRS
@@ -1833,7 +1888,7 @@
-
- Resolution - y
+ Resolution Y
@@ -1857,7 +1912,7 @@
-
- Resolution - x
+ Resolution X
@@ -2021,53 +2076,6 @@
- -
-
-
-
- Segoe UI
- 9
- 50
- false
- false
-
-
-
- Input:
-
-
-
-
-
-
-
- 0
- 0
-
-
-
- Raster file
-
-
-
- -
-
-
-
- 120
- 16777215
-
-
-
- Select file
-
-
-
- -
-
-
-
-
-
diff --git a/gdal_modules/ConvertTab.py b/gdal_modules/ConvertTab.py
index 18ed060..948b996 100644
--- a/gdal_modules/ConvertTab.py
+++ b/gdal_modules/ConvertTab.py
@@ -9,7 +9,7 @@
from CustomFileWidget import CustomFileWidget
from gdal_modules.TabPrototype import TabPrototype
from utils import insert_file_widget, get_extensions, APPLICATION_NAME, \
- universal_executor
+ universal_executor, simple_int_validator
class ConvertTab(TabPrototype, ABC):
@@ -22,7 +22,7 @@ def __init__(self, main_class: callable):
mode=CustomFileWidget.SaveFile,
filters=';; '.join([f'*.{ext}' for ext in get_extensions()]))
self.dlg.converter_save_btn.clicked.connect(self.convert_file)
- self.dlg.converter_srs_lineEdit.setValidator(QIntValidator())
+ self.dlg.converter_srs_lineEdit.setValidator(simple_int_validator(1))
def convert_file(self) -> None:
input_file = self.dlg.file_cbbx.currentText()
diff --git a/gdal_modules/MergeTilesTab.py b/gdal_modules/MergeTilesTab.py
index 1900a13..b097eff 100644
--- a/gdal_modules/MergeTilesTab.py
+++ b/gdal_modules/MergeTilesTab.py
@@ -8,7 +8,9 @@
from CustomFileWidget import CustomFileWidget
from gdal_modules.TabPrototype import TabPrototype
-from utils import insert_file_widget, get_extensions, APPLICATION_NAME
+from utils import insert_file_widget, get_extensions, APPLICATION_NAME, \
+ simple_float_validator, simple_int_validator
+
if os.path.exists(os.path.join(os.path.dirname(sys.executable), 'Scripts')):
sys.path.append(os.path.join(os.path.dirname(sys.executable), 'Scripts'))
import gdal_merge as gm
@@ -24,6 +26,9 @@ def __init__(self, main_class: callable):
mode=CustomFileWidget.SaveFile,
filters=';; '.join([f'*.{ext}' for ext in get_extensions()]))
self.dlg.merge_save_btn.clicked.connect(self.merge_rasters)
+ self.dlg.merge_nodata_lineEdit.setValidator(simple_float_validator())
+ self.dlg.pixel_x_lineEdit.setValidator(simple_int_validator(1))
+ self.dlg.pixel_y_lineEdit.setValidator(simple_int_validator(1))
def run(self, input_files: List[str],
output_path: Optional[str] = None) -> None:
diff --git a/gdal_modules/NoDataTab.py b/gdal_modules/NoDataTab.py
index a7329aa..13225cd 100644
--- a/gdal_modules/NoDataTab.py
+++ b/gdal_modules/NoDataTab.py
@@ -11,7 +11,8 @@
from CustomFileWidget import CustomFileWidget
from gdal_modules.TabPrototype import TabPrototype
from utils import universal_executor, json_to_html, APPLICATION_NAME, \
- get_extensions, proper_is_digit, insert_file_widget, FILE_DICT_INDEXES
+ get_extensions, proper_is_digit, insert_file_widget, FILE_DICT_INDEXES, \
+ simple_float_validator
class NoDataTab(TabPrototype, ABC):
@@ -25,6 +26,8 @@ def __init__(self, main_class: callable):
lambda: self.show_data(
self.dlg.file_cbbx.currentText()))
self.dlg.new_nodata_save_btn.clicked.connect(self.save_data)
+ self.dlg.nodata_new_value_lineedit.setValidator(
+ simple_float_validator())
self.dlg.nodata_output_path_lineedit = insert_file_widget(
self.dlg.nodata_output_path_groupBox.layout(), (0, 1),
mode=CustomFileWidget.SaveFile,
diff --git a/gdal_modules/TilesTab.py b/gdal_modules/TilesTab.py
index e17c859..6702a17 100644
--- a/gdal_modules/TilesTab.py
+++ b/gdal_modules/TilesTab.py
@@ -10,7 +10,8 @@
from CustomFileWidget import CustomFileWidget
from SimpleGdal2Tiles import SimpleGdal2Tiles
from gdal_modules.TabPrototype import TabPrototype
-from utils import APPLICATION_NAME, insert_file_widget
+from utils import APPLICATION_NAME, insert_file_widget, simple_float_validator, \
+ simple_int_validator
class TilesTab(TabPrototype, ABC):
@@ -25,11 +26,10 @@ def setup_dialog(self) -> None:
self.dlg.tiling_outdir_lineedit = insert_file_widget(
self.dlg.tiling_outdir_groupBox.layout(), (0, 1),
mode=CustomFileWidget.GetDirectory)
- self.dlg.tiling_srs_lineEdit.setValidator(QIntValidator())
+ self.dlg.tiling_srs_lineEdit.setValidator(simple_int_validator(1))
self.dlg.tiling_zoom_lineEdit.setValidator(
QRegExpValidator(QRegExp('[0-9-]{1,}')))
- self.dlg.tiling_nodata_lineEdit.setValidator(
- QDoubleValidator(-999999.9999999, 999999.9999999, 20))
+ self.dlg.tiling_nodata_lineEdit.setValidator(simple_float_validator())
self.dlg.tiling_xyz_checkbox.hide()
def save_data(self) -> None:
diff --git a/gdal_modules/TransformTab.py b/gdal_modules/TransformTab.py
index ab4a1b0..58473fd 100644
--- a/gdal_modules/TransformTab.py
+++ b/gdal_modules/TransformTab.py
@@ -8,7 +8,7 @@
from CustomFileWidget import CustomFileWidget
from gdal_modules.TabPrototype import TabPrototype
from utils import insert_file_widget, get_extensions, APPLICATION_NAME, \
- universal_executor
+ universal_executor, simple_float_validator, simple_int_validator
class TransformTab(TabPrototype, ABC):
@@ -21,6 +21,12 @@ def __init__(self, main_class: callable):
mode=CustomFileWidget.SaveFile,
filters=';; '.join([f'*.{ext}' for ext in get_extensions()]))
self.dlg.transform_save_btn.clicked.connect(self.transform_file)
+ self.dlg.transform_nodata_lineEdit.setValidator(
+ simple_float_validator())
+ self.dlg.transform_source_coord_lineEdit.setValidator(
+ simple_int_validator(1))
+ self.dlg.transform_target_coord_lineEdit.setValidator(
+ simple_int_validator(1))
def transform_file(self) -> None:
input_file = self.dlg.file_cbbx.currentText()
diff --git a/gdal_modules/VRTTab.py b/gdal_modules/VRTTab.py
index dcc642a..ccdf9ad 100644
--- a/gdal_modules/VRTTab.py
+++ b/gdal_modules/VRTTab.py
@@ -11,7 +11,7 @@
from CustomFileWidget import CustomFileWidget
from gdal_modules.TabPrototype import TabPrototype
from utils import insert_file_widget, APPLICATION_NAME, \
- universal_executor
+ universal_executor, simple_int_validator
class VRTTab(TabPrototype, ABC):
@@ -24,6 +24,8 @@ def __init__(self, main_class: callable):
mode=CustomFileWidget.SaveFile,
filters='*.vrt')
self.dlg.vrt_save_btn.clicked.connect(self.build_vrt)
+ self.dlg.vrt_user_res_x_lineEdit.setValidator(simple_int_validator(1))
+ self.dlg.vrt_user_res_y_lineEdit.setValidator(simple_int_validator(1))
self.setup_dialog()
def setup_dialog(self) -> None:
diff --git a/utils.py b/utils.py
index f5a6ec3..50d0eb9 100644
--- a/utils.py
+++ b/utils.py
@@ -5,7 +5,7 @@
from subprocess import run, PIPE
from typing import Optional, List, Tuple, Any, Union, Dict
-from PyQt5.QtGui import QIcon
+from PyQt5.QtGui import QIcon, QDoubleValidator, QIntValidator
from PyQt5.QtWidgets import QProgressDialog, QApplication, QLayout
from osgeo import gdal
@@ -103,6 +103,19 @@ def proper_is_digit(string_num: str, ret: bool = False) -> bool or float:
return False
+def simple_float_validator(minimum_val: float = -999999.9999999,
+ maximum_val: float = 999999.9999999,
+ precision: int = 20) -> QDoubleValidator:
+ valid = QDoubleValidator(minimum_val, maximum_val, precision)
+ valid.setNotation(QDoubleValidator.StandardNotation)
+ return valid
+
+
+def simple_int_validator(minimum_val: float = -99999999,
+ maximum_val: float = 99999999) -> QIntValidator:
+ return QIntValidator(minimum_val, maximum_val)
+
+
def json_to_html(
data: Union[Dict[str, Any], List[Any]], new: bool = True,
headers: Optional[List[str]] = None, delimiter_char: str = ':') -> str:
@@ -229,5 +242,6 @@ def insert_file_widget(destination_layout: QLayout, pos: Tuple[int, int],
file_widget.filter = filters
if action_after_use:
file_widget.lineEdit.textChanged.connect(action_after_use)
+ file_widget.lineEdit.set_correct_placeholder_text()
destination_layout.addWidget(file_widget, *pos)
return file_widget