imagecropperdemo.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #ifndef TESTIMAGECROPPERLABEL_H
  2. #define TESTIMAGECROPPERLABEL_H
  3. #include <QObject>
  4. #include <QDialog>
  5. #include <QHBoxLayout>
  6. #include <QLabel>
  7. #include <QComboBox>
  8. #include <QLineEdit>
  9. #include <QCheckBox>
  10. #include <QPushButton>
  11. #include <QSlider>
  12. #include "imagecropperlabel.h"
  13. class ImageCropperDemo : public QDialog
  14. {
  15. Q_OBJECT
  16. public:
  17. ImageCropperDemo(QWidget* parent = nullptr);
  18. void setupLayout();
  19. void init();
  20. public slots:
  21. void onOutputShapeChanged(int idx);
  22. void onCropperShapeChanged(int idx);
  23. void onEnableOpacityChanged(int state);
  24. void onShowDragSquareChanged(int state);
  25. void onDragSquareEdgeChanged(QString edge);
  26. void onOpacityChanged(int val);
  27. void onFixedWidthChanged(QString width);
  28. void onFixedHeightChanged(QString height);
  29. void onWidthChanged(QString width);//厘米宽度改变事件
  30. void onHeightChanged(QString height);//厘米高度改变事件
  31. void onMinWidthChanged(QString width);
  32. void onMinHeightChanged(QString height);
  33. void onShowRectBorder(int state);
  34. void onChooseRectBorderColor();
  35. void onChooseDragSquareColor();
  36. void onChooseOriginalImage();
  37. void onUpdatePreview();
  38. void onSaveCroppedImage();
  39. private:
  40. void setLabelColor(QLabel* label, QColor color) {
  41. QPixmap pixmap(QSize(80, 25));
  42. pixmap.fill(color);
  43. label->setPixmap(pixmap);
  44. }
  45. private:
  46. ImageCropperLabel* imgCropperLabel;
  47. QHBoxLayout* mainLayout;
  48. QLabel* labelPreviewImage;
  49. QComboBox* comboOutputShape;
  50. QComboBox* comboCropperShape;
  51. QLineEdit* editOriginalImagePath;
  52. QPushButton* btnChooseOriginalImagePath;
  53. QLineEdit* editCropperFixedWidth;//固定尺寸宽度,单位像素
  54. QLineEdit* editCropperFixedHeight;//固定尺寸高度,单位像素
  55. QLineEdit* editCropperMinWidth;
  56. QLineEdit* editCropperMinHeight;
  57. QLineEdit* editResolution;//设置图片分辨率
  58. QLineEdit* editFixedWidth;//固定尺寸宽度,单位厘米
  59. QLineEdit* editFixedHeight;//固定尺寸高度,单位厘米
  60. QCheckBox* checkShowDragSquare;
  61. QCheckBox* checkEnableOpacity;
  62. QSlider* sliderOpacity;
  63. QLineEdit* editDragSquareEdge;
  64. QCheckBox* checkShowRectBorder;
  65. QLabel* labelRectBorderColor;
  66. QPushButton* btnChooseRectBorderCorlor;
  67. QLabel* labelDragSquareColor;
  68. QPushButton* btnChooseDragSquareColor;
  69. QPushButton* btnSavePreview;
  70. QPushButton* btnQuit;
  71. };
  72. #endif // TESTIMAGECROPPERLABEL_H