QsWidget.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #pragma once
  2. #include <QtWidgets/qwidget.h>
  3. #include "QtGui/qevent.h"
  4. #include "QtCore/qeventloop.h"
  5. #include <string>
  6. #include <Kaguya/kaguya.hpp>
  7. #include "ybase/define.h"
  8. #include "yqt/widget.hpp"
  9. #include "yqlua/QsIcon.h"
  10. class QsWidgetPrivatte:public ylib::qt::Widget<QWidget>
  11. {
  12. public:
  13. QsWidgetPrivatte(QWidget* parent);
  14. ~QsWidgetPrivatte();
  15. void exec_ex();
  16. private:
  17. void initEvent();
  18. protected:
  19. void closeEvent(QCloseEvent* event);
  20. private:
  21. QEventLoop m_loop;
  22. };
  23. class QsVBoxLayout;
  24. class QsHBoxLayout;
  25. class QsWidget
  26. {
  27. public:
  28. QsWidget(QWidget* point = nullptr, QWidget* parent = nullptr);
  29. ~QsWidget();
  30. operator QWidget* () const { return m_qwidget; }
  31. static void regist(kaguya::State& T);
  32. private:
  33. static void destory(QWidget* widget) { if (widget == nullptr)return; widget->hide(); widget->setParent(nullptr); }
  34. private:
  35. QWidget* qwidget() { return m_qwidget; }
  36. QObject* qobject() { return m_qwidget; }
  37. void setWindowTitle(const std::string& title);
  38. void setWindowMouseMoveHeight(int height);
  39. void setWindowModality(int mod);
  40. void setFixedHeight(int height);
  41. void setFixedWidth(int width);
  42. void setFixedSize(int width,int height);
  43. void setStyleSheet(const std::string& qss);
  44. void setParent(QsWidget* parent);
  45. void setAttribute(int value);
  46. void show();
  47. void hide();
  48. int x();
  49. int y();
  50. int width();
  51. int height();
  52. void setGeometry(int x, int y, int width, int height);
  53. bool isPage() { return m_auto_delete; }
  54. int windowFlags();
  55. void setWindowFlags(int flags);
  56. void setEnabled(bool enable);
  57. void raise();
  58. void lower();
  59. void hideTopBar();
  60. void showMinimized();
  61. void close();
  62. void exec_ex();
  63. void info(const std::string& body);
  64. void error(const std::string& body);
  65. void warn(const std::string& body);
  66. bool isHidden();
  67. void toWidgetCenter(QsWidget* widget);
  68. void center();
  69. int winId();
  70. void setWindowIcon2(const std::string& base64image);
  71. void setWindowIcon(QsIcon icon);
  72. void setWindowState(int state);
  73. void setLayoutV(QsVBoxLayout* layout);
  74. void setLayoutH(QsHBoxLayout* layout);
  75. void move(int x, int y);
  76. private:
  77. kaguya::LuaFunction m_onMousePress;
  78. QWidget* m_qwidget = nullptr;
  79. bool m_auto_delete = false;
  80. };