|
4 | 4 | import os |
5 | 5 | import re |
6 | 6 |
|
7 | | -from PySide6.QtCore import QMargins, QDate, QLocale, QPointF, QSize, QUrl |
| 7 | +from PySide6.QtCore import QMargins, QDate, QLocale, QPointF, QSize, QUrl, QT_TRANSLATE_NOOP |
8 | 8 | from PySide6.QtCore import Signal as pyqtSignal |
9 | 9 | from PySide6.QtGui import ( |
10 | 10 | Qt, |
@@ -1336,3 +1336,56 @@ def paintEvent(self, event): |
1336 | 1336 |
|
1337 | 1337 | def sizeHint(self): |
1338 | 1338 | return self.PaintingScaleFactor * QSize(self.maxStarCount, 1) |
| 1339 | + |
| 1340 | + |
| 1341 | +class CurrencyEdit(QComboBox): |
| 1342 | + Currencies = ( |
| 1343 | + ('ARS', QT_TRANSLATE_NOOP("Currency", "ARS - Argentine peso")), |
| 1344 | + ('AUD', QT_TRANSLATE_NOOP("Currency", "AUD - Australian dollar")), |
| 1345 | + ('BGN', QT_TRANSLATE_NOOP("Currency", "BGN - Bulgarian lev")), |
| 1346 | + ('BRL', QT_TRANSLATE_NOOP("Currency", "BRL - Brazilian real")), |
| 1347 | + ('BYN', QT_TRANSLATE_NOOP("Currency", "BYN - Belarusian ruble")), |
| 1348 | + ('CAD', QT_TRANSLATE_NOOP("Currency", "CAD - Canadian dollar")), |
| 1349 | + ('CHF', QT_TRANSLATE_NOOP("Currency", "CHF - Swiss franc")), |
| 1350 | + ('CZK', QT_TRANSLATE_NOOP("Currency", "CZK - Czech koruna")), |
| 1351 | + ('EUR', QT_TRANSLATE_NOOP("Currency", "EUR - Euro")), |
| 1352 | + ('GBP', QT_TRANSLATE_NOOP("Currency", "GBP - Pound sterling")), |
| 1353 | + ('HUF', QT_TRANSLATE_NOOP("Currency", "HUF - Hungarian forint")), |
| 1354 | + ('INR', QT_TRANSLATE_NOOP("Currency", "INR - Indian rupee")), |
| 1355 | + ('NOK', QT_TRANSLATE_NOOP("Currency", "NOK - Norwegian krone")), |
| 1356 | + ('PLN', QT_TRANSLATE_NOOP("Currency", "PLN - Polish złoty")), |
| 1357 | + ('RUB', QT_TRANSLATE_NOOP("Currency", "RUB - Russian ruble")), |
| 1358 | + ('SEK', QT_TRANSLATE_NOOP("Currency", "SEK - Swedish krona")), |
| 1359 | + ('TRY', QT_TRANSLATE_NOOP("Currency", "TRY - Turkish lira")), |
| 1360 | + ('UAH', QT_TRANSLATE_NOOP("Currency", "UAH - Ukrainian hryvnia")), |
| 1361 | + ('USD', QT_TRANSLATE_NOOP("Currency", "USD - United States dollar")), |
| 1362 | + ) |
| 1363 | + |
| 1364 | + def __init__(self, parent=None): |
| 1365 | + super().__init__(parent) |
| 1366 | + self.setMinimumWidth(120) |
| 1367 | + self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) |
| 1368 | + |
| 1369 | + self.addItem("") |
| 1370 | + for code, title in self.Currencies: |
| 1371 | + self.addItem(title, code) |
| 1372 | + |
| 1373 | + def clear(self): |
| 1374 | + self.setCurrentIndex(0) |
| 1375 | + |
| 1376 | + def setReadOnly(self, b): |
| 1377 | + self.setEnabled(not b) |
| 1378 | + |
| 1379 | + def text(self): |
| 1380 | + return self.currentData() |
| 1381 | + |
| 1382 | + def setText(self, text): |
| 1383 | + index = self.findData(text) |
| 1384 | + if index >= 0: |
| 1385 | + old_index = self.currentIndex() |
| 1386 | + self.setCurrentIndex(index) |
| 1387 | + if old_index == index: |
| 1388 | + self.currentIndexChanged.emit(index) |
| 1389 | + |
| 1390 | + def home(self, _mark): |
| 1391 | + return |
0 commit comments