├── .gitignore ├── Example ├── Example.pro ├── example_resources.qrc ├── main.cpp ├── nbaseuikittest.cpp ├── nbaseuikittest.h ├── nbaseuikittest.ui └── res │ ├── icon_sun.png │ └── test.jpg ├── NBaseUiKit.pro ├── NBaseUiKit ├── 3rdparty │ ├── 3rdparty.pri │ ├── imagecropper │ │ ├── imagecropper.pri │ │ ├── inc │ │ │ ├── imagecropper.h │ │ │ ├── imagecropper_e.h │ │ │ └── imagecropper_p.h │ │ └── src │ │ │ └── imagecropper.cpp │ ├── qrencode │ │ ├── qrencode.pri │ │ └── qrencode │ │ │ ├── bitstream.c │ │ │ ├── bitstream.h │ │ │ ├── config.h │ │ │ ├── mask.c │ │ │ ├── mask.h │ │ │ ├── mmask.c │ │ │ ├── mmask.h │ │ │ ├── mqrspec.c │ │ │ ├── mqrspec.h │ │ │ ├── qrencode.c │ │ │ ├── qrencode.h │ │ │ ├── qrencode_inner.h │ │ │ ├── qrinput.c │ │ │ ├── qrinput.h │ │ │ ├── qrspec.c │ │ │ ├── qrspec.h │ │ │ ├── rscode.c │ │ │ ├── rscode.h │ │ │ ├── split.c │ │ │ └── split.h │ └── waiting │ │ ├── inc │ │ └── waitingspinnerwidget.h │ │ ├── qtwaitingspinner.pri │ │ └── src │ │ └── waitingspinnerwidget.cpp ├── NBaseUiKit.pro ├── NBaseUiKit_inc.pri ├── NBaseUiKit_resource.rc ├── NBaseUiKit_src.pri ├── image_resources.qrc ├── img │ ├── bg_hover.png │ ├── bg_lock.png │ ├── bg_setting.png │ ├── bg_tool.png │ ├── brightness.png │ ├── checked.png │ ├── delete.png │ ├── hover.png │ ├── image.png │ ├── locked.png │ ├── locked_2.png │ ├── rolling.gif │ ├── shadow_bottom.png │ ├── shadow_corner1.png │ ├── shadow_corner2.png │ ├── shadow_corner3.png │ ├── shadow_corner4.png │ ├── shadow_left.png │ ├── shadow_right.png │ ├── shadow_top.png │ ├── unlock.png │ ├── unlock_hover.png │ ├── upload.png │ ├── upload_hover.png │ ├── upload_press.png │ └── window_shadow.png ├── inc │ ├── nbasecaptcha.h │ ├── nbasecircleanimationwidget.h │ ├── nbaseclickwave.h │ ├── nbasecountdown.h │ ├── nbasefadewidget.h │ ├── nbaseimagecropper.h │ ├── nbaseledwidget.h │ ├── nbaselogowidget.h │ ├── nbasemarqueelabel.h │ ├── nbaseminiappwidget.h │ ├── nbasemoveablewidget.h │ ├── nbasepopwidget.h │ ├── nbaseqrencodewidget.h │ ├── nbasereelwidget.h │ ├── nbaserotatingstackedwidget.h │ ├── nbaseroundprogressbar.h │ ├── nbaseshadowlabel.h │ ├── nbaseshadowwidget.h │ ├── nbasesnowlabel.h │ ├── nbaseswitchbutton.h │ ├── nbasetoastr.h │ ├── nbasetoolbutton.h │ ├── nbaseuikit_global.h │ ├── nbasewaitdialog.h │ ├── ntouchlistview.h │ └── ntouchlistwidget.h └── src │ ├── nbasecaptcha.cpp │ ├── nbasecircleanimationwidget.cpp │ ├── nbaseclickwave.cpp │ ├── nbasecountdown.cpp │ ├── nbasefadewidget.cpp │ ├── nbaseimagecropper.cpp │ ├── nbaseledwidget.cpp │ ├── nbaselogowidget.cpp │ ├── nbasemarqueelabel.cpp │ ├── nbaseminiappwidget.cpp │ ├── nbasemoveablewidget.cpp │ ├── nbasepopwidget.cpp │ ├── nbaseqrencodewidget.cpp │ ├── nbasereelwidget.cpp │ ├── nbaserotatingstackedwidget.cpp │ ├── nbaseroundprogressbar.cpp │ ├── nbaseshadowlabel.cpp │ ├── nbaseshadowwidget.cpp │ ├── nbasesnowlabel.cpp │ ├── nbaseswitchbutton.cpp │ ├── nbasetoastr.cpp │ ├── nbasetoolbutton.cpp │ ├── nbasewaitdialog.cpp │ ├── ntouchlistview.cpp │ └── ntouchlistwidget.cpp ├── README.md ├── Scripts ├── clear.bat └── clear.sh └── _config.yml /.gitignore: -------------------------------------------------------------------------------- 1 | /NBaseUiKit.pro.user 2 | /.qmake.stash 3 | /bin 4 | /NBaseUiKit/*.Release 5 | /NBaseUiKit/*.Debug 6 | /NBaseUiKit/NBaseUiKit.pro.user 7 | -------------------------------------------------------------------------------- /Example/Example.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2016-08-05T15:36:47 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui 8 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 10 | 11 | TARGET = NBaseUiKit_Example 12 | TEMPLATE = app 13 | 14 | 15 | SOURCES += main.cpp \ 16 | nbaseuikittest.cpp 17 | 18 | HEADERS += \ 19 | nbaseuikittest.h 20 | 21 | # 定义输出路径 22 | CONFIG += debug_and_release 23 | CONFIG(release, debug|release) { 24 | target_path = ./build_/dist 25 | } else { 26 | target_path = ./build_/debug 27 | } 28 | DESTDIR = ../bin 29 | MOC_DIR = $$target_path/moc 30 | RCC_DIR = $$target_path/rcc 31 | UI_DIR = $$target_path/ui 32 | OBJECTS_DIR = $$target_path/obj 33 | 34 | # 引入测试类库 35 | LIBS += -L$$OUT_PWD/../bin/ -lNBaseUiKit 36 | include(../NBaseUiKit/NBaseUiKit_inc.pri) 37 | 38 | # 输出编译套件信息 39 | message(Qt version: $$[QT_VERSION]) 40 | message(Qt is installed in $$[QT_INSTALL_PREFIX]) 41 | message(the NBaseUiKit_Example will create in folder: $$target_path) 42 | 43 | RESOURCES += \ 44 | example_resources.qrc 45 | 46 | FORMS += \ 47 | nbaseuikittest.ui 48 | -------------------------------------------------------------------------------- /Example/example_resources.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | res/icon_sun.png 4 | res/test.jpg 5 | 6 | 7 | -------------------------------------------------------------------------------- /Example/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "nbaseuikittest.h" 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | NBaseUiKitTest test_widget; 8 | test_widget.show(); 9 | return a.exec(); 10 | } 11 | -------------------------------------------------------------------------------- /Example/nbaseuikittest.h: -------------------------------------------------------------------------------- 1 | #ifndef NBASEUIKITTEST_H 2 | #define NBASEUIKITTEST_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class NBaseUiKitTest; 8 | } 9 | 10 | class NBaseUiKitTest : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit NBaseUiKitTest(QWidget *parent = 0); 16 | ~NBaseUiKitTest(); 17 | 18 | private slots: 19 | /** 20 | * @brief on_pushButton_clicked 可以移动窗体的测试用例 21 | */ 22 | void on_pushButton_clicked(); 23 | 24 | /** 25 | * @brief on_pushButton_2_clicked 渐入渐出窗体测试用例 26 | */ 27 | void on_pushButton_2_clicked(); 28 | 29 | /** 30 | * @brief on_pushButton_3_clicked 迷你窗体测试用例 31 | */ 32 | void on_pushButton_3_clicked(); 33 | 34 | /** 35 | * @brief on_pushButton_4_clicked 阴影窗体测试用例 36 | */ 37 | void on_pushButton_4_clicked(); 38 | 39 | /** 40 | * @brief on_pushButton_5_clicked 弹出窗体测试用例 41 | */ 42 | void on_pushButton_5_clicked(); 43 | 44 | /** 45 | * @brief on_pushButton_6_clicked snowLabel测试用例 46 | */ 47 | void on_pushButton_6_clicked(); 48 | 49 | /** 50 | * @brief on_pushButton_8_clicked 圆周运动窗体测试用例 51 | */ 52 | void on_pushButton_8_clicked(); 53 | 54 | /** 55 | * @brief on_pushButton_7_clicked LED窗体测试用例 56 | */ 57 | void on_pushButton_7_clicked(); 58 | 59 | /** 60 | * @brief on_pushButton_9_clicked LED窗体测试用例(闪光灯效果) 61 | */ 62 | void on_pushButton_9_clicked(); 63 | 64 | /** 65 | * @brief on_pushButton_10_clicked 跑马灯label测试用例 66 | */ 67 | void on_pushButton_10_clicked(); 68 | 69 | /** 70 | * @brief on_pushButton_11_clicked QR测试用例 71 | */ 72 | void on_pushButton_11_clicked(); 73 | 74 | /** 75 | * @brief on_pushButton_12_clicked 圆形进度条测试用例(甜甜圈样式) 76 | */ 77 | void on_pushButton_12_clicked(); 78 | 79 | /** 80 | * @brief on_pushButton_13_clicked 圆形进度条测试用例(线性样式) 81 | */ 82 | void on_pushButton_13_clicked(); 83 | 84 | /** 85 | * @brief on_pushButton_14_clicked toastr 测试用例 86 | */ 87 | void on_pushButton_14_clicked(); 88 | 89 | /** 90 | * @brief on_pushButton_15_clicked 阴影Label 测试用例 91 | */ 92 | void on_pushButton_15_clicked(); 93 | 94 | /** 95 | * @brief on_pushButton_16_clicked 等待框(box) 测试用例 96 | */ 97 | void on_pushButton_16_clicked(); 98 | 99 | /** 100 | * @brief on_pushButton_16_clicked 等待框(android) 测试用例 101 | */ 102 | void on_pushButton_17_clicked(); 103 | 104 | /** 105 | * @brief on_pushButton_17_clicked 触屏垂直滚动 测试用例 106 | */ 107 | void on_pushButton_18_clicked(); 108 | 109 | /** 110 | * @brief on_pushButton_19_clicked 反转窗体 测试用例 111 | */ 112 | void on_pushButton_19_clicked(); 113 | 114 | /** 115 | * @brief on_pushButton_20_clicked 触屏水平滚动 测试用例 116 | */ 117 | void on_pushButton_20_clicked(); 118 | 119 | /** 120 | * @brief on_pushButton_21_clicked 验证码窗体 测试用例 121 | */ 122 | void on_pushButton_21_clicked(); 123 | 124 | /** 125 | * @brief on_pushButton_22_clicked 图片截取 测试用例 126 | */ 127 | void on_pushButton_22_clicked(); 128 | 129 | /** 130 | * @brief on_pushButton_23_clicked switch按钮 测试用例 131 | */ 132 | void on_pushButton_23_clicked(); 133 | 134 | /** 135 | * @brief on_pushButton_24_clicked 卷轴widget 测试用例 136 | */ 137 | void on_pushButton_24_clicked(); 138 | 139 | /** 140 | * @brief on_pushButton_25_clicked 头像编辑 测试用例 141 | */ 142 | void on_pushButton_25_clicked(); 143 | 144 | /** 145 | * @brief on_pushButton_26_clicked 点击波按钮 146 | */ 147 | void on_pushButton_26_clicked(); 148 | 149 | /** 150 | * @brief on_pushButton_27_clicked 倒计时按钮 151 | */ 152 | void on_pushButton_27_clicked(); 153 | 154 | private: 155 | Ui::NBaseUiKitTest *ui; 156 | }; 157 | 158 | #endif // NBASEUIKITTEST_H 159 | -------------------------------------------------------------------------------- /Example/res/icon_sun.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daodaoliang/NBaseUiKit/33de66f4a493a4299849ea091ee1957740f5c8f2/Example/res/icon_sun.png -------------------------------------------------------------------------------- /Example/res/test.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daodaoliang/NBaseUiKit/33de66f4a493a4299849ea091ee1957740f5c8f2/Example/res/test.jpg -------------------------------------------------------------------------------- /NBaseUiKit.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | 3 | SUBDIRS += \ 4 | NBaseUiKit \ 5 | Example 6 | -------------------------------------------------------------------------------- /NBaseUiKit/3rdparty/3rdparty.pri: -------------------------------------------------------------------------------- 1 | include($$PWD/qrencode/qrencode.pri) 2 | include($$PWD/waiting/qtwaitingspinner.pri) 3 | include($$PWD/imagecropper/imagecropper.pri) 4 | -------------------------------------------------------------------------------- /NBaseUiKit/3rdparty/imagecropper/imagecropper.pri: -------------------------------------------------------------------------------- 1 | 2 | HEADERS += \ 3 | $$PWD/inc/imagecropper.h \ 4 | $$PWD/inc/imagecropper_e.h \ 5 | $$PWD/inc/imagecropper_p.h 6 | 7 | SOURCES += \ 8 | $$PWD/src/imagecropper.cpp 9 | 10 | INCLUDEPATH += $$PWD/inc/ \ 11 | -------------------------------------------------------------------------------- /NBaseUiKit/3rdparty/imagecropper/inc/imagecropper.h: -------------------------------------------------------------------------------- 1 | #ifndef IMAGECROPPER_H 2 | #define IMAGECROPPER_H 3 | 4 | #include "imagecropper_p.h" 5 | #include "imagecropper_e.h" 6 | #include 7 | 8 | class ImageCropper : public QWidget 9 | { 10 | Q_OBJECT 11 | 12 | public: 13 | ImageCropper(QWidget *parent = 0); 14 | ~ImageCropper(); 15 | 16 | public slots: 17 | void setImage(const QPixmap& _image); 18 | 19 | void setBackgroundColor(const QColor& _backgroundColor); 20 | 21 | void setCroppingRectBorderColor(const QColor& _borderColor); 22 | 23 | void setProportion(const QSizeF& _proportion); 24 | 25 | void setProportionFixed(const bool _isFixed); 26 | 27 | public: 28 | 29 | const QPixmap cropImage(); 30 | 31 | protected: 32 | virtual void paintEvent(QPaintEvent* _event); 33 | virtual void mousePressEvent(QMouseEvent* _event); 34 | virtual void mouseMoveEvent(QMouseEvent* _event); 35 | virtual void mouseReleaseEvent(QMouseEvent* _event); 36 | 37 | private: 38 | 39 | CursorPosition cursorPosition(const QRectF& _cropRect, const QPointF& _mousePosition); 40 | 41 | void updateCursorIcon(const QPointF& _mousePosition); 42 | 43 | const QRectF calculateGeometry( 44 | const QRectF& _sourceGeometry, 45 | const CursorPosition _cursorPosition, 46 | const QPointF& _mouseDelta 47 | ); 48 | 49 | const QRectF calculateGeometryWithCustomProportions( 50 | const QRectF& _sourceGeometry, 51 | const CursorPosition _cursorPosition, 52 | const QPointF& _mouseDelta 53 | ); 54 | 55 | const QRectF calculateGeometryWithFixedProportions(const QRectF &_sourceGeometry, 56 | const CursorPosition _cursorPosition, 57 | const QPointF &_mouseDelta, 58 | const QSizeF &_deltas 59 | ); 60 | 61 | private: 62 | 63 | ImageCropperPrivate* pimpl; 64 | }; 65 | 66 | #endif // IMAGECROPPER_H 67 | -------------------------------------------------------------------------------- /NBaseUiKit/3rdparty/imagecropper/inc/imagecropper_e.h: -------------------------------------------------------------------------------- 1 | #ifndef IMAGECROPPER_E_H 2 | #define IMAGECROPPER_E_H 3 | 4 | enum CursorPosition 5 | { 6 | CursorPositionUndefined, 7 | CursorPositionMiddle, 8 | CursorPositionTop, 9 | CursorPositionBottom, 10 | CursorPositionLeft, 11 | CursorPositionRight, 12 | CursorPositionTopLeft, 13 | CursorPositionTopRight, 14 | CursorPositionBottomLeft, 15 | CursorPositionBottomRight 16 | }; 17 | 18 | #endif // IMAGECROPPER_E_H 19 | -------------------------------------------------------------------------------- /NBaseUiKit/3rdparty/imagecropper/inc/imagecropper_p.h: -------------------------------------------------------------------------------- 1 | #ifndef IMAGECROPPER_P_H 2 | #define IMAGECROPPER_P_H 3 | 4 | #include "imagecropper_e.h" 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | namespace { 11 | const QRect INIT_CROPPING_RECT = QRect(); 12 | const QSizeF INIT_PROPORTION = QSizeF(1.0, 1.0); 13 | } 14 | 15 | class ImageCropperPrivate { 16 | public: 17 | ImageCropperPrivate() : 18 | imageForCropping(QPixmap()), 19 | croppingRect(INIT_CROPPING_RECT), 20 | lastStaticCroppingRect(QRect()), 21 | cursorPosition(CursorPositionUndefined), 22 | isMousePressed(false), 23 | isProportionFixed(false), 24 | startMousePos(QPoint()), 25 | proportion(INIT_PROPORTION), 26 | deltas(INIT_PROPORTION), 27 | backgroundColor(Qt::black), 28 | croppingRectBorderColor(Qt::white) 29 | {} 30 | 31 | public: 32 | 33 | QPixmap imageForCropping; 34 | 35 | QRectF croppingRect; 36 | 37 | QRectF lastStaticCroppingRect; 38 | 39 | CursorPosition cursorPosition; 40 | 41 | bool isMousePressed; 42 | 43 | bool isProportionFixed; 44 | 45 | QPointF startMousePos; 46 | 47 | QSizeF proportion; 48 | 49 | QSizeF deltas; 50 | 51 | QColor backgroundColor; 52 | 53 | QColor croppingRectBorderColor; 54 | }; 55 | 56 | #endif // IMAGECROPPER_P_H 57 | -------------------------------------------------------------------------------- /NBaseUiKit/3rdparty/qrencode/qrencode.pri: -------------------------------------------------------------------------------- 1 | 2 | HEADERS += \ 3 | $$PWD/qrencode/bitstream.h \ 4 | $$PWD/qrencode/config.h \ 5 | $$PWD/qrencode/mask.h \ 6 | $$PWD/qrencode/mmask.h \ 7 | $$PWD/qrencode/mqrspec.h \ 8 | $$PWD/qrencode/qrencode.h \ 9 | $$PWD/qrencode/qrencode_inner.h \ 10 | $$PWD/qrencode/qrinput.h \ 11 | $$PWD/qrencode/qrspec.h \ 12 | $$PWD/qrencode/rscode.h \ 13 | $$PWD/qrencode/split.h 14 | 15 | SOURCES += \ 16 | $$PWD/qrencode/bitstream.c \ 17 | $$PWD/qrencode/mask.c \ 18 | $$PWD/qrencode/mmask.c \ 19 | $$PWD/qrencode/mqrspec.c \ 20 | $$PWD/qrencode/qrencode.c \ 21 | $$PWD/qrencode/qrinput.c \ 22 | $$PWD/qrencode/qrspec.c \ 23 | $$PWD/qrencode/rscode.c \ 24 | $$PWD/qrencode/split.c 25 | 26 | INCLUDEPATH += $$PWD/qrencode/ \ 27 | -------------------------------------------------------------------------------- /NBaseUiKit/3rdparty/qrencode/qrencode/bitstream.c: -------------------------------------------------------------------------------- 1 | /* 2 | * qrencode - QR Code encoder 3 | * 4 | * Binary sequence class. 5 | * Copyright (C) 2006-2011 Kentaro Fukuchi 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #include "config.h" 23 | #include 24 | #include 25 | #include 26 | 27 | #include "bitstream.h" 28 | 29 | BitStream *BitStream_new(void) 30 | { 31 | BitStream *bstream; 32 | 33 | bstream = (BitStream *)malloc(sizeof(BitStream)); 34 | if(bstream == NULL) return NULL; 35 | 36 | bstream->length = 0; 37 | bstream->data = NULL; 38 | 39 | return bstream; 40 | } 41 | 42 | static int BitStream_allocate(BitStream *bstream, int length) 43 | { 44 | unsigned char *data; 45 | 46 | if(bstream == NULL) { 47 | return -1; 48 | } 49 | 50 | data = (unsigned char *)malloc(length); 51 | if(data == NULL) { 52 | return -1; 53 | } 54 | 55 | if(bstream->data) { 56 | free(bstream->data); 57 | } 58 | bstream->length = length; 59 | bstream->data = data; 60 | 61 | return 0; 62 | } 63 | 64 | static BitStream *BitStream_newFromNum(int bits, unsigned int num) 65 | { 66 | unsigned int mask; 67 | int i; 68 | unsigned char *p; 69 | BitStream *bstream; 70 | 71 | bstream = BitStream_new(); 72 | if(bstream == NULL) return NULL; 73 | 74 | if(BitStream_allocate(bstream, bits)) { 75 | BitStream_free(bstream); 76 | return NULL; 77 | } 78 | 79 | p = bstream->data; 80 | mask = 1 << (bits - 1); 81 | for(i=0; i> 1; 89 | } 90 | 91 | return bstream; 92 | } 93 | 94 | static BitStream *BitStream_newFromBytes(int size, unsigned char *data) 95 | { 96 | unsigned char mask; 97 | int i, j; 98 | unsigned char *p; 99 | BitStream *bstream; 100 | 101 | bstream = BitStream_new(); 102 | if(bstream == NULL) return NULL; 103 | 104 | if(BitStream_allocate(bstream, size * 8)) { 105 | BitStream_free(bstream); 106 | return NULL; 107 | } 108 | 109 | p = bstream->data; 110 | for(i=0; i> 1; 120 | } 121 | } 122 | 123 | return bstream; 124 | } 125 | 126 | int BitStream_append(BitStream *bstream, BitStream *arg) 127 | { 128 | unsigned char *data; 129 | 130 | if(arg == NULL) { 131 | return -1; 132 | } 133 | if(arg->length == 0) { 134 | return 0; 135 | } 136 | if(bstream->length == 0) { 137 | if(BitStream_allocate(bstream, arg->length)) { 138 | return -1; 139 | } 140 | memcpy(bstream->data, arg->data, arg->length); 141 | return 0; 142 | } 143 | 144 | data = (unsigned char *)malloc(bstream->length + arg->length); 145 | if(data == NULL) { 146 | return -1; 147 | } 148 | memcpy(data, bstream->data, bstream->length); 149 | memcpy(data + bstream->length, arg->data, arg->length); 150 | 151 | free(bstream->data); 152 | bstream->length += arg->length; 153 | bstream->data = data; 154 | 155 | return 0; 156 | } 157 | 158 | int BitStream_appendNum(BitStream *bstream, int bits, unsigned int num) 159 | { 160 | BitStream *b; 161 | int ret; 162 | 163 | if(bits == 0) return 0; 164 | 165 | b = BitStream_newFromNum(bits, num); 166 | if(b == NULL) return -1; 167 | 168 | ret = BitStream_append(bstream, b); 169 | BitStream_free(b); 170 | 171 | return ret; 172 | } 173 | 174 | int BitStream_appendBytes(BitStream *bstream, int size, unsigned char *data) 175 | { 176 | BitStream *b; 177 | int ret; 178 | 179 | if(size == 0) return 0; 180 | 181 | b = BitStream_newFromBytes(size, data); 182 | if(b == NULL) return -1; 183 | 184 | ret = BitStream_append(bstream, b); 185 | BitStream_free(b); 186 | 187 | return ret; 188 | } 189 | 190 | unsigned char *BitStream_toByte(BitStream *bstream) 191 | { 192 | int i, j, size, bytes; 193 | unsigned char *data, v; 194 | unsigned char *p; 195 | 196 | size = BitStream_size(bstream); 197 | if(size == 0) { 198 | return NULL; 199 | } 200 | data = (unsigned char *)malloc((size + 7) / 8); 201 | if(data == NULL) { 202 | return NULL; 203 | } 204 | 205 | bytes = size / 8; 206 | 207 | p = bstream->data; 208 | for(i=0; idata); 234 | free(bstream); 235 | } 236 | } 237 | -------------------------------------------------------------------------------- /NBaseUiKit/3rdparty/qrencode/qrencode/bitstream.h: -------------------------------------------------------------------------------- 1 | /* 2 | * qrencode - QR Code encoder 3 | * 4 | * Binary sequence class. 5 | * Copyright (C) 2006-2011 Kentaro Fukuchi 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #ifndef __BITSTREAM_H__ 23 | #define __BITSTREAM_H__ 24 | 25 | typedef struct { 26 | int length; 27 | unsigned char *data; 28 | } BitStream; 29 | 30 | extern BitStream *BitStream_new(void); 31 | extern int BitStream_append(BitStream *bstream, BitStream *arg); 32 | extern int BitStream_appendNum(BitStream *bstream, int bits, unsigned int num); 33 | extern int BitStream_appendBytes(BitStream *bstream, int size, unsigned char *data); 34 | #define BitStream_size(__bstream__) (__bstream__->length) 35 | extern unsigned char *BitStream_toByte(BitStream *bstream); 36 | extern void BitStream_free(BitStream *bstream); 37 | 38 | #endif /* __BITSTREAM_H__ */ 39 | -------------------------------------------------------------------------------- /NBaseUiKit/3rdparty/qrencode/qrencode/config.h: -------------------------------------------------------------------------------- 1 | /* config.h. Generated from config.h.in by configure. */ 2 | /* config.h.in. Generated from configure.ac by autoheader. */ 3 | 4 | /* Define to 1 if you have the header file. */ 5 | // #define HAVE_DLFCN_H 1 6 | 7 | /* Define if you have the iconv() function and it works. */ 8 | /* #undef HAVE_ICONV */ 9 | 10 | /* Define to 1 if you have the header file. */ 11 | // #define HAVE_INTTYPES_H 1 12 | 13 | /* Define to 1 if using pthread is enabled. */ 14 | #define HAVE_LIBPTHREAD 1 15 | 16 | /* Define to 1 if you have the header file. */ 17 | // #define HAVE_MEMORY_H 1 18 | 19 | /* Define to 1 if you have the header file. */ 20 | // #define HAVE_STDINT_H 1 21 | 22 | /* Define to 1 if you have the header file. */ 23 | // #define HAVE_STDLIB_H 1 24 | 25 | /* Define to 1 if you have the `strdup' function. */ 26 | // #define HAVE_STRDUP 1 27 | 28 | /* Define to 1 if you have the header file. */ 29 | // #define HAVE_STRINGS_H 1 30 | 31 | /* Define to 1 if you have the header file. */ 32 | // #define HAVE_STRING_H 1 33 | 34 | /* Define to 1 if you have the header file. */ 35 | // #define HAVE_SYS_STAT_H 1 36 | 37 | /* Define to 1 if you have the header file. */ 38 | // #define HAVE_SYS_TYPES_H 1 39 | 40 | /* Define to 1 if you have the header file. */ 41 | // #define HAVE_UNISTD_H 1 42 | 43 | /* Define to the sub-directory in which libtool stores uninstalled libraries. 44 | */ 45 | // #define LT_OBJDIR ".libs/" 46 | 47 | /* Major version number */ 48 | #define MAJOR_VERSION 3 49 | 50 | /* Micro version number */ 51 | #define MICRO_VERSION 3 52 | 53 | /* Minor version number */ 54 | #define MINOR_VERSION 4 55 | 56 | /* Define to 1 if your C compiler doesn't accept -c and -o together. */ 57 | /* #undef NO_MINUS_C_MINUS_O */ 58 | 59 | /* Name of package */ 60 | // #define PACKAGE "qrencode" 61 | 62 | /* Define to the address where bug reports for this package should be sent. */ 63 | // #define PACKAGE_BUGREPORT "" 64 | 65 | /* Define to the full name of this package. */ 66 | // #define PACKAGE_NAME "" 67 | 68 | /* Define to the full name and version of this package. */ 69 | // #define PACKAGE_STRING "" 70 | 71 | /* Define to the one symbol short name of this package. */ 72 | // #define PACKAGE_TARNAME "" 73 | 74 | /* Define to the home page for this package. */ 75 | // #define PACKAGE_URL "" 76 | 77 | /* Define to the version of this package. */ 78 | // #define PACKAGE_VERSION "" 79 | 80 | /* Define to 1 if you have the ANSI C header files. */ 81 | // #define STDC_HEADERS 1 82 | 83 | /* Version number of package */ 84 | #define VERSION "3.4.3" 85 | 86 | /* Define to empty if `const' does not conform to ANSI C. */ 87 | /* #undef const */ 88 | 89 | /* Define to `__inline__' or `__inline' if that's what the C compiler 90 | calls it, or to nothing if 'inline' is not supported under any name. */ 91 | #ifndef __cplusplus 92 | /* #undef inline */ 93 | #endif 94 | 95 | /* Define to 'static' if no test programs will be compiled. */ 96 | #define __STATIC static 97 | /* #undef WITH_TESTS */ 98 | 99 | -------------------------------------------------------------------------------- /NBaseUiKit/3rdparty/qrencode/qrencode/mask.h: -------------------------------------------------------------------------------- 1 | /* 2 | * qrencode - QR Code encoder 3 | * 4 | * Masking. 5 | * Copyright (C) 2006-2011 Kentaro Fukuchi 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #ifndef __MASK_H__ 23 | #define __MASK_H__ 24 | 25 | extern unsigned char *Mask_makeMask(int width, unsigned char *frame, int mask, QRecLevel level); 26 | extern unsigned char *Mask_mask(int width, unsigned char *frame, QRecLevel level); 27 | 28 | #ifdef WITH_TESTS 29 | extern int Mask_calcN2(int width, unsigned char *frame); 30 | extern int Mask_calcN1N3(int length, int *runLength); 31 | extern int Mask_calcRunLength(int width, unsigned char *frame, int dir, int *runLength); 32 | extern int Mask_evaluateSymbol(int width, unsigned char *frame); 33 | extern int Mask_writeFormatInformation(int width, unsigned char *frame, int mask, QRecLevel level); 34 | extern unsigned char *Mask_makeMaskedFrame(int width, unsigned char *frame, int mask); 35 | #endif 36 | 37 | #endif /* __MASK_H__ */ 38 | -------------------------------------------------------------------------------- /NBaseUiKit/3rdparty/qrencode/qrencode/mmask.c: -------------------------------------------------------------------------------- 1 | /* 2 | * qrencode - QR Code encoder 3 | * 4 | * Masking for Micro QR Code. 5 | * Copyright (C) 2006-2011 Kentaro Fukuchi 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #include "config.h" 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include "qrencode.h" 29 | #include "mqrspec.h" 30 | #include "mmask.h" 31 | 32 | 33 | __STATIC void MMask_writeFormatInformation(int version, int width, unsigned char *frame, int mask, QRecLevel level) 34 | { 35 | unsigned int format; 36 | unsigned char v; 37 | int i; 38 | 39 | format = MQRspec_getFormatInfo(mask, version, level); 40 | 41 | for(i=0; i<8; i++) { 42 | v = 0x84 | (format & 1); 43 | frame[width * (i + 1) + 8] = v; 44 | format = format >> 1; 45 | } 46 | for(i=0; i<7; i++) { 47 | v = 0x84 | (format & 1); 48 | frame[width * 8 + 7 - i] = v; 49 | format = format >> 1; 50 | } 51 | } 52 | 53 | #define MASKMAKER(__exp__) \ 54 | int x, y;\ 55 | \ 56 | for(y=0; y= maskNum) { 113 | errno = EINVAL; 114 | return NULL; 115 | } 116 | 117 | width = MQRspec_getWidth(version); 118 | masked = (unsigned char *)malloc(width * width); 119 | if(masked == NULL) return NULL; 120 | 121 | maskMakers[mask](width, frame, masked); 122 | MMask_writeFormatInformation(version, width, masked, mask, level); 123 | 124 | return masked; 125 | } 126 | 127 | __STATIC int MMask_evaluateSymbol(int width, unsigned char *frame) 128 | { 129 | int x, y; 130 | unsigned char *p; 131 | int sum1 = 0, sum2 = 0; 132 | 133 | p = frame + width * (width - 1); 134 | for(x=1; x maxScore) { 167 | maxScore = score; 168 | free(bestMask); 169 | bestMask = mask; 170 | mask = (unsigned char *)malloc(width * width); 171 | if(mask == NULL) break; 172 | } 173 | } 174 | free(mask); 175 | return bestMask; 176 | } 177 | -------------------------------------------------------------------------------- /NBaseUiKit/3rdparty/qrencode/qrencode/mmask.h: -------------------------------------------------------------------------------- 1 | /* 2 | * qrencode - QR Code encoder 3 | * 4 | * Masking for Micro QR Code. 5 | * Copyright (C) 2006-2011 Kentaro Fukuchi 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #ifndef __MMASK_H__ 23 | #define __MMASK_H__ 24 | 25 | extern unsigned char *MMask_makeMask(int version, unsigned char *frame, int mask, QRecLevel level); 26 | extern unsigned char *MMask_mask(int version, unsigned char *frame, QRecLevel level); 27 | 28 | #ifdef WITH_TESTS 29 | extern int MMask_evaluateSymbol(int width, unsigned char *frame); 30 | extern void MMask_writeFormatInformation(int version, int width, unsigned char *frame, int mask, QRecLevel level); 31 | extern unsigned char *MMask_makeMaskedFrame(int width, unsigned char *frame, int mask); 32 | #endif 33 | 34 | #endif /* __MMASK_H__ */ 35 | -------------------------------------------------------------------------------- /NBaseUiKit/3rdparty/qrencode/qrencode/mqrspec.c: -------------------------------------------------------------------------------- 1 | /* 2 | * qrencode - QR Code encoder 3 | * 4 | * Micor QR Code specification in convenient format. 5 | * Copyright (C) 2006-2011 Kentaro Fukuchi 6 | * 7 | * The following data / specifications are taken from 8 | * "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004) 9 | * or 10 | * "Automatic identification and data capture techniques -- 11 | * QR Code 2005 bar code symbology specification" (ISO/IEC 18004:2006) 12 | * 13 | * This library is free software; you can redistribute it and/or 14 | * modify it under the terms of the GNU Lesser General Public 15 | * License as published by the Free Software Foundation; either 16 | * version 2.1 of the License, or any later version. 17 | * 18 | * This library is distributed in the hope that it will be useful, 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 | * Lesser General Public License for more details. 22 | * 23 | * You should have received a copy of the GNU Lesser General Public 24 | * License along with this library; if not, write to the Free Software 25 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 26 | */ 27 | 28 | #include "config.h" 29 | #include 30 | #include 31 | #include 32 | #include 33 | #ifdef HAVE_LIBPTHREAD 34 | #include 35 | #endif 36 | 37 | #include "mqrspec.h" 38 | 39 | /****************************************************************************** 40 | * Version and capacity 41 | *****************************************************************************/ 42 | 43 | typedef struct { 44 | int width; //< Edge length of the symbol 45 | int ec[4]; //< Number of ECC code (bytes) 46 | } MQRspec_Capacity; 47 | 48 | /** 49 | * Table of the capacity of symbols 50 | * See Table 1 (pp.106) and Table 8 (pp.113) of Appendix 1, JIS X0510:2004. 51 | */ 52 | static const MQRspec_Capacity mqrspecCapacity[MQRSPEC_VERSION_MAX + 1] = { 53 | { 0, {0, 0, 0, 0}}, 54 | { 11, {2, 0, 0, 0}}, 55 | { 13, {5, 6, 0, 0}}, 56 | { 15, {6, 8, 0, 0}}, 57 | { 17, {8, 10, 14, 0}} 58 | }; 59 | 60 | int MQRspec_getDataLengthBit(int version, QRecLevel level) 61 | { 62 | int w; 63 | int ecc; 64 | 65 | w = mqrspecCapacity[version].width - 1; 66 | ecc = mqrspecCapacity[version].ec[level]; 67 | if(ecc == 0) return 0; 68 | return w * w - 64 - ecc * 8; 69 | } 70 | 71 | int MQRspec_getDataLength(int version, QRecLevel level) 72 | { 73 | return (MQRspec_getDataLengthBit(version, level) + 4) / 8; 74 | } 75 | 76 | int MQRspec_getECCLength(int version, QRecLevel level) 77 | { 78 | return mqrspecCapacity[version].ec[level]; 79 | } 80 | 81 | int MQRspec_getWidth(int version) 82 | { 83 | return mqrspecCapacity[version].width; 84 | } 85 | 86 | /****************************************************************************** 87 | * Length indicator 88 | *****************************************************************************/ 89 | 90 | /** 91 | * See Table 3 (pp.107) of Appendix 1, JIS X0510:2004. 92 | */ 93 | static const int lengthTableBits[4][4] = { 94 | { 3, 4, 5, 6}, 95 | { 0, 3, 4, 5}, 96 | { 0, 0, 4, 5}, 97 | { 0, 0, 3, 4} 98 | }; 99 | 100 | int MQRspec_lengthIndicator(QRencodeMode mode, int version) 101 | { 102 | return lengthTableBits[mode][version - 1]; 103 | } 104 | 105 | int MQRspec_maximumWords(QRencodeMode mode, int version) 106 | { 107 | int bits; 108 | int words; 109 | 110 | bits = lengthTableBits[mode][version - 1]; 111 | words = (1 << bits) - 1; 112 | if(mode == QR_MODE_KANJI) { 113 | words *= 2; // the number of bytes is required 114 | } 115 | 116 | return words; 117 | } 118 | 119 | /****************************************************************************** 120 | * Format information 121 | *****************************************************************************/ 122 | 123 | /* See calcFormatInfo in tests/test_mqrspec.c */ 124 | static const unsigned int formatInfo[4][8] = { 125 | {0x4445, 0x55ae, 0x6793, 0x7678, 0x06de, 0x1735, 0x2508, 0x34e3}, 126 | {0x4172, 0x5099, 0x62a4, 0x734f, 0x03e9, 0x1202, 0x203f, 0x31d4}, 127 | {0x4e2b, 0x5fc0, 0x6dfd, 0x7c16, 0x0cb0, 0x1d5b, 0x2f66, 0x3e8d}, 128 | {0x4b1c, 0x5af7, 0x68ca, 0x7921, 0x0987, 0x186c, 0x2a51, 0x3bba} 129 | }; 130 | 131 | /* See Table 10 of Appendix 1. (pp.115) */ 132 | static const int typeTable[MQRSPEC_VERSION_MAX + 1][3] = { 133 | {-1, -1, -1}, 134 | { 0, -1, -1}, 135 | { 1, 2, -1}, 136 | { 3, 4, -1}, 137 | { 5, 6, 7} 138 | }; 139 | 140 | unsigned int MQRspec_getFormatInfo(int mask, int version, QRecLevel level) 141 | { 142 | int type; 143 | 144 | if(mask < 0 || mask > 3) return 0; 145 | if(version <= 0 || version > MQRSPEC_VERSION_MAX) return 0; 146 | if(level == QR_ECLEVEL_H) return 0; 147 | type = typeTable[version][level]; 148 | if(type < 0) return 0; 149 | 150 | return formatInfo[mask][type]; 151 | } 152 | 153 | /****************************************************************************** 154 | * Frame 155 | *****************************************************************************/ 156 | 157 | /** 158 | * Cache of initial frames. 159 | */ 160 | /* C99 says that static storage shall be initialized to a null pointer 161 | * by compiler. */ 162 | static unsigned char *frames[MQRSPEC_VERSION_MAX + 1]; 163 | #ifdef HAVE_LIBPTHREAD 164 | static pthread_mutex_t frames_mutex = PTHREAD_MUTEX_INITIALIZER; 165 | #endif 166 | 167 | /** 168 | * Put a finder pattern. 169 | * @param frame 170 | * @param width 171 | * @param ox,oy upper-left coordinate of the pattern 172 | */ 173 | static void putFinderPattern(unsigned char *frame, int width, int ox, int oy) 174 | { 175 | static const unsigned char finder[] = { 176 | 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 177 | 0xc1, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc1, 178 | 0xc1, 0xc0, 0xc1, 0xc1, 0xc1, 0xc0, 0xc1, 179 | 0xc1, 0xc0, 0xc1, 0xc1, 0xc1, 0xc0, 0xc1, 180 | 0xc1, 0xc0, 0xc1, 0xc1, 0xc1, 0xc0, 0xc1, 181 | 0xc1, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc1, 182 | 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 0xc1, 183 | }; 184 | int x, y; 185 | const unsigned char *s; 186 | 187 | frame += oy * width + ox; 188 | s = finder; 189 | for(y=0; y<7; y++) { 190 | for(x=0; x<7; x++) { 191 | frame[x] = s[x]; 192 | } 193 | frame += width; 194 | s += 7; 195 | } 196 | } 197 | 198 | static unsigned char *MQRspec_createFrame(int version) 199 | { 200 | unsigned char *frame, *p, *q; 201 | int width; 202 | int x, y; 203 | 204 | width = mqrspecCapacity[version].width; 205 | frame = (unsigned char *)malloc(width * width); 206 | if(frame == NULL) return NULL; 207 | 208 | memset(frame, 0, width * width); 209 | /* Finder pattern */ 210 | putFinderPattern(frame, width, 0, 0); 211 | /* Separator */ 212 | p = frame; 213 | for(y=0; y<7; y++) { 214 | p[7] = 0xc0; 215 | p += width; 216 | } 217 | memset(frame + width * 7, 0xc0, 8); 218 | /* Mask format information area */ 219 | memset(frame + width * 8 + 1, 0x84, 8); 220 | p = frame + width + 8; 221 | for(y=0; y<7; y++) { 222 | *p = 0x84; 223 | p += width; 224 | } 225 | /* Timing pattern */ 226 | p = frame + 8; 227 | q = frame + width * 8; 228 | for(x=1; x MQRSPEC_VERSION_MAX) return NULL; 244 | 245 | #ifdef HAVE_LIBPTHREAD 246 | pthread_mutex_lock(&frames_mutex); 247 | #endif 248 | if(frames[version] == NULL) { 249 | frames[version] = MQRspec_createFrame(version); 250 | } 251 | #ifdef HAVE_LIBPTHREAD 252 | pthread_mutex_unlock(&frames_mutex); 253 | #endif 254 | if(frames[version] == NULL) return NULL; 255 | 256 | width = mqrspecCapacity[version].width; 257 | frame = (unsigned char *)malloc(width * width); 258 | if(frame == NULL) return NULL; 259 | memcpy(frame, frames[version], width * width); 260 | 261 | return frame; 262 | } 263 | 264 | void MQRspec_clearCache(void) 265 | { 266 | int i; 267 | 268 | #ifdef HAVE_LIBPTHREAD 269 | pthread_mutex_lock(&frames_mutex); 270 | #endif 271 | for(i=1; i<=MQRSPEC_VERSION_MAX; i++) { 272 | free(frames[i]); 273 | frames[i] = NULL; 274 | } 275 | #ifdef HAVE_LIBPTHREAD 276 | pthread_mutex_unlock(&frames_mutex); 277 | #endif 278 | } 279 | -------------------------------------------------------------------------------- /NBaseUiKit/3rdparty/qrencode/qrencode/mqrspec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * qrencode - QR Code encoder 3 | * 4 | * Micro QR Code specification in convenient format. 5 | * Copyright (C) 2006-2011 Kentaro Fukuchi 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #ifndef __MQRSPEC_H__ 23 | #define __MQRSPEC_H__ 24 | 25 | #include "qrencode.h" 26 | 27 | /****************************************************************************** 28 | * Version and capacity 29 | *****************************************************************************/ 30 | 31 | /** 32 | * Maximum width of a symbol 33 | */ 34 | #define MQRSPEC_WIDTH_MAX 17 35 | 36 | /** 37 | * Return maximum data code length (bits) for the version. 38 | * @param version 39 | * @param level 40 | * @return maximum size (bits) 41 | */ 42 | extern int MQRspec_getDataLengthBit(int version, QRecLevel level); 43 | 44 | /** 45 | * Return maximum data code length (bytes) for the version. 46 | * @param version 47 | * @param level 48 | * @return maximum size (bytes) 49 | */ 50 | extern int MQRspec_getDataLength(int version, QRecLevel level); 51 | 52 | /** 53 | * Return maximum error correction code length (bytes) for the version. 54 | * @param version 55 | * @param level 56 | * @return ECC size (bytes) 57 | */ 58 | extern int MQRspec_getECCLength(int version, QRecLevel level); 59 | 60 | /** 61 | * Return a version number that satisfies the input code length. 62 | * @param size input code length (byte) 63 | * @param level 64 | * @return version number 65 | */ 66 | extern int MQRspec_getMinimumVersion(int size, QRecLevel level); 67 | 68 | /** 69 | * Return the width of the symbol for the version. 70 | * @param version 71 | * @return width 72 | */ 73 | extern int MQRspec_getWidth(int version); 74 | 75 | /** 76 | * Return the numer of remainder bits. 77 | * @param version 78 | * @return number of remainder bits 79 | */ 80 | extern int MQRspec_getRemainder(int version); 81 | 82 | /****************************************************************************** 83 | * Length indicator 84 | *****************************************************************************/ 85 | 86 | /** 87 | * Return the size of lenght indicator for the mode and version. 88 | * @param mode 89 | * @param version 90 | * @return the size of the appropriate length indicator (bits). 91 | */ 92 | extern int MQRspec_lengthIndicator(QRencodeMode mode, int version); 93 | 94 | /** 95 | * Return the maximum length for the mode and version. 96 | * @param mode 97 | * @param version 98 | * @return the maximum length (bytes) 99 | */ 100 | extern int MQRspec_maximumWords(QRencodeMode mode, int version); 101 | 102 | /****************************************************************************** 103 | * Version information pattern 104 | *****************************************************************************/ 105 | 106 | /** 107 | * Return BCH encoded version information pattern that is used for the symbol 108 | * of version 7 or greater. Use lower 18 bits. 109 | * @param version 110 | * @return BCH encoded version information pattern 111 | */ 112 | extern unsigned int MQRspec_getVersionPattern(int version); 113 | 114 | /****************************************************************************** 115 | * Format information 116 | *****************************************************************************/ 117 | 118 | /** 119 | * Return BCH encoded format information pattern. 120 | * @param mask 121 | * @param version 122 | * @param level 123 | * @return BCH encoded format information pattern 124 | */ 125 | extern unsigned int MQRspec_getFormatInfo(int mask, int version, QRecLevel level); 126 | 127 | /****************************************************************************** 128 | * Frame 129 | *****************************************************************************/ 130 | 131 | /** 132 | * Return a copy of initialized frame. 133 | * When the same version is requested twice or more, a copy of cached frame 134 | * is returned. 135 | * @param version 136 | * @return Array of unsigned char. You can free it by free(). 137 | */ 138 | extern unsigned char *MQRspec_newFrame(int version); 139 | 140 | /** 141 | * Clear the frame cache. Typically for debug. 142 | */ 143 | extern void MQRspec_clearCache(void); 144 | 145 | /****************************************************************************** 146 | * Mode indicator 147 | *****************************************************************************/ 148 | 149 | /** 150 | * Mode indicator. See Table 2 in Appendix 1 of JIS X0510:2004, pp.107. 151 | */ 152 | #define MQRSPEC_MODEID_NUM 0 153 | #define MQRSPEC_MODEID_AN 1 154 | #define MQRSPEC_MODEID_8 2 155 | #define MQRSPEC_MODEID_KANJI 3 156 | 157 | #endif /* __MQRSPEC_H__ */ 158 | -------------------------------------------------------------------------------- /NBaseUiKit/3rdparty/qrencode/qrencode/qrencode_inner.h: -------------------------------------------------------------------------------- 1 | /** 2 | * qrencode - QR Code encoder 3 | * 4 | * Header for test use 5 | * Copyright (C) 2006-2011 Kentaro Fukuchi 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #ifndef __QRENCODE_INNER_H__ 23 | #define __QRENCODE_INNER_H__ 24 | 25 | /** 26 | * This header file includes definitions for test use. 27 | */ 28 | 29 | /****************************************************************************** 30 | * Raw code 31 | *****************************************************************************/ 32 | 33 | typedef struct { 34 | int dataLength; 35 | unsigned char *data; 36 | int eccLength; 37 | unsigned char *ecc; 38 | } RSblock; 39 | 40 | typedef struct { 41 | int version; 42 | int dataLength; 43 | int eccLength; 44 | unsigned char *datacode; 45 | unsigned char *ecccode; 46 | int b1; 47 | int blocks; 48 | RSblock *rsblock; 49 | int count; 50 | } QRRawCode; 51 | 52 | extern QRRawCode *QRraw_new(QRinput *input); 53 | extern unsigned char QRraw_getCode(QRRawCode *raw); 54 | extern void QRraw_free(QRRawCode *raw); 55 | 56 | /****************************************************************************** 57 | * Raw code for Micro QR Code 58 | *****************************************************************************/ 59 | 60 | typedef struct { 61 | int version; 62 | int dataLength; 63 | int eccLength; 64 | unsigned char *datacode; 65 | unsigned char *ecccode; 66 | RSblock *rsblock; 67 | int oddbits; 68 | int count; 69 | } MQRRawCode; 70 | 71 | extern MQRRawCode *MQRraw_new(QRinput *input); 72 | extern unsigned char MQRraw_getCode(MQRRawCode *raw); 73 | extern void MQRraw_free(MQRRawCode *raw); 74 | 75 | /****************************************************************************** 76 | * Frame filling 77 | *****************************************************************************/ 78 | extern unsigned char *FrameFiller_test(int version); 79 | extern unsigned char *FrameFiller_testMQR(int version); 80 | 81 | /****************************************************************************** 82 | * QR-code encoding 83 | *****************************************************************************/ 84 | extern QRcode *QRcode_encodeMask(QRinput *input, int mask); 85 | extern QRcode *QRcode_encodeMaskMQR(QRinput *input, int mask); 86 | extern QRcode *QRcode_new(int version, int width, unsigned char *data); 87 | 88 | #endif /* __QRENCODE_INNER_H__ */ 89 | -------------------------------------------------------------------------------- /NBaseUiKit/3rdparty/qrencode/qrencode/qrinput.h: -------------------------------------------------------------------------------- 1 | /* 2 | * qrencode - QR Code encoder 3 | * 4 | * Input data chunk class 5 | * Copyright (C) 2006-2011 Kentaro Fukuchi 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #ifndef __QRINPUT_H__ 23 | #define __QRINPUT_H__ 24 | 25 | #include "qrencode.h" 26 | #include "bitstream.h" 27 | 28 | int QRinput_isSplittableMode(QRencodeMode mode); 29 | 30 | /****************************************************************************** 31 | * Entry of input data 32 | *****************************************************************************/ 33 | typedef struct _QRinput_List QRinput_List; 34 | 35 | struct _QRinput_List { 36 | QRencodeMode mode; 37 | int size; ///< Size of data chunk (byte). 38 | unsigned char *data; ///< Data chunk. 39 | BitStream *bstream; 40 | QRinput_List *next; 41 | }; 42 | 43 | /****************************************************************************** 44 | * Input Data 45 | *****************************************************************************/ 46 | struct _QRinput { 47 | int version; 48 | QRecLevel level; 49 | QRinput_List *head; 50 | QRinput_List *tail; 51 | int mqr; 52 | int fnc1; 53 | unsigned char appid; 54 | }; 55 | 56 | /****************************************************************************** 57 | * Structured append input data 58 | *****************************************************************************/ 59 | typedef struct _QRinput_InputList QRinput_InputList; 60 | 61 | struct _QRinput_InputList { 62 | QRinput *input; 63 | QRinput_InputList *next; 64 | }; 65 | 66 | struct _QRinput_Struct { 67 | int size; ///< number of structured symbols 68 | int parity; 69 | QRinput_InputList *head; 70 | QRinput_InputList *tail; 71 | }; 72 | 73 | /** 74 | * Pack all bit streams padding bits into a byte array. 75 | * @param input input data. 76 | * @return padded merged byte stream 77 | */ 78 | extern unsigned char *QRinput_getByteStream(QRinput *input); 79 | 80 | 81 | extern int QRinput_estimateBitsModeNum(int size); 82 | extern int QRinput_estimateBitsModeAn(int size); 83 | extern int QRinput_estimateBitsMode8(int size); 84 | extern int QRinput_estimateBitsModeKanji(int size); 85 | 86 | extern QRinput *QRinput_dup(QRinput *input); 87 | 88 | extern const signed char QRinput_anTable[128]; 89 | 90 | /** 91 | * Look up the alphabet-numeric convesion table (see JIS X0510:2004, pp.19). 92 | * @param __c__ character 93 | * @return value 94 | */ 95 | #define QRinput_lookAnTable(__c__) \ 96 | ((__c__ & 0x80)?-1:QRinput_anTable[(int)__c__]) 97 | 98 | /** 99 | * Length of a standard mode indicator in bits. 100 | */ 101 | 102 | #define MODE_INDICATOR_SIZE 4 103 | 104 | /** 105 | * Length of a segment of structured-append header. 106 | */ 107 | #define STRUCTURE_HEADER_SIZE 20 108 | 109 | /** 110 | * Maximum number of symbols in a set of structured-appended symbols. 111 | */ 112 | #define MAX_STRUCTURED_SYMBOLS 16 113 | 114 | #ifdef WITH_TESTS 115 | extern BitStream *QRinput_mergeBitStream(QRinput *input); 116 | extern BitStream *QRinput_getBitStream(QRinput *input); 117 | extern int QRinput_estimateBitStreamSize(QRinput *input, int version); 118 | extern int QRinput_splitEntry(QRinput_List *entry, int bytes); 119 | extern int QRinput_lengthOfCode(QRencodeMode mode, int version, int bits); 120 | extern int QRinput_insertStructuredAppendHeader(QRinput *input, int size, int index, unsigned char parity); 121 | #endif 122 | 123 | #endif /* __QRINPUT_H__ */ 124 | -------------------------------------------------------------------------------- /NBaseUiKit/3rdparty/qrencode/qrencode/qrspec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * qrencode - QR Code encoder 3 | * 4 | * QR Code specification in convenient format. 5 | * Copyright (C) 2006-2011 Kentaro Fukuchi 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #ifndef __QRSPEC_H__ 23 | #define __QRSPEC_H__ 24 | 25 | #include "qrencode.h" 26 | 27 | /****************************************************************************** 28 | * Version and capacity 29 | *****************************************************************************/ 30 | 31 | /** 32 | * Maximum width of a symbol 33 | */ 34 | #define QRSPEC_WIDTH_MAX 177 35 | 36 | /** 37 | * Return maximum data code length (bytes) for the version. 38 | * @param version 39 | * @param level 40 | * @return maximum size (bytes) 41 | */ 42 | extern int QRspec_getDataLength(int version, QRecLevel level); 43 | 44 | /** 45 | * Return maximum error correction code length (bytes) for the version. 46 | * @param version 47 | * @param level 48 | * @return ECC size (bytes) 49 | */ 50 | extern int QRspec_getECCLength(int version, QRecLevel level); 51 | 52 | /** 53 | * Return a version number that satisfies the input code length. 54 | * @param size input code length (byte) 55 | * @param level 56 | * @return version number 57 | */ 58 | extern int QRspec_getMinimumVersion(int size, QRecLevel level); 59 | 60 | /** 61 | * Return the width of the symbol for the version. 62 | * @param version 63 | * @return width 64 | */ 65 | extern int QRspec_getWidth(int version); 66 | 67 | /** 68 | * Return the numer of remainder bits. 69 | * @param version 70 | * @return number of remainder bits 71 | */ 72 | extern int QRspec_getRemainder(int version); 73 | 74 | /****************************************************************************** 75 | * Length indicator 76 | *****************************************************************************/ 77 | 78 | /** 79 | * Return the size of lenght indicator for the mode and version. 80 | * @param mode 81 | * @param version 82 | * @return the size of the appropriate length indicator (bits). 83 | */ 84 | extern int QRspec_lengthIndicator(QRencodeMode mode, int version); 85 | 86 | /** 87 | * Return the maximum length for the mode and version. 88 | * @param mode 89 | * @param version 90 | * @return the maximum length (bytes) 91 | */ 92 | extern int QRspec_maximumWords(QRencodeMode mode, int version); 93 | 94 | /****************************************************************************** 95 | * Error correction code 96 | *****************************************************************************/ 97 | 98 | /** 99 | * Return an array of ECC specification. 100 | * @param version 101 | * @param level 102 | * @param spec an array of ECC specification contains as following: 103 | * {# of type1 blocks, # of data code, # of ecc code, 104 | * # of type2 blocks, # of data code} 105 | */ 106 | void QRspec_getEccSpec(int version, QRecLevel level, int spec[5]); 107 | 108 | #define QRspec_rsBlockNum(__spec__) (__spec__[0] + __spec__[3]) 109 | #define QRspec_rsBlockNum1(__spec__) (__spec__[0]) 110 | #define QRspec_rsDataCodes1(__spec__) (__spec__[1]) 111 | #define QRspec_rsEccCodes1(__spec__) (__spec__[2]) 112 | #define QRspec_rsBlockNum2(__spec__) (__spec__[3]) 113 | #define QRspec_rsDataCodes2(__spec__) (__spec__[4]) 114 | #define QRspec_rsEccCodes2(__spec__) (__spec__[2]) 115 | 116 | #define QRspec_rsDataLength(__spec__) \ 117 | ((QRspec_rsBlockNum1(__spec__) * QRspec_rsDataCodes1(__spec__)) + \ 118 | (QRspec_rsBlockNum2(__spec__) * QRspec_rsDataCodes2(__spec__))) 119 | #define QRspec_rsEccLength(__spec__) \ 120 | (QRspec_rsBlockNum(__spec__) * QRspec_rsEccCodes1(__spec__)) 121 | 122 | /****************************************************************************** 123 | * Version information pattern 124 | *****************************************************************************/ 125 | 126 | /** 127 | * Return BCH encoded version information pattern that is used for the symbol 128 | * of version 7 or greater. Use lower 18 bits. 129 | * @param version 130 | * @return BCH encoded version information pattern 131 | */ 132 | extern unsigned int QRspec_getVersionPattern(int version); 133 | 134 | /****************************************************************************** 135 | * Format information 136 | *****************************************************************************/ 137 | 138 | /** 139 | * Return BCH encoded format information pattern. 140 | * @param mask 141 | * @param level 142 | * @return BCH encoded format information pattern 143 | */ 144 | extern unsigned int QRspec_getFormatInfo(int mask, QRecLevel level); 145 | 146 | /****************************************************************************** 147 | * Frame 148 | *****************************************************************************/ 149 | 150 | /** 151 | * Return a copy of initialized frame. 152 | * When the same version is requested twice or more, a copy of cached frame 153 | * is returned. 154 | * @param version 155 | * @return Array of unsigned char. You can free it by free(). 156 | */ 157 | extern unsigned char *QRspec_newFrame(int version); 158 | 159 | /** 160 | * Clear the frame cache. Typically for debug. 161 | */ 162 | extern void QRspec_clearCache(void); 163 | 164 | /****************************************************************************** 165 | * Mode indicator 166 | *****************************************************************************/ 167 | 168 | /** 169 | * Mode indicator. See Table 2 of JIS X0510:2004, pp.16. 170 | */ 171 | #define QRSPEC_MODEID_ECI 7 172 | #define QRSPEC_MODEID_NUM 1 173 | #define QRSPEC_MODEID_AN 2 174 | #define QRSPEC_MODEID_8 4 175 | #define QRSPEC_MODEID_KANJI 8 176 | #define QRSPEC_MODEID_FNC1FIRST 5 177 | #define QRSPEC_MODEID_FNC1SECOND 9 178 | #define QRSPEC_MODEID_STRUCTURE 3 179 | #define QRSPEC_MODEID_TERMINATOR 0 180 | 181 | #endif /* __QRSPEC_H__ */ 182 | -------------------------------------------------------------------------------- /NBaseUiKit/3rdparty/qrencode/qrencode/rscode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * qrencode - QR Code encoder 3 | * 4 | * Reed solomon encoder. This code is taken from Phil Karn's libfec then 5 | * editted and packed into a pair of .c and .h files. 6 | * 7 | * Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q 8 | * (libfec is released under the GNU Lesser General Public License.) 9 | * 10 | * Copyright (C) 2006-2011 Kentaro Fukuchi 11 | * 12 | * This library is free software; you can redistribute it and/or 13 | * modify it under the terms of the GNU Lesser General Public 14 | * License as published by the Free Software Foundation; either 15 | * version 2.1 of the License, or any later version. 16 | * 17 | * This library is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | * Lesser General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU Lesser General Public 23 | * License along with this library; if not, write to the Free Software 24 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 25 | */ 26 | 27 | #ifndef __RSCODE_H__ 28 | #define __RSCODE_H__ 29 | 30 | /* 31 | * General purpose RS codec, 8-bit symbols. 32 | */ 33 | 34 | typedef struct _RS RS; 35 | 36 | extern RS *init_rs(int symsize, int gfpoly, int fcr, int prim, int nroots, int pad); 37 | extern void encode_rs_char(RS *rs, const unsigned char *data, unsigned char *parity); 38 | extern void free_rs_char(RS *rs); 39 | extern void free_rs_cache(void); 40 | 41 | #endif /* __RSCODE_H__ */ 42 | -------------------------------------------------------------------------------- /NBaseUiKit/3rdparty/qrencode/qrencode/split.h: -------------------------------------------------------------------------------- 1 | /* 2 | * qrencode - QR Code encoder 3 | * 4 | * Input data splitter. 5 | * Copyright (C) 2006-2011 Kentaro Fukuchi 6 | * 7 | * The following data / specifications are taken from 8 | * "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004) 9 | * or 10 | * "Automatic identification and data capture techniques -- 11 | * QR Code 2005 bar code symbology specification" (ISO/IEC 18004:2006) 12 | * 13 | * This library is free software; you can redistribute it and/or 14 | * modify it under the terms of the GNU Lesser General Public 15 | * License as published by the Free Software Foundation; either 16 | * version 2.1 of the License, or any later version. 17 | * 18 | * This library is distributed in the hope that it will be useful, 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 | * Lesser General Public License for more details. 22 | * 23 | * You should have received a copy of the GNU Lesser General Public 24 | * License along with this library; if not, write to the Free Software 25 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 26 | */ 27 | 28 | #ifndef __SPLIT_H__ 29 | #define __SPLIT_H__ 30 | 31 | #include "qrencode.h" 32 | 33 | /** 34 | * Split the input string (null terminated) into QRinput. 35 | * @param string input string 36 | * @param hint give QR_MODE_KANJI if the input string contains Kanji character encoded in Shift-JIS. If not, give QR_MODE_8. 37 | * @param casesensitive 0 for case-insensitive encoding (all alphabet characters are replaced to UPPER-CASE CHARACTERS. 38 | * @retval 0 success. 39 | * @retval -1 an error occurred. errno is set to indicate the error. See 40 | * Exceptions for the details. 41 | * @throw EINVAL invalid input object. 42 | * @throw ENOMEM unable to allocate memory for input objects. 43 | */ 44 | extern int Split_splitStringToQRinput(const char *string, QRinput *input, 45 | QRencodeMode hint, int casesensitive); 46 | 47 | #endif /* __SPLIT_H__ */ 48 | -------------------------------------------------------------------------------- /NBaseUiKit/3rdparty/waiting/inc/waitingspinnerwidget.h: -------------------------------------------------------------------------------- 1 | /* Original Work Copyright (c) 2012-2014 Alexander Turkin 2 | Modified 2014 by William Hallatt 3 | Modified 2015 by Jacob Dawid 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | this software and associated documentation files (the "Software"), to deal in 6 | the Software without restriction, including without limitation the rights to 7 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | the Software, and to permit persons to whom the Software is furnished to do so, 9 | subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | #pragma once 23 | 24 | // Qt includes 25 | #include 26 | #include 27 | #include 28 | 29 | class WaitingSpinnerWidget : public QWidget { 30 | Q_OBJECT 31 | public: 32 | /*! Constructor for "standard" widget behaviour - use this 33 | * constructor if you wish to, e.g. embed your widget in another. */ 34 | WaitingSpinnerWidget(QWidget *parent = 0, 35 | bool centerOnParent = true, 36 | bool disableParentWhenSpinning = true); 37 | 38 | /*! Constructor - use this constructor to automatically create a modal 39 | * ("blocking") spinner on top of the calling widget/window. If a valid 40 | * parent widget is provided, "centreOnParent" will ensure that 41 | * QtWaitingSpinner automatically centres itself on it, if not, 42 | * "centreOnParent" is ignored. */ 43 | WaitingSpinnerWidget(Qt::WindowModality modality, 44 | QWidget *parent = 0, 45 | bool centerOnParent = true, 46 | bool disableParentWhenSpinning = true); 47 | 48 | public slots: 49 | void start(); 50 | void stop(); 51 | 52 | public: 53 | void setColor(QColor color); 54 | void setRoundness(qreal roundness); 55 | void setMinimumTrailOpacity(qreal minimumTrailOpacity); 56 | void setTrailFadePercentage(qreal trail); 57 | void setRevolutionsPerSecond(qreal revolutionsPerSecond); 58 | void setNumberOfLines(int lines); 59 | void setLineLength(int length); 60 | void setLineWidth(int width); 61 | void setInnerRadius(int radius); 62 | QColor color(); 63 | qreal roundness(); 64 | qreal minimumTrailOpacity(); 65 | qreal trailFadePercentage(); 66 | qreal revolutionsPersSecond(); 67 | int numberOfLines(); 68 | int lineLength(); 69 | int lineWidth(); 70 | int innerRadius(); 71 | bool isSpinning() const; 72 | 73 | private slots: 74 | void rotate(); 75 | 76 | protected: 77 | void paintEvent(QPaintEvent *paintEvent); 78 | 79 | private: 80 | static int lineCountDistanceFromPrimary(int current, int primary, 81 | int totalNrOfLines); 82 | static QColor currentLineColor(int distance, int totalNrOfLines, 83 | qreal trailFadePerc, qreal minOpacity, 84 | QColor color); 85 | 86 | void initialize(); 87 | void updateSize(); 88 | void updateTimer(); 89 | void updatePosition(); 90 | 91 | private: 92 | QColor _color; 93 | qreal _roundness; // 0..100 94 | qreal _minimumTrailOpacity; 95 | qreal _trailFadePercentage; 96 | qreal _revolutionsPerSecond; 97 | int _numberOfLines; 98 | int _lineLength; 99 | int _lineWidth; 100 | int _innerRadius; 101 | 102 | private: 103 | WaitingSpinnerWidget(const WaitingSpinnerWidget&); 104 | WaitingSpinnerWidget& operator=(const WaitingSpinnerWidget&); 105 | 106 | QTimer *_timer; 107 | bool _centerOnParent; 108 | bool _disableParentWhenSpinning; 109 | int _currentCounter; 110 | bool _isSpinning; 111 | }; 112 | -------------------------------------------------------------------------------- /NBaseUiKit/3rdparty/waiting/qtwaitingspinner.pri: -------------------------------------------------------------------------------- 1 | INCLUDEPATH += $$PWD/inc/ 2 | 3 | SOURCES += $$PWD/src/waitingspinnerwidget.cpp 4 | 5 | HEADERS += $$PWD/inc/waitingspinnerwidget.h 6 | -------------------------------------------------------------------------------- /NBaseUiKit/NBaseUiKit.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2016-08-05T15:35:45 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += widgets 8 | 9 | TARGET = NBaseUiKit 10 | TEMPLATE = lib 11 | 12 | DEFINES += NBASEUIKIT_LIBRARY 13 | 14 | CONFIG += c++11 15 | 16 | # 引入源码 17 | include($$PWD/NBaseUiKit_src.pri) 18 | 19 | # 引入第三方源码 20 | include($$PWD/3rdparty/3rdparty.pri) 21 | INCLUDEPATH += $$PWD/3rdparty/qrencode/qrencode \ 22 | 23 | # 引入版本信息 24 | RC_FILE += ./NBaseUiKit_resource.rc 25 | 26 | # 引入图片资源 27 | RESOURCES += \ 28 | image_resources.qrc 29 | 30 | # 定义输出路径 31 | CONFIG += debug_and_release 32 | CONFIG(release, debug|release) { 33 | target_path = ./build_/dist 34 | } else { 35 | target_path = ./build_/debug 36 | } 37 | DESTDIR = ../bin 38 | MOC_DIR = $$target_path/moc 39 | RCC_DIR = $$target_path/rcc 40 | OBJECTS_DIR = $$target_path/obj 41 | 42 | # 输出编译套件信息 43 | message(Qt version: $$[QT_VERSION]) 44 | message(Qt is installed in $$[QT_INSTALL_PREFIX]) 45 | message(the NBaseUiKit will create in folder: $$target_path) 46 | 47 | 48 | -------------------------------------------------------------------------------- /NBaseUiKit/NBaseUiKit_inc.pri: -------------------------------------------------------------------------------- 1 | INCLUDEPATH += $$PWD/inc/ \ 2 | -------------------------------------------------------------------------------- /NBaseUiKit/NBaseUiKit_resource.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daodaoliang/NBaseUiKit/33de66f4a493a4299849ea091ee1957740f5c8f2/NBaseUiKit/NBaseUiKit_resource.rc -------------------------------------------------------------------------------- /NBaseUiKit/NBaseUiKit_src.pri: -------------------------------------------------------------------------------- 1 | SOURCES += \ 2 | $$PWD/src/nbasemoveablewidget.cpp \ 3 | $$PWD/src/nbasefadewidget.cpp \ 4 | $$PWD/src/nbaseminiappwidget.cpp \ 5 | $$PWD/src/nbasepopwidget.cpp \ 6 | $$PWD/src/nbaserotatingstackedwidget.cpp \ 7 | $$PWD/src/nbasesnowlabel.cpp \ 8 | $$PWD/src/nbaseshadowwidget.cpp \ 9 | $$PWD/src/nbasecircleanimationwidget.cpp \ 10 | $$PWD/src/nbaseledwidget.cpp \ 11 | $$PWD/src/nbasemarqueelabel.cpp \ 12 | $$PWD/src/nbaseqrencodewidget.cpp \ 13 | $$PWD/src/nbaseroundprogressbar.cpp \ 14 | $$PWD/src/nbasetoastr.cpp \ 15 | $$PWD/src/nbasewaitdialog.cpp \ 16 | $$PWD/src/nbaseshadowlabel.cpp \ 17 | $$PWD/src/ntouchlistwidget.cpp \ 18 | $$PWD/src/nbasecaptcha.cpp \ 19 | $$PWD/src/nbaseimagecropper.cpp \ 20 | $$PWD/src/nbaseswitchbutton.cpp \ 21 | $$PWD/src/ntouchlistview.cpp \ 22 | $$PWD/src/nbasereelwidget.cpp \ 23 | $$PWD/src/nbasetoolbutton.cpp \ 24 | $$PWD/src/nbaselogowidget.cpp \ 25 | $$PWD/src/nbaseclickwave.cpp \ 26 | $$PWD/src/nbasecountdown.cpp 27 | 28 | HEADERS +=\ 29 | $$PWD/inc/nbaseuikit_global.h \ 30 | $$PWD/inc/nbasemoveablewidget.h \ 31 | $$PWD/inc/nbasefadewidget.h \ 32 | $$PWD/inc/nbaseminiappwidget.h \ 33 | $$PWD/inc/nbasepopwidget.h \ 34 | $$PWD/inc/nbaserotatingstackedwidget.h \ 35 | $$PWD/inc/nbasesnowlabel.h \ 36 | $$PWD/inc/nbaseshadowwidget.h \ 37 | $$PWD/inc/nbasecircleanimationwidget.h \ 38 | $$PWD/inc/nbaseledwidget.h \ 39 | $$PWD/inc/nbasemarqueelabel.h \ 40 | $$PWD/inc/nbaseqrencodewidget.h \ 41 | $$PWD/inc/nbaseroundprogressbar.h \ 42 | $$PWD/inc/nbasetoastr.h \ 43 | $$PWD/inc/nbasewaitdialog.h \ 44 | $$PWD/inc/nbaseshadowlabel.h \ 45 | $$PWD/inc/ntouchlistwidget.h \ 46 | $$PWD/inc/nbasecaptcha.h \ 47 | $$PWD/inc/nbaseimagecropper.h \ 48 | $$PWD/inc/nbaseswitchbutton.h \ 49 | $$PWD/inc/ntouchlistview.h \ 50 | $$PWD/inc/nbasereelwidget.h \ 51 | $$PWD/inc/nbasetoolbutton.h \ 52 | $$PWD/inc/nbaselogowidget.h \ 53 | $$PWD/inc/nbaseclickwave.h \ 54 | $$PWD/inc/nbasecountdown.h 55 | 56 | 57 | INCLUDEPATH += $$PWD/inc/ \ 58 | -------------------------------------------------------------------------------- /NBaseUiKit/image_resources.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | img/shadow_bottom.png 4 | img/shadow_corner1.png 5 | img/shadow_corner2.png 6 | img/shadow_corner3.png 7 | img/shadow_corner4.png 8 | img/shadow_left.png 9 | img/shadow_right.png 10 | img/shadow_top.png 11 | img/window_shadow.png 12 | img/rolling.gif 13 | img/upload.png 14 | img/upload_hover.png 15 | img/upload_press.png 16 | img/bg_lock.png 17 | img/bg_setting.png 18 | img/bg_hover.png 19 | img/locked.png 20 | img/unlock.png 21 | img/unlock_hover.png 22 | img/bg_tool.png 23 | img/checked.png 24 | img/delete.png 25 | img/hover.png 26 | img/brightness.png 27 | img/image.png 28 | img/locked_2.png 29 | 30 | 31 | -------------------------------------------------------------------------------- /NBaseUiKit/img/bg_hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daodaoliang/NBaseUiKit/33de66f4a493a4299849ea091ee1957740f5c8f2/NBaseUiKit/img/bg_hover.png -------------------------------------------------------------------------------- /NBaseUiKit/img/bg_lock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daodaoliang/NBaseUiKit/33de66f4a493a4299849ea091ee1957740f5c8f2/NBaseUiKit/img/bg_lock.png -------------------------------------------------------------------------------- /NBaseUiKit/img/bg_setting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daodaoliang/NBaseUiKit/33de66f4a493a4299849ea091ee1957740f5c8f2/NBaseUiKit/img/bg_setting.png -------------------------------------------------------------------------------- /NBaseUiKit/img/bg_tool.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daodaoliang/NBaseUiKit/33de66f4a493a4299849ea091ee1957740f5c8f2/NBaseUiKit/img/bg_tool.png -------------------------------------------------------------------------------- /NBaseUiKit/img/brightness.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daodaoliang/NBaseUiKit/33de66f4a493a4299849ea091ee1957740f5c8f2/NBaseUiKit/img/brightness.png -------------------------------------------------------------------------------- /NBaseUiKit/img/checked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daodaoliang/NBaseUiKit/33de66f4a493a4299849ea091ee1957740f5c8f2/NBaseUiKit/img/checked.png -------------------------------------------------------------------------------- /NBaseUiKit/img/delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daodaoliang/NBaseUiKit/33de66f4a493a4299849ea091ee1957740f5c8f2/NBaseUiKit/img/delete.png -------------------------------------------------------------------------------- /NBaseUiKit/img/hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daodaoliang/NBaseUiKit/33de66f4a493a4299849ea091ee1957740f5c8f2/NBaseUiKit/img/hover.png -------------------------------------------------------------------------------- /NBaseUiKit/img/image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daodaoliang/NBaseUiKit/33de66f4a493a4299849ea091ee1957740f5c8f2/NBaseUiKit/img/image.png -------------------------------------------------------------------------------- /NBaseUiKit/img/locked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daodaoliang/NBaseUiKit/33de66f4a493a4299849ea091ee1957740f5c8f2/NBaseUiKit/img/locked.png -------------------------------------------------------------------------------- /NBaseUiKit/img/locked_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daodaoliang/NBaseUiKit/33de66f4a493a4299849ea091ee1957740f5c8f2/NBaseUiKit/img/locked_2.png -------------------------------------------------------------------------------- /NBaseUiKit/img/rolling.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daodaoliang/NBaseUiKit/33de66f4a493a4299849ea091ee1957740f5c8f2/NBaseUiKit/img/rolling.gif -------------------------------------------------------------------------------- /NBaseUiKit/img/shadow_bottom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daodaoliang/NBaseUiKit/33de66f4a493a4299849ea091ee1957740f5c8f2/NBaseUiKit/img/shadow_bottom.png -------------------------------------------------------------------------------- /NBaseUiKit/img/shadow_corner1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daodaoliang/NBaseUiKit/33de66f4a493a4299849ea091ee1957740f5c8f2/NBaseUiKit/img/shadow_corner1.png -------------------------------------------------------------------------------- /NBaseUiKit/img/shadow_corner2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daodaoliang/NBaseUiKit/33de66f4a493a4299849ea091ee1957740f5c8f2/NBaseUiKit/img/shadow_corner2.png -------------------------------------------------------------------------------- /NBaseUiKit/img/shadow_corner3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daodaoliang/NBaseUiKit/33de66f4a493a4299849ea091ee1957740f5c8f2/NBaseUiKit/img/shadow_corner3.png -------------------------------------------------------------------------------- /NBaseUiKit/img/shadow_corner4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daodaoliang/NBaseUiKit/33de66f4a493a4299849ea091ee1957740f5c8f2/NBaseUiKit/img/shadow_corner4.png -------------------------------------------------------------------------------- /NBaseUiKit/img/shadow_left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daodaoliang/NBaseUiKit/33de66f4a493a4299849ea091ee1957740f5c8f2/NBaseUiKit/img/shadow_left.png -------------------------------------------------------------------------------- /NBaseUiKit/img/shadow_right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daodaoliang/NBaseUiKit/33de66f4a493a4299849ea091ee1957740f5c8f2/NBaseUiKit/img/shadow_right.png -------------------------------------------------------------------------------- /NBaseUiKit/img/shadow_top.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daodaoliang/NBaseUiKit/33de66f4a493a4299849ea091ee1957740f5c8f2/NBaseUiKit/img/shadow_top.png -------------------------------------------------------------------------------- /NBaseUiKit/img/unlock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daodaoliang/NBaseUiKit/33de66f4a493a4299849ea091ee1957740f5c8f2/NBaseUiKit/img/unlock.png -------------------------------------------------------------------------------- /NBaseUiKit/img/unlock_hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daodaoliang/NBaseUiKit/33de66f4a493a4299849ea091ee1957740f5c8f2/NBaseUiKit/img/unlock_hover.png -------------------------------------------------------------------------------- /NBaseUiKit/img/upload.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daodaoliang/NBaseUiKit/33de66f4a493a4299849ea091ee1957740f5c8f2/NBaseUiKit/img/upload.png -------------------------------------------------------------------------------- /NBaseUiKit/img/upload_hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daodaoliang/NBaseUiKit/33de66f4a493a4299849ea091ee1957740f5c8f2/NBaseUiKit/img/upload_hover.png -------------------------------------------------------------------------------- /NBaseUiKit/img/upload_press.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daodaoliang/NBaseUiKit/33de66f4a493a4299849ea091ee1957740f5c8f2/NBaseUiKit/img/upload_press.png -------------------------------------------------------------------------------- /NBaseUiKit/img/window_shadow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daodaoliang/NBaseUiKit/33de66f4a493a4299849ea091ee1957740f5c8f2/NBaseUiKit/img/window_shadow.png -------------------------------------------------------------------------------- /NBaseUiKit/inc/nbasecaptcha.h: -------------------------------------------------------------------------------- 1 | #ifndef NBASECAPTCHA_H 2 | #define NBASECAPTCHA_H 3 | 4 | /** 5 | * 作者: daodaoliang 6 | * 时间: 2016年8月31日 7 | * 邮箱: daodaoliang@yeah.net 8 | */ 9 | 10 | #include 11 | #include 12 | #include 13 | #include "nbaseuikit_global.h" 14 | 15 | class NBaseCaptcha_p; 16 | /** 17 | * @brief The NBaseCaptcha class 验证码窗体 18 | */ 19 | class NBASEUIKITSHARED_EXPORT NBaseCaptcha : public QWidget 20 | { 21 | Q_OBJECT 22 | public: 23 | explicit NBaseCaptcha(QWidget *parent = nullptr, quint16 width = 180, quint16 height = 50, quint8 count = 6); 24 | 25 | /** 26 | * @brief generateOneCaptcha 生成一个验证码 27 | * @return 28 | */ 29 | QPixmap generateOneCaptcha(); 30 | 31 | /** 32 | * @brief getCurrentCaptcha 获取当前验证码串 33 | * @return 34 | */ 35 | QString getCurrentCaptcha() const; 36 | 37 | /** 38 | * @brief setCurrentCaptcha 设置当前验证码 39 | * @param value 40 | */ 41 | void setCurrentCaptcha(const QString &value); 42 | 43 | /** 44 | * @brief getCanvasWidth 获取画布的宽度 45 | * @return 46 | */ 47 | quint16 getCanvasWidth() const; 48 | 49 | /** 50 | * @brief setCanvasWidth 设置画布的宽度 51 | * @param value 52 | */ 53 | void setCanvasWidth(const quint16 &value); 54 | 55 | /** 56 | * @brief getCanvasHeight 获取画布的高度 57 | * @return 58 | */ 59 | quint16 getCanvasHeight() const; 60 | 61 | /** 62 | * @brief setCanvasHeight 设置画布的高度 63 | * @param value 64 | */ 65 | void setCanvasHeight(const quint16 &value); 66 | 67 | /** 68 | * @brief getCaptchaCount 获取验证码的数量 69 | * @return 70 | */ 71 | quint8 getCaptchaSize() const; 72 | 73 | /** 74 | * @brief setCaptchaCount 设置验证码的数量 75 | * @param value 76 | */ 77 | void setCaptchaSize(const quint8 &value); 78 | 79 | private: 80 | /** 81 | * @brief captchaInstance 验证码操作类 82 | */ 83 | NBaseCaptcha_p *captchaInstance; 84 | 85 | /** 86 | * @brief currentCaptcha 当前验证码串 87 | */ 88 | QString currentCaptcha; 89 | 90 | /** 91 | * @brief canvasWidth 画布的宽度 92 | */ 93 | quint16 canvasWidth; 94 | 95 | /** 96 | * @brief canvasHeight 画布的高度 97 | */ 98 | quint16 canvasHeight; 99 | 100 | /** 101 | * @brief captchaCount 验证码的高度 102 | */ 103 | quint8 captchaSize; 104 | }; 105 | 106 | #endif // NBASECAPTCHA_H 107 | -------------------------------------------------------------------------------- /NBaseUiKit/inc/nbasecircleanimationwidget.h: -------------------------------------------------------------------------------- 1 | #ifndef NBASECIRCLEANIMATIONWIDGET_H 2 | #define NBASECIRCLEANIMATIONWIDGET_H 3 | 4 | /** 5 | * 作者: daodaoliang 6 | * 时间: 2016年8月10日 7 | * 邮箱: daodaoliang@yeah.net 8 | */ 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include "nbaseuikit_global.h" 16 | #include "nbasemoveablewidget.h" 17 | #define PI 3.1415 18 | 19 | class QPropertyAnimation; 20 | 21 | /** 22 | * @brief The NBaseCircleAnimationWidget class 圆周运动的组件类 23 | */ 24 | class NBASEUIKITSHARED_EXPORT NBaseCircleAnimationWidget : public NBaseMoveableWidget 25 | { 26 | Q_OBJECT 27 | Q_PROPERTY(qreal percent READ percent WRITE setPercent) 28 | 29 | public: 30 | explicit NBaseCircleAnimationWidget(NBaseMoveableWidget *parent = 0); 31 | 32 | /** 33 | * @brief NBaseCircleAnimationWidget 构造函数 34 | * @param icon 背景图片 35 | * @param radius 圆角度 36 | * @param parent 父控件 37 | */ 38 | explicit NBaseCircleAnimationWidget(const QString &icon,const qreal &radius, NBaseMoveableWidget *parent = 0); 39 | 40 | public: 41 | /** 42 | * @brief setCircleInfo 设置窗体的的信息 43 | * @param icon 44 | * @param radius 45 | */ 46 | void setCircleInfo(const QString &icon, const qreal &radius); 47 | 48 | /** 49 | * @brief startAnimation 开启动画效果 50 | */ 51 | void startAnimation(); 52 | 53 | /** 54 | * @brief stopAnimation 结束动画效果 55 | */ 56 | void stopAnimation(); 57 | 58 | /** 59 | * @brief setPercent 设置位置 60 | * @param per 位置 61 | */ 62 | void setPercent(const qreal &per); 63 | 64 | /** 65 | * @brief percent 位置 66 | * @return 67 | */ 68 | const qreal &percent(); 69 | 70 | protected: 71 | /** 72 | * @brief paintEvent 绘制事件 73 | */ 74 | void paintEvent(QPaintEvent *); 75 | 76 | private slots: 77 | /** 78 | * @brief updatePos 更新位置 79 | */ 80 | void updatePos(); 81 | 82 | private: 83 | QPoint mathPoint(); 84 | QPoint mathPoint(const QPoint ¢erPos, const qreal &percent, const qreal &radius); 85 | void initAnimation(); 86 | 87 | private: 88 | qreal m_percent; 89 | qreal m_radius; 90 | QPoint m_centerPos; 91 | QPropertyAnimation *m_percentAnimation; 92 | QPixmap m_pix; 93 | QPoint m_point; 94 | QPoint m_originPoint; 95 | }; 96 | 97 | #endif // NBASECIRCLEANIMATIONWIDGET_H 98 | -------------------------------------------------------------------------------- /NBaseUiKit/inc/nbaseclickwave.h: -------------------------------------------------------------------------------- 1 | #ifndef NBASECLICKWAVE_H 2 | #define NBASECLICKWAVE_H 3 | 4 | /** 5 | * 作者: daodaoliang 6 | * 时间: 2016年9月29日 7 | * 邮箱: daodaoliang@yeah.net 8 | */ 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include "nbaseuikit_global.h" 15 | 16 | /** 17 | * @brief The NBaseClickWave class 点击波按钮 18 | */ 19 | class NBASEUIKITSHARED_EXPORT NBaseClickWave : public QPushButton 20 | { 21 | Q_OBJECT 22 | Q_PROPERTY(qreal waveRadius READ getWaveRadius WRITE setWaveRadius NOTIFY waveRadiusChanged) 23 | 24 | public: 25 | /** 26 | * @brief NBaseClickWave 构造函数 27 | * @param parent 28 | */ 29 | explicit NBaseClickWave(QWidget *parent = 0); 30 | 31 | /** 32 | * @brief getWaveRadius 获取圆周半径 33 | * @return 34 | */ 35 | qreal getWaveRadius() const; 36 | 37 | /** 38 | * @brief setWaveRadius 设置圆周半径 39 | * @param value 40 | */ 41 | void setWaveRadius(const qreal &value); 42 | 43 | /** 44 | * @brief getClickColor 获取点击波颜色 45 | * @return 46 | */ 47 | QColor getClickColor() const; 48 | 49 | /** 50 | * @brief setClickColor 设置点击波颜色 51 | * @param value 52 | */ 53 | void setClickColor(const QColor &value); 54 | 55 | signals: 56 | /** 57 | * @brief waveRadiusChanged 点击波改变 58 | */ 59 | void waveRadiusChanged(qreal waveRadius); 60 | 61 | protected: 62 | /** 63 | * @brief paintEvent 绘制事件 64 | * @param event 65 | */ 66 | void paintEvent(QPaintEvent *event); 67 | 68 | /** 69 | * @brief mousePressEvent 鼠标按压事件 70 | * @param event 71 | */ 72 | void mousePressEvent(QMouseEvent *event); 73 | 74 | private: 75 | /** 76 | * @brief pointX 圆心x坐标 77 | */ 78 | qreal pointX; 79 | 80 | /** 81 | * @brief pointY 圆心y坐标 82 | */ 83 | qreal pointY; 84 | 85 | /** 86 | * @brief waveRadius 圆心半径 87 | */ 88 | qreal waveRadius; 89 | 90 | /** 91 | * @brief clickColor 点击波的颜色 92 | */ 93 | QColor clickColor; 94 | }; 95 | 96 | #endif // NBASECLICKWAVE_H 97 | -------------------------------------------------------------------------------- /NBaseUiKit/inc/nbasecountdown.h: -------------------------------------------------------------------------------- 1 | #ifndef NBASECOUNTDOWN_H 2 | #define NBASECOUNTDOWN_H 3 | 4 | /** 5 | * 作者: daodaoliang 6 | * 时间: 2016年9月29日 7 | * 邮箱: daodaoliang@yeah.net 8 | */ 9 | 10 | #include 11 | #include 12 | #include 13 | #include "nbasemoveablewidget.h" 14 | #include "nbaseuikit_global.h" 15 | 16 | 17 | /** 18 | * @brief The NBaseCountDown class 倒计时带有波纹效果的窗体 19 | */ 20 | class NBASEUIKITSHARED_EXPORT NBaseCountDown : public NBaseMoveableWidget 21 | { 22 | Q_OBJECT 23 | Q_PROPERTY(qreal waveRadius READ getWaveRadius WRITE setWaveRadius NOTIFY signalWaveRadius) 24 | 25 | public: 26 | /** 27 | * @brief NBaseCountDown 28 | * @param parent 29 | * @param paramCountDown 默认倒数的开始数量 30 | */ 31 | explicit NBaseCountDown(QWidget *parent = 0, int paramCountDown=10,bool isfill=false); 32 | 33 | /** 34 | * @brief startCountDown 开始倒计时 35 | */ 36 | void startCountDown(); 37 | 38 | /** 39 | * @brief stopCountDown 结束倒计时 40 | */ 41 | void stopCountDown(); 42 | 43 | /** 44 | * @brief getWaveRadius 获取波纹半径 45 | * @return 46 | */ 47 | qreal getWaveRadius() const; 48 | 49 | /** 50 | * @brief setWaveRadius 设置波纹半径 51 | * @param value 52 | */ 53 | void setWaveRadius(const qreal &value); 54 | 55 | /** 56 | * @brief getCountDown 获取倒计数 57 | * @return 58 | */ 59 | int getCountDown() const; 60 | 61 | /** 62 | * @brief setCountDown 设置倒计数 63 | * @param value 64 | */ 65 | void setCountDown(int value); 66 | 67 | signals: 68 | /** 69 | * @brief signalWaveRadius 70 | * @param paramWaveRadius 状态值 71 | */ 72 | void signalWaveRadius(qreal paramWaveRadius); 73 | 74 | /** 75 | * @brief signalCountFinshed 倒计时结束信号 76 | */ 77 | void signalCountFinshed(); 78 | 79 | protected: 80 | 81 | /** 82 | * @brief paintEvent 绘制事件 83 | * @param event 84 | */ 85 | void paintEvent(QPaintEvent *event); 86 | 87 | /** 88 | * @brief timerEvent 定时器事件 89 | * @param event 90 | */ 91 | void timerEvent(QTimerEvent *event); 92 | 93 | /** 94 | * @brief closeEvent 关闭事件 95 | * @param event 96 | */ 97 | void closeEvent(QCloseEvent *event); 98 | 99 | private: 100 | /** 101 | * @brief innerAnimation 开启内部动画片段 102 | * @param isPositive 是否是正序的 103 | */ 104 | void innerAnimation(bool isPositive); 105 | 106 | private: 107 | /** 108 | * @brief pointX 圆心x坐标 109 | */ 110 | qreal pointX; 111 | 112 | /** 113 | * @brief pointY 圆心y坐标 114 | */ 115 | qreal pointY; 116 | 117 | /** 118 | * @brief waveRadius 圆形波纹半径 119 | */ 120 | qreal waveRadius; 121 | 122 | /** 123 | * @brief timerId 倒计时的ID 124 | */ 125 | int timerId; 126 | 127 | /** 128 | * @brief countDown 倒计时的开始数量 129 | */ 130 | int countDown; 131 | 132 | /** 133 | * @brief innerAnima 内部动画 134 | */ 135 | QPropertyAnimation *innerAnima; 136 | 137 | /** 138 | * @brief coreRadius 内核圆半径 139 | */ 140 | int coreRadius; 141 | 142 | /** 143 | * @brief isFlag 顺序标记 144 | */ 145 | bool isFlag; 146 | 147 | /** 148 | * @brief backColor 背景波纹色 149 | */ 150 | QColor backColor; 151 | 152 | /** 153 | * @brief coreColorBegin 核心圆开始颜色 154 | */ 155 | QColor coreColorBegin; 156 | 157 | /** 158 | * @brief coreColorMid 核心圆中间色 159 | */ 160 | QColor coreColorMid; 161 | 162 | /** 163 | * @brief coreColorEnd 核心圆结束色 164 | */ 165 | QColor coreColorEnd; 166 | 167 | /** 168 | * @brief changeStep 步长 169 | */ 170 | int changeStep; 171 | 172 | /** 173 | * @brief isFill 是否充满窗体 174 | */ 175 | bool isFill; 176 | }; 177 | 178 | #endif // NBASECOUNTDOWN_H 179 | -------------------------------------------------------------------------------- /NBaseUiKit/inc/nbasefadewidget.h: -------------------------------------------------------------------------------- 1 | #ifndef NBASEFADEWIDGET_H 2 | #define NBASEFADEWIDGET_H 3 | 4 | /** 5 | * 作者: daodaoliang 6 | * 时间: 2016年8月10日 7 | * 邮箱: daodaoliang@yeah.net 8 | */ 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include "nbasemoveablewidget.h" 16 | #include "nbaseuikit_global.h" 17 | 18 | /** 19 | * @brief The NBaseFadeWidget class 淡入淡出widget 20 | */ 21 | class NBASEUIKITSHARED_EXPORT NBaseFadeWidget : public NBaseMoveableWidget 22 | { 23 | Q_OBJECT 24 | Q_PROPERTY(qreal opacity READ getopacity WRITE setopacity NOTIFY opacityChanged) 25 | 26 | public: 27 | /** 28 | * @brief NBaseFadeWidget 构造函数 29 | * @param parent 30 | */ 31 | explicit NBaseFadeWidget(NBaseMoveableWidget *parent = 0); 32 | 33 | signals: 34 | /** 35 | * @brief opacityChanged 透明度改变的信号 36 | * @param param_opacity 当前透明度 37 | */ 38 | void opacityChanged(qreal param_opacity); 39 | 40 | public: 41 | /** 42 | * @brief beginFadeShow 开启淡入淡出的效果 43 | * @param param_seconds param_seconds秒内完成效果动画 44 | */ 45 | void beginFadeShow(quint32 param_seconds); 46 | 47 | /** 48 | * @brief setopacity 设置透明度 49 | * @param param_opacity 透明度 50 | */ 51 | void setopacity(qreal param_opacity); 52 | 53 | /** 54 | * @brief getopacity 获取当前透明度 55 | * @return 56 | */ 57 | qreal getopacity(); 58 | 59 | private: 60 | /** 61 | * @brief opacity_ 当前透明度 62 | */ 63 | qreal opacity_; 64 | 65 | /** 66 | * @brief show_animation_ 显示动画 67 | */ 68 | QPropertyAnimation *show_animation_; 69 | }; 70 | 71 | #endif // NBASEFADEWIDGET_H 72 | -------------------------------------------------------------------------------- /NBaseUiKit/inc/nbaseimagecropper.h: -------------------------------------------------------------------------------- 1 | #ifndef NNBASEIMAGECROPPER_H 2 | #define NNBASEIMAGECROPPER_H 3 | 4 | /** 5 | * 作者: daodaoliang 6 | * 时间: 2016年9月02日 7 | * 邮箱: daodaoliang@yeah.net 8 | */ 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include "nbaseuikit_global.h" 15 | 16 | class NBaseImageCropper_p; 17 | 18 | /** 19 | * @brief The NBaseImageCropper class 图片截取组件 20 | */ 21 | class NBASEUIKITSHARED_EXPORT NBaseImageCropper : public QWidget 22 | { 23 | Q_OBJECT 24 | public: 25 | /** 26 | * @brief NBaseImageCropper 27 | * @param parent 28 | * @param isCropBtn 是否有截取按钮 29 | * @param isToolBtn 是否有工具按钮 30 | */ 31 | NBaseImageCropper(QWidget* parent = nullptr, bool isCropBtn=false, bool isToolBtn=false); 32 | 33 | public slots: 34 | /** 35 | * @brief setProportion 设置固定比例 36 | * @param paramWidth 宽的比例值 37 | * @param paramHeight 高的比例值 38 | */ 39 | void setProportion(const quint8 ¶mWidth, const quint8 ¶mHeight); 40 | 41 | /** 42 | * @brief setImage 设置要截取的图片 43 | * @param imagePath 图片路径 44 | */ 45 | void setImage(const QString imagePath); 46 | 47 | /** 48 | * @brief setCropStyle 设置截取框的风格 49 | * @param bgColor 背景颜色 50 | * @param borderColor 边框线的颜色 51 | */ 52 | void setCropStyle(const QColor &bgColor, const QColor &borderColor); 53 | 54 | /** 55 | * @brief setSize 设置尺寸 56 | * @param width 宽 57 | * @param height 高 58 | */ 59 | void setSize(const quint16 &width, const quint16 &height); 60 | 61 | /** 62 | * @brief cropImage 截取图片 63 | */ 64 | const QPixmap cropImage(); 65 | 66 | /** 67 | * @brief getCurrentPixMap 获取当前截取的图片 68 | * @return 69 | */ 70 | QPixmap getCurrentPixMap() const; 71 | 72 | /** 73 | * @brief setCurrentPixMap 设置截取的图片 74 | * @param value 75 | */ 76 | void setCurrentPixMap(const QPixmap &value); 77 | 78 | private slots: 79 | /** 80 | * @brief setFTProportion 设置四比三的比例 81 | */ 82 | void setFTProportion(); 83 | 84 | /** 85 | * @brief setOOProportion 设置一比一的比例 86 | */ 87 | void setOOProportion(); 88 | 89 | /** 90 | * @brief setNoProportion 不设置固定比例 91 | */ 92 | void setNoProportion(); 93 | 94 | signals: 95 | /** 96 | * @brief cropImage 截图信号 97 | * @param image 98 | */ 99 | void singalCropImage(QPixmap image); 100 | 101 | protected: 102 | /** 103 | * @brief showEvent showwvent 104 | * @param event 105 | */ 106 | void showEvent(QShowEvent *event); 107 | 108 | private: 109 | 110 | /** 111 | * @brief currentPixMap 当前截取的图片 112 | */ 113 | QPixmap currentPixMap; 114 | 115 | /** 116 | * @brief imageInstance 图片处理实例 117 | */ 118 | NBaseImageCropper_p *imageInstance; 119 | 120 | /** 121 | * @brief shortCut 双击显示截图的label 122 | */ 123 | QLabel *shortCut; 124 | 125 | /** 126 | * @brief showBtn 是否显示截取按钮 127 | */ 128 | bool showConfirmBtn; 129 | 130 | /** 131 | * @brief showToolBtn 是否显示工具按钮 132 | */ 133 | bool showToolBtn; 134 | 135 | /** 136 | * @brief isFixed 是否已经固定4:3比例 137 | */ 138 | bool isFTFixed; 139 | 140 | /** 141 | * @brief isOOFixed 是否已经固定1:1比例 142 | */ 143 | bool isOOFixed; 144 | 145 | /** 146 | * @brief cropBtn 截取按钮 147 | */ 148 | QPushButton *cropBtn; 149 | 150 | /** 151 | * @brief ftsBtn 4:3比例按钮 152 | */ 153 | QPushButton *ftsBtn; 154 | 155 | /** 156 | * @brief ooBtn 1:1比例按钮 157 | */ 158 | QPushButton *ooBtn; 159 | 160 | }; 161 | 162 | #endif // NNBASEIMAGECROPPER_H 163 | -------------------------------------------------------------------------------- /NBaseUiKit/inc/nbaseledwidget.h: -------------------------------------------------------------------------------- 1 | #ifndef NBASELEDWIDGET_H 2 | #define NBASELEDWIDGET_H 3 | 4 | /** 5 | * 作者: daodaoliang 6 | * 时间: 2016年8月11日 7 | * 邮箱: daodaoliang@yeah.net 8 | */ 9 | 10 | #include 11 | #include 12 | #include 13 | #include "nbaseuikit_global.h" 14 | 15 | /** 16 | * @brief The NBaseLEDWidget class 仿LED效果的widget 17 | */ 18 | class NBASEUIKITSHARED_EXPORT NBaseLEDWidget : public QWidget 19 | { 20 | Q_OBJECT 21 | Q_ENUMS(Effect) 22 | Q_PROPERTY(Effect effect READ effect WRITE setEffect) 23 | Q_PROPERTY(QColor colorText READ colorText WRITE setTextColor) 24 | Q_PROPERTY(QColor colorBackground READ colorBackground WRITE setBackgroundColor) 25 | Q_PROPERTY(QString text READ text WRITE setText) 26 | Q_PROPERTY(int timer READ timerInterval WRITE setTimer) 27 | Q_PROPERTY(bool start READ isStart WRITE startEffect) 28 | 29 | public: 30 | explicit NBaseLEDWidget(QWidget *parent = 0); 31 | /** 32 | * @brief The Effect enum 特效枚举 33 | * sliding 为跑马灯效果 34 | * intermittent 为闪烁效果 35 | */ 36 | enum Effect 37 | { 38 | sliding=1, 39 | intermittent=2 40 | }; 41 | 42 | public slots: 43 | /** 44 | * @brief setTextColor 设置文本颜色 45 | * @param colorTx 颜色 46 | */ 47 | void setTextColor(QColor colorText); 48 | 49 | /** 50 | * @brief setBackgroundColor 设置背景颜色 51 | * @param colorBg 颜色 52 | */ 53 | void setBackgroundColor(QColor colorBackground); 54 | 55 | /** 56 | * @brief setEffect 设置特效类型 57 | * @param effect sliding-为跑马灯效果 intermittent-为闪烁效果 58 | */ 59 | void setEffect(Effect effect); 60 | 61 | /** 62 | * @brief setText 设置文本内容 63 | * @param text 文本 64 | */ 65 | void setText(QString text); 66 | 67 | /** 68 | * @brief setTimer 设置定时频率(毫秒) 69 | * @param timer 频率 70 | */ 71 | void setTimer(int timer); 72 | 73 | /** 74 | * @brief startEffect 开始/关闭 特效 75 | * @param start true-开启 false-关闭 76 | */ 77 | void startEffect(bool start); 78 | 79 | public: 80 | /** 81 | * @brief minimumSizeHint 获取最小显示尺寸 82 | * @return 83 | */ 84 | QSize minimumSizeHint() const; 85 | 86 | /** 87 | * @brief sizeHint 获取尺寸 88 | * @return 89 | */ 90 | QSize sizeHint() const; 91 | 92 | /** 93 | * @brief effect 获取特效类型 94 | * @return 95 | */ 96 | Effect effect() const; 97 | 98 | /** 99 | * @brief colorText 获取文字颜色 100 | * @return 101 | */ 102 | QColor colorText() const; 103 | 104 | /** 105 | * @brief colorBackground 获取背景颜色 106 | * @return 107 | */ 108 | QColor colorBackground() const; 109 | 110 | /** 111 | * @brief text 获取文本内容 112 | * @return 113 | */ 114 | QString text() const; 115 | 116 | /** 117 | * @brief timerInterval 获取刷新频率 118 | * @return 119 | */ 120 | int timerInterval() const; 121 | 122 | /** 123 | * @brief isStart 获取特效是否开启中 124 | * @return 125 | */ 126 | bool isStart() const; 127 | 128 | signals: 129 | void timeOut(); 130 | 131 | protected: 132 | /** 133 | * @brief paintEvent 绘制事件 134 | * @param event 135 | */ 136 | void paintEvent(QPaintEvent *event); 137 | 138 | /** 139 | * @brief timerEvent 定时器事件 140 | * @param event 141 | */ 142 | void timerEvent(QTimerEvent *event); 143 | 144 | /** 145 | * @brief paintBorder 绘制边框 146 | */ 147 | void paintBorder(); 148 | 149 | /** 150 | * @brief paintText 绘制文本 151 | */ 152 | void paintText(); 153 | 154 | /** 155 | * @brief paintGrid 绘制网格 156 | */ 157 | void paintGrid(); 158 | 159 | private: 160 | int timerVal; 161 | int idTimer; 162 | double numChar; 163 | double length; 164 | bool on; 165 | bool timerState; 166 | QString textMsg; 167 | QString textOff; 168 | QString textOn; 169 | QColor textCol; 170 | QColor backCol; 171 | Effect typeEff; 172 | }; 173 | 174 | #endif // NBASELEDWIDGET_H 175 | -------------------------------------------------------------------------------- /NBaseUiKit/inc/nbaselogowidget.h: -------------------------------------------------------------------------------- 1 | #ifndef NBASELOGOWIDGET_H 2 | #define NBASELOGOWIDGET_H 3 | 4 | /** 5 | * 作者: daodaoliang 6 | * 时间: 2016年9月22日 7 | * 邮箱: daodaoliang@yeah.net 8 | */ 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include "nbaseuikit_global.h" 15 | #include "nbaseimagecropper.h" 16 | 17 | 18 | /** 19 | * @brief The NbaseLogoWidget class 头像编辑空间 20 | */ 21 | class NBASEUIKITSHARED_EXPORT NBaseLogoWidget : public QLabel 22 | { 23 | Q_OBJECT 24 | public: 25 | /** 26 | * @brief NbaseLogoWidget 构造函数 27 | * @param parent 28 | */ 29 | explicit NBaseLogoWidget(QWidget *parent = 0); 30 | 31 | public: 32 | /** 33 | * @brief editLogo 编辑头像的处理函数 34 | */ 35 | void editLogo(); 36 | 37 | /** 38 | * @brief getLogoPath 获取头像路径 39 | * @return 40 | */ 41 | QString getLogoPath() const; 42 | 43 | /** 44 | * @brief setLogoPath 设置头像路径 45 | * @param value 46 | */ 47 | void setLogoPath(const QString &value); 48 | 49 | private slots: 50 | /** 51 | * @brief cropImage 图片截取 52 | * @param paramValue 53 | */ 54 | void cropImage(QPixmap paramValue); 55 | 56 | protected: 57 | /** 58 | * @brief mouseDoubleClickEvent 鼠标双击事件 59 | * @param event 60 | */ 61 | void mouseDoubleClickEvent(QMouseEvent *event); 62 | 63 | private: 64 | /** 65 | * @brief isProcessing 是否正在处理 66 | */ 67 | bool isProcessing; 68 | /** 69 | * @brief imageCrop 图片截取 70 | */ 71 | NBaseImageCropper *imageCrop; 72 | 73 | /** 74 | * @brief logoPath 头像路径 75 | */ 76 | QString logoPath; 77 | }; 78 | 79 | #endif // NBASELOGOWIDGET_H 80 | -------------------------------------------------------------------------------- /NBaseUiKit/inc/nbasemarqueelabel.h: -------------------------------------------------------------------------------- 1 | #ifndef NBASEMARQUEELABEL_H 2 | #define NBASEMARQUEELABEL_H 3 | 4 | /** 5 | * 作者: daodaoliang 6 | * 时间: 2016年8月11日 7 | * 邮箱: daodaoliang@yeah.net 8 | */ 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include "nbaseuikit_global.h" 18 | 19 | /** 20 | * @brief The NBaseMarqueeLabel class 跑马灯组件 21 | */ 22 | class NBASEUIKITSHARED_EXPORT NBaseMarqueeLabel : public QLabel 23 | { 24 | Q_OBJECT 25 | Q_ENUMS(Direction) 26 | 27 | public: 28 | /** 29 | * @brief The Direction enum 文字的浮动方向 30 | */ 31 | enum Direction 32 | { 33 | // 从右向左 34 | RightToLeft = 0, 35 | // 从下到上 36 | BottomToTop = 1 37 | }; 38 | public: 39 | NBaseMarqueeLabel(QWidget * parent = 0, Qt::WindowFlags f = 0); 40 | NBaseMarqueeLabel(const QString &text, QWidget *parent = 0, Qt::WindowFlags f = 0); 41 | virtual ~NBaseMarqueeLabel(); 42 | int interval() const; 43 | bool isActive() const; 44 | Direction direction() const; 45 | void setAlignment(Qt::Alignment align); 46 | 47 | signals: 48 | void intervalChanged(int mInterval); 49 | void activeChanged(bool active); 50 | void directionChanged(Direction direction); 51 | 52 | public slots: 53 | void reset(); 54 | void setActive(bool paramActive); 55 | void setInterval(int msec); 56 | void start(); 57 | void stop(); 58 | void setDirection(Direction param_direciton); 59 | 60 | protected: 61 | virtual void enterEvent(QEvent *event); 62 | virtual void leaveEvent(QEvent *event); 63 | virtual void resizeEvent(QResizeEvent *event); 64 | virtual void timerEvent(QTimerEvent *event); 65 | virtual void paintEvent(QPaintEvent *event); 66 | 67 | private: 68 | int marqueeMargin; 69 | int timerId; 70 | int mInterval; 71 | bool active; 72 | bool mouseIn; 73 | Direction mDirection; 74 | }; 75 | #endif // NBASEMARQUEELABEL_H 76 | -------------------------------------------------------------------------------- /NBaseUiKit/inc/nbaseminiappwidget.h: -------------------------------------------------------------------------------- 1 | #ifndef NBASEMINIAPPWIDGET_H 2 | #define NBASEMINIAPPWIDGET_H 3 | 4 | /** 5 | * 作者: daodaoliang 6 | * 时间: 2016年8月10日 7 | * 邮箱: daodaoliang@yeah.net 8 | */ 9 | 10 | #include 11 | #include 12 | #include "nbasemoveablewidget.h" 13 | 14 | /** 15 | * @brief The NBaseMiniAppWidget class mini窗体基类 16 | */ 17 | class NBASEUIKITSHARED_EXPORT NBaseMiniAppWidget : public NBaseMoveableWidget 18 | { 19 | Q_OBJECT 20 | public: 21 | explicit NBaseMiniAppWidget(NBaseMoveableWidget *parent = 0); 22 | 23 | signals: 24 | /** 25 | * @brief signalMiniIconClicked 窗体点击事件 26 | */ 27 | void signalMiniIconClicked(); 28 | 29 | public: 30 | /** 31 | * @brief setPixmap 设置窗体背景图片 32 | * @param pixmap 33 | */ 34 | void setPixmap(QPixmap pixmap); 35 | 36 | protected: 37 | /** 38 | * @brief enterEvent 时间处理函数 39 | * @param event 40 | */ 41 | void enterEvent(QEvent *event); 42 | 43 | /** 44 | * @brief leaveEvent 鼠标离开事件 45 | * @param event 46 | */ 47 | void leaveEvent(QEvent *event); 48 | 49 | /** 50 | * @brief paintEvent 绘画事件 51 | * @param event 52 | */ 53 | void paintEvent(QPaintEvent *event); 54 | 55 | /** 56 | * @brief mouseDoubleClickEvent 鼠标双击事件 57 | * @param event 58 | */ 59 | void mouseDoubleClickEvent(QMouseEvent *event); 60 | 61 | private: 62 | /** 63 | * @brief m_Pixmap 背景图片 64 | */ 65 | QPixmap m_Pixmap; 66 | }; 67 | 68 | #endif // NBASEMINIAPPWIDGET_H 69 | -------------------------------------------------------------------------------- /NBaseUiKit/inc/nbasemoveablewidget.h: -------------------------------------------------------------------------------- 1 | #ifndef NBASEMOVEABLEWIDGET_H 2 | #define NBASEMOVEABLEWIDGET_H 3 | 4 | /** 5 | * 作者: daodaoliang 6 | * 时间: 2016年8月10日 7 | * 邮箱: daodaoliang@yeah.net 8 | */ 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #if defined(Q_OS_WIN) 19 | #include 20 | #include 21 | #endif 22 | #include "nbaseuikit_global.h" 23 | #include "nbasetoolbutton.h" 24 | 25 | /*接受边框处理的宽度*/ 26 | #define PADDING 2 27 | 28 | /** 29 | * @brief The Direction enum 30 | * 鼠标方向 31 | */ 32 | enum Direction{ 33 | UP = 0, 34 | DOWN, 35 | LEFT, 36 | RIGHT, 37 | LEFTTOP, 38 | LEFTBOTTOM, 39 | RIGHTBOTTOM, 40 | RIGHTTOP, 41 | NONE 42 | }; 43 | 44 | /** 45 | * @brief The MOVEPLAN enum 46 | * 窗体移动方案 47 | */ 48 | enum MOVEPLAN{ 49 | PLANA, 50 | PLANB 51 | }; 52 | 53 | /** 54 | * @brief The NBaseMoveableWidget class 55 | * 可拖动大小,可移动窗体 56 | */ 57 | 58 | class NBASEUIKITSHARED_EXPORT NBaseMoveableWidget : public NBaseToolButton 59 | { 60 | Q_OBJECT 61 | public: 62 | /** 63 | * @brief NBaseMoveableWidget 构造函数 64 | * @param parent 父指针 65 | */ 66 | explicit NBaseMoveableWidget(QWidget *parent = 0); 67 | 68 | /** 69 | * @brief move_plan 窗体移动方案 70 | * @return 方案 71 | */ 72 | MOVEPLAN move_plan() const; 73 | 74 | /** 75 | * @brief isDragAble 获取是否可拖拽 76 | * @return 是否可拖拽 77 | */ 78 | bool isDragAble() const; 79 | 80 | /** 81 | * @brief setIsDragAble 设置是否可拖拽 82 | * @param isDragAble 是否可拖拽 83 | */ 84 | void setIsDragAble(bool isDragAble); 85 | 86 | protected: 87 | /** 88 | * @brief mousePressEvent 鼠标按压事件处理 89 | * @param event 90 | */ 91 | void mousePressEvent(QMouseEvent *event); 92 | 93 | /** 94 | * @brief mouseMoveEvent 鼠标移动事件处理 95 | * @param event 96 | */ 97 | void mouseMoveEvent(QMouseEvent *event); 98 | 99 | /** 100 | * @brief mouseReleaseEvent 鼠标释放时间处理 101 | * @param event 102 | */ 103 | void mouseReleaseEvent(QMouseEvent *event); 104 | 105 | /** 106 | * @brief paintEvent 绘制事件 107 | * @param event 108 | */ 109 | void paintEvent(QPaintEvent *event); 110 | 111 | #if defined(Q_OS_WIN) 112 | /** 113 | * @brief winEvent windows窗体事件 114 | * @param message 115 | * @param result 116 | * @return 117 | */ 118 | bool winEvent(MSG *message, long *result); 119 | #endif 120 | private: 121 | /** 122 | * @brief region 鼠标指针修改 123 | * @param cursorGlobalPoint 124 | */ 125 | void region(const QPoint &cursorGlobalPoint); 126 | 127 | /** 128 | * @brief setMove_plan 设置窗体移动方案 129 | * @param move_plan 130 | */ 131 | void setMove_plan(const MOVEPLAN &move_plan); 132 | 133 | private: 134 | /** 135 | * @brief isLeftPressDown_ 左键是否按压 136 | */ 137 | bool isLeftPressDown_; 138 | 139 | /** 140 | * @brief isDragAble_ 窗体是否可拖拽大小 141 | */ 142 | bool isDragAble_; 143 | 144 | /** 145 | * @brief dragPosition_ 窗体拖拽的位置 146 | */ 147 | QPoint dragPosition_; 148 | 149 | /** 150 | * @brief dir_ 鼠标方向 151 | */ 152 | Direction dir_; 153 | 154 | /** 155 | * @brief move_plan_ 窗体移动方案 156 | */ 157 | MOVEPLAN move_plan_; 158 | }; 159 | 160 | #endif // NBASEMOVEABLEWIDGET_H 161 | -------------------------------------------------------------------------------- /NBaseUiKit/inc/nbasepopwidget.h: -------------------------------------------------------------------------------- 1 | #ifndef NBASEPOPWIDGET_H 2 | #define NBASEPOPWIDGET_H 3 | 4 | 5 | /** 6 | * 作者: daodaoliang 7 | * 时间: 2016年8月10日 8 | * 邮箱: daodaoliang@yeah.net 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include "nbaseuikit_global.h" 19 | 20 | /** 21 | * @brief The NBasePopWidget class 弹出窗体界面 22 | */ 23 | class NBASEUIKITSHARED_EXPORT NBasePopWidget : public QWidget 24 | { 25 | Q_OBJECT 26 | 27 | public: 28 | /** 29 | * @brief NBasePopWidget 构造函数 30 | * @param parent 31 | */ 32 | explicit NBasePopWidget(QWidget *parent = 0); 33 | 34 | public slots: 35 | /** 36 | * @brief showPopDialog 显示弹出窗口 37 | * @param paramRemainTime 38 | */ 39 | void showPopDialog(quint32 paramRemainTime = 6); 40 | 41 | /** 42 | * @brief closePopDialog 关闭弹出窗口 43 | */ 44 | void closePopDialog(); 45 | 46 | /** 47 | * @brief pausePopDialog 暂停动画效果 48 | */ 49 | void pausePopDialog(); 50 | 51 | /** 52 | * @brief startPopDialog 开启动画效果 53 | */ 54 | void startPopDialog(); 55 | 56 | private slots: 57 | 58 | /** 59 | * @brief closeAnimation 弹出窗消失时的动画效果 60 | */ 61 | void closeAnimation(); 62 | 63 | /** 64 | * @brief clearAll 清除弹出框消失时的动画并关闭窗体 65 | */ 66 | void clearAll(); 67 | 68 | /** 69 | * @brief showAnimation 弹出框显示时的动画效果 70 | */ 71 | void showAnimation(); 72 | 73 | /** 74 | * @brief animationValueChanged 属性值发生改变时的槽函数 75 | * @param param_value 76 | */ 77 | void animationValueChanged(QVariant param_value); 78 | 79 | private: 80 | 81 | /** 82 | * @brief desktop 窗体桌面信息 83 | */ 84 | QDesktopWidget desktop; 85 | 86 | 87 | /** 88 | * @brief animation 当前动画指针 89 | */ 90 | QPropertyAnimation* animation; 91 | 92 | /** 93 | * @brief remainTimer 出场动画和落场动画之间的时间间隔定时器(窗体停留时间) 94 | */ 95 | QTimer *remainTimer; 96 | 97 | 98 | /** 99 | * @brief mremainTime 动画效果持续的时间 100 | */ 101 | quint32 mremainTime; 102 | 103 | /** 104 | * @brief mIsPause 动画效果是否处于暂停 105 | */ 106 | bool mIsPause; 107 | }; 108 | 109 | #endif // NBASEPOPWIDGET_H 110 | -------------------------------------------------------------------------------- /NBaseUiKit/inc/nbaseqrencodewidget.h: -------------------------------------------------------------------------------- 1 | #ifndef NBASEQRENCODEWIDGET_H 2 | #define NBASEQRENCODEWIDGET_H 3 | 4 | /** 5 | * 作者: daodaoliang 6 | * 时间: 2016年8月15日 7 | * 邮箱: daodaoliang@yeah.net 8 | */ 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include "../3rdparty/qrencode/qrencode/qrencode.h" 16 | #include "nbaseuikit_global.h" 17 | 18 | /** 19 | * @brief The NBaseQREncodeWidget class 二维码生成组件 20 | */ 21 | class NBASEUIKITSHARED_EXPORT NBaseQREncodeWidget : public QWidget 22 | { 23 | Q_OBJECT 24 | 25 | public: 26 | explicit NBaseQREncodeWidget(QWidget *parent = 0); 27 | 28 | public: 29 | /** 30 | * @brief The QR_MODE enum 设置二维码的编码模式 31 | */ 32 | enum QR_MODE { 33 | MODE_NUL = QR_MODE_NUL, 34 | MODE_NUM = QR_MODE_NUM, 35 | MODE_AN = QR_MODE_AN, 36 | MODE_8 = QR_MODE_8, 37 | MODE_KANJI = QR_MODE_KANJI, 38 | MODE_STRUCTURE = QR_MODE_STRUCTURE, 39 | MODE_ECI = QR_MODE_ECI, 40 | MODE_FNC1FIRST = QR_MODE_FNC1FIRST, 41 | MODE_FNC1SECOND = QR_MODE_FNC1SECOND 42 | }; 43 | 44 | /** 45 | * @brief The QR_LEVEL enum 设置二维码编码的识别质量的级别 46 | */ 47 | enum QR_LEVEL { 48 | LEVEL_L = QR_ECLEVEL_L, 49 | LEVEL_M = QR_ECLEVEL_M, 50 | LEVEL_Q = QR_ECLEVEL_Q, 51 | LEVEL_H = QR_ECLEVEL_H 52 | }; 53 | 54 | public: 55 | /** 56 | * @brief getQrData 获取原始数据 57 | * @return 58 | */ 59 | QString getQrData() const; 60 | 61 | /** 62 | * @brief setQrData 设置原始数据 63 | * @param value 64 | */ 65 | void setQrData(const QString &value); 66 | 67 | /** 68 | * @brief getQrLogo 获取中间图标数据 69 | * @return 70 | */ 71 | QString getQrLogo() const; 72 | 73 | /** 74 | * @brief setQrLogo 设置中间图标 75 | * @param value 76 | */ 77 | void setQrLogo(const QString &value); 78 | 79 | /** 80 | * @brief getQrSize 获取二维码尺寸 81 | * @return 82 | */ 83 | QSize getQrSize() const; 84 | 85 | /** 86 | * @brief setQrSize 设置二维码尺寸 87 | * @param value 88 | */ 89 | void setQrSize(const QSize &value); 90 | 91 | /** 92 | * @brief getQrMode 获取二维码模式 93 | * @return 94 | */ 95 | QR_MODE getQrMode() const; 96 | 97 | /** 98 | * @brief setQrMode 设置二维码模式 99 | * @param value 100 | */ 101 | void setQrMode(const QR_MODE &value); 102 | 103 | /** 104 | * @brief getQrLevel 获取等级 105 | * @return 106 | */ 107 | QR_LEVEL getQrLevel() const; 108 | 109 | /** 110 | * @brief setQrLevel 设置等级 111 | * @param value 112 | */ 113 | void setQrLevel(const QR_LEVEL &value); 114 | 115 | bool getQrCasesen() const; 116 | void setQrCasesen(bool value); 117 | 118 | /** 119 | * @brief getQrMargin 获取边框 120 | * @return 121 | */ 122 | int getQrMargin() const; 123 | 124 | /** 125 | * @brief setQrMargin 设置边框 126 | * @param value 127 | */ 128 | void setQrMargin(int value); 129 | 130 | /** 131 | * @brief getQrPercent 获取Percent 132 | * @return 133 | */ 134 | qreal getQrPercent() const; 135 | 136 | /** 137 | * @brief setQrPercent 设置Percent 138 | * @param value 139 | */ 140 | void setQrPercent(const qreal &value); 141 | 142 | /** 143 | * @brief getQrForeground 获取前景色 144 | * @return 145 | */ 146 | QColor getQrForeground() const; 147 | 148 | /** 149 | * @brief setQrForeground 设置前景色 150 | * @param value 151 | */ 152 | void setQrForeground(const QColor &value); 153 | 154 | /** 155 | * @brief getQrBackground 获取背景色 156 | * @return 157 | */ 158 | QColor getQrBackground() const; 159 | 160 | /** 161 | * @brief setQrBackground设置背景色 162 | * @param value 163 | */ 164 | void setQrBackground(const QColor &value); 165 | 166 | /** 167 | * @brief getQrFilePath 获取文件路径 168 | * @return 169 | */ 170 | QString getQrFilePath() const; 171 | 172 | /** 173 | * @brief setQrFilePath 保存为文件 174 | * @param value 175 | */ 176 | void setQrFilePath(const QString &value); 177 | 178 | signals: 179 | void qrDataChanged(const QString& qrdata); 180 | void qrLogoChanged(const QString& qrlogo); 181 | void qrSizeChanged(const QSize& qrsize); 182 | void qrModeChanged(QR_MODE qrmodel); 183 | void qrLevelChanged(QR_LEVEL qrlevel); 184 | void qrCasesenChanged(bool qrcasesen); 185 | void qrMarginChanged(int qrmargin); 186 | void qrPercentChanged(qreal qrpercent); 187 | void qrForegroundChanged(const QColor& qrfg); 188 | void qrBackgroundChanged(const QColor& qrbg); 189 | void qrSaveFileChanged(const QString& qrfilepath); 190 | 191 | protected: 192 | /** 193 | * @brief paintEvent 绘制事件 194 | * @param e 195 | */ 196 | void paintEvent(QPaintEvent *e); 197 | 198 | /** 199 | * @brief resizeEvent 尺寸改变事件 200 | * @param e 201 | */ 202 | void resizeEvent(QResizeEvent *e); 203 | 204 | private: 205 | /** 206 | * @brief saveCurViewToFile 保存二维码到文件 207 | */ 208 | void saveCurViewToFile(); 209 | 210 | private: 211 | QString qrData; 212 | QString qrLogo; 213 | QSize qrSize; 214 | QR_MODE qrMode; 215 | QR_LEVEL qrLevel; 216 | bool qrCasesen; 217 | int qrMargin; 218 | qreal qrPercent; 219 | QColor qrForeground; 220 | QColor qrBackground; 221 | QString qrFilePath; 222 | }; 223 | 224 | #endif // NBASEQRENCODEWIDGET_H 225 | -------------------------------------------------------------------------------- /NBaseUiKit/inc/nbasereelwidget.h: -------------------------------------------------------------------------------- 1 | #ifndef NBASEREELWIDGET_H 2 | #define NBASEREELWIDGET_H 3 | 4 | /** 5 | * 作者: daodaoliang 6 | * 时间: 2016年9月06日 7 | * 邮箱: daodaoliang@yeah.net 8 | */ 9 | 10 | #include 11 | #include 12 | #include 13 | #include "nbasemoveablewidget.h" 14 | #include "nbaseuikit_global.h" 15 | 16 | /** 17 | * @brief The NBaseReelWidget class 卷轴widget 18 | */ 19 | class NBASEUIKITSHARED_EXPORT NBaseReelWidget : public NBaseMoveableWidget 20 | { 21 | Q_OBJECT 22 | public: 23 | explicit NBaseReelWidget(QWidget *parent = 0); 24 | /** 25 | * @brief setOriPos 设置起始位置 26 | * @param p 27 | */ 28 | void setOriPos(const QPoint& p); 29 | 30 | /** 31 | * @brief setOriSize 设置尺寸 32 | * @param s 33 | */ 34 | void setOriSize(const QSize& s); 35 | 36 | /** 37 | * @brief showExpan 以卷轴的方式打开 38 | */ 39 | void showExpan(); 40 | 41 | protected: 42 | /** 43 | * @brief paintEvent 绘制事件 44 | * @param event 45 | */ 46 | void paintEvent(QPaintEvent* event); 47 | 48 | private slots: 49 | /** 50 | * @brief onExpansion 展开的过程槽函数 51 | */ 52 | void onExpansion(); 53 | 54 | private: 55 | /** 56 | * @brief bFinally 是否 结束显示 57 | */ 58 | bool bFinally; 59 | 60 | /** 61 | * @brief oriPos 起始位置 62 | */ 63 | QPoint oriPos; 64 | 65 | /** 66 | * @brief oriSize 尺寸 67 | */ 68 | QSize oriSize; 69 | 70 | /** 71 | * @brief animaExpan 卷轴展开的动画时间线 72 | */ 73 | QTimeLine animaExpan; 74 | 75 | /** 76 | * @brief bgColorbegin 卷轴背景颜色渐变开始色 77 | */ 78 | QColor bgColorbegin; 79 | 80 | /** 81 | * @brief bgColorEnd 卷轴背景颜色渐变结束色 82 | */ 83 | QColor bgColorEnd; 84 | 85 | /** 86 | * @brief bgCorner 卷轴角落的阴影色 87 | */ 88 | QColor bgCorner; 89 | }; 90 | 91 | #endif // NBASEREELWIDGET_H 92 | -------------------------------------------------------------------------------- /NBaseUiKit/inc/nbaserotatingstackedwidget.h: -------------------------------------------------------------------------------- 1 | #ifndef NBASEROTATINGSTACKEDWIDGET_H 2 | #define NBASEROTATINGSTACKEDWIDGET_H 3 | 4 | /** 5 | * 作者: daodaoliang 6 | * 时间: 2016年8月10日 7 | * 邮箱: daodaoliang@yeah.net 8 | */ 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include "nbaseuikit_global.h" 20 | 21 | /** 22 | * @brief The NBaseRotatingStackedWidget class 反转的stacked 23 | */ 24 | class NBASEUIKITSHARED_EXPORT NBaseRotatingStackedWidget : public QStackedWidget 25 | { 26 | Q_OBJECT 27 | Q_PROPERTY( float rotateVal READ rotateVal WRITE setRotateVal) 28 | public: 29 | /** 30 | * @brief NBaseRotatingStackedWidget 构造函数 31 | * @param parent 32 | */ 33 | explicit NBaseRotatingStackedWidget(QWidget *parent = 0); 34 | 35 | /** 36 | * @brief paintEvent 绘制事件 37 | */ 38 | void paintEvent(QPaintEvent *event); 39 | 40 | public slots: 41 | /** 42 | * @brief nextPage 下一页 43 | */ 44 | void nextPage(); 45 | 46 | public: 47 | 48 | /** 49 | * @brief rotate index 跳转到索引页 50 | */ 51 | void rotate(int index); 52 | 53 | /** 54 | * @brief rotateVal 旋转值 55 | * @return 56 | */ 57 | float rotateVal(); 58 | 59 | /** 60 | * @brief setRotateVal 设置旋转值 61 | * @param fl 值 62 | */ 63 | void setRotateVal(float fl); 64 | 65 | private slots: 66 | /** 67 | * @brief valChanged 旋转值改变了 68 | */ 69 | void valChanged(QVariant); 70 | 71 | /** 72 | * @brief animDone 动画结束 73 | */ 74 | void animDone(); 75 | 76 | private: 77 | /** 78 | * @brief iRotateVal 旋转值 79 | */ 80 | float iRotateVal; 81 | 82 | /** 83 | * @brief isAnimating 旋转动画中 84 | */ 85 | bool isAnimating; 86 | 87 | /** 88 | * @brief nextIndex 下一个索引页 89 | */ 90 | int nextIndex; 91 | }; 92 | 93 | #endif // NBASEROTATINGSTACKEDWIDGET_H 94 | -------------------------------------------------------------------------------- /NBaseUiKit/inc/nbaseroundprogressbar.h: -------------------------------------------------------------------------------- 1 | #ifndef NBASEROUNDPROGRESSBAR_H 2 | #define NBASEROUNDPROGRESSBAR_H 3 | 4 | /** 5 | * 作者: daodaoliang 6 | * 时间: 2016年8月16日 7 | * 邮箱: daodaoliang@yeah.net 8 | */ 9 | 10 | #include 11 | #include 12 | #include 13 | #include "nbaseuikit_global.h" 14 | 15 | /** 16 | * @brief The NBaseRoundProgressBar class 圆形进度条 17 | */ 18 | class NBASEUIKITSHARED_EXPORT NBaseRoundProgressBar : public QWidget 19 | { 20 | Q_OBJECT 21 | public: 22 | explicit NBaseRoundProgressBar(QWidget *parent = 0); 23 | 24 | static const int PositionLeft = 180; 25 | static const int PositionTop = 90; 26 | static const int PositionRight = 0; 27 | static const int PositionBottom = -90; 28 | 29 | enum BarStyle 30 | { 31 | // 甜甜圈风格 32 | StyleDonut, 33 | // 圆饼风格 34 | StylePie, 35 | // 线风格 36 | StyleLine 37 | }; 38 | public: 39 | double nullPosition() const; 40 | void setNullPosition(double position); 41 | 42 | void setBarStyle(BarStyle style); 43 | BarStyle barStyle() const; 44 | 45 | void setOutlinePenWidth(double penWidth); 46 | double outlinePenWidth() const; 47 | 48 | void setDataPenWidth(double penWidth); 49 | double dataPenWidth() const; 50 | 51 | void setDataColors(const QGradientStops& stopPoints); 52 | 53 | void setFormat(const QString& format); 54 | void resetFormat(); 55 | QString format() const; 56 | 57 | void setDecimals(int count); 58 | int decimals() const; 59 | 60 | double value() const; 61 | 62 | double minimum() const; 63 | 64 | double maximum() const; 65 | 66 | public slots: 67 | void setRange(double min, double max); 68 | void setMinimum(double min); 69 | void setMaximum(double max); 70 | void setValue(double val); 71 | void setValue(int val); 72 | 73 | protected: 74 | virtual void paintEvent(QPaintEvent *event); 75 | virtual void drawBackground(QPainter& p, const QRectF& baseRect); 76 | virtual void drawBase(QPainter& p, const QRectF& baseRect); 77 | virtual void drawValue(QPainter& p, const QRectF& baseRect, double value, double arcLength); 78 | virtual void calculateInnerRect(const QRectF& baseRect, double outerRadius, QRectF& innerRect, double& innerRadius); 79 | virtual void drawInnerBackground(QPainter& p, const QRectF& innerRect); 80 | virtual void drawText(QPainter& p, const QRectF& innerRect, double innerRadius, double value); 81 | virtual QString valueToText(double value) const; 82 | virtual void valueFormatChanged(); 83 | virtual QSize minimumSizeHint() const { return QSize(32,32); } 84 | virtual bool hasHeightForWidth() const { return true; } 85 | virtual int heightForWidth(int w) const { return w; } 86 | void rebuildDataBrushIfNeeded(); 87 | 88 | protected: 89 | double m_min, m_max; 90 | double m_value; 91 | double m_nullPosition; 92 | BarStyle m_barStyle; 93 | double m_outlinePenWidth, m_dataPenWidth; 94 | QGradientStops m_gradientData; 95 | bool m_rebuildBrush; 96 | QString m_format; 97 | int m_decimals; 98 | static const int UF_VALUE = 1; 99 | static const int UF_PERCENT = 2; 100 | static const int UF_MAX = 4; 101 | int m_updateFlags; 102 | }; 103 | 104 | #endif // NBASEROUNDPROGRESSBAR_H 105 | -------------------------------------------------------------------------------- /NBaseUiKit/inc/nbaseshadowlabel.h: -------------------------------------------------------------------------------- 1 | #ifndef NBASESHADOWLABEL_H 2 | #define NBASESHADOWLABEL_H 3 | 4 | /** 5 | * 作者: daodaoliang 6 | * 时间: 2016年8月18日 7 | * 邮箱: daodaoliang@yeah.net 8 | */ 9 | 10 | #include 11 | #include 12 | #include "nbaseuikit_global.h" 13 | 14 | /** 15 | * @brief The NBaseShadowLabel class 文字阴影的label 16 | */ 17 | class NBASEUIKITSHARED_EXPORT NBaseShadowLabel : public QLabel 18 | { 19 | Q_OBJECT 20 | public: 21 | explicit NBaseShadowLabel(QLabel *parent = 0); 22 | explicit NBaseShadowLabel(const QString &text, QLabel *parent = 0); 23 | }; 24 | 25 | #endif // NBASESHADOWLABEL_H 26 | -------------------------------------------------------------------------------- /NBaseUiKit/inc/nbaseshadowwidget.h: -------------------------------------------------------------------------------- 1 | #ifndef NBASESHOWDOWWIDGET_H 2 | #define NBASESHOWDOWWIDGET_H 3 | 4 | /** 5 | * 作者: daodaoliang 6 | * 时间: 2016年8月10日 7 | * 邮箱: daodaoliang@yeah.net 8 | */ 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include "nbaseuikit_global.h" 16 | #include "nbasemoveablewidget.h" 17 | 18 | /** 19 | * @brief The NBaseShowdowWidget class 阴影widget基类 20 | */ 21 | class NBASEUIKITSHARED_EXPORT NBaseShadowWidget : public NBaseMoveableWidget 22 | { 23 | Q_OBJECT 24 | public: 25 | /** 26 | * @brief NBaseShowdowWidget 构造函数 27 | * @param parent 28 | */ 29 | explicit NBaseShadowWidget(NBaseMoveableWidget *parent = 0); 30 | 31 | protected: 32 | /** 33 | * @brief changeEvent 改变事件处理函数 34 | * @param event 35 | */ 36 | void changeEvent(QEvent *event); 37 | 38 | /** 39 | * @brief paintEvent 绘制事件处理函数 40 | * @param e 41 | */ 42 | void paintEvent(QPaintEvent *e); 43 | 44 | private: 45 | /** 46 | * @brief drawShadowPlanA 阴影绘制方案A 47 | */ 48 | void drawShadowPlanA(); 49 | 50 | /** 51 | * @brief drawShadowPlanB 阴影绘制方案B 52 | */ 53 | void drawShadowPlanB(); 54 | 55 | private: 56 | QPixmap m_shadow; 57 | }; 58 | 59 | #endif // NBASESHOWDOWWIDGET_H 60 | -------------------------------------------------------------------------------- /NBaseUiKit/inc/nbasesnowlabel.h: -------------------------------------------------------------------------------- 1 | #ifndef NBASESNOWLABEL_H 2 | #define NBASESNOWLABEL_H 3 | 4 | /** 5 | * 作者: daodaoliang 6 | * 时间: 2016年8月10日 7 | * 邮箱: daodaoliang@yeah.net 8 | */ 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include "nbaseuikit_global.h" 16 | 17 | /** 18 | * @brief The NBaseSnowLabel class Label前面加红色星号 19 | */ 20 | class NBASEUIKITSHARED_EXPORT NBaseSnowLabel : public QLabel 21 | { 22 | Q_OBJECT 23 | public: 24 | explicit NBaseSnowLabel(QWidget *parent = 0); 25 | 26 | protected: 27 | void paintEvent(QPaintEvent *event); 28 | }; 29 | 30 | #endif // NBASESNOWLABEL_H 31 | -------------------------------------------------------------------------------- /NBaseUiKit/inc/nbaseswitchbutton.h: -------------------------------------------------------------------------------- 1 | #ifndef NBASESWITCHBUTTON_H 2 | #define NBASESWITCHBUTTON_H 3 | 4 | /** 5 | * 作者: daodaoliang 6 | * 时间: 2016年9月05日 7 | * 邮箱: daodaoliang@yeah.net 8 | */ 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include "nbaseuikit_global.h" 15 | 16 | /** 17 | * @brief The NBaseSwitchButton class switch button 18 | */ 19 | class NBASEUIKITSHARED_EXPORT NBaseSwitchButton : public QWidget 20 | { 21 | Q_OBJECT 22 | public: 23 | explicit NBaseSwitchButton(QWidget *parent = 0); 24 | 25 | protected: 26 | void mousePressEvent(QMouseEvent *event); 27 | void mouseMoveEvent(QMouseEvent *event); 28 | void mouseReleaseEvent(QMouseEvent *event); 29 | void paintEvent(QPaintEvent *event); 30 | 31 | private: 32 | void drawPressBackground(QPainter *painter); 33 | void drawPressSlide(QPainter *painter); 34 | 35 | private: 36 | QColor mOffBgcBegin; 37 | QColor mOffBgcEnd; 38 | QColor mOnBgcBegin; 39 | QColor mOnBgcEnd; 40 | QColor mSlideONCBegin; 41 | QColor mSlideONCEnd; 42 | QColor mSlidOFFCBegin; 43 | QColor mSlidOFFCEnd; 44 | bool mState; 45 | bool mMouseDown; 46 | bool mMouseMove; 47 | bool mMouseUp; 48 | QPoint firstPoint; 49 | QPoint lastPoint; 50 | }; 51 | 52 | #endif // NBASESWITCHBUTTON_H 53 | -------------------------------------------------------------------------------- /NBaseUiKit/inc/nbasetoastr.h: -------------------------------------------------------------------------------- 1 | #ifndef NBASETOASTR_H 2 | #define NBASETOASTR_H 3 | 4 | /** 5 | * 作者: daodaoliang 6 | * 时间: 2016年8月16日 7 | * 邮箱: daodaoliang@yeah.net 8 | */ 9 | 10 | #include 11 | #include 12 | #include "nbaseuikit_global.h" 13 | 14 | #define DEFULT_TOAST_STYLE "\ 15 | QLabel{\ 16 | color:#FFFFFF;\ 17 | font:18px;\ 18 | font-weight:500;\ 19 | background-color:rgb(98,92,82,90);\ 20 | padding:3px;\ 21 | border-radius:2;\ 22 | }\ 23 | " 24 | 25 | /** 26 | * @brief The NBaseToastr class 自动消失的提示框 27 | */ 28 | class NBASEUIKITSHARED_EXPORT NBaseToastr : public QLabel 29 | { 30 | Q_OBJECT 31 | public: 32 | explicit NBaseToastr(QWidget *parent, 33 | const QString &message = QString(), 34 | int w = 200, 35 | int h = 50, 36 | const QString &style = DEFULT_TOAST_STYLE); 37 | void toastr(); 38 | 39 | private: 40 | /** 41 | * @brief setShadow 设置窗体阴影效果 42 | * @param w 窗体指针 43 | * @param blurRadius 阴影清晰度,越小越清晰 44 | * @param dx x方向阴影位置和偏移量,正值在右方,值越大偏移越大 45 | * @param dy y方向阴影位置和偏移量,正值在下方,值越大偏移越大 46 | * @return 47 | */ 48 | void setShadow(QWidget *w, qreal blurRadius=10, qreal dx=5, qreal dy=5); 49 | 50 | private slots: 51 | void animationFinished(); 52 | void delSelf(); 53 | 54 | private: 55 | int startx; 56 | int starty; 57 | int endy; 58 | }; 59 | 60 | #endif // NBASETOASTR_H 61 | -------------------------------------------------------------------------------- /NBaseUiKit/inc/nbasetoolbutton.h: -------------------------------------------------------------------------------- 1 | #ifndef NBASETOOLBUTTON_H 2 | #define NBASETOOLBUTTON_H 3 | 4 | /** 5 | * 作者: daodaoliang 6 | * 时间: 2016年9月06日 7 | * 邮箱: daodaoliang@yeah.net 8 | */ 9 | 10 | #include 11 | #include 12 | #include 13 | #include "nbaseuikit_global.h" 14 | 15 | class NBASEUIKITSHARED_EXPORT NBaseToolButton : public QWidget 16 | { 17 | Q_OBJECT 18 | public: 19 | explicit NBaseToolButton(QWidget *parent = 0); 20 | 21 | void setShowToolButton(); 22 | void setHideToolButton(); 23 | 24 | public: 25 | QToolButton *minButton; 26 | QToolButton *closeButton; 27 | }; 28 | 29 | #endif // NBASETOOLBUTTON_H 30 | -------------------------------------------------------------------------------- /NBaseUiKit/inc/nbaseuikit_global.h: -------------------------------------------------------------------------------- 1 | #ifndef NBASEUIKIT_GLOBAL_H 2 | #define NBASEUIKIT_GLOBAL_H 3 | 4 | #include 5 | 6 | #if defined(NBASEUIKIT_LIBRARY) 7 | # define NBASEUIKITSHARED_EXPORT Q_DECL_EXPORT 8 | #else 9 | # define NBASEUIKITSHARED_EXPORT Q_DECL_IMPORT 10 | #endif 11 | 12 | #endif // NBASEUIKIT_GLOBAL_H 13 | -------------------------------------------------------------------------------- /NBaseUiKit/inc/nbasewaitdialog.h: -------------------------------------------------------------------------------- 1 | #ifndef NBASEWAITDIALOG_H 2 | #define NBASEWAITDIALOG_H 3 | 4 | /** 5 | * 作者: daodaoliang 6 | * 时间: 2016年8月16日 7 | * 邮箱: daodaoliang@yeah.net 8 | */ 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include "nbaseshadowwidget.h" 16 | #include "nbaseuikit_global.h" 17 | 18 | /** 19 | * @brief The NBaseWaitDialog class 等待框 20 | */ 21 | class NBASEUIKITSHARED_EXPORT NBaseWaitDialog : public NBaseShadowWidget 22 | { 23 | Q_OBJECT 24 | 25 | public: 26 | enum WaitStyle{ 27 | // box 风格 28 | BOXSTYLE, 29 | // android 风格 30 | ANDROIDSTYLE 31 | }; 32 | 33 | public: 34 | explicit NBaseWaitDialog(QWidget * parent = NULL, WaitStyle paramStyle=BOXSTYLE); 35 | ~NBaseWaitDialog(){} 36 | 37 | public slots: 38 | /** 39 | * @brief showWaitDialog 显示等待框 40 | * @return 41 | */ 42 | bool showWaitDialog(); 43 | 44 | /** 45 | * @brief closeWaitDialog 关闭等待框 46 | * @param flag 47 | */ 48 | void closeWaitDialog(); 49 | 50 | protected: 51 | /** 52 | * @brief closeEvent 关闭事件 53 | * @param event 54 | */ 55 | void closeEvent(QCloseEvent *event); 56 | 57 | /** 58 | * @brief paintEvent 绘制事件 59 | * @param event 60 | */ 61 | void paintEvent(QPaintEvent *event); 62 | 63 | /** 64 | * @brief moveEvent 移动事件 65 | * @param event 66 | */ 67 | void moveEvent(QMoveEvent *event); 68 | 69 | private: 70 | /** 71 | * @brief setBoxStyle 盒子风格的等待框 72 | */ 73 | void setBoxStyle(); 74 | 75 | /** 76 | * @brief setAndroidStyle android 风格的等待框 77 | */ 78 | void setAndroidStyle(); 79 | private: 80 | QWidget *parentObj; 81 | bool isShow; 82 | }; 83 | 84 | #endif // NBASEWAITDIALOG_H 85 | -------------------------------------------------------------------------------- /NBaseUiKit/inc/ntouchlistview.h: -------------------------------------------------------------------------------- 1 | #ifndef NTOUCHLISTVIEW_H 2 | #define NTOUCHLISTVIEW_H 3 | 4 | /** 5 | * 作者: daodaoliang 6 | * 时间: 2016年9月06日 7 | * 邮箱: daodaoliang@yeah.net 8 | */ 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include "nbasetoastr.h" 15 | #include "nbaseuikit_global.h" 16 | 17 | /** 18 | * @brief The NTouchListView class 类似触屏的滑动效果的ListView 19 | */ 20 | class NBASEUIKITSHARED_EXPORT NTouchListView : public QListView 21 | { 22 | Q_OBJECT 23 | public: 24 | explicit NTouchListView(QWidget *parent = 0); 25 | 26 | protected: 27 | void mousePressEvent(QMouseEvent *event); 28 | void mouseMoveEvent(QMouseEvent *event); 29 | void mouseReleaseEvent(QMouseEvent *event); 30 | 31 | private: 32 | int originPosY; 33 | int originPosX; 34 | bool isMoved; 35 | }; 36 | 37 | #endif // NTOUCHLISTVIEW_H 38 | -------------------------------------------------------------------------------- /NBaseUiKit/inc/ntouchlistwidget.h: -------------------------------------------------------------------------------- 1 | #ifndef NTOUCHLISTVIEW_H 2 | #define NTOUCHLISTVIEW_H 3 | 4 | /** 5 | * 作者: daodaoliang 6 | * 时间: 2016年8月29日 7 | * 邮箱: daodaoliang@yeah.net 8 | */ 9 | 10 | #include 11 | #include 12 | #include 13 | #include "nbaseuikit_global.h" 14 | 15 | /** 16 | * @brief The NTouchListWidget class 类似触屏的滑动效果的ListWidget 17 | */ 18 | class NBASEUIKITSHARED_EXPORT NTouchListWidget : public QListWidget 19 | { 20 | Q_OBJECT 21 | public: 22 | explicit NTouchListWidget(QWidget *parent = 0); 23 | 24 | protected: 25 | void mousePressEvent(QMouseEvent *event); 26 | void mouseMoveEvent(QMouseEvent *event); 27 | void mouseReleaseEvent(QMouseEvent *event); 28 | 29 | private: 30 | int originPosY; 31 | int originPosX; 32 | bool isMoved; 33 | }; 34 | 35 | #endif // NTOUCHLISTVIEW_H 36 | -------------------------------------------------------------------------------- /NBaseUiKit/src/nbasecircleanimationwidget.cpp: -------------------------------------------------------------------------------- 1 | #include "nbasecircleanimationwidget.h" 2 | 3 | NBaseCircleAnimationWidget::NBaseCircleAnimationWidget(NBaseMoveableWidget *parent) : NBaseMoveableWidget(parent) 4 | { 5 | this->setAttribute(Qt::WA_TranslucentBackground); 6 | } 7 | 8 | NBaseCircleAnimationWidget::NBaseCircleAnimationWidget(const QString &icon, const qreal &radius, NBaseMoveableWidget *parent) 9 | { 10 | this->setAttribute(Qt::WA_TranslucentBackground); 11 | this->setCircleInfo(icon, radius); 12 | Q_UNUSED(parent) 13 | } 14 | 15 | void NBaseCircleAnimationWidget::setCircleInfo(const QString &icon, const qreal &radius) 16 | { 17 | m_pix.load(icon); 18 | m_percent = 0; 19 | m_radius = radius; 20 | int pixW = m_pix.width(); 21 | int pixH = m_pix.height(); 22 | m_centerPos.setX(radius); 23 | m_centerPos.setY(radius); 24 | m_originPoint.setX(radius*2); 25 | m_originPoint.setY(radius); 26 | m_point = m_originPoint; 27 | this->setFixedSize(pixW + radius*2, pixH + radius*2); 28 | this->initAnimation(); 29 | } 30 | 31 | void NBaseCircleAnimationWidget::startAnimation() 32 | { 33 | m_percentAnimation->start(); 34 | } 35 | 36 | void NBaseCircleAnimationWidget::stopAnimation() 37 | { 38 | m_percentAnimation->stop(); 39 | m_point = m_originPoint; 40 | m_percent = 0; 41 | update(); 42 | } 43 | 44 | void NBaseCircleAnimationWidget::setPercent(const qreal &per) 45 | { 46 | m_percent = per; 47 | updatePos(); 48 | } 49 | 50 | const qreal &NBaseCircleAnimationWidget::percent(){return m_percent;} 51 | 52 | void NBaseCircleAnimationWidget::paintEvent(QPaintEvent *) 53 | { 54 | QPainter painter(this); 55 | painter.drawPixmap(m_point, m_pix); 56 | } 57 | 58 | void NBaseCircleAnimationWidget::updatePos() 59 | { 60 | m_point = mathPoint(); 61 | update(); 62 | } 63 | 64 | QPoint NBaseCircleAnimationWidget::mathPoint() 65 | { 66 | return this->mathPoint(m_centerPos, m_percent, m_radius); 67 | } 68 | 69 | QPoint NBaseCircleAnimationWidget::mathPoint(const QPoint ¢erPos, const qreal &percent, const qreal &radius) 70 | { 71 | qreal dx = radius * qCos(percent * ( 2 * PI)) + centerPos.x();//计算x坐标 72 | qreal dy = radius * qSin(percent * ( 2 * PI)) + centerPos.y(); // 计算y坐标 73 | return QPoint(dx, dy); 74 | } 75 | 76 | void NBaseCircleAnimationWidget::initAnimation() 77 | { 78 | m_percentAnimation = new QPropertyAnimation(this, "percent"); 79 | m_percentAnimation->setDuration(250); 80 | m_percentAnimation->setStartValue(0.0); 81 | m_percentAnimation->setEndValue(1.0); 82 | m_percentAnimation->setLoopCount(-1); //无限循环,只有调用stop才会停止 83 | } 84 | -------------------------------------------------------------------------------- /NBaseUiKit/src/nbaseclickwave.cpp: -------------------------------------------------------------------------------- 1 | #include "nbaseclickwave.h" 2 | #include 3 | #include 4 | #include 5 | 6 | NBaseClickWave::NBaseClickWave(QWidget *parent) 7 | : QPushButton(parent) 8 | ,pointX(0) 9 | ,pointY(0) 10 | ,waveRadius(0) 11 | { 12 | setClickColor(QColor(Qt::lightGray)); 13 | } 14 | 15 | void NBaseClickWave::paintEvent(QPaintEvent *event) 16 | { 17 | if(waveRadius<(width()>height()?width():height())*2){ 18 | // 主圆圈 19 | QPainter tempPainter; 20 | tempPainter.begin(this); 21 | QBrush tempBrush; 22 | tempBrush.setStyle(Qt::SolidPattern); 23 | tempBrush.setColor(getClickColor()); 24 | tempPainter.setBrush(tempBrush); 25 | QPen tempPen; 26 | tempPen.setColor(getClickColor()); 27 | tempPen.setJoinStyle(Qt::RoundJoin); 28 | tempPen.setCapStyle(Qt::FlatCap); 29 | tempPainter.setPen(tempPen); 30 | tempPainter.setRenderHint(QPainter::HighQualityAntialiasing); 31 | tempPainter.setOpacity(0.7); 32 | QRectF rectangle(pointX-waveRadius/2, pointY-waveRadius/2, waveRadius, waveRadius); 33 | tempPainter.drawEllipse(rectangle); 34 | tempPainter.end(); 35 | } 36 | QWidget::paintEvent(event); 37 | } 38 | 39 | void NBaseClickWave::mousePressEvent(QMouseEvent *event) 40 | { 41 | pointX = event->x(); 42 | pointY = event->y(); 43 | QPropertyAnimation *animation = new QPropertyAnimation(this, "waveRadius"); 44 | animation->setDuration(400); 45 | animation->setStartValue(0); 46 | animation->setEndValue((width()>height()?width():height())*2); 47 | animation->start(); 48 | } 49 | 50 | QColor NBaseClickWave::getClickColor() const 51 | { 52 | return clickColor; 53 | } 54 | 55 | void NBaseClickWave::setClickColor(const QColor &value) 56 | { 57 | clickColor = value; 58 | } 59 | 60 | qreal NBaseClickWave::getWaveRadius() const 61 | { 62 | return waveRadius; 63 | } 64 | 65 | void NBaseClickWave::setWaveRadius(const qreal &value) 66 | { 67 | waveRadius = value; 68 | emit waveRadiusChanged(value); 69 | update(); 70 | } 71 | -------------------------------------------------------------------------------- /NBaseUiKit/src/nbasecountdown.cpp: -------------------------------------------------------------------------------- 1 | #include "nbasecountdown.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | NBaseCountDown::NBaseCountDown(QWidget *parent, int paramCountDown, bool isfill) 8 | : NBaseMoveableWidget(parent), 9 | pointX(0), 10 | pointY(0), 11 | waveRadius(0), 12 | timerId(0), 13 | countDown(paramCountDown), 14 | isFill(isfill) 15 | { 16 | setWindowFlags(Qt::FramelessWindowHint|Qt::WindowStaysOnTopHint|Qt::SplashScreen); 17 | setAttribute(Qt::WA_TranslucentBackground); 18 | innerAnima = NULL; 19 | isFlag = true; 20 | coreRadius = 100; 21 | changeStep = paramCountDown; 22 | // 背景波纹默认是绿色 23 | backColor.setRgb(0, 245, 0); 24 | // 核心圆开始颜色 25 | coreColorBegin.setRgb(0, 245, 0); 26 | // 核心圆中间颜色 27 | coreColorMid.setRgb(0, 210, 0); 28 | // 核心圆结束颜色 29 | coreColorEnd.setRgb(0, 140, 0); 30 | } 31 | 32 | void NBaseCountDown::startCountDown() 33 | { 34 | show(); 35 | timerId = startTimer(1000); 36 | } 37 | 38 | void NBaseCountDown::stopCountDown() 39 | { 40 | close(); 41 | } 42 | 43 | qreal NBaseCountDown::getWaveRadius() const 44 | { 45 | return waveRadius; 46 | } 47 | 48 | void NBaseCountDown::setWaveRadius(const qreal &value) 49 | { 50 | waveRadius = value; 51 | emit signalWaveRadius(value); 52 | update(); 53 | } 54 | 55 | void NBaseCountDown::paintEvent(QPaintEvent *event) 56 | { 57 | // 波纹 58 | QPainter tempPainter; 59 | tempPainter.begin(this); 60 | tempPainter.setRenderHint(QPainter::Antialiasing); 61 | QRadialGradient wavwRg(0, 0, waveRadius-4); 62 | wavwRg.setColorAt(0, backColor); 63 | QBrush tempBrush(wavwRg); 64 | tempPainter.setBrush(tempBrush); 65 | tempPainter.setPen(Qt::NoPen); 66 | tempPainter.setOpacity(0.4); 67 | QRectF rectangle(pointX-waveRadius/2, pointY-waveRadius/2, waveRadius, waveRadius); 68 | tempPainter.drawEllipse(rectangle); 69 | tempPainter.end(); 70 | 71 | // 圆形内核 72 | coreRadius = 65; 73 | QPainter painter(this); 74 | painter.translate(width() / 2, height() / 2); 75 | painter.setRenderHint(QPainter::Antialiasing); 76 | painter.setPen(Qt::transparent); 77 | 78 | // 外边框 79 | QLinearGradient lg1(0, -coreRadius, 0, coreRadius); 80 | lg1.setColorAt(0, QColor(255, 255, 255)); 81 | lg1.setColorAt(1, QColor(166, 166, 166)); 82 | painter.setBrush(lg1); 83 | painter.drawEllipse(-coreRadius, -coreRadius, coreRadius << 1, coreRadius << 1); 84 | 85 | // 内边框 86 | coreRadius -= 13; 87 | QLinearGradient lg2(0, -coreRadius, 0, coreRadius); 88 | lg2.setColorAt(0, QColor(155, 155, 155)); 89 | lg2.setColorAt(1, QColor(255, 255, 255)); 90 | painter.setBrush(lg2); 91 | painter.drawEllipse(-coreRadius, -coreRadius, coreRadius << 1, coreRadius << 1); 92 | 93 | // 内部的圆 94 | coreRadius -= 4; 95 | QRadialGradient rg(0, 0, coreRadius); 96 | // begin 97 | rg.setColorAt(0, coreColorBegin); 98 | // mid 99 | rg.setColorAt(0.6, coreColorMid); 100 | // end 101 | rg.setColorAt(1, coreColorEnd); 102 | painter.setBrush(rg); 103 | painter.setOpacity(0.3); 104 | painter.drawEllipse(-coreRadius, -coreRadius, coreRadius << 1, coreRadius << 1); 105 | 106 | // 高光 107 | coreRadius -= 3; 108 | QPainterPath path; 109 | path.addEllipse(-coreRadius, -coreRadius - 2, coreRadius << 1, coreRadius << 1); 110 | QPainterPath bigEllipse; 111 | coreRadius *= 2; 112 | bigEllipse.addEllipse(-coreRadius, -coreRadius + 140, coreRadius << 1, coreRadius << 1); 113 | path -= bigEllipse; 114 | painter.drawPath(path); 115 | 116 | // 文字 117 | QPainter textPainter(this); 118 | textPainter.setFont(QFont("微软雅黑",30,QFont::Bold)); 119 | QPen tempPen; 120 | tempPen.setColor(QColor("#625c52")); 121 | textPainter.setPen(tempPen); 122 | textPainter.translate(width() / 2, height() / 2); 123 | textPainter.drawText(QRectF(-50,-50,100,100),Qt::AlignCenter,QString::number(countDown)); 124 | NBaseMoveableWidget::paintEvent(event); 125 | } 126 | 127 | void NBaseCountDown::timerEvent(QTimerEvent *event) 128 | { 129 | if(event->timerId() == timerId){ 130 | innerAnimation(isFlag); 131 | isFlag = !isFlag; 132 | } 133 | } 134 | 135 | void NBaseCountDown::closeEvent(QCloseEvent *event) 136 | { 137 | killTimer(timerId); 138 | NBaseMoveableWidget::closeEvent(event); 139 | } 140 | 141 | void NBaseCountDown::innerAnimation(bool isPositive) 142 | { 143 | pointX = width()/2; 144 | pointY = height()/2; 145 | if(!innerAnima){ 146 | innerAnima = new QPropertyAnimation(this, "waveRadius"); 147 | } 148 | innerAnima->setDuration(800); 149 | if(isPositive){ 150 | innerAnima->setStartValue(0); 151 | if(isFill){ 152 | innerAnima->setEndValue((width()>height()?width():height())*2); 153 | }else { 154 | innerAnima->setEndValue((width()>height()?height():width())); 155 | } 156 | } else { 157 | if(isFill){ 158 | innerAnima->setStartValue((width()>height()?width():height())*2); 159 | } else { 160 | innerAnima->setStartValue((width()>height()?height():width())); 161 | } 162 | innerAnima->setEndValue(0); 163 | } 164 | innerAnima->start(); 165 | setCountDown(countDown--); 166 | } 167 | 168 | int NBaseCountDown::getCountDown() const 169 | { 170 | return countDown; 171 | } 172 | 173 | void NBaseCountDown::setCountDown(int value) 174 | { 175 | countDown = value; 176 | // 波纹颜色改变 177 | int tempWavwRed = backColor.red() + 255/changeStep; 178 | backColor.setRed(tempWavwRed<255?tempWavwRed:255); 179 | int tempWaveGreen = backColor.green() - 244/changeStep; 180 | backColor.setGreen(tempWaveGreen<0?0:tempWaveGreen); 181 | // 核心圆颜色改变 182 | int tempRed = coreColorBegin.red() + 245/changeStep; 183 | coreColorBegin.setRed(tempRed<245?tempRed:245); 184 | int tempGreen = coreColorBegin.green() - 245/changeStep; 185 | coreColorBegin.setGreen(tempGreen<0?0:tempGreen); 186 | tempRed = coreColorMid.red() + 210/changeStep; 187 | coreColorMid.setRed(tempRed<210?tempRed:210); 188 | tempGreen = coreColorMid.green() - 210/changeStep; 189 | coreColorMid.setGreen(tempGreen<0?0:tempGreen); 190 | tempRed = coreColorEnd.red() + 140/changeStep; 191 | coreColorEnd.setRed(tempRed<140?tempRed:140); 192 | tempGreen = coreColorEnd.green() - 140/changeStep; 193 | coreColorEnd.setGreen(tempGreen<0?0:tempGreen); 194 | if(countDown-- <= 0){ 195 | emit signalCountFinshed(); 196 | close(); 197 | } 198 | } 199 | -------------------------------------------------------------------------------- /NBaseUiKit/src/nbasefadewidget.cpp: -------------------------------------------------------------------------------- 1 | #include "nbasefadewidget.h" 2 | 3 | NBaseFadeWidget::NBaseFadeWidget(NBaseMoveableWidget *parent) : NBaseMoveableWidget(parent) 4 | { 5 | setWindowFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint); 6 | show_animation_ = new QPropertyAnimation(this,"opacity"); 7 | } 8 | 9 | void NBaseFadeWidget::beginFadeShow(quint32 param_seconds) 10 | { 11 | show_animation_->setDuration(param_seconds * 1000); 12 | show_animation_->setStartValue(0); 13 | show(); 14 | show_animation_->setEndValue(1); 15 | show_animation_->start(); 16 | } 17 | 18 | void NBaseFadeWidget::setopacity(qreal param_opacity) 19 | { 20 | opacity_ = param_opacity; 21 | this->setWindowOpacity(param_opacity); 22 | update(); 23 | emit opacityChanged(param_opacity); 24 | } 25 | 26 | qreal NBaseFadeWidget::getopacity() 27 | { 28 | return opacity_; 29 | } 30 | -------------------------------------------------------------------------------- /NBaseUiKit/src/nbaseimagecropper.cpp: -------------------------------------------------------------------------------- 1 | #include "nbaseimagecropper.h" 2 | #include "imagecropper.h" 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | /** 9 | * @brief imageInstance 图片截取 10 | */ 11 | 12 | class NBaseImageCropper_p{ 13 | public: 14 | NBaseImageCropper_p(); 15 | 16 | public: 17 | ImageCropper *imageInstance; 18 | }; 19 | 20 | NBaseImageCropper::NBaseImageCropper(QWidget *parent, bool isCropBtn, bool isToolBtn) 21 | :QWidget(parent) 22 | { 23 | imageInstance = new NBaseImageCropper_p(); 24 | imageInstance->imageInstance = new ImageCropper; 25 | // 风格设置 26 | setCropStyle(QColor(98,92,82), QColor(231,105,63)); 27 | // 窗体属性 28 | setWindowFlags(Qt::FramelessWindowHint|Qt::WindowStaysOnTopHint); 29 | setAttribute(Qt::WA_TranslucentBackground); 30 | setWindowModality(Qt::WindowModal); 31 | // 标识设置 32 | shortCut = nullptr; 33 | showConfirmBtn = isCropBtn; 34 | showToolBtn = isToolBtn; 35 | isFTFixed = false; 36 | isOOFixed = false; 37 | // 工具布局 38 | QGridLayout *tempLayout = new QGridLayout; 39 | // 主区域 40 | tempLayout->addWidget(imageInstance->imageInstance,1,1,5,5); 41 | // 截取并上传按钮 42 | if(showConfirmBtn) { 43 | cropBtn = new QPushButton(tr(""),this); 44 | cropBtn->setProperty("cropBtn",true); 45 | cropBtn->setAttribute(Qt::WA_TranslucentBackground); 46 | cropBtn->setStyleSheet(tr("QPushButton[cropBtn=\"true\"]{border-image:url(:upload)}" 47 | "QPushButton[cropBtn=\"true\"]:hover{border-image:url(:upload_h)}" 48 | "QPushButton[cropBtn=\"true\"]:pressed{border-image:url(:upload_p)}")); 49 | cropBtn->setFixedSize(80,80); 50 | cropBtn->setToolTip(tr("裁剪并上传图像")); 51 | tempLayout->addWidget(cropBtn,6,3); 52 | connect(cropBtn,SIGNAL(clicked(bool)), this,SLOT(cropImage())); 53 | } 54 | // 右边栏工具按钮 55 | if(showToolBtn){ 56 | // 4:3 比例按钮 57 | ftsBtn = new QPushButton(tr(""),this); 58 | ftsBtn->setProperty("ftsBtn",true); 59 | ftsBtn->setAttribute(Qt::WA_TranslucentBackground); 60 | ftsBtn->setStyleSheet(tr("QPushButton[ftsBtn=\"true\"]{border-image:url(:image_bg);color:#e8853b;}" 61 | "QPushButton[ftsBtn=\"true\"]:hover{border-image:url(:bright);color:#e8853b;}")); 62 | ftsBtn->setText(tr("4:3")); 63 | ftsBtn->setFont(QFont("微软雅黑",12,QFont::Bold)); 64 | ftsBtn->setFixedSize(50,50); 65 | ftsBtn->setToolTip(tr("固定4:3的比例")); 66 | tempLayout->addWidget(ftsBtn,2,6); 67 | connect(ftsBtn,SIGNAL(clicked(bool)), this,SLOT(setFTProportion())); 68 | 69 | // 1:1 比例按钮 70 | ooBtn = new QPushButton(tr(""),this); 71 | ooBtn->setProperty("ooBtn",true); 72 | ooBtn->setAttribute(Qt::WA_TranslucentBackground); 73 | ooBtn->setStyleSheet(tr("QPushButton[ooBtn=\"true\"]{border-image:url(:image_bg);color:#e8853b;}" 74 | "QPushButton[ooBtn=\"true\"]:hover{border-image:url(:bright);color:#e8853b;}")); 75 | ooBtn->setText(tr("1:1")); 76 | ooBtn->setFont(QFont("微软雅黑",12,QFont::Bold)); 77 | ooBtn->setFixedSize(50,50); 78 | ooBtn->setToolTip(tr("固定1:1的比例")); 79 | tempLayout->addWidget(ooBtn,3,6); 80 | connect(ooBtn,SIGNAL(clicked(bool)), this,SLOT(setOOProportion())); 81 | } 82 | // 布局设置 83 | tempLayout->setSpacing(0); 84 | tempLayout->setMargin(0); 85 | setLayout(tempLayout); 86 | } 87 | 88 | void NBaseImageCropper::setProportion(const quint8 ¶mWidth, const quint8 ¶mHeight) 89 | { 90 | isFTFixed = true; 91 | imageInstance->imageInstance->setProportionFixed(true); 92 | imageInstance->imageInstance->setProportion(QSize(paramWidth, paramHeight)); 93 | } 94 | 95 | void NBaseImageCropper::setImage(const QString imagePath) 96 | { 97 | imageInstance->imageInstance->setImage(QPixmap(imagePath)); 98 | } 99 | 100 | void NBaseImageCropper::setCropStyle(const QColor &bgColor, const QColor &borderColor) 101 | { 102 | imageInstance->imageInstance->setBackgroundColor(bgColor); 103 | imageInstance->imageInstance->setCroppingRectBorderColor(borderColor); 104 | } 105 | 106 | void NBaseImageCropper::setSize(const quint16 &width, const quint16 &height) 107 | { 108 | imageInstance->imageInstance->resize(width, height); 109 | } 110 | 111 | const QPixmap NBaseImageCropper::cropImage() 112 | { 113 | setCurrentPixMap(imageInstance->imageInstance->cropImage()); 114 | emit singalCropImage(getCurrentPixMap()); 115 | return getCurrentPixMap(); 116 | } 117 | 118 | QPixmap NBaseImageCropper::getCurrentPixMap() const 119 | { 120 | return currentPixMap; 121 | } 122 | 123 | void NBaseImageCropper::setCurrentPixMap(const QPixmap &value) 124 | { 125 | currentPixMap = value; 126 | } 127 | 128 | void NBaseImageCropper::setFTProportion() 129 | { 130 | if(!isFTFixed){ 131 | ftsBtn->setStyleSheet(tr("QPushButton[ftsBtn=\"true\"]{border-image:url(:lock_t);color:#e8853b;}" 132 | "QPushButton[ftsBtn=\"true\"]:hover{border-image:url(:bright);color:#e8853b;}")); 133 | setProportion(4,3); 134 | isFTFixed = true; 135 | } else { 136 | setNoProportion(); 137 | isFTFixed = false; 138 | } 139 | } 140 | 141 | void NBaseImageCropper::setOOProportion() 142 | { 143 | if(!isOOFixed){ 144 | ooBtn->setStyleSheet(tr("QPushButton[ooBtn=\"true\"]{border-image:url(:lock_t);color:#e8853b;}" 145 | "QPushButton[ooBtn=\"true\"]:hover{border-image:url(:bright);color:#e8853b;}")); 146 | setProportion(1,1); 147 | isOOFixed = true; 148 | } else { 149 | setNoProportion(); 150 | isOOFixed = false; 151 | } 152 | } 153 | 154 | void NBaseImageCropper::setNoProportion() 155 | { 156 | ftsBtn->setStyleSheet(tr("QPushButton[ftsBtn=\"true\"]{border-image:url(:image_bg);color:#e8853b;}" 157 | "QPushButton[ftsBtn=\"true\"]:hover{border-image:url(:bright);color:#e8853b;}")); 158 | ooBtn->setStyleSheet(tr("QPushButton[ooBtn=\"true\"]{border-image:url(:image_bg);color:#e8853b;}" 159 | "QPushButton[ooBtn=\"true\"]:hover{border-image:url(:bright);color:#e8853b;}")); 160 | imageInstance->imageInstance->setProportionFixed(false); 161 | } 162 | 163 | void NBaseImageCropper::showEvent(QShowEvent *event) 164 | { 165 | if(showConfirmBtn){ 166 | cropBtn->show(); 167 | } 168 | QWidget::showEvent(event); 169 | } 170 | 171 | NBaseImageCropper_p::NBaseImageCropper_p() 172 | { 173 | imageInstance = NULL; 174 | } 175 | -------------------------------------------------------------------------------- /NBaseUiKit/src/nbaseledwidget.cpp: -------------------------------------------------------------------------------- 1 | #include "nbaseledwidget.h" 2 | 3 | NBaseLEDWidget::NBaseLEDWidget(QWidget *parent) : QWidget(parent) 4 | { 5 | textCol = Qt::green; 6 | backCol = Qt::black; 7 | textMsg = "daodaoliang"; 8 | numChar = textMsg.size(); 9 | length = fontMetrics().width(textMsg) + (numChar-1)*fontInfo().pointSize()/4; 10 | typeEff = sliding; 11 | on = true; 12 | textOff = ""; 13 | textOn = textMsg; 14 | timerVal = 300; 15 | idTimer = 0; 16 | timerState = false; 17 | } 18 | 19 | void NBaseLEDWidget::paintEvent(QPaintEvent *event) 20 | { 21 | paintBorder(); 22 | paintText(); 23 | paintGrid(); 24 | QWidget::paintEvent(event); 25 | } 26 | 27 | void NBaseLEDWidget::paintBorder() 28 | { 29 | QPainter painter(this); 30 | painter.setWindow(0, 0, length, 14); 31 | painter.setRenderHint(QPainter::Antialiasing); 32 | 33 | painter.setPen(QPen(Qt::black, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); 34 | QRectF border(0, 0, length, 14); 35 | painter.setBrush(backCol); 36 | painter.drawRect(border); 37 | } 38 | 39 | void NBaseLEDWidget::paintText() 40 | { 41 | QPainter painter(this); 42 | painter.setWindow(0, 0, length, 14); 43 | painter.setRenderHint(QPainter::Antialiasing); 44 | 45 | QRectF textR(1, -1, length, 14); 46 | painter.setPen(QPen(textCol)); 47 | QFont font("Fixed", 10, QFont::Bold); 48 | QFontMetrics fm (font); 49 | painter.setFont(font); 50 | painter.drawText(textR, Qt::AlignVCenter, textMsg); 51 | emit timeOut(); 52 | } 53 | 54 | void NBaseLEDWidget::paintGrid() 55 | { 56 | QPainter painter(this); 57 | painter.setWindow(0, 0, length, 14); 58 | painter.setRenderHint(QPainter::Antialiasing); 59 | painter.setPen(QPen(QColor(60, 60, 60), 0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); 60 | 61 | for (int i = 0; i <=length; i++) 62 | { 63 | painter.drawLine(1*i, 1, 1*i, 13); 64 | } 65 | for (int i = 0; i <=14; i++) 66 | { 67 | painter.drawLine(1, 1*i, length-1, 1*i); 68 | } 69 | } 70 | 71 | void NBaseLEDWidget::timerEvent(QTimerEvent *event) 72 | { 73 | if (timerState == true) 74 | { 75 | if (typeEff == sliding) 76 | { 77 | int size = textMsg.size(); 78 | QString tmp = textMsg; 79 | QString rest = tmp.remove(0, 1); 80 | QString first = textMsg.remove(1, size-1); 81 | textMsg = rest.append(first); 82 | update(); 83 | } 84 | if (typeEff == intermittent) 85 | { 86 | on = !on; 87 | if (on) 88 | { 89 | textMsg = textOn; 90 | update(); 91 | } 92 | if (!on) 93 | { 94 | textMsg = textOff; 95 | update(); 96 | } 97 | } 98 | } 99 | if (timerState == false) 100 | { 101 | textMsg = textOn; 102 | update(); 103 | } 104 | QWidget::timerEvent(event); 105 | } 106 | 107 | void NBaseLEDWidget::setTextColor(QColor colorTx) 108 | { 109 | textCol = colorTx; 110 | update(); 111 | } 112 | 113 | void NBaseLEDWidget::setBackgroundColor(QColor colorBg) 114 | { 115 | backCol = colorBg; 116 | update(); 117 | } 118 | 119 | void NBaseLEDWidget::setEffect(Effect effect) 120 | { 121 | typeEff = effect; 122 | textMsg = textOn; 123 | update(); 124 | } 125 | 126 | void NBaseLEDWidget::setText(QString text) 127 | { 128 | textMsg = text; 129 | textOn = text; 130 | numChar = textMsg.size(); 131 | length = fontMetrics().width(textMsg) + (numChar-1)*fontInfo().pointSize()/4; 132 | update(); 133 | } 134 | 135 | 136 | void NBaseLEDWidget::setTimer(int timer) 137 | { 138 | killTimer(idTimer); 139 | timerVal = timer; 140 | timerState = false; 141 | update(); 142 | } 143 | 144 | void NBaseLEDWidget::startEffect(bool start) 145 | { 146 | timerState = start; 147 | 148 | if (timerState == true) 149 | { 150 | idTimer = startTimer(timerVal); 151 | update(); 152 | } 153 | if (timerState == false) 154 | { 155 | killTimer(idTimer); 156 | update(); 157 | } 158 | } 159 | 160 | QSize NBaseLEDWidget::minimumSizeHint() const 161 | { 162 | return QSize(length*0.3, 3); 163 | } 164 | 165 | QSize NBaseLEDWidget::sizeHint() const 166 | { 167 | return QSize(length*3, 30); 168 | } 169 | 170 | NBaseLEDWidget::Effect NBaseLEDWidget::effect() const 171 | { 172 | return typeEff; 173 | } 174 | 175 | QColor NBaseLEDWidget::colorText() const 176 | { 177 | return textCol; 178 | } 179 | 180 | QColor NBaseLEDWidget::colorBackground() const 181 | { 182 | return backCol; 183 | } 184 | 185 | QString NBaseLEDWidget::text() const 186 | { 187 | return textOn; 188 | } 189 | 190 | int NBaseLEDWidget::timerInterval() const 191 | { 192 | return timerVal; 193 | } 194 | 195 | bool NBaseLEDWidget::isStart() const 196 | { 197 | return timerState; 198 | } 199 | -------------------------------------------------------------------------------- /NBaseUiKit/src/nbaselogowidget.cpp: -------------------------------------------------------------------------------- 1 | #include "nbaselogowidget.h" 2 | #include 3 | #include 4 | #include 5 | #include "nbasetoastr.h" 6 | 7 | NBaseLogoWidget::NBaseLogoWidget(QWidget *parent) : QLabel(parent) 8 | { 9 | isProcessing = false; 10 | imageCrop = new NBaseImageCropper(nullptr, true, true); 11 | imageCrop->setSize(400,400); 12 | setFixedSize(100,100); 13 | connect(imageCrop,SIGNAL(singalCropImage(QPixmap)),this,SLOT(cropImage(QPixmap))); 14 | setLogoPath(QCoreApplication::applicationDirPath() + "/default.jpg"); 15 | } 16 | 17 | void NBaseLogoWidget::editLogo() 18 | { 19 | isProcessing = true; 20 | QString fileName = QFileDialog::getOpenFileName(this, 21 | tr("选择头像文件"), 22 | "./", 23 | "Images (*.png *.xpm *.jpg)"); 24 | if(QFile::exists(fileName)){ 25 | imageCrop->setImage(fileName); 26 | imageCrop->show(); 27 | } 28 | isProcessing = false; 29 | } 30 | 31 | void NBaseLogoWidget::cropImage(QPixmap paramValue) 32 | { 33 | QString tempPath = QCoreApplication::applicationDirPath() + "/logo.jpg"; 34 | QString defaultPath = QCoreApplication::applicationDirPath() + "/default.jpg"; 35 | paramValue.save(tempPath); 36 | if(QFile::exists(tempPath)){ 37 | setStyleSheet(tr("border-image: url(%1);").arg(tempPath)); 38 | setLogoPath(tempPath); 39 | } else { 40 | setStyleSheet(tr("border-image: url(%1);").arg(defaultPath)); 41 | setLogoPath(defaultPath); 42 | } 43 | qDebug()<hide(); 45 | } 46 | 47 | void NBaseLogoWidget::mouseDoubleClickEvent(QMouseEvent *event) 48 | { 49 | if(!isProcessing){ 50 | editLogo(); 51 | } 52 | QLabel::mouseDoubleClickEvent(event); 53 | } 54 | 55 | QString NBaseLogoWidget::getLogoPath() const 56 | { 57 | return logoPath; 58 | } 59 | 60 | void NBaseLogoWidget::setLogoPath(const QString &value) 61 | { 62 | logoPath = value; 63 | } 64 | -------------------------------------------------------------------------------- /NBaseUiKit/src/nbasemarqueelabel.cpp: -------------------------------------------------------------------------------- 1 | #include "nbasemarqueelabel.h" 2 | 3 | NBaseMarqueeLabel::NBaseMarqueeLabel(QWidget *parent, Qt::WindowFlags f) 4 | :QLabel(parent, f) 5 | { 6 | marqueeMargin = 0; 7 | } 8 | 9 | NBaseMarqueeLabel::NBaseMarqueeLabel(const QString &text, QWidget *parent, Qt::WindowFlags f) 10 | :QLabel(text, parent, f) 11 | { 12 | marqueeMargin = 0; 13 | } 14 | 15 | NBaseMarqueeLabel::~NBaseMarqueeLabel() 16 | { 17 | if(timerId > 0){ 18 | killTimer(timerId); 19 | timerId = 0; 20 | } 21 | } 22 | 23 | int NBaseMarqueeLabel::interval() const 24 | { 25 | return mInterval; 26 | } 27 | 28 | bool NBaseMarqueeLabel::isActive() const 29 | { 30 | return active; 31 | } 32 | 33 | NBaseMarqueeLabel::Direction NBaseMarqueeLabel::direction() const 34 | { 35 | return mDirection; 36 | } 37 | 38 | void NBaseMarqueeLabel::setAlignment(Qt::Alignment align) 39 | { 40 | switch (mDirection) 41 | { 42 | case RightToLeft: 43 | QLabel::setAlignment(Qt::AlignLeft 44 | | (align & Qt::AlignVertical_Mask)); 45 | break; 46 | case BottomToTop: 47 | default: 48 | QLabel::setAlignment(Qt::AlignTop 49 | | (align & Qt::AlignHorizontal_Mask)); 50 | } 51 | } 52 | 53 | void NBaseMarqueeLabel::reset() 54 | { 55 | if (timerId != 0) 56 | { 57 | killTimer(timerId); 58 | timerId = 0; 59 | } 60 | bool bActiveChanged = false; 61 | if (active) 62 | { 63 | active = false; 64 | bActiveChanged = true; 65 | } 66 | marqueeMargin = 0; 67 | setContentsMargins(0, 0, 0, 0); 68 | update(); 69 | 70 | if (bActiveChanged) 71 | { 72 | Q_EMIT activeChanged(active); 73 | } 74 | } 75 | 76 | void NBaseMarqueeLabel::setActive(bool paramActive) 77 | { 78 | if (this->active == paramActive) 79 | { 80 | return; 81 | } 82 | if (paramActive) 83 | { 84 | start(); 85 | } else { 86 | stop(); 87 | } 88 | } 89 | 90 | void NBaseMarqueeLabel::setInterval(int msec) 91 | { 92 | if (msec < 1) 93 | { 94 | return; 95 | } 96 | if (mInterval != msec) 97 | { 98 | mInterval = msec; 99 | if (timerId != 0) 100 | { 101 | killTimer(timerId); 102 | timerId = startTimer(mInterval); 103 | } 104 | Q_EMIT intervalChanged(mInterval); 105 | } 106 | } 107 | 108 | void NBaseMarqueeLabel::start() 109 | { 110 | bool bActiveChanged = false; 111 | if (!active) 112 | { 113 | active = true; 114 | bActiveChanged = true; 115 | } 116 | if (!mouseIn) 117 | { 118 | if (timerId == 0) 119 | { 120 | timerId = startTimer(mInterval); 121 | } 122 | setContentsMargins(0, 0, 0, 0); 123 | } 124 | 125 | if (bActiveChanged) 126 | { 127 | Q_EMIT activeChanged(active); 128 | } 129 | } 130 | 131 | void NBaseMarqueeLabel::stop() 132 | { 133 | bool bActiveChanged = false; 134 | if (active) 135 | { 136 | active = false; 137 | bActiveChanged = true; 138 | } 139 | if (!mouseIn) 140 | { 141 | if (timerId != 0) 142 | { 143 | killTimer(timerId); 144 | timerId = 0; 145 | } 146 | switch (mDirection) 147 | { 148 | case RightToLeft: 149 | setContentsMargins(marqueeMargin, 0, 0, 0); 150 | break; 151 | case BottomToTop: 152 | default: 153 | setContentsMargins(0, marqueeMargin, 0, 0); 154 | } 155 | } 156 | 157 | if (bActiveChanged) 158 | { 159 | Q_EMIT activeChanged(active); 160 | } 161 | } 162 | 163 | void NBaseMarqueeLabel::setDirection(NBaseMarqueeLabel::Direction param_direciton) 164 | { 165 | if (param_direciton == mDirection) 166 | { 167 | return; 168 | } 169 | mDirection = param_direciton; 170 | switch (mDirection) 171 | { 172 | case RightToLeft: 173 | setAlignment(Qt::AlignLeft 174 | | (alignment() & Qt::AlignVertical_Mask)); 175 | break; 176 | case BottomToTop: 177 | default: 178 | setAlignment(Qt::AlignTop 179 | | (alignment() & Qt::AlignHorizontal_Mask)); 180 | } 181 | marqueeMargin = 0; 182 | setContentsMargins(0, 0, 0, 0); 183 | update(); 184 | Q_EMIT directionChanged(mDirection); 185 | } 186 | 187 | void NBaseMarqueeLabel::enterEvent(QEvent *event) 188 | { 189 | mouseIn = true; 190 | if (active) 191 | { 192 | if (timerId != 0) 193 | { 194 | killTimer(timerId); 195 | timerId = 0; 196 | } 197 | switch (mDirection) 198 | { 199 | case RightToLeft: 200 | setContentsMargins(marqueeMargin, 0, 0, 0); 201 | break; 202 | case BottomToTop: 203 | default: 204 | setContentsMargins(0, marqueeMargin, 0, 0); 205 | } 206 | } 207 | QLabel::enterEvent(event); 208 | } 209 | 210 | void NBaseMarqueeLabel::leaveEvent(QEvent *event) 211 | { 212 | mouseIn = false; 213 | if (active) 214 | { 215 | if (timerId == 0) 216 | { 217 | timerId = startTimer(mInterval); 218 | } 219 | setContentsMargins(0, 0, 0, 0); 220 | } 221 | QLabel::leaveEvent(event); 222 | } 223 | 224 | void NBaseMarqueeLabel::resizeEvent(QResizeEvent *event) 225 | { 226 | QLabel::resizeEvent(event); 227 | int w; 228 | switch (mDirection) 229 | { 230 | case RightToLeft: 231 | w = event->size().width(); 232 | break; 233 | case BottomToTop: 234 | default: 235 | w = event->size().height(); 236 | } 237 | if (marqueeMargin > w) 238 | { 239 | marqueeMargin = w; 240 | update(); 241 | } 242 | } 243 | 244 | void NBaseMarqueeLabel::timerEvent(QTimerEvent *event) 245 | { 246 | QLabel::timerEvent(event); 247 | if (timerId != 0 && event->timerId() == timerId) 248 | { 249 | marqueeMargin--; 250 | int w, w2; 251 | switch (mDirection) 252 | { 253 | case RightToLeft: 254 | w = sizeHint().width(); 255 | w2 = width(); 256 | break; 257 | case BottomToTop: 258 | default: 259 | w = sizeHint().height(); 260 | w2 = height(); 261 | } 262 | if (marqueeMargin < 0 && -marqueeMargin > w) 263 | { 264 | marqueeMargin = w2; 265 | } 266 | update(); 267 | } 268 | } 269 | 270 | void NBaseMarqueeLabel::paintEvent(QPaintEvent *event) 271 | { 272 | switch (mDirection) 273 | { 274 | case RightToLeft: 275 | setContentsMargins(marqueeMargin, 0, 0, 0); 276 | break; 277 | case BottomToTop: 278 | default: 279 | setContentsMargins(0, marqueeMargin, 0, 0); 280 | } 281 | QLabel::paintEvent(event); 282 | 283 | if (timerId != 0) 284 | { 285 | setContentsMargins(0, 0, 0, 0); 286 | } 287 | } 288 | -------------------------------------------------------------------------------- /NBaseUiKit/src/nbaseminiappwidget.cpp: -------------------------------------------------------------------------------- 1 | #include "nbaseminiappwidget.h" 2 | 3 | NBaseMiniAppWidget::NBaseMiniAppWidget(NBaseMoveableWidget *parent) : NBaseMoveableWidget(parent) 4 | { 5 | setWindowFlags( Qt::FramelessWindowHint|Qt::WindowStaysOnTopHint|Qt::Tool ); 6 | setAttribute(Qt::WA_TranslucentBackground, true); 7 | setFocusPolicy(Qt::NoFocus); 8 | } 9 | 10 | void NBaseMiniAppWidget::setPixmap(QPixmap pixmap) 11 | { 12 | m_Pixmap = pixmap; 13 | update(); 14 | } 15 | 16 | void NBaseMiniAppWidget::enterEvent(QEvent *event) 17 | { 18 | setCursor(Qt::PointingHandCursor); 19 | NBaseMoveableWidget::enterEvent(event); 20 | } 21 | 22 | void NBaseMiniAppWidget::leaveEvent(QEvent *event) 23 | { 24 | setCursor(Qt::ArrowCursor); 25 | NBaseMoveableWidget::leaveEvent(event); 26 | } 27 | 28 | void NBaseMiniAppWidget::paintEvent(QPaintEvent *event) 29 | { 30 | QPainter painter(this); 31 | painter.drawPixmap(0, 0, m_Pixmap); 32 | NBaseMoveableWidget::paintEvent(event); 33 | } 34 | 35 | void NBaseMiniAppWidget::mouseDoubleClickEvent(QMouseEvent *event) 36 | { 37 | emit signalMiniIconClicked(); 38 | NBaseMoveableWidget::mouseDoubleClickEvent(event); 39 | } 40 | -------------------------------------------------------------------------------- /NBaseUiKit/src/nbasemoveablewidget.cpp: -------------------------------------------------------------------------------- 1 | #include "nbasemoveablewidget.h" 2 | 3 | NBaseMoveableWidget::NBaseMoveableWidget(QWidget *parent) : NBaseToolButton(parent) 4 | { 5 | isLeftPressDown_ = false; 6 | this->dir_ = NONE; 7 | this->setWindowFlags(Qt::FramelessWindowHint); 8 | this->setAttribute(Qt::WA_TranslucentBackground); 9 | this->setMouseTracking(true); 10 | move_plan_ = PLANA; 11 | isDragAble_ = true; 12 | } 13 | 14 | MOVEPLAN NBaseMoveableWidget::move_plan() const 15 | { 16 | return move_plan_; 17 | } 18 | 19 | void NBaseMoveableWidget::mousePressEvent(QMouseEvent *event) 20 | { 21 | if(event->button() == Qt::LeftButton && move_plan_ == PLANA) { 22 | isLeftPressDown_ = true; 23 | if(dir_ != NONE) { 24 | this->mouseGrabber(); 25 | } else { 26 | dragPosition_ = event->globalPos() - this->frameGeometry().topLeft(); 27 | } 28 | } 29 | NBaseToolButton::mousePressEvent(event); 30 | } 31 | 32 | void NBaseMoveableWidget::mouseMoveEvent(QMouseEvent *event) 33 | { 34 | if(move_plan_ == PLANA){ 35 | QPoint gloPoint = event->globalPos(); 36 | QRect rect = this->rect(); 37 | QPoint tl = mapToGlobal(rect.topLeft()); 38 | QPoint rb = mapToGlobal(rect.bottomRight()); 39 | if(!isLeftPressDown_) { 40 | if(isDragAble_) this->region(gloPoint); 41 | } else { 42 | if(dir_ != NONE) { 43 | QRect rMove(tl, rb); 44 | switch(dir_) { 45 | case LEFT: 46 | if(rb.x() - gloPoint.x() <= this->minimumWidth()) 47 | rMove.setX(tl.x()); 48 | else 49 | rMove.setX(gloPoint.x()); 50 | break; 51 | case RIGHT: 52 | rMove.setWidth(gloPoint.x() - tl.x()); 53 | break; 54 | case UP: 55 | if(rb.y() - gloPoint.y() <= this->minimumHeight()) 56 | rMove.setY(tl.y()); 57 | else 58 | rMove.setY(gloPoint.y()); 59 | break; 60 | case DOWN: 61 | rMove.setHeight(gloPoint.y() - tl.y()); 62 | break; 63 | case LEFTTOP: 64 | if(rb.x() - gloPoint.x() <= this->minimumWidth()) 65 | rMove.setX(tl.x()); 66 | else 67 | rMove.setX(gloPoint.x()); 68 | if(rb.y() - gloPoint.y() <= this->minimumHeight()) 69 | rMove.setY(tl.y()); 70 | else 71 | rMove.setY(gloPoint.y()); 72 | break; 73 | case RIGHTTOP: 74 | rMove.setWidth(gloPoint.x() - tl.x()); 75 | rMove.setY(gloPoint.y()); 76 | break; 77 | case LEFTBOTTOM: 78 | rMove.setX(gloPoint.x()); 79 | rMove.setHeight(gloPoint.y() - tl.y()); 80 | break; 81 | case RIGHTBOTTOM: 82 | rMove.setWidth(gloPoint.x() - tl.x()); 83 | rMove.setHeight(gloPoint.y() - tl.y()); 84 | break; 85 | default: 86 | break; 87 | } 88 | if(isDragAble_) this->setGeometry(rMove); 89 | } else { 90 | move(event->globalPos() - dragPosition_); 91 | event->accept(); 92 | } 93 | } 94 | } 95 | NBaseToolButton::mouseMoveEvent(event); 96 | } 97 | 98 | void NBaseMoveableWidget::mouseReleaseEvent(QMouseEvent *event) 99 | { 100 | if(event->button() == Qt::LeftButton && move_plan_ == PLANA) { 101 | isLeftPressDown_ = false; 102 | if(dir_ != NONE) { 103 | this->releaseMouse(); 104 | this->setCursor(QCursor(Qt::ArrowCursor)); 105 | } 106 | } 107 | NBaseToolButton::mouseReleaseEvent(event); 108 | } 109 | 110 | void NBaseMoveableWidget::paintEvent(QPaintEvent *event) 111 | { 112 | QStyleOption opt; 113 | opt.init(this); 114 | QPainter p(this); 115 | style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); 116 | NBaseToolButton::paintEvent(event); 117 | } 118 | 119 | #if defined(Q_OS_WIN) 120 | bool NBaseMoveableWidget::winEvent(MSG *message, long *result) 121 | { 122 | if(move_plan_ == PLANB){ 123 | switch(message->message) 124 | { 125 | case WM_NCHITTEST: 126 | int xPos = GET_X_LPARAM(message->lParam) - this->frameGeometry().x(); 127 | int yPos = GET_Y_LPARAM(message->lParam) - this->frameGeometry().y(); 128 | if(this->childAt(xPos,yPos) == 0) 129 | { 130 | *result = HTCAPTION; 131 | }else{ 132 | return false; 133 | } 134 | if(xPos > 1 && xPos < 6) 135 | *result = HTLEFT; 136 | if(xPos > (this->width() - 6) && xPos < (this->width() - 1)) 137 | *result = HTRIGHT; 138 | if(yPos > 1 && yPos < 6) 139 | *result = HTTOP; 140 | if(yPos > (this->height() - 6) && yPos < (this->height() - 1)) 141 | *result = HTBOTTOM; 142 | if(xPos > 1 && xPos < 6 && yPos > 1 && yPos < 6) 143 | *result = HTTOPLEFT; 144 | if(xPos > (this->width() - 6) && xPos < (this->width() - 1) && yPos > 1 && yPos < 6) 145 | *result = HTTOPRIGHT; 146 | if(xPos > 1 && xPos < 6 && yPos > (this->height() - 6) && yPos < (this->height() - 1)) 147 | *result = HTBOTTOMLEFT; 148 | if(xPos > (this->width() - 6) && xPos < (this->width() - 1) && yPos > (this->height() - 6) && yPos < (this->height() - 1)) 149 | *result = HTBOTTOMRIGHT; 150 | return true; 151 | } 152 | return false; 153 | } else { 154 | return false; 155 | } 156 | } 157 | #endif 158 | 159 | void NBaseMoveableWidget::region(const QPoint &cursorGlobalPoint) 160 | { 161 | QRect rect = this->rect(); 162 | QPoint tl = mapToGlobal(rect.topLeft()); 163 | QPoint rb = mapToGlobal(rect.bottomRight()); 164 | int x = cursorGlobalPoint.x(); 165 | int y = cursorGlobalPoint.y(); 166 | 167 | if(tl.x() + PADDING >= x && tl.x() <= x && tl.y() + PADDING >= y && tl.y() <= y) { 168 | // 左上角 169 | dir_ = LEFTTOP; 170 | this->setCursor(QCursor(Qt::SizeFDiagCursor)); 171 | } else if(x >= rb.x() - PADDING && x <= rb.x() && y >= rb.y() - PADDING && y <= rb.y()) { 172 | // 右下角 173 | dir_ = RIGHTBOTTOM; 174 | this->setCursor(QCursor(Qt::SizeFDiagCursor)); 175 | } else if(x <= tl.x() + PADDING && x >= tl.x() && y >= rb.y() - PADDING && y <= rb.y()) { 176 | //左下角 177 | dir_ = LEFTBOTTOM; 178 | this->setCursor(QCursor(Qt::SizeBDiagCursor)); 179 | } else if(x <= rb.x() && x >= rb.x() - PADDING && y >= tl.y() && y <= tl.y() + PADDING) { 180 | // 右上角 181 | dir_ = RIGHTTOP; 182 | this->setCursor(QCursor(Qt::SizeBDiagCursor)); 183 | } else if(x <= tl.x() + PADDING && x >= tl.x()) { 184 | // 左边 185 | dir_ = LEFT; 186 | this->setCursor(QCursor(Qt::SizeHorCursor)); 187 | } else if( x <= rb.x() && x >= rb.x() - PADDING) { 188 | // 右边 189 | dir_ = RIGHT; 190 | this->setCursor(QCursor(Qt::SizeHorCursor)); 191 | }else if(y >= tl.y() && y <= tl.y() + PADDING){ 192 | // 上边 193 | dir_ = UP; 194 | this->setCursor(QCursor(Qt::SizeVerCursor)); 195 | } else if(y <= rb.y() && y >= rb.y() - PADDING) { 196 | // 下边 197 | dir_ = DOWN; 198 | this->setCursor(QCursor(Qt::SizeVerCursor)); 199 | }else { 200 | // 默认 201 | dir_ = NONE; 202 | this->setCursor(QCursor(Qt::ArrowCursor)); 203 | } 204 | } 205 | 206 | void NBaseMoveableWidget::setMove_plan(const MOVEPLAN &move_plan) 207 | { 208 | move_plan_ = move_plan; 209 | } 210 | 211 | bool NBaseMoveableWidget::isDragAble() const 212 | { 213 | return isDragAble_; 214 | } 215 | 216 | void NBaseMoveableWidget::setIsDragAble(bool isDragAble) 217 | { 218 | isDragAble_ = isDragAble; 219 | } 220 | -------------------------------------------------------------------------------- /NBaseUiKit/src/nbasepopwidget.cpp: -------------------------------------------------------------------------------- 1 | #include "nbasepopwidget.h" 2 | 3 | NBasePopWidget::NBasePopWidget(QWidget *parent) : QWidget(parent) 4 | { 5 | this->setWindowFlags(Qt::FramelessWindowHint|Qt::WindowStaysOnTopHint|Qt::Tool); 6 | mIsPause = false; 7 | remainTimer = NULL; 8 | animation = NULL; 9 | } 10 | 11 | void NBasePopWidget::showPopDialog(quint32 paramRemainTime) 12 | { 13 | mremainTime = paramRemainTime * 500; 14 | this->move((desktop.availableGeometry().width()-this->width()),desktop.availableGeometry().height()); 15 | if(!this->isVisible()){ 16 | show(); 17 | showAnimation(); 18 | } 19 | } 20 | 21 | void NBasePopWidget::closePopDialog() 22 | { 23 | hide(); 24 | clearAll(); 25 | } 26 | 27 | void NBasePopWidget::pausePopDialog() 28 | { 29 | if(animation != NULL){ 30 | this->move((desktop.availableGeometry().width()-this->width()),(desktop.availableGeometry().height()-this->height())); 31 | animation->setPaused(true); 32 | mIsPause = true; 33 | } 34 | } 35 | 36 | void NBasePopWidget::startPopDialog() 37 | { 38 | if(mIsPause){ 39 | if(animation != NULL){ 40 | animation->setPaused(false); 41 | mIsPause = false; 42 | } 43 | } 44 | } 45 | 46 | void NBasePopWidget::closeAnimation() 47 | { 48 | if(!mIsPause){ 49 | remainTimer->stop(); 50 | disconnect(remainTimer,SIGNAL(timeout()),this,SLOT(closeAnimation())); 51 | delete remainTimer; 52 | remainTimer=NULL; 53 | animation->setStartValue(QPoint(this->x(),this->y())); 54 | animation->setEndValue(QPoint((desktop.availableGeometry().width()-this->width()),desktop.availableGeometry().height()+50)); 55 | animation->start(); 56 | connect(animation,SIGNAL(finished()),this,SLOT(clearAll())); 57 | } 58 | } 59 | 60 | void NBasePopWidget::clearAll() 61 | { 62 | if(animation != NULL){ 63 | disconnect(animation,SIGNAL(finished()),this,SLOT(clearAll())); 64 | delete animation; 65 | } 66 | animation=NULL; 67 | hide(); 68 | } 69 | 70 | void NBasePopWidget::showAnimation() 71 | { 72 | if(!mIsPause){ 73 | animation=new QPropertyAnimation(this,"pos"); 74 | animation->setDuration(mremainTime); 75 | animation->setEasingCurve(QEasingCurve::OutElastic); 76 | animation->setStartValue(QPoint(this->x(),this->y())); 77 | animation->setEndValue(QPoint((desktop.availableGeometry().width()-this->width()),(desktop.availableGeometry().height()-this->height()))); 78 | connect(animation,SIGNAL(valueChanged(QVariant)),this,SLOT(animationValueChanged(QVariant))); 79 | animation->start(); 80 | remainTimer=new QTimer(); 81 | connect(remainTimer,SIGNAL(timeout()),this,SLOT(closeAnimation())); 82 | remainTimer->start(mremainTime*4); 83 | } 84 | } 85 | 86 | void NBasePopWidget::animationValueChanged(QVariant param_value) 87 | { 88 | QPoint tempValue = param_value.toPoint(); 89 | Q_UNUSED(tempValue) 90 | } 91 | -------------------------------------------------------------------------------- /NBaseUiKit/src/nbaseqrencodewidget.cpp: -------------------------------------------------------------------------------- 1 | #include "nbaseqrencodewidget.h" 2 | 3 | NBaseQREncodeWidget::NBaseQREncodeWidget(QWidget *parent) : QWidget(parent) 4 | { 5 | qrMargin =5; 6 | qrSize = QSize(128,128); 7 | qrForeground = QColor("#0E4963"); 8 | qrBackground = QColor("white"); 9 | qrCasesen = true; 10 | qrMode = MODE_8; 11 | qrLevel = LEVEL_Q; 12 | qrPercent = 0.23; 13 | qrLogo="daodaoliang.github.io"; 14 | qrData = "daodaoliang.github.io"; 15 | qrFilePath = ""; 16 | resize(qrSize); 17 | } 18 | 19 | QString NBaseQREncodeWidget::getQrData() const 20 | { 21 | return qrData; 22 | } 23 | 24 | void NBaseQREncodeWidget::setQrData(const QString &value) 25 | { 26 | if(qrData != value){ 27 | qrData = value; 28 | emit qrDataChanged(qrData); 29 | update(); 30 | } 31 | } 32 | 33 | QString NBaseQREncodeWidget::getQrLogo() const 34 | { 35 | return qrLogo; 36 | } 37 | 38 | void NBaseQREncodeWidget::setQrLogo(const QString &value) 39 | { 40 | if(qrLogo != value){ 41 | qrLogo = value; 42 | emit qrLogoChanged(qrLogo); 43 | update(); 44 | } 45 | } 46 | 47 | QSize NBaseQREncodeWidget::getQrSize() const 48 | { 49 | return qrSize; 50 | } 51 | 52 | void NBaseQREncodeWidget::setQrSize(const QSize &value) 53 | { 54 | if(qrSize != value){ 55 | qrSize = value; 56 | emit qrSizeChanged(qrSize); 57 | update(); 58 | } 59 | } 60 | 61 | NBaseQREncodeWidget::QR_MODE NBaseQREncodeWidget::getQrMode() const 62 | { 63 | return qrMode; 64 | } 65 | 66 | void NBaseQREncodeWidget::setQrMode(const QR_MODE &value) 67 | { 68 | if(qrMode != value){ 69 | qrMode = value; 70 | emit qrModeChanged(qrMode); 71 | update(); 72 | } 73 | } 74 | 75 | NBaseQREncodeWidget::QR_LEVEL NBaseQREncodeWidget::getQrLevel() const 76 | { 77 | return qrLevel; 78 | } 79 | 80 | void NBaseQREncodeWidget::setQrLevel(const QR_LEVEL &value) 81 | { 82 | if(qrLevel != value){ 83 | qrLevel = value; 84 | emit qrLevelChanged(qrLevel); 85 | update(); 86 | } 87 | } 88 | 89 | bool NBaseQREncodeWidget::getQrCasesen() const 90 | { 91 | return qrCasesen; 92 | } 93 | 94 | void NBaseQREncodeWidget::setQrCasesen(bool value) 95 | { 96 | if(qrCasesen != value){ 97 | qrCasesen = value; 98 | emit qrCasesenChanged(qrCasesen); 99 | update(); 100 | } 101 | } 102 | 103 | int NBaseQREncodeWidget::getQrMargin() const 104 | { 105 | return qrMargin; 106 | } 107 | 108 | void NBaseQREncodeWidget::setQrMargin(int value) 109 | { 110 | if(qrMargin != value){ 111 | qrMargin = value; 112 | emit qrMarginChanged(qrMargin); 113 | update(); 114 | } 115 | } 116 | 117 | qreal NBaseQREncodeWidget::getQrPercent() const 118 | { 119 | return qrPercent; 120 | } 121 | 122 | void NBaseQREncodeWidget::setQrPercent(const qreal &value) 123 | { 124 | if(qrPercent != value){ 125 | qrPercent = value; 126 | emit qrPercentChanged(qrPercent); 127 | update(); 128 | } 129 | } 130 | 131 | QColor NBaseQREncodeWidget::getQrForeground() const 132 | { 133 | return qrForeground; 134 | } 135 | 136 | void NBaseQREncodeWidget::setQrForeground(const QColor &value) 137 | { 138 | if(qrForeground != value){ 139 | qrForeground = value; 140 | emit qrForegroundChanged(qrForeground); 141 | update(); 142 | } 143 | } 144 | 145 | QColor NBaseQREncodeWidget::getQrBackground() const 146 | { 147 | return qrBackground; 148 | } 149 | 150 | void NBaseQREncodeWidget::setQrBackground(const QColor &value) 151 | { 152 | if(qrBackground != value){ 153 | qrBackground = value; 154 | emit qrBackgroundChanged(qrBackground); 155 | update(); 156 | } 157 | } 158 | 159 | QString NBaseQREncodeWidget::getQrFilePath() const 160 | { 161 | return qrFilePath; 162 | } 163 | 164 | void NBaseQREncodeWidget::setQrFilePath(const QString &value) 165 | { 166 | qrFilePath = value; 167 | if(!qrFilePath.isEmpty()){ 168 | saveCurViewToFile(); 169 | } 170 | } 171 | 172 | void NBaseQREncodeWidget::paintEvent(QPaintEvent *e) 173 | { 174 | Q_UNUSED(e) 175 | QPainter painter(this); 176 | QRcode *qrcode = QRcode_encodeString(qrData.toUtf8() , 7, (QRecLevel)qrLevel, (QRencodeMode)qrMode, qrCasesen ? 1 : 0); 177 | QRect rect(0,0,qrSize.width(),qrSize.height()); 178 | if(0 != qrcode) { 179 | unsigned char *point = qrcode->data; 180 | painter.setPen(Qt::NoPen); 181 | painter.setBrush(this->qrBackground); 182 | painter.drawRect(rect); 183 | double scale = (rect.width () - 2.0 * qrMargin) / qrcode->width; 184 | painter.setBrush(this->qrForeground); 185 | for (int y = 0; y < qrcode->width; y ++) { 186 | for (int x = 0; x < qrcode->width; x ++) { 187 | if (*point & 1) { 188 | QRectF r(qrMargin + x * scale, qrMargin + y * scale, scale, scale); 189 | painter.drawRects(&r, 1); 190 | } 191 | point ++; 192 | } 193 | } 194 | point = NULL; 195 | QRcode_free(qrcode); 196 | painter.setBrush(QColor("#00ffffff")); 197 | double icon_width = (rect.width () - 2.0 * qrMargin) * qrPercent; 198 | double icon_height = icon_width; 199 | double wrap_x = (rect.width () - icon_width) / 2.0; 200 | double wrap_y = (rect.width () - icon_height) / 2.0; 201 | QRectF wrap(wrap_x - 5, wrap_y - 5, icon_width + 10, icon_height + 10); 202 | painter.drawRoundRect(wrap, 50, 50); 203 | if(qrLogo.isEmpty() || qrLogo == "daodaoliang.github.io"){ 204 | painter.save(); 205 | QPen pen; 206 | pen.setColor(Qt::red); 207 | painter.setFont(QFont("微软雅黑",14)); 208 | painter.setPen(pen); 209 | painter.drawText(wrap,"daodaoliang.github.io"); 210 | painter.restore(); 211 | }else{ 212 | if(qrLogo.startsWith("qrc")){ 213 | qrLogo = qrLogo.replace("qrc",""); 214 | } 215 | QPixmap image(qrLogo); 216 | QRectF target(wrap_x, wrap_y, icon_width, icon_height); 217 | QRectF source(0, 0, image.width (), image.height ()); 218 | painter.drawPixmap (target, image, source); 219 | } 220 | } 221 | } 222 | 223 | void NBaseQREncodeWidget::resizeEvent(QResizeEvent *e) 224 | { 225 | if(e->size().isValid()){ 226 | int w = this->size().width(); 227 | int h = this->size().height(); 228 | if(w>h){ 229 | setQrSize(QSize(h,h)); 230 | }else{ 231 | setQrSize(QSize(w,w)); 232 | } 233 | } 234 | } 235 | 236 | void NBaseQREncodeWidget::saveCurViewToFile() 237 | { 238 | QString str = qrFilePath; 239 | if(!str.endsWith(".png")){ 240 | str.append(".png"); 241 | } 242 | QFile file(str); 243 | if (!file.open(QIODevice::WriteOnly)){ 244 | file.close(); 245 | return; 246 | } 247 | QRect rect(0,0,qrSize.width(),qrSize.height()); 248 | QPixmap pixmap(rect.size()); 249 | this->render(&pixmap, QPoint(), QRegion(rect)); 250 | pixmap.save(str); 251 | } 252 | -------------------------------------------------------------------------------- /NBaseUiKit/src/nbasereelwidget.cpp: -------------------------------------------------------------------------------- 1 | #include "nbasereelwidget.h" 2 | #include 3 | 4 | 5 | NBaseReelWidget::NBaseReelWidget(QWidget *parent) : NBaseMoveableWidget(parent) 6 | { 7 | oriSize = QSize(0, 0); 8 | connect(&animaExpan, SIGNAL(frameChanged(int)), SLOT(onExpansion())); 9 | animaExpan.setFrameRange(0, 100); 10 | animaExpan.setDuration(3000); 11 | bgColorbegin = QColor(255,250,250); 12 | bgColorEnd = QColor(209,227,219); 13 | bgCorner = QColor(90,76,76); 14 | animaExpan.setCurveShape(QTimeLine::LinearCurve); 15 | setIsDragAble(false); 16 | } 17 | 18 | void NBaseReelWidget::paintEvent(QPaintEvent *event) 19 | { 20 | QPainter painter(this); 21 | painter.setRenderHint(QPainter::Antialiasing,true); 22 | // 画边框 23 | QPen p(QColor(209,227,220)); 24 | p.setWidth(2); 25 | painter.setPen(p); 26 | // 背景渐变颜色 27 | QLinearGradient linearGradient(QPointF(0, 0), QPointF(0, rect().height())); 28 | linearGradient.setColorAt(0, bgColorbegin); 29 | linearGradient.setColorAt(1, bgColorEnd); 30 | linearGradient.setSpread(QGradient::PadSpread); 31 | painter.save(); 32 | QPainterPath path; 33 | path.addRoundedRect(QRect(rect().topLeft(),QPoint(rect().right(),rect().bottom()-25)),8,8); 34 | painter.fillPath(path,QBrush(linearGradient)); 35 | painter.drawPath(path); 36 | painter.restore(); 37 | if(bFinally) { //定格,即最终呈现的时候 38 | painter.save(); 39 | //因为窗体左下角有一个弧度,还要考虑曲线外留下的空白区域,先“填补”它 40 | QRect r(0,height()-33,15,16); 41 | painter.fillRect(r,bgColorEnd); 42 | painter.drawLine(r.topLeft(), r.bottomLeft()); 43 | painter.restore(); 44 | //用贝塞尔曲线填充 45 | QPoint startPos(20,height()-25); 46 | QPoint endPos(20,startPos.y()+25); 47 | QPainterPath path1(startPos); 48 | //贝塞尔曲线的两个控制点可能没那么精确,大家可以参考贝塞尔曲线算法做到更精确的控制,我这就不赘述了 49 | path1.cubicTo(QPoint(0,startPos.y()), QPoint(-15,startPos.y()+8), endPos); 50 | //闭合曲线区域 51 | path1.closeSubpath(); 52 | painter.fillPath(path1, bgCorner); 53 | painter.drawPath(path1); 54 | } 55 | else { //动画的时候 56 | painter.save(); 57 | //同上面一样,先“填补”窗体左下角的空白区域 58 | /* 注意这里的椭圆高度控制为15,底部给定格的时候留下一定区域 59 | * 因为定格的时候“卷筒”要展开 */ 60 | QRect r(0,height()-33,20,15); 61 | painter.fillRect(r,bgColorEnd); 62 | //画三条边框线 63 | painter.drawLine(r.topLeft(), r.bottomLeft()); 64 | painter.drawLine(QPoint(20,height()-25), r.bottomRight()); 65 | painter.drawLine(QPoint(10,height()-25), QPoint(20,height()-25)); 66 | painter.restore(); 67 | //用椭圆填充 68 | QPainterPath path1; 69 | path1.addEllipse(0,height()-25,20,15); 70 | painter.fillPath(path1, bgCorner); 71 | painter.drawPath(path1); 72 | } 73 | NBaseMoveableWidget::paintEvent(event); 74 | } 75 | 76 | void NBaseReelWidget::setOriPos(const QPoint &p) 77 | { 78 | move(p); 79 | this->oriPos = p; 80 | } 81 | 82 | void NBaseReelWidget::setOriSize(const QSize &s) 83 | { 84 | this->oriSize = s; 85 | } 86 | 87 | void NBaseReelWidget::showExpan() 88 | { 89 | bFinally = false; 90 | resize(20,oriSize.height()); 91 | show(); 92 | animaExpan.stop(); 93 | animaExpan.start(); 94 | } 95 | 96 | void NBaseReelWidget::onExpansion() 97 | { 98 | int indexFrame = animaExpan.currentFrame(); 99 | resize(20+(oriSize.width()-20)/100.0*indexFrame, oriSize.height()); 100 | if(indexFrame >= 99) { 101 | bFinally = true; 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /NBaseUiKit/src/nbaserotatingstackedwidget.cpp: -------------------------------------------------------------------------------- 1 | #include "nbaserotatingstackedwidget.h" 2 | 3 | NBaseRotatingStackedWidget::NBaseRotatingStackedWidget(QWidget *parent) 4 | { 5 | Q_UNUSED(parent); 6 | iRotateVal=0; 7 | isAnimating=false; 8 | setAttribute(Qt::WA_TranslucentBackground, true); 9 | setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint); 10 | } 11 | 12 | void NBaseRotatingStackedWidget::paintEvent(QPaintEvent *event) 13 | { 14 | if(isAnimating) 15 | { 16 | if(iRotateVal > 90) 17 | { 18 | QPixmap pixmap(widget(nextIndex)->size()); 19 | widget(nextIndex)->render(&pixmap); 20 | QPainter painter(this); 21 | 22 | QTransform transform; 23 | transform.translate(width()/2, 0); 24 | transform.rotate(iRotateVal+180,Qt::YAxis); 25 | painter.setTransform(transform); 26 | painter.drawPixmap(-1*width()/2,0,pixmap); 27 | } else { 28 | QPixmap pixmap(currentWidget()->size()); 29 | currentWidget()->render(&pixmap); 30 | QPainter painter(this); 31 | 32 | QTransform transform; 33 | transform.translate(width()/2, 0); 34 | transform.rotate(iRotateVal,Qt::YAxis); 35 | painter.setTransform(transform); 36 | painter.drawPixmap(-1*width()/2,0,pixmap); 37 | } 38 | } else { 39 | QWidget::paintEvent(event); 40 | } 41 | } 42 | 43 | void NBaseRotatingStackedWidget::nextPage() 44 | { 45 | rotate((currentIndex() + 1) >= count() ? 0: (currentIndex() + 1)); 46 | } 47 | 48 | void NBaseRotatingStackedWidget::rotate(int index) 49 | { 50 | if(isAnimating) return; 51 | nextIndex = index; 52 | int offsetx=frameRect().width(); 53 | int offsety=frameRect().height(); 54 | widget(index)->setGeometry ( 0, 0, offsetx, offsety ); 55 | QPropertyAnimation *animnow = new QPropertyAnimation(this,"rotateVal"); 56 | animnow->setDuration(500); 57 | animnow->setEasingCurve(QEasingCurve::Linear); 58 | animnow->setStartValue(0); 59 | animnow->setEndValue(180); 60 | connect(animnow,SIGNAL(valueChanged(QVariant)),this,SLOT(valChanged(QVariant))); 61 | connect(animnow,SIGNAL(finished()),this,SLOT(animDone())); 62 | currentWidget()->hide(); 63 | isAnimating = true; 64 | animnow->start(); 65 | } 66 | 67 | float NBaseRotatingStackedWidget::rotateVal() 68 | { 69 | return iRotateVal; 70 | } 71 | 72 | void NBaseRotatingStackedWidget::setRotateVal(float fl) 73 | { 74 | iRotateVal = fl; 75 | } 76 | 77 | void NBaseRotatingStackedWidget::valChanged(QVariant) 78 | { 79 | repaint(); 80 | } 81 | 82 | void NBaseRotatingStackedWidget::animDone() 83 | { 84 | iRotateVal=0; 85 | isAnimating=false; 86 | widget(nextIndex)->show(); 87 | widget(nextIndex)->raise();; 88 | setCurrentWidget(widget(nextIndex)); 89 | repaint(); 90 | } 91 | -------------------------------------------------------------------------------- /NBaseUiKit/src/nbaseshadowlabel.cpp: -------------------------------------------------------------------------------- 1 | #include "nbaseshadowlabel.h" 2 | #include 3 | 4 | NBaseShadowLabel::NBaseShadowLabel(QLabel *parent) : QLabel(parent) 5 | { 6 | this->setAttribute(Qt::WA_TranslucentBackground, true); 7 | this->setAutoFillBackground(false); 8 | this->setWindowFlags(Qt::FramelessWindowHint); 9 | QGraphicsDropShadowEffect *shadow_effect = new QGraphicsDropShadowEffect; 10 | shadow_effect->setOffset(-5, 5); 11 | shadow_effect->setColor(Qt::darkBlue); 12 | shadow_effect->setBlurRadius(8); 13 | setGraphicsEffect(shadow_effect); 14 | } 15 | 16 | NBaseShadowLabel::NBaseShadowLabel(const QString &text, QLabel *parent) 17 | :QLabel(text, parent) 18 | { 19 | this->setAttribute(Qt::WA_TranslucentBackground, true); 20 | this->setAutoFillBackground(false); 21 | this->setWindowFlags(Qt::FramelessWindowHint); 22 | QGraphicsDropShadowEffect *shadow_effect = new QGraphicsDropShadowEffect; 23 | shadow_effect->setOffset(-5, 5); 24 | shadow_effect->setColor(Qt::darkBlue); 25 | shadow_effect->setBlurRadius(8); 26 | setGraphicsEffect(shadow_effect); 27 | } 28 | -------------------------------------------------------------------------------- /NBaseUiKit/src/nbaseshadowwidget.cpp: -------------------------------------------------------------------------------- 1 | #include "nbaseshadowwidget.h" 2 | 3 | NBaseShadowWidget::NBaseShadowWidget(NBaseMoveableWidget *parent) : NBaseMoveableWidget(parent) 4 | { 5 | this->setWindowFlags(Qt::FramelessWindowHint); 6 | this->setAttribute(Qt::WA_TranslucentBackground); 7 | } 8 | 9 | void NBaseShadowWidget::changeEvent(QEvent *event) 10 | { 11 | NBaseMoveableWidget::changeEvent(event); 12 | } 13 | 14 | void NBaseShadowWidget::paintEvent(QPaintEvent *e) 15 | { 16 | drawShadowPlanB(); 17 | NBaseMoveableWidget::paintEvent(e); 18 | } 19 | 20 | void NBaseShadowWidget::drawShadowPlanA() 21 | { 22 | // blurRadius 阴影清晰度,越小越清晰 23 | // dx x方向阴影位置和偏移量,正值在右方,值越大偏移越大 24 | // dy y方向阴影位置和偏移量,正值在下方,值越大偏移越大 25 | QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect; 26 | shadow->setBlurRadius(10); 27 | shadow->setColor(QColor(0, 0, 0, 160)); 28 | shadow->setOffset(5, 5); 29 | this->setGraphicsEffect(shadow); 30 | } 31 | 32 | void NBaseShadowWidget::drawShadowPlanB() 33 | { 34 | //画阴影边框方案[B] 35 | QPainter painter(this); 36 | QList pixmaps; 37 | pixmaps.append(QPixmap(":/img/shadow_left.png")); 38 | pixmaps.append(QPixmap(":/img/shadow_right.png")); 39 | pixmaps.append(QPixmap(":/img/shadow_top.png")); 40 | pixmaps.append(QPixmap(":/img/shadow_bottom.png")); 41 | pixmaps.append(QPixmap(":/img/shadow_corner1.png")); 42 | pixmaps.append(QPixmap(":/img/shadow_corner2.png")); 43 | pixmaps.append(QPixmap(":/img/shadow_corner3.png")); 44 | pixmaps.append(QPixmap(":/img/shadow_corner4.png")); 45 | painter.drawPixmap(0,0,20,20,pixmaps[4]); 46 | painter.drawPixmap(this->width() - 20,0,20,20,pixmaps[5]); 47 | painter.drawPixmap(0,this->height() - 20,20,20,pixmaps[6]); 48 | painter.drawPixmap(this->width() - 20,this->height() - 20,20,20,pixmaps[7]); 49 | painter.drawPixmap(0,20,20,this->height() - 40,pixmaps[0].scaled(20,this->height() - 40)); 50 | painter.drawPixmap(this->width() - 20,20,20,this->height() - 40,pixmaps[1].scaled(20,this->height() - 40)); 51 | painter.drawPixmap(20,0,this->width() - 40,20,pixmaps[2].scaled(this->width() - 40,20)); 52 | painter.drawPixmap(20,this->height() - 20,this->width() - 40,20,pixmaps[3].scaled(this->width() - 40,20)); 53 | painter.setPen(Qt::NoPen); 54 | painter.setBrush(Qt::white); 55 | painter.drawRoundedRect(QRect(18,18,this->width() - 36,this->height() - 36),2.0f,2.0f); 56 | } 57 | -------------------------------------------------------------------------------- /NBaseUiKit/src/nbasesnowlabel.cpp: -------------------------------------------------------------------------------- 1 | #include "nbasesnowlabel.h" 2 | 3 | NBaseSnowLabel::NBaseSnowLabel(QWidget *parent) : QLabel(parent) 4 | { 5 | 6 | } 7 | 8 | void NBaseSnowLabel::paintEvent(QPaintEvent *event) 9 | { 10 | QPainter tempPainter(this); 11 | tempPainter.setPen(Qt::red); 12 | tempPainter.setBrush(Qt::red); 13 | tempPainter.setFont(QFont("微软雅黑", 12, QFont::Bold)); 14 | if(alignment() == (Qt::AlignHCenter|Qt::AlignVCenter)){ 15 | tempPainter.drawText((width() - fontMetrics().width(text()))/2-10,this->contentsRect().height()/2-6,8,12,Qt::AlignCenter,"*"); 16 | } else if(alignment() == (Qt::AlignRight|Qt::AlignVCenter)){ 17 | tempPainter.drawText((width() - fontMetrics().width(text()))-10,this->contentsRect().height()/2-6,8,12,Qt::AlignCenter,"*"); 18 | } 19 | QLabel::paintEvent(event); 20 | } 21 | -------------------------------------------------------------------------------- /NBaseUiKit/src/nbaseswitchbutton.cpp: -------------------------------------------------------------------------------- 1 | #include "nbaseswitchbutton.h" 2 | #include 3 | 4 | NBaseSwitchButton::NBaseSwitchButton(QWidget *parent) : QWidget(parent) 5 | { 6 | setMouseTracking(true); 7 | setWindowFlags(Qt::FramelessWindowHint); 8 | setAttribute(Qt::WA_TranslucentBackground); 9 | //默认OFF背景色 10 | mOffBgcBegin = QColor(252, 177, 170); 11 | mOffBgcEnd = QColor(254, 179, 172); 12 | 13 | //默认ON背景色 14 | mOnBgcBegin = QColor(144, 202, 175); 15 | mOnBgcEnd = QColor(146,204,177); 16 | 17 | //默认滑块ON背景色 18 | mSlideONCBegin = QColor(0, 142, 89); 19 | mSlideONCEnd = QColor(2, 144, 91); 20 | 21 | //默认滑块OFF背景色 22 | mSlidOFFCBegin = QColor(192,63,60); 23 | mSlidOFFCEnd = QColor(194,65,62); 24 | 25 | //默认开关状态 26 | mState = false; 27 | mMouseDown = false; 28 | mMouseMove = false; 29 | mMouseUp = true; 30 | resize(70,30); 31 | } 32 | 33 | void NBaseSwitchButton::mousePressEvent(QMouseEvent *event) 34 | { 35 | if (event->button() == Qt::LeftButton) { 36 | mMouseDown = true; 37 | mMouseUp = false; 38 | firstPoint = event->pos(); 39 | } 40 | } 41 | 42 | void NBaseSwitchButton::mouseMoveEvent(QMouseEvent *event) 43 | { 44 | if(mMouseDown) 45 | { 46 | mMouseMove = true; 47 | lastPoint = event->pos(); //获取当前光标的位置 48 | repaint(); 49 | } 50 | } 51 | 52 | void NBaseSwitchButton::mouseReleaseEvent(QMouseEvent *event) 53 | { 54 | if(mMouseDown) { 55 | mMouseDown = false; 56 | mMouseMove = false; 57 | mMouseUp = true; 58 | if (event->pos().x() < width() / 2.0) 59 | { 60 | mState = false; 61 | } 62 | else 63 | { 64 | mState = true; 65 | } 66 | repaint(); 67 | } 68 | } 69 | 70 | void NBaseSwitchButton::paintEvent(QPaintEvent *event) 71 | { 72 | Q_UNUSED(event); 73 | QPainter painter(this); 74 | painter.setRenderHint(QPainter::Antialiasing, true); //抗锯齿 75 | drawPressBackground(&painter); 76 | if(mMouseMove) { 77 | QRect sliderect; 78 | int left; 79 | int diff = lastPoint.x()-firstPoint.x(); //计算移动差值 80 | if(mState) { 81 | //(width() - height() + 4 - 2) --- 表示滑块右边界值 82 | left = (width() - height() + 4 - 2) + diff; 83 | if(left < 2) { 84 | sliderect.setLeft(2); 85 | } 86 | else if (left > (width() - height() + 4 - 2)) { 87 | sliderect.setLeft(width() - height() + 4 - 2); 88 | } 89 | else { 90 | sliderect.setLeft(width() - height() + 4 - 2 + diff); 91 | } 92 | } 93 | else { 94 | left = diff; 95 | if(left < 2) { 96 | sliderect.setLeft(2); 97 | } 98 | else if (left > (width() - height() + 4 - 2)) { 99 | sliderect.setLeft(width() - height() + 4 - 2); 100 | } 101 | else { 102 | sliderect.setLeft(diff); 103 | } 104 | } 105 | sliderect.setTop(2); 106 | sliderect.setWidth(height() - 4 ); 107 | sliderect.setHeight(height() - 4); 108 | 109 | painter.setPen(Qt::NoPen); 110 | QLinearGradient linGrad(rect().topLeft(), rect().bottomLeft()); 111 | linGrad.setColorAt(0, mSlideONCBegin); 112 | linGrad.setColorAt(1, mSlideONCEnd); 113 | linGrad.setSpread(QGradient::PadSpread); 114 | painter.setBrush(linGrad); 115 | 116 | QRect rrect = sliderect.intersected(rect()); 117 | painter.drawEllipse(rrect); 118 | //画边框 119 | painter.setBrush(Qt::NoBrush); 120 | painter.setPen(QColor(173, 173, 173, 160)); 121 | painter.drawEllipse(rrect); 122 | } 123 | else { 124 | drawPressSlide(&painter); 125 | } 126 | } 127 | 128 | void NBaseSwitchButton::drawPressBackground(QPainter *painter) 129 | { 130 | QPainterPath path; 131 | 132 | path.moveTo(height() / 2.0, 0); 133 | path.arcTo(QRectF(0, 0, height(), height()), 90, 180); 134 | path.lineTo(width() - height() / 2.0, height()); 135 | path.arcTo(QRectF(width() - height(), 0, height(), height()), 270, 180); 136 | path.lineTo(height() / 2.0, 0); 137 | 138 | QPainterPath pathrect; 139 | pathrect.moveTo(0, 0); 140 | pathrect.lineTo(0, height()); 141 | pathrect.lineTo(width(), height()); 142 | pathrect.lineTo(width(), 0); 143 | pathrect.lineTo(0, 0); 144 | 145 | QPainterPath interpath = path.intersected(pathrect); 146 | painter->setPen(Qt::NoPen); 147 | QLinearGradient linGrad(rect().topLeft(), rect().bottomLeft()); 148 | linGrad.setColorAt(0, mState ? mOnBgcBegin : mOffBgcBegin); 149 | linGrad.setColorAt(1, mState ? mOnBgcEnd : mOffBgcEnd); 150 | linGrad.setSpread(QGradient::PadSpread); 151 | painter->setBrush(linGrad); 152 | painter->drawPath(interpath); 153 | 154 | //画边框 155 | painter->setBrush(Qt::NoBrush); 156 | painter->setPen(QColor(173, 173, 173, 255)); 157 | painter->drawPath(interpath); 158 | 159 | painter->setBrush(Qt::Dense1Pattern); 160 | painter->setPen(QColor(72,72,72)); 161 | QFont tempFont = QFont("微软雅黑",10,QFont::Bold); 162 | painter->setFont(tempFont); 163 | painter->drawText((mState?width()/5*2:width()/5*3) - fontMetrics().width("开")/2, 164 | height()/2 + fontMetrics().height()/2, 165 | mState?"开":"关"); 166 | } 167 | 168 | void NBaseSwitchButton::drawPressSlide(QPainter *painter) 169 | { 170 | QRect sliderect; 171 | sliderect.setLeft(mState ? width() - height() + 4 - 2 : 2); 172 | sliderect.setTop(2); 173 | sliderect.setWidth(height() - 4 ); 174 | sliderect.setHeight(height() - 4); 175 | 176 | painter->setPen(Qt::NoPen); 177 | QLinearGradient linGrad(rect().topLeft(), rect().bottomLeft()); 178 | if(mState){ 179 | linGrad.setColorAt(0, mSlideONCBegin); 180 | linGrad.setColorAt(1, mSlideONCEnd); 181 | } else { 182 | linGrad.setColorAt(0, mSlidOFFCBegin); 183 | linGrad.setColorAt(1, mSlidOFFCEnd); 184 | } 185 | linGrad.setSpread(QGradient::PadSpread); 186 | painter->setBrush(linGrad); 187 | QRect rrect = sliderect.intersected(rect()); 188 | painter->drawEllipse(rrect); 189 | 190 | //画边框 191 | painter->setBrush(Qt::NoBrush); 192 | painter->setPen(QColor(173, 173, 173, 160)); 193 | painter->drawEllipse(rrect); 194 | } 195 | -------------------------------------------------------------------------------- /NBaseUiKit/src/nbasetoastr.cpp: -------------------------------------------------------------------------------- 1 | #include "nbasetoastr.h" 2 | #include 3 | #include 4 | #include 5 | 6 | void NBaseToastr::setShadow(QWidget *w, qreal blurRadius, qreal dx, qreal dy) 7 | { 8 | QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect; 9 | shadow->setBlurRadius(blurRadius); 10 | shadow->setColor(QColor(0, 0, 0, 160)); 11 | shadow->setOffset(dx, dy); 12 | w->setGraphicsEffect(shadow); 13 | } 14 | 15 | NBaseToastr::NBaseToastr(QWidget *parent, const QString &message, int w, int h, const QString &style) 16 | :QLabel(parent) 17 | { 18 | setText(message); 19 | setFixedSize(w, h); 20 | setAlignment(Qt::AlignCenter); 21 | startx = (parent->width()-width()) / 2; 22 | starty = parent->height(); 23 | endy = parent->height()*3/4; 24 | setStyleSheet(style); 25 | this->setShadow(this); 26 | } 27 | 28 | void NBaseToastr::toastr() 29 | { 30 | QPropertyAnimation *animal= new QPropertyAnimation(this,"pos"); 31 | animal->setDuration(500); 32 | animal->setStartValue(QPoint(startx,starty)); 33 | animal->setEndValue(QPoint(startx,endy)); 34 | animal->setEasingCurve(QEasingCurve::OutCubic); 35 | connect(animal, SIGNAL(finished()), this, SLOT(animationFinished())); 36 | this->show(); 37 | animal->start(); 38 | } 39 | 40 | void NBaseToastr::animationFinished() 41 | { 42 | QTimer::singleShot(400, this, SLOT(delSelf())); 43 | } 44 | 45 | void NBaseToastr::delSelf() 46 | { 47 | delete this; 48 | } 49 | -------------------------------------------------------------------------------- /NBaseUiKit/src/nbasetoolbutton.cpp: -------------------------------------------------------------------------------- 1 | #include "nbasetoolbutton.h" 2 | #include 3 | #include 4 | 5 | 6 | NBaseToolButton::NBaseToolButton(QWidget *parent) : QWidget(parent) 7 | { 8 | minButton = new QToolButton(this); 9 | closeButton = new QToolButton(this); 10 | QPixmap minPix = style()->standardPixmap(QStyle::SP_TitleBarMinButton); 11 | QPixmap closePix = style()->standardPixmap(QStyle::SP_TitleBarCloseButton); 12 | minButton->setIcon(minPix); 13 | closeButton->setIcon(closePix); 14 | minButton->setToolTip(tr("最小化")); 15 | closeButton->setToolTip(tr("关闭")); 16 | minButton->setStyleSheet("background-color:transparent;"); 17 | closeButton->setStyleSheet("background-color:transparent;"); 18 | connect(minButton,SIGNAL(clicked(bool)),this,SLOT(showMinimized())); 19 | connect(closeButton,SIGNAL(clicked(bool)),this,SLOT(deleteLater())); 20 | setHideToolButton(); 21 | } 22 | 23 | void NBaseToolButton::setShowToolButton() 24 | { 25 | int width = this->width(); 26 | minButton->setGeometry(width-46,5,20,20); 27 | closeButton->setGeometry(width-25,5,20,20); 28 | minButton->setHidden(false); 29 | closeButton->setHidden(false); 30 | } 31 | 32 | void NBaseToolButton::setHideToolButton() 33 | { 34 | minButton->setHidden(true); 35 | closeButton->setHidden(true); 36 | } 37 | -------------------------------------------------------------------------------- /NBaseUiKit/src/nbasewaitdialog.cpp: -------------------------------------------------------------------------------- 1 | #include "nbasewaitdialog.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "waitingspinnerwidget.h" 10 | 11 | WaitingSpinnerWidget * innerSpin; 12 | 13 | NBaseWaitDialog::NBaseWaitDialog(QWidget *parent, WaitStyle paramStyle) 14 | :parentObj(parent) 15 | { 16 | setWindowFlags(Qt::FramelessWindowHint); 17 | setWindowModality(Qt::ApplicationModal); 18 | setWindowOpacity(0.9); 19 | isShow = false; 20 | switch (paramStyle) { 21 | case BOXSTYLE: 22 | setBoxStyle(); 23 | break; 24 | case ANDROIDSTYLE: 25 | setAndroidStyle(); 26 | break; 27 | default: 28 | setBoxStyle(); 29 | break; 30 | } 31 | } 32 | 33 | bool NBaseWaitDialog::showWaitDialog() 34 | { 35 | QWidget *parentObj = (QWidget *)(parent()); 36 | if(parentObj != NULL) setGeometry(parentObj->width()/2-width()/2,parentObj->height()/2-height()/2,width(),height()); 37 | // 增加spinbox 38 | innerSpin->start(); 39 | // 显示 40 | show(); 41 | isShow = true; 42 | return true; 43 | } 44 | 45 | void NBaseWaitDialog::closeWaitDialog() 46 | { 47 | qDebug()<<"daodaoliang"; 48 | innerSpin->stop(); 49 | hide(); 50 | isShow = false; 51 | } 52 | 53 | void NBaseWaitDialog::closeEvent(QCloseEvent *event) 54 | { 55 | Q_UNUSED(event); 56 | } 57 | 58 | void NBaseWaitDialog::paintEvent(QPaintEvent *event) 59 | { 60 | QStyleOption opt; 61 | opt.init(this); 62 | QPainter p(this); 63 | style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); 64 | NBaseShadowWidget::paintEvent(event); 65 | } 66 | 67 | void NBaseWaitDialog::moveEvent(QMoveEvent *event) 68 | { 69 | if(isShow && parentObj){ 70 | QPoint newPos = event->pos(); 71 | QPoint fatherPos = parentObj->pos(); 72 | if(newPos.x()=fatherPos.y()&&newPos.y()<=fatherPos.y()+parentObj->height()-height()) move(fatherPos.x(), newPos.y()); 75 | else move(fatherPos.x(), fatherPos.y()+parentObj->height()-height()); 76 | } else if (fatherPos.x() <= newPos.x() && newPos.x() <= fatherPos.x() + parentObj->width() - width()) { 77 | if(newPos.y()=fatherPos.y()&&newPos.y()<=fatherPos.y()+parentObj->height()-height()) event->accept(); 79 | else move(newPos.x(), fatherPos.y()+parentObj->height()-height()); 80 | } else { 81 | if(newPos.y()width()-width(),fatherPos.y()); 82 | else if (newPos.y()>=fatherPos.y()&&newPos.y()<=fatherPos.y()+parentObj->height()-height()) move(fatherPos.x()+parentObj->width()-width(),newPos.y()); 83 | else move(fatherPos.x()+parentObj->width()-width(), fatherPos.y()+parentObj->height()-height()); 84 | } 85 | event->ignore(); 86 | } 87 | event->ignore(); 88 | } 89 | 90 | void NBaseWaitDialog::setBoxStyle() 91 | { 92 | setFixedSize(300, 250); 93 | // 增加辅助控件(标题) 94 | QLabel *innerTitleLabel = new QLabel("我是测试标题", this); 95 | innerTitleLabel->setFont(QFont("微软雅黑", 13, QFont::Bold)); 96 | innerTitleLabel->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter); 97 | innerTitleLabel->setStyleSheet("background-color:rgb(41,146,204);" 98 | "color:white;"); 99 | innerTitleLabel->setGeometry(this->x() + 18 , this->y() + 18, this->width() - 36, 40); 100 | 101 | // 增加辅助控件(按钮) 102 | QPushButton *innerCancleBtn = new QPushButton("关闭", this); 103 | innerCancleBtn->setFont(QFont("微软雅黑", 13, QFont::Bold)); 104 | innerCancleBtn->setEnabled(true); 105 | innerCancleBtn->setStyleSheet("background-color:rgb(41,146,204);" 106 | "border:1px solid;" 107 | "border-color:rgb(41,146,204);" 108 | "color:white;"); 109 | innerCancleBtn->setGeometry(this->x() + this->width()/2 - 50, this->y() + this->height() - 50, 100, 30); 110 | connect(innerCancleBtn, SIGNAL(clicked(bool)), this, SLOT(closeWaitDialog())); 111 | 112 | // 增加辅助控件(中间面板) 113 | QWidget *innerCenter = new QWidget(this); 114 | innerCenter->setStyleSheet("border-top:0.5px solid;" 115 | "border-top-color: rgb(50,55,51);" 116 | "border-bottom:0.5px solid;" 117 | "border-bottom-color: rgb(50,55,51);"); 118 | innerCenter->setGeometry(this->x() + 18 , this->y() + 58, this->width() - 36, this->height() - 110); 119 | 120 | // 设置spinbox 121 | innerSpin = new WaitingSpinnerWidget(innerCenter); 122 | innerSpin->setRoundness(70.0); 123 | innerSpin->setMinimumTrailOpacity(15.0); 124 | innerSpin->setTrailFadePercentage(70.0); 125 | innerSpin->setNumberOfLines(17); 126 | innerSpin->setLineLength(13); 127 | innerSpin->setLineWidth(4); 128 | innerSpin->setInnerRadius(13); 129 | innerSpin->setRevolutionsPerSecond(1); 130 | innerSpin->setColor(QColor(41,146,204)); 131 | } 132 | 133 | void NBaseWaitDialog::setAndroidStyle() 134 | { 135 | setFixedSize(300, 100); 136 | // 增加左边辅助面板 137 | QWidget *left = new QWidget(this); 138 | left->setGeometry(0,18,90,this->height()-36); 139 | // 增加右边文字面板 140 | QLabel *right = new QLabel(QString("请耐心等候……"),this); 141 | right->setFont(QFont("微软雅黑", 14, QFont::Bold)); 142 | right->setAlignment(Qt::AlignCenter); 143 | right->setGeometry(90,18,200,this->height()-36); 144 | right->setStyleSheet("color:rgb(50,55,50);"); 145 | // 设置spinbox 146 | innerSpin = new WaitingSpinnerWidget(left); 147 | innerSpin->setRoundness(70.0); 148 | innerSpin->setMinimumTrailOpacity(15.0); 149 | innerSpin->setTrailFadePercentage(70.0); 150 | innerSpin->setNumberOfLines(17); 151 | innerSpin->setLineLength(13); 152 | innerSpin->setLineWidth(4); 153 | innerSpin->setInnerRadius(13); 154 | innerSpin->setRevolutionsPerSecond(1); 155 | innerSpin->setColor(QColor(41,146,204)); 156 | } 157 | -------------------------------------------------------------------------------- /NBaseUiKit/src/ntouchlistview.cpp: -------------------------------------------------------------------------------- 1 | #include "ntouchlistview.h" 2 | #include 3 | 4 | NTouchListView::NTouchListView(QWidget *parent) 5 | { 6 | Q_UNUSED(parent); 7 | verticalScrollBar()->setVisible(false); 8 | setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 9 | horizontalScrollBar()->setVisible(false); 10 | setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 11 | isMoved = false; 12 | } 13 | 14 | void NTouchListView::mousePressEvent(QMouseEvent *event) 15 | { 16 | originPosY = event->globalY(); 17 | originPosX = event->globalX(); 18 | QListView::mousePressEvent(event); 19 | } 20 | 21 | void NTouchListView::mouseMoveEvent(QMouseEvent *event) 22 | { 23 | int varDiff; 24 | if(flow() == QListView::TopToBottom){ 25 | varDiff = verticalScrollBar()->sliderPosition() - (event->globalY() - originPosY); 26 | verticalScrollBar()->setSliderPosition(varDiff); 27 | } else { 28 | varDiff = horizontalScrollBar()->sliderPosition() - (event->globalX() - originPosX); 29 | horizontalScrollBar()->setSliderPosition(varDiff); 30 | } 31 | originPosY = event->globalY(); 32 | originPosX = event->globalX(); 33 | isMoved = true; 34 | QListView::mouseMoveEvent(event); 35 | } 36 | 37 | void NTouchListView::mouseReleaseEvent(QMouseEvent *event) 38 | { 39 | int varDiff; 40 | if(flow() == QListView::TopToBottom){ 41 | varDiff = verticalScrollBar()->sliderPosition() - (event->globalY() - originPosY); 42 | verticalScrollBar()->setSliderPosition(varDiff); 43 | } else { 44 | varDiff = horizontalScrollBar()->sliderPosition() - (event->globalX() - originPosX); 45 | horizontalScrollBar()->setSliderPosition(varDiff); 46 | } 47 | if(isMoved){ 48 | if(varDiff<=0){ 49 | NBaseToastr * tempToa = new NBaseToastr(this, "已经到达顶部"); 50 | tempToa->toastr(); 51 | } else if(varDiff >= verticalScrollBar()->maximum()){ 52 | NBaseToastr * tempToa = new NBaseToastr(this, "已经到达底部"); 53 | tempToa->toastr(); 54 | } 55 | } 56 | isMoved = false; 57 | originPosY = event->globalY(); 58 | originPosX = event->globalX(); 59 | QListView::mouseReleaseEvent(event); 60 | } 61 | -------------------------------------------------------------------------------- /NBaseUiKit/src/ntouchlistwidget.cpp: -------------------------------------------------------------------------------- 1 | #include "ntouchlistwidget.h" 2 | #include 3 | #include 4 | #include "nbasetoastr.h" 5 | 6 | NTouchListWidget::NTouchListWidget(QWidget *parent) 7 | { 8 | Q_UNUSED(parent); 9 | verticalScrollBar()->setVisible(false); 10 | setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 11 | horizontalScrollBar()->setVisible(false); 12 | setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 13 | isMoved = false; 14 | } 15 | 16 | void NTouchListWidget::mousePressEvent(QMouseEvent *event) 17 | { 18 | originPosY = event->globalY(); 19 | originPosX = event->globalX(); 20 | QListWidget::mousePressEvent(event); 21 | } 22 | 23 | void NTouchListWidget::mouseMoveEvent(QMouseEvent *event) 24 | { 25 | int varDiff; 26 | if(flow() == QListWidget::TopToBottom){ 27 | varDiff = verticalScrollBar()->sliderPosition() - (event->globalY() - originPosY); 28 | verticalScrollBar()->setSliderPosition(varDiff); 29 | } else { 30 | varDiff = horizontalScrollBar()->sliderPosition() - (event->globalX() - originPosX); 31 | horizontalScrollBar()->setSliderPosition(varDiff); 32 | } 33 | originPosY = event->globalY(); 34 | originPosX = event->globalX(); 35 | isMoved = true; 36 | QListWidget::mouseMoveEvent(event); 37 | } 38 | 39 | void NTouchListWidget::mouseReleaseEvent(QMouseEvent *event) 40 | { 41 | int varDiff; 42 | if(flow() == QListWidget::TopToBottom){ 43 | varDiff = verticalScrollBar()->sliderPosition() - (event->globalY() - originPosY); 44 | verticalScrollBar()->setSliderPosition(varDiff); 45 | } else { 46 | varDiff = horizontalScrollBar()->sliderPosition() - (event->globalX() - originPosX); 47 | horizontalScrollBar()->setSliderPosition(varDiff); 48 | } 49 | if(isMoved){ 50 | if(varDiff<=0){ 51 | NBaseToastr * tempToa = new NBaseToastr(this, "已经到达顶部"); 52 | tempToa->toastr(); 53 | } else if(varDiff >= verticalScrollBar()->maximum()){ 54 | NBaseToastr * tempToa = new NBaseToastr(this, "已经到达底部"); 55 | tempToa->toastr(); 56 | } 57 | } 58 | isMoved = false; 59 | originPosY = event->globalY(); 60 | originPosX = event->globalX(); 61 | QListWidget::mouseReleaseEvent(event); 62 | } 63 | -------------------------------------------------------------------------------- /Scripts/clear.bat: -------------------------------------------------------------------------------- 1 | rmdir /S /Q %~dp0..\NBaseUiKit\release 2 | rmdir /S /Q %~dp0..\NBaseUiKit\debug 3 | rmdir /S /Q %~dp0..\NBaseUiKit\build_ 4 | rmdir /S /Q %~dp0..\Example\build_ 5 | rmdir /S /Q %~dp0..\Example\release 6 | rmdir /S /Q %~dp0..\Example\debug 7 | rmdir /S /Q %~dp0..\bin 8 | del /Q %~dp0..\Makefile* 9 | del /Q %~dp0..\NBaseUiKit\Makefile* 10 | del /Q %~dp0..\Example\Makefile* 11 | -------------------------------------------------------------------------------- /Scripts/clear.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | rm -rf ..\NBaseUiKit\release 4 | rm -rf ..\NBaseUiKit\debug 5 | rm -rf ..\NBaseUiKit\build_ 6 | rm -rf \Example\build_ 7 | rm -rf ..\Example\release 8 | rm -rf ..\Example\debug 9 | rm -rf ..\bin 10 | rm -rf ..\Makefile* 11 | rm -rf ..\NBaseUiKit\Makefile* 12 | rm -rf ..\Example\Makefile* 13 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-architect --------------------------------------------------------------------------------