diff --git a/ui/0snap/flatui.jpg b/ui/0snap/flatui.jpg new file mode 100644 index 0000000..aa5474a Binary files /dev/null and b/ui/0snap/flatui.jpg differ diff --git a/ui/0snap/iconhelper1.jpg b/ui/0snap/iconhelper1.jpg new file mode 100644 index 0000000..2b9531f Binary files /dev/null and b/ui/0snap/iconhelper1.jpg differ diff --git a/ui/0snap/iconhelper2.jpg b/ui/0snap/iconhelper2.jpg new file mode 100644 index 0000000..9703078 Binary files /dev/null and b/ui/0snap/iconhelper2.jpg differ diff --git a/ui/0snap/styledemo.jpg b/ui/0snap/styledemo.jpg new file mode 100644 index 0000000..bfaac7e Binary files /dev/null and b/ui/0snap/styledemo.jpg differ diff --git a/ui/0snap/uidemo01.jpg b/ui/0snap/uidemo01.jpg new file mode 100644 index 0000000..c60e2a0 Binary files /dev/null and b/ui/0snap/uidemo01.jpg differ diff --git a/ui/0snap/uidemo08.jpg b/ui/0snap/uidemo08.jpg new file mode 100644 index 0000000..44edec4 Binary files /dev/null and b/ui/0snap/uidemo08.jpg differ diff --git a/ui/0snap/uidemo09.jpg b/ui/0snap/uidemo09.jpg new file mode 100644 index 0000000..0994af8 Binary files /dev/null and b/ui/0snap/uidemo09.jpg differ diff --git a/ui/0snap/uidemo10.jpg b/ui/0snap/uidemo10.jpg new file mode 100644 index 0000000..f05df5e Binary files /dev/null and b/ui/0snap/uidemo10.jpg differ diff --git a/ui/bin/flatui.exe b/ui/bin/flatui.exe new file mode 100644 index 0000000..32b637f Binary files /dev/null and b/ui/bin/flatui.exe differ diff --git a/ui/bin/flatui.ilk b/ui/bin/flatui.ilk new file mode 100644 index 0000000..de07d35 Binary files /dev/null and b/ui/bin/flatui.ilk differ diff --git a/ui/bin/flatui.pdb b/ui/bin/flatui.pdb new file mode 100644 index 0000000..9861a2d Binary files /dev/null and b/ui/bin/flatui.pdb differ diff --git a/ui/bin/iconhelper.exe b/ui/bin/iconhelper.exe new file mode 100644 index 0000000..ecba50e Binary files /dev/null and b/ui/bin/iconhelper.exe differ diff --git a/ui/bin/iconhelper.ilk b/ui/bin/iconhelper.ilk new file mode 100644 index 0000000..b6a7c0b Binary files /dev/null and b/ui/bin/iconhelper.ilk differ diff --git a/ui/bin/iconhelper.pdb b/ui/bin/iconhelper.pdb new file mode 100644 index 0000000..e8fffef Binary files /dev/null and b/ui/bin/iconhelper.pdb differ diff --git a/ui/bin/styledemo.exe b/ui/bin/styledemo.exe new file mode 100644 index 0000000..e06c096 Binary files /dev/null and b/ui/bin/styledemo.exe differ diff --git a/ui/bin/styledemo.ilk b/ui/bin/styledemo.ilk new file mode 100644 index 0000000..e66bed2 Binary files /dev/null and b/ui/bin/styledemo.ilk differ diff --git a/ui/bin/styledemo.pdb b/ui/bin/styledemo.pdb new file mode 100644 index 0000000..9a536ad Binary files /dev/null and b/ui/bin/styledemo.pdb differ diff --git a/ui/bin/uidemo01.exe b/ui/bin/uidemo01.exe new file mode 100644 index 0000000..36967fd Binary files /dev/null and b/ui/bin/uidemo01.exe differ diff --git a/ui/bin/uidemo01.ilk b/ui/bin/uidemo01.ilk new file mode 100644 index 0000000..ac3416c Binary files /dev/null and b/ui/bin/uidemo01.ilk differ diff --git a/ui/bin/uidemo01.pdb b/ui/bin/uidemo01.pdb new file mode 100644 index 0000000..b07484c Binary files /dev/null and b/ui/bin/uidemo01.pdb differ diff --git a/ui/bin/uidemo08.exe b/ui/bin/uidemo08.exe new file mode 100644 index 0000000..67e8476 Binary files /dev/null and b/ui/bin/uidemo08.exe differ diff --git a/ui/bin/uidemo08.ilk b/ui/bin/uidemo08.ilk new file mode 100644 index 0000000..5e542cd Binary files /dev/null and b/ui/bin/uidemo08.ilk differ diff --git a/ui/bin/uidemo08.pdb b/ui/bin/uidemo08.pdb new file mode 100644 index 0000000..f2dfb82 Binary files /dev/null and b/ui/bin/uidemo08.pdb differ diff --git a/ui/bin/uidemo09.exe b/ui/bin/uidemo09.exe new file mode 100644 index 0000000..3c5348c Binary files /dev/null and b/ui/bin/uidemo09.exe differ diff --git a/ui/bin/uidemo09.ilk b/ui/bin/uidemo09.ilk new file mode 100644 index 0000000..a80b8d6 Binary files /dev/null and b/ui/bin/uidemo09.ilk differ diff --git a/ui/bin/uidemo09.pdb b/ui/bin/uidemo09.pdb new file mode 100644 index 0000000..1027443 Binary files /dev/null and b/ui/bin/uidemo09.pdb differ diff --git a/ui/bin/uidemo10.exe b/ui/bin/uidemo10.exe new file mode 100644 index 0000000..9ba69cd Binary files /dev/null and b/ui/bin/uidemo10.exe differ diff --git a/ui/bin/uidemo10.ilk b/ui/bin/uidemo10.ilk new file mode 100644 index 0000000..c1f3d88 Binary files /dev/null and b/ui/bin/uidemo10.ilk differ diff --git a/ui/bin/uidemo10.pdb b/ui/bin/uidemo10.pdb new file mode 100644 index 0000000..c436e67 Binary files /dev/null and b/ui/bin/uidemo10.pdb differ diff --git a/ui/core_base/appdata.cpp b/ui/core_base/appdata.cpp new file mode 100644 index 0000000..b532a42 --- /dev/null +++ b/ui/core_base/appdata.cpp @@ -0,0 +1,20 @@ +#include "appdata.h" +#include "quihelper.h" + +QString AppData::TitleFlag = "(QQ: 517216493 WX: feiyangqingyun)"; +int AppData::RowHeight = 25; +int AppData::RightWidth = 180; +int AppData::FormWidth = 1200; +int AppData::FormHeight = 750; + +void AppData::checkRatio() +{ + //根据分辨率设定宽高 + int width = QUIHelper::deskWidth(); + if (width >= 1440) { + RowHeight = RowHeight < 25 ? 25 : RowHeight; + RightWidth = RightWidth < 220 ? 220 : RightWidth; + FormWidth = FormWidth < 1200 ? 1200 : FormWidth; + FormHeight = FormHeight < 800 ? 800 : FormHeight; + } +} diff --git a/ui/core_base/appdata.h b/ui/core_base/appdata.h new file mode 100644 index 0000000..197adf4 --- /dev/null +++ b/ui/core_base/appdata.h @@ -0,0 +1,18 @@ +#ifndef APPDATA_H +#define APPDATA_H + +#include "head.h" + +class AppData +{ +public: + static QString TitleFlag; //标题标识 + static int RowHeight; //行高 + static int RightWidth; //右侧宽度 + static int FormWidth; //窗体宽度 + static int FormHeight; //窗体高度 + + static void checkRatio(); //校验分辨率 +}; + +#endif // APPDATA_H diff --git a/ui/core_base/appinit.cpp b/ui/core_base/appinit.cpp new file mode 100644 index 0000000..8ecdb2a --- /dev/null +++ b/ui/core_base/appinit.cpp @@ -0,0 +1,57 @@ +#include "appinit.h" +#include "qmutex.h" +#include "qapplication.h" +#include "qevent.h" +#include "qwidget.h" +#include "qdebug.h" + +QScopedPointer AppInit::self; +AppInit *AppInit::Instance() +{ + if (self.isNull()) { + static QMutex mutex; + QMutexLocker locker(&mutex); + if (self.isNull()) { + self.reset(new AppInit); + } + } + + return self.data(); +} + +AppInit::AppInit(QObject *parent) : QObject(parent) +{ +} + +bool AppInit::eventFilter(QObject *watched, QEvent *event) +{ + QWidget *w = (QWidget *)watched; + if (!w->property("canMove").toBool()) { + return QObject::eventFilter(watched, event); + } + + static QPoint mousePoint; + static bool mousePressed = false; + + QMouseEvent *mouseEvent = static_cast(event); + if (mouseEvent->type() == QEvent::MouseButtonPress) { + if (mouseEvent->button() == Qt::LeftButton) { + mousePressed = true; + mousePoint = mouseEvent->globalPos() - w->pos(); + } + } else if (mouseEvent->type() == QEvent::MouseButtonRelease) { + mousePressed = false; + } else if (mouseEvent->type() == QEvent::MouseMove) { + if (mousePressed) { + w->move(mouseEvent->globalPos() - mousePoint); + return true; + } + } + + return QObject::eventFilter(watched, event); +} + +void AppInit::start() +{ + qApp->installEventFilter(this); +} diff --git a/ui/core_base/appinit.h b/ui/core_base/appinit.h new file mode 100644 index 0000000..467ad84 --- /dev/null +++ b/ui/core_base/appinit.h @@ -0,0 +1,23 @@ +#ifndef APPINIT_H +#define APPINIT_H + +#include + +class AppInit : public QObject +{ + Q_OBJECT +public: + static AppInit *Instance(); + explicit AppInit(QObject *parent = 0); + +protected: + bool eventFilter(QObject *watched, QEvent *event); + +private: + static QScopedPointer self; + +public slots: + void start(); +}; + +#endif // APPINIT_H diff --git a/ui/core_base/base64helper.cpp b/ui/core_base/base64helper.cpp new file mode 100644 index 0000000..e294fcd --- /dev/null +++ b/ui/core_base/base64helper.cpp @@ -0,0 +1,41 @@ +#include "base64helper.h" +#include "qbuffer.h" +#include "qdebug.h" + +QString Base64Helper::imageToBase64(const QImage &image) +{ + return QString(imageToBase64x(image)); +} + +QByteArray Base64Helper::imageToBase64x(const QImage &image) +{ + //这个转换可能比较耗时建议在线程中执行 + QByteArray data; + QBuffer buffer(&data); + image.save(&buffer, "JPG"); + data = data.toBase64(); + return data; +} + +QImage Base64Helper::base64ToImage(const QString &data) +{ + return base64ToImagex(data.toUtf8()); +} + +QImage Base64Helper::base64ToImagex(const QByteArray &data) +{ + //这个转换可能比较耗时建议在线程中执行 + QImage image; + image.loadFromData(QByteArray::fromBase64(data)); + return image; +} + +QString Base64Helper::textToBase64(const QString &text) +{ + return QString(text.toUtf8().toBase64()); +} + +QString Base64Helper::base64ToText(const QString &text) +{ + return QString(QByteArray::fromBase64(text.toUtf8())); +} diff --git a/ui/core_base/base64helper.h b/ui/core_base/base64helper.h new file mode 100644 index 0000000..e17cae6 --- /dev/null +++ b/ui/core_base/base64helper.h @@ -0,0 +1,37 @@ +#ifndef BASE64HELPER_H +#define BASE64HELPER_H + +/** + * base64编码转换类 作者:feiyangqingyun(QQ:517216493) 2016-12-16 + * 1. 图片转base64字符串。 + * 2. base64字符串转图片。 + * 3. 字符转base64字符串。 + * 4. base64字符串转字符。 + * 5. 后期增加数据压缩。 + * 6. Qt6对base64编码转换进行了重写效率提升至少200%。 + */ + +#include + +#ifdef quc +class Q_DECL_EXPORT Base64Helper +#else +class Base64Helper +#endif + +{ +public: + //图片转base64字符串 + static QString imageToBase64(const QImage &image); + static QByteArray imageToBase64x(const QImage &image); + + //base64字符串转图片 + static QImage base64ToImage(const QString &data); + static QImage base64ToImagex(const QByteArray &data); + + //字符串与base64互转 + static QString textToBase64(const QString &text); + static QString base64ToText(const QString &text); +}; + +#endif // BASE64HELPER_H diff --git a/ui/core_base/core_base.pri b/ui/core_base/core_base.pri new file mode 100644 index 0000000..a11faa0 --- /dev/null +++ b/ui/core_base/core_base.pri @@ -0,0 +1,64 @@ +QT += network +greaterThan(QT_MAJOR_VERSION, 4) { +lessThan(QT_MAJOR_VERSION, 6) { +android {QT += androidextras} +} else { +QT += core-private +}} + +#指定编译产生的文件分门别类放到对应目录 +MOC_DIR = temp/moc +RCC_DIR = temp/rcc +UI_DIR = temp/ui +OBJECTS_DIR = temp/obj + +#指定编译生成的可执行文件放到源码上一级目录下的bin目录 +!android { +!wasm { +DESTDIR = $$PWD/../bin +}} + +#把所有警告都关掉眼不见为净 +CONFIG += warn_off +#开启大资源支持 +CONFIG += resources_big +#开启后会将打印信息用控制台输出 +#CONFIG += console +#开启后不会生成空的 debug release 目录 +#CONFIG -= debug_and_release + +#引入全志H3芯片依赖 +include ($$PWD/h3.pri) +#将当前目录加入到头文件路径 +INCLUDEPATH += $$PWD + +HEADERS += $$PWD/appdata.h +SOURCES += $$PWD/appdata.cpp + +HEADERS += $$PWD/appinit.h +SOURCES += $$PWD/appinit.cpp + +HEADERS += $$PWD/base64helper.h +SOURCES += $$PWD/base64helper.cpp + +HEADERS += $$PWD/customstyle.h +SOURCES += $$PWD/customstyle.cpp + +HEADERS += $$PWD/iconhelper.h +SOURCES += $$PWD/iconhelper.cpp + +HEADERS += $$PWD/quihelper.h +SOURCES += $$PWD/quihelper.cpp + +#可以指定不加载对应的资源文件 +!contains(DEFINES, no_qrc_image) { +RESOURCES += $$PWD/qrc/image.qrc +} + +!contains(DEFINES, no_qrc_qm) { +RESOURCES += $$PWD/qrc/qm.qrc +} + +!contains(DEFINES, no_qrc_font) { +RESOURCES += $$PWD/qrc/font.qrc +} diff --git a/ui/core_base/customstyle.cpp b/ui/core_base/customstyle.cpp new file mode 100644 index 0000000..6ea7402 --- /dev/null +++ b/ui/core_base/customstyle.cpp @@ -0,0 +1,66 @@ +#include "customstyle.h" +#include "qapplication.h" +#include "qpalette.h" + +void CustomStyle::initStyle(int fontSize, int radioButtonSize, int checkBoxSize, int sliderHeight) +{ + if (fontSize <= 0) { + return; + } + + QStringList list; + //全局字体 + list << QString("*{font-size:%1px;}").arg(fontSize); + //单选框 + list << QString("QRadioButton::indicator{width:%1px;height:%1px;}").arg(radioButtonSize); + //复选框 + list << QString("QCheckBox::indicator,QGroupBox::indicator,QTreeWidget::indicator,QListWidget::indicator{width:%1px;height:%1px;}").arg(checkBoxSize); + + //滑块颜色 +#if 0 + QString normalColor = "#e3e3e3"; + QString grooveColor = "#0078d7"; + QString handleColor = "#FFFFFF"; + QString borderColor = "#9B9B9B"; +#else + QPalette palette; + for (int i = 0; i < 21; ++i) { + //qDebug() << i << palette.color((QPalette::ColorRole)i).name(); + } + + QString normalColor = palette.color(QPalette::Midlight).name(); + QString grooveColor = palette.color(QPalette::Highlight).name(); + QString handleColor = palette.color(QPalette::Light).name(); + QString borderColor = palette.color(QPalette::Shadow).name(); +#endif + int sliderRadius = sliderHeight / 2; + int handleWidth = (sliderHeight * 3) / 2 + (sliderHeight / 5); + int handleRadius = handleWidth / 2 + 1; + int handleOffset = handleRadius / 2; + + //横向滑块 + list << QString("QSlider::horizontal{min-height:%1px;}").arg(sliderHeight * 2); + list << QString("QSlider::groove:horizontal{background:%1;height:%2px;border-radius:%3px;}") + .arg(normalColor).arg(sliderHeight).arg(sliderRadius); + list << QString("QSlider::add-page:horizontal{background:%1;height:%2px;border-radius:%3px;}") + .arg(normalColor).arg(sliderHeight).arg(sliderRadius); + list << QString("QSlider::sub-page:horizontal{background:%1;height:%2px;border-radius:%3px;}") + .arg(grooveColor).arg(sliderHeight).arg(sliderRadius); + list << QString("QSlider::handle:horizontal{border:1px solid %5;width:%2px;margin-top:-%3px;margin-bottom:-%3px;border-radius:%4px;" + "background:qradialgradient(spread:pad,cx:0.5,cy:0.5,radius:0.5,fx:0.5,fy:0.5,stop:0.6 #FFFFFF,stop:0.8 %1);}") + .arg(handleColor).arg(handleWidth).arg(handleOffset).arg(handleRadius).arg(borderColor); + + //垂直滑块 + list << QString("QSlider::vertical{min-width:%1px;}").arg(sliderHeight * 2); + list << QString("QSlider::groove:vertical{background:%1;width:%2px;border-radius:%3px;}") + .arg(normalColor).arg(sliderHeight).arg(sliderRadius); + list << QString("QSlider::add-page:vertical{background:%1;width:%2px;border-radius:%3px;}") + .arg(grooveColor).arg(sliderHeight).arg(sliderRadius); + list << QString("QSlider::sub-page:vertical{background:%1;width:%2px;border-radius:%3px;}") + .arg(normalColor).arg(sliderHeight).arg(sliderRadius); + list << QString("QSlider::handle:vertical{border:1px solid %5;height:%2px;margin-left:-%3px;margin-right:-%3px;border-radius:%4px;" + "background:qradialgradient(spread:pad,cx:0.5,cy:0.5,radius:0.5,fx:0.5,fy:0.5,stop:0.6 #FFFFFF,stop:0.8 %1);}") + .arg(handleColor).arg(handleWidth).arg(handleOffset).arg(handleRadius).arg(borderColor); + + qApp->setStyleSheet(list.join("")); +} diff --git a/ui/core_base/customstyle.h b/ui/core_base/customstyle.h new file mode 100644 index 0000000..cdad7d5 --- /dev/null +++ b/ui/core_base/customstyle.h @@ -0,0 +1,13 @@ +#ifndef CUSTOMSTYLE_H +#define CUSTOMSTYLE_H + +#include + +class CustomStyle +{ +public: + //全局样式比如放大选择器 + static void initStyle(int fontSize = 15, int radioButtonSize = 18, int checkBoxSize = 16, int sliderHeight = 13); +}; + +#endif // CUSTOMSTYLE_H diff --git a/ui/core_base/h3.pri b/ui/core_base/h3.pri new file mode 100644 index 0000000..65ec6d1 --- /dev/null +++ b/ui/core_base/h3.pri @@ -0,0 +1,7 @@ +unix:!macx { +contains(QT_ARCH, arm) { +contains(DEFINES, arma7) { +INCLUDEPATH += /usr/local/openssl-1.0.2m-h3-gcc-4.9.2/include +LIBS += -L/usr/local/openssl-1.0.2m-h3-gcc-4.9.2/lib -lssl -lcrypto +LIBS += -L/usr/local/h3_rootfsv -lXdmcp +}}} diff --git a/ui/core_base/iconhelper.cpp b/ui/core_base/iconhelper.cpp new file mode 100644 index 0000000..1e703e6 --- /dev/null +++ b/ui/core_base/iconhelper.cpp @@ -0,0 +1,387 @@ +#include "iconhelper.h" + +IconHelper *IconHelper::iconFontAliBaBa = 0; +IconHelper *IconHelper::iconFontAwesome = 0; +IconHelper *IconHelper::iconFontAwesome6 = 0; +IconHelper *IconHelper::iconFontWeather = 0; +int IconHelper::iconFontIndex = -1; + +void IconHelper::initFont() +{ + static bool isInit = false; + if (!isInit) { + isInit = true; + if (iconFontAliBaBa == 0) { + iconFontAliBaBa = new IconHelper(":/font/iconfont.ttf", "iconfont"); + } + if (iconFontAwesome == 0) { + iconFontAwesome = new IconHelper(":/font/fontawesome-webfont.ttf", "FontAwesome"); + } + if (iconFontAwesome6 == 0) { + iconFontAwesome6 = new IconHelper(":/font/fa-regular-400.ttf", "Font Awesome 6 Pro Regular"); + } + if (iconFontWeather == 0) { + iconFontWeather = new IconHelper(":/font/pe-icon-set-weather.ttf", "pe-icon-set-weather"); + } + } +} + +void IconHelper::setIconFontIndex(int index) +{ + iconFontIndex = index; +} + +QFont IconHelper::getIconFontAliBaBa() +{ + initFont(); + return iconFontAliBaBa->getIconFont(); +} + +QFont IconHelper::getIconFontAwesome() +{ + initFont(); + return iconFontAwesome->getIconFont(); +} + +QFont IconHelper::getIconFontAwesome6() +{ + initFont(); + return iconFontAwesome6->getIconFont(); +} + +QFont IconHelper::getIconFontWeather() +{ + initFont(); + return iconFontWeather->getIconFont(); +} + +IconHelper *IconHelper::getIconHelper(int icon) +{ + initFont(); + + //指定了字体索引则取对应索引的字体类 + //没指定则自动根据不同的字体的值选择对应的类 + //由于部分值范围冲突所以可以指定索引来取 + //fontawesome 0xf000-0xf2e0 + //fontawesome6 0xe000-0xe33d 0xf000-0xf8ff + //iconfont 0xe501-0xe793 0xe8d5-0xea5d 0xeb00-0xec00 + //weather 0xe900-0xe9cf + + IconHelper *iconHelper = iconFontAwesome; + if (iconFontIndex < 0) { + if ((icon >= 0xe501 && icon <= 0xe793) || (icon >= 0xe8d5 && icon <= 0xea5d) || (icon >= 0xeb00 && icon <= 0xec00)) { + iconHelper = iconFontAliBaBa; + } + } else if (iconFontIndex == 0) { + iconHelper = iconFontAliBaBa; + } else if (iconFontIndex == 1) { + iconHelper = iconFontAwesome; + } else if (iconFontIndex == 2) { + iconHelper = iconFontAwesome6; + } else if (iconFontIndex == 3) { + iconHelper = iconFontWeather; + } + + return iconHelper; +} + +void IconHelper::setIcon(QLabel *lab, int icon, quint32 size) +{ + getIconHelper(icon)->setIcon1(lab, icon, size); +} + +void IconHelper::setIcon(QAbstractButton *btn, int icon, quint32 size) +{ + getIconHelper(icon)->setIcon1(btn, icon, size); +} + +void IconHelper::setPixmap(QAbstractButton *btn, const QColor &color, int icon, quint32 size, + quint32 width, quint32 height, int flags) +{ + getIconHelper(icon)->setPixmap1(btn, color, icon, size, width, height, flags); +} + +QPixmap IconHelper::getPixmap(const QColor &color, int icon, quint32 size, + quint32 width, quint32 height, int flags) +{ + return getIconHelper(icon)->getPixmap1(color, icon, size, width, height, flags); +} + +void IconHelper::setStyle(QWidget *widget, QList btns, + QList icons, const IconHelper::StyleColor &styleColor) +{ + int icon = icons.first(); + getIconHelper(icon)->setStyle1(widget, btns, icons, styleColor); +} + +void IconHelper::setStyle(QWidget *widget, QList btns, + QList icons, const IconHelper::StyleColor &styleColor) +{ + int icon = icons.first(); + getIconHelper(icon)->setStyle1(widget, btns, icons, styleColor); +} + +void IconHelper::setStyle(QWidget *widget, QList btns, + QList icons, const IconHelper::StyleColor &styleColor) +{ + int icon = icons.first(); + getIconHelper(icon)->setStyle1(widget, btns, icons, styleColor); +} + + +IconHelper::IconHelper(const QString &fontFile, const QString &fontName, QObject *parent) : QObject(parent) +{ + //判断图形字体是否存在,不存在则加入 + QFontDatabase fontDb; + if (!fontDb.families().contains(fontName) && QFile(fontFile).exists()) { + int fontId = fontDb.addApplicationFont(fontFile); + QStringList listName = fontDb.applicationFontFamilies(fontId); + if (listName.count() == 0) { + qDebug() << QString("load %1 error").arg(fontName); + } + } + + //再次判断是否包含字体名称防止加载失败 + if (fontDb.families().contains(fontName)) { + iconFont = QFont(fontName); +#if (QT_VERSION >= QT_VERSION_CHECK(4,8,0)) + iconFont.setHintingPreference(QFont::PreferNoHinting); +#endif + } +} + +bool IconHelper::eventFilter(QObject *watched, QEvent *event) +{ + //根据不同的 + if (watched->inherits("QAbstractButton")) { + QAbstractButton *btn = (QAbstractButton *)watched; + int index = btns.indexOf(btn); + if (index >= 0) { + //不同的事件设置不同的图标,同时区分选中的和没有选中的 + if (btn->isChecked()) { + if (event->type() == QEvent::MouseButtonPress) { + QMouseEvent *mouseEvent = (QMouseEvent *)event; + if (mouseEvent->button() == Qt::LeftButton) { + btn->setIcon(QIcon(pixChecked.at(index))); + } + } else if (event->type() == QEvent::Enter) { + btn->setIcon(QIcon(pixChecked.at(index))); + } else if (event->type() == QEvent::Leave) { + btn->setIcon(QIcon(pixChecked.at(index))); + } + } else { + if (event->type() == QEvent::MouseButtonPress) { + QMouseEvent *mouseEvent = (QMouseEvent *)event; + if (mouseEvent->button() == Qt::LeftButton) { + btn->setIcon(QIcon(pixPressed.at(index))); + } + } else if (event->type() == QEvent::Enter) { + btn->setIcon(QIcon(pixHover.at(index))); + } else if (event->type() == QEvent::Leave) { + btn->setIcon(QIcon(pixNormal.at(index))); + } + } + } + } + + return QObject::eventFilter(watched, event); +} + +void IconHelper::toggled(bool checked) +{ + //选中和不选中设置不同的图标 + QAbstractButton *btn = (QAbstractButton *)sender(); + int index = btns.indexOf(btn); + if (checked) { + btn->setIcon(QIcon(pixChecked.at(index))); + } else { + btn->setIcon(QIcon(pixNormal.at(index))); + } +} + +QFont IconHelper::getIconFont() +{ + return this->iconFont; +} + +void IconHelper::setIcon1(QLabel *lab, int icon, quint32 size) +{ + iconFont.setPixelSize(size); + lab->setFont(iconFont); + lab->setText((QChar)icon); +} + +void IconHelper::setIcon1(QAbstractButton *btn, int icon, quint32 size) +{ + iconFont.setPixelSize(size); + btn->setFont(iconFont); + btn->setText((QChar)icon); +} + +void IconHelper::setPixmap1(QAbstractButton *btn, const QColor &color, int icon, quint32 size, + quint32 width, quint32 height, int flags) +{ + btn->setIcon(getPixmap1(color, icon, size, width, height, flags)); +} + +QPixmap IconHelper::getPixmap1(const QColor &color, int icon, quint32 size, + quint32 width, quint32 height, int flags) +{ + //主动绘制图形字体到图片 + QPixmap pix(width, height); + pix.fill(Qt::transparent); + + QPainter painter; + painter.begin(&pix); + painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing); + painter.setPen(color); + + iconFont.setPixelSize(size); + painter.setFont(iconFont); + painter.drawText(pix.rect(), flags, (QChar)icon); + painter.end(); + return pix; +} + +void IconHelper::setStyle1(QWidget *widget, QList btns, QList icons, const IconHelper::StyleColor &styleColor) +{ + QList list; + foreach (QPushButton *btn, btns) { + list << btn; + } + + setStyle(widget, list, icons, styleColor); +} + +void IconHelper::setStyle1(QWidget *widget, QList btns, QList icons, const IconHelper::StyleColor &styleColor) +{ + QList list; + foreach (QToolButton *btn, btns) { + list << btn; + } + + setStyle(widget, list, icons, styleColor); +} + +void IconHelper::setStyle1(QWidget *widget, QList btns, QList icons, const IconHelper::StyleColor &styleColor) +{ + int btnCount = btns.count(); + int iconCount = icons.count(); + if (btnCount <= 0 || iconCount <= 0 || btnCount != iconCount) { + return; + } + + QString position = styleColor.position; + quint32 btnWidth = styleColor.btnWidth; + quint32 btnHeight = styleColor.btnHeight; + quint32 iconSize = styleColor.iconSize; + quint32 iconWidth = styleColor.iconWidth; + quint32 iconHeight = styleColor.iconHeight; + quint32 borderWidth = styleColor.borderWidth; + + //根据不同的位置计算边框 + QString strBorder; + if (position == "top") { + strBorder = QString("border-width:%1px 0px 0px 0px;padding-top:%1px;padding-bottom:%2px;") + .arg(borderWidth).arg(borderWidth * 2); + } else if (position == "right") { + strBorder = QString("border-width:0px %1px 0px 0px;padding-right:%1px;padding-left:%2px;") + .arg(borderWidth).arg(borderWidth * 2); + } else if (position == "bottom") { + strBorder = QString("border-width:0px 0px %1px 0px;padding-bottom:%1px;padding-top:%2px;") + .arg(borderWidth).arg(borderWidth * 2); + } else if (position == "left") { + strBorder = QString("border-width:0px 0px 0px %1px;padding-left:%1px;padding-right:%2px;") + .arg(borderWidth).arg(borderWidth * 2); + } + + //如果图标是左侧显示则需要让没有选中的按钮左侧也有加深的边框,颜色为背景颜色 + //如果图标在文字上面而设置的边框是 top bottom 也需要启用加深边框 + QStringList qss; + if (styleColor.defaultBorder) { + qss << QString("QWidget[flag=\"%1\"] QAbstractButton{border-style:solid;border-radius:0px;%2border-color:%3;color:%4;background:%5;}") + .arg(position).arg(strBorder).arg(styleColor.normalBgColor).arg(styleColor.normalTextColor).arg(styleColor.normalBgColor); + } else { + qss << QString("QWidget[flag=\"%1\"] QAbstractButton{border-style:none;border-radius:0px;padding:5px;color:%2;background:%3;}") + .arg(position).arg(styleColor.normalTextColor).arg(styleColor.normalBgColor); + } + + //悬停+按下+选中 + qss << QString("QWidget[flag=\"%1\"] QAbstractButton:hover{border-style:solid;%2border-color:%3;color:%4;background:%5;}") + .arg(position).arg(strBorder).arg(styleColor.borderColor).arg(styleColor.hoverTextColor).arg(styleColor.hoverBgColor); + qss << QString("QWidget[flag=\"%1\"] QAbstractButton:pressed{border-style:solid;%2border-color:%3;color:%4;background:%5;}") + .arg(position).arg(strBorder).arg(styleColor.borderColor).arg(styleColor.pressedTextColor).arg(styleColor.pressedBgColor); + qss << QString("QWidget[flag=\"%1\"] QAbstractButton:checked{border-style:solid;%2border-color:%3;color:%4;background:%5;}") + .arg(position).arg(strBorder).arg(styleColor.borderColor).arg(styleColor.checkedTextColor).arg(styleColor.checkedBgColor); + + //窗体背景颜色+按钮背景颜色 + qss << QString("QWidget#%1{background:%2;}") + .arg(widget->objectName()).arg(styleColor.normalBgColor); + qss << QString("QWidget>QAbstractButton{border-width:0px;background-color:%1;color:%2;}") + .arg(styleColor.normalBgColor).arg(styleColor.normalTextColor); + qss << QString("QWidget>QAbstractButton:hover{background-color:%1;color:%2;}") + .arg(styleColor.hoverBgColor).arg(styleColor.hoverTextColor); + qss << QString("QWidget>QAbstractButton:pressed{background-color:%1;color:%2;}") + .arg(styleColor.pressedBgColor).arg(styleColor.pressedTextColor); + qss << QString("QWidget>QAbstractButton:checked{background-color:%1;color:%2;}") + .arg(styleColor.checkedBgColor).arg(styleColor.checkedTextColor); + + //按钮宽度高度 + if (btnWidth > 0) { + qss << QString("QWidget>QAbstractButton{min-width:%1px;}").arg(btnWidth); + } + if (btnHeight > 0) { + qss << QString("QWidget>QAbstractButton{min-height:%1px;}").arg(btnHeight); + } + + //设置样式表 + widget->setStyleSheet(qss.join("")); + + //可能会重复调用设置所以先要移除上一次的 + for (int i = 0; i < btnCount; ++i) { + for (int j = 0; j < this->btns.count(); j++) { + if (this->btns.at(j) == btns.at(i)) { + disconnect(btns.at(i), SIGNAL(toggled(bool)), this, SLOT(toggled(bool))); + this->btns.at(j)->removeEventFilter(this); + this->btns.removeAt(j); + this->pixNormal.removeAt(j); + this->pixHover.removeAt(j); + this->pixPressed.removeAt(j); + this->pixChecked.removeAt(j); + break; + } + } + } + + //存储对应按钮对象,方便鼠标移上去的时候切换图片 + int checkedIndex = -1; + for (int i = 0; i < btnCount; ++i) { + int icon = icons.at(i); + QPixmap pixNormal = getPixmap1(styleColor.normalTextColor, icon, iconSize, iconWidth, iconHeight); + QPixmap pixHover = getPixmap1(styleColor.hoverTextColor, icon, iconSize, iconWidth, iconHeight); + QPixmap pixPressed = getPixmap1(styleColor.pressedTextColor, icon, iconSize, iconWidth, iconHeight); + QPixmap pixChecked = getPixmap1(styleColor.checkedTextColor, icon, iconSize, iconWidth, iconHeight); + + //记住最后选中的按钮 + QAbstractButton *btn = btns.at(i); + if (btn->isChecked()) { + checkedIndex = i; + } + + btn->setIcon(QIcon(pixNormal)); + btn->setIconSize(QSize(iconWidth, iconHeight)); + btn->installEventFilter(this); + connect(btn, SIGNAL(toggled(bool)), this, SLOT(toggled(bool))); + + this->btns << btn; + this->pixNormal << pixNormal; + this->pixHover << pixHover; + this->pixPressed << pixPressed; + this->pixChecked << pixChecked; + } + + //主动触发一下选中的按钮 + if (checkedIndex >= 0) { + QMetaObject::invokeMethod(btns.at(checkedIndex), "toggled", Q_ARG(bool, true)); + } +} diff --git a/ui/core_base/iconhelper.h b/ui/core_base/iconhelper.h new file mode 100644 index 0000000..adcf69e --- /dev/null +++ b/ui/core_base/iconhelper.h @@ -0,0 +1,189 @@ +#ifndef ICONHELPER_H +#define ICONHELPER_H + +/** + * 超级图形字体类 作者:feiyangqingyun(QQ:517216493) 2016-11-23 + * 1. 可传入多种图形字体文件,一个类通用所有图形字体。 + * 2. 默认已经内置了阿里巴巴图形字体FontAliBaBa、国际知名图形字体FontAwesome、天气图形字体FontWeather。 + * 3. 可设置 QLabel、QAbstractButton 文本为图形字体。 + * 4. 可设置图形字体作为 QAbstractButton 按钮图标。 + * 5. 内置万能的方法 getPixmap 将图形字体值转换为图片。 + * 6. 无论是设置文本、图标、图片等都可以设置图标的大小、尺寸、颜色等参数。 + * 7. 内置超级导航栏样式设置,将图形字体作为图标设置到按钮。 + * 8. 支持各种颜色设置比如正常颜色、悬停颜色、按下颜色、选中颜色。 + * 9. 可设置导航的位置为 left、right、top、bottom 四种。 + * 10. 可设置导航加深边框颜色和粗细大小。 + * 11. 导航面板的各种切换效果比如鼠标悬停、按下、选中等都自动处理掉样式设置。 + * 12. 全局静态方法,接口丰富,使用极其简单方便。 + */ + +#include +#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0)) +#include +#endif + +#ifdef quc +class Q_DECL_EXPORT IconHelper : public QObject +#else +class IconHelper : public QObject +#endif + +{ + Q_OBJECT + +private: + //阿里巴巴图形字体类 + static IconHelper *iconFontAliBaBa; + //FontAwesome图形字体类 + static IconHelper *iconFontAwesome; + //FontAwesome6图形字体类 + static IconHelper *iconFontAwesome6; + //天气图形字体类 + static IconHelper *iconFontWeather; + //图形字体索引 + static int iconFontIndex; + +public: + //样式颜色结构体 + struct StyleColor { + QString position; //位置 left right top bottom + bool defaultBorder; //默认有边框 + + quint32 btnWidth; //按钮宽度 + quint32 btnHeight; //按钮高度 + + quint32 iconSize; //图标字体尺寸 + quint32 iconWidth; //图标图片宽度 + quint32 iconHeight; //图标图片高度 + + quint32 borderWidth; //边框宽度 + QString borderColor; //边框颜色 + + QString normalBgColor; //正常背景颜色 + QString normalTextColor; //正常文字颜色 + QString hoverBgColor; //悬停背景颜色 + QString hoverTextColor; //悬停文字颜色 + QString pressedBgColor; //按下背景颜色 + QString pressedTextColor; //按下文字颜色 + QString checkedBgColor; //选中背景颜色 + QString checkedTextColor; //选中文字颜色 + + StyleColor() { + position = "left"; + defaultBorder = false; + + btnWidth = 0; + btnHeight = 0; + + iconSize = 12; + iconWidth = 15; + iconHeight = 15; + + borderWidth = 3; + borderColor = "#029FEA"; + + normalBgColor = "#292F38"; + normalTextColor = "#54626F"; + hoverBgColor = "#40444D"; + hoverTextColor = "#FDFDFD"; + pressedBgColor = "#404244"; + pressedTextColor = "#FDFDFD"; + checkedBgColor = "#44494F"; + checkedTextColor = "#FDFDFD"; + } + + //设置常规颜色 普通状态+加深状态 + void setColor(const QString &normalBgColor, + const QString &normalTextColor, + const QString &darkBgColor, + const QString &darkTextColor) { + this->normalBgColor = normalBgColor; + this->normalTextColor = normalTextColor; + this->hoverBgColor = darkBgColor; + this->hoverTextColor = darkTextColor; + this->pressedBgColor = darkBgColor; + this->pressedTextColor = darkTextColor; + this->checkedBgColor = darkBgColor; + this->checkedTextColor = darkTextColor; + } + }; + + + //初始化图形字体 + static void initFont(); + //设置引用图形字体文件索引 + static void setIconFontIndex(int index); + + //获取图形字体 + static QFont getIconFontAliBaBa(); + static QFont getIconFontAwesome(); + static QFont getIconFontAwesome6(); + static QFont getIconFontWeather(); + + //根据值获取图形字体类 + static IconHelper *getIconHelper(int icon); + + //设置图形字体到标签 + static void setIcon(QLabel *lab, int icon, quint32 size = 12); + //设置图形字体到按钮 + static void setIcon(QAbstractButton *btn, int icon, quint32 size = 12); + + //设置图形字体到图标 + static void setPixmap(QAbstractButton *btn, const QColor &color, + int icon, quint32 size = 12, + quint32 width = 15, quint32 height = 15, + int flags = Qt::AlignCenter); + //获取指定图形字体,可以指定文字大小,图片宽高,文字对齐 + static QPixmap getPixmap(const QColor &color, int icon, quint32 size = 12, + quint32 width = 15, quint32 height = 15, + int flags = Qt::AlignCenter); + + //指定导航面板样式,带图标和效果切换+悬停颜色+按下颜色+选中颜色 + static void setStyle(QWidget *widget, QList btns, QList icons, const StyleColor &styleColor); + static void setStyle(QWidget *widget, QList btns, QList icons, const StyleColor &styleColor); + static void setStyle(QWidget *widget, QList btns, QList icons, const StyleColor &styleColor); + + //默认构造函数,传入字体文件+字体名称 + explicit IconHelper(const QString &fontFile, const QString &fontName, QObject *parent = 0); + +protected: + bool eventFilter(QObject *watched, QEvent *event); + +private: + QFont iconFont; //图形字体 + QList btns; //按钮队列 + QList pixNormal; //正常图片队列 + QList pixHover; //悬停图片队列 + QList pixPressed; //按下图片队列 + QList pixChecked; //选中图片队列 + +private slots: + //按钮选中状态切换处理 + void toggled(bool checked); + +public: + //获取图形字体 + QFont getIconFont(); + + //设置图形字体到标签 + void setIcon1(QLabel *lab, int icon, quint32 size = 12); + //设置图形字体到按钮 + void setIcon1(QAbstractButton *btn, int icon, quint32 size = 12); + + //设置图形字体到图标 + void setPixmap1(QAbstractButton *btn, const QColor &color, + int icon, quint32 size = 12, + quint32 width = 15, quint32 height = 15, + int flags = Qt::AlignCenter); + //获取指定图形字体,可以指定文字大小,图片宽高,文字对齐 + QPixmap getPixmap1(const QColor &color, int icon, quint32 size = 12, + quint32 width = 15, quint32 height = 15, + int flags = Qt::AlignCenter); + + //指定导航面板样式,带图标和效果切换+悬停颜色+按下颜色+选中颜色 + void setStyle1(QWidget *widget, QList btns, QList icons, const StyleColor &styleColor); + void setStyle1(QWidget *widget, QList btns, QList icons, const StyleColor &styleColor); + void setStyle1(QWidget *widget, QList btns, QList icons, const StyleColor &styleColor); +}; + +#endif // ICONHELPER_H diff --git a/ui/core_base/qrc/font.qrc b/ui/core_base/qrc/font.qrc new file mode 100644 index 0000000..9f303b2 --- /dev/null +++ b/ui/core_base/qrc/font.qrc @@ -0,0 +1,7 @@ + + + font/fontawesome-webfont.ttf + font/iconfont.ttf + font/pe-icon-set-weather.ttf + + diff --git a/ui/core_base/qrc/font/fontawesome-webfont.ttf b/ui/core_base/qrc/font/fontawesome-webfont.ttf new file mode 100644 index 0000000..35acda2 Binary files /dev/null and b/ui/core_base/qrc/font/fontawesome-webfont.ttf differ diff --git a/ui/core_base/qrc/font/iconfont.ttf b/ui/core_base/qrc/font/iconfont.ttf new file mode 100644 index 0000000..4757471 Binary files /dev/null and b/ui/core_base/qrc/font/iconfont.ttf differ diff --git a/ui/core_base/qrc/font/pe-icon-set-weather.ttf b/ui/core_base/qrc/font/pe-icon-set-weather.ttf new file mode 100644 index 0000000..eb6f8e5 Binary files /dev/null and b/ui/core_base/qrc/font/pe-icon-set-weather.ttf differ diff --git a/ui/core_base/qrc/image.qrc b/ui/core_base/qrc/image.qrc new file mode 100644 index 0000000..458c609 --- /dev/null +++ b/ui/core_base/qrc/image.qrc @@ -0,0 +1,5 @@ + + + image/bg_novideo.png + + diff --git a/ui/core_base/qrc/image/bg_novideo.png b/ui/core_base/qrc/image/bg_novideo.png new file mode 100644 index 0000000..510dfb8 Binary files /dev/null and b/ui/core_base/qrc/image/bg_novideo.png differ diff --git a/ui/core_base/qrc/qm.qrc b/ui/core_base/qrc/qm.qrc new file mode 100644 index 0000000..d14db1a --- /dev/null +++ b/ui/core_base/qrc/qm.qrc @@ -0,0 +1,6 @@ + + + qm/qt_zh_CN.qm + qm/widgets.qm + + diff --git a/ui/core_base/qrc/qm/qt_zh_CN.qm b/ui/core_base/qrc/qm/qt_zh_CN.qm new file mode 100644 index 0000000..623b8e3 Binary files /dev/null and b/ui/core_base/qrc/qm/qt_zh_CN.qm differ diff --git a/ui/core_base/qrc/qm/widgets.qm b/ui/core_base/qrc/qm/widgets.qm new file mode 100644 index 0000000..244bf0d Binary files /dev/null and b/ui/core_base/qrc/qm/widgets.qm differ diff --git a/ui/core_base/quihelper.cpp b/ui/core_base/quihelper.cpp new file mode 100644 index 0000000..82144ee --- /dev/null +++ b/ui/core_base/quihelper.cpp @@ -0,0 +1,1006 @@ +#include "quihelper.h" +#include "qnetworkinterface.h" +#include "qnetworkproxy.h" + +#define TIMEMS qPrintable(QTime::currentTime().toString("HH:mm:ss zzz")) + +int QUIHelper::getScreenIndex() +{ + //需要对多个屏幕进行处理 + int screenIndex = 0; +#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0)) + int screenCount = qApp->screens().size(); +#else + int screenCount = qApp->desktop()->screenCount(); +#endif + + if (screenCount > 1) { + //找到当前鼠标所在屏幕 + QPoint pos = QCursor::pos(); + for (int i = 0; i < screenCount; ++i) { +#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0)) + if (qApp->screens().at(i)->geometry().contains(pos)) { +#else + if (qApp->desktop()->screenGeometry(i).contains(pos)) { +#endif + screenIndex = i; + break; + } + } + } + return screenIndex; +} + +QRect QUIHelper::getScreenRect(bool available) +{ + QRect rect; + int screenIndex = QUIHelper::getScreenIndex(); + if (available) { +#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0)) + rect = qApp->screens().at(screenIndex)->availableGeometry(); +#else + rect = qApp->desktop()->availableGeometry(screenIndex); +#endif + } else { +#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0)) + rect = qApp->screens().at(screenIndex)->geometry(); +#else + rect = qApp->desktop()->screenGeometry(screenIndex); +#endif + } + return rect; +} + +qreal QUIHelper::getScreenRatio(bool devicePixel) +{ + qreal ratio = 1.0; + int screenIndex = getScreenIndex(); +#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0)) + QScreen *screen = qApp->screens().at(screenIndex); + if (devicePixel) { + //需要开启 AA_EnableHighDpiScaling 属性才能正常获取 + ratio = screen->devicePixelRatio() * 100; + } else { + ratio = screen->logicalDotsPerInch(); + } +#else + //Qt4不能动态识别缩放更改后的值 + ratio = qApp->desktop()->screen(screenIndex)->logicalDpiX(); +#endif + return ratio / 96; +} + +QRect QUIHelper::checkCenterRect(QRect &rect, bool available) +{ + QRect deskRect = QUIHelper::getScreenRect(available); + int formWidth = rect.width(); + int formHeight = rect.height(); + int deskWidth = deskRect.width(); + int deskHeight = deskRect.height(); + int formX = deskWidth / 2 - formWidth / 2 + deskRect.x(); + int formY = deskHeight / 2 - formHeight / 2; + rect = QRect(formX, formY, formWidth, formHeight); + return deskRect; +} + +int QUIHelper::deskWidth() +{ + return getScreenRect().width(); +} + +int QUIHelper::deskHeight() +{ + return getScreenRect().height(); +} + +QSize QUIHelper::deskSize() +{ + return getScreenRect().size(); +} + +QWidget *QUIHelper::centerBaseForm = 0; +void QUIHelper::setFormInCenter(QWidget *form) +{ + int formWidth = form->width(); + int formHeight = form->height(); + + //如果=0表示采用系统桌面屏幕为参照 + QRect rect; + if (centerBaseForm == 0) { + rect = getScreenRect(); + } else { + rect = centerBaseForm->geometry(); + } + + int deskWidth = rect.width(); + int deskHeight = rect.height(); + QPoint movePoint(deskWidth / 2 - formWidth / 2 + rect.x(), deskHeight / 2 - formHeight / 2 + rect.y()); + form->move(movePoint); +} + +void QUIHelper::showForm(QWidget *form) +{ + setFormInCenter(form); + form->show(); + + //判断宽高是否超过了屏幕分辨率,超过了则最大化显示 + //qDebug() << TIMEMS << form->size() << deskSize(); + if (form->width() + 20 > deskWidth() || form->height() + 50 > deskHeight()) { + QMetaObject::invokeMethod(form, "showMaximized", Qt::QueuedConnection); + } +} + +QString QUIHelper::appName() +{ + //没有必要每次都获取,只有当变量为空时才去获取一次 + static QString name; + if (name.isEmpty()) { + name = qApp->applicationFilePath(); + //下面的方法主要为了过滤安卓的路径 lib程序名_armeabi-v7a/lib程序名_arm64-v8a + QStringList list = name.split("/"); + name = list.at(list.size() - 1).split(".").at(0); + name.replace("_armeabi-v7a", ""); + name.replace("_arm64-v8a", ""); + } + + return name; +} + +QString QUIHelper::appPath() +{ + static QString path; + if (path.isEmpty()) { +#ifdef Q_OS_ANDROID + //默认安卓根目录 + path = "/storage/emulated/0"; + //带上程序名称作为目录 前面加个0方便排序 + path = path + "/0" + appName(); +#else + path = qApp->applicationDirPath(); +#endif + } + + return path; +} + +QStringList QUIHelper::getLocalIPs() +{ + static QStringList ips; + if (ips.size() == 0) { +#ifdef Q_OS_WASM + ips << "127.0.0.1"; +#else + QList netInterfaces = QNetworkInterface::allInterfaces(); + foreach (QNetworkInterface netInterface, netInterfaces) { + //移除虚拟机和抓包工具的虚拟网卡 + QString humanReadableName = netInterface.humanReadableName().toLower(); + if (humanReadableName.startsWith("vmware network adapter") || humanReadableName.startsWith("npcap loopback adapter")) { + continue; + } + + //过滤当前网络接口 + bool flag = (netInterface.flags() == (QNetworkInterface::IsUp | QNetworkInterface::IsRunning | QNetworkInterface::CanBroadcast | QNetworkInterface::CanMulticast)); + if (!flag) { + continue; + } + + QList addrs = netInterface.addressEntries(); + foreach (QNetworkAddressEntry addr, addrs) { + //只取出IPV4的地址 + if (addr.ip().protocol() != QAbstractSocket::IPv4Protocol) { + continue; + } + + QString ip4 = addr.ip().toString(); + if (ip4 != "127.0.0.1") { + ips << ip4; + } + } + } +#endif + } + + return ips; +} + +QList QUIHelper::colors = QList(); +QList QUIHelper::getColorList() +{ + //备用颜色集合 可以自行添加 + if (colors.size() == 0) { + colors << QColor(0, 176, 180) << QColor(0, 113, 193) << QColor(255, 192, 0); + colors << QColor(72, 103, 149) << QColor(185, 87, 86) << QColor(0, 177, 125); + colors << QColor(214, 77, 84) << QColor(71, 164, 233) << QColor(34, 163, 169); + colors << QColor(59, 123, 156) << QColor(162, 121, 197) << QColor(72, 202, 245); + colors << QColor(0, 150, 121) << QColor(111, 9, 176) << QColor(250, 170, 20); + } + + return colors; +} + +QStringList QUIHelper::getColorNames() +{ + QList colors = getColorList(); + QStringList colorNames; + foreach (QColor color, colors) { + colorNames << color.name(); + } + return colorNames; +} + +QColor QUIHelper::getRandColor() +{ + QList colors = getColorList(); + int index = getRandValue(0, colors.size(), true); + return colors.at(index); +} + +void QUIHelper::initRand() +{ + //初始化随机数种子 + QTime t = QTime::currentTime(); + srand(t.msec() + t.second() * 1000); +} + +float QUIHelper::getRandFloat(float min, float max) +{ + double diff = fabs(max - min); + double value = (double)(rand() % 100) / 100; + value = min + value * diff; + return value; +} + +double QUIHelper::getRandValue(int min, int max, bool contansMin, bool contansMax) +{ + int value; +#if (QT_VERSION <= QT_VERSION_CHECK(5,10,0)) + //通用公式 a是起始值,n是整数的范围 + //int value = a + rand() % n; + if (contansMin) { + if (contansMax) { + value = min + 0 + (rand() % (max - min + 1)); + } else { + value = min + 0 + (rand() % (max - min + 0)); + } + } else { + if (contansMax) { + value = min + 1 + (rand() % (max - min + 0)); + } else { + value = min + 1 + (rand() % (max - min - 1)); + } + } +#else + if (contansMin) { + if (contansMax) { + value = QRandomGenerator::global()->bounded(min + 0, max + 1); + } else { + value = QRandomGenerator::global()->bounded(min + 0, max + 0); + } + } else { + if (contansMax) { + value = QRandomGenerator::global()->bounded(min + 1, max + 1); + } else { + value = QRandomGenerator::global()->bounded(min + 1, max + 0); + } + } +#endif + return value; +} + +QStringList QUIHelper::getRandPoint(int count, float mainLng, float mainLat, float dotLng, float dotLat) +{ + //随机生成点坐标 + QStringList points; + for (int i = 0; i < count; ++i) { + //0.00881415 0.000442928 +#if (QT_VERSION >= QT_VERSION_CHECK(5,10,0)) + float lngx = QRandomGenerator::global()->bounded(dotLng); + float latx = QRandomGenerator::global()->bounded(dotLat); +#else + float lngx = getRandFloat(dotLng / 10, dotLng); + float latx = getRandFloat(dotLat / 10, dotLat); +#endif + //需要先用精度转换成字符串 + QString lng2 = QString::number(mainLng + lngx, 'f', 8); + QString lat2 = QString::number(mainLat + latx, 'f', 8); + QString point = QString("%1,%2").arg(lng2).arg(lat2); + points << point; + } + + return points; +} + +int QUIHelper::getRangeValue(int oldMin, int oldMax, int oldValue, int newMin, int newMax) +{ + return (((oldValue - oldMin) * (newMax - newMin)) / (oldMax - oldMin)) + newMin; +} + +QString QUIHelper::getUuid() +{ + QString uuid = QUuid::createUuid().toString(); + uuid.replace("{", ""); + uuid.replace("}", ""); + return uuid; +} + +void QUIHelper::checkPath(const QString &dirName) +{ + //相对路径需要补全完整路径 + QString path = dirName; + if (path.startsWith("./")) { + path.replace(".", ""); + path = QUIHelper::appPath() + path; + } else if (!path.startsWith("/") && !path.contains(":/")) { + path = QUIHelper::appPath() + "/" + path; + } + + //目录不存在则新建 + QDir dir(path); + if (!dir.exists()) { + dir.mkpath(path); + } +} + +void QUIHelper::sleep(int msec) +{ + if (msec <= 0) { + return; + } + +#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0)) + QThread::msleep(msec); +#else + QTime endTime = QTime::currentTime().addMSecs(msec); + while (QTime::currentTime() < endTime) { + QCoreApplication::processEvents(QEventLoop::AllEvents, 100); + } +#endif +} + +void QUIHelper::setStyle() +{ + //打印下所有内置风格的名字 + qDebug() << TIMEMS << "QStyleFactory::keys" << QStyleFactory::keys(); + //设置内置风格 +#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0)) + qApp->setStyle(QStyleFactory::create("Fusion")); +#else + qApp->setStyle(QStyleFactory::create("Cleanlooks")); +#endif + + //设置指定颜色 + QPalette palette; + palette.setBrush(QPalette::Window, QColor("#F0F0F0")); + qApp->setPalette(palette); +} + +QFont QUIHelper::addFont(const QString &fontFile, const QString &fontName) +{ + //判断图形字体是否存在,不存在则加入 + QFontDatabase fontDb; + if (!fontDb.families().contains(fontName)) { + int fontId = fontDb.addApplicationFont(fontFile); + QStringList listName = fontDb.applicationFontFamilies(fontId); + if (listName.size() == 0) { + qDebug() << QString("load %1 error").arg(fontName); + } + } + + //再次判断是否包含字体名称防止加载失败 + QFont font; + if (fontDb.families().contains(fontName)) { + font = QFont(fontName); +#if (QT_VERSION >= QT_VERSION_CHECK(4,8,0)) + font.setHintingPreference(QFont::PreferNoHinting); +#endif + } + + return font; +} + +void QUIHelper::setFont(int fontSize) +{ +#ifdef rk3399 + return; +#endif + //安卓套件在有些手机上默认字体不好看需要主动设置字体 + //网页套件需要主动加载中文字体才能正常显示中文 +#if (defined Q_OS_ANDROID) || (defined Q_OS_WASM) + QString fontFile = ":/font/DroidSansFallback.ttf"; + QString fontName = "Droid Sans Fallback"; + qApp->setFont(addFont(fontFile, fontName)); + return; +#endif + +#ifdef __arm__ + fontSize = 25; +#endif +#ifdef Q_OS_ANDROID + fontSize = 15; +#endif + + QFont font; + font.setFamily("MicroSoft Yahei"); + font.setPixelSize(fontSize); + qApp->setFont(font); +} + +void QUIHelper::setCode(bool utf8) +{ +#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0)) + //如果想要控制台打印信息中文正常就注释掉这个设置 + if (utf8) { + QTextCodec *codec = QTextCodec::codecForName("utf-8"); + QTextCodec::setCodecForLocale(codec); + } +#else +#if _MSC_VER + QTextCodec *codec = QTextCodec::codecForName("gbk"); +#else + QTextCodec *codec = QTextCodec::codecForName("utf-8"); +#endif + QTextCodec::setCodecForLocale(codec); + QTextCodec::setCodecForCStrings(codec); + QTextCodec::setCodecForTr(codec); +#endif +} + +void QUIHelper::setTranslator(const QString &qmFile) +{ + //过滤下不存在的就不用设置了 + if (!QFile(qmFile).exists()) { + return; + } + + QTranslator *translator = new QTranslator(qApp); + if (translator->load(qmFile)) { + qApp->installTranslator(translator); + } +} + +#ifdef Q_OS_ANDROID +#if (QT_VERSION < QT_VERSION_CHECK(6,0,0)) +#include +#else +//Qt6中将相关类移到了core模块而且名字变了 +#include +#endif +#endif + +bool QUIHelper::checkPermission(const QString &permission) +{ +#ifdef Q_OS_ANDROID +#if (QT_VERSION >= QT_VERSION_CHECK(5,10,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)) + QtAndroid::PermissionResult result = QtAndroid::checkPermission(permission); + if (result == QtAndroid::PermissionResult::Denied) { + QtAndroid::requestPermissionsSync(QStringList() << permission); + result = QtAndroid::checkPermission(permission); + if (result == QtAndroid::PermissionResult::Denied) { + return false; + } + } +#else + QFuture result = QtAndroidPrivate::requestPermission(permission); + if (result.resultAt(0) == QtAndroidPrivate::PermissionResult::Denied) { + return false; + } +#endif +#endif + return true; +} + +void QUIHelper::initAndroidPermission() +{ + //可以把所有要动态申请的权限都写在这里 + checkPermission("android.permission.CALL_PHONE"); + checkPermission("android.permission.SEND_SMS"); + checkPermission("android.permission.CAMERA"); + checkPermission("android.permission.READ_EXTERNAL_STORAGE"); + checkPermission("android.permission.WRITE_EXTERNAL_STORAGE"); + + checkPermission("android.permission.ACCESS_COARSE_LOCATION"); + checkPermission("android.permission.BLUETOOTH"); + checkPermission("android.permission.BLUETOOTH_SCAN"); + checkPermission("android.permission.BLUETOOTH_CONNECT"); + checkPermission("android.permission.BLUETOOTH_ADVERTISE"); +} + +void QUIHelper::initAll(bool utf8, bool style, int fontSize) +{ + //初始化安卓权限 + QUIHelper::initAndroidPermission(); + //初始化随机数种子 + QUIHelper::initRand(); + //设置编码 + QUIHelper::setCode(utf8); + //设置字体 + QUIHelper::setFont(fontSize); + //设置样式风格 + if (style) { + QUIHelper::setStyle(); + } + + //设置翻译文件支持多个 + QUIHelper::setTranslator(":/qm/widgets.qm"); + QUIHelper::setTranslator(":/qm/qt_zh_CN.qm"); + QUIHelper::setTranslator(":/qm/designer_zh_CN.qm"); + + //设置不使用本地系统环境代理配置 + QNetworkProxyFactory::setUseSystemConfiguration(false); +} + +void QUIHelper::initMain(bool desktopSettingsAware, bool useOpenGLES) +{ + //设置是否应用操作系统设置比如字体 + QApplication::setDesktopSettingsAware(desktopSettingsAware); + +#ifdef Q_OS_ANDROID +#if (QT_VERSION >= QT_VERSION_CHECK(5,6,0)) + //开启高分屏缩放支持 + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); +#endif +#else +#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0)) + //不应用任何缩放 + QApplication::setAttribute(Qt::AA_Use96Dpi); +#endif +#endif + +#if (QT_VERSION >= QT_VERSION_CHECK(5,14,0)) + //高分屏缩放策略 + QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::Floor); +#endif + +#if (QT_VERSION >= QT_VERSION_CHECK(5,4,0)) + //win上获取显卡是否被禁用(禁用则必须启用OpenGLES) +#ifdef Q_OS_WIN + QProcess p; + QStringList args; + args << "path" << "win32_VideoController" << "get" << "name,Status"; + p.start("wmic", args); + p.waitForFinished(1000); + QString result = QString::fromLocal8Bit(p.readAllStandardOutput()); + result.replace("\r", ""); + result.replace("\n", ""); + result = result.simplified(); + result = result.trimmed(); + //Name Status Intel(R) UHD Graphics 630 OK + //Name Status Intel(R) UHD Graphics 630 Error + //QStringList list = result.split(" "); + if (result.contains("Error")) { + useOpenGLES = true; + } +#endif + + //设置opengl模式 AA_UseDesktopOpenGL(默认) AA_UseOpenGLES AA_UseSoftwareOpenGL + //在一些很旧的设备上或者对opengl支持很低的设备上需要使用AA_UseOpenGLES表示禁用硬件加速 + //如果开启的是AA_UseOpenGLES则无法使用硬件加速比如ffmpeg的dxva2 + if (useOpenGLES) { + QApplication::setAttribute(Qt::AA_UseOpenGLES); + } + + //设置opengl共享上下文 + QApplication::setAttribute(Qt::AA_ShareOpenGLContexts); +#endif +} + +QVector QUIHelper::msgTypes = QVector() << 0 << 1 << 2 << 3 << 4; +QVector QUIHelper::msgKeys = QVector() << QString::fromUtf8("发送") << QString::fromUtf8("接收") << QString::fromUtf8("解析") << QString::fromUtf8("错误") << QString::fromUtf8("提示"); +QVector QUIHelper::msgColors = QVector() << QColor("#3BA372") << QColor("#EE6668") << QColor("#9861B4") << QColor("#FA8359") << QColor("#22A3A9"); +QString QUIHelper::appendMsg(QTextEdit *textEdit, int type, const QString &data, int maxCount, int ¤tCount, bool clear, bool pause) +{ + if (clear) { + textEdit->clear(); + currentCount = 0; + return QString(); + } + + if (pause) { + return QString(); + } + + if (currentCount >= maxCount) { + textEdit->clear(); + currentCount = 0; + } + + //不同类型不同颜色显示 + QString strType; + int index = msgTypes.indexOf(type); + if (index >= 0) { + strType = msgKeys.at(index); + textEdit->setTextColor(msgColors.at(index)); + } + + //过滤回车换行符 + QString strData = data; + strData.replace("\r", ""); + strData.replace("\n", ""); + strData = QString("时间[%1] %2: %3").arg(TIMEMS).arg(strType).arg(strData); + textEdit->append(strData); + currentCount++; + return strData; +} + +void QUIHelper::setFramelessForm(QWidget *widgetMain, bool tool, bool top, bool menu) +{ + widgetMain->setProperty("form", true); + widgetMain->setProperty("canMove", true); + + //根据设定逐个追加属性 +#ifdef __arm__ + widgetMain->setWindowFlags(Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint); +#else + widgetMain->setWindowFlags(Qt::FramelessWindowHint); +#endif + if (tool) { + widgetMain->setWindowFlags(widgetMain->windowFlags() | Qt::Tool); + } + if (top) { + widgetMain->setWindowFlags(widgetMain->windowFlags() | Qt::WindowStaysOnTopHint); + } + if (menu) { + //如果是其他系统比如neokylin会产生系统边框 +#ifdef Q_OS_WIN + widgetMain->setWindowFlags(widgetMain->windowFlags() | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint); +#endif + } +} + +int QUIHelper::showMessageBox(const QString &text, int type, int closeSec, bool exec) +{ + int result = 0; + if (type == 0) { + showMessageBoxInfo(text, closeSec, exec); + } else if (type == 1) { + showMessageBoxError(text, closeSec, exec); + } else if (type == 2) { + result = showMessageBoxQuestion(text); + } + + return result; +} + +void QUIHelper::showMessageBoxInfo(const QString &text, int closeSec, bool exec) +{ + QMessageBox box(QMessageBox::Information, "提示", text); + box.setStandardButtons(QMessageBox::Yes); + box.setButtonText(QMessageBox::Yes, QString("确 定")); + box.exec(); + //QMessageBox::information(0, "提示", info, QMessageBox::Yes); +} + +void QUIHelper::showMessageBoxError(const QString &text, int closeSec, bool exec) +{ + QMessageBox box(QMessageBox::Critical, "错误", text); + box.setStandardButtons(QMessageBox::Yes); + box.setButtonText(QMessageBox::Yes, QString("确 定")); + box.exec(); + //QMessageBox::critical(0, "错误", info, QMessageBox::Yes); +} + +int QUIHelper::showMessageBoxQuestion(const QString &text) +{ + QMessageBox box(QMessageBox::Question, "询问", text); + box.setStandardButtons(QMessageBox::Yes | QMessageBox::No); + box.setButtonText(QMessageBox::Yes, QString("确 定")); + box.setButtonText(QMessageBox::No, QString("取 消")); + return box.exec(); + //return QMessageBox::question(0, "询问", info, QMessageBox::Yes | QMessageBox::No); +} + +void QUIHelper::initDialog(QFileDialog *dialog, const QString &title, const QString &acceptName, + const QString &dirName, bool native, int width, int height) +{ + //设置标题 + dialog->setWindowTitle(title); + //设置标签文本 + dialog->setLabelText(QFileDialog::Accept, acceptName); + dialog->setLabelText(QFileDialog::Reject, "取消(&C)"); + dialog->setLabelText(QFileDialog::LookIn, "查看"); + dialog->setLabelText(QFileDialog::FileName, "名称"); + dialog->setLabelText(QFileDialog::FileType, "类型"); + + //设置默认显示目录 + if (!dirName.isEmpty()) { + dialog->setDirectory(dirName); + } + + //设置对话框宽高 + if (width > 0 && height > 0) { +#ifdef Q_OS_ANDROID + bool horizontal = (QUIHelper::deskWidth() > QUIHelper::deskHeight()); + if (horizontal) { + width = QUIHelper::deskWidth() / 2; + height = QUIHelper::deskHeight() - 50; + } else { + width = QUIHelper::deskWidth() - 10; + height = QUIHelper::deskHeight() / 2; + } +#endif + dialog->setFixedSize(width, height); + } + + //设置是否采用本地对话框 + dialog->setOption(QFileDialog::DontUseNativeDialog, !native); + //设置只读可以取消右上角的新建按钮 + //dialog->setReadOnly(true); +} + +QString QUIHelper::getDialogResult(QFileDialog *dialog) +{ + QString result; + if (dialog->exec() == QFileDialog::Accepted) { + result = dialog->selectedFiles().first(); + } + return result; +} + +QString QUIHelper::getOpenFileName(const QString &filter, const QString &dirName, const QString &fileName, + bool native, int width, int height) +{ + QFileDialog dialog; + initDialog(&dialog, "打开文件", "选择(&S)", dirName, native, width, height); + + //设置文件类型 + if (!filter.isEmpty()) { + dialog.setNameFilter(filter); + } + + //设置默认文件名称 + dialog.selectFile(fileName); + return getDialogResult(&dialog); +} + +QString QUIHelper::getSaveFileName(const QString &filter, const QString &dirName, const QString &fileName, + bool native, int width, int height) +{ + QFileDialog dialog; + initDialog(&dialog, "保存文件", "保存(&S)", dirName, native, width, height); + + //设置文件类型 + if (!filter.isEmpty()) { + dialog.setNameFilter(filter); + } + + //设置默认文件名称 + dialog.selectFile(fileName); + //设置模态类型允许输入 + dialog.setWindowModality(Qt::WindowModal); + //设置置顶显示 + dialog.setWindowFlags(dialog.windowFlags() | Qt::WindowStaysOnTopHint); + return getDialogResult(&dialog); +} + +QString QUIHelper::getExistingDirectory(const QString &dirName, bool native, int width, int height) +{ + QFileDialog dialog; + initDialog(&dialog, "选择目录", "选择(&S)", dirName, native, width, height); + dialog.setOption(QFileDialog::ReadOnly); + //设置只显示目录 +#if (QT_VERSION < QT_VERSION_CHECK(6,0,0)) + dialog.setFileMode(QFileDialog::DirectoryOnly); +#endif + dialog.setOption(QFileDialog::ShowDirsOnly); + return getDialogResult(&dialog); +} + +QString QUIHelper::getXorEncryptDecrypt(const QString &value, char key) +{ + //矫正范围外的数据 + if (key < 0 || key >= 127) { + key = 127; + } + + //大概从5.9版本输出的加密密码字符串前面会加上 @String 字符 + QString result = value; + if (result.startsWith("@String")) { + result = result.mid(8, result.length() - 9); + } + + int size = result.size(); + for (int i = 0; i < size; ++i) { + result[i] = QChar(result.at(i).toLatin1() ^ key); + } + return result; +} + +quint8 QUIHelper::getOrCode(const QByteArray &data) +{ + int len = data.length(); + quint8 result = 0; + for (int i = 0; i < len; ++i) { + result ^= data.at(i); + } + + return result; +} + +quint8 QUIHelper::getCheckCode(const QByteArray &data) +{ + int len = data.length(); + quint8 temp = 0; + for (int i = 0; i < len; ++i) { + temp += data.at(i); + } + + return temp % 256; +} + +void QUIHelper::initTableView(QTableView *tableView, int rowHeight, bool headVisible, bool edit, bool stretchLast) +{ + //设置弱属性用于应用qss特殊样式 + tableView->setProperty("model", true); + //取消自动换行 + tableView->setWordWrap(false); + //超出文本不显示省略号 + tableView->setTextElideMode(Qt::ElideNone); + //奇数偶数行颜色交替 + tableView->setAlternatingRowColors(false); + //垂直表头是否可见 + tableView->verticalHeader()->setVisible(headVisible); + //选中一行表头是否加粗 + tableView->horizontalHeader()->setHighlightSections(false); + //最后一行拉伸填充 + tableView->horizontalHeader()->setStretchLastSection(stretchLast); + //行标题最小宽度尺寸 + tableView->horizontalHeader()->setMinimumSectionSize(0); + //行标题最小高度,等同于和默认行高一致 + tableView->horizontalHeader()->setFixedHeight(rowHeight); + //默认行高 + tableView->verticalHeader()->setDefaultSectionSize(rowHeight); + //选中时一行整体选中 + tableView->setSelectionBehavior(QAbstractItemView::SelectRows); + //只允许选择单个 + tableView->setSelectionMode(QAbstractItemView::SingleSelection); + + //表头不可单击 +#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0)) + tableView->horizontalHeader()->setSectionsClickable(false); +#else + tableView->horizontalHeader()->setClickable(false); +#endif + + //鼠标按下即进入编辑模式 + if (edit) { + tableView->setEditTriggers(QAbstractItemView::CurrentChanged | QAbstractItemView::DoubleClicked); + } else { + tableView->setEditTriggers(QAbstractItemView::NoEditTriggers); + } +} + +void QUIHelper::openFile(const QString &fileName, const QString &msg) +{ +#ifdef __arm__ + return; +#endif + //文件不存在则不用处理 + if (!QFile(fileName).exists()) { + return; + } + if (QUIHelper::showMessageBoxQuestion(msg + "成功, 确定现在就打开吗?") == QMessageBox::Yes) { + QString url = QString("file:///%1").arg(fileName); + QDesktopServices::openUrl(QUrl(url, QUrl::TolerantMode)); + } +} + +bool QUIHelper::checkIniFile(const QString &iniFile) +{ + //如果配置文件大小为0,则以初始值继续运行,并生成配置文件 + QFile file(iniFile); + if (file.size() == 0) { + return false; + } + + //如果配置文件不完整,则以初始值继续运行,并生成配置文件 + if (file.open(QFile::ReadOnly)) { + bool ok = true; + while (!file.atEnd()) { + QString line = file.readLine(); + line.replace("\r", ""); + line.replace("\n", ""); + QStringList list = line.split("="); + + if (list.size() == 2) { + QString key = list.at(0); + QString value = list.at(1); + if (value.isEmpty()) { + qDebug() << TIMEMS << "ini node no value" << key; + ok = false; + break; + } + } + } + + if (!ok) { + return false; + } + } else { + return false; + } + + return true; +} + +QString QUIHelper::cutString(const QString &text, int len, int left, int right, bool file, const QString &mid) +{ + //如果指定了字符串分割则表示是文件名需要去掉拓展名 + QString result = text; + if (file && result.contains(".")) { + int index = result.lastIndexOf("."); + result = result.mid(0, index); + } + + //最终字符串格式为 前缀字符...后缀字符 + if (result.length() > len) { + result = QString("%1%2%3").arg(result.left(left)).arg(mid).arg(result.right(right)); + } + + return result; +} + +QRect QUIHelper::getCenterRect(const QSize &imageSize, const QRect &widgetRect, int borderWidth, int scaleMode) +{ + QSize newSize = imageSize; + QSize widgetSize = widgetRect.size() - QSize(borderWidth * 1, borderWidth * 1); + + if (scaleMode == 0) { + if (newSize.width() > widgetSize.width() || newSize.height() > widgetSize.height()) { + newSize.scale(widgetSize, Qt::KeepAspectRatio); + } + } else if (scaleMode == 1) { + newSize.scale(widgetSize, Qt::KeepAspectRatio); + } else { + newSize = widgetSize; + } + + int x = widgetRect.center().x() - newSize.width() / 2; + int y = widgetRect.center().y() - newSize.height() / 2; + //不是2的倍数需要偏移1像素 + x += (x % 2 == 0 ? 1 : 0); + y += (y % 2 == 0 ? 1 : 0); + return QRect(x, y, newSize.width(), newSize.height()); +} + +void QUIHelper::getScaledImage(QImage &image, const QSize &widgetSize, int scaleMode, bool fast) +{ + Qt::TransformationMode mode = fast ? Qt::FastTransformation : Qt::SmoothTransformation; + if (scaleMode == 0) { + if (image.width() > widgetSize.width() || image.height() > widgetSize.height()) { + image = image.scaled(widgetSize, Qt::KeepAspectRatio, mode); + } + } else if (scaleMode == 1) { + image = image.scaled(widgetSize, Qt::KeepAspectRatio, mode); + } else { + image = image.scaled(widgetSize, Qt::IgnoreAspectRatio, mode); + } +} + +QString QUIHelper::getTimeString(qint64 time) +{ + time = time / 1000; + QString min = QString("%1").arg(time / 60, 2, 10, QChar('0')); + QString sec = QString("%2").arg(time % 60, 2, 10, QChar('0')); + return QString("%1:%2").arg(min).arg(sec); +} + +QString QUIHelper::getTimeString(QElapsedTimer timer) +{ + return QString::number((float)timer.elapsed() / 1000, 'f', 3); +} + +QString QUIHelper::getSizeString(quint64 size) +{ + float num = size; + QStringList list; + list << "KB" << "MB" << "GB" << "TB"; + + QString unit("bytes"); + QStringListIterator i(list); + while (num >= 1024.0 && i.hasNext()) { + unit = i.next(); + num /= 1024.0; + } + + return QString("%1 %2").arg(QString::number(num, 'f', 2)).arg(unit); +} diff --git a/ui/core_base/quihelper.h b/ui/core_base/quihelper.h new file mode 100644 index 0000000..d0d79a9 --- /dev/null +++ b/ui/core_base/quihelper.h @@ -0,0 +1,152 @@ +#ifndef QUIHELPER2_H +#define QUIHELPER2_H + +#include "head.h" + +class QUIHelper +{ +public: + //获取当前鼠标所在屏幕索引/区域尺寸/缩放系数 + static int getScreenIndex(); + static QRect getScreenRect(bool available = true); + static qreal getScreenRatio(bool devicePixel = false); + //矫正当前鼠标所在屏幕居中尺寸 + static QRect checkCenterRect(QRect &rect, bool available = true); + + //获取桌面宽度高度+居中显示 + static int deskWidth(); + static int deskHeight(); + static QSize deskSize(); + + //居中显示窗体 + //定义标志位指定是以桌面为参照还是主程序界面为参照 + static QWidget *centerBaseForm; + static void setFormInCenter(QWidget *form); + static void showForm(QWidget *form); + + //程序文件名称+当前所在路径 + static QString appName(); + static QString appPath(); + + //获取本地网卡IP集合 + static QStringList getLocalIPs(); + + //获取内置颜色集合 + static QList colors; + static QList getColorList(); + static QStringList getColorNames(); + //随机获取颜色集合中的颜色 + static QColor getRandColor(); + + //初始化随机数种子 + static void initRand(); + //获取随机小数 + static float getRandFloat(float min, float max); + //获取随机数,指定最小值和最大值 + static double getRandValue(int min, int max, bool contansMin = false, bool contansMax = false); + //获取范围值随机经纬度集合 + static QStringList getRandPoint(int count, float mainLng, float mainLat, float dotLng, float dotLat); + //根据旧的范围值和值计算新的范围值对应的值 + static int getRangeValue(int oldMin, int oldMax, int oldValue, int newMin, int newMax); + + //获取uuid + static QString getUuid(); + //校验目录 + static void checkPath(const QString &dirName); + //延时 + static void sleep(int msec); + + //设置Qt自带样式 + static void setStyle(); + //设置字体 + static QFont addFont(const QString &fontFile, const QString &fontName); + static void setFont(int fontSize = 12); + //设置编码 + static void setCode(bool utf8 = true); + //设置翻译文件 + static void setTranslator(const QString &qmFile); + + //动态设置权限 + static bool checkPermission(const QString &permission); + //申请安卓权限 + static void initAndroidPermission(); + + //一次性设置所有包括编码样式字体等 + static void initAll(bool utf8 = true, bool style = true, int fontSize = 13); + //初始化main函数最前面执行的一段代码 + static void initMain(bool desktopSettingsAware = true, bool useOpenGLES = false); + + //插入消息 + static QVector msgTypes; + static QVector msgKeys; + static QVector msgColors; + static QString appendMsg(QTextEdit *textEdit, int type, const QString &data, + int maxCount, int ¤tCount, + bool clear = false, bool pause = false); + + //设置无边框 + static void setFramelessForm(QWidget *widgetMain, bool tool = false, bool top = false, bool menu = true); + + //弹出框 + static int showMessageBox(const QString &text, int type = 0, int closeSec = 0, bool exec = false); + //弹出消息框 + static void showMessageBoxInfo(const QString &text, int closeSec = 0, bool exec = false); + //弹出错误框 + static void showMessageBoxError(const QString &text, int closeSec = 0, bool exec = false); + //弹出询问框 + static int showMessageBoxQuestion(const QString &text); + + //为什么还要自定义对话框因为可控宽高和汉化对应文本等 + //初始化对话框文本 + static void initDialog(QFileDialog *dialog, const QString &title, const QString &acceptName, + const QString &dirName, bool native, int width, int height); + //拿到对话框结果 + static QString getDialogResult(QFileDialog *dialog); + //选择文件对话框 + static QString getOpenFileName(const QString &filter = QString(), + const QString &dirName = QString(), + const QString &fileName = QString(), + bool native = false, int width = 900, int height = 600); + //保存文件对话框 + static QString getSaveFileName(const QString &filter = QString(), + const QString &dirName = QString(), + const QString &fileName = QString(), + bool native = false, int width = 900, int height = 600); + //选择目录对话框 + static QString getExistingDirectory(const QString &dirName = QString(), + bool native = false, int width = 900, int height = 600); + + //异或加密-只支持字符,如果是中文需要将其转换base64编码 + static QString getXorEncryptDecrypt(const QString &value, char key); + //异或校验 + static quint8 getOrCode(const QByteArray &data); + //计算校验码 + static quint8 getCheckCode(const QByteArray &data); + + //初始化表格 + static void initTableView(QTableView *tableView, int rowHeight = 25, + bool headVisible = false, bool edit = false, + bool stretchLast = true); + //打开文件带提示框 + static void openFile(const QString &fileName, const QString &msg); + + //检查ini配置文件 + static bool checkIniFile(const QString &iniFile); + + //首尾截断字符串显示 + static QString cutString(const QString &text, int len, int left, int right, bool file, const QString &mid = "..."); + + //传入图片尺寸和窗体区域及边框大小返回居中区域(scaleMode: 0-自动调整 1-等比缩放 2-拉伸填充) + static QRect getCenterRect(const QSize &imageSize, const QRect &widgetRect, int borderWidth = 2, int scaleMode = 0); + //传入图片尺寸和窗体尺寸及缩放策略返回合适尺寸(scaleMode: 0-自动调整 1-等比缩放 2-拉伸填充) + static void getScaledImage(QImage &image, const QSize &widgetSize, int scaleMode = 0, bool fast = true); + + //毫秒数转时间 00:00 + static QString getTimeString(qint64 time); + //用时时间转秒数 + static QString getTimeString(QElapsedTimer timer); + //文件大小转 KB MB GB TB + static QString getSizeString(quint64 size); +}; + +#endif // QUIHELPER2_H diff --git a/ui/core_qss/qss.qrc b/ui/core_qss/qss.qrc new file mode 100644 index 0000000..c5219ef --- /dev/null +++ b/ui/core_qss/qss.qrc @@ -0,0 +1,28 @@ + + + qss/blacksoft.css + qss/blacksoft/add_bottom.png + qss/blacksoft/add_left.png + qss/blacksoft/add_right.png + qss/blacksoft/add_top.png + qss/blacksoft/arrow_bottom.png + qss/blacksoft/arrow_left.png + qss/blacksoft/arrow_right.png + qss/blacksoft/arrow_top.png + qss/blacksoft/branch_close.png + qss/blacksoft/branch_open.png + qss/blacksoft/calendar_nextmonth.png + qss/blacksoft/calendar_prevmonth.png + qss/blacksoft/checkbox_checked.png + qss/blacksoft/checkbox_checked_disable.png + qss/blacksoft/checkbox_parcial.png + qss/blacksoft/checkbox_parcial_disable.png + qss/blacksoft/checkbox_unchecked.png + qss/blacksoft/checkbox_unchecked_disable.png + qss/blacksoft/menu_checked.png + qss/blacksoft/radiobutton_checked.png + qss/blacksoft/radiobutton_checked_disable.png + qss/blacksoft/radiobutton_unchecked.png + qss/blacksoft/radiobutton_unchecked_disable.png + + diff --git a/ui/core_qss/qss/blacksoft.css b/ui/core_qss/qss/blacksoft.css new file mode 100644 index 0000000..6780634 --- /dev/null +++ b/ui/core_qss/qss/blacksoft.css @@ -0,0 +1,694 @@ +QPalette{background:#444444;}*{outline:0px;color:#DCDCDC;} + +QGraphicsView{ +border:1px solid #242424; +qproperty-backgroundBrush:#444444; +} + +QWidget[form="true"],QLabel[frameShape="1"]{ +border:1px solid #242424; +border-radius:0px; +} + +QWidget[form="bottom"]{ +background:#484848; +} + +QWidget[form="bottom"] .QFrame{ +border:1px solid #DCDCDC; +} + +QWidget[form="bottom"] QLabel,QWidget[form="title"] QLabel{ +border-radius:0px; +color:#DCDCDC; +background:none; +border-style:none; +} + +QWidget[form="title"],QWidget[nav="left"],QWidget[nav="top"] QAbstractButton{ +border-style:none; +border-radius:0px; +padding:5px; +color:#DCDCDC; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #484848,stop:1 #383838); +} + +QWidget[nav="top"] QAbstractButton:hover,QWidget[nav="top"] QAbstractButton:pressed,QWidget[nav="top"] QAbstractButton:checked{ +border-style:solid; +border-width:0px 0px 2px 0px; +padding:4px 4px 2px 4px; +border-color:#AAAAAA; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #646464,stop:1 #525252); +} + +QWidget[nav="left"] QAbstractButton{ +border-radius:0px; +color:#DCDCDC; +background:none; +border-style:none; +} + +QWidget[nav="left"] QAbstractButton:hover{ +color:#FFFFFF; +background-color:#AAAAAA; +} + +QWidget[nav="left"] QAbstractButton:checked,QWidget[nav="left"] QAbstractButton:pressed{ +color:#DCDCDC; +border-style:solid; +border-width:0px 0px 0px 2px; +padding:4px 4px 4px 2px; +border-color:#AAAAAA; +background-color:#444444; +} + +QWidget[video="true"] QLabel{ +color:#DCDCDC; +border:1px solid #242424; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #484848,stop:1 #383838); +} + +QWidget[video="true"] QLabel:focus{ +border:1px solid #AAAAAA; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #646464,stop:1 #525252); +} + +QLineEdit:read-only{ +background-color:#484848; +} + +QLineEdit,QTextEdit,QPlainTextEdit,QSpinBox,QDoubleSpinBox,QComboBox,QDateEdit,QTimeEdit,QDateTimeEdit{ +border:1px solid #242424; +border-radius:3px; +padding:2px; +background:none; +selection-background-color:#AAAAAA; +selection-color:#FFFFFF; +} + +QLineEdit:focus,QTextEdit:focus,QPlainTextEdit:focus,QSpinBox:focus,QDoubleSpinBox:focus,QComboBox:focus,QDateEdit:focus,QTimeEdit:focus,QDateTimeEdit:focus,QLineEdit:hover,QTextEdit:hover,QPlainTextEdit:hover,QSpinBox:hover,QDoubleSpinBox:hover,QComboBox:hover,QDateEdit:hover,QTimeEdit:hover,QDateTimeEdit:hover{ +border:1px solid #242424; +} + +QLineEdit[echoMode="2"]{ +lineedit-password-character:9679; +} + +.QFrame{ +border:1px solid #242424; +border-radius:3px; +} + +.QGroupBox{ +border:1px solid #242424; +border-radius:5px; +margin-top:9px; +} + +.QGroupBox::title{ +subcontrol-origin:margin; +position:relative; +left:10px; +} + +.QPushButton,.QToolButton{ +border-style:none; +border:1px solid #242424; +color:#DCDCDC; +padding:5px; +min-height:15px; +border-radius:5px; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #484848,stop:1 #383838); +} + +.QPushButton:hover,.QToolButton:hover{ +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #646464,stop:1 #525252); +} + +.QPushButton:pressed,.QToolButton:pressed{ +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #484848,stop:1 #383838); +} + +.QToolButton::menu-indicator{ +image:None; +} + +QToolButton#btnMenu,QPushButton#btnMenu_Min,QPushButton#btnMenu_Max,QPushButton#btnMenu_Close{ +border-radius:3px; +color:#DCDCDC; +padding:3px; +margin:0px; +background:none; +border-style:none; +} + +QToolButton#btnMenu:hover,QPushButton#btnMenu_Min:hover,QPushButton#btnMenu_Max:hover{ +color:#FFFFFF; +margin:1px 1px 2px 1px; +background-color:rgba(51,127,209,230); +} + +QPushButton#btnMenu_Close:hover{ +color:#FFFFFF; +margin:1px 1px 2px 1px; +background-color:rgba(238,0,0,128); +} + +QRadioButton::indicator{ +width:15px; +height:15px; +} + +QRadioButton::indicator::unchecked{ +image:url(:/qss/blacksoft/radiobutton_unchecked.png); +} + +QRadioButton::indicator::unchecked:disabled{ +image:url(:/qss/blacksoft/radiobutton_unchecked_disable.png); +} + +QRadioButton::indicator::checked{ +image:url(:/qss/blacksoft/radiobutton_checked.png); +} + +QRadioButton::indicator::checked:disabled{ +image:url(:/qss/blacksoft/radiobutton_checked_disable.png); +} + +QGroupBox::indicator,QTreeView::indicator,QListView::indicator,QTableView::indicator{ +padding:0px 0px 0px 0px; +} + +QCheckBox::indicator,QGroupBox::indicator,QTreeView::indicator,QListView::indicator,QTableView::indicator{ +width:13px; +height:13px; +} + +QCheckBox::indicator:unchecked,QGroupBox::indicator:unchecked,QTreeView::indicator:unchecked,QListView::indicator:unchecked,QTableView::indicator:unchecked{ +image:url(:/qss/blacksoft/checkbox_unchecked.png); +} + +QCheckBox::indicator:unchecked:disabled,QGroupBox::indicator:unchecked:disabled,QTreeView::indicator:unchecked:disabled,QListView::indicator:unchecked:disabled,QTableView::indicator:unchecked:disabled{ +image:url(:/qss/blacksoft/checkbox_unchecked_disable.png); +} + +QCheckBox::indicator:checked,QGroupBox::indicator:checked,QTreeView::indicator:checked,QListView::indicator:checked,QTableView::indicator:checked{ +image:url(:/qss/blacksoft/checkbox_checked.png); +} + +QCheckBox::indicator:checked:disabled,QGroupBox::indicator:checked:disabled,QTreeView::indicator:checked:disabled,QListView::indicator:checked:disabled,QTableView::indicator:checked:disabled{ +image:url(:/qss/blacksoft/checkbox_checked_disable.png); +} + +QCheckBox::indicator:indeterminate,QGroupBox::indicator:indeterminate,QTreeView::indicator:indeterminate,QListView::indicator:indeterminate,QTableView::indicator:indeterminate{ +image:url(:/qss/blacksoft/checkbox_parcial.png); +} + +QCheckBox::indicator:indeterminate:disabled,QGroupBox::indicator:indeterminate:disabled,QTreeView::indicator:indeterminate:disabled,QListView::indicator:indeterminate:disabled,QTableView::indicator:indeterminate:disabled{ +image:url(:/qss/blacksoft/checkbox_parcial_disable.png); +} + +QTimeEdit::up-button,QDateEdit::up-button,QDateTimeEdit::up-button,QDoubleSpinBox::up-button,QSpinBox::up-button{ +image:url(:/qss/blacksoft/add_top.png); +width:10px; +height:10px; +padding:2px 5px 0px 0px; +} + +QTimeEdit::down-button,QDateEdit::down-button,QDateTimeEdit::down-button,QDoubleSpinBox::down-button,QSpinBox::down-button{ +image:url(:/qss/blacksoft/add_bottom.png); +width:10px; +height:10px; +padding:0px 5px 2px 0px; +} + +QTimeEdit::up-button:pressed,QDateEdit::up-button:pressed,QDateTimeEdit::up-button:pressed,QDoubleSpinBox::up-button:pressed,QSpinBox::up-button:pressed{ +top:-2px; +} + +QTimeEdit::down-button:pressed,QDateEdit::down-button:pressed,QDateTimeEdit::down-button:pressed,QDoubleSpinBox::down-button:pressed,QSpinBox::down-button:pressed,QSpinBox::down-button:pressed{ +bottom:-2px; +} + +QComboBox::down-arrow,QDateEdit[calendarPopup="true"]::down-arrow,QTimeEdit[calendarPopup="true"]::down-arrow,QDateTimeEdit[calendarPopup="true"]::down-arrow{ +image:url(:/qss/blacksoft/add_bottom.png); +width:10px; +height:10px; +right:2px; +} + +QComboBox::drop-down,QDateEdit::drop-down,QTimeEdit::drop-down,QDateTimeEdit::drop-down{ +subcontrol-origin:padding; +subcontrol-position:top right; +width:15px; +border-left-width:0px; +border-left-style:solid; +border-top-right-radius:3px; +border-bottom-right-radius:3px; +border-left-color:#242424; +} + +QComboBox::drop-down:on{ +top:1px; +} + +QMenuBar::item{ +color:#DCDCDC; +background-color:#484848; +margin:0px; +padding:3px 10px; +} + +QMenu,QMenuBar,QMenu:disabled,QMenuBar:disabled{ +color:#DCDCDC; +background-color:#484848; +border:1px solid #242424; +margin:0px; +} + +QMenu::item{ +padding:3px 20px; +} + +QMenu::indicator{ +width:20px; +height:13px; +} + +QMenu::indicator::checked{ +image:url(:/qss/blacksoft/menu_checked.png); +} + +QMenu::right-arrow{ +image:url(:/qss/blacksoft/arrow_right.png); +width:13px; +height:13px; +padding:0px 3px 0px 0px; +} + +QMenu::item:selected,QMenuBar::item:selected{ +color:#DCDCDC; +border:0px solid #242424; +background:#646464; +} + +QMenu::separator{ +height:1px; +background:#242424; +} + +QProgressBar{ +min-height:10px; +background:#484848; +border-radius:5px; +text-align:center; +border:1px solid #484848; +} + +QProgressBar:chunk{ +border-radius:5px; +background-color:#242424; +} + +QSlider::groove:horizontal{ +height:8px; +border-radius:4px; +background:#484848; +} + +QSlider::add-page:horizontal{ +height:8px; +border-radius:4px; +background:#484848; +} + +QSlider::sub-page:horizontal{ +height:8px; +border-radius:4px; +background:#242424; +} + +QSlider::handle:horizontal{ +width:13px; +margin-top:-3px; +margin-bottom:-3px; +border-radius:6px; +background:qradialgradient(spread:pad,cx:0.5,cy:0.5,radius:0.5,fx:0.5,fy:0.5,stop:0.6 #444444,stop:0.8 #242424); +} + +QSlider::groove:vertical{ +width:8px; +border-radius:4px; +background:#484848; +} + +QSlider::add-page:vertical{ +width:8px; +border-radius:4px; +background:#242424; +} + +QSlider::sub-page:vertical{ +width:8px; +border-radius:4px; +background:#484848; +} + +QSlider::handle:vertical{ +height:14px; +margin-left:-3px; +margin-right:-3px; +border-radius:6px; +background:qradialgradient(spread:pad,cx:0.5,cy:0.5,radius:0.5,fx:0.5,fy:0.5,stop:0.6 #444444,stop:0.8 #242424); +} + +QScrollBar:horizontal{ +background:#484848; +padding:0px; +border-radius:6px; +max-height:12px; +} + +QScrollBar::handle:horizontal{ +background:#242424; +min-width:50px; +border-radius:6px; +} + +QScrollBar::handle:horizontal:hover{ +background:#AAAAAA; +} + +QScrollBar::handle:horizontal:pressed{ +background:#AAAAAA; +} + +QScrollBar::add-page:horizontal{ +background:none; +} + +QScrollBar::sub-page:horizontal{ +background:none; +} + +QScrollBar::add-line:horizontal{ +background:none; +} + +QScrollBar::sub-line:horizontal{ +background:none; +} + +QScrollBar:vertical{ +background:#484848; +padding:0px; +border-radius:6px; +max-width:12px; +} + +QScrollBar::handle:vertical{ +background:#242424; +min-height:50px; +border-radius:6px; +} + +QScrollBar::handle:vertical:hover{ +background:#AAAAAA; +} + +QScrollBar::handle:vertical:pressed{ +background:#AAAAAA; +} + +QScrollBar::add-page:vertical{ +background:none; +} + +QScrollBar::sub-page:vertical{ +background:none; +} + +QScrollBar::add-line:vertical{ +background:none; +} + +QScrollBar::sub-line:vertical{ +background:none; +} + +QScrollArea{ +border:0px; +} + +QTreeView,QListView,QTableView,QTabWidget::pane{ +border:1px solid #242424; +selection-background-color:#646464; +selection-color:#DCDCDC; +alternate-background-color:#525252; +gridline-color:#242424; +} + +QTreeView::branch:closed:has-children{ +margin:4px; +border-image:url(:/qss/blacksoft/branch_open.png); +} + +QTreeView::branch:open:has-children{ +margin:4px; +border-image:url(:/qss/blacksoft/branch_close.png); +} + +QTreeView,QListView,QTableView,QSplitter::handle,QTreeView::branch{ +background:#444444; +} + +QTableView::item:selected,QListView::item:selected,QTreeView::item:selected{ +color:#DCDCDC; +background:#383838; +} + +QTableView::item:hover,QListView::item:hover,QTreeView::item:hover,QHeaderView,QHeaderView::section,QTableCornerButton:section{ +color:#DCDCDC; +background:#525252; +} + +QTableView::item,QListView::item,QTreeView::item{ +padding:1px; +margin:0px; +border:0px; +} + +QHeaderView::section,QTableCornerButton:section{ +padding:3px; +margin:0px; +border:1px solid #242424; +border-left-width:0px; +border-right-width:1px; +border-top-width:0px; +border-bottom-width:1px; +} + +QTabBar::tab{ +border:1px solid #242424; +color:#DCDCDC; +margin:0px; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #646464,stop:1 #525252); +} + +QTabBar::tab:selected{ +border-style:solid; +border-color:#AAAAAA; +background:#444444; +} + +QTabBar::tab:top,QTabBar::tab:bottom{ +padding:3px 8px 3px 8px; +} + +QTabBar::tab:left,QTabBar::tab:right{ +padding:8px 3px 8px 3px; +} + +QTabBar::tab:top:selected{ +border-width:2px 0px 0px 0px; +} + +QTabBar::tab:right:selected{ +border-width:0px 0px 0px 2px; +} + +QTabBar::tab:bottom:selected{ +border-width:0px 0px 2px 0px; +} + +QTabBar::tab:left:selected{ +border-width:0px 2px 0px 0px; +} + +QTabBar::tab:first:top:selected,QTabBar::tab:first:bottom:selected{ +border-left-width:1px; +border-left-color:#242424; +} + +QTabBar::tab:first:left:selected,QTabBar::tab:first:right:selected{ +border-top-width:1px; +border-top-color:#242424; +} + +QTabBar::tab:last:top:selected,QTabBar::tab:last:bottom:selected{ +border-right-width:1px; +border-right-color:#242424; +} + +QTabBar::tab:last:left:selected,QTabBar::tab:last:right:selected{ +border-bottom-width:1px; +border-bottom-color:#242424; +} + +QStatusBar::item{ +border:0px solid #484848; +border-radius:3px; +} + +QToolBox::tab,QWidget[form="panel"]{ +padding:3px; +border-radius:5px; +color:#DCDCDC; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #484848,stop:1 #383838); +} + +QWidget[flag="paneltitle"]{ +border-bottom-left-radius:0px; +border-bottom-right-radius:0px; +} + +QWidget[flag="panelcontrol"]{ +border-top-width:0px; +border-top-left-radius:0px; +border-top-right-radius:0px; +} + +QToolTip{ +border:0px solid #DCDCDC; +padding:1px; +color:#DCDCDC; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #484848,stop:1 #383838); +} + +QToolBox::tab:selected{ +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #646464,stop:1 #525252); +} + +QPrintPreviewDialog QToolButton{ +border:0px solid #DCDCDC; +border-radius:0px; +margin:0px; +padding:3px; +background:none; +} + +QColorDialog QPushButton,QFileDialog QPushButton{ +min-width:80px; +} + +QToolButton#qt_calendar_prevmonth{ +icon-size:0px; +min-width:20px; +image:url(:/qss/blacksoft/calendar_prevmonth.png); +} + +QToolButton#qt_calendar_nextmonth{ +icon-size:0px; +min-width:20px; +image:url(:/qss/blacksoft/calendar_nextmonth.png); +} + +QToolButton#qt_calendar_prevmonth,QToolButton#qt_calendar_nextmonth,QToolButton#qt_calendar_monthbutton,QToolButton#qt_calendar_yearbutton{ +border:0px solid #DCDCDC; +border-radius:3px; +margin:3px 3px 3px 3px; +padding:3px; +background:none; +} + +QToolButton#qt_calendar_prevmonth:hover,QToolButton#qt_calendar_nextmonth:hover,QToolButton#qt_calendar_monthbutton:hover,QToolButton#qt_calendar_yearbutton:hover,QToolButton#qt_calendar_prevmonth:pressed,QToolButton#qt_calendar_nextmonth:pressed,QToolButton#qt_calendar_monthbutton:pressed,QToolButton#qt_calendar_yearbutton:pressed{ +border:1px solid #242424; +} + +QCalendarWidget QSpinBox#qt_calendar_yearedit{ +margin:2px; +} + +QCalendarWidget QToolButton::menu-indicator{ +image:None; +} + +QCalendarWidget QTableView{ +border-width:0px; +} + +QCalendarWidget QWidget#qt_calendar_navigationbar{ +border:1px solid #242424; +border-width:1px 1px 0px 1px; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #484848,stop:1 #383838); +} + +QTableView[model="true"]::item{ +padding:0px; +margin:0px; +} + +QTableView QLineEdit,QTableView QComboBox,QTableView QSpinBox,QTableView QDoubleSpinBox,QTableView QDateEdit,QTableView QTimeEdit,QTableView QDateTimeEdit{ +border-width:0px; +border-radius:0px; +} + +QTableView QLineEdit:focus,QTableView QComboBox:focus,QTableView QSpinBox:focus,QTableView QDoubleSpinBox:focus,QTableView QDateEdit:focus,QTableView QTimeEdit:focus,QTableView QDateTimeEdit:focus{ +border-width:0px; +border-radius:0px; +} + +QLineEdit,QTextEdit,QPlainTextEdit,QSpinBox,QDoubleSpinBox,QComboBox,QDateEdit,QTimeEdit,QDateTimeEdit{ +background:#444444; +} + +QTabWidget::pane:top{top:-1px;} +QTabWidget::pane:bottom{bottom:-1px;} +QTabWidget::pane:left{right:-1px;} +QTabWidget::pane:right{left:-1px;} + +QDialog,QDial,#QUIWidgetMain{ +background-color:#444444; +color:#DCDCDC; +} + +QDialogButtonBox>QPushButton{ +min-width:50px; +} + +QListView[noborder="true"],QTreeView[noborder="true"],QTabWidget[noborder="true"]::pane{ +border-width:0px; +} + +QToolBar>*,QStatusBar>*{ +margin:2px; +} + +*:disabled,QMenu::item:disabled,QTabBar:tab:disabled,QHeaderView::section:disabled{ +background:#444444; +border-color:#484848; +color:#242424; +} + +QLabel:disabled{ +background:none; +} + +/*TextColor:#DCDCDC*/ +/*PanelColor:#444444*/ +/*BorderColor:#242424*/ +/*NormalColorStart:#484848*/ +/*NormalColorEnd:#383838*/ +/*DarkColorStart:#646464*/ +/*DarkColorEnd:#525252*/ +/*HighColor:#AAAAAA*/ \ No newline at end of file diff --git a/ui/core_qss/qss/blacksoft/add_bottom.png b/ui/core_qss/qss/blacksoft/add_bottom.png new file mode 100644 index 0000000..b4a5f14 Binary files /dev/null and b/ui/core_qss/qss/blacksoft/add_bottom.png differ diff --git a/ui/core_qss/qss/blacksoft/add_left.png b/ui/core_qss/qss/blacksoft/add_left.png new file mode 100644 index 0000000..165ebd0 Binary files /dev/null and b/ui/core_qss/qss/blacksoft/add_left.png differ diff --git a/ui/core_qss/qss/blacksoft/add_right.png b/ui/core_qss/qss/blacksoft/add_right.png new file mode 100644 index 0000000..4c79925 Binary files /dev/null and b/ui/core_qss/qss/blacksoft/add_right.png differ diff --git a/ui/core_qss/qss/blacksoft/add_top.png b/ui/core_qss/qss/blacksoft/add_top.png new file mode 100644 index 0000000..f76300f Binary files /dev/null and b/ui/core_qss/qss/blacksoft/add_top.png differ diff --git a/ui/core_qss/qss/blacksoft/arrow_bottom.png b/ui/core_qss/qss/blacksoft/arrow_bottom.png new file mode 100644 index 0000000..39d7cbc Binary files /dev/null and b/ui/core_qss/qss/blacksoft/arrow_bottom.png differ diff --git a/ui/core_qss/qss/blacksoft/arrow_left.png b/ui/core_qss/qss/blacksoft/arrow_left.png new file mode 100644 index 0000000..1353cb8 Binary files /dev/null and b/ui/core_qss/qss/blacksoft/arrow_left.png differ diff --git a/ui/core_qss/qss/blacksoft/arrow_right.png b/ui/core_qss/qss/blacksoft/arrow_right.png new file mode 100644 index 0000000..0e50d47 Binary files /dev/null and b/ui/core_qss/qss/blacksoft/arrow_right.png differ diff --git a/ui/core_qss/qss/blacksoft/arrow_top.png b/ui/core_qss/qss/blacksoft/arrow_top.png new file mode 100644 index 0000000..d2c71e8 Binary files /dev/null and b/ui/core_qss/qss/blacksoft/arrow_top.png differ diff --git a/ui/core_qss/qss/blacksoft/branch_close.png b/ui/core_qss/qss/blacksoft/branch_close.png new file mode 100644 index 0000000..58a7d13 Binary files /dev/null and b/ui/core_qss/qss/blacksoft/branch_close.png differ diff --git a/ui/core_qss/qss/blacksoft/branch_open.png b/ui/core_qss/qss/blacksoft/branch_open.png new file mode 100644 index 0000000..a072d68 Binary files /dev/null and b/ui/core_qss/qss/blacksoft/branch_open.png differ diff --git a/ui/core_qss/qss/blacksoft/calendar_nextmonth.png b/ui/core_qss/qss/blacksoft/calendar_nextmonth.png new file mode 100644 index 0000000..b06ae31 Binary files /dev/null and b/ui/core_qss/qss/blacksoft/calendar_nextmonth.png differ diff --git a/ui/core_qss/qss/blacksoft/calendar_prevmonth.png b/ui/core_qss/qss/blacksoft/calendar_prevmonth.png new file mode 100644 index 0000000..46d4d62 Binary files /dev/null and b/ui/core_qss/qss/blacksoft/calendar_prevmonth.png differ diff --git a/ui/core_qss/qss/blacksoft/checkbox_checked.png b/ui/core_qss/qss/blacksoft/checkbox_checked.png new file mode 100644 index 0000000..b5ba6ef Binary files /dev/null and b/ui/core_qss/qss/blacksoft/checkbox_checked.png differ diff --git a/ui/core_qss/qss/blacksoft/checkbox_checked_disable.png b/ui/core_qss/qss/blacksoft/checkbox_checked_disable.png new file mode 100644 index 0000000..f6aab40 Binary files /dev/null and b/ui/core_qss/qss/blacksoft/checkbox_checked_disable.png differ diff --git a/ui/core_qss/qss/blacksoft/checkbox_parcial.png b/ui/core_qss/qss/blacksoft/checkbox_parcial.png new file mode 100644 index 0000000..cd1645f Binary files /dev/null and b/ui/core_qss/qss/blacksoft/checkbox_parcial.png differ diff --git a/ui/core_qss/qss/blacksoft/checkbox_parcial_disable.png b/ui/core_qss/qss/blacksoft/checkbox_parcial_disable.png new file mode 100644 index 0000000..dd0918f Binary files /dev/null and b/ui/core_qss/qss/blacksoft/checkbox_parcial_disable.png differ diff --git a/ui/core_qss/qss/blacksoft/checkbox_unchecked.png b/ui/core_qss/qss/blacksoft/checkbox_unchecked.png new file mode 100644 index 0000000..8a23968 Binary files /dev/null and b/ui/core_qss/qss/blacksoft/checkbox_unchecked.png differ diff --git a/ui/core_qss/qss/blacksoft/checkbox_unchecked_disable.png b/ui/core_qss/qss/blacksoft/checkbox_unchecked_disable.png new file mode 100644 index 0000000..e2a2262 Binary files /dev/null and b/ui/core_qss/qss/blacksoft/checkbox_unchecked_disable.png differ diff --git a/ui/core_qss/qss/blacksoft/menu_checked.png b/ui/core_qss/qss/blacksoft/menu_checked.png new file mode 100644 index 0000000..4fca11f Binary files /dev/null and b/ui/core_qss/qss/blacksoft/menu_checked.png differ diff --git a/ui/core_qss/qss/blacksoft/radiobutton_checked.png b/ui/core_qss/qss/blacksoft/radiobutton_checked.png new file mode 100644 index 0000000..69e499f Binary files /dev/null and b/ui/core_qss/qss/blacksoft/radiobutton_checked.png differ diff --git a/ui/core_qss/qss/blacksoft/radiobutton_checked_disable.png b/ui/core_qss/qss/blacksoft/radiobutton_checked_disable.png new file mode 100644 index 0000000..f098cc5 Binary files /dev/null and b/ui/core_qss/qss/blacksoft/radiobutton_checked_disable.png differ diff --git a/ui/core_qss/qss/blacksoft/radiobutton_unchecked.png b/ui/core_qss/qss/blacksoft/radiobutton_unchecked.png new file mode 100644 index 0000000..3f36472 Binary files /dev/null and b/ui/core_qss/qss/blacksoft/radiobutton_unchecked.png differ diff --git a/ui/core_qss/qss/blacksoft/radiobutton_unchecked_disable.png b/ui/core_qss/qss/blacksoft/radiobutton_unchecked_disable.png new file mode 100644 index 0000000..f729f17 Binary files /dev/null and b/ui/core_qss/qss/blacksoft/radiobutton_unchecked_disable.png differ diff --git a/ui/flatui/flatui.cpp b/ui/flatui/flatui.cpp new file mode 100644 index 0000000..78a76fb --- /dev/null +++ b/ui/flatui/flatui.cpp @@ -0,0 +1,170 @@ +#pragma execution_character_set("utf-8") + +#include "flatui.h" +#include "qpushbutton.h" +#include "qlineedit.h" +#include "qprogressbar.h" +#include "qslider.h" +#include "qradiobutton.h" +#include "qcheckbox.h" +#include "qscrollbar.h" +#include "qdebug.h" + +QString FlatUI::setPushButtonQss(QPushButton *btn, int radius, int padding, + const QString &normalColor, + const QString &normalTextColor, + const QString &hoverColor, + const QString &hoverTextColor, + const QString &pressedColor, + const QString &pressedTextColor) +{ + QStringList list; + list.append(QString("QPushButton{border-style:none;padding:%1px;border-radius:%2px;color:%3;background:%4;}") + .arg(padding).arg(radius).arg(normalTextColor).arg(normalColor)); + list.append(QString("QPushButton:hover{color:%1;background:%2;}") + .arg(hoverTextColor).arg(hoverColor)); + list.append(QString("QPushButton:pressed{color:%1;background:%2;}") + .arg(pressedTextColor).arg(pressedColor)); + + QString qss = list.join(""); + btn->setStyleSheet(qss); + return qss; +} + +QString FlatUI::setLineEditQss(QLineEdit *txt, int radius, int borderWidth, + const QString &normalColor, + const QString &focusColor) +{ + QStringList list; + list.append(QString("QLineEdit{border-style:none;padding:3px;border-radius:%1px;border:%2px solid %3;}") + .arg(radius).arg(borderWidth).arg(normalColor)); + list.append(QString("QLineEdit:focus{border:%1px solid %2;}") + .arg(borderWidth).arg(focusColor)); + + QString qss = list.join(""); + txt->setStyleSheet(qss); + return qss; +} + +QString FlatUI::setProgressQss(QProgressBar *bar, int barHeight, + int barRadius, int fontSize, + const QString &normalColor, + const QString &chunkColor) +{ + + QStringList list; + list.append(QString("QProgressBar{font:%1px;background:%2;max-height:%3px;border-radius:%4px;text-align:center;border:1px solid %2;}") + .arg(fontSize).arg(normalColor).arg(barHeight).arg(barRadius)); + list.append(QString("QProgressBar:chunk{border-radius:%2px;background-color:%1;}") + .arg(chunkColor).arg(barRadius)); + + QString qss = list.join(""); + bar->setStyleSheet(qss); + return qss; +} + +QString FlatUI::setSliderQss(QSlider *slider, int sliderHeight, + const QString &normalColor, + const QString &grooveColor, + const QString &handleBorderColor, + const QString &handleColor) +{ + int sliderRadius = sliderHeight / 2; + int handleWidth = (sliderHeight * 3) / 2 + (sliderHeight / 5); + int handleRadius = handleWidth / 2; + int handleOffset = handleRadius / 2; + + QStringList list; + list.append(QString("QSlider::horizontal{min-height:%1px;}").arg(sliderHeight * 2)); + list.append(QString("QSlider::groove:horizontal{background:%1;height:%2px;border-radius:%3px;}") + .arg(normalColor).arg(sliderHeight).arg(sliderRadius)); + list.append(QString("QSlider::add-page:horizontal{background:%1;height:%2px;border-radius:%3px;}") + .arg(normalColor).arg(sliderHeight).arg(sliderRadius)); + list.append(QString("QSlider::sub-page:horizontal{background:%1;height:%2px;border-radius:%3px;}") + .arg(grooveColor).arg(sliderHeight).arg(sliderRadius)); + list.append(QString("QSlider::handle:horizontal{width:%3px;margin-top:-%4px;margin-bottom:-%4px;border-radius:%5px;" + "background:qradialgradient(spread:pad,cx:0.5,cy:0.5,radius:0.5,fx:0.5,fy:0.5,stop:0.6 %1,stop:0.8 %2);}") + .arg(handleColor).arg(handleBorderColor).arg(handleWidth).arg(handleOffset).arg(handleRadius)); + + //偏移一个像素 + handleWidth = handleWidth + 1; + list.append(QString("QSlider::vertical{min-width:%1px;}").arg(sliderHeight * 2)); + list.append(QString("QSlider::groove:vertical{background:%1;width:%2px;border-radius:%3px;}") + .arg(normalColor).arg(sliderHeight).arg(sliderRadius)); + list.append(QString("QSlider::add-page:vertical{background:%1;width:%2px;border-radius:%3px;}") + .arg(grooveColor).arg(sliderHeight).arg(sliderRadius)); + list.append(QString("QSlider::sub-page:vertical{background:%1;width:%2px;border-radius:%3px;}") + .arg(normalColor).arg(sliderHeight).arg(sliderRadius)); + list.append(QString("QSlider::handle:vertical{height:%3px;margin-left:-%4px;margin-right:-%4px;border-radius:%5px;" + "background:qradialgradient(spread:pad,cx:0.5,cy:0.5,radius:0.5,fx:0.5,fy:0.5,stop:0.6 %1,stop:0.8 %2);}") + .arg(handleColor).arg(handleBorderColor).arg(handleWidth).arg(handleOffset).arg(handleRadius)); + + QString qss = list.join(""); + slider->setStyleSheet(qss); + return qss; +} + +QString FlatUI::setRadioButtonQss(QRadioButton *rbtn, int indicatorRadius, + const QString &normalColor, + const QString &checkColor) +{ + int indicatorWidth = indicatorRadius * 2; + + QStringList list; + list.append(QString("QRadioButton::indicator{border-radius:%1px;width:%2px;height:%2px;}") + .arg(indicatorRadius).arg(indicatorWidth)); + list.append(QString("QRadioButton::indicator::unchecked{background:qradialgradient(spread:pad,cx:0.5,cy:0.5,radius:0.5,fx:0.5,fy:0.5," + "stop:0.6 #FFFFFF,stop:0.7 %1);}").arg(normalColor)); + list.append(QString("QRadioButton::indicator::checked{background:qradialgradient(spread:pad,cx:0.5,cy:0.5,radius:0.5,fx:0.5,fy:0.5," + "stop:0 %1,stop:0.3 %1,stop:0.4 #FFFFFF,stop:0.6 #FFFFFF,stop:0.7 %1);}").arg(checkColor)); + + QString qss = list.join(""); + rbtn->setStyleSheet(qss); + return qss; +} + +QString FlatUI::setScrollBarQss(QWidget *scroll, int radius, int min, int max, + const QString &bgColor, + const QString &handleNormalColor, + const QString &handleHoverColor, + const QString &handlePressedColor) +{ + //滚动条离背景间隔 + int padding = 0; + + QStringList list; + + //handle:指示器,滚动条拉动部分 add-page:滚动条拉动时增加的部分 sub-page:滚动条拉动时减少的部分 add-line:递增按钮 sub-line:递减按钮 + + //横向滚动条部分 + list.append(QString("QScrollBar:horizontal{background:%1;padding:%2px;border-radius:%3px;min-height:%4px;max-height:%4px;}") + .arg(bgColor).arg(padding).arg(radius).arg(max)); + list.append(QString("QScrollBar::handle:horizontal{background:%1;min-width:%2px;border-radius:%3px;}") + .arg(handleNormalColor).arg(min).arg(radius)); + list.append(QString("QScrollBar::handle:horizontal:hover{background:%1;}") + .arg(handleHoverColor)); + list.append(QString("QScrollBar::handle:horizontal:pressed{background:%1;}") + .arg(handlePressedColor)); + list.append(QString("QScrollBar::add-page:horizontal{background:none;}")); + list.append(QString("QScrollBar::sub-page:horizontal{background:none;}")); + list.append(QString("QScrollBar::add-line:horizontal{background:none;}")); + list.append(QString("QScrollBar::sub-line:horizontal{background:none;}")); + + //纵向滚动条部分 + list.append(QString("QScrollBar:vertical{background:%1;padding:%2px;border-radius:%3px;min-width:%4px;max-width:%4px;}") + .arg(bgColor).arg(padding).arg(radius).arg(max)); + list.append(QString("QScrollBar::handle:vertical{background:%1;min-height:%2px;border-radius:%3px;}") + .arg(handleNormalColor).arg(min).arg(radius)); + list.append(QString("QScrollBar::handle:vertical:hover{background:%1;}") + .arg(handleHoverColor)); + list.append(QString("QScrollBar::handle:vertical:pressed{background:%1;}") + .arg(handlePressedColor)); + list.append(QString("QScrollBar::add-page:vertical{background:none;}")); + list.append(QString("QScrollBar::sub-page:vertical{background:none;}")); + list.append(QString("QScrollBar::add-line:vertical{background:none;}")); + list.append(QString("QScrollBar::sub-line:vertical{background:none;}")); + + QString qss = list.join(""); + scroll->setStyleSheet(qss); + return qss; +} diff --git a/ui/flatui/flatui.h b/ui/flatui/flatui.h new file mode 100644 index 0000000..bfcb64c --- /dev/null +++ b/ui/flatui/flatui.h @@ -0,0 +1,85 @@ +#ifndef FLATUI_H +#define FLATUI_H + +/** + * FlatUI辅助类 作者:feiyangqingyun(QQ:517216493) 2016-12-16 + * 1. 按钮样式设置。 + * 2. 文本框样式设置。 + * 3. 进度条样式。 + * 4. 滑块条样式。 + * 5. 单选框样式。 + * 6. 滚动条样式。 + * 7. 可自由设置对象的高度宽度大小等。 + * 8. 自带默认参数值。 + */ + +#include + +class QPushButton; +class QLineEdit; +class QProgressBar; +class QSlider; +class QRadioButton; +class QCheckBox; +class QScrollBar; + +#ifdef quc +class Q_DECL_EXPORT FlatUI +#else +class FlatUI +#endif + +{ +public: + //设置按钮样式 + static QString setPushButtonQss(QPushButton *btn, //按钮对象 + int radius = 5, //圆角半径 + int padding = 8, //间距 + const QString &normalColor = "#34495E", //正常颜色 + const QString &normalTextColor = "#FFFFFF", //文字颜色 + const QString &hoverColor = "#4E6D8C", //悬停颜色 + const QString &hoverTextColor = "#F0F0F0", //悬停文字颜色 + const QString &pressedColor = "#2D3E50", //按下颜色 + const QString &pressedTextColor = "#B8C6D1"); //按下文字颜色 + + //设置文本框样式 + static QString setLineEditQss(QLineEdit *txt, //文本框对象 + int radius = 3, //圆角半径 + int borderWidth = 2, //边框大小 + const QString &normalColor = "#DCE4EC", //正常颜色 + const QString &focusColor = "#34495E"); //选中颜色 + + //设置进度条样式 + static QString setProgressQss(QProgressBar *bar, + int barHeight = 8, //进度条高度 + int barRadius = 5, //进度条半径 + int fontSize = 12, //文字字号 + const QString &normalColor = "#E8EDF2", //正常颜色 + const QString &chunkColor = "#E74C3C"); //进度颜色 + + //设置滑块条样式 + static QString setSliderQss(QSlider *slider, //滑动条对象 + int sliderHeight = 8, //滑动条高度 + const QString &normalColor = "#E8EDF2", //正常颜色 + const QString &grooveColor = "#1ABC9C", //滑块颜色 + const QString &handleBorderColor = "#1ABC9C", //指示器边框颜色 + const QString &handleColor = "#FFFFFF"); //指示器颜色 + + //设置单选框样式 + static QString setRadioButtonQss(QRadioButton *rbtn, //单选框对象 + int indicatorRadius = 8, //指示器圆角角度 + const QString &normalColor = "#D7DBDE", //正常颜色 + const QString &checkColor = "#34495E"); //选中颜色 + + //设置滚动条样式 + static QString setScrollBarQss(QWidget *scroll, //滚动条对象 + int radius = 6, //圆角角度 + int min = 120, //指示器最小长度 + int max = 12, //滚动条最大长度 + const QString &bgColor = "#606060", //背景色 + const QString &handleNormalColor = "#34495E", //指示器正常颜色 + const QString &handleHoverColor = "#1ABC9C", //指示器悬停颜色 + const QString &handlePressedColor = "#E74C3C"); //指示器按下颜色 +}; + +#endif // FLATUI_H diff --git a/ui/flatui/flatui.pro b/ui/flatui/flatui.pro new file mode 100644 index 0000000..7dc1b46 --- /dev/null +++ b/ui/flatui/flatui.pro @@ -0,0 +1,17 @@ +QT += core gui +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets +greaterThan(QT_MAJOR_VERSION, 5): QT += core5compat + +TARGET = flatui +TEMPLATE = app +DESTDIR = $$PWD/../bin +CONFIG += warn_off + +SOURCES += main.cpp +SOURCES += frmflatui.cpp +SOURCES += flatui.cpp + +HEADERS += frmflatui.h +HEADERS += flatui.h + +FORMS += frmflatui.ui diff --git a/ui/flatui/frmflatui.cpp b/ui/flatui/frmflatui.cpp new file mode 100644 index 0000000..87b210e --- /dev/null +++ b/ui/flatui/frmflatui.cpp @@ -0,0 +1,96 @@ +#pragma execution_character_set("utf-8") + +#include "frmflatui.h" +#include "ui_frmflatui.h" +#include "flatui.h" +#include "qdebug.h" +#include "qdatetime.h" + +frmFlatUI::frmFlatUI(QWidget *parent) : QWidget(parent), ui(new Ui::frmFlatUI) +{ + ui->setupUi(this); + this->initForm(); +} + +frmFlatUI::~frmFlatUI() +{ + delete ui; +} + +void frmFlatUI::initForm() +{ + ui->bar1->setRange(0, 100); + ui->bar2->setRange(0, 100); + ui->slider1->setRange(0, 100); + ui->slider2->setRange(0, 100); + + connect(ui->slider1, SIGNAL(valueChanged(int)), ui->bar1, SLOT(setValue(int))); + connect(ui->slider2, SIGNAL(valueChanged(int)), ui->bar2, SLOT(setValue(int))); + ui->slider1->setValue(30); + ui->slider2->setValue(30); + + this->setStyleSheet("*{outline:0px;}QWidget#frmFlatUI{background:#FFFFFF;}"); + + FlatUI::setPushButtonQss(ui->btn1); + FlatUI::setPushButtonQss(ui->btn2, 5, 8, "#1ABC9C", "#E6F8F5", "#2EE1C1", "#FFFFFF", "#16A086", "#A7EEE6"); + FlatUI::setPushButtonQss(ui->btn3, 5, 8, "#3498DB", "#FFFFFF", "#5DACE4", "#E5FEFF", "#2483C7", "#A0DAFB"); + FlatUI::setPushButtonQss(ui->btn4, 5, 8, "#E74C3C", "#FFFFFF", "#EC7064", "#FFF5E7", "#DC2D1A", "#F5A996"); + + FlatUI::setLineEditQss(ui->txt1); + FlatUI::setLineEditQss(ui->txt2, 5, 2, "#DCE4EC", "#1ABC9C"); + FlatUI::setLineEditQss(ui->txt3, 3, 1, "#DCE4EC", "#3498DB"); + FlatUI::setLineEditQss(ui->txt4, 3, 1, "#DCE4EC", "#E74C3C"); + + FlatUI::setProgressQss(ui->bar1); + FlatUI::setProgressQss(ui->bar2, 8, 5, 9, "#E8EDF2", "#1ABC9C"); + + FlatUI::setSliderQss(ui->slider1); + FlatUI::setSliderQss(ui->slider2, 10, "#E8EDF2", "#E74C3C", "#E74C3C"); + FlatUI::setSliderQss(ui->slider3, 10, "#E8EDF2", "#34495E", "#34495E"); + + FlatUI::setRadioButtonQss(ui->rbtn1); + FlatUI::setRadioButtonQss(ui->rbtn2, 8, "#D7DBDE", "#1ABC9C"); + FlatUI::setRadioButtonQss(ui->rbtn3, 8, "#D7DBDE", "#3498DB"); + FlatUI::setRadioButtonQss(ui->rbtn4, 8, "#D7DBDE", "#E74C3C"); + + FlatUI::setScrollBarQss(ui->horizontalScrollBar); + FlatUI::setScrollBarQss(ui->verticalScrollBar, 8, 120, 20, "#606060", "#34495E", "#1ABC9C", "#E74C3C"); + + //设置列数和列宽 + int width = 1920; + ui->tableWidget->setColumnCount(5); + ui->tableWidget->setColumnWidth(0, width * 0.06); + ui->tableWidget->setColumnWidth(1, width * 0.10); + ui->tableWidget->setColumnWidth(2, width * 0.06); + ui->tableWidget->setColumnWidth(3, width * 0.10); + ui->tableWidget->setColumnWidth(4, width * 0.20); + ui->tableWidget->verticalHeader()->setDefaultSectionSize(25); + + QStringList headText; + headText << "设备编号" << "设备名称" << "设备地址" << "告警内容" << "告警时间"; + ui->tableWidget->setHorizontalHeaderLabels(headText); + ui->tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows); + ui->tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers); + ui->tableWidget->setSelectionMode(QAbstractItemView::SingleSelection); + ui->tableWidget->setAlternatingRowColors(true); + ui->tableWidget->verticalHeader()->setVisible(false); + ui->tableWidget->horizontalHeader()->setStretchLastSection(true); + + //设置行高 + ui->tableWidget->setRowCount(300); + + for (int i = 0; i < 300; i++) { + ui->tableWidget->setRowHeight(i, 24); + QTableWidgetItem *itemDeviceID = new QTableWidgetItem(QString::number(i + 1)); + QTableWidgetItem *itemDeviceName = new QTableWidgetItem(QString("测试设备%1").arg(i + 1)); + QTableWidgetItem *itemDeviceAddr = new QTableWidgetItem(QString::number(i + 1)); + QTableWidgetItem *itemContent = new QTableWidgetItem("防区告警"); + QTableWidgetItem *itemTime = new QTableWidgetItem(QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss")); + + ui->tableWidget->setItem(i, 0, itemDeviceID); + ui->tableWidget->setItem(i, 1, itemDeviceName); + ui->tableWidget->setItem(i, 2, itemDeviceAddr); + ui->tableWidget->setItem(i, 3, itemContent); + ui->tableWidget->setItem(i, 4, itemTime); + } +} diff --git a/ui/flatui/frmflatui.h b/ui/flatui/frmflatui.h new file mode 100644 index 0000000..8086a3f --- /dev/null +++ b/ui/flatui/frmflatui.h @@ -0,0 +1,25 @@ +#ifndef FRMFLATUI_H +#define FRMFLATUI_H + +#include + +namespace Ui { +class frmFlatUI; +} + +class frmFlatUI : public QWidget +{ + Q_OBJECT + +public: + explicit frmFlatUI(QWidget *parent = 0); + ~frmFlatUI(); + +private: + Ui::frmFlatUI *ui; + +private slots: + void initForm(); +}; + +#endif // FRMFLATUI_H diff --git a/ui/flatui/frmflatui.ui b/ui/flatui/frmflatui.ui new file mode 100644 index 0000000..c95b752 --- /dev/null +++ b/ui/flatui/frmflatui.ui @@ -0,0 +1,203 @@ + + + frmFlatUI + + + + 0 + 0 + 800 + 600 + + + + Form + + + + + + + + + 语文 + + + true + + + + + + + + + + 测试按钮 + + + + + + + + + + + + + 测试按钮 + + + + + + + Qt::Vertical + + + false + + + QSlider::NoTicks + + + + + + + 英语 + + + + + + + + 0 + 16 + + + + 24 + + + + + + + + + + Qt::Horizontal + + + + + + + 历史 + + + + + + + 数学 + + + + + + + + + + 测试按钮 + + + + + + + + + + + + + + + + 测试按钮 + + + + + + + + + + + 0 + 16 + + + + 24 + + + + + + + Qt::Vertical + + + + + + + + 0 + 20 + + + + Qt::Horizontal + + + + + + + + 0 + 20 + + + + 255 + + + Qt::Horizontal + + + + + + + + + + Qt::DashDotLine + + + + + + + + + diff --git a/ui/flatui/main.cpp b/ui/flatui/main.cpp new file mode 100644 index 0000000..e44e938 --- /dev/null +++ b/ui/flatui/main.cpp @@ -0,0 +1,34 @@ +#pragma execution_character_set("utf-8") + +#include "frmflatui.h" +#include +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + QFont font; + font.setFamily("Microsoft Yahei"); + font.setPixelSize(13); + a.setFont(font); + +#if (QT_VERSION < QT_VERSION_CHECK(5,0,0)) +#if _MSC_VER + QTextCodec *codec = QTextCodec::codecForName("gbk"); +#else + QTextCodec *codec = QTextCodec::codecForName("utf-8"); +#endif + QTextCodec::setCodecForLocale(codec); + QTextCodec::setCodecForCStrings(codec); + QTextCodec::setCodecForTr(codec); +#else + QTextCodec *codec = QTextCodec::codecForName("utf-8"); + QTextCodec::setCodecForLocale(codec); +#endif + + frmFlatUI w; + w.setWindowTitle("FlatUI控件集合 (QQ: 517216493 WX: feiyangqingyun)"); + w.show(); + + return a.exec(); +} diff --git a/ui/iconhelper/font/fa-regular-400.ttf b/ui/iconhelper/font/fa-regular-400.ttf new file mode 100644 index 0000000..4eeca8d Binary files /dev/null and b/ui/iconhelper/font/fa-regular-400.ttf differ diff --git a/ui/iconhelper/font/fontawesome-webfont.ttf b/ui/iconhelper/font/fontawesome-webfont.ttf new file mode 100644 index 0000000..35acda2 Binary files /dev/null and b/ui/iconhelper/font/fontawesome-webfont.ttf differ diff --git a/ui/iconhelper/font/iconfont.ttf b/ui/iconhelper/font/iconfont.ttf new file mode 100644 index 0000000..4757471 Binary files /dev/null and b/ui/iconhelper/font/iconfont.ttf differ diff --git a/ui/iconhelper/font/pe-icon-set-weather.ttf b/ui/iconhelper/font/pe-icon-set-weather.ttf new file mode 100644 index 0000000..eb6f8e5 Binary files /dev/null and b/ui/iconhelper/font/pe-icon-set-weather.ttf differ diff --git a/ui/iconhelper/frmiconhelper.cpp b/ui/iconhelper/frmiconhelper.cpp new file mode 100644 index 0000000..34e4784 --- /dev/null +++ b/ui/iconhelper/frmiconhelper.cpp @@ -0,0 +1,418 @@ +#pragma execution_character_set("utf-8") + +#include "frmiconhelper.h" +#include "ui_frmiconhelper.h" +#include "iconhelper.h" + +frmIconHelper::frmIconHelper(QWidget *parent) : QWidget(parent), ui(new Ui::frmIconHelper) +{ + ui->setupUi(this); + this->initForm(); + this->initWidget1(); + this->initWidget2(); + this->initWidget3(); + this->initWidget4(); + this->initWidget5(); + this->initWidget6(); + QTimer::singleShot(100, this, SLOT(initPanel())); +} + +frmIconHelper::~frmIconHelper() +{ + delete ui; +} + +bool frmIconHelper::eventFilter(QObject *watched, QEvent *event) +{ + if (event->type() == QEvent::Enter) { + QLabel *lab = (QLabel *)watched; + if (lab != 0) { + //由于有图形字体的范围值冲突需要手动切换索引 + if (ui->rbtnFontAwesome6->isChecked()) { + IconHelper::setIconFontIndex(2); + } else if (ui->rbtnFontWeather->isChecked()) { + IconHelper::setIconFontIndex(3); + } else { + IconHelper::setIconFontIndex(-1); + } + + //对应图形字体的16进制值已经赋值给了 toolTip + QString value = lab->toolTip(); + ui->labValue->setText(value); + int icon = value.toInt(NULL, 16); + + IconHelper::setIcon(ui->labIcon, icon, iconSize); + IconHelper::setIcon(ui->btnIcon, icon, iconSize); + + //万能大法直接从指定标识获取图片文件 + QPixmap pix = IconHelper::getPixmap("#753775", icon, iconSize, iconSize, iconSize); + ui->labImage->setPixmap(pix); + + //设置图标 以下方法二选一都可以 + //ui->btnImage->setIcon(QIcon(pix)); + IconHelper::setPixmap(ui->btnImage, "#FD8B28", icon, iconSize, iconSize, iconSize); + + //取出对应图形字体类 + QFont font = IconHelper::getIconFontAwesome(); + if (ui->rbtnFontAliBaBa->isChecked()) { + font = IconHelper::getIconFontAliBaBa(); + } else if (ui->rbtnFontAwesome6->isChecked()) { + font = IconHelper::getIconFontAwesome6(); + } else if (ui->rbtnFontWeather->isChecked()) { + font = IconHelper::getIconFontWeather(); + } + + //直接设置图标+文本到按钮 + font.setPixelSize(15); + ui->btnTest1->setFont(font); + ui->btnTest1->setText(QString("%1 测试图标").arg((QChar)icon)); + + //分别设置图标+文本到按钮 + ui->btnTest2->setIcon(QIcon(pix)); + } + } + + return QWidget::eventFilter(watched, event); +} + +void frmIconHelper::initForm() +{ + iconSize = 40; + //图标对应图形字体值 + icons << 0xf2ba << 0xf002 << 0xf013 << 0xf021; + + //设置样式表 + QStringList qss; + qss << QString("#labIcon{color:#32B9CF;}"); + qss << QString("#btnIcon{color:#C13256;}"); + qss << QString("#labValue,#labCount,#labInfo1,#labInfo2,#labInfo3,#labInfo4{font-weight:bold;font-size:20px;}"); + qss << QString("QWidget#widget1 QAbstractButton{min-height:%1px;max-height:%1px;}").arg(35); + qss << QString("QWidget#widget2 QAbstractButton{min-height:%1px;max-height:%1px;}").arg(35); + qss << QString("QWidget#widget3 QAbstractButton{min-height:%1px;max-height:%1px;}").arg(70); + qss << QString("QWidget#widget4 QAbstractButton{min-height:%1px;max-height:%1px;}").arg(70); + qss << QString("QWidget#widget5 QAbstractButton{min-width:%1px;max-width:%1px;}").arg(90); + qss << QString("QWidget#widget6 QAbstractButton{min-width:%1px;max-width:%1px;}").arg(90); + this->setStyleSheet(qss.join("")); + + //设置图形字体 + IconHelper::setIcon(ui->labIcon, 0xf067, iconSize); + IconHelper::setIcon(ui->btnIcon, 0xf067, iconSize); + QPixmap pix = IconHelper::getPixmap("#753775", 0xf067, iconSize, iconSize, iconSize); + ui->labImage->setPixmap(pix); + ui->btnImage->setIconSize(QSize(iconSize, iconSize)); + ui->btnImage->setIcon(QIcon(pix)); + + //关联单选框切换 + QList rbtns = ui->widgetRight->findChildren(); + foreach (QRadioButton *rbtn, rbtns) { + connect(rbtn, SIGNAL(toggled(bool)), this, SLOT(toggled(bool))); + } + + ui->tabWidget->setCurrentIndex(0); +} + +void frmIconHelper::initPanel() +{ + //清空原有对象 + qDeleteAll(labs); + labs.clear(); + + //选择不同的图形字体 + int start = 0xf000; + int end = 0xf2e0; + QFont iconFont = IconHelper::getIconFontAwesome(); + IconHelper::setIconFontIndex(-1); + + if (ui->rbtnFontAliBaBa->isChecked()) { + start = 0xe500; + end = 0xec00; + iconFont = IconHelper::getIconFontAliBaBa(); + } else if (ui->rbtnFontAwesome6->isChecked()) { + start = 0xe000; + end = 0xf8ff; + iconFont = IconHelper::getIconFontAwesome6(); + IconHelper::setIconFontIndex(2); + } else if (ui->rbtnFontWeather->isChecked()) { + start = 0xe900; + end = 0xe9cf; + iconFont = IconHelper::getIconFontWeather(); + IconHelper::setIconFontIndex(3); + } + + //设置字体大小 + iconFont.setPixelSize(15); + + //加载图形字体面板 + QStringList list; + for (int icon = start; icon <= end; icon++) { + //中间有一段是空的,可以自行屏蔽下面这段代码查看这段空的值对应的文字 + if (ui->rbtnFontAliBaBa->isChecked()) { + if (icon >= 0xe76c && icon <= 0xe8f8) { + continue; + } + } else if (ui->rbtnFontAwesome6->isChecked()) { + if (icon >= 0xe33d && icon <= 0xefff) { + continue; + } + } + + QString tip = "0x" + QString::number(icon, 16); + if (!checkIcon(icon)) { + list << tip; + continue; + } + + QLabel *lab = new QLabel; + lab->installEventFilter(this); + lab->setAlignment(Qt::AlignCenter); + lab->setFont(iconFont); + lab->setText((QChar)icon); + lab->setToolTip(tip); + lab->setMinimumSize(30, 30); + labs << lab; + } + + //qDebug() << "no text font" << list.count() << list; + ui->widgetFontPanel->setAutoWidth(true); + ui->widgetFontPanel->setMargin(3); + ui->widgetFontPanel->setSpace(3); + ui->widgetFontPanel->setColumnCount(18); + ui->widgetFontPanel->setWidgets(labs); + + //设置图形字体面板鼠标悬停时的效果 + QString qss = QString("QLabel:hover,QLabel:focus{color:%1;border:1px solid %1;}").arg("#00BB9E"); + ui->widgetFontPanel->setStyleSheet(qss); + + int count = end - start + 1; + ui->labCount->setText(QString("%1/%2").arg(labs.count()).arg(count)); +} + +bool frmIconHelper::checkIcon(int icon) +{ + //从图形字体对应值生成一个指定颜色的图片 + QPixmap pix = IconHelper::getPixmap("#FF0000", icon, 120, 120, 120); + QImage img = pix.toImage(); + int width = img.width(); + int height = img.height(); + + //过滤不存在的图形字体 + //对该图片逐个扫描像素点,都是空白则意味着当前图形字体不存在 + for (int i = 0; i < height; ++i) { + uchar *lineByte = img.scanLine(i); + for (int j = 0; j < width; j++) { + uchar tp = lineByte[j]; + if (tp > 0x00) { + return true; + } + } + } + + //保存下图片看下 + //QString fileName = QString("%1/icon/%2.jpg").arg(qApp->applicationDirPath()).arg(icon); + //pix.save(fileName, "jpg"); + return false; +} + +void frmIconHelper::toggled(bool checked) +{ + //单选框按下后自动重新加载对应的图形字体 + if (checked) { + initPanel(); + } +} + +void frmIconHelper::initBtn(QButtonGroup *btnGroup, bool textBesideIcon) +{ + QList btns = btnGroup->buttons(); + foreach (QAbstractButton *btn, btns) { + QToolButton *b = (QToolButton *)btn; + //关联按钮单击事件 + connect(b, SIGNAL(clicked(bool)), this, SLOT(btnClicked())); + b->setCheckable(true); + b->setToolButtonStyle(textBesideIcon ? Qt::ToolButtonTextBesideIcon : Qt::ToolButtonTextUnderIcon); + } +} + +void frmIconHelper::btnClicked() +{ + QAbstractButton *btn = (QAbstractButton *)sender(); + QString objName = btn->parent()->objectName(); + if (objName == "widget1") { + ui->labInfo1->setText(btn->text()); + } else if (objName == "widget2") { + ui->labInfo2->setText(btn->text()); + } else if (objName == "widget3") { + ui->labInfo3->setText(btn->text()); + } else if (objName == "widget4") { + ui->labInfo4->setText(btn->text()); + } +} + +void frmIconHelper::initWidget1() +{ + //加入按钮组自动互斥 + QButtonGroup *btnGroup = new QButtonGroup(this); + btnGroup->addButton(ui->btn11); + btnGroup->addButton(ui->btn12); + btnGroup->addButton(ui->btn13); + btnGroup->addButton(ui->btn14); + + //设置按钮可选中以及图标样式 + initBtn(btnGroup, true); + //设置弱属性以便应用样式 + ui->widget1->setProperty("flag", "left"); + + IconHelper::StyleColor styleColor; + styleColor.defaultBorder = true; + styleColor.position = "left"; + styleColor.iconSize = 18; + styleColor.iconWidth = 30; + styleColor.iconHeight = 25; + styleColor.borderWidth = 4; + IconHelper::setStyle(ui->widget1, btnGroup->buttons(), icons, styleColor); + + //默认选中某个按钮 + ui->btn11->click(); +} + +void frmIconHelper::initWidget2() +{ + //加入按钮组自动互斥 + QButtonGroup *btnGroup = new QButtonGroup(this); + btnGroup->addButton(ui->btn21); + btnGroup->addButton(ui->btn22); + btnGroup->addButton(ui->btn23); + btnGroup->addButton(ui->btn24); + + //设置按钮可选中以及图标样式 + initBtn(btnGroup, true); + //设置弱属性以便应用样式 + ui->widget2->setProperty("flag", "right"); + + IconHelper::StyleColor styleColor; + styleColor.defaultBorder = true; + styleColor.position = "right"; + styleColor.iconSize = 18; + styleColor.iconWidth = 25; + styleColor.iconHeight = 20; + styleColor.borderWidth = 4; + styleColor.borderColor = "#32B9CF"; + styleColor.setColor("#187294", "#B6D7E3", "#145C75", "#F0F0F0"); + IconHelper::setStyle(ui->widget2, btnGroup->buttons(), icons, styleColor); + + //默认选中某个按钮 + ui->btn22->click(); +} + +void frmIconHelper::initWidget3() +{ + //加入按钮组自动互斥 + QButtonGroup *btnGroup = new QButtonGroup(this); + btnGroup->addButton(ui->btn31); + btnGroup->addButton(ui->btn32); + btnGroup->addButton(ui->btn33); + btnGroup->addButton(ui->btn34); + + //设置按钮可选中以及图标样式 + initBtn(btnGroup, false); + //设置弱属性以便应用样式 + ui->widget3->setProperty("flag", "left"); + + IconHelper::StyleColor styleColor; + styleColor.position = "left"; + styleColor.iconSize = 30; + styleColor.iconWidth = 40; + styleColor.iconHeight = 40; + styleColor.borderWidth = 3; + styleColor.borderColor = "#609EE9"; + IconHelper::setStyle(ui->widget3, btnGroup->buttons(), icons, styleColor); + + //默认选中某个按钮 + ui->btn33->click(); +} + +void frmIconHelper::initWidget4() +{ + //加入按钮组自动互斥 + QButtonGroup *btnGroup = new QButtonGroup(this); + btnGroup->addButton(ui->btn41); + btnGroup->addButton(ui->btn42); + btnGroup->addButton(ui->btn43); + btnGroup->addButton(ui->btn44); + + //设置按钮可选中以及图标样式 + initBtn(btnGroup, false); + //设置弱属性以便应用样式 + ui->widget4->setProperty("flag", "right"); + + IconHelper::StyleColor styleColor; + styleColor.position = "right"; + styleColor.iconSize = 30; + styleColor.iconWidth = 40; + styleColor.iconHeight = 40; + styleColor.borderWidth = 3; + styleColor.borderColor = "#F7AE13"; + styleColor.setColor("#FCDC97", "#54626F", "#FFF0BC", "#54626F"); + IconHelper::setStyle(ui->widget4, btnGroup->buttons(), icons, styleColor); + + //默认选中某个按钮 + ui->btn44->click(); +} + +void frmIconHelper::initWidget5() +{ + //加入按钮组自动互斥 + QButtonGroup *btnGroup = new QButtonGroup(this); + btnGroup->addButton(ui->btn51); + btnGroup->addButton(ui->btn52); + btnGroup->addButton(ui->btn53); + btnGroup->addButton(ui->btn54); + + //设置按钮可选中以及图标样式 + initBtn(btnGroup, false); + //设置弱属性以便应用样式 + ui->widget5->setProperty("flag", "top"); + + //设置整体按钮组样式 + IconHelper::StyleColor styleColor; + styleColor.defaultBorder = true; + styleColor.position = "top"; + styleColor.iconSize = 25; + styleColor.iconWidth = 25; + styleColor.iconHeight = 25; + styleColor.borderWidth = 3; + IconHelper::setStyle(ui->widget5, btnGroup->buttons(), icons, styleColor); + + //默认选中某个按钮 + ui->btn51->click(); +} + +void frmIconHelper::initWidget6() +{ + //加入按钮组自动互斥 + QButtonGroup *btnGroup = new QButtonGroup(this); + btnGroup->addButton(ui->btn61); + btnGroup->addButton(ui->btn62); + btnGroup->addButton(ui->btn63); + btnGroup->addButton(ui->btn64); + + //设置按钮可选中以及图标样式 + initBtn(btnGroup, false); + //设置弱属性以便应用样式 + ui->widget6->setProperty("flag", "bottom"); + + //设置整体按钮组样式 + IconHelper::StyleColor styleColor; + styleColor.defaultBorder = true; + styleColor.position = "bottom"; + styleColor.iconSize = 25; + styleColor.iconWidth = 25; + styleColor.iconHeight = 25; + styleColor.borderWidth = 3; + styleColor.borderColor = "#A279C5"; + styleColor.setColor("#292929", "#B6D7E3", "#10689A", "#F0F0F0"); + IconHelper::setStyle(ui->widget6, btnGroup->buttons(), icons, styleColor); + + //默认选中某个按钮 + ui->btn63->click(); +} diff --git a/ui/iconhelper/frmiconhelper.h b/ui/iconhelper/frmiconhelper.h new file mode 100644 index 0000000..ded0aed --- /dev/null +++ b/ui/iconhelper/frmiconhelper.h @@ -0,0 +1,45 @@ +#ifndef FRMICONHELPER_H +#define FRMICONHELPER_H + +#include +class QButtonGroup; + +namespace Ui { +class frmIconHelper; +} + +class frmIconHelper : public QWidget +{ + Q_OBJECT + +public: + explicit frmIconHelper(QWidget *parent = 0); + ~frmIconHelper(); + +protected: + bool eventFilter(QObject *watched, QEvent *event); + +private: + Ui::frmIconHelper *ui; + int iconSize; + QList icons; + QList labs; + +private slots: + void initForm(); + void initPanel(); + bool checkIcon(int icon); + void toggled(bool checked); + + void initBtn(QButtonGroup *btnGroup, bool textBesideIcon); + void btnClicked(); + + void initWidget1(); + void initWidget2(); + void initWidget3(); + void initWidget4(); + void initWidget5(); + void initWidget6(); +}; + +#endif // FRMICONHELPER_H diff --git a/ui/iconhelper/frmiconhelper.ui b/ui/iconhelper/frmiconhelper.ui new file mode 100644 index 0000000..4fbf880 --- /dev/null +++ b/ui/iconhelper/frmiconhelper.ui @@ -0,0 +1,963 @@ + + + frmIconHelper + + + + 0 + 0 + 800 + 600 + + + + Dialog + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + 1 + + + + 使用示例 + + + + + + + 0 + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 120 + 0 + + + + + 120 + 16777215 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + 访客登记 + + + + + + + + 0 + 0 + + + + 记录查询 + + + + + + + + 0 + 0 + + + + 系统设置 + + + + + + + + 0 + 0 + + + + 系统重启 + + + + + + + Qt::Vertical + + + + 20 + 366 + + + + + + + + + + + + 120 + 0 + + + + + 120 + 16777215 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + 访客登记 + + + + + + + + 0 + 0 + + + + 记录查询 + + + + + + + + 0 + 0 + + + + 系统设置 + + + + + + + + 0 + 0 + + + + 系统重启 + + + + + + + Qt::Vertical + + + + 20 + 366 + + + + + + + + + + + + 120 + 0 + + + + + 120 + 16777215 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + 访客登记 + + + + + + + + 0 + 0 + + + + 记录查询 + + + + + + + + 0 + 0 + + + + 系统设置 + + + + + + + + 0 + 0 + + + + 系统重启 + + + + + + + Qt::Vertical + + + + 20 + 366 + + + + + + + + + + + + 120 + 0 + + + + + 120 + 16777215 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + 访客登记 + + + + + + + + 0 + 0 + + + + 记录查询 + + + + + + + + 0 + 0 + + + + 系统设置 + + + + + + + + 0 + 0 + + + + 系统重启 + + + + + + + Qt::Vertical + + + + 20 + 366 + + + + + + + + + + + Qt::Horizontal + + + + 261 + 20 + + + + + + + + QFrame::Box + + + QFrame::Sunken + + + + + + Qt::AlignCenter + + + + + + + QFrame::Box + + + QFrame::Sunken + + + + + + Qt::AlignCenter + + + + + + + QFrame::Box + + + QFrame::Sunken + + + + + + Qt::AlignCenter + + + + + + + QFrame::Box + + + QFrame::Sunken + + + + + + Qt::AlignCenter + + + + + + + + + + + 0 + 75 + + + + + 16777215 + 75 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + 访客登记 + + + + + + + + 0 + 0 + + + + 记录查询 + + + + + + + + 0 + 0 + + + + 系统设置 + + + + + + + + 0 + 0 + + + + 系统重启 + + + + + + + Qt::Horizontal + + + + 413 + 20 + + + + + + + + + + + + 0 + 75 + + + + + 16777215 + 75 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Qt::Horizontal + + + + 413 + 20 + + + + + + + + + 0 + 0 + + + + 访客登记 + + + + + + + + 0 + 0 + + + + 记录查询 + + + + + + + + 0 + 0 + + + + 系统设置 + + + + + + + + 0 + 0 + + + + 系统重启 + + + + + + + + + + + 图形字体 + + + + + + + 0 + 0 + + + + + + + + + 130 + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + FontAwesome + + + true + + + + + + + FontAwesome6 + + + + + + + FontAliBaBa + + + + + + + FontWeather + + + + + + + + 0 + 35 + + + + QFrame::Box + + + QFrame::Sunken + + + + + + Qt::AlignCenter + + + + + + + + 0 + 35 + + + + QFrame::Box + + + QFrame::Sunken + + + + + + Qt::AlignCenter + + + + + + + + 0 + 70 + + + + QFrame::Box + + + QFrame::Sunken + + + 标签文字 + + + Qt::AlignCenter + + + + + + + + 0 + 70 + + + + QFrame::Box + + + QFrame::Sunken + + + 标签图片 + + + Qt::AlignCenter + + + + + + + + 0 + 70 + + + + 按钮文字 + + + + + + + + 0 + 0 + + + + + 0 + 70 + + + + 按钮图标 + + + + + + + 测试图标 + + + + + + + 测试图标 + + + + + + + Qt::Vertical + + + + 20 + 105 + + + + + + + + + + + + + + + + PanelWidget + QWidget +
panelwidget.h
+ 1 +
+
+ + +
diff --git a/ui/iconhelper/iconhelper.cpp b/ui/iconhelper/iconhelper.cpp new file mode 100644 index 0000000..1e703e6 --- /dev/null +++ b/ui/iconhelper/iconhelper.cpp @@ -0,0 +1,387 @@ +#include "iconhelper.h" + +IconHelper *IconHelper::iconFontAliBaBa = 0; +IconHelper *IconHelper::iconFontAwesome = 0; +IconHelper *IconHelper::iconFontAwesome6 = 0; +IconHelper *IconHelper::iconFontWeather = 0; +int IconHelper::iconFontIndex = -1; + +void IconHelper::initFont() +{ + static bool isInit = false; + if (!isInit) { + isInit = true; + if (iconFontAliBaBa == 0) { + iconFontAliBaBa = new IconHelper(":/font/iconfont.ttf", "iconfont"); + } + if (iconFontAwesome == 0) { + iconFontAwesome = new IconHelper(":/font/fontawesome-webfont.ttf", "FontAwesome"); + } + if (iconFontAwesome6 == 0) { + iconFontAwesome6 = new IconHelper(":/font/fa-regular-400.ttf", "Font Awesome 6 Pro Regular"); + } + if (iconFontWeather == 0) { + iconFontWeather = new IconHelper(":/font/pe-icon-set-weather.ttf", "pe-icon-set-weather"); + } + } +} + +void IconHelper::setIconFontIndex(int index) +{ + iconFontIndex = index; +} + +QFont IconHelper::getIconFontAliBaBa() +{ + initFont(); + return iconFontAliBaBa->getIconFont(); +} + +QFont IconHelper::getIconFontAwesome() +{ + initFont(); + return iconFontAwesome->getIconFont(); +} + +QFont IconHelper::getIconFontAwesome6() +{ + initFont(); + return iconFontAwesome6->getIconFont(); +} + +QFont IconHelper::getIconFontWeather() +{ + initFont(); + return iconFontWeather->getIconFont(); +} + +IconHelper *IconHelper::getIconHelper(int icon) +{ + initFont(); + + //指定了字体索引则取对应索引的字体类 + //没指定则自动根据不同的字体的值选择对应的类 + //由于部分值范围冲突所以可以指定索引来取 + //fontawesome 0xf000-0xf2e0 + //fontawesome6 0xe000-0xe33d 0xf000-0xf8ff + //iconfont 0xe501-0xe793 0xe8d5-0xea5d 0xeb00-0xec00 + //weather 0xe900-0xe9cf + + IconHelper *iconHelper = iconFontAwesome; + if (iconFontIndex < 0) { + if ((icon >= 0xe501 && icon <= 0xe793) || (icon >= 0xe8d5 && icon <= 0xea5d) || (icon >= 0xeb00 && icon <= 0xec00)) { + iconHelper = iconFontAliBaBa; + } + } else if (iconFontIndex == 0) { + iconHelper = iconFontAliBaBa; + } else if (iconFontIndex == 1) { + iconHelper = iconFontAwesome; + } else if (iconFontIndex == 2) { + iconHelper = iconFontAwesome6; + } else if (iconFontIndex == 3) { + iconHelper = iconFontWeather; + } + + return iconHelper; +} + +void IconHelper::setIcon(QLabel *lab, int icon, quint32 size) +{ + getIconHelper(icon)->setIcon1(lab, icon, size); +} + +void IconHelper::setIcon(QAbstractButton *btn, int icon, quint32 size) +{ + getIconHelper(icon)->setIcon1(btn, icon, size); +} + +void IconHelper::setPixmap(QAbstractButton *btn, const QColor &color, int icon, quint32 size, + quint32 width, quint32 height, int flags) +{ + getIconHelper(icon)->setPixmap1(btn, color, icon, size, width, height, flags); +} + +QPixmap IconHelper::getPixmap(const QColor &color, int icon, quint32 size, + quint32 width, quint32 height, int flags) +{ + return getIconHelper(icon)->getPixmap1(color, icon, size, width, height, flags); +} + +void IconHelper::setStyle(QWidget *widget, QList btns, + QList icons, const IconHelper::StyleColor &styleColor) +{ + int icon = icons.first(); + getIconHelper(icon)->setStyle1(widget, btns, icons, styleColor); +} + +void IconHelper::setStyle(QWidget *widget, QList btns, + QList icons, const IconHelper::StyleColor &styleColor) +{ + int icon = icons.first(); + getIconHelper(icon)->setStyle1(widget, btns, icons, styleColor); +} + +void IconHelper::setStyle(QWidget *widget, QList btns, + QList icons, const IconHelper::StyleColor &styleColor) +{ + int icon = icons.first(); + getIconHelper(icon)->setStyle1(widget, btns, icons, styleColor); +} + + +IconHelper::IconHelper(const QString &fontFile, const QString &fontName, QObject *parent) : QObject(parent) +{ + //判断图形字体是否存在,不存在则加入 + QFontDatabase fontDb; + if (!fontDb.families().contains(fontName) && QFile(fontFile).exists()) { + int fontId = fontDb.addApplicationFont(fontFile); + QStringList listName = fontDb.applicationFontFamilies(fontId); + if (listName.count() == 0) { + qDebug() << QString("load %1 error").arg(fontName); + } + } + + //再次判断是否包含字体名称防止加载失败 + if (fontDb.families().contains(fontName)) { + iconFont = QFont(fontName); +#if (QT_VERSION >= QT_VERSION_CHECK(4,8,0)) + iconFont.setHintingPreference(QFont::PreferNoHinting); +#endif + } +} + +bool IconHelper::eventFilter(QObject *watched, QEvent *event) +{ + //根据不同的 + if (watched->inherits("QAbstractButton")) { + QAbstractButton *btn = (QAbstractButton *)watched; + int index = btns.indexOf(btn); + if (index >= 0) { + //不同的事件设置不同的图标,同时区分选中的和没有选中的 + if (btn->isChecked()) { + if (event->type() == QEvent::MouseButtonPress) { + QMouseEvent *mouseEvent = (QMouseEvent *)event; + if (mouseEvent->button() == Qt::LeftButton) { + btn->setIcon(QIcon(pixChecked.at(index))); + } + } else if (event->type() == QEvent::Enter) { + btn->setIcon(QIcon(pixChecked.at(index))); + } else if (event->type() == QEvent::Leave) { + btn->setIcon(QIcon(pixChecked.at(index))); + } + } else { + if (event->type() == QEvent::MouseButtonPress) { + QMouseEvent *mouseEvent = (QMouseEvent *)event; + if (mouseEvent->button() == Qt::LeftButton) { + btn->setIcon(QIcon(pixPressed.at(index))); + } + } else if (event->type() == QEvent::Enter) { + btn->setIcon(QIcon(pixHover.at(index))); + } else if (event->type() == QEvent::Leave) { + btn->setIcon(QIcon(pixNormal.at(index))); + } + } + } + } + + return QObject::eventFilter(watched, event); +} + +void IconHelper::toggled(bool checked) +{ + //选中和不选中设置不同的图标 + QAbstractButton *btn = (QAbstractButton *)sender(); + int index = btns.indexOf(btn); + if (checked) { + btn->setIcon(QIcon(pixChecked.at(index))); + } else { + btn->setIcon(QIcon(pixNormal.at(index))); + } +} + +QFont IconHelper::getIconFont() +{ + return this->iconFont; +} + +void IconHelper::setIcon1(QLabel *lab, int icon, quint32 size) +{ + iconFont.setPixelSize(size); + lab->setFont(iconFont); + lab->setText((QChar)icon); +} + +void IconHelper::setIcon1(QAbstractButton *btn, int icon, quint32 size) +{ + iconFont.setPixelSize(size); + btn->setFont(iconFont); + btn->setText((QChar)icon); +} + +void IconHelper::setPixmap1(QAbstractButton *btn, const QColor &color, int icon, quint32 size, + quint32 width, quint32 height, int flags) +{ + btn->setIcon(getPixmap1(color, icon, size, width, height, flags)); +} + +QPixmap IconHelper::getPixmap1(const QColor &color, int icon, quint32 size, + quint32 width, quint32 height, int flags) +{ + //主动绘制图形字体到图片 + QPixmap pix(width, height); + pix.fill(Qt::transparent); + + QPainter painter; + painter.begin(&pix); + painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing); + painter.setPen(color); + + iconFont.setPixelSize(size); + painter.setFont(iconFont); + painter.drawText(pix.rect(), flags, (QChar)icon); + painter.end(); + return pix; +} + +void IconHelper::setStyle1(QWidget *widget, QList btns, QList icons, const IconHelper::StyleColor &styleColor) +{ + QList list; + foreach (QPushButton *btn, btns) { + list << btn; + } + + setStyle(widget, list, icons, styleColor); +} + +void IconHelper::setStyle1(QWidget *widget, QList btns, QList icons, const IconHelper::StyleColor &styleColor) +{ + QList list; + foreach (QToolButton *btn, btns) { + list << btn; + } + + setStyle(widget, list, icons, styleColor); +} + +void IconHelper::setStyle1(QWidget *widget, QList btns, QList icons, const IconHelper::StyleColor &styleColor) +{ + int btnCount = btns.count(); + int iconCount = icons.count(); + if (btnCount <= 0 || iconCount <= 0 || btnCount != iconCount) { + return; + } + + QString position = styleColor.position; + quint32 btnWidth = styleColor.btnWidth; + quint32 btnHeight = styleColor.btnHeight; + quint32 iconSize = styleColor.iconSize; + quint32 iconWidth = styleColor.iconWidth; + quint32 iconHeight = styleColor.iconHeight; + quint32 borderWidth = styleColor.borderWidth; + + //根据不同的位置计算边框 + QString strBorder; + if (position == "top") { + strBorder = QString("border-width:%1px 0px 0px 0px;padding-top:%1px;padding-bottom:%2px;") + .arg(borderWidth).arg(borderWidth * 2); + } else if (position == "right") { + strBorder = QString("border-width:0px %1px 0px 0px;padding-right:%1px;padding-left:%2px;") + .arg(borderWidth).arg(borderWidth * 2); + } else if (position == "bottom") { + strBorder = QString("border-width:0px 0px %1px 0px;padding-bottom:%1px;padding-top:%2px;") + .arg(borderWidth).arg(borderWidth * 2); + } else if (position == "left") { + strBorder = QString("border-width:0px 0px 0px %1px;padding-left:%1px;padding-right:%2px;") + .arg(borderWidth).arg(borderWidth * 2); + } + + //如果图标是左侧显示则需要让没有选中的按钮左侧也有加深的边框,颜色为背景颜色 + //如果图标在文字上面而设置的边框是 top bottom 也需要启用加深边框 + QStringList qss; + if (styleColor.defaultBorder) { + qss << QString("QWidget[flag=\"%1\"] QAbstractButton{border-style:solid;border-radius:0px;%2border-color:%3;color:%4;background:%5;}") + .arg(position).arg(strBorder).arg(styleColor.normalBgColor).arg(styleColor.normalTextColor).arg(styleColor.normalBgColor); + } else { + qss << QString("QWidget[flag=\"%1\"] QAbstractButton{border-style:none;border-radius:0px;padding:5px;color:%2;background:%3;}") + .arg(position).arg(styleColor.normalTextColor).arg(styleColor.normalBgColor); + } + + //悬停+按下+选中 + qss << QString("QWidget[flag=\"%1\"] QAbstractButton:hover{border-style:solid;%2border-color:%3;color:%4;background:%5;}") + .arg(position).arg(strBorder).arg(styleColor.borderColor).arg(styleColor.hoverTextColor).arg(styleColor.hoverBgColor); + qss << QString("QWidget[flag=\"%1\"] QAbstractButton:pressed{border-style:solid;%2border-color:%3;color:%4;background:%5;}") + .arg(position).arg(strBorder).arg(styleColor.borderColor).arg(styleColor.pressedTextColor).arg(styleColor.pressedBgColor); + qss << QString("QWidget[flag=\"%1\"] QAbstractButton:checked{border-style:solid;%2border-color:%3;color:%4;background:%5;}") + .arg(position).arg(strBorder).arg(styleColor.borderColor).arg(styleColor.checkedTextColor).arg(styleColor.checkedBgColor); + + //窗体背景颜色+按钮背景颜色 + qss << QString("QWidget#%1{background:%2;}") + .arg(widget->objectName()).arg(styleColor.normalBgColor); + qss << QString("QWidget>QAbstractButton{border-width:0px;background-color:%1;color:%2;}") + .arg(styleColor.normalBgColor).arg(styleColor.normalTextColor); + qss << QString("QWidget>QAbstractButton:hover{background-color:%1;color:%2;}") + .arg(styleColor.hoverBgColor).arg(styleColor.hoverTextColor); + qss << QString("QWidget>QAbstractButton:pressed{background-color:%1;color:%2;}") + .arg(styleColor.pressedBgColor).arg(styleColor.pressedTextColor); + qss << QString("QWidget>QAbstractButton:checked{background-color:%1;color:%2;}") + .arg(styleColor.checkedBgColor).arg(styleColor.checkedTextColor); + + //按钮宽度高度 + if (btnWidth > 0) { + qss << QString("QWidget>QAbstractButton{min-width:%1px;}").arg(btnWidth); + } + if (btnHeight > 0) { + qss << QString("QWidget>QAbstractButton{min-height:%1px;}").arg(btnHeight); + } + + //设置样式表 + widget->setStyleSheet(qss.join("")); + + //可能会重复调用设置所以先要移除上一次的 + for (int i = 0; i < btnCount; ++i) { + for (int j = 0; j < this->btns.count(); j++) { + if (this->btns.at(j) == btns.at(i)) { + disconnect(btns.at(i), SIGNAL(toggled(bool)), this, SLOT(toggled(bool))); + this->btns.at(j)->removeEventFilter(this); + this->btns.removeAt(j); + this->pixNormal.removeAt(j); + this->pixHover.removeAt(j); + this->pixPressed.removeAt(j); + this->pixChecked.removeAt(j); + break; + } + } + } + + //存储对应按钮对象,方便鼠标移上去的时候切换图片 + int checkedIndex = -1; + for (int i = 0; i < btnCount; ++i) { + int icon = icons.at(i); + QPixmap pixNormal = getPixmap1(styleColor.normalTextColor, icon, iconSize, iconWidth, iconHeight); + QPixmap pixHover = getPixmap1(styleColor.hoverTextColor, icon, iconSize, iconWidth, iconHeight); + QPixmap pixPressed = getPixmap1(styleColor.pressedTextColor, icon, iconSize, iconWidth, iconHeight); + QPixmap pixChecked = getPixmap1(styleColor.checkedTextColor, icon, iconSize, iconWidth, iconHeight); + + //记住最后选中的按钮 + QAbstractButton *btn = btns.at(i); + if (btn->isChecked()) { + checkedIndex = i; + } + + btn->setIcon(QIcon(pixNormal)); + btn->setIconSize(QSize(iconWidth, iconHeight)); + btn->installEventFilter(this); + connect(btn, SIGNAL(toggled(bool)), this, SLOT(toggled(bool))); + + this->btns << btn; + this->pixNormal << pixNormal; + this->pixHover << pixHover; + this->pixPressed << pixPressed; + this->pixChecked << pixChecked; + } + + //主动触发一下选中的按钮 + if (checkedIndex >= 0) { + QMetaObject::invokeMethod(btns.at(checkedIndex), "toggled", Q_ARG(bool, true)); + } +} diff --git a/ui/iconhelper/iconhelper.h b/ui/iconhelper/iconhelper.h new file mode 100644 index 0000000..adcf69e --- /dev/null +++ b/ui/iconhelper/iconhelper.h @@ -0,0 +1,189 @@ +#ifndef ICONHELPER_H +#define ICONHELPER_H + +/** + * 超级图形字体类 作者:feiyangqingyun(QQ:517216493) 2016-11-23 + * 1. 可传入多种图形字体文件,一个类通用所有图形字体。 + * 2. 默认已经内置了阿里巴巴图形字体FontAliBaBa、国际知名图形字体FontAwesome、天气图形字体FontWeather。 + * 3. 可设置 QLabel、QAbstractButton 文本为图形字体。 + * 4. 可设置图形字体作为 QAbstractButton 按钮图标。 + * 5. 内置万能的方法 getPixmap 将图形字体值转换为图片。 + * 6. 无论是设置文本、图标、图片等都可以设置图标的大小、尺寸、颜色等参数。 + * 7. 内置超级导航栏样式设置,将图形字体作为图标设置到按钮。 + * 8. 支持各种颜色设置比如正常颜色、悬停颜色、按下颜色、选中颜色。 + * 9. 可设置导航的位置为 left、right、top、bottom 四种。 + * 10. 可设置导航加深边框颜色和粗细大小。 + * 11. 导航面板的各种切换效果比如鼠标悬停、按下、选中等都自动处理掉样式设置。 + * 12. 全局静态方法,接口丰富,使用极其简单方便。 + */ + +#include +#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0)) +#include +#endif + +#ifdef quc +class Q_DECL_EXPORT IconHelper : public QObject +#else +class IconHelper : public QObject +#endif + +{ + Q_OBJECT + +private: + //阿里巴巴图形字体类 + static IconHelper *iconFontAliBaBa; + //FontAwesome图形字体类 + static IconHelper *iconFontAwesome; + //FontAwesome6图形字体类 + static IconHelper *iconFontAwesome6; + //天气图形字体类 + static IconHelper *iconFontWeather; + //图形字体索引 + static int iconFontIndex; + +public: + //样式颜色结构体 + struct StyleColor { + QString position; //位置 left right top bottom + bool defaultBorder; //默认有边框 + + quint32 btnWidth; //按钮宽度 + quint32 btnHeight; //按钮高度 + + quint32 iconSize; //图标字体尺寸 + quint32 iconWidth; //图标图片宽度 + quint32 iconHeight; //图标图片高度 + + quint32 borderWidth; //边框宽度 + QString borderColor; //边框颜色 + + QString normalBgColor; //正常背景颜色 + QString normalTextColor; //正常文字颜色 + QString hoverBgColor; //悬停背景颜色 + QString hoverTextColor; //悬停文字颜色 + QString pressedBgColor; //按下背景颜色 + QString pressedTextColor; //按下文字颜色 + QString checkedBgColor; //选中背景颜色 + QString checkedTextColor; //选中文字颜色 + + StyleColor() { + position = "left"; + defaultBorder = false; + + btnWidth = 0; + btnHeight = 0; + + iconSize = 12; + iconWidth = 15; + iconHeight = 15; + + borderWidth = 3; + borderColor = "#029FEA"; + + normalBgColor = "#292F38"; + normalTextColor = "#54626F"; + hoverBgColor = "#40444D"; + hoverTextColor = "#FDFDFD"; + pressedBgColor = "#404244"; + pressedTextColor = "#FDFDFD"; + checkedBgColor = "#44494F"; + checkedTextColor = "#FDFDFD"; + } + + //设置常规颜色 普通状态+加深状态 + void setColor(const QString &normalBgColor, + const QString &normalTextColor, + const QString &darkBgColor, + const QString &darkTextColor) { + this->normalBgColor = normalBgColor; + this->normalTextColor = normalTextColor; + this->hoverBgColor = darkBgColor; + this->hoverTextColor = darkTextColor; + this->pressedBgColor = darkBgColor; + this->pressedTextColor = darkTextColor; + this->checkedBgColor = darkBgColor; + this->checkedTextColor = darkTextColor; + } + }; + + + //初始化图形字体 + static void initFont(); + //设置引用图形字体文件索引 + static void setIconFontIndex(int index); + + //获取图形字体 + static QFont getIconFontAliBaBa(); + static QFont getIconFontAwesome(); + static QFont getIconFontAwesome6(); + static QFont getIconFontWeather(); + + //根据值获取图形字体类 + static IconHelper *getIconHelper(int icon); + + //设置图形字体到标签 + static void setIcon(QLabel *lab, int icon, quint32 size = 12); + //设置图形字体到按钮 + static void setIcon(QAbstractButton *btn, int icon, quint32 size = 12); + + //设置图形字体到图标 + static void setPixmap(QAbstractButton *btn, const QColor &color, + int icon, quint32 size = 12, + quint32 width = 15, quint32 height = 15, + int flags = Qt::AlignCenter); + //获取指定图形字体,可以指定文字大小,图片宽高,文字对齐 + static QPixmap getPixmap(const QColor &color, int icon, quint32 size = 12, + quint32 width = 15, quint32 height = 15, + int flags = Qt::AlignCenter); + + //指定导航面板样式,带图标和效果切换+悬停颜色+按下颜色+选中颜色 + static void setStyle(QWidget *widget, QList btns, QList icons, const StyleColor &styleColor); + static void setStyle(QWidget *widget, QList btns, QList icons, const StyleColor &styleColor); + static void setStyle(QWidget *widget, QList btns, QList icons, const StyleColor &styleColor); + + //默认构造函数,传入字体文件+字体名称 + explicit IconHelper(const QString &fontFile, const QString &fontName, QObject *parent = 0); + +protected: + bool eventFilter(QObject *watched, QEvent *event); + +private: + QFont iconFont; //图形字体 + QList btns; //按钮队列 + QList pixNormal; //正常图片队列 + QList pixHover; //悬停图片队列 + QList pixPressed; //按下图片队列 + QList pixChecked; //选中图片队列 + +private slots: + //按钮选中状态切换处理 + void toggled(bool checked); + +public: + //获取图形字体 + QFont getIconFont(); + + //设置图形字体到标签 + void setIcon1(QLabel *lab, int icon, quint32 size = 12); + //设置图形字体到按钮 + void setIcon1(QAbstractButton *btn, int icon, quint32 size = 12); + + //设置图形字体到图标 + void setPixmap1(QAbstractButton *btn, const QColor &color, + int icon, quint32 size = 12, + quint32 width = 15, quint32 height = 15, + int flags = Qt::AlignCenter); + //获取指定图形字体,可以指定文字大小,图片宽高,文字对齐 + QPixmap getPixmap1(const QColor &color, int icon, quint32 size = 12, + quint32 width = 15, quint32 height = 15, + int flags = Qt::AlignCenter); + + //指定导航面板样式,带图标和效果切换+悬停颜色+按下颜色+选中颜色 + void setStyle1(QWidget *widget, QList btns, QList icons, const StyleColor &styleColor); + void setStyle1(QWidget *widget, QList btns, QList icons, const StyleColor &styleColor); + void setStyle1(QWidget *widget, QList btns, QList icons, const StyleColor &styleColor); +}; + +#endif // ICONHELPER_H diff --git a/ui/iconhelper/iconhelper.pro b/ui/iconhelper/iconhelper.pro new file mode 100644 index 0000000..3077f64 --- /dev/null +++ b/ui/iconhelper/iconhelper.pro @@ -0,0 +1,23 @@ +QT += core gui +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets +greaterThan(QT_MAJOR_VERSION, 5): QT += core5compat + +TARGET = iconhelper +TEMPLATE = app +DESTDIR = $$PWD/../bin +CONFIG += warn_off + +SOURCES += main.cpp + +SOURCES += frmiconhelper.cpp +SOURCES += iconhelper.cpp +SOURCES += panelwidget.cpp + +HEADERS += frmiconhelper.h +HEADERS += iconhelper.h +HEADERS += panelwidget.h + +FORMS += frmiconhelper.ui + +INCLUDEPATH += $$PWD +RESOURCES += main.qrc diff --git a/ui/iconhelper/main.cpp b/ui/iconhelper/main.cpp new file mode 100644 index 0000000..7b424b6 --- /dev/null +++ b/ui/iconhelper/main.cpp @@ -0,0 +1,41 @@ +#pragma execution_character_set("utf-8") + +#include "frmiconhelper.h" +#include +#include + +int main(int argc, char *argv[]) +{ +#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0)) + QApplication::setAttribute(Qt::AA_Use96Dpi); +#endif +#if (QT_VERSION >= QT_VERSION_CHECK(5,14,0)) + QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::Floor); +#endif + + QApplication a(argc, argv); + QFont font; + font.setFamily("Microsoft Yahei"); + font.setPixelSize(13); + a.setFont(font); + +#if (QT_VERSION < QT_VERSION_CHECK(5,0,0)) +#if _MSC_VER + QTextCodec *codec = QTextCodec::codecForName("gbk"); +#else + QTextCodec *codec = QTextCodec::codecForName("utf-8"); +#endif + QTextCodec::setCodecForLocale(codec); + QTextCodec::setCodecForCStrings(codec); + QTextCodec::setCodecForTr(codec); +#else + QTextCodec *codec = QTextCodec::codecForName("utf-8"); + QTextCodec::setCodecForLocale(codec); +#endif + + frmIconHelper w; + w.setWindowTitle("图形字体示例 (QQ: 517216493 WX: feiyangqingyun)"); + w.show(); + + return a.exec(); +} diff --git a/ui/iconhelper/main.qrc b/ui/iconhelper/main.qrc new file mode 100644 index 0000000..6a90706 --- /dev/null +++ b/ui/iconhelper/main.qrc @@ -0,0 +1,8 @@ + + + font/fontawesome-webfont.ttf + font/iconfont.ttf + font/pe-icon-set-weather.ttf + font/fa-regular-400.ttf + + diff --git a/ui/iconhelper/panelwidget.cpp b/ui/iconhelper/panelwidget.cpp new file mode 100644 index 0000000..8117460 --- /dev/null +++ b/ui/iconhelper/panelwidget.cpp @@ -0,0 +1,191 @@ +#pragma execution_character_set("utf-8") + +#include "panelwidget.h" +#include "qscrollarea.h" +#include "qframe.h" +#include "qboxlayout.h" +#include "qdebug.h" + +PanelWidget::PanelWidget(QWidget *parent) : QWidget(parent) +{ + scrollArea = new QScrollArea(this); + scrollArea->setObjectName("scrollAreaMain"); + scrollArea->setWidgetResizable(true); + + scrollAreaContents = new QWidget(); + scrollAreaContents->setGeometry(QRect(0, 0, 100, 100)); + + verticalLayout = new QVBoxLayout(scrollAreaContents); + verticalLayout->setSpacing(0); + verticalLayout->setContentsMargins(0, 0, 0, 0); + + frame = new QFrame(scrollAreaContents); + frame->setObjectName("frameMain"); + + gridLayout = new QGridLayout(frame); + gridLayout->setSpacing(0); + gridLayout->setContentsMargins(0, 0, 0, 0); + + verticalLayout->addWidget(frame); + scrollArea->setWidget(scrollAreaContents); + frame->setStyleSheet("QFrame#frameMain{border-width:0px;}"); + + hSpacer = new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum); + vSpacer = new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding); + + margin = 0; + space = 0; + autoWidth = false; + autoHeight = false; +} + +void PanelWidget::resizeEvent(QResizeEvent *) +{ + scrollArea->resize(this->size()); +} + +QSize PanelWidget::sizeHint() const +{ + return QSize(300, 200); +} + +QSize PanelWidget::minimumSizeHint() const +{ + return QSize(20, 20); +} + +void PanelWidget::setMargin(int left, int top, int right, int bottom) +{ + gridLayout->setContentsMargins(left, top, right, bottom); +} + +int PanelWidget::getMargin() const +{ + return this->margin; +} + +void PanelWidget::setMargin(int margin) +{ + if (this->margin != margin) { + setMargin(margin, margin, margin, margin); + } +} + +int PanelWidget::getSpace() const +{ + return this->space; +} + +void PanelWidget::setSpace(int space) +{ + if (this->space != space) { + gridLayout->setSpacing(space); + } +} + +bool PanelWidget::getAutoWidth() const +{ + return this->autoWidth; +} + +void PanelWidget::setAutoWidth(bool autoWidth) +{ + if (this->autoWidth != autoWidth) { + this->autoWidth = autoWidth; + } +} + +bool PanelWidget::getAutoHeight() const +{ + return this->autoHeight; +} + +void PanelWidget::setAutoHeight(bool autoHeight) +{ + if (this->autoHeight != autoHeight) { + this->autoHeight = autoHeight; + } +} + +int PanelWidget::getColumnCount() const +{ + return this->columnCount; +} + +void PanelWidget::setColumnCount(int columnCount) +{ + if (this->columnCount != columnCount) { + this->columnCount = columnCount; + } +} + +QList PanelWidget::getWidgets() const +{ + return this->widgets; +} + +void PanelWidget::setWidgets(QList widgets) +{ + this->widgets = widgets; + this->loadWidgets(); +} + +void PanelWidget::loadWidgets() +{ + int row = 0; + int column = 0; + int index = 0; + + //先把之前的所有移除并不可见 + foreach (QWidget *widget, widgets) { + gridLayout->removeWidget(widget); + widget->setVisible(false); + } + + //移除所有弹簧 + gridLayout->removeItem(hSpacer); + gridLayout->removeItem(vSpacer); + + //重新添加到布局中并可见 + foreach (QWidget *widget, widgets) { + gridLayout->addWidget(widget, row, column); + widget->setVisible(true); + + column++; + index++; + if (index % columnCount == 0) { + row++; + column = 0; + } + } + + row++; + + //设置右边弹簧 + if (!autoWidth) { + gridLayout->addItem(hSpacer, 0, gridLayout->columnCount()); + } + + //设置底边弹簧 + if (!autoHeight) { + gridLayout->addItem(vSpacer, row, 0); + } +} + +void PanelWidget::insertWidget(int index, QWidget *widget) +{ + this->widgets.insert(index, widget); + this->loadWidgets(); +} + +void PanelWidget::removeWidget(QWidget *widget) +{ + this->widgets.removeOne(widget); + this->loadWidgets(); +} + +void PanelWidget::clearWidgets() +{ + qDeleteAll(this->widgets); + this->widgets.clear(); +} diff --git a/ui/iconhelper/panelwidget.h b/ui/iconhelper/panelwidget.h new file mode 100644 index 0000000..054ba45 --- /dev/null +++ b/ui/iconhelper/panelwidget.h @@ -0,0 +1,101 @@ +#ifndef PANELWIDGET_H +#define PANELWIDGET_H + +/** + * 面板容器控件 作者:feiyangqingyun(QQ:517216493) 2016-11-20 + * 1. 支持所有widget子类对象,自动产生滚动条。 + * 2. 支持自动拉伸自动填充。 + * 3. 提供接口获取容器内的所有对象的指针。 + * 4. 可设置是否自动拉伸宽度高度。 + * 5. 可设置设备面板之间的间距和边距。 + */ + +#include + +class QScrollArea; +class QFrame; +class QVBoxLayout; +class QGridLayout; +class QSpacerItem; + +#ifdef quc +class Q_DECL_EXPORT PanelWidget : public QWidget +#else +class PanelWidget : public QWidget +#endif + +{ + Q_OBJECT + + Q_PROPERTY(int margin READ getMargin WRITE setMargin) + Q_PROPERTY(int space READ getSpace WRITE setSpace) + Q_PROPERTY(bool autoWidth READ getAutoWidth WRITE setAutoWidth) + Q_PROPERTY(bool autoHeight READ getAutoHeight WRITE setAutoHeight) + Q_PROPERTY(int columnCount READ getColumnCount WRITE setColumnCount) + +public: + explicit PanelWidget(QWidget *parent = 0); + +protected: + void resizeEvent(QResizeEvent *); + +private: + QScrollArea *scrollArea; //滚动区域 + QWidget *scrollAreaContents;//滚动区域载体 + QFrame *frame; //放置设备的框架,自动变宽变高 + QVBoxLayout *verticalLayout;//设备面板总布局 + QGridLayout *gridLayout; //设备表格布局 + QSpacerItem *hSpacer; //横向弹簧 + QSpacerItem *vSpacer; //垂直弹簧 + + int margin; //边距 + int space; //设备之间的间隔 + bool autoWidth; //宽度自动拉伸 + bool autoHeight; //高度自动拉伸 + + int columnCount; //面板列数 + QList widgets; //设备面板对象集合 + +public: + //默认尺寸和最小尺寸 + QSize sizeHint() const; + QSize minimumSizeHint() const; + + //设置边距 + void setMargin(int left, int top, int right, int bottom); + + //获取和设置边距 + int getMargin() const; + void setMargin(int margin); + + //获取和设置间距 + int getSpace() const; + void setSpace(int space); + + //获取和设置自动填充宽度 + bool getAutoWidth() const; + void setAutoWidth(bool autoWidth); + + //获取和设置自自动填充高度 + bool getAutoHeight() const; + void setAutoHeight(bool autoHeight); + + //获取和设置列数 + int getColumnCount() const; + void setColumnCount(int columnCount); + + //获取和设置窗体集合 + QList getWidgets() const; + void setWidgets(QList widgets); + + //载入窗体集合 + void loadWidgets(); + //指定位置插入新窗体 + void insertWidget(int index, QWidget *widget); + //移除指定的窗体 + void removeWidget(QWidget *widget); + //清空窗体 + void clearWidgets(); +}; + +#endif // PANELWIDGET_H diff --git a/ui/iconhelper/图形字体对照表/FontAliBaBa.png b/ui/iconhelper/图形字体对照表/FontAliBaBa.png new file mode 100644 index 0000000..ffd61a3 Binary files /dev/null and b/ui/iconhelper/图形字体对照表/FontAliBaBa.png differ diff --git a/ui/iconhelper/图形字体对照表/FontAwesome.png b/ui/iconhelper/图形字体对照表/FontAwesome.png new file mode 100644 index 0000000..c0bd604 Binary files /dev/null and b/ui/iconhelper/图形字体对照表/FontAwesome.png differ diff --git a/ui/iconhelper/图形字体对照表/FontWeather.png b/ui/iconhelper/图形字体对照表/FontWeather.png new file mode 100644 index 0000000..c9ede89 Binary files /dev/null and b/ui/iconhelper/图形字体对照表/FontWeather.png differ diff --git a/ui/styledemo/frmmain.cpp b/ui/styledemo/frmmain.cpp new file mode 100644 index 0000000..5236a24 --- /dev/null +++ b/ui/styledemo/frmmain.cpp @@ -0,0 +1,95 @@ +#include "frmmain.h" +#include "ui_frmmain.h" +#include "head.h" + +frmMain::frmMain(QWidget *parent) : QMainWindow(parent), ui(new Ui::frmMain) +{ + ui->setupUi(this); + this->initForm(); +} + +frmMain::~frmMain() +{ + delete ui; +} + +void frmMain::initForm() +{ + ui->rbtn1->setChecked(true); + ui->ck2->setChecked(true); + ui->ck3->setCheckState(Qt::PartiallyChecked); + + ui->textEdit->setText("QQ:517216493\nWX:feiyangqingyun"); + ui->treeWidget->expandAll(); + + int rowHeight = 23; + ui->tableWidget->horizontalHeader()->setFixedHeight(rowHeight); + ui->tableWidget->verticalHeader()->setDefaultSectionSize(rowHeight); + + //加载鼠标右键菜单翻译文件 + QTranslator *translator1 = new QTranslator(qApp); + if (translator1->load(":/qm/qt_zh_CN.qm")) { + qApp->installTranslator(translator1); + } + + //加载富文本框鼠标右键菜单翻译文件 + QTranslator *translator2 = new QTranslator(qApp); + if (translator2->load(":/qm/widgets.qm")) { + qApp->installTranslator(translator2); + } + + on_btnStyle1_clicked(); +} + +void frmMain::loadStyle(const QString &qssFile) +{ + //开启计时 + QElapsedTimer time; + time.start(); + + //加载样式表 + QString qss; + QFile file(qssFile); + if (file.open(QFile::ReadOnly)) { + //用QTextStream读取样式文件不用区分文件编码 带bom也行 + QStringList list; + QTextStream in(&file); + //in.setCodec("utf-8"); + while (!in.atEnd()) { + QString line; + in >> line; + list << line; + } + + file.close(); + qss = list.join("\n"); + QString paletteColor = qss.mid(20, 7); + qApp->setPalette(QPalette(paletteColor)); + //用时主要在下面这句 + qApp->setStyleSheet(qss); + } + + qDebug() << "用时:" << time.elapsed(); +} + +void frmMain::on_btnStyle1_clicked() +{ + loadStyle(":/qss/lightblue.css"); +} + +void frmMain::on_btnStyle2_clicked() +{ + loadStyle(":/qss/flatgray.css"); +} + +void frmMain::on_btnStyle3_clicked() +{ + loadStyle(":/qss/blacksoft.css"); +} + +void frmMain::on_btnInfo_clicked() +{ + //QFileDialog::getOpenFileName(this, "", "", "", 0, QFileDialog::DontUseNativeDialog); + //QFileDialog::getExistingDirectory(0, "", "", QFileDialog::DontUseNativeDialog); +} + diff --git a/ui/styledemo/frmmain.h b/ui/styledemo/frmmain.h new file mode 100644 index 0000000..f860c3d --- /dev/null +++ b/ui/styledemo/frmmain.h @@ -0,0 +1,32 @@ +#ifndef FRMMAIN_H +#define FRMMAIN_H + +#include + +namespace Ui { +class frmMain; +} + +class frmMain : public QMainWindow +{ + Q_OBJECT + +public: + explicit frmMain(QWidget *parent = 0); + ~frmMain(); + +private: + Ui::frmMain *ui; + +private slots: + void initForm(); + void loadStyle(const QString &qssFile); + +private slots: + void on_btnStyle1_clicked(); + void on_btnStyle2_clicked(); + void on_btnStyle3_clicked(); + void on_btnInfo_clicked(); +}; + +#endif // FRMMAIN_H diff --git a/ui/styledemo/frmmain.ui b/ui/styledemo/frmmain.ui new file mode 100644 index 0000000..0c58d04 --- /dev/null +++ b/ui/styledemo/frmmain.ui @@ -0,0 +1,915 @@ + + + frmMain + + + + 0 + 0 + 820 + 632 + + + + MainWindow + + + + + + + + + + 分组框 + + + true + + + + + + + 0 + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + 80 + + + Qt::Vertical + + + + + + + Qt::Vertical + + + + + + + + 12 + 16777215 + + + + 80 + + + false + + + Qt::Vertical + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + 100 + 0 + + + + + + + + 右下框 + + + + + + + 单选框2 + + + + + + + 软件黑 + + + + + + + 拿人钱财替人消灾,人生江湖如此,程序江湖亦如此. + + + + + + + + + + + 100 + 0 + + + + 信息框 + + + + + + + + 0 + 0 + + + + 只读文本框 + + + true + + + + + + + true + + + + + + + + 0 + 0 + + + + 1234 + + + QLineEdit::Password + + + + + + + 日期框 + + + + + + + true + + + + + + + + 0 + 0 + + + + + + + + 询问框 + + + + + + + QFrame::NoFrame + + + 8 + + + QLCDNumber::Flat + + + 12345678.000000000000000 + + + 12345678 + + + + + + + + 100 + 0 + + + + 浅蓝色 + + + + + + + 错误框 + + + + + + + + + + 我是标签 + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + true + + + + + + + QFrame::Box + + + QFrame::Sunken + + + 我是标签 + + + + + + + 新窗体 + + + + + + + 单选框1 + + + + + + + 扁平灰 + + + + + + + 提示框 + + + + + + + 复选框3 + + + + + + + 复选框2 + + + false + + + + + + + 复选框1 + + + + + + + 单选框3 + + + + + + + 关于Qt + + + + + + + 关于程序 + + + + + + + 100 + + + Qt::Horizontal + + + + + + + + 16777215 + 12 + + + + + + + + Qt::Horizontal + + + + + + + + + + + + + + true + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:9.07563pt;"><br /></p></body></html> + + + + + + + + 新建项目 + + + Checked + + + + + 新建项目 + + + PartiallyChecked + + + + + 新建项目 + + + Unchecked + + + + + 新建项目 + + + Checked + + + + + 新建项目 + + + Checked + + + + + + + + + 新建列 + + + + + 新建项目 + + + PartiallyChecked + + + + 新建子项目 + + + Unchecked + + + + + 新建子项目 + + + Checked + + + + + 新建子项目 + + + Checked + + + + + + 新建项目 + + + Checked + + + + 新建子项目 + + + Checked + + + + 新建子项目 + + + Checked + + + + + + + + + + + + 20 + + + false + + + true + + + false + + + false + + + + 1 + + + + + 2 + + + + + 3 + + + + + 4 + + + + + 5 + + + + + 新建列 + + + + + 新建列 + + + + + 新建列 + + + + + 新建列 + + + + + 新建列 + + + + + 11111 + + + Checked + + + + + 11111 + + + + + 11111 + + + + + 11111 + + + + + 11111 + + + + + 22222 + + + Checked + + + + + 22222 + + + + + 22222 + + + + + 22222 + + + + + 22222 + + + + + 33333 + + + Checked + + + + + 33333 + + + + + 33333 + + + + + 33333 + + + + + 33333 + + + + + 44444 + + + Checked + + + + + 44444 + + + + + 44444 + + + + + 44444 + + + + + 44444 + + + + + 55555 + + + Checked + + + + + 55555 + + + + + 55555 + + + + + 55555 + + + + + 55555 + + + + + + + + + + 0 + 0 + 820 + 26 + + + + + 文件(&F) + + + + + + + + + + 编辑(&E) + + + + + + + + 构建(&B) + + + + 编译项目(&C) + + + + + + + + + + 帮助(&H) + + + + + + + + + + + + 新建文件(&N) + + + + + 打开文件(&O) + + + + + 保存文件(&S) + + + + + 关闭退出(&C) + + + + + 剪切(&X) + + + + + 复制(&C) + + + + + 粘贴(&V) + + + + + 构建项目(&B) + + + + + 帮助文档(&T) + + + + + 关于(&A) + + + + + true + + + true + + + 编译项目1 + + + + + true + + + 编译项目2 + + + + + + + horizontalSlider + valueChanged(int) + progressBar1 + setValue(int) + + + 424 + 265 + + + 547 + 260 + + + + + verticalSlider + valueChanged(int) + progressBar2 + setValue(int) + + + 736 + 101 + + + 760 + 115 + + + + + diff --git a/ui/styledemo/head.h b/ui/styledemo/head.h new file mode 100644 index 0000000..a8d5a79 --- /dev/null +++ b/ui/styledemo/head.h @@ -0,0 +1,12 @@ +#include +#include + +#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0)) +#include +#endif + +#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) +#include +#endif + +#pragma execution_character_set("utf-8") diff --git a/ui/styledemo/main.cpp b/ui/styledemo/main.cpp new file mode 100644 index 0000000..5638191 --- /dev/null +++ b/ui/styledemo/main.cpp @@ -0,0 +1,40 @@ +#include "frmmain.h" +#include "head.h" + +int main(int argc, char *argv[]) +{ + //设置不应用操作系统设置比如字体 + QApplication::setDesktopSettingsAware(false); +#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0)) + QApplication::setAttribute(Qt::AA_Use96Dpi); +#endif +#if (QT_VERSION >= QT_VERSION_CHECK(5,14,0)) + QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::Floor); +#endif + + QApplication a(argc, argv); + QFont font; + font.setFamily("Microsoft Yahei"); + font.setPixelSize(13); + a.setFont(font); + +#if (QT_VERSION < QT_VERSION_CHECK(5,0,0)) +#if _MSC_VER + QTextCodec *codec = QTextCodec::codecForName("gbk"); +#else + QTextCodec *codec = QTextCodec::codecForName("utf-8"); +#endif + QTextCodec::setCodecForLocale(codec); + QTextCodec::setCodecForCStrings(codec); + QTextCodec::setCodecForTr(codec); +#else + QTextCodec *codec = QTextCodec::codecForName("utf-8"); + QTextCodec::setCodecForLocale(codec); +#endif + + frmMain w; + w.setWindowTitle("样式表示例 (QQ: 517216493 WX: feiyangqingyun)"); + w.show(); + + return a.exec(); +} diff --git a/ui/styledemo/qrc/font.qrc b/ui/styledemo/qrc/font.qrc new file mode 100644 index 0000000..de5ece3 --- /dev/null +++ b/ui/styledemo/qrc/font.qrc @@ -0,0 +1,5 @@ + + + font/fontawesome-webfont.ttf + + diff --git a/ui/styledemo/qrc/font/Font Awesome Cheatsheet.png b/ui/styledemo/qrc/font/Font Awesome Cheatsheet.png new file mode 100644 index 0000000..c0bd604 Binary files /dev/null and b/ui/styledemo/qrc/font/Font Awesome Cheatsheet.png differ diff --git a/ui/styledemo/qrc/font/fontawesome-webfont.ttf b/ui/styledemo/qrc/font/fontawesome-webfont.ttf new file mode 100644 index 0000000..35acda2 Binary files /dev/null and b/ui/styledemo/qrc/font/fontawesome-webfont.ttf differ diff --git a/ui/styledemo/qrc/image/btn_close.png b/ui/styledemo/qrc/image/btn_close.png new file mode 100644 index 0000000..ef21a40 Binary files /dev/null and b/ui/styledemo/qrc/image/btn_close.png differ diff --git a/ui/styledemo/qrc/image/btn_ok.png b/ui/styledemo/qrc/image/btn_ok.png new file mode 100644 index 0000000..833e774 Binary files /dev/null and b/ui/styledemo/qrc/image/btn_ok.png differ diff --git a/ui/styledemo/qrc/image/msg_error.png b/ui/styledemo/qrc/image/msg_error.png new file mode 100644 index 0000000..e52446d Binary files /dev/null and b/ui/styledemo/qrc/image/msg_error.png differ diff --git a/ui/styledemo/qrc/image/msg_info.png b/ui/styledemo/qrc/image/msg_info.png new file mode 100644 index 0000000..a305070 Binary files /dev/null and b/ui/styledemo/qrc/image/msg_info.png differ diff --git a/ui/styledemo/qrc/image/msg_question.png b/ui/styledemo/qrc/image/msg_question.png new file mode 100644 index 0000000..6d5abb1 Binary files /dev/null and b/ui/styledemo/qrc/image/msg_question.png differ diff --git a/ui/styledemo/qrc/main.qrc b/ui/styledemo/qrc/main.qrc new file mode 100644 index 0000000..1451ee0 --- /dev/null +++ b/ui/styledemo/qrc/main.qrc @@ -0,0 +1,9 @@ + + + image/btn_close.png + image/btn_ok.png + image/msg_error.png + image/msg_info.png + image/msg_question.png + + diff --git a/ui/styledemo/qrc/qm.qrc b/ui/styledemo/qrc/qm.qrc new file mode 100644 index 0000000..d14db1a --- /dev/null +++ b/ui/styledemo/qrc/qm.qrc @@ -0,0 +1,6 @@ + + + qm/qt_zh_CN.qm + qm/widgets.qm + + diff --git a/ui/styledemo/qrc/qm/qt_zh_CN.qm b/ui/styledemo/qrc/qm/qt_zh_CN.qm new file mode 100644 index 0000000..623b8e3 Binary files /dev/null and b/ui/styledemo/qrc/qm/qt_zh_CN.qm differ diff --git a/ui/styledemo/qrc/qm/widgets.qm b/ui/styledemo/qrc/qm/widgets.qm new file mode 100644 index 0000000..244bf0d Binary files /dev/null and b/ui/styledemo/qrc/qm/widgets.qm differ diff --git a/ui/styledemo/qrc/qss.qrc b/ui/styledemo/qrc/qss.qrc new file mode 100644 index 0000000..acc88b7 --- /dev/null +++ b/ui/styledemo/qrc/qss.qrc @@ -0,0 +1,76 @@ + + + qss/flatgray.css + qss/lightblue.css + qss/flatgray/add_bottom.png + qss/flatgray/add_left.png + qss/flatgray/add_right.png + qss/flatgray/add_top.png + qss/flatgray/arrow_bottom.png + qss/flatgray/arrow_left.png + qss/flatgray/arrow_right.png + qss/flatgray/arrow_top.png + qss/flatgray/branch_close.png + qss/flatgray/branch_open.png + qss/flatgray/calendar_nextmonth.png + qss/flatgray/calendar_prevmonth.png + qss/flatgray/checkbox_checked.png + qss/flatgray/checkbox_checked_disable.png + qss/flatgray/checkbox_parcial.png + qss/flatgray/checkbox_parcial_disable.png + qss/flatgray/checkbox_unchecked.png + qss/flatgray/checkbox_unchecked_disable.png + qss/flatgray/menu_checked.png + qss/flatgray/radiobutton_checked.png + qss/flatgray/radiobutton_checked_disable.png + qss/flatgray/radiobutton_unchecked.png + qss/flatgray/radiobutton_unchecked_disable.png + qss/lightblue/add_bottom.png + qss/lightblue/add_left.png + qss/lightblue/add_right.png + qss/lightblue/add_top.png + qss/lightblue/arrow_bottom.png + qss/lightblue/arrow_left.png + qss/lightblue/arrow_right.png + qss/lightblue/arrow_top.png + qss/lightblue/branch_close.png + qss/lightblue/branch_open.png + qss/lightblue/calendar_nextmonth.png + qss/lightblue/calendar_prevmonth.png + qss/lightblue/checkbox_checked.png + qss/lightblue/checkbox_checked_disable.png + qss/lightblue/checkbox_parcial.png + qss/lightblue/checkbox_parcial_disable.png + qss/lightblue/checkbox_unchecked.png + qss/lightblue/checkbox_unchecked_disable.png + qss/lightblue/menu_checked.png + qss/lightblue/radiobutton_checked.png + qss/lightblue/radiobutton_checked_disable.png + qss/lightblue/radiobutton_unchecked.png + qss/lightblue/radiobutton_unchecked_disable.png + qss/blacksoft.css + qss/blacksoft/add_bottom.png + qss/blacksoft/add_left.png + qss/blacksoft/add_right.png + qss/blacksoft/add_top.png + qss/blacksoft/arrow_bottom.png + qss/blacksoft/arrow_left.png + qss/blacksoft/arrow_right.png + qss/blacksoft/arrow_top.png + qss/blacksoft/branch_close.png + qss/blacksoft/branch_open.png + qss/blacksoft/calendar_nextmonth.png + qss/blacksoft/calendar_prevmonth.png + qss/blacksoft/checkbox_checked.png + qss/blacksoft/checkbox_checked_disable.png + qss/blacksoft/checkbox_parcial.png + qss/blacksoft/checkbox_parcial_disable.png + qss/blacksoft/checkbox_unchecked.png + qss/blacksoft/checkbox_unchecked_disable.png + qss/blacksoft/menu_checked.png + qss/blacksoft/radiobutton_checked.png + qss/blacksoft/radiobutton_checked_disable.png + qss/blacksoft/radiobutton_unchecked.png + qss/blacksoft/radiobutton_unchecked_disable.png + + diff --git a/ui/styledemo/qrc/qss/blacksoft.css b/ui/styledemo/qrc/qss/blacksoft.css new file mode 100644 index 0000000..6780634 --- /dev/null +++ b/ui/styledemo/qrc/qss/blacksoft.css @@ -0,0 +1,694 @@ +QPalette{background:#444444;}*{outline:0px;color:#DCDCDC;} + +QGraphicsView{ +border:1px solid #242424; +qproperty-backgroundBrush:#444444; +} + +QWidget[form="true"],QLabel[frameShape="1"]{ +border:1px solid #242424; +border-radius:0px; +} + +QWidget[form="bottom"]{ +background:#484848; +} + +QWidget[form="bottom"] .QFrame{ +border:1px solid #DCDCDC; +} + +QWidget[form="bottom"] QLabel,QWidget[form="title"] QLabel{ +border-radius:0px; +color:#DCDCDC; +background:none; +border-style:none; +} + +QWidget[form="title"],QWidget[nav="left"],QWidget[nav="top"] QAbstractButton{ +border-style:none; +border-radius:0px; +padding:5px; +color:#DCDCDC; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #484848,stop:1 #383838); +} + +QWidget[nav="top"] QAbstractButton:hover,QWidget[nav="top"] QAbstractButton:pressed,QWidget[nav="top"] QAbstractButton:checked{ +border-style:solid; +border-width:0px 0px 2px 0px; +padding:4px 4px 2px 4px; +border-color:#AAAAAA; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #646464,stop:1 #525252); +} + +QWidget[nav="left"] QAbstractButton{ +border-radius:0px; +color:#DCDCDC; +background:none; +border-style:none; +} + +QWidget[nav="left"] QAbstractButton:hover{ +color:#FFFFFF; +background-color:#AAAAAA; +} + +QWidget[nav="left"] QAbstractButton:checked,QWidget[nav="left"] QAbstractButton:pressed{ +color:#DCDCDC; +border-style:solid; +border-width:0px 0px 0px 2px; +padding:4px 4px 4px 2px; +border-color:#AAAAAA; +background-color:#444444; +} + +QWidget[video="true"] QLabel{ +color:#DCDCDC; +border:1px solid #242424; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #484848,stop:1 #383838); +} + +QWidget[video="true"] QLabel:focus{ +border:1px solid #AAAAAA; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #646464,stop:1 #525252); +} + +QLineEdit:read-only{ +background-color:#484848; +} + +QLineEdit,QTextEdit,QPlainTextEdit,QSpinBox,QDoubleSpinBox,QComboBox,QDateEdit,QTimeEdit,QDateTimeEdit{ +border:1px solid #242424; +border-radius:3px; +padding:2px; +background:none; +selection-background-color:#AAAAAA; +selection-color:#FFFFFF; +} + +QLineEdit:focus,QTextEdit:focus,QPlainTextEdit:focus,QSpinBox:focus,QDoubleSpinBox:focus,QComboBox:focus,QDateEdit:focus,QTimeEdit:focus,QDateTimeEdit:focus,QLineEdit:hover,QTextEdit:hover,QPlainTextEdit:hover,QSpinBox:hover,QDoubleSpinBox:hover,QComboBox:hover,QDateEdit:hover,QTimeEdit:hover,QDateTimeEdit:hover{ +border:1px solid #242424; +} + +QLineEdit[echoMode="2"]{ +lineedit-password-character:9679; +} + +.QFrame{ +border:1px solid #242424; +border-radius:3px; +} + +.QGroupBox{ +border:1px solid #242424; +border-radius:5px; +margin-top:9px; +} + +.QGroupBox::title{ +subcontrol-origin:margin; +position:relative; +left:10px; +} + +.QPushButton,.QToolButton{ +border-style:none; +border:1px solid #242424; +color:#DCDCDC; +padding:5px; +min-height:15px; +border-radius:5px; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #484848,stop:1 #383838); +} + +.QPushButton:hover,.QToolButton:hover{ +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #646464,stop:1 #525252); +} + +.QPushButton:pressed,.QToolButton:pressed{ +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #484848,stop:1 #383838); +} + +.QToolButton::menu-indicator{ +image:None; +} + +QToolButton#btnMenu,QPushButton#btnMenu_Min,QPushButton#btnMenu_Max,QPushButton#btnMenu_Close{ +border-radius:3px; +color:#DCDCDC; +padding:3px; +margin:0px; +background:none; +border-style:none; +} + +QToolButton#btnMenu:hover,QPushButton#btnMenu_Min:hover,QPushButton#btnMenu_Max:hover{ +color:#FFFFFF; +margin:1px 1px 2px 1px; +background-color:rgba(51,127,209,230); +} + +QPushButton#btnMenu_Close:hover{ +color:#FFFFFF; +margin:1px 1px 2px 1px; +background-color:rgba(238,0,0,128); +} + +QRadioButton::indicator{ +width:15px; +height:15px; +} + +QRadioButton::indicator::unchecked{ +image:url(:/qss/blacksoft/radiobutton_unchecked.png); +} + +QRadioButton::indicator::unchecked:disabled{ +image:url(:/qss/blacksoft/radiobutton_unchecked_disable.png); +} + +QRadioButton::indicator::checked{ +image:url(:/qss/blacksoft/radiobutton_checked.png); +} + +QRadioButton::indicator::checked:disabled{ +image:url(:/qss/blacksoft/radiobutton_checked_disable.png); +} + +QGroupBox::indicator,QTreeView::indicator,QListView::indicator,QTableView::indicator{ +padding:0px 0px 0px 0px; +} + +QCheckBox::indicator,QGroupBox::indicator,QTreeView::indicator,QListView::indicator,QTableView::indicator{ +width:13px; +height:13px; +} + +QCheckBox::indicator:unchecked,QGroupBox::indicator:unchecked,QTreeView::indicator:unchecked,QListView::indicator:unchecked,QTableView::indicator:unchecked{ +image:url(:/qss/blacksoft/checkbox_unchecked.png); +} + +QCheckBox::indicator:unchecked:disabled,QGroupBox::indicator:unchecked:disabled,QTreeView::indicator:unchecked:disabled,QListView::indicator:unchecked:disabled,QTableView::indicator:unchecked:disabled{ +image:url(:/qss/blacksoft/checkbox_unchecked_disable.png); +} + +QCheckBox::indicator:checked,QGroupBox::indicator:checked,QTreeView::indicator:checked,QListView::indicator:checked,QTableView::indicator:checked{ +image:url(:/qss/blacksoft/checkbox_checked.png); +} + +QCheckBox::indicator:checked:disabled,QGroupBox::indicator:checked:disabled,QTreeView::indicator:checked:disabled,QListView::indicator:checked:disabled,QTableView::indicator:checked:disabled{ +image:url(:/qss/blacksoft/checkbox_checked_disable.png); +} + +QCheckBox::indicator:indeterminate,QGroupBox::indicator:indeterminate,QTreeView::indicator:indeterminate,QListView::indicator:indeterminate,QTableView::indicator:indeterminate{ +image:url(:/qss/blacksoft/checkbox_parcial.png); +} + +QCheckBox::indicator:indeterminate:disabled,QGroupBox::indicator:indeterminate:disabled,QTreeView::indicator:indeterminate:disabled,QListView::indicator:indeterminate:disabled,QTableView::indicator:indeterminate:disabled{ +image:url(:/qss/blacksoft/checkbox_parcial_disable.png); +} + +QTimeEdit::up-button,QDateEdit::up-button,QDateTimeEdit::up-button,QDoubleSpinBox::up-button,QSpinBox::up-button{ +image:url(:/qss/blacksoft/add_top.png); +width:10px; +height:10px; +padding:2px 5px 0px 0px; +} + +QTimeEdit::down-button,QDateEdit::down-button,QDateTimeEdit::down-button,QDoubleSpinBox::down-button,QSpinBox::down-button{ +image:url(:/qss/blacksoft/add_bottom.png); +width:10px; +height:10px; +padding:0px 5px 2px 0px; +} + +QTimeEdit::up-button:pressed,QDateEdit::up-button:pressed,QDateTimeEdit::up-button:pressed,QDoubleSpinBox::up-button:pressed,QSpinBox::up-button:pressed{ +top:-2px; +} + +QTimeEdit::down-button:pressed,QDateEdit::down-button:pressed,QDateTimeEdit::down-button:pressed,QDoubleSpinBox::down-button:pressed,QSpinBox::down-button:pressed,QSpinBox::down-button:pressed{ +bottom:-2px; +} + +QComboBox::down-arrow,QDateEdit[calendarPopup="true"]::down-arrow,QTimeEdit[calendarPopup="true"]::down-arrow,QDateTimeEdit[calendarPopup="true"]::down-arrow{ +image:url(:/qss/blacksoft/add_bottom.png); +width:10px; +height:10px; +right:2px; +} + +QComboBox::drop-down,QDateEdit::drop-down,QTimeEdit::drop-down,QDateTimeEdit::drop-down{ +subcontrol-origin:padding; +subcontrol-position:top right; +width:15px; +border-left-width:0px; +border-left-style:solid; +border-top-right-radius:3px; +border-bottom-right-radius:3px; +border-left-color:#242424; +} + +QComboBox::drop-down:on{ +top:1px; +} + +QMenuBar::item{ +color:#DCDCDC; +background-color:#484848; +margin:0px; +padding:3px 10px; +} + +QMenu,QMenuBar,QMenu:disabled,QMenuBar:disabled{ +color:#DCDCDC; +background-color:#484848; +border:1px solid #242424; +margin:0px; +} + +QMenu::item{ +padding:3px 20px; +} + +QMenu::indicator{ +width:20px; +height:13px; +} + +QMenu::indicator::checked{ +image:url(:/qss/blacksoft/menu_checked.png); +} + +QMenu::right-arrow{ +image:url(:/qss/blacksoft/arrow_right.png); +width:13px; +height:13px; +padding:0px 3px 0px 0px; +} + +QMenu::item:selected,QMenuBar::item:selected{ +color:#DCDCDC; +border:0px solid #242424; +background:#646464; +} + +QMenu::separator{ +height:1px; +background:#242424; +} + +QProgressBar{ +min-height:10px; +background:#484848; +border-radius:5px; +text-align:center; +border:1px solid #484848; +} + +QProgressBar:chunk{ +border-radius:5px; +background-color:#242424; +} + +QSlider::groove:horizontal{ +height:8px; +border-radius:4px; +background:#484848; +} + +QSlider::add-page:horizontal{ +height:8px; +border-radius:4px; +background:#484848; +} + +QSlider::sub-page:horizontal{ +height:8px; +border-radius:4px; +background:#242424; +} + +QSlider::handle:horizontal{ +width:13px; +margin-top:-3px; +margin-bottom:-3px; +border-radius:6px; +background:qradialgradient(spread:pad,cx:0.5,cy:0.5,radius:0.5,fx:0.5,fy:0.5,stop:0.6 #444444,stop:0.8 #242424); +} + +QSlider::groove:vertical{ +width:8px; +border-radius:4px; +background:#484848; +} + +QSlider::add-page:vertical{ +width:8px; +border-radius:4px; +background:#242424; +} + +QSlider::sub-page:vertical{ +width:8px; +border-radius:4px; +background:#484848; +} + +QSlider::handle:vertical{ +height:14px; +margin-left:-3px; +margin-right:-3px; +border-radius:6px; +background:qradialgradient(spread:pad,cx:0.5,cy:0.5,radius:0.5,fx:0.5,fy:0.5,stop:0.6 #444444,stop:0.8 #242424); +} + +QScrollBar:horizontal{ +background:#484848; +padding:0px; +border-radius:6px; +max-height:12px; +} + +QScrollBar::handle:horizontal{ +background:#242424; +min-width:50px; +border-radius:6px; +} + +QScrollBar::handle:horizontal:hover{ +background:#AAAAAA; +} + +QScrollBar::handle:horizontal:pressed{ +background:#AAAAAA; +} + +QScrollBar::add-page:horizontal{ +background:none; +} + +QScrollBar::sub-page:horizontal{ +background:none; +} + +QScrollBar::add-line:horizontal{ +background:none; +} + +QScrollBar::sub-line:horizontal{ +background:none; +} + +QScrollBar:vertical{ +background:#484848; +padding:0px; +border-radius:6px; +max-width:12px; +} + +QScrollBar::handle:vertical{ +background:#242424; +min-height:50px; +border-radius:6px; +} + +QScrollBar::handle:vertical:hover{ +background:#AAAAAA; +} + +QScrollBar::handle:vertical:pressed{ +background:#AAAAAA; +} + +QScrollBar::add-page:vertical{ +background:none; +} + +QScrollBar::sub-page:vertical{ +background:none; +} + +QScrollBar::add-line:vertical{ +background:none; +} + +QScrollBar::sub-line:vertical{ +background:none; +} + +QScrollArea{ +border:0px; +} + +QTreeView,QListView,QTableView,QTabWidget::pane{ +border:1px solid #242424; +selection-background-color:#646464; +selection-color:#DCDCDC; +alternate-background-color:#525252; +gridline-color:#242424; +} + +QTreeView::branch:closed:has-children{ +margin:4px; +border-image:url(:/qss/blacksoft/branch_open.png); +} + +QTreeView::branch:open:has-children{ +margin:4px; +border-image:url(:/qss/blacksoft/branch_close.png); +} + +QTreeView,QListView,QTableView,QSplitter::handle,QTreeView::branch{ +background:#444444; +} + +QTableView::item:selected,QListView::item:selected,QTreeView::item:selected{ +color:#DCDCDC; +background:#383838; +} + +QTableView::item:hover,QListView::item:hover,QTreeView::item:hover,QHeaderView,QHeaderView::section,QTableCornerButton:section{ +color:#DCDCDC; +background:#525252; +} + +QTableView::item,QListView::item,QTreeView::item{ +padding:1px; +margin:0px; +border:0px; +} + +QHeaderView::section,QTableCornerButton:section{ +padding:3px; +margin:0px; +border:1px solid #242424; +border-left-width:0px; +border-right-width:1px; +border-top-width:0px; +border-bottom-width:1px; +} + +QTabBar::tab{ +border:1px solid #242424; +color:#DCDCDC; +margin:0px; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #646464,stop:1 #525252); +} + +QTabBar::tab:selected{ +border-style:solid; +border-color:#AAAAAA; +background:#444444; +} + +QTabBar::tab:top,QTabBar::tab:bottom{ +padding:3px 8px 3px 8px; +} + +QTabBar::tab:left,QTabBar::tab:right{ +padding:8px 3px 8px 3px; +} + +QTabBar::tab:top:selected{ +border-width:2px 0px 0px 0px; +} + +QTabBar::tab:right:selected{ +border-width:0px 0px 0px 2px; +} + +QTabBar::tab:bottom:selected{ +border-width:0px 0px 2px 0px; +} + +QTabBar::tab:left:selected{ +border-width:0px 2px 0px 0px; +} + +QTabBar::tab:first:top:selected,QTabBar::tab:first:bottom:selected{ +border-left-width:1px; +border-left-color:#242424; +} + +QTabBar::tab:first:left:selected,QTabBar::tab:first:right:selected{ +border-top-width:1px; +border-top-color:#242424; +} + +QTabBar::tab:last:top:selected,QTabBar::tab:last:bottom:selected{ +border-right-width:1px; +border-right-color:#242424; +} + +QTabBar::tab:last:left:selected,QTabBar::tab:last:right:selected{ +border-bottom-width:1px; +border-bottom-color:#242424; +} + +QStatusBar::item{ +border:0px solid #484848; +border-radius:3px; +} + +QToolBox::tab,QWidget[form="panel"]{ +padding:3px; +border-radius:5px; +color:#DCDCDC; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #484848,stop:1 #383838); +} + +QWidget[flag="paneltitle"]{ +border-bottom-left-radius:0px; +border-bottom-right-radius:0px; +} + +QWidget[flag="panelcontrol"]{ +border-top-width:0px; +border-top-left-radius:0px; +border-top-right-radius:0px; +} + +QToolTip{ +border:0px solid #DCDCDC; +padding:1px; +color:#DCDCDC; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #484848,stop:1 #383838); +} + +QToolBox::tab:selected{ +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #646464,stop:1 #525252); +} + +QPrintPreviewDialog QToolButton{ +border:0px solid #DCDCDC; +border-radius:0px; +margin:0px; +padding:3px; +background:none; +} + +QColorDialog QPushButton,QFileDialog QPushButton{ +min-width:80px; +} + +QToolButton#qt_calendar_prevmonth{ +icon-size:0px; +min-width:20px; +image:url(:/qss/blacksoft/calendar_prevmonth.png); +} + +QToolButton#qt_calendar_nextmonth{ +icon-size:0px; +min-width:20px; +image:url(:/qss/blacksoft/calendar_nextmonth.png); +} + +QToolButton#qt_calendar_prevmonth,QToolButton#qt_calendar_nextmonth,QToolButton#qt_calendar_monthbutton,QToolButton#qt_calendar_yearbutton{ +border:0px solid #DCDCDC; +border-radius:3px; +margin:3px 3px 3px 3px; +padding:3px; +background:none; +} + +QToolButton#qt_calendar_prevmonth:hover,QToolButton#qt_calendar_nextmonth:hover,QToolButton#qt_calendar_monthbutton:hover,QToolButton#qt_calendar_yearbutton:hover,QToolButton#qt_calendar_prevmonth:pressed,QToolButton#qt_calendar_nextmonth:pressed,QToolButton#qt_calendar_monthbutton:pressed,QToolButton#qt_calendar_yearbutton:pressed{ +border:1px solid #242424; +} + +QCalendarWidget QSpinBox#qt_calendar_yearedit{ +margin:2px; +} + +QCalendarWidget QToolButton::menu-indicator{ +image:None; +} + +QCalendarWidget QTableView{ +border-width:0px; +} + +QCalendarWidget QWidget#qt_calendar_navigationbar{ +border:1px solid #242424; +border-width:1px 1px 0px 1px; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #484848,stop:1 #383838); +} + +QTableView[model="true"]::item{ +padding:0px; +margin:0px; +} + +QTableView QLineEdit,QTableView QComboBox,QTableView QSpinBox,QTableView QDoubleSpinBox,QTableView QDateEdit,QTableView QTimeEdit,QTableView QDateTimeEdit{ +border-width:0px; +border-radius:0px; +} + +QTableView QLineEdit:focus,QTableView QComboBox:focus,QTableView QSpinBox:focus,QTableView QDoubleSpinBox:focus,QTableView QDateEdit:focus,QTableView QTimeEdit:focus,QTableView QDateTimeEdit:focus{ +border-width:0px; +border-radius:0px; +} + +QLineEdit,QTextEdit,QPlainTextEdit,QSpinBox,QDoubleSpinBox,QComboBox,QDateEdit,QTimeEdit,QDateTimeEdit{ +background:#444444; +} + +QTabWidget::pane:top{top:-1px;} +QTabWidget::pane:bottom{bottom:-1px;} +QTabWidget::pane:left{right:-1px;} +QTabWidget::pane:right{left:-1px;} + +QDialog,QDial,#QUIWidgetMain{ +background-color:#444444; +color:#DCDCDC; +} + +QDialogButtonBox>QPushButton{ +min-width:50px; +} + +QListView[noborder="true"],QTreeView[noborder="true"],QTabWidget[noborder="true"]::pane{ +border-width:0px; +} + +QToolBar>*,QStatusBar>*{ +margin:2px; +} + +*:disabled,QMenu::item:disabled,QTabBar:tab:disabled,QHeaderView::section:disabled{ +background:#444444; +border-color:#484848; +color:#242424; +} + +QLabel:disabled{ +background:none; +} + +/*TextColor:#DCDCDC*/ +/*PanelColor:#444444*/ +/*BorderColor:#242424*/ +/*NormalColorStart:#484848*/ +/*NormalColorEnd:#383838*/ +/*DarkColorStart:#646464*/ +/*DarkColorEnd:#525252*/ +/*HighColor:#AAAAAA*/ \ No newline at end of file diff --git a/ui/styledemo/qrc/qss/blacksoft/add_bottom.png b/ui/styledemo/qrc/qss/blacksoft/add_bottom.png new file mode 100644 index 0000000..b4a5f14 Binary files /dev/null and b/ui/styledemo/qrc/qss/blacksoft/add_bottom.png differ diff --git a/ui/styledemo/qrc/qss/blacksoft/add_left.png b/ui/styledemo/qrc/qss/blacksoft/add_left.png new file mode 100644 index 0000000..165ebd0 Binary files /dev/null and b/ui/styledemo/qrc/qss/blacksoft/add_left.png differ diff --git a/ui/styledemo/qrc/qss/blacksoft/add_right.png b/ui/styledemo/qrc/qss/blacksoft/add_right.png new file mode 100644 index 0000000..4c79925 Binary files /dev/null and b/ui/styledemo/qrc/qss/blacksoft/add_right.png differ diff --git a/ui/styledemo/qrc/qss/blacksoft/add_top.png b/ui/styledemo/qrc/qss/blacksoft/add_top.png new file mode 100644 index 0000000..f76300f Binary files /dev/null and b/ui/styledemo/qrc/qss/blacksoft/add_top.png differ diff --git a/ui/styledemo/qrc/qss/blacksoft/arrow_bottom.png b/ui/styledemo/qrc/qss/blacksoft/arrow_bottom.png new file mode 100644 index 0000000..39d7cbc Binary files /dev/null and b/ui/styledemo/qrc/qss/blacksoft/arrow_bottom.png differ diff --git a/ui/styledemo/qrc/qss/blacksoft/arrow_left.png b/ui/styledemo/qrc/qss/blacksoft/arrow_left.png new file mode 100644 index 0000000..1353cb8 Binary files /dev/null and b/ui/styledemo/qrc/qss/blacksoft/arrow_left.png differ diff --git a/ui/styledemo/qrc/qss/blacksoft/arrow_right.png b/ui/styledemo/qrc/qss/blacksoft/arrow_right.png new file mode 100644 index 0000000..0e50d47 Binary files /dev/null and b/ui/styledemo/qrc/qss/blacksoft/arrow_right.png differ diff --git a/ui/styledemo/qrc/qss/blacksoft/arrow_top.png b/ui/styledemo/qrc/qss/blacksoft/arrow_top.png new file mode 100644 index 0000000..d2c71e8 Binary files /dev/null and b/ui/styledemo/qrc/qss/blacksoft/arrow_top.png differ diff --git a/ui/styledemo/qrc/qss/blacksoft/branch_close.png b/ui/styledemo/qrc/qss/blacksoft/branch_close.png new file mode 100644 index 0000000..58a7d13 Binary files /dev/null and b/ui/styledemo/qrc/qss/blacksoft/branch_close.png differ diff --git a/ui/styledemo/qrc/qss/blacksoft/branch_open.png b/ui/styledemo/qrc/qss/blacksoft/branch_open.png new file mode 100644 index 0000000..a072d68 Binary files /dev/null and b/ui/styledemo/qrc/qss/blacksoft/branch_open.png differ diff --git a/ui/styledemo/qrc/qss/blacksoft/calendar_nextmonth.png b/ui/styledemo/qrc/qss/blacksoft/calendar_nextmonth.png new file mode 100644 index 0000000..b06ae31 Binary files /dev/null and b/ui/styledemo/qrc/qss/blacksoft/calendar_nextmonth.png differ diff --git a/ui/styledemo/qrc/qss/blacksoft/calendar_prevmonth.png b/ui/styledemo/qrc/qss/blacksoft/calendar_prevmonth.png new file mode 100644 index 0000000..46d4d62 Binary files /dev/null and b/ui/styledemo/qrc/qss/blacksoft/calendar_prevmonth.png differ diff --git a/ui/styledemo/qrc/qss/blacksoft/checkbox_checked.png b/ui/styledemo/qrc/qss/blacksoft/checkbox_checked.png new file mode 100644 index 0000000..b5ba6ef Binary files /dev/null and b/ui/styledemo/qrc/qss/blacksoft/checkbox_checked.png differ diff --git a/ui/styledemo/qrc/qss/blacksoft/checkbox_checked_disable.png b/ui/styledemo/qrc/qss/blacksoft/checkbox_checked_disable.png new file mode 100644 index 0000000..f6aab40 Binary files /dev/null and b/ui/styledemo/qrc/qss/blacksoft/checkbox_checked_disable.png differ diff --git a/ui/styledemo/qrc/qss/blacksoft/checkbox_parcial.png b/ui/styledemo/qrc/qss/blacksoft/checkbox_parcial.png new file mode 100644 index 0000000..cd1645f Binary files /dev/null and b/ui/styledemo/qrc/qss/blacksoft/checkbox_parcial.png differ diff --git a/ui/styledemo/qrc/qss/blacksoft/checkbox_parcial_disable.png b/ui/styledemo/qrc/qss/blacksoft/checkbox_parcial_disable.png new file mode 100644 index 0000000..dd0918f Binary files /dev/null and b/ui/styledemo/qrc/qss/blacksoft/checkbox_parcial_disable.png differ diff --git a/ui/styledemo/qrc/qss/blacksoft/checkbox_unchecked.png b/ui/styledemo/qrc/qss/blacksoft/checkbox_unchecked.png new file mode 100644 index 0000000..8a23968 Binary files /dev/null and b/ui/styledemo/qrc/qss/blacksoft/checkbox_unchecked.png differ diff --git a/ui/styledemo/qrc/qss/blacksoft/checkbox_unchecked_disable.png b/ui/styledemo/qrc/qss/blacksoft/checkbox_unchecked_disable.png new file mode 100644 index 0000000..e2a2262 Binary files /dev/null and b/ui/styledemo/qrc/qss/blacksoft/checkbox_unchecked_disable.png differ diff --git a/ui/styledemo/qrc/qss/blacksoft/menu_checked.png b/ui/styledemo/qrc/qss/blacksoft/menu_checked.png new file mode 100644 index 0000000..4fca11f Binary files /dev/null and b/ui/styledemo/qrc/qss/blacksoft/menu_checked.png differ diff --git a/ui/styledemo/qrc/qss/blacksoft/radiobutton_checked.png b/ui/styledemo/qrc/qss/blacksoft/radiobutton_checked.png new file mode 100644 index 0000000..69e499f Binary files /dev/null and b/ui/styledemo/qrc/qss/blacksoft/radiobutton_checked.png differ diff --git a/ui/styledemo/qrc/qss/blacksoft/radiobutton_checked_disable.png b/ui/styledemo/qrc/qss/blacksoft/radiobutton_checked_disable.png new file mode 100644 index 0000000..f098cc5 Binary files /dev/null and b/ui/styledemo/qrc/qss/blacksoft/radiobutton_checked_disable.png differ diff --git a/ui/styledemo/qrc/qss/blacksoft/radiobutton_unchecked.png b/ui/styledemo/qrc/qss/blacksoft/radiobutton_unchecked.png new file mode 100644 index 0000000..3f36472 Binary files /dev/null and b/ui/styledemo/qrc/qss/blacksoft/radiobutton_unchecked.png differ diff --git a/ui/styledemo/qrc/qss/blacksoft/radiobutton_unchecked_disable.png b/ui/styledemo/qrc/qss/blacksoft/radiobutton_unchecked_disable.png new file mode 100644 index 0000000..f729f17 Binary files /dev/null and b/ui/styledemo/qrc/qss/blacksoft/radiobutton_unchecked_disable.png differ diff --git a/ui/styledemo/qrc/qss/flatgray.css b/ui/styledemo/qrc/qss/flatgray.css new file mode 100644 index 0000000..fe82b5b --- /dev/null +++ b/ui/styledemo/qrc/qss/flatgray.css @@ -0,0 +1,694 @@ +QPalette{background:#FFFFFF;}*{outline:0px;color:#57595B;} + +QGraphicsView{ +border:1px solid #B6B6B6; +qproperty-backgroundBrush:#FFFFFF; +} + +QWidget[form="true"],QLabel[frameShape="1"]{ +border:1px solid #B6B6B6; +border-radius:0px; +} + +QWidget[form="bottom"]{ +background:#E4E4E4; +} + +QWidget[form="bottom"] .QFrame{ +border:1px solid #57595B; +} + +QWidget[form="bottom"] QLabel,QWidget[form="title"] QLabel{ +border-radius:0px; +color:#57595B; +background:none; +border-style:none; +} + +QWidget[form="title"],QWidget[nav="left"],QWidget[nav="top"] QAbstractButton{ +border-style:none; +border-radius:0px; +padding:5px; +color:#57595B; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #E4E4E4,stop:1 #E4E4E4); +} + +QWidget[nav="top"] QAbstractButton:hover,QWidget[nav="top"] QAbstractButton:pressed,QWidget[nav="top"] QAbstractButton:checked{ +border-style:solid; +border-width:0px 0px 2px 0px; +padding:4px 4px 2px 4px; +border-color:#575959; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #F6F6F6,stop:1 #F6F6F6); +} + +QWidget[nav="left"] QAbstractButton{ +border-radius:0px; +color:#57595B; +background:none; +border-style:none; +} + +QWidget[nav="left"] QAbstractButton:hover{ +color:#FFFFFF; +background-color:#575959; +} + +QWidget[nav="left"] QAbstractButton:checked,QWidget[nav="left"] QAbstractButton:pressed{ +color:#57595B; +border-style:solid; +border-width:0px 0px 0px 2px; +padding:4px 4px 4px 2px; +border-color:#575959; +background-color:#FFFFFF; +} + +QWidget[video="true"] QLabel{ +color:#57595B; +border:1px solid #B6B6B6; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #E4E4E4,stop:1 #E4E4E4); +} + +QWidget[video="true"] QLabel:focus{ +border:1px solid #575959; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #F6F6F6,stop:1 #F6F6F6); +} + +QLineEdit:read-only{ +background-color:#E4E4E4; +} + +QLineEdit,QTextEdit,QPlainTextEdit,QSpinBox,QDoubleSpinBox,QComboBox,QDateEdit,QTimeEdit,QDateTimeEdit{ +border:1px solid #B6B6B6; +border-radius:3px; +padding:2px; +background:none; +selection-background-color:#575959; +selection-color:#FFFFFF; +} + +QLineEdit:focus,QTextEdit:focus,QPlainTextEdit:focus,QSpinBox:focus,QDoubleSpinBox:focus,QComboBox:focus,QDateEdit:focus,QTimeEdit:focus,QDateTimeEdit:focus,QLineEdit:hover,QTextEdit:hover,QPlainTextEdit:hover,QSpinBox:hover,QDoubleSpinBox:hover,QComboBox:hover,QDateEdit:hover,QTimeEdit:hover,QDateTimeEdit:hover{ +border:1px solid #B6B6B6; +} + +QLineEdit[echoMode="2"]{ +lineedit-password-character:9679; +} + +.QFrame{ +border:1px solid #B6B6B6; +border-radius:3px; +} + +.QGroupBox{ +border:1px solid #B6B6B6; +border-radius:5px; +margin-top:9px; +} + +.QGroupBox::title{ +subcontrol-origin:margin; +position:relative; +left:10px; +} + +.QPushButton,.QToolButton{ +border-style:none; +border:1px solid #B6B6B6; +color:#57595B; +padding:5px; +min-height:15px; +border-radius:5px; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #E4E4E4,stop:1 #E4E4E4); +} + +.QPushButton:hover,.QToolButton:hover{ +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #F6F6F6,stop:1 #F6F6F6); +} + +.QPushButton:pressed,.QToolButton:pressed{ +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #E4E4E4,stop:1 #E4E4E4); +} + +.QToolButton::menu-indicator{ +image:None; +} + +QToolButton#btnMenu,QPushButton#btnMenu_Min,QPushButton#btnMenu_Max,QPushButton#btnMenu_Close{ +border-radius:3px; +color:#57595B; +padding:3px; +margin:0px; +background:none; +border-style:none; +} + +QToolButton#btnMenu:hover,QPushButton#btnMenu_Min:hover,QPushButton#btnMenu_Max:hover{ +color:#FFFFFF; +margin:1px 1px 2px 1px; +background-color:rgba(51,127,209,230); +} + +QPushButton#btnMenu_Close:hover{ +color:#FFFFFF; +margin:1px 1px 2px 1px; +background-color:rgba(238,0,0,128); +} + +QRadioButton::indicator{ +width:15px; +height:15px; +} + +QRadioButton::indicator::unchecked{ +image:url(:/qss/flatgray/radiobutton_unchecked.png); +} + +QRadioButton::indicator::unchecked:disabled{ +image:url(:/qss/flatgray/radiobutton_unchecked_disable.png); +} + +QRadioButton::indicator::checked{ +image:url(:/qss/flatgray/radiobutton_checked.png); +} + +QRadioButton::indicator::checked:disabled{ +image:url(:/qss/flatgray/radiobutton_checked_disable.png); +} + +QGroupBox::indicator,QTreeView::indicator,QListView::indicator,QTableView::indicator{ +padding:0px 0px 0px 0px; +} + +QCheckBox::indicator,QGroupBox::indicator,QTreeView::indicator,QListView::indicator,QTableView::indicator{ +width:13px; +height:13px; +} + +QCheckBox::indicator:unchecked,QGroupBox::indicator:unchecked,QTreeView::indicator:unchecked,QListView::indicator:unchecked,QTableView::indicator:unchecked{ +image:url(:/qss/flatgray/checkbox_unchecked.png); +} + +QCheckBox::indicator:unchecked:disabled,QGroupBox::indicator:unchecked:disabled,QTreeView::indicator:unchecked:disabled,QListView::indicator:unchecked:disabled,QTableView::indicator:unchecked:disabled{ +image:url(:/qss/flatgray/checkbox_unchecked_disable.png); +} + +QCheckBox::indicator:checked,QGroupBox::indicator:checked,QTreeView::indicator:checked,QListView::indicator:checked,QTableView::indicator:checked{ +image:url(:/qss/flatgray/checkbox_checked.png); +} + +QCheckBox::indicator:checked:disabled,QGroupBox::indicator:checked:disabled,QTreeView::indicator:checked:disabled,QListView::indicator:checked:disabled,QTableView::indicator:checked:disabled{ +image:url(:/qss/flatgray/checkbox_checked_disable.png); +} + +QCheckBox::indicator:indeterminate,QGroupBox::indicator:indeterminate,QTreeView::indicator:indeterminate,QListView::indicator:indeterminate,QTableView::indicator:indeterminate{ +image:url(:/qss/flatgray/checkbox_parcial.png); +} + +QCheckBox::indicator:indeterminate:disabled,QGroupBox::indicator:indeterminate:disabled,QTreeView::indicator:indeterminate:disabled,QListView::indicator:indeterminate:disabled,QTableView::indicator:indeterminate:disabled{ +image:url(:/qss/flatgray/checkbox_parcial_disable.png); +} + +QTimeEdit::up-button,QDateEdit::up-button,QDateTimeEdit::up-button,QDoubleSpinBox::up-button,QSpinBox::up-button{ +image:url(:/qss/flatgray/add_top.png); +width:10px; +height:10px; +padding:2px 5px 0px 0px; +} + +QTimeEdit::down-button,QDateEdit::down-button,QDateTimeEdit::down-button,QDoubleSpinBox::down-button,QSpinBox::down-button{ +image:url(:/qss/flatgray/add_bottom.png); +width:10px; +height:10px; +padding:0px 5px 2px 0px; +} + +QTimeEdit::up-button:pressed,QDateEdit::up-button:pressed,QDateTimeEdit::up-button:pressed,QDoubleSpinBox::up-button:pressed,QSpinBox::up-button:pressed{ +top:-2px; +} + +QTimeEdit::down-button:pressed,QDateEdit::down-button:pressed,QDateTimeEdit::down-button:pressed,QDoubleSpinBox::down-button:pressed,QSpinBox::down-button:pressed,QSpinBox::down-button:pressed{ +bottom:-2px; +} + +QComboBox::down-arrow,QDateEdit[calendarPopup="true"]::down-arrow,QTimeEdit[calendarPopup="true"]::down-arrow,QDateTimeEdit[calendarPopup="true"]::down-arrow{ +image:url(:/qss/flatgray/add_bottom.png); +width:10px; +height:10px; +right:2px; +} + +QComboBox::drop-down,QDateEdit::drop-down,QTimeEdit::drop-down,QDateTimeEdit::drop-down{ +subcontrol-origin:padding; +subcontrol-position:top right; +width:15px; +border-left-width:0px; +border-left-style:solid; +border-top-right-radius:3px; +border-bottom-right-radius:3px; +border-left-color:#B6B6B6; +} + +QComboBox::drop-down:on{ +top:1px; +} + +QMenuBar::item{ +color:#57595B; +background-color:#E4E4E4; +margin:0px; +padding:3px 10px; +} + +QMenu,QMenuBar,QMenu:disabled,QMenuBar:disabled{ +color:#57595B; +background-color:#E4E4E4; +border:1px solid #B6B6B6; +margin:0px; +} + +QMenu::item{ +padding:3px 20px; +} + +QMenu::indicator{ +width:20px; +height:13px; +} + +QMenu::indicator::checked{ +image:url(:/qss/flatgray/menu_checked.png); +} + +QMenu::right-arrow{ +image:url(:/qss/flatgray/arrow_right.png); +width:13px; +height:13px; +padding:0px 3px 0px 0px; +} + +QMenu::item:selected,QMenuBar::item:selected{ +color:#57595B; +border:0px solid #B6B6B6; +background:#F6F6F6; +} + +QMenu::separator{ +height:1px; +background:#B6B6B6; +} + +QProgressBar{ +min-height:10px; +background:#E4E4E4; +border-radius:5px; +text-align:center; +border:1px solid #E4E4E4; +} + +QProgressBar:chunk{ +border-radius:5px; +background-color:#B6B6B6; +} + +QSlider::groove:horizontal{ +height:8px; +border-radius:4px; +background:#E4E4E4; +} + +QSlider::add-page:horizontal{ +height:8px; +border-radius:4px; +background:#E4E4E4; +} + +QSlider::sub-page:horizontal{ +height:8px; +border-radius:4px; +background:#B6B6B6; +} + +QSlider::handle:horizontal{ +width:13px; +margin-top:-3px; +margin-bottom:-3px; +border-radius:6px; +background:qradialgradient(spread:pad,cx:0.5,cy:0.5,radius:0.5,fx:0.5,fy:0.5,stop:0.6 #FFFFFF,stop:0.8 #B6B6B6); +} + +QSlider::groove:vertical{ +width:8px; +border-radius:4px; +background:#E4E4E4; +} + +QSlider::add-page:vertical{ +width:8px; +border-radius:4px; +background:#B6B6B6; +} + +QSlider::sub-page:vertical{ +width:8px; +border-radius:4px; +background:#E4E4E4; +} + +QSlider::handle:vertical{ +height:14px; +margin-left:-3px; +margin-right:-3px; +border-radius:6px; +background:qradialgradient(spread:pad,cx:0.5,cy:0.5,radius:0.5,fx:0.5,fy:0.5,stop:0.6 #FFFFFF,stop:0.8 #B6B6B6); +} + +QScrollBar:horizontal{ +background:#E4E4E4; +padding:0px; +border-radius:6px; +max-height:12px; +} + +QScrollBar::handle:horizontal{ +background:#B6B6B6; +min-width:50px; +border-radius:6px; +} + +QScrollBar::handle:horizontal:hover{ +background:#575959; +} + +QScrollBar::handle:horizontal:pressed{ +background:#575959; +} + +QScrollBar::add-page:horizontal{ +background:none; +} + +QScrollBar::sub-page:horizontal{ +background:none; +} + +QScrollBar::add-line:horizontal{ +background:none; +} + +QScrollBar::sub-line:horizontal{ +background:none; +} + +QScrollBar:vertical{ +background:#E4E4E4; +padding:0px; +border-radius:6px; +max-width:12px; +} + +QScrollBar::handle:vertical{ +background:#B6B6B6; +min-height:50px; +border-radius:6px; +} + +QScrollBar::handle:vertical:hover{ +background:#575959; +} + +QScrollBar::handle:vertical:pressed{ +background:#575959; +} + +QScrollBar::add-page:vertical{ +background:none; +} + +QScrollBar::sub-page:vertical{ +background:none; +} + +QScrollBar::add-line:vertical{ +background:none; +} + +QScrollBar::sub-line:vertical{ +background:none; +} + +QScrollArea{ +border:0px; +} + +QTreeView,QListView,QTableView,QTabWidget::pane{ +border:1px solid #B6B6B6; +selection-background-color:#F6F6F6; +selection-color:#57595B; +alternate-background-color:#F6F6F6; +gridline-color:#B6B6B6; +} + +QTreeView::branch:closed:has-children{ +margin:4px; +border-image:url(:/qss/flatgray/branch_open.png); +} + +QTreeView::branch:open:has-children{ +margin:4px; +border-image:url(:/qss/flatgray/branch_close.png); +} + +QTreeView,QListView,QTableView,QSplitter::handle,QTreeView::branch{ +background:#FFFFFF; +} + +QTableView::item:selected,QListView::item:selected,QTreeView::item:selected{ +color:#57595B; +background:#E4E4E4; +} + +QTableView::item:hover,QListView::item:hover,QTreeView::item:hover,QHeaderView,QHeaderView::section,QTableCornerButton:section{ +color:#57595B; +background:#F6F6F6; +} + +QTableView::item,QListView::item,QTreeView::item{ +padding:1px; +margin:0px; +border:0px; +} + +QHeaderView::section,QTableCornerButton:section{ +padding:3px; +margin:0px; +border:1px solid #B6B6B6; +border-left-width:0px; +border-right-width:1px; +border-top-width:0px; +border-bottom-width:1px; +} + +QTabBar::tab{ +border:1px solid #B6B6B6; +color:#57595B; +margin:0px; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #F6F6F6,stop:1 #F6F6F6); +} + +QTabBar::tab:selected{ +border-style:solid; +border-color:#575959; +background:#FFFFFF; +} + +QTabBar::tab:top,QTabBar::tab:bottom{ +padding:3px 8px 3px 8px; +} + +QTabBar::tab:left,QTabBar::tab:right{ +padding:8px 3px 8px 3px; +} + +QTabBar::tab:top:selected{ +border-width:2px 0px 0px 0px; +} + +QTabBar::tab:right:selected{ +border-width:0px 0px 0px 2px; +} + +QTabBar::tab:bottom:selected{ +border-width:0px 0px 2px 0px; +} + +QTabBar::tab:left:selected{ +border-width:0px 2px 0px 0px; +} + +QTabBar::tab:first:top:selected,QTabBar::tab:first:bottom:selected{ +border-left-width:1px; +border-left-color:#B6B6B6; +} + +QTabBar::tab:first:left:selected,QTabBar::tab:first:right:selected{ +border-top-width:1px; +border-top-color:#B6B6B6; +} + +QTabBar::tab:last:top:selected,QTabBar::tab:last:bottom:selected{ +border-right-width:1px; +border-right-color:#B6B6B6; +} + +QTabBar::tab:last:left:selected,QTabBar::tab:last:right:selected{ +border-bottom-width:1px; +border-bottom-color:#B6B6B6; +} + +QStatusBar::item{ +border:0px solid #E4E4E4; +border-radius:3px; +} + +QToolBox::tab,QWidget[form="panel"]{ +padding:3px; +border-radius:5px; +color:#57595B; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #E4E4E4,stop:1 #E4E4E4); +} + +QWidget[flag="paneltitle"]{ +border-bottom-left-radius:0px; +border-bottom-right-radius:0px; +} + +QWidget[flag="panelcontrol"]{ +border-top-width:0px; +border-top-left-radius:0px; +border-top-right-radius:0px; +} + +QToolTip{ +border:0px solid #57595B; +padding:1px; +color:#57595B; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #E4E4E4,stop:1 #E4E4E4); +} + +QToolBox::tab:selected{ +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #F6F6F6,stop:1 #F6F6F6); +} + +QPrintPreviewDialog QToolButton{ +border:0px solid #57595B; +border-radius:0px; +margin:0px; +padding:3px; +background:none; +} + +QColorDialog QPushButton,QFileDialog QPushButton{ +min-width:80px; +} + +QToolButton#qt_calendar_prevmonth{ +icon-size:0px; +min-width:20px; +image:url(:/qss/flatgray/calendar_prevmonth.png); +} + +QToolButton#qt_calendar_nextmonth{ +icon-size:0px; +min-width:20px; +image:url(:/qss/flatgray/calendar_nextmonth.png); +} + +QToolButton#qt_calendar_prevmonth,QToolButton#qt_calendar_nextmonth,QToolButton#qt_calendar_monthbutton,QToolButton#qt_calendar_yearbutton{ +border:0px solid #57595B; +border-radius:3px; +margin:3px 3px 3px 3px; +padding:3px; +background:none; +} + +QToolButton#qt_calendar_prevmonth:hover,QToolButton#qt_calendar_nextmonth:hover,QToolButton#qt_calendar_monthbutton:hover,QToolButton#qt_calendar_yearbutton:hover,QToolButton#qt_calendar_prevmonth:pressed,QToolButton#qt_calendar_nextmonth:pressed,QToolButton#qt_calendar_monthbutton:pressed,QToolButton#qt_calendar_yearbutton:pressed{ +border:1px solid #B6B6B6; +} + +QCalendarWidget QSpinBox#qt_calendar_yearedit{ +margin:2px; +} + +QCalendarWidget QToolButton::menu-indicator{ +image:None; +} + +QCalendarWidget QTableView{ +border-width:0px; +} + +QCalendarWidget QWidget#qt_calendar_navigationbar{ +border:1px solid #B6B6B6; +border-width:1px 1px 0px 1px; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #E4E4E4,stop:1 #E4E4E4); +} + +QTableView[model="true"]::item{ +padding:0px; +margin:0px; +} + +QTableView QLineEdit,QTableView QComboBox,QTableView QSpinBox,QTableView QDoubleSpinBox,QTableView QDateEdit,QTableView QTimeEdit,QTableView QDateTimeEdit{ +border-width:0px; +border-radius:0px; +} + +QTableView QLineEdit:focus,QTableView QComboBox:focus,QTableView QSpinBox:focus,QTableView QDoubleSpinBox:focus,QTableView QDateEdit:focus,QTableView QTimeEdit:focus,QTableView QDateTimeEdit:focus{ +border-width:0px; +border-radius:0px; +} + +QLineEdit,QTextEdit,QPlainTextEdit,QSpinBox,QDoubleSpinBox,QComboBox,QDateEdit,QTimeEdit,QDateTimeEdit{ +background:#FFFFFF; +} + +QTabWidget::pane:top{top:-1px;} +QTabWidget::pane:bottom{bottom:-1px;} +QTabWidget::pane:left{right:-1px;} +QTabWidget::pane:right{left:-1px;} + +QDialog,QDial,#QUIWidgetMain{ +background-color:#FFFFFF; +color:#57595B; +} + +QDialogButtonBox>QPushButton{ +min-width:50px; +} + +QListView[noborder="true"],QTreeView[noborder="true"],QTabWidget[noborder="true"]::pane{ +border-width:0px; +} + +QToolBar>*,QStatusBar>*{ +margin:2px; +} + +*:disabled,QMenu::item:disabled,QTabBar:tab:disabled,QHeaderView::section:disabled{ +background:#FFFFFF; +border-color:#E4E4E4; +color:#B6B6B6; +} + +QLabel:disabled{ +background:none; +} + +/*TextColor:#57595B*/ +/*PanelColor:#FFFFFF*/ +/*BorderColor:#B6B6B6*/ +/*NormalColorStart:#E4E4E4*/ +/*NormalColorEnd:#E4E4E4*/ +/*DarkColorStart:#F6F6F6*/ +/*DarkColorEnd:#F6F6F6*/ +/*HighColor:#575959*/ \ No newline at end of file diff --git a/ui/styledemo/qrc/qss/flatgray/add_bottom.png b/ui/styledemo/qrc/qss/flatgray/add_bottom.png new file mode 100644 index 0000000..868e687 Binary files /dev/null and b/ui/styledemo/qrc/qss/flatgray/add_bottom.png differ diff --git a/ui/styledemo/qrc/qss/flatgray/add_left.png b/ui/styledemo/qrc/qss/flatgray/add_left.png new file mode 100644 index 0000000..d9d5127 Binary files /dev/null and b/ui/styledemo/qrc/qss/flatgray/add_left.png differ diff --git a/ui/styledemo/qrc/qss/flatgray/add_right.png b/ui/styledemo/qrc/qss/flatgray/add_right.png new file mode 100644 index 0000000..be8dd1a Binary files /dev/null and b/ui/styledemo/qrc/qss/flatgray/add_right.png differ diff --git a/ui/styledemo/qrc/qss/flatgray/add_top.png b/ui/styledemo/qrc/qss/flatgray/add_top.png new file mode 100644 index 0000000..ef55ce1 Binary files /dev/null and b/ui/styledemo/qrc/qss/flatgray/add_top.png differ diff --git a/ui/styledemo/qrc/qss/flatgray/arrow_bottom.png b/ui/styledemo/qrc/qss/flatgray/arrow_bottom.png new file mode 100644 index 0000000..37307b7 Binary files /dev/null and b/ui/styledemo/qrc/qss/flatgray/arrow_bottom.png differ diff --git a/ui/styledemo/qrc/qss/flatgray/arrow_left.png b/ui/styledemo/qrc/qss/flatgray/arrow_left.png new file mode 100644 index 0000000..aa4312b Binary files /dev/null and b/ui/styledemo/qrc/qss/flatgray/arrow_left.png differ diff --git a/ui/styledemo/qrc/qss/flatgray/arrow_right.png b/ui/styledemo/qrc/qss/flatgray/arrow_right.png new file mode 100644 index 0000000..4db5efa Binary files /dev/null and b/ui/styledemo/qrc/qss/flatgray/arrow_right.png differ diff --git a/ui/styledemo/qrc/qss/flatgray/arrow_top.png b/ui/styledemo/qrc/qss/flatgray/arrow_top.png new file mode 100644 index 0000000..0da1cad Binary files /dev/null and b/ui/styledemo/qrc/qss/flatgray/arrow_top.png differ diff --git a/ui/styledemo/qrc/qss/flatgray/branch_close.png b/ui/styledemo/qrc/qss/flatgray/branch_close.png new file mode 100644 index 0000000..f5b6d34 Binary files /dev/null and b/ui/styledemo/qrc/qss/flatgray/branch_close.png differ diff --git a/ui/styledemo/qrc/qss/flatgray/branch_open.png b/ui/styledemo/qrc/qss/flatgray/branch_open.png new file mode 100644 index 0000000..6392c13 Binary files /dev/null and b/ui/styledemo/qrc/qss/flatgray/branch_open.png differ diff --git a/ui/styledemo/qrc/qss/flatgray/calendar_nextmonth.png b/ui/styledemo/qrc/qss/flatgray/calendar_nextmonth.png new file mode 100644 index 0000000..6cb40d7 Binary files /dev/null and b/ui/styledemo/qrc/qss/flatgray/calendar_nextmonth.png differ diff --git a/ui/styledemo/qrc/qss/flatgray/calendar_prevmonth.png b/ui/styledemo/qrc/qss/flatgray/calendar_prevmonth.png new file mode 100644 index 0000000..8a17d0f Binary files /dev/null and b/ui/styledemo/qrc/qss/flatgray/calendar_prevmonth.png differ diff --git a/ui/styledemo/qrc/qss/flatgray/checkbox_checked.png b/ui/styledemo/qrc/qss/flatgray/checkbox_checked.png new file mode 100644 index 0000000..8808382 Binary files /dev/null and b/ui/styledemo/qrc/qss/flatgray/checkbox_checked.png differ diff --git a/ui/styledemo/qrc/qss/flatgray/checkbox_checked_disable.png b/ui/styledemo/qrc/qss/flatgray/checkbox_checked_disable.png new file mode 100644 index 0000000..9aa0a10 Binary files /dev/null and b/ui/styledemo/qrc/qss/flatgray/checkbox_checked_disable.png differ diff --git a/ui/styledemo/qrc/qss/flatgray/checkbox_parcial.png b/ui/styledemo/qrc/qss/flatgray/checkbox_parcial.png new file mode 100644 index 0000000..97376f3 Binary files /dev/null and b/ui/styledemo/qrc/qss/flatgray/checkbox_parcial.png differ diff --git a/ui/styledemo/qrc/qss/flatgray/checkbox_parcial_disable.png b/ui/styledemo/qrc/qss/flatgray/checkbox_parcial_disable.png new file mode 100644 index 0000000..b9b286f Binary files /dev/null and b/ui/styledemo/qrc/qss/flatgray/checkbox_parcial_disable.png differ diff --git a/ui/styledemo/qrc/qss/flatgray/checkbox_unchecked.png b/ui/styledemo/qrc/qss/flatgray/checkbox_unchecked.png new file mode 100644 index 0000000..50c25e2 Binary files /dev/null and b/ui/styledemo/qrc/qss/flatgray/checkbox_unchecked.png differ diff --git a/ui/styledemo/qrc/qss/flatgray/checkbox_unchecked_disable.png b/ui/styledemo/qrc/qss/flatgray/checkbox_unchecked_disable.png new file mode 100644 index 0000000..7c4c7db Binary files /dev/null and b/ui/styledemo/qrc/qss/flatgray/checkbox_unchecked_disable.png differ diff --git a/ui/styledemo/qrc/qss/flatgray/menu_checked.png b/ui/styledemo/qrc/qss/flatgray/menu_checked.png new file mode 100644 index 0000000..6a1c729 Binary files /dev/null and b/ui/styledemo/qrc/qss/flatgray/menu_checked.png differ diff --git a/ui/styledemo/qrc/qss/flatgray/radiobutton_checked.png b/ui/styledemo/qrc/qss/flatgray/radiobutton_checked.png new file mode 100644 index 0000000..513a41e Binary files /dev/null and b/ui/styledemo/qrc/qss/flatgray/radiobutton_checked.png differ diff --git a/ui/styledemo/qrc/qss/flatgray/radiobutton_checked_disable.png b/ui/styledemo/qrc/qss/flatgray/radiobutton_checked_disable.png new file mode 100644 index 0000000..8d16af5 Binary files /dev/null and b/ui/styledemo/qrc/qss/flatgray/radiobutton_checked_disable.png differ diff --git a/ui/styledemo/qrc/qss/flatgray/radiobutton_unchecked.png b/ui/styledemo/qrc/qss/flatgray/radiobutton_unchecked.png new file mode 100644 index 0000000..8ef34fb Binary files /dev/null and b/ui/styledemo/qrc/qss/flatgray/radiobutton_unchecked.png differ diff --git a/ui/styledemo/qrc/qss/flatgray/radiobutton_unchecked_disable.png b/ui/styledemo/qrc/qss/flatgray/radiobutton_unchecked_disable.png new file mode 100644 index 0000000..f70c364 Binary files /dev/null and b/ui/styledemo/qrc/qss/flatgray/radiobutton_unchecked_disable.png differ diff --git a/ui/styledemo/qrc/qss/lightblue.css b/ui/styledemo/qrc/qss/lightblue.css new file mode 100644 index 0000000..4928ebd --- /dev/null +++ b/ui/styledemo/qrc/qss/lightblue.css @@ -0,0 +1,694 @@ +QPalette{background:#EAF7FF;}*{outline:0px;color:#386487;} + +QGraphicsView{ +border:1px solid #C0DCF2; +qproperty-backgroundBrush:#EAF7FF; +} + +QWidget[form="true"],QLabel[frameShape="1"],QGraphicsView{ +border:1px solid #C0DCF2; +border-radius:0px; +} + +QWidget[form="bottom"]{ +background:#DEF0FE; +} + +QWidget[form="bottom"] .QFrame{ +border:1px solid #386487; +} + +QWidget[form="bottom"] QLabel,QWidget[form="title"] QLabel{ +border-radius:0px; +color:#386487; +background:none; +border-style:none; +} + +QWidget[form="title"],QWidget[nav="left"],QWidget[nav="top"] QAbstractButton{ +border-style:none; +border-radius:0px; +padding:5px; +color:#386487; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #DEF0FE,stop:1 #C0DEF6); +} + +QWidget[nav="top"] QAbstractButton:hover,QWidget[nav="top"] QAbstractButton:pressed,QWidget[nav="top"] QAbstractButton:checked{ +border-style:solid; +border-width:0px 0px 2px 0px; +padding:4px 4px 2px 4px; +border-color:#386488; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #F2F9FF,stop:1 #DAEFFF); +} + +QWidget[nav="left"] QAbstractButton{ +border-radius:0px; +color:#386487; +background:none; +border-style:none; +} + +QWidget[nav="left"] QAbstractButton:hover{ +color:#FFFFFF; +background-color:#386488; +} + +QWidget[nav="left"] QAbstractButton:checked,QWidget[nav="left"] QAbstractButton:pressed{ +color:#386487; +border-style:solid; +border-width:0px 0px 0px 2px; +padding:4px 4px 4px 2px; +border-color:#386488; +background-color:#EAF7FF; +} + +QWidget[video="true"] QLabel{ +color:#386487; +border:1px solid #C0DCF2; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #DEF0FE,stop:1 #C0DEF6); +} + +QWidget[video="true"] QLabel:focus{ +border:1px solid #386488; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #F2F9FF,stop:1 #DAEFFF); +} + +QLineEdit:read-only{ +background-color:#DEF0FE; +} + +QLineEdit,QTextEdit,QPlainTextEdit,QSpinBox,QDoubleSpinBox,QComboBox,QDateEdit,QTimeEdit,QDateTimeEdit{ +border:1px solid #C0DCF2; +border-radius:3px; +padding:2px; +background:none; +selection-background-color:#386488; +selection-color:#FFFFFF; +} + +QLineEdit:focus,QTextEdit:focus,QPlainTextEdit:focus,QSpinBox:focus,QDoubleSpinBox:focus,QComboBox:focus,QDateEdit:focus,QTimeEdit:focus,QDateTimeEdit:focus,QLineEdit:hover,QTextEdit:hover,QPlainTextEdit:hover,QSpinBox:hover,QDoubleSpinBox:hover,QComboBox:hover,QDateEdit:hover,QTimeEdit:hover,QDateTimeEdit:hover{ +border:1px solid #C0DCF2; +} + +QLineEdit[echoMode="2"]{ +lineedit-password-character:9679; +} + +.QFrame{ +border:1px solid #C0DCF2; +border-radius:3px; +} + +.QGroupBox{ +border:1px solid #C0DCF2; +border-radius:5px; +margin-top:9px; +} + +.QGroupBox::title{ +subcontrol-origin:margin; +position:relative; +left:10px; +} + +.QPushButton,.QToolButton{ +border-style:none; +border:1px solid #C0DCF2; +color:#386487; +padding:5px; +min-height:15px; +border-radius:5px; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #DEF0FE,stop:1 #C0DEF6); +} + +.QPushButton:hover,.QToolButton:hover{ +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #F2F9FF,stop:1 #DAEFFF); +} + +.QPushButton:pressed,.QToolButton:pressed{ +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #DEF0FE,stop:1 #C0DEF6); +} + +.QToolButton::menu-indicator{ +image:None; +} + +QToolButton#btnMenu,QPushButton#btnMenu_Min,QPushButton#btnMenu_Max,QPushButton#btnMenu_Close{ +border-radius:3px; +color:#386487; +padding:3px; +margin:0px; +background:none; +border-style:none; +} + +QToolButton#btnMenu:hover,QPushButton#btnMenu_Min:hover,QPushButton#btnMenu_Max:hover{ +color:#FFFFFF; +margin:1px 1px 2px 1px; +background-color:rgba(51,127,209,230); +} + +QPushButton#btnMenu_Close:hover{ +color:#FFFFFF; +margin:1px 1px 2px 1px; +background-color:rgba(238,0,0,128); +} + +QRadioButton::indicator{ +width:15px; +height:15px; +} + +QRadioButton::indicator::unchecked{ +image:url(:/qss/lightblue/radiobutton_unchecked.png); +} + +QRadioButton::indicator::unchecked:disabled{ +image:url(:/qss/lightblue/radiobutton_unchecked_disable.png); +} + +QRadioButton::indicator::checked{ +image:url(:/qss/lightblue/radiobutton_checked.png); +} + +QRadioButton::indicator::checked:disabled{ +image:url(:/qss/lightblue/radiobutton_checked_disable.png); +} + +QGroupBox::indicator,QTreeView::indicator,QListView::indicator,QTableView::indicator{ +padding:0px 0px 0px 0px; +} + +QCheckBox::indicator,QGroupBox::indicator,QTreeView::indicator,QListView::indicator,QTableView::indicator{ +width:13px; +height:13px; +} + +QCheckBox::indicator:unchecked,QGroupBox::indicator:unchecked,QTreeView::indicator:unchecked,QListView::indicator:unchecked,QTableView::indicator:unchecked{ +image:url(:/qss/lightblue/checkbox_unchecked.png); +} + +QCheckBox::indicator:unchecked:disabled,QGroupBox::indicator:unchecked:disabled,QTreeView::indicator:unchecked:disabled,QListView::indicator:unchecked:disabled,QTableView::indicator:unchecked:disabled{ +image:url(:/qss/lightblue/checkbox_unchecked_disable.png); +} + +QCheckBox::indicator:checked,QGroupBox::indicator:checked,QTreeView::indicator:checked,QListView::indicator:checked,QTableView::indicator:checked{ +image:url(:/qss/lightblue/checkbox_checked.png); +} + +QCheckBox::indicator:checked:disabled,QGroupBox::indicator:checked:disabled,QTreeView::indicator:checked:disabled,QListView::indicator:checked:disabled,QTableView::indicator:checked:disabled{ +image:url(:/qss/lightblue/checkbox_checked_disable.png); +} + +QCheckBox::indicator:indeterminate,QGroupBox::indicator:indeterminate,QTreeView::indicator:indeterminate,QListView::indicator:indeterminate,QTableView::indicator:indeterminate{ +image:url(:/qss/lightblue/checkbox_parcial.png); +} + +QCheckBox::indicator:indeterminate:disabled,QGroupBox::indicator:indeterminate:disabled,QTreeView::indicator:indeterminate:disabled,QListView::indicator:indeterminate:disabled,QTableView::indicator:indeterminate:disabled{ +image:url(:/qss/lightblue/checkbox_parcial_disable.png); +} + +QTimeEdit::up-button,QDateEdit::up-button,QDateTimeEdit::up-button,QDoubleSpinBox::up-button,QSpinBox::up-button{ +image:url(:/qss/lightblue/add_top.png); +width:10px; +height:10px; +padding:2px 5px 0px 0px; +} + +QTimeEdit::down-button,QDateEdit::down-button,QDateTimeEdit::down-button,QDoubleSpinBox::down-button,QSpinBox::down-button{ +image:url(:/qss/lightblue/add_bottom.png); +width:10px; +height:10px; +padding:0px 5px 2px 0px; +} + +QTimeEdit::up-button:pressed,QDateEdit::up-button:pressed,QDateTimeEdit::up-button:pressed,QDoubleSpinBox::up-button:pressed,QSpinBox::up-button:pressed{ +top:-2px; +} + +QTimeEdit::down-button:pressed,QDateEdit::down-button:pressed,QDateTimeEdit::down-button:pressed,QDoubleSpinBox::down-button:pressed,QSpinBox::down-button:pressed,QSpinBox::down-button:pressed{ +bottom:-2px; +} + +QComboBox::down-arrow,QDateEdit[calendarPopup="true"]::down-arrow,QTimeEdit[calendarPopup="true"]::down-arrow,QDateTimeEdit[calendarPopup="true"]::down-arrow{ +image:url(:/qss/lightblue/add_bottom.png); +width:10px; +height:10px; +right:2px; +} + +QComboBox::drop-down,QDateEdit::drop-down,QTimeEdit::drop-down,QDateTimeEdit::drop-down{ +subcontrol-origin:padding; +subcontrol-position:top right; +width:15px; +border-left-width:0px; +border-left-style:solid; +border-top-right-radius:3px; +border-bottom-right-radius:3px; +border-left-color:#C0DCF2; +} + +QComboBox::drop-down:on{ +top:1px; +} + +QMenuBar::item{ +color:#386487; +background-color:#DEF0FE; +margin:0px; +padding:3px 10px; +} + +QMenu,QMenuBar,QMenu:disabled,QMenuBar:disabled{ +color:#386487; +background-color:#DEF0FE; +border:1px solid #C0DCF2; +margin:0px; +} + +QMenu::item{ +padding:3px 20px; +} + +QMenu::indicator{ +width:20px; +height:13px; +} + +QMenu::indicator::checked{ +image:url(:/qss/lightblue/menu_checked.png); +} + +QMenu::right-arrow{ +image:url(:/qss/lightblue/arrow_right.png); +width:13px; +height:13px; +padding:0px 3px 0px 0px; +} + +QMenu::item:selected,QMenuBar::item:selected{ +color:#386487; +border:0px solid #C0DCF2; +background:#F2F9FF; +} + +QMenu::separator{ +height:1px; +background:#C0DCF2; +} + +QProgressBar{ +min-height:10px; +background:#DEF0FE; +border-radius:5px; +text-align:center; +border:1px solid #DEF0FE; +} + +QProgressBar:chunk{ +border-radius:5px; +background-color:#C0DCF2; +} + +QSlider::groove:horizontal{ +height:8px; +border-radius:4px; +background:#DEF0FE; +} + +QSlider::add-page:horizontal{ +height:8px; +border-radius:4px; +background:#DEF0FE; +} + +QSlider::sub-page:horizontal{ +height:8px; +border-radius:4px; +background:#C0DCF2; +} + +QSlider::handle:horizontal{ +width:13px; +margin-top:-3px; +margin-bottom:-3px; +border-radius:6px; +background:qradialgradient(spread:pad,cx:0.5,cy:0.5,radius:0.5,fx:0.5,fy:0.5,stop:0.6 #EAF7FF,stop:0.8 #C0DCF2); +} + +QSlider::groove:vertical{ +width:8px; +border-radius:4px; +background:#DEF0FE; +} + +QSlider::add-page:vertical{ +width:8px; +border-radius:4px; +background:#C0DCF2; +} + +QSlider::sub-page:vertical{ +width:8px; +border-radius:4px; +background:#DEF0FE; +} + +QSlider::handle:vertical{ +height:14px; +margin-left:-3px; +margin-right:-3px; +border-radius:6px; +background:qradialgradient(spread:pad,cx:0.5,cy:0.5,radius:0.5,fx:0.5,fy:0.5,stop:0.6 #EAF7FF,stop:0.8 #C0DCF2); +} + +QScrollBar:horizontal{ +background:#DEF0FE; +padding:0px; +border-radius:6px; +max-height:12px; +} + +QScrollBar::handle:horizontal{ +background:#C0DCF2; +min-width:50px; +border-radius:6px; +} + +QScrollBar::handle:horizontal:hover{ +background:#386488; +} + +QScrollBar::handle:horizontal:pressed{ +background:#386488; +} + +QScrollBar::add-page:horizontal{ +background:none; +} + +QScrollBar::sub-page:horizontal{ +background:none; +} + +QScrollBar::add-line:horizontal{ +background:none; +} + +QScrollBar::sub-line:horizontal{ +background:none; +} + +QScrollBar:vertical{ +background:#DEF0FE; +padding:0px; +border-radius:6px; +max-width:12px; +} + +QScrollBar::handle:vertical{ +background:#C0DCF2; +min-height:50px; +border-radius:6px; +} + +QScrollBar::handle:vertical:hover{ +background:#386488; +} + +QScrollBar::handle:vertical:pressed{ +background:#386488; +} + +QScrollBar::add-page:vertical{ +background:none; +} + +QScrollBar::sub-page:vertical{ +background:none; +} + +QScrollBar::add-line:vertical{ +background:none; +} + +QScrollBar::sub-line:vertical{ +background:none; +} + +QScrollArea{ +border:0px; +} + +QTreeView,QListView,QTableView,QTabWidget::pane{ +border:1px solid #C0DCF2; +selection-background-color:#F2F9FF; +selection-color:#386487; +alternate-background-color:#DAEFFF; +gridline-color:#C0DCF2; +} + +QTreeView::branch:closed:has-children{ +margin:4px; +border-image:url(:/qss/lightblue/branch_open.png); +} + +QTreeView::branch:open:has-children{ +margin:4px; +border-image:url(:/qss/lightblue/branch_close.png); +} + +QTreeView,QListView,QTableView,QSplitter::handle,QTreeView::branch{ +background:#EAF7FF; +} + +QTableView::item:selected,QListView::item:selected,QTreeView::item:selected{ +color:#386487; +background:#C0DEF6; +} + +QTableView::item:hover,QListView::item:hover,QTreeView::item:hover,QHeaderView,QHeaderView::section,QTableCornerButton:section{ +color:#386487; +background:#DAEFFF; +} + +QTableView::item,QListView::item,QTreeView::item{ +padding:1px; +margin:0px; +border:0px; +} + +QHeaderView::section,QTableCornerButton:section{ +padding:3px; +margin:0px; +border:1px solid #C0DCF2; +border-left-width:0px; +border-right-width:1px; +border-top-width:0px; +border-bottom-width:1px; +} + +QTabBar::tab{ +border:1px solid #C0DCF2; +color:#386487; +margin:0px; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #F2F9FF,stop:1 #DAEFFF); +} + +QTabBar::tab:selected{ +border-style:solid; +border-color:#386488; +background:#EAF7FF; +} + +QTabBar::tab:top,QTabBar::tab:bottom{ +padding:3px 8px 3px 8px; +} + +QTabBar::tab:left,QTabBar::tab:right{ +padding:8px 3px 8px 3px; +} + +QTabBar::tab:top:selected{ +border-width:2px 0px 0px 0px; +} + +QTabBar::tab:right:selected{ +border-width:0px 0px 0px 2px; +} + +QTabBar::tab:bottom:selected{ +border-width:0px 0px 2px 0px; +} + +QTabBar::tab:left:selected{ +border-width:0px 2px 0px 0px; +} + +QTabBar::tab:first:top:selected,QTabBar::tab:first:bottom:selected{ +border-left-width:1px; +border-left-color:#C0DCF2; +} + +QTabBar::tab:first:left:selected,QTabBar::tab:first:right:selected{ +border-top-width:1px; +border-top-color:#C0DCF2; +} + +QTabBar::tab:last:top:selected,QTabBar::tab:last:bottom:selected{ +border-right-width:1px; +border-right-color:#C0DCF2; +} + +QTabBar::tab:last:left:selected,QTabBar::tab:last:right:selected{ +border-bottom-width:1px; +border-bottom-color:#C0DCF2; +} + +QStatusBar::item{ +border:0px solid #DEF0FE; +border-radius:3px; +} + +QToolBox::tab,QWidget[form="panel"]{ +padding:3px; +border-radius:5px; +color:#386487; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #DEF0FE,stop:1 #C0DEF6); +} + +QWidget[flag="paneltitle"]{ +border-bottom-left-radius:0px; +border-bottom-right-radius:0px; +} + +QWidget[flag="panelcontrol"]{ +border-top-width:0px; +border-top-left-radius:0px; +border-top-right-radius:0px; +} + +QToolTip{ +border:0px solid #386487; +padding:1px; +color:#386487; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #DEF0FE,stop:1 #C0DEF6); +} + +QToolBox::tab:selected{ +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #F2F9FF,stop:1 #DAEFFF); +} + +QPrintPreviewDialog QToolButton{ +border:0px solid #386487; +border-radius:0px; +margin:0px; +padding:3px; +background:none; +} + +QColorDialog QPushButton,QFileDialog QPushButton{ +min-width:80px; +} + +QToolButton#qt_calendar_prevmonth{ +icon-size:0px; +min-width:20px; +image:url(:/qss/lightblue/calendar_prevmonth.png); +} + +QToolButton#qt_calendar_nextmonth{ +icon-size:0px; +min-width:20px; +image:url(:/qss/lightblue/calendar_nextmonth.png); +} + +QToolButton#qt_calendar_prevmonth,QToolButton#qt_calendar_nextmonth,QToolButton#qt_calendar_monthbutton,QToolButton#qt_calendar_yearbutton{ +border:0px solid #386487; +border-radius:3px; +margin:3px 3px 3px 3px; +padding:3px; +background:none; +} + +QToolButton#qt_calendar_prevmonth:hover,QToolButton#qt_calendar_nextmonth:hover,QToolButton#qt_calendar_monthbutton:hover,QToolButton#qt_calendar_yearbutton:hover,QToolButton#qt_calendar_prevmonth:pressed,QToolButton#qt_calendar_nextmonth:pressed,QToolButton#qt_calendar_monthbutton:pressed,QToolButton#qt_calendar_yearbutton:pressed{ +border:1px solid #C0DCF2; +} + +QCalendarWidget QSpinBox#qt_calendar_yearedit{ +margin:2px; +} + +QCalendarWidget QToolButton::menu-indicator{ +image:None; +} + +QCalendarWidget QTableView{ +border-width:0px; +} + +QCalendarWidget QWidget#qt_calendar_navigationbar{ +border:1px solid #C0DCF2; +border-width:1px 1px 0px 1px; +background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 #DEF0FE,stop:1 #C0DEF6); +} + +QTableView[model="true"]::item{ +padding:0px; +margin:0px; +} + +QTableView QLineEdit,QTableView QComboBox,QTableView QSpinBox,QTableView QDoubleSpinBox,QTableView QDateEdit,QTableView QTimeEdit,QTableView QDateTimeEdit{ +border-width:0px; +border-radius:0px; +} + +QTableView QLineEdit:focus,QTableView QComboBox:focus,QTableView QSpinBox:focus,QTableView QDoubleSpinBox:focus,QTableView QDateEdit:focus,QTableView QTimeEdit:focus,QTableView QDateTimeEdit:focus{ +border-width:0px; +border-radius:0px; +} + +QLineEdit,QTextEdit,QPlainTextEdit,QSpinBox,QDoubleSpinBox,QComboBox,QDateEdit,QTimeEdit,QDateTimeEdit{ +background:#EAF7FF; +} + +QTabWidget::pane:top{top:-1px;} +QTabWidget::pane:bottom{bottom:-1px;} +QTabWidget::pane:left{right:-1px;} +QTabWidget::pane:right{left:-1px;} + +QDialog,QDial,#QUIWidgetMain{ +background-color:#EAF7FF; +color:#386487; +} + +QDialogButtonBox>QPushButton{ +min-width:50px; +} + +QListView[noborder="true"],QTreeView[noborder="true"],QTabWidget[noborder="true"]::pane{ +border-width:0px; +} + +QToolBar>*,QStatusBar>*{ +margin:2px; +} + +*:disabled,QMenu::item:disabled,QTabBar:tab:disabled,QHeaderView::section:disabled{ +background:#EAF7FF; +border-color:#DEF0FE; +color:#C0DCF2; +} + +QLabel:disabled{ +background:none; +} + +/*TextColor:#386487*/ +/*PanelColor:#EAF7FF*/ +/*BorderColor:#C0DCF2*/ +/*NormalColorStart:#DEF0FE*/ +/*NormalColorEnd:#C0DEF6*/ +/*DarkColorStart:#F2F9FF*/ +/*DarkColorEnd:#DAEFFF*/ +/*HighColor:#386488*/ \ No newline at end of file diff --git a/ui/styledemo/qrc/qss/lightblue/add_bottom.png b/ui/styledemo/qrc/qss/lightblue/add_bottom.png new file mode 100644 index 0000000..99eadb9 Binary files /dev/null and b/ui/styledemo/qrc/qss/lightblue/add_bottom.png differ diff --git a/ui/styledemo/qrc/qss/lightblue/add_left.png b/ui/styledemo/qrc/qss/lightblue/add_left.png new file mode 100644 index 0000000..a7329d3 Binary files /dev/null and b/ui/styledemo/qrc/qss/lightblue/add_left.png differ diff --git a/ui/styledemo/qrc/qss/lightblue/add_right.png b/ui/styledemo/qrc/qss/lightblue/add_right.png new file mode 100644 index 0000000..0c0ef6f Binary files /dev/null and b/ui/styledemo/qrc/qss/lightblue/add_right.png differ diff --git a/ui/styledemo/qrc/qss/lightblue/add_top.png b/ui/styledemo/qrc/qss/lightblue/add_top.png new file mode 100644 index 0000000..911f5b4 Binary files /dev/null and b/ui/styledemo/qrc/qss/lightblue/add_top.png differ diff --git a/ui/styledemo/qrc/qss/lightblue/arrow_bottom.png b/ui/styledemo/qrc/qss/lightblue/arrow_bottom.png new file mode 100644 index 0000000..6dc9f23 Binary files /dev/null and b/ui/styledemo/qrc/qss/lightblue/arrow_bottom.png differ diff --git a/ui/styledemo/qrc/qss/lightblue/arrow_left.png b/ui/styledemo/qrc/qss/lightblue/arrow_left.png new file mode 100644 index 0000000..87171e9 Binary files /dev/null and b/ui/styledemo/qrc/qss/lightblue/arrow_left.png differ diff --git a/ui/styledemo/qrc/qss/lightblue/arrow_right.png b/ui/styledemo/qrc/qss/lightblue/arrow_right.png new file mode 100644 index 0000000..604def6 Binary files /dev/null and b/ui/styledemo/qrc/qss/lightblue/arrow_right.png differ diff --git a/ui/styledemo/qrc/qss/lightblue/arrow_top.png b/ui/styledemo/qrc/qss/lightblue/arrow_top.png new file mode 100644 index 0000000..3c02231 Binary files /dev/null and b/ui/styledemo/qrc/qss/lightblue/arrow_top.png differ diff --git a/ui/styledemo/qrc/qss/lightblue/branch_close.png b/ui/styledemo/qrc/qss/lightblue/branch_close.png new file mode 100644 index 0000000..73492b3 Binary files /dev/null and b/ui/styledemo/qrc/qss/lightblue/branch_close.png differ diff --git a/ui/styledemo/qrc/qss/lightblue/branch_open.png b/ui/styledemo/qrc/qss/lightblue/branch_open.png new file mode 100644 index 0000000..9abd65c Binary files /dev/null and b/ui/styledemo/qrc/qss/lightblue/branch_open.png differ diff --git a/ui/styledemo/qrc/qss/lightblue/calendar_nextmonth.png b/ui/styledemo/qrc/qss/lightblue/calendar_nextmonth.png new file mode 100644 index 0000000..36a453b Binary files /dev/null and b/ui/styledemo/qrc/qss/lightblue/calendar_nextmonth.png differ diff --git a/ui/styledemo/qrc/qss/lightblue/calendar_prevmonth.png b/ui/styledemo/qrc/qss/lightblue/calendar_prevmonth.png new file mode 100644 index 0000000..cce673f Binary files /dev/null and b/ui/styledemo/qrc/qss/lightblue/calendar_prevmonth.png differ diff --git a/ui/styledemo/qrc/qss/lightblue/checkbox_checked.png b/ui/styledemo/qrc/qss/lightblue/checkbox_checked.png new file mode 100644 index 0000000..524d243 Binary files /dev/null and b/ui/styledemo/qrc/qss/lightblue/checkbox_checked.png differ diff --git a/ui/styledemo/qrc/qss/lightblue/checkbox_checked_disable.png b/ui/styledemo/qrc/qss/lightblue/checkbox_checked_disable.png new file mode 100644 index 0000000..de9ece8 Binary files /dev/null and b/ui/styledemo/qrc/qss/lightblue/checkbox_checked_disable.png differ diff --git a/ui/styledemo/qrc/qss/lightblue/checkbox_parcial.png b/ui/styledemo/qrc/qss/lightblue/checkbox_parcial.png new file mode 100644 index 0000000..1990ead Binary files /dev/null and b/ui/styledemo/qrc/qss/lightblue/checkbox_parcial.png differ diff --git a/ui/styledemo/qrc/qss/lightblue/checkbox_parcial_disable.png b/ui/styledemo/qrc/qss/lightblue/checkbox_parcial_disable.png new file mode 100644 index 0000000..cdd3779 Binary files /dev/null and b/ui/styledemo/qrc/qss/lightblue/checkbox_parcial_disable.png differ diff --git a/ui/styledemo/qrc/qss/lightblue/checkbox_unchecked.png b/ui/styledemo/qrc/qss/lightblue/checkbox_unchecked.png new file mode 100644 index 0000000..0f766a4 Binary files /dev/null and b/ui/styledemo/qrc/qss/lightblue/checkbox_unchecked.png differ diff --git a/ui/styledemo/qrc/qss/lightblue/checkbox_unchecked_disable.png b/ui/styledemo/qrc/qss/lightblue/checkbox_unchecked_disable.png new file mode 100644 index 0000000..25c0cdf Binary files /dev/null and b/ui/styledemo/qrc/qss/lightblue/checkbox_unchecked_disable.png differ diff --git a/ui/styledemo/qrc/qss/lightblue/menu_checked.png b/ui/styledemo/qrc/qss/lightblue/menu_checked.png new file mode 100644 index 0000000..bb52701 Binary files /dev/null and b/ui/styledemo/qrc/qss/lightblue/menu_checked.png differ diff --git a/ui/styledemo/qrc/qss/lightblue/radiobutton_checked.png b/ui/styledemo/qrc/qss/lightblue/radiobutton_checked.png new file mode 100644 index 0000000..cd6561d Binary files /dev/null and b/ui/styledemo/qrc/qss/lightblue/radiobutton_checked.png differ diff --git a/ui/styledemo/qrc/qss/lightblue/radiobutton_checked_disable.png b/ui/styledemo/qrc/qss/lightblue/radiobutton_checked_disable.png new file mode 100644 index 0000000..27a6896 Binary files /dev/null and b/ui/styledemo/qrc/qss/lightblue/radiobutton_checked_disable.png differ diff --git a/ui/styledemo/qrc/qss/lightblue/radiobutton_unchecked.png b/ui/styledemo/qrc/qss/lightblue/radiobutton_unchecked.png new file mode 100644 index 0000000..8f0b4fc Binary files /dev/null and b/ui/styledemo/qrc/qss/lightblue/radiobutton_unchecked.png differ diff --git a/ui/styledemo/qrc/qss/lightblue/radiobutton_unchecked_disable.png b/ui/styledemo/qrc/qss/lightblue/radiobutton_unchecked_disable.png new file mode 100644 index 0000000..57c0eb3 Binary files /dev/null and b/ui/styledemo/qrc/qss/lightblue/radiobutton_unchecked_disable.png differ diff --git a/ui/styledemo/styledemo.pro b/ui/styledemo/styledemo.pro new file mode 100644 index 0000000..54d2dee --- /dev/null +++ b/ui/styledemo/styledemo.pro @@ -0,0 +1,20 @@ +QT += core gui +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets +greaterThan(QT_MAJOR_VERSION, 5): QT += core5compat + +TARGET = styledemo +TEMPLATE = app +DESTDIR = $$PWD/../bin + +SOURCES += main.cpp +HEADERS += head.h +HEADERS += frmmain.h +SOURCES += frmmain.cpp +FORMS += frmmain.ui + +RESOURCES += qrc/qss.qrc +RESOURCES += qrc/qm.qrc +RESOURCES += qrc/font.qrc +RESOURCES += qrc/main.qrc + +INCLUDEPATH += $$PWD diff --git a/ui/ui.pro b/ui/ui.pro new file mode 100644 index 0000000..abfd29c --- /dev/null +++ b/ui/ui.pro @@ -0,0 +1,8 @@ +TEMPLATE = subdirs +SUBDIRS += flatui +SUBDIRS += styledemo +SUBDIRS += uidemo01 +SUBDIRS += uidemo08 +SUBDIRS += uidemo09 +SUBDIRS += uidemo10 +SUBDIRS += iconhelper \ No newline at end of file diff --git a/ui/uidemo01/form/form.pri b/ui/uidemo01/form/form.pri new file mode 100644 index 0000000..c6126ba --- /dev/null +++ b/ui/uidemo01/form/form.pri @@ -0,0 +1,8 @@ +FORMS += \ + $$PWD/frmmain.ui + +HEADERS += \ + $$PWD/frmmain.h + +SOURCES += \ + $$PWD/frmmain.cpp diff --git a/ui/uidemo01/form/frmmain.cpp b/ui/uidemo01/form/frmmain.cpp new file mode 100644 index 0000000..af2a4f4 --- /dev/null +++ b/ui/uidemo01/form/frmmain.cpp @@ -0,0 +1,138 @@ +#include "frmmain.h" +#include "ui_frmmain.h" +#include "iconhelper.h" +#include "quihelper.h" + +frmMain::frmMain(QWidget *parent) : QDialog(parent), ui(new Ui::frmMain) +{ + ui->setupUi(this); + this->initForm(); +} + +frmMain::~frmMain() +{ + delete ui; +} + +bool frmMain::eventFilter(QObject *watched, QEvent *event) +{ + if (event->type() == QEvent::MouseButtonDblClick) { + if (watched == ui->widgetTitle) { + on_btnMenu_Max_clicked(); + return true; + } + } + + return QWidget::eventFilter(watched, event); +} + +void frmMain::initForm() +{ + //设置无边框 + QUIHelper::setFramelessForm(this); + //设置图标 + IconHelper::setIcon(ui->labIco, 0xf099, 35); + IconHelper::setIcon(ui->btnMenu_Min, 0xf068); + IconHelper::setIcon(ui->btnMenu_Max, 0xf067); + IconHelper::setIcon(ui->btnMenu_Close, 0xf00d); + + //ui->widgetMenu->setVisible(false); + ui->widgetTitle->installEventFilter(this); + ui->widgetTitle->setProperty("form", "title"); + ui->widgetTop->setProperty("nav", "top"); + + QFont font; + font.setPixelSize(25); + ui->labTitle->setFont(font); + ui->labTitle->setText("智能访客管理平台"); + this->setWindowTitle(ui->labTitle->text()); + + ui->stackedWidget->setStyleSheet("QLabel{font:60px;}"); + + //单独设置指示器大小 + int addWidth = 20; + int addHeight = 10; + int rbtnWidth = 15; + int ckWidth = 13; + int scrWidth = 12; + int borderWidth = 3; + + QStringList qss; + qss << QString("QComboBox::drop-down,QDateEdit::drop-down,QTimeEdit::drop-down,QDateTimeEdit::drop-down{width:%1px;}").arg(addWidth); + qss << QString("QComboBox::down-arrow,QDateEdit[calendarPopup=\"true\"]::down-arrow,QTimeEdit[calendarPopup=\"true\"]::down-arrow," + "QDateTimeEdit[calendarPopup=\"true\"]::down-arrow{width:%1px;height:%1px;right:2px;}").arg(addHeight); + qss << QString("QRadioButton::indicator{width:%1px;height:%1px;}").arg(rbtnWidth); + qss << QString("QCheckBox::indicator,QGroupBox::indicator,QTreeWidget::indicator,QListWidget::indicator{width:%1px;height:%1px;}").arg(ckWidth); + qss << QString("QScrollBar:horizontal{min-height:%1px;border-radius:%2px;}QScrollBar::handle:horizontal{border-radius:%2px;}" + "QScrollBar:vertical{min-width:%1px;border-radius:%2px;}QScrollBar::handle:vertical{border-radius:%2px;}").arg(scrWidth).arg(scrWidth / 2); + qss << QString("QWidget#widget_top>QToolButton:pressed,QWidget#widget_top>QToolButton:hover," + "QWidget#widget_top>QToolButton:checked,QWidget#widget_top>QLabel:hover{" + "border-width:0px 0px %1px 0px;}").arg(borderWidth); + qss << QString("QWidget#widgetleft>QPushButton:checked,QWidget#widgetleft>QToolButton:checked," + "QWidget#widgetleft>QPushButton:pressed,QWidget#widgetleft>QToolButton:pressed{" + "border-width:0px 0px 0px %1px;}").arg(borderWidth); + this->setStyleSheet(qss.join("")); + + QSize icoSize(32, 32); + int icoWidth = 85; + + //设置顶部导航按钮 + QList tbtns = ui->widgetTop->findChildren(); + foreach (QToolButton *btn, tbtns) { + btn->setIconSize(icoSize); + btn->setMinimumWidth(icoWidth); + btn->setCheckable(true); + connect(btn, SIGNAL(clicked()), this, SLOT(buttonClick())); + } + + ui->btnMain->click(); +} + +void frmMain::buttonClick() +{ + QToolButton *b = (QToolButton *)sender(); + QString name = b->text(); + + QList tbtns = ui->widgetTop->findChildren(); + foreach (QToolButton *btn, tbtns) { + btn->setChecked(btn == b); + } + + if (name == "主界面") { + ui->stackedWidget->setCurrentIndex(0); + } else if (name == "系统设置") { + ui->stackedWidget->setCurrentIndex(1); + } else if (name == "警情查询") { + ui->stackedWidget->setCurrentIndex(2); + } else if (name == "调试帮助") { + ui->stackedWidget->setCurrentIndex(3); + } else if (name == "用户退出") { + exit(0); + } +} + +void frmMain::on_btnMenu_Min_clicked() +{ + showMinimized(); +} + +void frmMain::on_btnMenu_Max_clicked() +{ + static bool max = false; + static QRect location = this->geometry(); + + if (max) { + this->setGeometry(location); + } else { + location = this->geometry(); + this->setGeometry(QUIHelper::getScreenRect()); + } + + this->setProperty("canMove", max); + max = !max; +} + +void frmMain::on_btnMenu_Close_clicked() +{ + close(); +} diff --git a/ui/uidemo01/form/frmmain.h b/ui/uidemo01/form/frmmain.h new file mode 100644 index 0000000..3132c9f --- /dev/null +++ b/ui/uidemo01/form/frmmain.h @@ -0,0 +1,34 @@ +#ifndef FRMMAIN_H +#define FRMMAIN_H + +#include + +namespace Ui { +class frmMain; +} + +class frmMain : public QDialog +{ + Q_OBJECT + +public: + explicit frmMain(QWidget *parent = 0); + ~frmMain(); + +protected: + bool eventFilter(QObject *watched, QEvent *event); + +private: + Ui::frmMain *ui; + +private slots: + void initForm(); + void buttonClick(); + +private slots: + void on_btnMenu_Min_clicked(); + void on_btnMenu_Max_clicked(); + void on_btnMenu_Close_clicked(); +}; + +#endif // UIDEMO01_H diff --git a/ui/uidemo01/form/frmmain.ui b/ui/uidemo01/form/frmmain.ui new file mode 100644 index 0000000..e4ac272 --- /dev/null +++ b/ui/uidemo01/form/frmmain.ui @@ -0,0 +1,412 @@ + + + frmMain + + + + 0 + 0 + 800 + 600 + + + + Form + + + + 0 + + + 1 + + + 1 + + + 1 + + + 1 + + + + + + 0 + 0 + + + + + 10 + + + 10 + + + 0 + + + 0 + + + 0 + + + + + + + + Qt::AlignCenter + + + + + + + + + + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + 主界面 + + + + :/image/main_main.png:/image/main_main.png + + + Qt::ToolButtonTextUnderIcon + + + + + + + + 0 + 0 + + + + 系统设置 + + + + :/image/main_config.png:/image/main_config.png + + + Qt::ToolButtonTextUnderIcon + + + + + + + + 0 + 0 + + + + 警情查询 + + + + :/image/main_data.png:/image/main_data.png + + + false + + + Qt::ToolButtonTextUnderIcon + + + + + + + + 0 + 0 + + + + + + + 调试帮助 + + + + :/image/main_person.png:/image/main_person.png + + + Qt::ToolButtonTextUnderIcon + + + + + + + + 0 + 0 + + + + + + + 用户退出 + + + + :/image/main_exit.png:/image/main_exit.png + + + Qt::ToolButtonTextUnderIcon + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + 0 + 0 + + + + + 30 + 30 + + + + ArrowCursor + + + Qt::NoFocus + + + 最小化 + + + + + + + + + + + 0 + 0 + + + + + 30 + 30 + + + + ArrowCursor + + + Qt::NoFocus + + + 关闭 + + + + + + + + + + + 0 + 0 + + + + + 30 + 30 + + + + Qt::NoFocus + + + + + + + + + + + + + + + + + + + 0 + + + + + + + + + + 主界面 + + + Qt::AlignCenter + + + + + + + + + + + 系统设置 + + + Qt::AlignCenter + + + + + + + + + + + 警情查询 + + + Qt::AlignCenter + + + + + + + + + + + 调试帮助 + + + Qt::AlignCenter + + + + + + + + + + + + + + diff --git a/ui/uidemo01/head.h b/ui/uidemo01/head.h new file mode 100644 index 0000000..a8d5a79 --- /dev/null +++ b/ui/uidemo01/head.h @@ -0,0 +1,12 @@ +#include +#include + +#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0)) +#include +#endif + +#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) +#include +#endif + +#pragma execution_character_set("utf-8") diff --git a/ui/uidemo01/main.cpp b/ui/uidemo01/main.cpp new file mode 100644 index 0000000..69c2de3 --- /dev/null +++ b/ui/uidemo01/main.cpp @@ -0,0 +1,30 @@ +#include "frmmain.h" +#include "appinit.h" +#include "quihelper.h" + +int main(int argc, char *argv[]) +{ + QUIHelper::initMain(); + QApplication a(argc, argv); + AppInit::Instance()->start(); + + QUIHelper::setFont(); + QUIHelper::setCode(); + + //加载样式表 + QFile file(":/qss/blacksoft.css"); + if (file.open(QFile::ReadOnly)) { + QString qss = QLatin1String(file.readAll()); + QString paletteColor = qss.mid(20, 7); + qApp->setPalette(QPalette(QColor(paletteColor))); + qApp->setStyleSheet(qss); + file.close(); + } + + frmMain w; + w.resize(800, 600); + QUIHelper::setFormInCenter(&w); + w.show(); + + return a.exec(); +} diff --git a/ui/uidemo01/other/image/main_about.png b/ui/uidemo01/other/image/main_about.png new file mode 100644 index 0000000..7db8e7b Binary files /dev/null and b/ui/uidemo01/other/image/main_about.png differ diff --git a/ui/uidemo01/other/image/main_company.png b/ui/uidemo01/other/image/main_company.png new file mode 100644 index 0000000..87a52b3 Binary files /dev/null and b/ui/uidemo01/other/image/main_company.png differ diff --git a/ui/uidemo01/other/image/main_config.png b/ui/uidemo01/other/image/main_config.png new file mode 100644 index 0000000..d45b094 Binary files /dev/null and b/ui/uidemo01/other/image/main_config.png differ diff --git a/ui/uidemo01/other/image/main_data.png b/ui/uidemo01/other/image/main_data.png new file mode 100644 index 0000000..29b7250 Binary files /dev/null and b/ui/uidemo01/other/image/main_data.png differ diff --git a/ui/uidemo01/other/image/main_exit.png b/ui/uidemo01/other/image/main_exit.png new file mode 100644 index 0000000..d26ee30 Binary files /dev/null and b/ui/uidemo01/other/image/main_exit.png differ diff --git a/ui/uidemo01/other/image/main_help.png b/ui/uidemo01/other/image/main_help.png new file mode 100644 index 0000000..cb293d0 Binary files /dev/null and b/ui/uidemo01/other/image/main_help.png differ diff --git a/ui/uidemo01/other/image/main_main.png b/ui/uidemo01/other/image/main_main.png new file mode 100644 index 0000000..3273ada Binary files /dev/null and b/ui/uidemo01/other/image/main_main.png differ diff --git a/ui/uidemo01/other/image/main_person.png b/ui/uidemo01/other/image/main_person.png new file mode 100644 index 0000000..d68a5ee Binary files /dev/null and b/ui/uidemo01/other/image/main_person.png differ diff --git a/ui/uidemo01/other/main.qrc b/ui/uidemo01/other/main.qrc new file mode 100644 index 0000000..0b0bb1e --- /dev/null +++ b/ui/uidemo01/other/main.qrc @@ -0,0 +1,12 @@ + + + image/main_about.png + image/main_company.png + image/main_config.png + image/main_data.png + image/main_exit.png + image/main_help.png + image/main_main.png + image/main_person.png + + diff --git a/ui/uidemo01/snap.png b/ui/uidemo01/snap.png new file mode 100644 index 0000000..c707dd1 Binary files /dev/null and b/ui/uidemo01/snap.png differ diff --git a/ui/uidemo01/uidemo01.pro b/ui/uidemo01/uidemo01.pro new file mode 100644 index 0000000..51296cc --- /dev/null +++ b/ui/uidemo01/uidemo01.pro @@ -0,0 +1,18 @@ +QT += core gui +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets +greaterThan(QT_MAJOR_VERSION, 5): QT += core5compat + +TARGET = uidemo01 +TEMPLATE = app + +HEADERS += head.h +SOURCES += main.cpp +RESOURCES += other/main.qrc +RESOURCES += $$PWD/../core_qss/qss.qrc + +INCLUDEPATH += $$PWD +INCLUDEPATH += $$PWD/form +include ($$PWD/form/form.pri) + +INCLUDEPATH += $$PWD/../core_base +include ($$PWD/../core_base/core_base.pri) diff --git a/ui/uidemo08/form/form.pri b/ui/uidemo08/form/form.pri new file mode 100644 index 0000000..c6126ba --- /dev/null +++ b/ui/uidemo08/form/form.pri @@ -0,0 +1,8 @@ +FORMS += \ + $$PWD/frmmain.ui + +HEADERS += \ + $$PWD/frmmain.h + +SOURCES += \ + $$PWD/frmmain.cpp diff --git a/ui/uidemo08/form/frmmain.cpp b/ui/uidemo08/form/frmmain.cpp new file mode 100644 index 0000000..5c1275a --- /dev/null +++ b/ui/uidemo08/form/frmmain.cpp @@ -0,0 +1,250 @@ +#pragma execution_character_set("utf-8") + +#include "frmmain.h" +#include "ui_frmmain.h" +#include "iconhelper.h" +#include "quihelper.h" + +frmMain::frmMain(QWidget *parent) : QWidget(parent), ui(new Ui::frmMain) +{ + ui->setupUi(this); + this->initForm(); + this->initStyle(); + this->initLeftMain(); + this->initLeftConfig(); +} + +frmMain::~frmMain() +{ + delete ui; +} + +bool frmMain::eventFilter(QObject *watched, QEvent *event) +{ + if (watched == ui->widgetTitle) { + if (event->type() == QEvent::MouseButtonDblClick) { + on_btnMenu_Max_clicked(); + } + } + return QWidget::eventFilter(watched, event); +} + +void frmMain::getQssColor(const QString &qss, const QString &flag, QString &color) +{ + int index = qss.indexOf(flag); + if (index >= 0) { + color = qss.mid(index + flag.length(), 7); + } + //qDebug() << TIMEMS << flag << color; +} + +void frmMain::getQssColor(const QString &qss, QString &textColor, QString &panelColor, + QString &borderColor, QString &normalColorStart, QString &normalColorEnd, + QString &darkColorStart, QString &darkColorEnd, QString &highColor) +{ + getQssColor(qss, "TextColor:", textColor); + getQssColor(qss, "PanelColor:", panelColor); + getQssColor(qss, "BorderColor:", borderColor); + getQssColor(qss, "NormalColorStart:", normalColorStart); + getQssColor(qss, "NormalColorEnd:", normalColorEnd); + getQssColor(qss, "DarkColorStart:", darkColorStart); + getQssColor(qss, "DarkColorEnd:", darkColorEnd); + getQssColor(qss, "HighColor:", highColor); +} + +void frmMain::initForm() +{ + //设置无边框 + QUIHelper::setFramelessForm(this); + //设置图标 + IconHelper::setIcon(ui->labIco, 0xf073, 30); + IconHelper::setIcon(ui->btnMenu_Min, 0xf068); + IconHelper::setIcon(ui->btnMenu_Max, 0xf067); + IconHelper::setIcon(ui->btnMenu_Close, 0xf00d); + + //ui->widgetMenu->setVisible(false); + ui->widgetTitle->setProperty("form", "title"); + //关联事件过滤器用于双击放大 + ui->widgetTitle->installEventFilter(this); + ui->widgetTop->setProperty("nav", "top"); + + QFont font; + font.setPixelSize(25); + ui->labTitle->setFont(font); + ui->labTitle->setText("智能访客管理平台"); + this->setWindowTitle(ui->labTitle->text()); + + ui->stackedWidget->setStyleSheet("QLabel{font:60px;}"); + + QSize icoSize(32, 32); + int icoWidth = 85; + + //设置顶部导航按钮 + QList tbtns = ui->widgetTop->findChildren(); + foreach (QAbstractButton *btn, tbtns) { + btn->setIconSize(icoSize); + btn->setMinimumWidth(icoWidth); + btn->setCheckable(true); + connect(btn, SIGNAL(clicked()), this, SLOT(buttonClick())); + } + + ui->btnMain->click(); + + ui->widgetLeftMain->setProperty("flag", "left"); + ui->widgetLeftConfig->setProperty("flag", "left"); + ui->page1->setStyleSheet(QString("QWidget[flag=\"left\"] QAbstractButton{min-height:%1px;max-height:%1px;}").arg(60)); + ui->page2->setStyleSheet(QString("QWidget[flag=\"left\"] QAbstractButton{min-height:%1px;max-height:%1px;}").arg(25)); +} + +void frmMain::initStyle() +{ + //加载样式表 + QString qss; + QFile file(":/qss/blacksoft.css"); + if (file.open(QFile::ReadOnly)) { + qss = QLatin1String(file.readAll()); + QString paletteColor = qss.mid(20, 7); + qApp->setPalette(QPalette(paletteColor)); + qApp->setStyleSheet(qss); + file.close(); + } + + //先从样式表中取出对应的颜色 + QString textColor, panelColor, borderColor, normalColorStart, normalColorEnd, darkColorStart, darkColorEnd, highColor; + getQssColor(qss, textColor, panelColor, borderColor, normalColorStart, normalColorEnd, darkColorStart, darkColorEnd, highColor); + + //将对应颜色设置到控件 + this->borderColor = highColor; + this->normalBgColor = normalColorStart; + this->darkBgColor = panelColor; + this->normalTextColor = textColor; + this->darkTextColor = normalTextColor; +} + +void frmMain::buttonClick() +{ + QAbstractButton *b = (QAbstractButton *)sender(); + QString name = b->text(); + + QList tbtns = ui->widgetTop->findChildren(); + foreach (QAbstractButton *btn, tbtns) { + btn->setChecked(btn == b); + } + + if (name == "主界面") { + ui->stackedWidget->setCurrentIndex(0); + } else if (name == "系统设置") { + ui->stackedWidget->setCurrentIndex(1); + } else if (name == "警情查询") { + ui->stackedWidget->setCurrentIndex(2); + } else if (name == "调试帮助") { + ui->stackedWidget->setCurrentIndex(3); + } else if (name == "用户退出") { + exit(0); + } +} + +void frmMain::initLeftMain() +{ + iconsMain << 0xf030 << 0xf03e << 0xf247; + btnsMain << ui->tbtnMain1 << ui->tbtnMain2 << ui->tbtnMain3; + + int count = btnsMain.count(); + for (int i = 0; i < count; ++i) { + QToolButton *btn = (QToolButton *)btnsMain.at(i); + btn->setCheckable(true); + btn->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); + connect(btn, SIGNAL(clicked(bool)), this, SLOT(leftMainClick())); + } + + IconHelper::StyleColor styleColor; + styleColor.position = "left"; + styleColor.iconSize = 18; + styleColor.iconWidth = 35; + styleColor.iconHeight = 25; + styleColor.borderWidth = 4; + styleColor.borderColor = borderColor; + styleColor.setColor(normalBgColor, normalTextColor, darkBgColor, darkTextColor); + IconHelper::setStyle(ui->widgetLeftMain, btnsMain, iconsMain, styleColor); + ui->tbtnMain1->click(); +} + +void frmMain::initLeftConfig() +{ + iconsConfig << 0xf031 << 0xf036 << 0xf249 << 0xf055 << 0xf05a << 0xf249; + btnsConfig << ui->tbtnConfig1 << ui->tbtnConfig2 << ui->tbtnConfig3 << ui->tbtnConfig4 << ui->tbtnConfig5 << ui->tbtnConfig6; + + int count = btnsConfig.count(); + for (int i = 0; i < count; ++i) { + QToolButton *btn = (QToolButton *)btnsConfig.at(i); + btn->setCheckable(true); + btn->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + connect(btn, SIGNAL(clicked(bool)), this, SLOT(leftConfigClick())); + } + + IconHelper::StyleColor styleColor; + styleColor.position = "left"; + styleColor.iconSize = 16; + styleColor.iconWidth = 20; + styleColor.iconHeight = 20; + styleColor.borderWidth = 3; + styleColor.borderColor = borderColor; + styleColor.setColor(normalBgColor, normalTextColor, darkBgColor, darkTextColor); + IconHelper::setStyle(ui->widgetLeftConfig, btnsConfig, iconsConfig, styleColor); + ui->tbtnConfig1->click(); +} + +void frmMain::leftMainClick() +{ + QAbstractButton *b = (QAbstractButton *)sender(); + QString name = b->text(); + + int count = btnsMain.count(); + for (int i = 0; i < count; ++i) { + QAbstractButton *btn = btnsMain.at(i); + btn->setChecked(btn == b); + } + + ui->lab1->setText(name); +} + +void frmMain::leftConfigClick() +{ + QToolButton *b = (QToolButton *)sender(); + QString name = b->text(); + + int count = btnsConfig.count(); + for (int i = 0; i < count; ++i) { + QAbstractButton *btn = btnsConfig.at(i); + btn->setChecked(btn == b); + } + + ui->lab2->setText(name); +} + +void frmMain::on_btnMenu_Min_clicked() +{ + showMinimized(); +} + +void frmMain::on_btnMenu_Max_clicked() +{ + static bool max = false; + static QRect location = this->geometry(); + + if (max) { + this->setGeometry(location); + } else { + location = this->geometry(); + this->setGeometry(QUIHelper::getScreenRect()); + } + + this->setProperty("canMove", max); + max = !max; +} + +void frmMain::on_btnMenu_Close_clicked() +{ + close(); +} + diff --git a/ui/uidemo08/form/frmmain.h b/ui/uidemo08/form/frmmain.h new file mode 100644 index 0000000..fc7b9ec --- /dev/null +++ b/ui/uidemo08/form/frmmain.h @@ -0,0 +1,62 @@ +#ifndef FRMMAIN_H +#define FRMMAIN_H + +#include + +class QAbstractButton; + +namespace Ui { +class frmMain; +} + +class frmMain : public QWidget +{ + Q_OBJECT + +public: + explicit frmMain(QWidget *parent = 0); + ~frmMain(); + +protected: + bool eventFilter(QObject *watched, QEvent *event); + +private: + Ui::frmMain *ui; + + QList iconsMain; + QList btnsMain; + + QList iconsConfig; + QList btnsConfig; + +private: + //根据QSS样式获取对应颜色值 + QString borderColor; + QString normalBgColor; + QString darkBgColor; + QString normalTextColor; + QString darkTextColor; + + void getQssColor(const QString &qss, const QString &flag, QString &color); + void getQssColor(const QString &qss, QString &textColor, + QString &panelColor, QString &borderColor, + QString &normalColorStart, QString &normalColorEnd, + QString &darkColorStart, QString &darkColorEnd, + QString &highColor); + +private slots: + void initForm(); + void initStyle(); + void buttonClick(); + void initLeftMain(); + void initLeftConfig(); + void leftMainClick(); + void leftConfigClick(); + +private slots: + void on_btnMenu_Min_clicked(); + void on_btnMenu_Max_clicked(); + void on_btnMenu_Close_clicked(); +}; + +#endif // FRMMAIN_H diff --git a/ui/uidemo08/form/frmmain.ui b/ui/uidemo08/form/frmmain.ui new file mode 100644 index 0000000..bfdce03 --- /dev/null +++ b/ui/uidemo08/form/frmmain.ui @@ -0,0 +1,645 @@ + + + frmMain + + + + 0 + 0 + 810 + 600 + + + + Dialog + + + false + + + + 0 + + + 1 + + + 1 + + + 1 + + + 1 + + + + + + 0 + 0 + + + + + 10 + + + 10 + + + 0 + + + 0 + + + 0 + + + + + + + + Qt::AlignCenter + + + + + + + + + + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + 主界面 + + + + :/image/main_main.png:/image/main_main.png + + + Qt::ToolButtonTextUnderIcon + + + + + + + + 0 + 0 + + + + 系统设置 + + + + :/image/main_config.png:/image/main_config.png + + + Qt::ToolButtonTextUnderIcon + + + + + + + + 0 + 0 + + + + 警情查询 + + + + :/image/main_data.png:/image/main_data.png + + + false + + + Qt::ToolButtonTextUnderIcon + + + + + + + + 0 + 0 + + + + + + + 调试帮助 + + + + :/image/main_person.png:/image/main_person.png + + + Qt::ToolButtonTextUnderIcon + + + + + + + + 0 + 0 + + + + + + + 用户退出 + + + + :/image/main_exit.png:/image/main_exit.png + + + Qt::ToolButtonTextUnderIcon + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + 0 + 0 + + + + ArrowCursor + + + Qt::NoFocus + + + 最小化 + + + + + + + + + + + 0 + 0 + + + + ArrowCursor + + + Qt::NoFocus + + + 关闭 + + + + + + + + + + + 0 + 0 + + + + Qt::NoFocus + + + + + + + + + + + + + + + + + + + 1 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 90 + 16777215 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + 视频监控 + + + + + + + + 0 + 0 + + + + 地图监控 + + + + + + + + 0 + 0 + + + + 设备监控 + + + + + + + Qt::Vertical + + + + 20 + 471 + + + + + + + + + + + + 0 + 0 + + + + + + + Qt::AlignCenter + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 110 + 16777215 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + 基本设置 + + + + + + + + 0 + 0 + + + + 转发设置 + + + + + + + + 0 + 0 + + + + 用户设置 + + + + + + + + 0 + 0 + + + + 防区设置 + + + + + + + + 0 + 0 + + + + 设备设置 + + + + + + + + 0 + 0 + + + + 其他设置 + + + + + + + Qt::Vertical + + + + 20 + 417 + + + + + + + + + + + + 0 + 0 + + + + 系统设置 + + + Qt::AlignCenter + + + + + + + + + + + 警情查询 + + + Qt::AlignCenter + + + + + + + + + + + 调试帮助 + + + Qt::AlignCenter + + + + + + + + + + + + + + diff --git a/ui/uidemo08/head.h b/ui/uidemo08/head.h new file mode 100644 index 0000000..a8d5a79 --- /dev/null +++ b/ui/uidemo08/head.h @@ -0,0 +1,12 @@ +#include +#include + +#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0)) +#include +#endif + +#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) +#include +#endif + +#pragma execution_character_set("utf-8") diff --git a/ui/uidemo08/main.cpp b/ui/uidemo08/main.cpp new file mode 100644 index 0000000..af869a3 --- /dev/null +++ b/ui/uidemo08/main.cpp @@ -0,0 +1,19 @@ +#include "frmmain.h" +#include "appinit.h" +#include "quihelper.h" + +int main(int argc, char *argv[]) +{ + QUIHelper::initMain(); + QApplication a(argc, argv); + AppInit::Instance()->start(); + + QUIHelper::setFont(); + QUIHelper::setCode(); + + frmMain w; + QUIHelper::setFormInCenter(&w); + w.show(); + + return a.exec(); +} diff --git a/ui/uidemo08/other/image/main_about.png b/ui/uidemo08/other/image/main_about.png new file mode 100644 index 0000000..7db8e7b Binary files /dev/null and b/ui/uidemo08/other/image/main_about.png differ diff --git a/ui/uidemo08/other/image/main_company.png b/ui/uidemo08/other/image/main_company.png new file mode 100644 index 0000000..87a52b3 Binary files /dev/null and b/ui/uidemo08/other/image/main_company.png differ diff --git a/ui/uidemo08/other/image/main_config.png b/ui/uidemo08/other/image/main_config.png new file mode 100644 index 0000000..d45b094 Binary files /dev/null and b/ui/uidemo08/other/image/main_config.png differ diff --git a/ui/uidemo08/other/image/main_data.png b/ui/uidemo08/other/image/main_data.png new file mode 100644 index 0000000..29b7250 Binary files /dev/null and b/ui/uidemo08/other/image/main_data.png differ diff --git a/ui/uidemo08/other/image/main_exit.png b/ui/uidemo08/other/image/main_exit.png new file mode 100644 index 0000000..d26ee30 Binary files /dev/null and b/ui/uidemo08/other/image/main_exit.png differ diff --git a/ui/uidemo08/other/image/main_help.png b/ui/uidemo08/other/image/main_help.png new file mode 100644 index 0000000..cb293d0 Binary files /dev/null and b/ui/uidemo08/other/image/main_help.png differ diff --git a/ui/uidemo08/other/image/main_main.png b/ui/uidemo08/other/image/main_main.png new file mode 100644 index 0000000..3273ada Binary files /dev/null and b/ui/uidemo08/other/image/main_main.png differ diff --git a/ui/uidemo08/other/image/main_person.png b/ui/uidemo08/other/image/main_person.png new file mode 100644 index 0000000..d68a5ee Binary files /dev/null and b/ui/uidemo08/other/image/main_person.png differ diff --git a/ui/uidemo08/other/main.qrc b/ui/uidemo08/other/main.qrc new file mode 100644 index 0000000..0b0bb1e --- /dev/null +++ b/ui/uidemo08/other/main.qrc @@ -0,0 +1,12 @@ + + + image/main_about.png + image/main_company.png + image/main_config.png + image/main_data.png + image/main_exit.png + image/main_help.png + image/main_main.png + image/main_person.png + + diff --git a/ui/uidemo08/uidemo08.pro b/ui/uidemo08/uidemo08.pro new file mode 100644 index 0000000..ac0a6fe --- /dev/null +++ b/ui/uidemo08/uidemo08.pro @@ -0,0 +1,18 @@ +QT += core gui +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets +greaterThan(QT_MAJOR_VERSION, 5): QT += core5compat + +TARGET = uidemo08 +TEMPLATE = app + +HEADERS += head.h +SOURCES += main.cpp +RESOURCES += other/main.qrc +RESOURCES += $$PWD/../core_qss/qss.qrc + +INCLUDEPATH += $$PWD +INCLUDEPATH += $$PWD/form +include ($$PWD/form/form.pri) + +INCLUDEPATH += $$PWD/../core_base +include ($$PWD/../core_base/core_base.pri) diff --git a/ui/uidemo09/form/form.pri b/ui/uidemo09/form/form.pri new file mode 100644 index 0000000..c6126ba --- /dev/null +++ b/ui/uidemo09/form/form.pri @@ -0,0 +1,8 @@ +FORMS += \ + $$PWD/frmmain.ui + +HEADERS += \ + $$PWD/frmmain.h + +SOURCES += \ + $$PWD/frmmain.cpp diff --git a/ui/uidemo09/form/frmmain.cpp b/ui/uidemo09/form/frmmain.cpp new file mode 100644 index 0000000..9d557f1 --- /dev/null +++ b/ui/uidemo09/form/frmmain.cpp @@ -0,0 +1,73 @@ +#pragma execution_character_set("utf-8") + +#include "frmmain.h" +#include "ui_frmmain.h" + +frmMain::frmMain(QWidget *parent) : QWidget(parent), ui(new Ui::frmMain) +{ + ui->setupUi(this); + this->initForm(); +} + +frmMain::~frmMain() +{ + delete ui; +} + +void frmMain::initForm() +{ + this->setWindowTitle("九宫格主界面"); + + bg = "main2.jpg"; + QList btns = this->findChildren(); + + foreach (QToolButton *btn, btns) { + connect(btn, SIGNAL(clicked()), this, SLOT(buttonClick())); + } +} + +void frmMain::buttonClick() +{ + QToolButton *btn = (QToolButton *)sender(); + QString objName = btn->objectName(); + + if (objName == "btnCOMTool") { + if (bg == "main1.jpg") { + bg = "main2.jpg"; + } else if (bg == "main2.jpg") { + bg = "main3.jpg"; + } else if (bg == "main3.jpg") { + bg = "main4.jpg"; + } else if (bg == "main4.jpg") { + bg = "main5.jpg"; + } else if (bg == "main5.jpg") { + bg = "main1.jpg"; + } + + QString qss = QString("QWidget#frm{background-image: url(:/image/%1);}").arg(bg); + qss += "QToolButton{color:#E7ECF0;background-color:rgba(0,0,0,0);border-style:none;}"; + this->setStyleSheet(qss); + } else if (objName == "btnAddressTool") { + + } else if (objName == "btnTCPTool") { + this->close(); + } else if (objName == "btnCOMTCPTool") { + + } else if (objName == "btnDefence") { + + } else if (objName == "btnHostTool") { + + } else if (objName == "btnLinkTool") { + + } else if (objName == "btnMaiChongTool") { + + } else if (objName == "btnPlot") { + + } else if (objName == "btnZhangLi4Tool") { + + } else if (objName == "btnZhangLi5Tool") { + + } else if (objName == "btnZhangLiTool") { + + } +} diff --git a/ui/uidemo09/form/frmmain.h b/ui/uidemo09/form/frmmain.h new file mode 100644 index 0000000..04e5e6d --- /dev/null +++ b/ui/uidemo09/form/frmmain.h @@ -0,0 +1,27 @@ +#ifndef FRMMAIN_H +#define FRMMAIN_H + +#include + +namespace Ui { +class frmMain; +} + +class frmMain : public QWidget +{ + Q_OBJECT + +public: + explicit frmMain(QWidget *parent = 0); + ~frmMain(); + +private: + Ui::frmMain *ui; + QString bg; + +private slots: + void initForm(); + void buttonClick(); +}; + +#endif // FRMMAIN_H diff --git a/ui/uidemo09/form/frmmain.ui b/ui/uidemo09/form/frmmain.ui new file mode 100644 index 0000000..d83a1a7 --- /dev/null +++ b/ui/uidemo09/form/frmmain.ui @@ -0,0 +1,382 @@ + + + frmMain + + + + 0 + 0 + 800 + 480 + + + + Dialog + + + QWidget#frm{ +background-image: url(:/image/main2.jpg); +} +QToolButton{ +font: 10pt "微软雅黑"; +color:#E7ECF0; +background-color:rgba(0,0,0,0); +border-style:none; +} + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 30 + + + 30 + + + 30 + + + 30 + + + 6 + + + + + + 0 + 0 + + + + 更换背景 + + + + :/image/PNG112.png:/image/PNG112.png + + + + 100 + 100 + + + + Qt::ToolButtonTextUnderIcon + + + + + + + + 0 + 0 + + + + 退出系统 + + + + :/image/PNG100.png:/image/PNG100.png + + + + 100 + 100 + + + + Qt::ToolButtonTextUnderIcon + + + + + + + + 0 + 0 + + + + 串口转网络工具 + + + + :/image/PNG99.png:/image/PNG99.png + + + + 100 + 100 + + + + Qt::ToolButtonTextUnderIcon + + + + + + + + 0 + 0 + + + + 设备调试工具 + + + + :/image/PNG101.png:/image/PNG101.png + + + + 100 + 100 + + + + Qt::ToolButtonTextUnderIcon + + + + + + + + 0 + 0 + + + + 张力批量配置工具 + + + + :/image/PNG103.png:/image/PNG103.png + + + + 100 + 100 + + + + Qt::ToolButtonTextUnderIcon + + + + + + + + 0 + 0 + + + + 5道张力调试工具 + + + + :/image/PNG104.png:/image/PNG104.png + + + + 100 + 100 + + + + Qt::ToolButtonTextUnderIcon + + + + + + + + 0 + 0 + + + + 脉冲主机调试工具 + + + + :/image/PNG105.png:/image/PNG105.png + + + + 100 + 100 + + + + Qt::ToolButtonTextUnderIcon + + + + + + + + 0 + 0 + + + + 主机内部调试工具 + + + + :/image/PNG108.png:/image/PNG108.png + + + + 100 + 100 + + + + Qt::ToolButtonTextUnderIcon + + + + + + + + 0 + 0 + + + + 联动模块调试工具 + + + + :/image/PNG109.png:/image/PNG109.png + + + + 100 + 100 + + + + Qt::ToolButtonTextUnderIcon + + + + + + + + 0 + 0 + + + + 张力曲线图 + + + + :/image/PNG110.png:/image/PNG110.png + + + + 100 + 100 + + + + Qt::ToolButtonTextUnderIcon + + + + + + + + 0 + 0 + + + + 防区管理 + + + + :/image/PNG111.png:/image/PNG111.png + + + + 100 + 100 + + + + Qt::ToolButtonTextUnderIcon + + + + + + + + 0 + 0 + + + + 系统配置 + + + + :/image/PNG114.png:/image/PNG114.png + + + + 100 + 100 + + + + Qt::ToolButtonTextUnderIcon + + + + + + + + + + + + + diff --git a/ui/uidemo09/head.h b/ui/uidemo09/head.h new file mode 100644 index 0000000..e0e56a4 --- /dev/null +++ b/ui/uidemo09/head.h @@ -0,0 +1,13 @@ +#include +#include + +#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0)) +#include +#endif + +#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) +#include +#endif + +#pragma execution_character_set("utf-8") + diff --git a/ui/uidemo09/main.cpp b/ui/uidemo09/main.cpp new file mode 100644 index 0000000..69b1b2d --- /dev/null +++ b/ui/uidemo09/main.cpp @@ -0,0 +1,29 @@ +#include "frmmain.h" +#include "appinit.h" +#include "quihelper.h" + +int main(int argc, char *argv[]) +{ + QUIHelper::initMain(); + QApplication a(argc, argv); + AppInit::Instance()->start(); + + QUIHelper::setFont(); + QUIHelper::setCode(); + + //加载样式表 + QFile file(":/qss/blacksoft.css"); + if (file.open(QFile::ReadOnly)) { + QString qss = QLatin1String(file.readAll()); + QString paletteColor = qss.mid(20, 7); + qApp->setPalette(QPalette(paletteColor)); + qApp->setStyleSheet(qss); + file.close(); + } + + frmMain w; + QUIHelper::setFormInCenter(&w); + w.show(); + + return a.exec(); +} diff --git a/ui/uidemo09/other/image/PNG100.png b/ui/uidemo09/other/image/PNG100.png new file mode 100644 index 0000000..b42907d Binary files /dev/null and b/ui/uidemo09/other/image/PNG100.png differ diff --git a/ui/uidemo09/other/image/PNG101.png b/ui/uidemo09/other/image/PNG101.png new file mode 100644 index 0000000..38c9663 Binary files /dev/null and b/ui/uidemo09/other/image/PNG101.png differ diff --git a/ui/uidemo09/other/image/PNG102.png b/ui/uidemo09/other/image/PNG102.png new file mode 100644 index 0000000..9ca638e Binary files /dev/null and b/ui/uidemo09/other/image/PNG102.png differ diff --git a/ui/uidemo09/other/image/PNG103.png b/ui/uidemo09/other/image/PNG103.png new file mode 100644 index 0000000..4fa8c15 Binary files /dev/null and b/ui/uidemo09/other/image/PNG103.png differ diff --git a/ui/uidemo09/other/image/PNG104.png b/ui/uidemo09/other/image/PNG104.png new file mode 100644 index 0000000..cb1141a Binary files /dev/null and b/ui/uidemo09/other/image/PNG104.png differ diff --git a/ui/uidemo09/other/image/PNG105.png b/ui/uidemo09/other/image/PNG105.png new file mode 100644 index 0000000..a3c4737 Binary files /dev/null and b/ui/uidemo09/other/image/PNG105.png differ diff --git a/ui/uidemo09/other/image/PNG106.png b/ui/uidemo09/other/image/PNG106.png new file mode 100644 index 0000000..e05374f Binary files /dev/null and b/ui/uidemo09/other/image/PNG106.png differ diff --git a/ui/uidemo09/other/image/PNG107.png b/ui/uidemo09/other/image/PNG107.png new file mode 100644 index 0000000..2d6ebb9 Binary files /dev/null and b/ui/uidemo09/other/image/PNG107.png differ diff --git a/ui/uidemo09/other/image/PNG108.png b/ui/uidemo09/other/image/PNG108.png new file mode 100644 index 0000000..4376893 Binary files /dev/null and b/ui/uidemo09/other/image/PNG108.png differ diff --git a/ui/uidemo09/other/image/PNG109.png b/ui/uidemo09/other/image/PNG109.png new file mode 100644 index 0000000..fc157d6 Binary files /dev/null and b/ui/uidemo09/other/image/PNG109.png differ diff --git a/ui/uidemo09/other/image/PNG110.png b/ui/uidemo09/other/image/PNG110.png new file mode 100644 index 0000000..c33d305 Binary files /dev/null and b/ui/uidemo09/other/image/PNG110.png differ diff --git a/ui/uidemo09/other/image/PNG111.png b/ui/uidemo09/other/image/PNG111.png new file mode 100644 index 0000000..b60ee54 Binary files /dev/null and b/ui/uidemo09/other/image/PNG111.png differ diff --git a/ui/uidemo09/other/image/PNG112.png b/ui/uidemo09/other/image/PNG112.png new file mode 100644 index 0000000..d7a7d2a Binary files /dev/null and b/ui/uidemo09/other/image/PNG112.png differ diff --git a/ui/uidemo09/other/image/PNG114.png b/ui/uidemo09/other/image/PNG114.png new file mode 100644 index 0000000..9b6b294 Binary files /dev/null and b/ui/uidemo09/other/image/PNG114.png differ diff --git a/ui/uidemo09/other/image/PNG99.png b/ui/uidemo09/other/image/PNG99.png new file mode 100644 index 0000000..6c6ae13 Binary files /dev/null and b/ui/uidemo09/other/image/PNG99.png differ diff --git a/ui/uidemo09/other/image/main1.jpg b/ui/uidemo09/other/image/main1.jpg new file mode 100644 index 0000000..efdd4f2 Binary files /dev/null and b/ui/uidemo09/other/image/main1.jpg differ diff --git a/ui/uidemo09/other/image/main2.jpg b/ui/uidemo09/other/image/main2.jpg new file mode 100644 index 0000000..c5c20dc Binary files /dev/null and b/ui/uidemo09/other/image/main2.jpg differ diff --git a/ui/uidemo09/other/image/main3.jpg b/ui/uidemo09/other/image/main3.jpg new file mode 100644 index 0000000..6b9521f Binary files /dev/null and b/ui/uidemo09/other/image/main3.jpg differ diff --git a/ui/uidemo09/other/image/main4.jpg b/ui/uidemo09/other/image/main4.jpg new file mode 100644 index 0000000..6cfdfe8 Binary files /dev/null and b/ui/uidemo09/other/image/main4.jpg differ diff --git a/ui/uidemo09/other/image/main5.jpg b/ui/uidemo09/other/image/main5.jpg new file mode 100644 index 0000000..730e810 Binary files /dev/null and b/ui/uidemo09/other/image/main5.jpg differ diff --git a/ui/uidemo09/other/main.qrc b/ui/uidemo09/other/main.qrc new file mode 100644 index 0000000..bb6cf4a --- /dev/null +++ b/ui/uidemo09/other/main.qrc @@ -0,0 +1,24 @@ + + + image/main1.jpg + image/main2.jpg + image/main3.jpg + image/main4.jpg + image/main5.jpg + image/PNG99.png + image/PNG100.png + image/PNG101.png + image/PNG102.png + image/PNG103.png + image/PNG104.png + image/PNG105.png + image/PNG106.png + image/PNG107.png + image/PNG108.png + image/PNG109.png + image/PNG110.png + image/PNG111.png + image/PNG112.png + image/PNG114.png + + diff --git a/ui/uidemo09/snap.png b/ui/uidemo09/snap.png new file mode 100644 index 0000000..2bbff8e Binary files /dev/null and b/ui/uidemo09/snap.png differ diff --git a/ui/uidemo09/uidemo09.pro b/ui/uidemo09/uidemo09.pro new file mode 100644 index 0000000..30d36c0 --- /dev/null +++ b/ui/uidemo09/uidemo09.pro @@ -0,0 +1,18 @@ +QT += core gui +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets +greaterThan(QT_MAJOR_VERSION, 5): QT += core5compat + +TARGET = uidemo09 +TEMPLATE = app + +HEADERS += head.h +SOURCES += main.cpp +RESOURCES += other/main.qrc +RESOURCES += $$PWD/../core_qss/qss.qrc + +INCLUDEPATH += $$PWD +INCLUDEPATH += $$PWD/form +include ($$PWD/form/form.pri) + +INCLUDEPATH += $$PWD/../core_base +include ($$PWD/../core_base/core_base.pri) diff --git a/ui/uidemo10/form/form.pri b/ui/uidemo10/form/form.pri new file mode 100644 index 0000000..c6126ba --- /dev/null +++ b/ui/uidemo10/form/form.pri @@ -0,0 +1,8 @@ +FORMS += \ + $$PWD/frmmain.ui + +HEADERS += \ + $$PWD/frmmain.h + +SOURCES += \ + $$PWD/frmmain.cpp diff --git a/ui/uidemo10/form/frmmain.cpp b/ui/uidemo10/form/frmmain.cpp new file mode 100644 index 0000000..b655716 --- /dev/null +++ b/ui/uidemo10/form/frmmain.cpp @@ -0,0 +1,59 @@ +#pragma execution_character_set("utf-8") + +#include "frmmain.h" +#include "ui_frmmain.h" +#include "iconhelper.h" + +frmMain::frmMain(QWidget *parent) : QWidget(parent), ui(new Ui::frmMain) +{ + ui->setupUi(this); + this->initForm(); +} + +frmMain::~frmMain() +{ + delete ui; +} + +void frmMain::initForm() +{ + int iconSize = 100; + int iconWidth = 150; + int iconHeight = 130; + + QList listColorBg; + listColorBg << "#FF3739" << "#1A9FE0" << "#41BB1A" << "#1570A5" << "#FE781F" << "#9B59BB"; + QList listColorText; + listColorText << "#FEFEFE" << "#FEFEFE" << "#FEFEFE" << "#FEFEFE" << "#FEFEFE" << "#FEFEFE"; + + QList icons; + icons << 0xf2ba << 0xf002 << 0xf2c2 << 0xf02f << 0xf013 << 0xf021; + QList names; + names << "访客登记" << "记录查询" << "证件扫描" << "信息打印" << "系统设置" << "系统重启"; + + QList btns = this->findChildren(); + for (int i = 0; i < btns.count(); ++i) { + QToolButton *btn = btns.at(i); + btn->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); + btn->setIconSize(QSize(iconWidth, iconHeight)); + + QPixmap pix = IconHelper::getPixmap(listColorText.at(i), icons.at(i), iconSize, iconWidth, iconHeight); + btn->setIcon(QIcon(pix)); + btn->setText(names.at(i)); + btn->setStyleSheet(QString("QToolButton{font:%1px;color:%2;background-color:%3;border:none;border-radius:0px;}") + .arg(iconSize / 2).arg(listColorText.at(i)).arg(listColorBg.at(i))); + + connect(btn, SIGNAL(clicked(bool)), this, SLOT(buttonClicked())); + } +} + +void frmMain::buttonClicked() +{ + QToolButton *btn = (QToolButton *)sender(); + QString text = btn->text(); + qDebug() << text; + + if (text == "系统重启") { + close(); + } +} diff --git a/ui/uidemo10/form/frmmain.h b/ui/uidemo10/form/frmmain.h new file mode 100644 index 0000000..0033b5f --- /dev/null +++ b/ui/uidemo10/form/frmmain.h @@ -0,0 +1,26 @@ +#ifndef FRMMAIN_H +#define FRMMAIN_H + +#include + +namespace Ui { +class frmMain; +} + +class frmMain : public QWidget +{ + Q_OBJECT + +public: + explicit frmMain(QWidget *parent = 0); + ~frmMain(); + +private: + Ui::frmMain *ui; + +private slots: + void initForm(); + void buttonClicked(); +}; + +#endif // FRMMAIN_H diff --git a/ui/uidemo10/form/frmmain.ui b/ui/uidemo10/form/frmmain.ui new file mode 100644 index 0000000..65d0a75 --- /dev/null +++ b/ui/uidemo10/form/frmmain.ui @@ -0,0 +1,135 @@ + + + frmMain + + + + 0 + 0 + 800 + 480 + + + + Dialog + + + + + + + 0 + 0 + + + + + + + + + + Qt::ToolButtonTextUnderIcon + + + + + + + + 0 + 0 + + + + + + + + + + Qt::ToolButtonTextUnderIcon + + + + + + + + 0 + 0 + + + + + + + + + + Qt::ToolButtonTextUnderIcon + + + + + + + + 0 + 0 + + + + + + + + + + Qt::ToolButtonTextUnderIcon + + + + + + + + 0 + 0 + + + + + + + + + + Qt::ToolButtonTextUnderIcon + + + + + + + + 0 + 0 + + + + + + + + + + Qt::ToolButtonTextUnderIcon + + + + + + + + diff --git a/ui/uidemo10/head.h b/ui/uidemo10/head.h new file mode 100644 index 0000000..a8d5a79 --- /dev/null +++ b/ui/uidemo10/head.h @@ -0,0 +1,12 @@ +#include +#include + +#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0)) +#include +#endif + +#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) +#include +#endif + +#pragma execution_character_set("utf-8") diff --git a/ui/uidemo10/main.cpp b/ui/uidemo10/main.cpp new file mode 100644 index 0000000..047e477 --- /dev/null +++ b/ui/uidemo10/main.cpp @@ -0,0 +1,20 @@ +#include "frmmain.h" +#include "appinit.h" +#include "quihelper.h" + +int main(int argc, char *argv[]) +{ + QUIHelper::initMain(); + QApplication a(argc, argv); + AppInit::Instance()->start(); + + QUIHelper::setFont(); + QUIHelper::setCode(); + + frmMain w; + w.setWindowTitle("metro风格主界面 (QQ: 517216493 WX: feiyangqingyun)"); + QUIHelper::setFormInCenter(&w); + w.show(); + + return a.exec(); +} diff --git a/ui/uidemo10/snap.png b/ui/uidemo10/snap.png new file mode 100644 index 0000000..687709b Binary files /dev/null and b/ui/uidemo10/snap.png differ diff --git a/ui/uidemo10/uidemo10.pro b/ui/uidemo10/uidemo10.pro new file mode 100644 index 0000000..973aeb4 --- /dev/null +++ b/ui/uidemo10/uidemo10.pro @@ -0,0 +1,16 @@ +QT += core gui +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets +greaterThan(QT_MAJOR_VERSION, 5): QT += core5compat + +TARGET = uidemo10 +TEMPLATE = app + +HEADERS += head.h +SOURCES += main.cpp + +INCLUDEPATH += $$PWD +INCLUDEPATH += $$PWD/form +include ($$PWD/form/form.pri) + +INCLUDEPATH += $$PWD/../core_base +include ($$PWD/../core_base/core_base.pri)