guiutil.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. // ECOin - Copyright (c) - 2014/2024 - GPLv3 - epsylon@riseup.net (https://03c8.net)
  2. #ifndef GUIUTIL_H
  3. #define GUIUTIL_H
  4. #include <QString>
  5. #include <QObject>
  6. #include <QMessageBox>
  7. QT_BEGIN_NAMESPACE
  8. class QFont;
  9. class QLineEdit;
  10. class QWidget;
  11. class QDateTime;
  12. class QUrl;
  13. class QAbstractItemView;
  14. QT_END_NAMESPACE
  15. class SendCoinsRecipient;
  16. namespace GUIUtil
  17. {
  18. // Create human-readable string from date
  19. QString dateTimeStr(const QDateTime &datetime);
  20. QString dateTimeStr(qint64 nTime);
  21. // Render Ecoin addresses in monospace font
  22. QFont ecoinAddressFont();
  23. // Set up widgets for address and amounts
  24. void setupAddressWidget(QLineEdit *widget, QWidget *parent);
  25. void setupAmountWidget(QLineEdit *widget, QWidget *parent);
  26. bool parseEcoinURI(const QUrl &uri, SendCoinsRecipient *out);
  27. bool parseEcoinURI(QString uri, SendCoinsRecipient *out);
  28. // HTML escaping for rich text controls
  29. QString HtmlEscape(const QString& str, bool fMultiLine=false);
  30. QString HtmlEscape(const std::string& str, bool fMultiLine=false);
  31. void copyEntryData(QAbstractItemView *view, int column, int role=Qt::EditRole);
  32. QString getSaveFileName(QWidget *parent=0, const QString &caption=QString(),
  33. const QString &dir=QString(), const QString &filter=QString(),
  34. QString *selectedSuffixOut=0);
  35. Qt::ConnectionType blockingGUIThreadConnection();
  36. // Determine whether a widget is hidden behind other windows
  37. bool isObscured(QWidget *w);
  38. // Open debug.log
  39. void openDebugLogfile();
  40. class ToolTipToRichTextFilter : public QObject
  41. {
  42. Q_OBJECT
  43. public:
  44. explicit ToolTipToRichTextFilter(int size_threshold, QObject *parent = 0);
  45. protected:
  46. bool eventFilter(QObject *obj, QEvent *evt);
  47. private:
  48. int size_threshold;
  49. };
  50. bool GetStartOnSystemStartup();
  51. bool SetStartOnSystemStartup(bool fAutoStart);
  52. /** Help message for Ecoin-Qt, shown with --help. */
  53. class HelpMessageBox : public QMessageBox
  54. {
  55. Q_OBJECT
  56. public:
  57. HelpMessageBox(QWidget *parent = 0);
  58. /** Show message box or print help message to standard output, based on operating system. */
  59. void showOrPrint();
  60. /** Print help message to console */
  61. void printToConsole();
  62. private:
  63. QString header;
  64. QString coreOptions;
  65. QString uiOptions;
  66. };
  67. } // namespace GUIUtil
  68. #endif // GUIUTIL_H