qdesktopservices.sip 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // qdesktopservices.sip generated by MetaSIP
  2. //
  3. // This file is part of the QtGui Python extension module.
  4. //
  5. // Copyright (c) 2026 Riverbank Computing Limited <info@riverbankcomputing.com>
  6. //
  7. // This file is part of PyQt6.
  8. //
  9. // This file may be used under the terms of the GNU General Public License
  10. // version 3.0 as published by the Free Software Foundation and appearing in
  11. // the file LICENSE included in the packaging of this file. Please review the
  12. // following information to ensure the GNU General Public License version 3.0
  13. // requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  14. //
  15. // If you do not wish to use this file under the terms of the GPL version 3.0
  16. // then you may purchase a commercial license. For more information contact
  17. // info@riverbankcomputing.com.
  18. //
  19. // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  20. // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  21. class QDesktopServices
  22. {
  23. %TypeHeaderCode
  24. #include <qdesktopservices.h>
  25. %End
  26. public:
  27. static bool openUrl(const QUrl &url) /ReleaseGIL/;
  28. static void setUrlHandler(const QString &scheme, QObject *receiver, const char *method);
  29. static void setUrlHandler(const QString &scheme, SIP_PYCALLABLE method /TypeHint="Callable[[QUrl], None]"/);
  30. %MethodCode
  31. // Allow a callable that must be a slot of a QObject, although we never tell
  32. // the user if it isn't.
  33. sipMethodDef pm;
  34. if (sipGetMethod(a1, &pm))
  35. {
  36. int iserr = 0;
  37. QObject *receiver = reinterpret_cast<QObject *>(sipForceConvertToType(
  38. pm.pm_self, sipType_QObject, NULL, SIP_NOT_NONE, NULL, &iserr));
  39. if (!iserr)
  40. {
  41. PyObject *f_name_obj = PyObject_GetAttrString(pm.pm_function, "__name__");
  42. if (f_name_obj)
  43. {
  44. // We only want a borrowed reference.
  45. Py_DECREF(f_name_obj);
  46. const char *f_name = sipString_AsASCIIString(&f_name_obj);
  47. if (f_name)
  48. {
  49. QDesktopServices::setUrlHandler(*a0, receiver, f_name);
  50. Py_DECREF(f_name_obj);
  51. }
  52. }
  53. }
  54. }
  55. %End
  56. static void unsetUrlHandler(const QString &scheme);
  57. };