1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776
crate::ix!();
//-------------------------------------------[.cpp/bitcoin/src/qt/guiutil.h]
/**
| Utility functions used by the Bitcoin
| Qt UI.
|
*/
pub mod gui_util {
use super::*;
/**
| Use this flags to prevent a "What's This"
| button in the title bar of the dialog
| on
|
| Windows.
|
*/
pub const DIALOG_FLAGS: u32 =
QtWindowTitleHint
| QtWindowSystemMenuHint
| QtWindowCloseButtonHint;
/**
| Qt event filter that intercepts ToolTipChange
| events, and replaces the tooltip with
| a rich text representation if needed.
| This assures that Qt can word-wrap long
| tooltip messages.
|
| Tooltips longer than the provided size
| threshold (in characters) are wrapped.
|
*/
#[Q_OBJECT]
pub struct ToolTipToRichTextFilter {
base: QObject,
size_threshold: i32,
}
/**
| Qt event filter that intercepts QEvent::FocusOut
| events for QLabel objects, and resets
| their `textInteractionFlags' property
| to get rid of the visible cursor.
|
| This is a temporary fix of QTBUG-59514.
|
*/
#[Q_OBJECT]
pub struct LabelOutOfFocusEventFilter {
base: QObject,
}
///-----------------------------
#[Q_OBJECT]
pub struct ThemedLabel {
base: QLabel,
platform_style: *const PlatformStyle,
image_filename: String,
pixmap_width: i32,
pixmap_height: i32,
}
///-----------------------
#[Q_OBJECT]
pub struct ClickableLabel {
base: ThemedLabel,
}
impl ClickableLabel {
/**
| Emitted when the label is clicked. The
| relative mouse coordinates of the click
| are passed to the signal.
|
*/
#[Q_SIGNAL]
pub fn clicked(&mut self, point: &QPoint) {
}
}
///-----------------------
#[Q_OBJECT]
pub struct ClickableProgressBar {
base: QProgressBar,
}
impl ClickableProgressBar {
/**
| Emitted when the progressbar is clicked.
| The relative mouse coordinates of the
| click are passed to the signal.
|
*/
#[Q_SIGNAL]
pub fn clicked(&mut self, point: &QPoint) {
}
}
pub type ProgressBar = ClickableProgressBar;
///----------------------
#[Q_OBJECT]
pub struct ItemDelegate {
base: QItemDelegate,
}
impl ItemDelegate {
pub fn new(parent: *mut QObject) -> Self {
todo!();
/*
: q_item_delegate(parent),
*/
}
#[Q_SIGNAL]
pub fn key_escape_pressed(&mut self) {
}
}
/**
| Splits the string into substrings wherever
| separator occurs, and returns the list
| of those strings. Empty strings do not
| appear in the result.
|
| QString::split() signature differs
| in different Qt versions:
|
| - QString::SplitBehavior is deprecated
| since Qt 5.15
|
| - QtSplitBehavior was introduced
| in Qt 5.14
|
| If {QString|Qt}::SkipEmptyParts
| behavior is required, use this function
| instead of QString::split().
|
*/
pub fn split_skip_empty_parts<SeparatorType>(
string: &String,
separator: &SeparatorType) -> QStringList {
todo!();
/*
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
return string.split(separator, QtSkipEmptyParts);
#else
return string.split(separator, QString::SkipEmptyParts);
#endif
*/
}
/**
| Queue a function to run in an object's
| event loop. This can be replaced by a
| call to the QMetaObject::invokeMethod
| functor overload after Qt 5.10, but
| for now use a QObject::connect for compatibility
| with older Qt versions, based on https://stackoverflow.com/questions/21646467/how-to-execute-a-functor-or-a-lambda-in-a-given-thread-in-qt-gcd-style
|
*/
pub fn object_invoke<Fn>(
object: *mut QObject,
function: Fn,
connection: Option<QtConnectionType>) {
let connection: QtConnectionType =
connection.unwrap_or(QtQueuedConnection);
todo!();
/*
QObject source;
QObject::connect(&source, &QObject::destroyed, object, std::forward<Fn>(function), connection);
*/
}
/**
| A drop-in replacement of QObject::connect
| function (see: https://doc.qt.io/qt-5/qobject.html#connect-3),
| that guaranties that all exceptions
| are handled within the slot.
|
| -----------
| @note
|
| This function is incompatible with
| Qt private signals.
|
*/
pub fn exception_safe_connect<Sender, Signal, Receiver, Slot, R>(
sender: Sender,
signal: Signal,
receiver: Receiver,
method: Slot,
ty: Option<QtConnectionType>) -> R {
let ty: QtConnectionType =
ty.unwrap_or(QtAutoConnection);
todo!();
/*
return QObject::connect(
sender, signal, receiver,
[sender, receiver, method](auto&&... args) {
bool ok{true};
try {
(receiver->*method)(std::forward<decltype(args)>(args)...);
} catch (const NonFatalCheckError& e) {
PrintSlotException(&e, sender, receiver);
ok = QMetaObject::invokeMethod(
qApp, "handleNonFatalException",
blockingGUIThreadConnection(),
Q_ARG(QString, QString::fromStdString(e.what())));
} catch (const std::exception& e) {
PrintSlotException(&e, sender, receiver);
ok = QMetaObject::invokeMethod(
qApp, "handleRunawayException",
blockingGUIThreadConnection(),
Q_ARG(QString, QString::fromStdString(e.what())));
} catch (...) {
PrintSlotException(nullptr, sender, receiver);
ok = QMetaObject::invokeMethod(
qApp, "handleRunawayException",
blockingGUIThreadConnection(),
Q_ARG(QString, "Unknown failure occurred."));
}
assert(ok);
},
type);
*/
}
/**
| Create human-readable string from
| date
|
*/
pub fn date_time_str_from_qdatetime(date: &QDateTime) -> String {
todo!();
/*
return QLocale::system().toString(date.date(), QLocale::ShortFormat) + QString(" ") + date.toString("hh:mm");
*/
}
pub fn date_time_str(n_time: i64) -> String {
todo!();
/*
return dateTimeStr(QDateTime::fromSecsSinceEpoch(nTime));
*/
}
/**
| Return a monospace font
|
*/
pub fn fixed_pitch_font(use_embedded_font: Option<bool>) -> QFont {
let use_embedded_font: bool = use_embedded_font.unwrap_or(false);
todo!();
/*
if (use_embedded_font) {
return {"Roboto Mono"};
}
return QFontDatabase::systemFont(QFontDatabase::FixedFont);
*/
}
/**
| Just some dummy data to generate a convincing
| random-looking (but consistent) address
|
*/
pub const DUMMYDATA: &[u8] =
&[
0xeb,0x15,0x23,0x1d,0xfc,0xeb,0x60,0x92,0x58,0x86,0xb6,0x7d,0x06,0x52,0x99,0x92,0x59,0x15,0xae,0xb1,0x72,0xc0,0x66,0x47
];
/**
| Generate a dummy address with invalid
| CRC, starting with the network prefix.
|
*/
pub fn dummy_address(params: &ChainParams) -> String {
todo!();
/*
std::vector<unsigned char> sourcedata = params.Base58Prefix(CChainParams::PUBKEY_ADDRESS);
sourcedata.insert(sourcedata.end(), dummydata, dummydata + sizeof(dummydata));
for(int i=0; i<256; ++i) { // Try every trailing byte
std::string s = EncodeBase58(sourcedata);
if (!IsValidDestinationString(s)) {
return s;
}
sourcedata[sourcedata.size()-1] += 1;
}
return "";
*/
}
/**
| Set up widget for address
|
*/
pub fn setup_address_widget(
widget: *mut QValidatedLineEdit,
parent: *mut QWidget) {
todo!();
/*
parent->setFocusProxy(widget);
widget->setFont(fixedPitchFont());
// We don't want translators to use own addresses in translations
// and this is the only place, where this address is supplied.
widget->setPlaceholderText(QObject::tr("Enter a Bitcoin address (e.g. %1)").arg(
QString::fromStdString(DummyAddress(Params()))));
widget->setValidator(new BitcoinAddressEntryValidator(parent));
widget->setCheckValidator(new BitcoinAddressCheckValidator(parent));
*/
}
/**
| Connects an additional shortcut to
| a QAbstractButton. Works around the
| one shortcut limitation of the button's
| shortcut property.
|
| -----------
| @param[in] button
|
| QAbstractButton to assign shortcut
| to
| ----------
| @param[in] shortcut
|
| QKeySequence to use as shortcut
|
*/
pub fn add_button_shortcut(
button: *mut QAbstractButton,
shortcut: &QKeySequence) {
todo!();
/*
QObject::connect(new QShortcut(shortcut, button), &QShortcut::activated, [button]() { button->animateClick(); });
*/
}
/**
| Parse "bitcoin:" URI into recipient
| object, return true on successful parsing
|
*/
pub fn parse_bitcoinuri_with_qurl(
uri: &QUrl,
out: *mut SendCoinsRecipient) -> bool {
todo!();
/*
// return if URI is not valid or is no bitcoin: URI
if(!uri.isValid() || uri.scheme() != QString("bitcoin"))
return false;
SendCoinsRecipient rv;
rv.address = uri.path();
// Trim any following forward slash which may have been added by the OS
if (rv.address.endsWith("/")) {
rv.address.truncate(rv.address.length() - 1);
}
rv.amount = 0;
QUrlQuery uriQuery(uri);
QList<QPair<QString, QString> > items = uriQuery.queryItems();
for (QList<QPair<QString, QString> >::iterator i = items.begin(); i != items.end(); i++)
{
bool fShouldReturnFalse = false;
if (i->first.startsWith("req-"))
{
i->first.remove(0, 4);
fShouldReturnFalse = true;
}
if (i->first == "label")
{
rv.label = i->second;
fShouldReturnFalse = false;
}
if (i->first == "message")
{
rv.message = i->second;
fShouldReturnFalse = false;
}
else if (i->first == "amount")
{
if(!i->second.isEmpty())
{
if(!BitcoinUnits::parse(BitcoinUnits::BTC, i->second, &rv.amount))
{
return false;
}
}
fShouldReturnFalse = false;
}
if (fShouldReturnFalse)
return false;
}
if(out)
{
*out = rv;
}
return true;
*/
}
///----------------------
pub fn parse_bitcoinuri(
uri: String,
out: *mut SendCoinsRecipient) -> bool {
todo!();
/*
QUrl uriInstance(uri);
return parseBitcoinURI(uriInstance, out);
*/
}
pub fn format_bitcoinuri(info: &SendCoinsRecipient) -> String {
todo!();
/*
bool bech_32 = info.address.startsWith(QString::fromStdString(Params().Bech32HRP() + "1"));
QString ret = QString("bitcoin:%1").arg(bech_32 ? info.address.toUpper() : info.address);
int paramCount = 0;
if (info.amount)
{
ret += QString("?amount=%1").arg(BitcoinUnits::format(BitcoinUnits::BTC, info.amount, false, BitcoinUnits::SeparatorStyle::NEVER));
paramCount++;
}
if (!info.label.isEmpty())
{
QString lbl(QUrl::toPercentEncoding(info.label));
ret += QString("%1label=%2").arg(paramCount == 0 ? "?" : "&").arg(lbl);
paramCount++;
}
if (!info.message.isEmpty())
{
QString msg(QUrl::toPercentEncoding(info.message));
ret += QString("%1message=%2").arg(paramCount == 0 ? "?" : "&").arg(msg);
paramCount++;
}
return ret;
*/
}
/**
| Returns true if given address+amount
| meets "dust" definition
|
*/
pub fn is_dust(
node: Rc<RefCell<dyn NodeInterface>>,
address: &String,
amount: &Amount) -> bool {
todo!();
/*
TxDestination dest = DecodeDestination(address.toStdString());
CScript script = GetScriptForDestination(dest);
CTxOut txOut(amount, script);
return IsDust(txOut, node.getDustRelayFee());
*/
}
/**
| HTML escaping for rich text controls
|
*/
pub fn html_escape(
str_: &String,
multi_line: Option<bool>) -> String {
let multi_line: bool = multi_line.unwrap_or(false);
todo!();
/*
QString escaped = str.toHtmlEscaped();
if(fMultiLine)
{
escaped = escaped.replace("\n", "<br>\n");
}
return escaped;
*/
}
/**
| Copy a field of the currently selected
| entry of a view to the clipboard. Does
| nothing if nothing is selected.
|
| -----------
| @param[in] column
|
| Data column to extract from the model
| ----------
| @param[in] role
|
| Data role to extract from the model @see
| TransactionView::copyLabel, TransactionView::copyAmount,
| TransactionView::copyAddress
|
*/
pub fn copy_entry_data(
view: *const QAbstractItemView,
column: i32,
role: Option<i32>) {
let role: i32 = role.unwrap_or(*QtEditRole);
todo!();
/*
if(!view || !view->selectionModel())
return;
QModelIndexList selection = view->selectionModel()->selectedRows(column);
if(!selection.isEmpty())
{
// Copy first item
setClipboard(selection.at(0).data(role).toString());
}
*/
}
/**
| Return a field of the currently selected
| entry as a QString. Does nothing if nothing
| is selected.
|
| -----------
| @param[in] column
|
| Data column to extract from the model
| @see TransactionView::copyLabel,
| TransactionView::copyAmount, TransactionView::copyAddress
|
*/
pub fn get_entry_data(
view: *const QAbstractItemView,
column: i32) -> QList<QModelIndex> {
todo!();
/*
if(!view || !view->selectionModel())
return QList<QModelIndex>();
return view->selectionModel()->selectedRows(column);
*/
}
/**
| Returns true if the specified field
| of the currently selected view entry
| is not empty.
|
| -----------
| @param[in] column
|
| Data column to extract from the model
| ----------
| @param[in] role
|
| Data role to extract from the model @see
| TransactionView::contextualMenu
|
*/
pub fn has_entry_data(
view: *const QAbstractItemView,
column: i32,
role: i32) -> bool {
todo!();
/*
QModelIndexList selection = getEntryData(view, column);
if (selection.isEmpty()) return false;
return !selection.at(0).data(role).toString().isEmpty();
*/
}
/**
| Loads the font from the file specified
| by file_name, aborts if it fails.
|
*/
pub fn load_font(file_name: &String) {
todo!();
/*
const int id = QFontDatabase::addApplicationFont(file_name);
assert(id != -1);
*/
}
/**
| Determine default data directory for
| operating system.
|
*/
pub fn get_default_data_directory() -> String {
todo!();
/*
return boostPathToQString(GetDefaultDataDir());
*/
}
/**
| Get save filename, mimics QFileDialog::getSaveFileName,
| except that it appends a default suffix
| when no suffix is provided by the user.
|
| -----------
| @param[in] parent
|
| Parent window (or 0)
| ----------
| @param[in] caption
|
| Window caption (or empty, for default)
| ----------
| @param[in] dir
|
| Starting directory (or empty, to default
| to documents directory)
| ----------
| @param[in] filter
|
| Filter specification such as "Comma
| Separated Files (*.csv)"
| ----------
| @param[out] selectedSuffixOut
|
| Pointer to return the suffix (file type)
| that was selected (or 0).
|
| Can be useful when choosing the save
| file format based on suffix.
|
*/
pub fn get_save_file_name(
parent: *mut QWidget,
caption: &String,
dir: &String,
filter: &String,
selected_suffix_out: *mut String) -> String {
todo!();
/*
QString selectedFilter;
QString myDir;
if(dir.isEmpty()) // Default to user documents location
{
myDir = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
}
else
{
myDir = dir;
}
/* Directly convert path to native OS path separators */
QString result = QDir::toNativeSeparators(QFileDialog::getSaveFileName(parent, caption, myDir, filter, &selectedFilter));
/* Extract first suffix from filter pattern "Description (*.foo)" or "Description (*.foo *.bar ...) */
QRegExp filter_re(".* \\(\\*\\.(.*)[ \\)]");
QString selectedSuffix;
if(filter_re.exactMatch(selectedFilter))
{
selectedSuffix = filter_re.cap(1);
}
/* Add suffix if needed */
QFileInfo info(result);
if(!result.isEmpty())
{
if(info.suffix().isEmpty() && !selectedSuffix.isEmpty())
{
/* No suffix specified, add selected suffix */
if(!result.endsWith("."))
result.append(".");
result.append(selectedSuffix);
}
}
/* Return selected suffix if asked to */
if(selectedSuffixOut)
{
*selectedSuffixOut = selectedSuffix;
}
return result;
*/
}
/**
| Get open filename, convenience wrapper
| for QFileDialog::getOpenFileName.
|
| -----------
| @param[in] parent
|
| Parent window (or 0)
| ----------
| @param[in] caption
|
| Window caption (or empty, for default)
| ----------
| @param[in] dir
|
| Starting directory (or empty, to default
| to documents directory)
| ----------
| @param[in] filter
|
| Filter specification such as "Comma
| Separated Files (*.csv)"
| ----------
| @param[out] selectedSuffixOut
|
| Pointer to return the suffix (file type)
| that was selected (or 0).
|
| Can be useful when choosing the save
| file format based on suffix.
|
*/
pub fn get_open_file_name(
parent: *mut QWidget,
caption: &String,
dir: &String,
filter: &String,
selected_suffix_out: *mut String) -> String {
todo!();
/*
QString selectedFilter;
QString myDir;
if(dir.isEmpty()) // Default to user documents location
{
myDir = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
}
else
{
myDir = dir;
}
/* Directly convert path to native OS path separators */
QString result = QDir::toNativeSeparators(QFileDialog::getOpenFileName(parent, caption, myDir, filter, &selectedFilter));
if(selectedSuffixOut)
{
/* Extract first suffix from filter pattern "Description (*.foo)" or "Description (*.foo *.bar ...) */
QRegExp filter_re(".* \\(\\*\\.(.*)[ \\)]");
QString selectedSuffix;
if(filter_re.exactMatch(selectedFilter))
{
selectedSuffix = filter_re.cap(1);
}
*selectedSuffixOut = selectedSuffix;
}
return result;
*/
}
/**
| Get connection type to call object slot
| in GUI thread with invokeMethod. The
| call will be blocking.
|
| -----------
| @return
|
| If called from the GUI thread, return
| a QtDirectConnection.
|
| If called from another thread, return
| a QtBlockingQueuedConnection.
|
*/
pub fn blocking_gui_thread_connection() -> QtConnectionType {
todo!();
/*
if(QThread::currentThread() != qApp->thread())
{
return QtBlockingQueuedConnection;
}
else
{
return QtDirectConnection;
}
*/
}
pub fn check_point(
p: &QPoint,
w: *const QWidget) -> bool {
todo!();
/*
QWidget *atW = QApplication::widgetAt(w->mapToGlobal(p));
if (!atW) return false;
return atW->window() == w;
*/
}
/**
| Determine whether a widget is hidden
| behind other windows
|
*/
pub fn is_obscured(w: *mut QWidget) -> bool {
todo!();
/*
return !(checkPoint(QPoint(0, 0), w)
&& checkPoint(QPoint(w->width() - 1, 0), w)
&& checkPoint(QPoint(0, w->height() - 1), w)
&& checkPoint(QPoint(w->width() - 1, w->height() - 1), w)
&& checkPoint(QPoint(w->width() / 2, w->height() / 2), w));
*/
}
/**
| Activate, show and raise the widget
|
*/
pub fn bring_to_front(w: *mut QWidget) {
todo!();
/*
#ifdef Q_OS_MAC
ForceActivation();
#endif
if (w) {
// activateWindow() (sometimes) helps with keyboard focus on Windows
if (w->isMinimized()) {
w->showNormal();
} else {
w->show();
}
w->activateWindow();
w->raise();
}
*/
}
/**
| Set shortcut to close window
|
*/
pub fn handle_close_window_shortcut(w: *mut QWidget) {
todo!();
/*
QObject::connect(new QShortcut(QKeySequence(QtCTRL + QtKey_W), w), &QShortcut::activated, w, &QWidget::close);
*/
}
/**
| Open debug.log
|
*/
pub fn open_debug_logfile() {
todo!();
/*
fs::path pathDebug = gArgs.GetDataDirNet() / "debug.log";
/* Open debug.log with the associated application */
if (fs::exists(pathDebug))
QDesktopServices::openUrl(QUrl::fromLocalFile(boostPathToQString(pathDebug)));
*/
}
/**
| Open the config file
|
*/
pub fn open_bitcoin_conf() -> bool {
todo!();
/*
fs::path pathConfig = GetConfigFile(gArgs.GetArg("-conf", BITCOIN_CONF_FILENAME));
/* Create the file */
fsbridge::ofstream configFile(pathConfig, std::ios_base::app);
if (!configFile.good())
return false;
configFile.close();
/* Open bitcoin.conf with the associated application */
bool res = QDesktopServices::openUrl(QUrl::fromLocalFile(boostPathToQString(pathConfig)));
#ifdef Q_OS_MAC
// Workaround for macOS-specific behavior; see #15409.
if (!res) {
res = QProcess::startDetached("/usr/bin/open", QStringList{"-t", boostPathToQString(pathConfig)});
}
#endif
return res;
*/
}
impl ToolTipToRichTextFilter {
pub fn new(
size_threshold: i32,
parent: *mut QObject) -> Self {
todo!();
/*
: q_object(parent),
: size_threshold(_size_threshold),
*/
}
pub fn event_filter(&mut self,
obj: *mut QObject,
evt: *mut QEvent) -> bool {
todo!();
/*
if(evt->type() == QEvent::ToolTipChange)
{
QWidget *widget = static_cast<QWidget*>(obj);
QString tooltip = widget->toolTip();
if(tooltip.size() > size_threshold && !tooltip.startsWith("<qt") && !QtmightBeRichText(tooltip))
{
// Envelop with <qt></qt> to make sure Qt detects this as rich text
// Escape the current message as HTML and replace \n by <br>
tooltip = "<qt>" + HtmlEscape(tooltip, true) + "</qt>";
widget->setToolTip(tooltip);
return true;
}
}
return QObject::eventFilter(obj, evt);
*/
}
}
impl LabelOutOfFocusEventFilter {
pub fn new(parent: *mut QObject) -> Self {
todo!();
/*
: q_object(parent),
*/
}
pub fn event_filter(&mut self,
watched: *mut QObject,
event: *mut QEvent) -> bool {
todo!();
/*
if (event->type() == QEvent::FocusOut) {
auto focus_out = static_cast<QFocusEvent*>(event);
if (focus_out->reason() != QtPopupFocusReason) {
auto label = qobject_cast<QLabel*>(watched);
if (label) {
auto flags = label->textInteractionFlags();
label->setTextInteractionFlags(QtNoTextInteraction);
label->setTextInteractionFlags(flags);
}
}
}
return QObject::eventFilter(watched, event);
*/
}
}
#[cfg(WIN32)]
pub fn startup_shortcut_path() -> Path {
todo!();
/*
std::string chain = gArgs.GetChainName();
if (chain == CBaseChainParams::MAIN)
return GetSpecialFolderPath(CSIDL_STARTUP) / "Bitcoin.lnk";
if (chain == CBaseChainParams::TESTNET) // Remove this special case when CBaseChainParams::TESTNET = "testnet4"
return GetSpecialFolderPath(CSIDL_STARTUP) / "Bitcoin (testnet).lnk";
return GetSpecialFolderPath(CSIDL_STARTUP) / strprintf("Bitcoin (%s).lnk", chain);
*/
}
#[cfg(WIN32)]
pub fn get_start_on_system_startup() -> bool {
todo!();
/*
// check for Bitcoin*.lnk
return fs::exists(StartupShortcutPath());
*/
}
#[cfg(WIN32)]
pub fn set_start_on_system_startup(auto_start: bool) -> bool {
todo!();
/*
// If the shortcut exists already, remove it for updating
fs::remove(StartupShortcutPath());
if (fAutoStart)
{
CoInitialize(nullptr);
// Get a pointer to the IShellLink interface.
IShellLinkW* psl = nullptr;
HRESULT hres = CoCreateInstance(CLSID_ShellLink, nullptr,
CLSCTX_INPROC_SERVER, IID_IShellLinkW,
reinterpret_cast<c_void**>(&psl));
if (SUCCEEDED(hres))
{
// Get the current executable path
WCHAR pszExePath[MAX_PATH];
GetModuleFileNameW(nullptr, pszExePath, ARRAYSIZE(pszExePath));
// Start client minimized
QString strArgs = "-min";
// Set -testnet /-regtest options
strArgs += QString::fromStdString(strprintf(" -chain=%s", gArgs.GetChainName()));
// Set the path to the shortcut target
psl->SetPath(pszExePath);
PathRemoveFileSpecW(pszExePath);
psl->SetWorkingDirectory(pszExePath);
psl->SetShowCmd(SW_SHOWMINNOACTIVE);
psl->SetArguments(strArgs.toStdWString().c_str());
// Query IShellLink for the IPersistFile interface for
// saving the shortcut in persistent storage.
IPersistFile* ppf = nullptr;
hres = psl->QueryInterface(IID_IPersistFile, reinterpret_cast<c_void**>(&ppf));
if (SUCCEEDED(hres))
{
// Save the link by calling IPersistFile::Save.
hres = ppf->Save(StartupShortcutPath().wstring().c_str(), TRUE);
ppf->Release();
psl->Release();
CoUninitialize();
return true;
}
psl->Release();
}
CoUninitialize();
return false;
}
return true;
*/
}
/**
| Follow the Desktop Application Autostart
| Spec: https://specifications.freedesktop.org/autostart-spec/autostart-spec-latest.html
|
*/
#[cfg(Q_OS_LINUX)]
pub fn get_autostart_dir() -> Path {
todo!();
/*
char* pszConfigHome = getenv("XDG_CONFIG_HOME");
if (pszConfigHome) return fs::path(pszConfigHome) / "autostart";
char* pszHome = getenv("HOME");
if (pszHome) return fs::path(pszHome) / ".config" / "autostart";
return fs::path();
*/
}
#[cfg(Q_OS_LINUX)]
pub fn get_autostart_file_path() -> Path {
todo!();
/*
std::string chain = gArgs.GetChainName();
if (chain == CBaseChainParams::MAIN)
return GetAutostartDir() / "bitcoin.desktop";
return GetAutostartDir() / strprintf("bitcoin-%s.desktop", chain);
*/
}
#[cfg(Q_OS_LINUX)]
pub fn get_start_on_system_startup() -> bool {
todo!();
/*
fsbridge::ifstream optionFile(GetAutostartFilePath());
if (!optionFile.good())
return false;
// Scan through file for "Hidden=true":
std::string line;
while (!optionFile.eof())
{
getline(optionFile, line);
if (line.find("Hidden") != std::string::npos &&
line.find("true") != std::string::npos)
return false;
}
optionFile.close();
return true;
*/
}
#[cfg(Q_OS_LINUX)]
pub fn set_start_on_system_startup(auto_start: bool) -> bool {
todo!();
/*
if (!fAutoStart)
fs::remove(GetAutostartFilePath());
else
{
char pszExePath[MAX_PATH+1];
ssize_t r = readlink("/proc/self/exe", pszExePath, sizeof(pszExePath) - 1);
if (r == -1)
return false;
pszExePath[r] = '\0';
fs::create_directories(GetAutostartDir());
fsbridge::ofstream optionFile(GetAutostartFilePath(), std::ios_base::out | std::ios_base::trunc);
if (!optionFile.good())
return false;
std::string chain = gArgs.GetChainName();
// Write a bitcoin.desktop file to the autostart directory:
optionFile << "[Desktop Entry]\n";
optionFile << "Type=Application\n";
if (chain == CBaseChainParams::MAIN)
optionFile << "Name=Bitcoin\n";
else
optionFile << strprintf("Name=Bitcoin (%s)\n", chain);
optionFile << "Exec=" << pszExePath << strprintf(" -min -chain=%s\n", chain);
optionFile << "Terminal=false\n";
optionFile << "Hidden=false\n";
optionFile.close();
}
return true;
*/
}
#[cfg(not(any(WIN32,Q_OS_LINUX)))]
pub fn get_start_on_system_startup() -> bool {
todo!();
/*
return false;
*/
}
#[cfg(not(any(WIN32,Q_OS_LINUX)))]
pub fn set_start_on_system_startup(auto_start: bool) -> bool {
todo!();
/*
return false;
*/
}
pub fn set_clipboard(str_: &String) {
todo!();
/*
QClipboard* clipboard = QApplication::clipboard();
clipboard->setText(str, QClipboard::Clipboard);
if (clipboard->supportsSelection()) {
clipboard->setText(str, QClipboard::Selection);
}
*/
}
/**
| Convert QString to OS specific boost
| path through UTF-8
|
*/
pub fn qstring_to_boost_path(path: &String) -> Box<Path> {
todo!();
/*
return fs::u8path(path.toStdString());
*/
}
/**
| Convert OS specific boost path to QString
| through UTF-8
|
*/
pub fn boost_path_to_qstring(path: &Box<Path>) -> String {
todo!();
/*
return QString::fromStdString(path.u8string());
*/
}
/**
| Convert enum Network to QString
|
*/
pub fn network_to_qstring(net: Network) -> String {
todo!();
/*
switch (net) {
case NET_UNROUTABLE: return QObject::tr("Unroutable");
case NET_IPV4: return "IPv4";
case NET_IPV6: return "IPv6";
case NET_ONION: return "Onion";
case NET_I2P: return "I2P";
case NET_CJDNS: return "CJDNS";
case NET_INTERNAL: return QObject::tr("Internal");
case NET_MAX: assert(false);
} // no default case, so the compiler can warn about missing cases
assert(false);
*/
}
/**
| Convert enum ConnectionType to QString
|
*/
pub fn connection_type_to_qstring(
conn_type: ConnectionType,
prepend_direction: bool) -> String {
todo!();
/*
QString prefix;
if (prepend_direction) {
prefix = (conn_type == ConnectionType::INBOUND) ?
/*: An inbound connection from a peer. An inbound connection
is a connection initiated by a peer. */
QObject::tr("Inbound") :
/*: An outbound connection to a peer. An outbound connection
is a connection initiated by us. */
QObject::tr("Outbound") + " ";
}
switch (conn_type) {
case ConnectionType::INBOUND: return prefix;
//: Peer connection type that relays all network information.
case ConnectionType::OUTBOUND_FULL_RELAY: return prefix + QObject::tr("Full Relay");
/*: Peer connection type that relays network information about
blocks and not transactions or addresses. */
case ConnectionType::BLOCK_RELAY: return prefix + QObject::tr("Block Relay");
//: Peer connection type established manually through one of several methods.
case ConnectionType::MANUAL: return prefix + QObject::tr("Manual");
//: Short-lived peer connection type that tests the aliveness of known addresses.
case ConnectionType::FEELER: return prefix + QObject::tr("Feeler");
//: Short-lived peer connection type that solicits known addresses from a peer.
case ConnectionType::ADDR_FETCH: return prefix + QObject::tr("Address Fetch");
} // no default case, so the compiler can warn about missing cases
assert(false);
*/
}
/**
| Convert seconds into a QString with
| days, hours, mins, secs
|
*/
pub fn format_duration_str(secs: i32) -> String {
todo!();
/*
QStringList strList;
int days = secs / 86400;
int hours = (secs % 86400) / 3600;
int mins = (secs % 3600) / 60;
int seconds = secs % 60;
if (days)
strList.append(QObject::tr("%1 d").arg(days));
if (hours)
strList.append(QObject::tr("%1 h").arg(hours));
if (mins)
strList.append(QObject::tr("%1 m").arg(mins));
if (seconds || (!days && !hours && !mins))
strList.append(QObject::tr("%1 s").arg(seconds));
return strList.join(" ");
*/
}
/**
| Format NodeStats.nServices bitmask
| into a user-readable string
|
*/
pub fn format_services_str(mask: u64) -> String {
todo!();
/*
QStringList strList;
for (const auto& flag : serviceFlagsToStr(mask)) {
strList.append(QString::fromStdString(flag));
}
if (strList.size())
return strList.join(", ");
else
return QObject::tr("None");
*/
}
/**
| Format a NodeStats.m_last_ping_time
| into a user-readable string or display
| N/A, if 0
|
*/
pub fn format_ping_time(ping_time: Duration /*micros*/) -> String {
todo!();
/*
return (ping_time == std::chrono::microseconds::max() || ping_time == 0us) ?
QObject::tr("N/A") :
QObject::tr("%1 ms").arg(QString::number((int)(count_microseconds(ping_time) / 1000), 10));
*/
}
/**
| Format a NodeCombinedStats.nTimeOffset
| into a user-readable string
|
*/
pub fn format_time_offset(n_time_offset: i64) -> String {
todo!();
/*
return QObject::tr("%1 s").arg(QString::number((int)nTimeOffset, 10));
*/
}
pub fn format_nice_time_offset(secs: i64) -> String {
todo!();
/*
// Represent time from last generated block in human readable text
QString timeBehindText;
const int HOUR_IN_SECONDS = 60*60;
const int DAY_IN_SECONDS = 24*60*60;
const int WEEK_IN_SECONDS = 7*24*60*60;
const int YEAR_IN_SECONDS = 31556952; // Average length of year in Gregorian calendar
if(secs < 60)
{
timeBehindText = QObject::tr("%n second(s)","",secs);
}
else if(secs < 2*HOUR_IN_SECONDS)
{
timeBehindText = QObject::tr("%n minute(s)","",secs/60);
}
else if(secs < 2*DAY_IN_SECONDS)
{
timeBehindText = QObject::tr("%n hour(s)","",secs/HOUR_IN_SECONDS);
}
else if(secs < 2*WEEK_IN_SECONDS)
{
timeBehindText = QObject::tr("%n day(s)","",secs/DAY_IN_SECONDS);
}
else if(secs < YEAR_IN_SECONDS)
{
timeBehindText = QObject::tr("%n week(s)","",secs/WEEK_IN_SECONDS);
}
else
{
i64 years = secs / YEAR_IN_SECONDS;
i64 remainder = secs % YEAR_IN_SECONDS;
timeBehindText = QObject::tr("%1 and %2").arg(QObject::tr("%n year(s)", "", years)).arg(QObject::tr("%n week(s)","", remainder/WEEK_IN_SECONDS));
}
return timeBehindText;
*/
}
pub fn format_bytes(bytes: u64) -> String {
todo!();
/*
if (bytes < 1'000)
return QObject::tr("%1 B").arg(bytes);
if (bytes < 1'000'000)
return QObject::tr("%1 kB").arg(bytes / 1'000);
if (bytes < 1'000'000'000)
return QObject::tr("%1 MB").arg(bytes / 1'000'000);
return QObject::tr("%1 GB").arg(bytes / 1'000'000'000);
*/
}
pub fn calculate_ideal_font_size(
width: i32,
text: &String,
font: QFont,
min_point_size: Option<f64>,
font_size: f64) -> f64 {
let min_point_size: f64 = min_point_size.unwrap_or(4.0);
//let start_point_size: f64 = start_point_size.unwrap_or(14.0);
todo!();
/*
while(font_size >= minPointSize) {
font.setPointSizeF(font_size);
QFontMetrics fm(font);
if (TextWidth(fm, text) < width) {
break;
}
font_size -= 0.5;
}
return font_size;
*/
}
impl ThemedLabel {
pub fn new(
platform_style: *const PlatformStyle,
parent: *mut QWidget) -> Self {
todo!();
/*
: QLabel{parent}, m_platform_style{platform_style}
assert(m_platform_style);
*/
}
pub fn set_themed_pixmap(&mut self,
image_filename: &String,
width: i32,
height: i32) {
todo!();
/*
m_image_filename = image_filename;
m_pixmap_width = width;
m_pixmap_height = height;
updateThemedPixmap();
*/
}
pub fn change_event(&mut self, e: *mut QEvent) {
todo!();
/*
if (e->type() == QEvent::PaletteChange) {
updateThemedPixmap();
}
QLabel::changeEvent(e);
*/
}
pub fn update_themed_pixmap(&mut self) {
todo!();
/*
setPixmap(m_platform_style->SingleColorIcon(m_image_filename).pixmap(m_pixmap_width, m_pixmap_height));
*/
}
}
impl ClickableLabel {
pub fn new(
platform_style: *const PlatformStyle,
parent: *mut QWidget) -> Self {
todo!();
/*
: ThemedLabel{platform_style, parent}
*/
}
pub fn mouse_release_event(&mut self, event: *mut QMouseEvent) {
todo!();
/*
Q_EMIT clicked(event->pos());
*/
}
}
impl ClickableProgressBar {
pub fn mouse_release_event(&mut self, event: *mut QMouseEvent) {
todo!();
/*
Q_EMIT clicked(event->pos());
*/
}
}
impl ItemDelegate {
pub fn event_filter(&mut self,
object: *mut QObject,
event: *mut QEvent) -> bool {
todo!();
/*
if (event->type() == QEvent::KeyPress) {
if (static_cast<QKeyEvent*>(event)->key() == QtKey_Escape) {
Q_EMIT keyEscapePressed();
}
}
return QItemDelegate::eventFilter(object, event);
*/
}
}
/**
| Fix known bugs in QProgressDialog class.
|
*/
pub fn polish_progress_dialog(dialog: *mut QProgressDialog) {
todo!();
/*
#ifdef Q_OS_MAC
// Workaround for macOS-only Qt bug; see: QTBUG-65750, QTBUG-70357.
const int margin = TextWidth(dialog->fontMetrics(), ("X"));
dialog->resize(dialog->width() + 2 * margin, dialog->height());
#endif
// QProgressDialog estimates the time the operation will take (based on time
// for steps), and only shows itself if that estimate is beyond minimumDuration.
// The default minimumDuration value is 4 seconds, and it could make users
// think that the GUI is frozen.
dialog->setMinimumDuration(0);
*/
}
/**
| Returns the distance in pixels appropriate
| for drawing a subsequent character
| after text.
|
| In Qt 5.12 and before the QFontMetrics::width()
| is used and it is deprecated since Qt
| 5.13.
|
| In Qt 5.11 the QFontMetrics::horizontalAdvance()
| was introduced.
|
*/
pub fn text_width(
fm: &QFontMetrics,
text: &String) -> i32 {
todo!();
/*
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
return fm.horizontalAdvance(text);
#else
return fm.width(text);
#endif
*/
}
/**
| Writes to debug.log short info about
| the used Qt and the host system.
|
*/
pub fn log_qt_info() {
todo!();
/*
#ifdef QT_STATIC
const std::string qt_link{"static"};
#else
const std::string qt_link{"dynamic"};
#endif
#ifdef QT_STATICPLUGIN
const std::string plugin_link{"static"};
#else
const std::string plugin_link{"dynamic"};
#endif
LogPrintf("Qt %s (%s), plugin=%s (%s)\n", qVersion(), qt_link, QGuiApplication::platformName().toStdString(), plugin_link);
const auto static_plugins = QPluginLoader::staticPlugins();
if (static_plugins.empty()) {
LogPrintf("No static plugins.\n");
} else {
LogPrintf("Static plugins:\n");
for (const QStaticPlugin& p : static_plugins) {
QJsonObject meta_data = p.metaData();
const std::string plugin_class = meta_data.take(QString("className")).toString().toStdString();
const int plugin_version = meta_data.take(QString("version")).toInt();
LogPrintf(" %s, version %d\n", plugin_class, plugin_version);
}
}
LogPrintf("Style: %s / %s\n", QApplication::style()->objectName().toStdString(), QApplication::style()->metaObject()->className());
LogPrintf("System: %s, %s\n", QSysInfo::prettyProductName().toStdString(), QSysInfo::buildAbi().toStdString());
for (const QScreen* s : QGuiApplication::screens()) {
LogPrintf("Screen: %s %dx%d, pixel ratio=%.1f\n", s->name().toStdString(), s->size().width(), s->size().height(), s->devicePixelRatio());
}
*/
}
/**
| Call QMenu::popup() only on supported
| QT_QPA_PLATFORM.
|
*/
pub fn popup_menu(
menu: *mut QMenu,
point: &QPoint,
at_action: Option<*mut QAction>) {
todo!();
/*
// The qminimal plugin does not provide window system integration.
if (QApplication::platformName() == "minimal") return;
menu->popup(point, at_action);
*/
}
/**
| Returns the start-moment of the day
| in local time.
|
| QDateTime::QDateTime(const QDate&
| date) is deprecated since Qt 5.15.
|
| QDate::startOfDay() was introduced
| in Qt 5.14.
|
*/
pub fn start_of_day(date: &QDate) -> QDateTime {
todo!();
/*
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
return date.startOfDay();
#else
return QDateTime(date);
#endif
*/
}
/**
| Returns true if pixmap has been set.
|
| QPixmap* QLabel::pixmap() is deprecated
| since Qt 5.15.
|
*/
pub fn has_pixmap(label: *const QLabel) -> bool {
todo!();
/*
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
return !label->pixmap(QtReturnByValue).isNull();
#else
return label->pixmap() != nullptr;
#endif
*/
}
pub fn get_image(label: *const QLabel) -> QImage {
todo!();
/*
if (!HasPixmap(label)) {
return QImage();
}
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
return label->pixmap(QtReturnByValue).toImage();
#else
return label->pixmap()->toImage();
#endif
*/
}
/**
| Replaces a plain text link with an HTML
| tagged one.
|
*/
pub fn make_html_link(
source: &String,
link: &String) -> String {
todo!();
/*
return QString(source).replace(
link,
QLatin1String("<a href=\"") + link + QLatin1String("\">") + link + QLatin1String("</a>"));
*/
}
pub fn print_slot_exception(
exception: *const Exception,
sender: *const QObject,
receiver: *const QObject) {
todo!();
/*
std::string description = sender->metaObject()->className();
description += "->";
description += receiver->metaObject()->className();
PrintExceptionContinue(exception, description.c_str());
*/
}
/**
| Shows a QDialog instance asynchronously,
| and deletes it on close.
|
*/
pub fn show_modal_dialog_and_delete_on_close(dialog: *mut QDialog) {
todo!();
/*
dialog->setAttribute(QtWA_DeleteOnClose);
dialog->setWindowModality(QtApplicationModal);
dialog->show();
*/
}
}
//-------------------------------------------[.cpp/bitcoin/src/qt/guiutil.cpp]
#[cfg(Q_OS_MAC)]
pub fn force_activation() {
todo!();
/*
*/
}