改进很多代码
After Width: | Height: | Size: 143 KiB |
Before Width: | Height: | Size: 172 KiB |
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 43 KiB |
|
@ -1,9 +1,10 @@
|
|||
#### 一、目录说明
|
||||
#### 一、目录说明
|
||||
1. **可以选择打开QWidgetDemo.pro一次性编译所有的,也可以进入到目录下打开pro进行编译。**
|
||||
2. **如果发现有些子项目没有加载请打开QWidgetDemo.pro仔细看里面的注释。**
|
||||
3. **编译好的可执行文件在源码同级目录下的bin目录。**
|
||||
4. **亲测Qt4.6到Qt6.2所有版本,亲测win、linux、mac、uos等系统。**
|
||||
5. **本项目开源的是下面表格中描述的内容,并未开源左侧的树状导航菜单控件,只是方便演示效果图直接用的自定义控件大全的效果图,懒得重新截图。**
|
||||
6. **建议用git命令行下载,压缩包下载后重新解压文件可能会有问题,不知为何。**
|
||||
|
||||
| 编号 | 文件夹 | 描述 |
|
||||
| :------ | :------ | :------ |
|
||||
|
@ -77,7 +78,7 @@
|
|||
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/0snap/bgdemo.gif)
|
||||
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/0snap/dbpage.png)
|
||||
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/0snap/pngtool.gif)
|
||||
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/0snap/savelog.png)
|
||||
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/0snap/savelog.jpg)
|
||||
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/0snap/saveruntime.jpg)
|
||||
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/0snap/colorwidget.gif)
|
||||
![avatar](https://gitee.com/feiyangqingyun/QWidgetDemo/raw/master/0snap/maskwidget.gif)
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
#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.toLocal8Bit().toBase64());
|
||||
}
|
||||
|
||||
QString Base64Helper::base64ToText(const QString &text)
|
||||
{
|
||||
return QString(QByteArray::fromBase64(text.toLocal8Bit()));
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
#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 <QImage>
|
||||
|
||||
#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
|
|
@ -21,7 +21,6 @@ CONFIG += resources_big
|
|||
include ($$PWD/h3.pri)
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/base64helper.h \
|
||||
$$PWD/iconhelper.h \
|
||||
$$PWD/quiconfig.h \
|
||||
$$PWD/quidateselect.h \
|
||||
|
@ -34,7 +33,6 @@ HEADERS += \
|
|||
$$PWD/quiwidget.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/base64helper.cpp \
|
||||
$$PWD/iconhelper.cpp \
|
||||
$$PWD/quiconfig.cpp \
|
||||
$$PWD/quidateselect.cpp \
|
||||
|
|
|
@ -59,5 +59,6 @@
|
|||
#include "quitipbox.h"
|
||||
#include "quidateselect.h"
|
||||
#include "quiinputbox.h"
|
||||
#include "quiwidget.h"
|
||||
|
||||
#endif // QUIHEAD_H
|
||||
|
|
|
@ -1372,3 +1372,87 @@ bool QUIHelper::checkRowCount(int rowCount, int maxCount, int warnCount)
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
QPixmap QUIHelper::getPixmap(QWidget *widget, const QPixmap &pixmap, bool scale)
|
||||
{
|
||||
if (pixmap.isNull()) {
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
//scale=false 超过尺寸才需要等比例缩放
|
||||
QPixmap pix = pixmap;
|
||||
if (scale) {
|
||||
pix = pix.scaled(widget->size() - QSize(2, 2), Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
} else if (pix.width() > widget->width() || pix.height() > widget->height()) {
|
||||
pix = pix.scaled(widget->size() - QSize(2, 2), Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
}
|
||||
|
||||
return pix;
|
||||
}
|
||||
|
||||
void QUIHelper::setPixmap(QLabel *label, const QString &file, bool scale)
|
||||
{
|
||||
//文件不存在则不用处理
|
||||
if (!QFile(file).exists()) {
|
||||
label->clear();
|
||||
return;
|
||||
}
|
||||
|
||||
QPixmap pixmap(file);
|
||||
pixmap = getPixmap(label, pixmap);
|
||||
label->setPixmap(pixmap);
|
||||
}
|
||||
|
||||
void QUIHelper::setLogo(QLabel *label, const QString &file,
|
||||
int width, int height, int offset,
|
||||
const QString &oldColor, const QString &newColor)
|
||||
{
|
||||
//如果是icon开头则表示图形字体否则取logo图片
|
||||
if (file.startsWith("icon")) {
|
||||
//设置图形字体作为logo
|
||||
height = 55, width = 80;
|
||||
QString text = file.split("_").last();
|
||||
int icon = text.toInt(NULL, 16);
|
||||
IconHelper::setIcon(label, icon, height);
|
||||
} else {
|
||||
//区分资源文件和本地文件
|
||||
QString fileName = file;
|
||||
if (!file.startsWith(":/")) {
|
||||
height = 50;
|
||||
fileName = QString("%1/logo/%2.png").arg(QUIHelper::appPath()).arg(file);
|
||||
}
|
||||
|
||||
//svg图片自动换颜色
|
||||
if (file.endsWith(".svg")) {
|
||||
//打开文件对指定颜色进行替换
|
||||
QFile f(file);
|
||||
if (f.open(QFile::ReadOnly)) {
|
||||
QString text = f.readAll();
|
||||
text.replace(oldColor, newColor);
|
||||
f.close();
|
||||
|
||||
//打开新的文件输出
|
||||
fileName = QString("%1/logo/temp.svg").arg(QUIHelper::appPath());
|
||||
QFile f2(fileName);
|
||||
if (f2.open(QFile::WriteOnly)) {
|
||||
f2.write(text.toUtf8());
|
||||
f2.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//自动计算宽度比例
|
||||
QPixmap pixmap(fileName);
|
||||
width = pixmap.width() / (pixmap.height() / height);
|
||||
pixmap = pixmap.scaled(width, height, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
label->setPixmap(pixmap);
|
||||
}
|
||||
|
||||
//设置logo标签最小宽度
|
||||
if (width - height < offset) {
|
||||
width += offset;
|
||||
}
|
||||
|
||||
label->setFixedWidth(width);
|
||||
label->setAlignment(Qt::AlignCenter);
|
||||
}
|
||||
|
|
|
@ -223,6 +223,14 @@ public:
|
|||
static void openFile(const QString &fileName, const QString &msg);
|
||||
//导出和打印数据提示框
|
||||
static bool checkRowCount(int rowCount, int maxCount, int warnCount);
|
||||
|
||||
//获取等比例缩放过的图片
|
||||
static QPixmap getPixmap(QWidget *widget, const QPixmap &pixmap, bool scale = false);
|
||||
static void setPixmap(QLabel *label, const QString &file, bool scale = false);
|
||||
//设置logo图片支持 资源文件+本地图片+图形字体+svg自动变色 等多种形式
|
||||
static void setLogo(QLabel *label, const QString &file,
|
||||
int width, int height, int offset = 20,
|
||||
const QString &oldColor = QString(), const QString &newColor = QString());
|
||||
};
|
||||
|
||||
#endif // QUIHELPER_H
|
||||
|
|
|
@ -25,11 +25,25 @@ void QUIStyle::getStyle(QStringList &styleNames, QStringList &styleFiles)
|
|||
styleFiles = files;
|
||||
}
|
||||
|
||||
void QUIStyle::setStyle(const QString &qss, const QString &paletteColor)
|
||||
void QUIStyle::setStyle(const QString &qss)
|
||||
{
|
||||
QStringList list;
|
||||
list << qss;
|
||||
|
||||
//5.12开始tabbar左右反过来的
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5,12,0))
|
||||
//左右两侧的边框偏移一个像素
|
||||
list << "QTabWidget::pane:left{left:-1px;right:0px;}";
|
||||
list << "QTabWidget::pane:right{right:-1px;left:0px;}";
|
||||
//选中和悬停的时候边缘加深2个像素
|
||||
list << "QTabBar::tab:left:selected,QTabBar::tab:left:hover{border-width:0px 0px 0px 2px;}";
|
||||
list << "QTabBar::tab:right:selected,QTabBar::tab:right:hover{border-width:0px 2px 0px 0px;}";
|
||||
#endif
|
||||
|
||||
QUIHelper::isCustomUI = true;
|
||||
QString paletteColor = qss.mid(20, 7);
|
||||
qApp->setPalette(QPalette(paletteColor));
|
||||
qApp->setStyleSheet(qss);
|
||||
qApp->setStyleSheet(list.join(""));
|
||||
}
|
||||
|
||||
void QUIStyle::setStyle(const QUIStyle::Style &style)
|
||||
|
@ -48,18 +62,18 @@ void QUIStyle::setStyle(const QUIStyle::Style &style)
|
|||
QString paletteColor = qss.mid(20, 7);
|
||||
getQssColor(qss, QUIConfig::TextColor, QUIConfig::PanelColor, QUIConfig::BorderColor, QUIConfig::NormalColorStart,
|
||||
QUIConfig::NormalColorEnd, QUIConfig::DarkColorStart, QUIConfig::DarkColorEnd, QUIConfig::HighColor);
|
||||
setStyle(qss, paletteColor);
|
||||
setStyle(qss);
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
|
||||
void QUIStyle::setStyle(const QString &qssFile)
|
||||
void QUIStyle::setStyleFile(const QString &qssFile)
|
||||
{
|
||||
QString paletteColor, textColor;
|
||||
setStyle(qssFile, paletteColor, textColor);
|
||||
setStyleFile(qssFile, paletteColor, textColor);
|
||||
}
|
||||
|
||||
void QUIStyle::setStyle(const QString &qssFile, QString &paletteColor, QString &textColor)
|
||||
void QUIStyle::setStyleFile(const QString &qssFile, QString &paletteColor, QString &textColor)
|
||||
{
|
||||
QFile file(qssFile);
|
||||
if (file.open(QFile::ReadOnly)) {
|
||||
|
@ -68,78 +82,49 @@ void QUIStyle::setStyle(const QString &qssFile, QString &paletteColor, QString &
|
|||
textColor = qss.mid(49, 7);
|
||||
getQssColor(qss, QUIConfig::TextColor, QUIConfig::PanelColor, QUIConfig::BorderColor, QUIConfig::NormalColorStart,
|
||||
QUIConfig::NormalColorEnd, QUIConfig::DarkColorStart, QUIConfig::DarkColorEnd, QUIConfig::HighColor);
|
||||
setStyle(qss, paletteColor);
|
||||
setStyle(qss);
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
|
||||
void QUIStyle::setStyle(const QString &qssFile, QString &textColor, QString &panelColor, QString &borderColor,
|
||||
QString &normalColorStart, QString &normalColorEnd,
|
||||
QString &darkColorStart, QString &darkColorEnd, QString &highColor)
|
||||
void QUIStyle::setStyleFile(const QString &qssFile, QString &textColor, QString &panelColor, QString &borderColor,
|
||||
QString &normalColorStart, QString &normalColorEnd,
|
||||
QString &darkColorStart, QString &darkColorEnd, QString &highColor)
|
||||
{
|
||||
QFile file(qssFile);
|
||||
if (file.open(QFile::ReadOnly)) {
|
||||
QString qss = QLatin1String(file.readAll());
|
||||
getQssColor(qss, textColor, panelColor, borderColor, normalColorStart, normalColorEnd, darkColorStart, darkColorEnd, highColor);
|
||||
setStyle(qss, panelColor);
|
||||
setStyle(qss);
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
|
||||
void QUIStyle::getQssColor(const QString &qss, QString &textColor, QString &panelColor, QString &borderColor,
|
||||
void QUIStyle::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 QUIStyle::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);
|
||||
|
||||
QUIHelper::isCustomUI = true;
|
||||
|
||||
QString str = qss;
|
||||
QString flagTextColor = "TextColor:";
|
||||
int indexTextColor = str.indexOf(flagTextColor);
|
||||
if (indexTextColor >= 0) {
|
||||
textColor = str.mid(indexTextColor + flagTextColor.length(), 7);
|
||||
}
|
||||
|
||||
QString flagPanelColor = "PanelColor:";
|
||||
int indexPanelColor = str.indexOf(flagPanelColor);
|
||||
if (indexPanelColor >= 0) {
|
||||
panelColor = str.mid(indexPanelColor + flagPanelColor.length(), 7);
|
||||
}
|
||||
|
||||
QString flagBorderColor = "BorderColor:";
|
||||
int indexBorderColor = str.indexOf(flagBorderColor);
|
||||
if (indexBorderColor >= 0) {
|
||||
borderColor = str.mid(indexBorderColor + flagBorderColor.length(), 7);
|
||||
}
|
||||
|
||||
QString flagNormalColorStart = "NormalColorStart:";
|
||||
int indexNormalColorStart = str.indexOf(flagNormalColorStart);
|
||||
if (indexNormalColorStart >= 0) {
|
||||
normalColorStart = str.mid(indexNormalColorStart + flagNormalColorStart.length(), 7);
|
||||
}
|
||||
|
||||
QString flagNormalColorEnd = "NormalColorEnd:";
|
||||
int indexNormalColorEnd = str.indexOf(flagNormalColorEnd);
|
||||
if (indexNormalColorEnd >= 0) {
|
||||
normalColorEnd = str.mid(indexNormalColorEnd + flagNormalColorEnd.length(), 7);
|
||||
}
|
||||
|
||||
QString flagDarkColorStart = "DarkColorStart:";
|
||||
int indexDarkColorStart = str.indexOf(flagDarkColorStart);
|
||||
if (indexDarkColorStart >= 0) {
|
||||
darkColorStart = str.mid(indexDarkColorStart + flagDarkColorStart.length(), 7);
|
||||
}
|
||||
|
||||
QString flagDarkColorEnd = "DarkColorEnd:";
|
||||
int indexDarkColorEnd = str.indexOf(flagDarkColorEnd);
|
||||
if (indexDarkColorEnd >= 0) {
|
||||
darkColorEnd = str.mid(indexDarkColorEnd + flagDarkColorEnd.length(), 7);
|
||||
}
|
||||
|
||||
QString flagHighColor = "HighColor:";
|
||||
int indexHighColor = str.indexOf(flagHighColor);
|
||||
if (indexHighColor >= 0) {
|
||||
highColor = str.mid(indexHighColor + flagHighColor.length(), 7);
|
||||
}
|
||||
QUIConfig::TextColor = textColor;
|
||||
}
|
||||
|
||||
void QUIStyle::setLabStyle(QLabel *lab, quint8 type, const QString &bgColor, const QString &textColor)
|
||||
|
|
|
@ -30,17 +30,18 @@ public:
|
|||
//获取皮肤样式中文名称和对应的样式表文件
|
||||
static void getStyle(QStringList &styleNames, QStringList &styleFiles);
|
||||
//设置全局样式
|
||||
static void setStyle(const QString &qss, const QString &paletteColor);
|
||||
static void setStyle(const QString &qss);
|
||||
static void setStyle(const QUIStyle::Style &style);
|
||||
static void setStyle(const QString &qssFile);
|
||||
static void setStyle(const QString &qssFile, QString &paletteColor, QString &textColor);
|
||||
static void setStyle(const QString &qssFile, QString &textColor,
|
||||
QString &panelColor, QString &borderColor,
|
||||
QString &normalColorStart, QString &normalColorEnd,
|
||||
QString &darkColorStart, QString &darkColorEnd,
|
||||
QString &highColor);
|
||||
static void setStyleFile(const QString &qssFile);
|
||||
static void setStyleFile(const QString &qssFile, QString &paletteColor, QString &textColor);
|
||||
static void setStyleFile(const QString &qssFile, QString &textColor,
|
||||
QString &panelColor, QString &borderColor,
|
||||
QString &normalColorStart, QString &normalColorEnd,
|
||||
QString &darkColorStart, QString &darkColorEnd,
|
||||
QString &highColor);
|
||||
|
||||
//根据QSS样式获取对应颜色值
|
||||
static void getQssColor(const QString &qss, const QString &flag, QString &color);
|
||||
static void getQssColor(const QString &qss, QString &textColor,
|
||||
QString &panelColor, QString &borderColor,
|
||||
QString &normalColorStart, QString &normalColorEnd,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
QUIWidget::QUIWidget(QWidget *parent) : QDialog(parent)
|
||||
{
|
||||
this->initControl();
|
||||
this->initForm();
|
||||
this->initForm();
|
||||
}
|
||||
|
||||
QUIWidget::~QUIWidget()
|
||||
|
@ -234,7 +234,7 @@ void QUIWidget::initForm()
|
|||
setIcon(QUIWidget::BtnMenu_Close, QUIConfig::IconClose);
|
||||
|
||||
this->widgetTitle->setProperty("form", "title");
|
||||
QUIHelper::setFramelessForm(this);
|
||||
QUIHelper::setFramelessForm(this, false, false, false);
|
||||
|
||||
//设置标题及对齐方式
|
||||
title = "QUI Demo";
|
||||
|
@ -249,24 +249,41 @@ void QUIWidget::initForm()
|
|||
this->installEventFilter(this);
|
||||
this->widgetTitle->installEventFilter(this);
|
||||
|
||||
//默认切换换肤立即换肤
|
||||
changedStyle = true;
|
||||
|
||||
//添加换肤菜单
|
||||
QStringList styleNames, styleFiles;
|
||||
QUIStyle::getStyle(styleNames, styleFiles);
|
||||
|
||||
//添加到动作分组中形成互斥效果
|
||||
actionGroup = new QActionGroup(this);
|
||||
int count = styleNames.count();
|
||||
for (int i = 0; i < count; i++) {
|
||||
QAction *action = new QAction(this);
|
||||
//设置可选中前面有个勾勾
|
||||
action->setCheckable(true);
|
||||
action->setText(styleNames.at(i));
|
||||
action->setData(styleFiles.at(i));
|
||||
connect(action, SIGNAL(triggered(bool)), this, SLOT(changeStyle()));
|
||||
this->btnMenu->addAction(action);
|
||||
actionGroup->addAction(action);
|
||||
}
|
||||
|
||||
//默认选择一种样式
|
||||
setQssChecked(":/qss/lightblue.css");
|
||||
}
|
||||
|
||||
void QUIWidget::changeStyle()
|
||||
{
|
||||
QAction *action = (QAction *)sender();
|
||||
QString qssFile = action->data().toString();
|
||||
QUIStyle::setStyle(qssFile);
|
||||
|
||||
//有些应用可能只需要发送个换肤的信号给他就行
|
||||
if (changedStyle) {
|
||||
QUIStyle::setStyleFile(qssFile);
|
||||
}
|
||||
|
||||
emit changeStyle(qssFile);
|
||||
}
|
||||
|
||||
|
@ -399,6 +416,22 @@ void QUIWidget::setMainWidget(QWidget *mainWidget)
|
|||
}
|
||||
}
|
||||
|
||||
void QUIWidget::setQssChecked(const QString &qssFile)
|
||||
{
|
||||
QList<QAction *> actions = actionGroup->actions();
|
||||
foreach (QAction *action, actions) {
|
||||
if (action->data().toString() == qssFile) {
|
||||
action->setChecked(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QUIWidget::setChangedStyle(bool changedStyle)
|
||||
{
|
||||
this->changedStyle = changedStyle;
|
||||
}
|
||||
|
||||
void QUIWidget::on_btnMenu_Min_clicked()
|
||||
{
|
||||
if (minHide) {
|
||||
|
|
|
@ -42,11 +42,14 @@ private:
|
|||
QVBoxLayout *verticalLayout3;
|
||||
|
||||
private:
|
||||
QString title; //标题
|
||||
Qt::Alignment alignment;//标题文本对齐
|
||||
bool minHide; //最小化隐藏
|
||||
bool exitAll; //退出整个程序
|
||||
QWidget *mainWidget; //主窗体对象
|
||||
QString title; //标题
|
||||
Qt::Alignment alignment; //标题文本对齐
|
||||
bool minHide; //最小化隐藏
|
||||
bool exitAll; //退出整个程序
|
||||
QWidget *mainWidget; //主窗体对象
|
||||
|
||||
bool changedStyle; //切换换肤是否立即换肤
|
||||
QActionGroup *actionGroup; //换肤菜单动作组
|
||||
|
||||
public:
|
||||
QLabel *getLabIco() const;
|
||||
|
@ -55,7 +58,7 @@ public:
|
|||
QToolButton *getBtnMenu() const;
|
||||
QPushButton *getBtnMenuMin() const;
|
||||
QPushButton *getBtnMenuMax() const;
|
||||
QPushButton *getBtnMenuClose() const;
|
||||
QPushButton *getBtnMenuClose() const;
|
||||
|
||||
QString getTitle() const;
|
||||
Qt::Alignment getAlignment() const;
|
||||
|
@ -66,9 +69,9 @@ public:
|
|||
QSize minimumSizeHint() const;
|
||||
|
||||
private slots:
|
||||
void initControl(); //初始化控件
|
||||
void initForm(); //初始化窗体
|
||||
void changeStyle(); //更换样式
|
||||
void initControl(); //初始化控件
|
||||
void initForm(); //初始化窗体
|
||||
void changeStyle(); //更换样式
|
||||
|
||||
private slots:
|
||||
void on_btnMenu_Min_clicked();
|
||||
|
@ -104,6 +107,11 @@ public Q_SLOTS:
|
|||
//设置主窗体
|
||||
void setMainWidget(QWidget *mainWidget);
|
||||
|
||||
//设置默认选中的换肤菜单
|
||||
void setQssChecked(const QString &qssFile);
|
||||
//设置切换换肤是否立即换肤
|
||||
void setChangedStyle(bool changedStyle);
|
||||
|
||||
Q_SIGNALS:
|
||||
void changeStyle(const QString &qssFile);
|
||||
void closing();
|
||||
|
|
|
@ -2,5 +2,6 @@
|
|||
<qresource prefix="/">
|
||||
<file>image/fontawesome-webfont.ttf</file>
|
||||
<file>image/iconfont.ttf</file>
|
||||
<file>image/pe-icon-set-weather.ttf</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include "qfileinfo.h"
|
||||
#include "qdir.h"
|
||||
#include "qprogressbar.h"
|
||||
#include "qtimer.h"
|
||||
#include "qdebug.h"
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
|
@ -53,8 +52,7 @@ DeviceSizeTable::DeviceSizeTable(QWidget *parent) : QTableWidget(parent)
|
|||
this->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
this->verticalHeader()->setVisible(true);
|
||||
this->horizontalHeader()->setStretchLastSection(true);
|
||||
|
||||
QTimer::singleShot(0, this, SLOT(load()));
|
||||
QMetaObject::invokeMethod(this, "load");
|
||||
}
|
||||
|
||||
QColor DeviceSizeTable::getBgColor() const
|
||||
|
|
|
@ -20,25 +20,107 @@ frmSaveLog::~frmSaveLog()
|
|||
|
||||
void frmSaveLog::initForm()
|
||||
{
|
||||
//启动定时器追加数据
|
||||
count = 0;
|
||||
timer = new QTimer(this);
|
||||
connect(timer, SIGNAL(timeout()), this, SLOT(append()));
|
||||
timer->setInterval(1000);
|
||||
timer->setInterval(100);
|
||||
|
||||
SaveLog::Instance()->setPath(qApp->applicationDirPath());
|
||||
//添加消息类型
|
||||
QStringList types, datas;
|
||||
types << "Debug" << "Info" << "Warning" << "Critical" << "Fatal";
|
||||
datas << "1" << "2" << "4" << "8" << "16";
|
||||
ui->cboxType->addItems(types);
|
||||
|
||||
//添加消息类型到列表用于勾选设置哪些类型需要重定向
|
||||
int count = types.count();
|
||||
for (int i = 0; i < count; ++i) {
|
||||
QListWidgetItem *item = new QListWidgetItem;
|
||||
item->setText(types.at(i));
|
||||
item->setData(Qt::UserRole, datas.at(i));
|
||||
item->setCheckState(Qt::Checked);
|
||||
ui->listType->addItem(item);
|
||||
}
|
||||
|
||||
//添加日志文件大小下拉框
|
||||
ui->cboxSize->addItem("不启用", 0);
|
||||
ui->cboxSize->addItem("5kb", 5);
|
||||
ui->cboxSize->addItem("10kb", 10);
|
||||
ui->cboxSize->addItem("30kb", 30);
|
||||
ui->cboxSize->addItem("1mb", 1024);
|
||||
|
||||
ui->cboxRow->addItem("不启用", 0);
|
||||
ui->cboxRow->addItem("100条", 100);
|
||||
ui->cboxRow->addItem("500条", 500);
|
||||
ui->cboxRow->addItem("2000条", 2000);
|
||||
ui->cboxRow->addItem("10000条", 10000);
|
||||
|
||||
//设置是否开启日志上下文打印比如行号、函数等
|
||||
SaveLog::Instance()->setUseContext(false);
|
||||
//设置文件存储目录
|
||||
SaveLog::Instance()->setPath(qApp->applicationDirPath() + "/log");
|
||||
}
|
||||
|
||||
void frmSaveLog::append()
|
||||
void frmSaveLog::append(const QString &flag)
|
||||
{
|
||||
QString msg = QString("当前时间: %1 测试打印输出消息").arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss"));
|
||||
if (count >= 100) {
|
||||
count = 0;
|
||||
ui->txtMain->clear();
|
||||
}
|
||||
|
||||
QString str1;
|
||||
int type = ui->cboxType->currentIndex();
|
||||
if (!ui->ckSave->isChecked()) {
|
||||
if (type == 0) {
|
||||
str1 = "Debug ";
|
||||
} else if (type == 1) {
|
||||
str1 = "Infox ";
|
||||
} else if (type == 2) {
|
||||
str1 = "Warnx ";
|
||||
} else if (type == 3) {
|
||||
str1 = "Error ";
|
||||
} else if (type == 4) {
|
||||
str1 = "Fatal ";
|
||||
}
|
||||
}
|
||||
|
||||
QString str2 = QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss");
|
||||
QString str3 = flag.isEmpty() ? "自动插入消息" : flag;
|
||||
QString msg = QString("%1当前时间: %2 %3").arg(str1).arg(str2).arg(str3);
|
||||
|
||||
//开启网络重定向换成英文方便接收解析不乱码
|
||||
//对方接收解析的工具未必是utf8
|
||||
if (ui->ckNet->isChecked()) {
|
||||
msg = QString("%1time: %2 %3").arg(str1).arg(str2).arg("(QQ: 517216493 WX: feiyangqingyun)");
|
||||
}
|
||||
|
||||
count++;
|
||||
ui->txtMain->append(msg);
|
||||
qDebug() << msg;
|
||||
|
||||
//根据不同的类型打印
|
||||
//TMD转换要分两部走不然msvc的debug版本会乱码(英文也一样)
|
||||
//char *data = msg.toUtf8().data();
|
||||
QByteArray buffer = msg.toUtf8();
|
||||
const char *data = buffer.constData();
|
||||
if (type == 0) {
|
||||
qDebug(data);
|
||||
} else if (type == 1) {
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0))
|
||||
qInfo(data);
|
||||
#endif
|
||||
} else if (type == 2) {
|
||||
qWarning(data);
|
||||
} else if (type == 3) {
|
||||
qCritical(data);
|
||||
} else if (type == 4) {
|
||||
//调用下面这个打印完会直接退出程序
|
||||
qFatal(data);
|
||||
}
|
||||
}
|
||||
|
||||
void frmSaveLog::on_btnDebug_clicked()
|
||||
void frmSaveLog::on_btnLog_clicked()
|
||||
{
|
||||
QString msg = QString("当前时间: %1 手动插入消息").arg(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss"));
|
||||
ui->txtMain->append(msg);
|
||||
qDebug() << msg;
|
||||
append("手动插入消息");
|
||||
}
|
||||
|
||||
void frmSaveLog::on_ckTimer_stateChanged(int arg1)
|
||||
|
@ -47,12 +129,15 @@ void frmSaveLog::on_ckTimer_stateChanged(int arg1)
|
|||
timer->stop();
|
||||
} else {
|
||||
timer->start();
|
||||
on_btnLog_clicked();
|
||||
}
|
||||
}
|
||||
|
||||
void frmSaveLog::on_ckNet_stateChanged(int arg1)
|
||||
{
|
||||
SaveLog::Instance()->setToNet(arg1 != 0);
|
||||
SaveLog::Instance()->setListenPort(ui->txtPort->text().toInt());
|
||||
SaveLog::Instance()->setToNet(ui->ckNet->isChecked());
|
||||
on_btnLog_clicked();
|
||||
}
|
||||
|
||||
void frmSaveLog::on_ckSave_stateChanged(int arg1)
|
||||
|
@ -61,5 +146,42 @@ void frmSaveLog::on_ckSave_stateChanged(int arg1)
|
|||
SaveLog::Instance()->stop();
|
||||
} else {
|
||||
SaveLog::Instance()->start();
|
||||
on_btnLog_clicked();
|
||||
}
|
||||
}
|
||||
|
||||
void frmSaveLog::on_cboxSize_currentIndexChanged(int index)
|
||||
{
|
||||
int size = ui->cboxSize->itemData(index).toInt();
|
||||
SaveLog::Instance()->setMaxSize(size);
|
||||
on_btnLog_clicked();
|
||||
}
|
||||
|
||||
void frmSaveLog::on_cboxRow_currentIndexChanged(int index)
|
||||
{
|
||||
int row = ui->cboxRow->itemData(index).toInt();
|
||||
SaveLog::Instance()->setMaxRow(row);
|
||||
on_btnLog_clicked();
|
||||
}
|
||||
|
||||
void frmSaveLog::on_listType_itemPressed(QListWidgetItem *item)
|
||||
{
|
||||
if (item <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
//切换选中行状态
|
||||
item->setCheckState(item->checkState() == Qt::Checked ? Qt::Unchecked : Qt::Checked);
|
||||
|
||||
//找到所有勾选的类型进行设置
|
||||
quint8 types = 0;
|
||||
int count = ui->listType->count();
|
||||
for (int i = 0; i < count; ++i) {
|
||||
QListWidgetItem *item = ui->listType->item(i);
|
||||
if (item->checkState() == Qt::Checked) {
|
||||
types += item->data(Qt::UserRole).toInt();
|
||||
}
|
||||
}
|
||||
|
||||
SaveLog::Instance()->setMsgType((MsgType)types);
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define FRMSAVELOG_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QListWidgetItem>
|
||||
|
||||
namespace Ui {
|
||||
class frmSaveLog;
|
||||
|
@ -17,15 +18,22 @@ public:
|
|||
|
||||
private:
|
||||
Ui::frmSaveLog *ui;
|
||||
int count;
|
||||
QTimer *timer;
|
||||
|
||||
private slots:
|
||||
void initForm();
|
||||
void append();
|
||||
void on_btnDebug_clicked();
|
||||
void append(const QString &flag = QString());
|
||||
|
||||
private slots:
|
||||
void on_btnLog_clicked();
|
||||
void on_ckTimer_stateChanged(int arg1);
|
||||
void on_ckNet_stateChanged(int arg1);
|
||||
void on_ckSave_stateChanged(int arg1);
|
||||
void on_ckSave_stateChanged(int arg1);
|
||||
|
||||
void on_cboxSize_currentIndexChanged(int index);
|
||||
void on_cboxRow_currentIndexChanged(int index);
|
||||
void on_listType_itemPressed(QListWidgetItem *item);
|
||||
};
|
||||
|
||||
#endif // FRMSAVELOG_H
|
||||
|
|
|
@ -13,60 +13,119 @@
|
|||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QTextEdit" name="txtMain"/>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnDebug">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>130</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>手动插入消息</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="ckTimer">
|
||||
<property name="text">
|
||||
<string>定时器打印消息</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="ckNet">
|
||||
<property name="text">
|
||||
<string>重定向到网络</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="ckSave">
|
||||
<property name="text">
|
||||
<string>保存日志</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Box</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="cboxSize"/>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="cboxRow"/>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="cboxType">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="labSize">
|
||||
<property name="text">
|
||||
<string>文件大小</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="labRow">
|
||||
<property name="text">
|
||||
<string>文件行数</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labType">
|
||||
<property name="text">
|
||||
<string>消息类型</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="labPort">
|
||||
<property name="text">
|
||||
<string>监听端口</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="txtPort">
|
||||
<property name="text">
|
||||
<string>6000</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listType"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="ckSave">
|
||||
<property name="text">
|
||||
<string>开启日志重定向</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="ckNet">
|
||||
<property name="text">
|
||||
<string>日志输出到网络</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="ckTimer">
|
||||
<property name="text">
|
||||
<string>定时器打印消息</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnLog">
|
||||
<property name="text">
|
||||
<string>手动插入消息</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
|
|
@ -24,7 +24,7 @@ int main(int argc, char *argv[])
|
|||
#endif
|
||||
|
||||
frmSaveLog w;
|
||||
w.setWindowTitle("输出日志文件");
|
||||
w.setWindowTitle("日志重定向示例 V2022 (QQ: 517216493 WX: feiyangqingyun)");
|
||||
w.show();
|
||||
|
||||
return a.exec();
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
目前发现msvc的qt debug模式的可能数据不正确,不知道debug编码做了什么处理
|
|
@ -1,4 +1,6 @@
|
|||
#include "savelog.h"
|
||||
#pragma execution_character_set("utf-8")
|
||||
|
||||
#include "savelog.h"
|
||||
#include "qmutex.h"
|
||||
#include "qdir.h"
|
||||
#include "qfile.h"
|
||||
|
@ -10,6 +12,7 @@
|
|||
#include "qstringlist.h"
|
||||
|
||||
#define QDATE qPrintable(QDate::currentDate().toString("yyyy-MM-dd"))
|
||||
#define QDATETIMS qPrintable(QDateTime::currentDateTime().toString("yyyy-MM-dd-HH-mm-ss"))
|
||||
|
||||
//日志重定向
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0))
|
||||
|
@ -24,24 +27,42 @@ void Log(QtMsgType type, const char *msg)
|
|||
QString content;
|
||||
|
||||
//这里可以根据不同的类型加上不同的头部用于区分
|
||||
int msgType = SaveLog::Instance()->getMsgType();
|
||||
switch (type) {
|
||||
case QtDebugMsg:
|
||||
content = QString("%1").arg(msg);
|
||||
if ((msgType & MsgType_Debug) == MsgType_Debug) {
|
||||
content = QString("Debug %1").arg(msg);
|
||||
}
|
||||
break;
|
||||
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0))
|
||||
case QtInfoMsg:
|
||||
if ((msgType & MsgType_Info) == MsgType_Info) {
|
||||
content = QString("Infox %1").arg(msg);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case QtWarningMsg:
|
||||
content = QString("%1").arg(msg);
|
||||
if ((msgType & MsgType_Warning) == MsgType_Warning) {
|
||||
content = QString("Warnx %1").arg(msg);
|
||||
}
|
||||
break;
|
||||
|
||||
case QtCriticalMsg:
|
||||
content = QString("%1").arg(msg);
|
||||
if ((msgType & MsgType_Critical) == MsgType_Critical) {
|
||||
content = QString("Error %1").arg(msg);
|
||||
}
|
||||
break;
|
||||
|
||||
case QtFatalMsg:
|
||||
content = QString("%1").arg(msg);
|
||||
if ((msgType & MsgType_Fatal) == MsgType_Fatal) {
|
||||
content = QString("Fatal %1").arg(msg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
//没有内容则返回
|
||||
if (content.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
//加上打印代码所在代码文件、行号、函数名
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0))
|
||||
if (SaveLog::Instance()->getUseContext()) {
|
||||
|
@ -54,6 +75,7 @@ void Log(QtMsgType type, const char *msg)
|
|||
}
|
||||
#endif
|
||||
|
||||
//还可以将数据转成html内容分颜色区分
|
||||
//将内容传给函数进行处理
|
||||
SaveLog::Instance()->save(content);
|
||||
}
|
||||
|
@ -78,10 +100,14 @@ SaveLog::SaveLog(QObject *parent) : QObject(parent)
|
|||
//估计日志钩子可能单独开了线程
|
||||
connect(this, SIGNAL(send(QString)), SendLog::Instance(), SLOT(send(QString)));
|
||||
|
||||
file = new QFile(this);
|
||||
isRun = false;
|
||||
maxRow = currentRow = 0;
|
||||
maxSize = 128;
|
||||
toNet = false;
|
||||
useContext = true;
|
||||
|
||||
//全局的文件对象,在需要的时候打开而不是每次添加日志都打开
|
||||
file = new QFile(this);
|
||||
//默认取应用程序根目录
|
||||
path = qApp->applicationDirPath();
|
||||
//默认取应用程序可执行文件名称
|
||||
|
@ -89,6 +115,9 @@ SaveLog::SaveLog(QObject *parent) : QObject(parent)
|
|||
QStringList list = str.split("/");
|
||||
name = list.at(list.count() - 1).split(".").at(0);
|
||||
fileName = "";
|
||||
|
||||
//默认所有类型都输出
|
||||
msgType = MsgType(MsgType_Debug | MsgType_Info | MsgType_Warning | MsgType_Critical | MsgType_Fatal);
|
||||
}
|
||||
|
||||
SaveLog::~SaveLog()
|
||||
|
@ -96,14 +125,40 @@ SaveLog::~SaveLog()
|
|||
file->close();
|
||||
}
|
||||
|
||||
void SaveLog::openFile(const QString &fileName)
|
||||
{
|
||||
//当文件名改变时才新建和打开文件而不是每次都打开文件(效率极低)或者一开始打开文件
|
||||
if (this->fileName != fileName) {
|
||||
this->fileName = fileName;
|
||||
//先关闭之前的
|
||||
if (file->isOpen()) {
|
||||
file->close();
|
||||
}
|
||||
//重新设置新的日志文件
|
||||
file->setFileName(fileName);
|
||||
//以 Append 追加的形式打开
|
||||
file->open(QIODevice::WriteOnly | QIODevice::Append | QFile::Text);
|
||||
}
|
||||
}
|
||||
|
||||
bool SaveLog::getUseContext()
|
||||
{
|
||||
return this->useContext;
|
||||
}
|
||||
|
||||
MsgType SaveLog::getMsgType()
|
||||
{
|
||||
return this->msgType;
|
||||
}
|
||||
|
||||
//安装日志钩子,输出调试信息到文件,便于调试
|
||||
void SaveLog::start()
|
||||
{
|
||||
if (isRun) {
|
||||
return;
|
||||
}
|
||||
|
||||
isRun = true;
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0))
|
||||
qInstallMessageHandler(Log);
|
||||
#else
|
||||
|
@ -114,6 +169,12 @@ void SaveLog::start()
|
|||
//卸载日志钩子
|
||||
void SaveLog::stop()
|
||||
{
|
||||
if (!isRun) {
|
||||
return;
|
||||
}
|
||||
|
||||
isRun = false;
|
||||
this->clear();
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0))
|
||||
qInstallMessageHandler(0);
|
||||
#else
|
||||
|
@ -121,38 +182,97 @@ void SaveLog::stop()
|
|||
#endif
|
||||
}
|
||||
|
||||
void SaveLog::clear()
|
||||
{
|
||||
currentRow = 0;
|
||||
fileName.clear();
|
||||
if (file->isOpen()) {
|
||||
file->close();
|
||||
}
|
||||
}
|
||||
|
||||
void SaveLog::save(const QString &content)
|
||||
{
|
||||
//如果重定向输出到网络则通过网络发出去,否则输出到日志文件
|
||||
if (toNet) {
|
||||
emit send(content);
|
||||
} else {
|
||||
//检查目录是否存在,不存在则先新建
|
||||
//目录不存在则先新建目录
|
||||
QDir dir(path);
|
||||
if (!dir.exists()) {
|
||||
dir.mkdir(path);
|
||||
}
|
||||
|
||||
//方法改进:之前每次输出日志都打开文件,改成只有当日期改变时才新建和打开文件
|
||||
QString fileName = QString("%1/%2_log_%3.txt").arg(path).arg(name).arg(QDATE);
|
||||
if (this->fileName != fileName) {
|
||||
this->fileName = fileName;
|
||||
if (file->isOpen()) {
|
||||
file->close();
|
||||
//日志存储规则有多种策略 优先级 行数>大小>日期
|
||||
//1: 设置了最大行数限制则按照行数限制来
|
||||
//2: 设置了大小则按照大小来控制日志文件
|
||||
//3: 都没有设置都存储到日期命名的文件,只有当日期变化了才会切换到新的日志文件
|
||||
bool needOpen = false;
|
||||
if (maxRow > 0) {
|
||||
currentRow++;
|
||||
if (fileName.isEmpty()) {
|
||||
needOpen = true;
|
||||
} else if (currentRow >= maxRow) {
|
||||
needOpen = true;
|
||||
}
|
||||
|
||||
file->setFileName(fileName);
|
||||
file->open(QIODevice::WriteOnly | QIODevice::Append | QFile::Text);
|
||||
} else if (maxSize > 0) {
|
||||
//1MB=1024*1024 经过大量测试 QFile().size() 方法速度非常快
|
||||
//首次需要重新打开文件以及超过大小需要重新打开文件
|
||||
if (fileName.isEmpty()) {
|
||||
needOpen = true;
|
||||
} else if (file->size() > (maxSize * 1024)) {
|
||||
needOpen = true;
|
||||
}
|
||||
} else {
|
||||
//日期改变了才会触发
|
||||
QString fileName = QString("%1/%2_log_%3.txt").arg(path).arg(name).arg(QDATE);
|
||||
openFile(fileName);
|
||||
}
|
||||
|
||||
QTextStream logStream(file);
|
||||
logStream << content << "\n";
|
||||
if ((maxRow > 0 || maxSize > 0) && needOpen) {
|
||||
currentRow = 0;
|
||||
QString fileName = QString("%1/%2_log_%3.txt").arg(path).arg(name).arg(QDATETIMS);
|
||||
openFile(fileName);
|
||||
}
|
||||
|
||||
//用文本流的输出速度更快
|
||||
QTextStream stream(file);
|
||||
stream.setCodec("utf-8");
|
||||
stream << content << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
void SaveLog::setMaxRow(int maxRow)
|
||||
{
|
||||
//这里可以限定最大最小值
|
||||
if (maxRow >= 0) {
|
||||
this->maxRow = maxRow;
|
||||
this->clear();
|
||||
}
|
||||
}
|
||||
|
||||
void SaveLog::setMaxSize(int maxSize)
|
||||
{
|
||||
//这里可以限定最大最小值
|
||||
if (maxSize >= 0) {
|
||||
this->maxSize = maxSize;
|
||||
this->clear();
|
||||
}
|
||||
}
|
||||
|
||||
void SaveLog::setListenPort(int listenPort)
|
||||
{
|
||||
SendLog::Instance()->setListenPort(listenPort);
|
||||
}
|
||||
|
||||
void SaveLog::setToNet(bool toNet)
|
||||
{
|
||||
this->toNet = toNet;
|
||||
if (toNet) {
|
||||
SendLog::Instance()->start();
|
||||
} else {
|
||||
SendLog::Instance()->stop();
|
||||
}
|
||||
}
|
||||
|
||||
void SaveLog::setUseContext(bool useContext)
|
||||
|
@ -170,6 +290,11 @@ void SaveLog::setName(const QString &name)
|
|||
this->name = name;
|
||||
}
|
||||
|
||||
void SaveLog::setMsgType(const MsgType &msgType)
|
||||
{
|
||||
this->msgType = msgType;
|
||||
}
|
||||
|
||||
|
||||
//网络发送日志数据类
|
||||
QScopedPointer<SendLog> SendLog::self;
|
||||
|
@ -186,18 +311,14 @@ SendLog *SendLog::Instance()
|
|||
return self.data();
|
||||
}
|
||||
|
||||
SendLog::SendLog(QObject *parent)
|
||||
SendLog::SendLog(QObject *parent) : QObject(parent)
|
||||
{
|
||||
listenPort = 6000;
|
||||
socket = NULL;
|
||||
|
||||
//实例化网络通信服务器对象
|
||||
server = new QTcpServer(this);
|
||||
connect(server, SIGNAL(newConnection()), this, SLOT(newConnection()));
|
||||
|
||||
int listenPort = 6000;
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0))
|
||||
server->listen(QHostAddress::AnyIPv4, listenPort);
|
||||
#else
|
||||
server->listen(QHostAddress::Any, listenPort);
|
||||
#endif
|
||||
}
|
||||
|
||||
SendLog::~SendLog()
|
||||
|
@ -211,15 +332,41 @@ SendLog::~SendLog()
|
|||
|
||||
void SendLog::newConnection()
|
||||
{
|
||||
//限定就一个连接
|
||||
while (server->hasPendingConnections()) {
|
||||
socket = server->nextPendingConnection();
|
||||
}
|
||||
}
|
||||
|
||||
void SendLog::setListenPort(int listenPort)
|
||||
{
|
||||
this->listenPort = listenPort;
|
||||
}
|
||||
|
||||
void SendLog::start()
|
||||
{
|
||||
//启动端口监听
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0))
|
||||
server->listen(QHostAddress::AnyIPv4, listenPort);
|
||||
#else
|
||||
server->listen(QHostAddress::Any, listenPort);
|
||||
#endif
|
||||
}
|
||||
|
||||
void SendLog::stop()
|
||||
{
|
||||
if (socket != NULL) {
|
||||
socket->disconnectFromHost();
|
||||
socket = NULL;
|
||||
}
|
||||
|
||||
server->close();
|
||||
}
|
||||
|
||||
void SendLog::send(const QString &content)
|
||||
{
|
||||
if (socket != NULL && socket->isOpen()) {
|
||||
socket->write(content.toUtf8());
|
||||
socket->flush();
|
||||
//socket->flush();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,9 +7,14 @@
|
|||
* 2. 支持日志存储的目录。
|
||||
* 3. 支持网络发出打印日志。
|
||||
* 4. 支持输出日志上下文信息比如所在代码文件、行号、函数名等。
|
||||
* 5. 支持Qt4+Qt5+Qt6,开箱即用。
|
||||
* 6. 自动加锁支持多线程。
|
||||
* 7. 使用做到最简单,start即可。
|
||||
* 5. 支持设置日志文件大小限制,超过则自动分文件,默认128kb。
|
||||
* 6. 支持按照日志行数自动分文件,和日志大小条件互斥。
|
||||
* 7. 可选按照日期时间区分文件名存储日志。
|
||||
* 8. 日志文件命名规则优先级:行数》大小》日期。
|
||||
* 9. 自动加锁支持多线程。
|
||||
* 10. 可以分别控制哪些类型的日志需要重定向输出。
|
||||
* 11. 支持Qt4+Qt5+Qt6,开箱即用。
|
||||
* 12. 使用方式最简单,调用函数start()启动服务,stop()停止服务。
|
||||
*/
|
||||
|
||||
#include <QObject>
|
||||
|
@ -18,6 +23,15 @@ class QFile;
|
|||
class QTcpSocket;
|
||||
class QTcpServer;
|
||||
|
||||
//消息类型
|
||||
enum MsgType {
|
||||
MsgType_Debug = 0x0001,
|
||||
MsgType_Info = 0x0002,
|
||||
MsgType_Warning = 0x0004,
|
||||
MsgType_Critical = 0x0008,
|
||||
MsgType_Fatal = 0x0010,
|
||||
};
|
||||
|
||||
#ifdef quc
|
||||
class Q_DECL_EXPORT SaveLog : public QObject
|
||||
#else
|
||||
|
@ -34,21 +48,34 @@ public:
|
|||
private:
|
||||
static QScopedPointer<SaveLog> self;
|
||||
|
||||
//文件对象
|
||||
QFile *file;
|
||||
//是否在运行
|
||||
bool isRun;
|
||||
//文件最大行数 0表示不启用
|
||||
int maxRow, currentRow;
|
||||
//文件最大大小 0表示不启用 单位kb
|
||||
int maxSize;
|
||||
//是否重定向到网络
|
||||
bool toNet;
|
||||
//是否输出日志上下文
|
||||
bool useContext;
|
||||
|
||||
//文件对象
|
||||
QFile *file;
|
||||
//日志文件路径
|
||||
QString path;
|
||||
//日志文件名称
|
||||
QString name;
|
||||
//日志文件完整名称
|
||||
QString fileName;
|
||||
//消息类型
|
||||
MsgType msgType;
|
||||
|
||||
private:
|
||||
void openFile(const QString &fileName);
|
||||
|
||||
public:
|
||||
bool getUseContext();
|
||||
MsgType getMsgType();
|
||||
|
||||
Q_SIGNALS:
|
||||
//发送内容信号
|
||||
|
@ -59,20 +86,38 @@ public Q_SLOTS:
|
|||
void start();
|
||||
//暂停日志服务
|
||||
void stop();
|
||||
|
||||
//清空状态
|
||||
void clear();
|
||||
//保存日志
|
||||
void save(const QString &content);
|
||||
|
||||
//设置日志文件最大行数
|
||||
void setMaxRow(int maxRow);
|
||||
//设置日志文件最大大小 单位kb
|
||||
void setMaxSize(int maxSize);
|
||||
|
||||
//设置监听端口
|
||||
void setListenPort(int listenPort);
|
||||
//设置是否重定向到网络
|
||||
void setToNet(bool toNet);
|
||||
//设置是否输出日志上下文
|
||||
void setUseContext(bool useContext);
|
||||
|
||||
//设置日志文件存放路径
|
||||
void setPath(const QString &path);
|
||||
//设置日志文件名称
|
||||
void setName(const QString &name);
|
||||
//设置消息类型
|
||||
void setMsgType(const MsgType &msgType);
|
||||
};
|
||||
|
||||
#ifdef quc
|
||||
class Q_DECL_EXPORT SendLog : public QObject
|
||||
#else
|
||||
class SendLog : public QObject
|
||||
#endif
|
||||
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
@ -83,6 +128,8 @@ public:
|
|||
private:
|
||||
static QScopedPointer<SendLog> self;
|
||||
|
||||
//监听端口
|
||||
int listenPort;
|
||||
//网络通信对象
|
||||
QTcpSocket *socket;
|
||||
//网络监听服务器
|
||||
|
@ -93,6 +140,13 @@ private slots:
|
|||
void newConnection();
|
||||
|
||||
public Q_SLOTS:
|
||||
//设置监听端口
|
||||
void setListenPort(int listenPort);
|
||||
|
||||
//启动和停止服务
|
||||
void start();
|
||||
void stop();
|
||||
|
||||
//发送日志
|
||||
void send(const QString &content);
|
||||
};
|
||||
|
|
|
@ -4,10 +4,13 @@
|
|||
#include "ui_frmsaveruntime.h"
|
||||
#include "qfile.h"
|
||||
#include "saveruntime.h"
|
||||
#include "qdebug.h"
|
||||
|
||||
frmSaveRunTime::frmSaveRunTime(QWidget *parent) : QWidget(parent), ui(new Ui::frmSaveRunTime)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->setupUi(this);
|
||||
//设置文件存储目录
|
||||
SaveRunTime::Instance()->setPath(qApp->applicationDirPath() + "/log");
|
||||
}
|
||||
|
||||
frmSaveRunTime::~frmSaveRunTime()
|
||||
|
@ -40,7 +43,12 @@ void frmSaveRunTime::on_btnUpdate_clicked()
|
|||
|
||||
void frmSaveRunTime::on_btnOpen_clicked()
|
||||
{
|
||||
QString fileName = QString("%1/examples_runtime_%2.txt").arg(qApp->applicationDirPath()).arg(QDate::currentDate().year());
|
||||
QString path = qApp->applicationDirPath();
|
||||
QString name = qApp->applicationFilePath();
|
||||
QStringList list = name.split("/");
|
||||
name = list.at(list.count() - 1).split(".").at(0);
|
||||
|
||||
QString fileName = QString("%1/log/%2_runtime_%3.txt").arg(path).arg(name).arg(QDate::currentDate().year());
|
||||
QFile file(fileName);
|
||||
if (file.open(QFile::ReadOnly | QFile::Text)) {
|
||||
ui->txtMain->setText(file.readAll());
|
||||
|
|
|
@ -13,72 +13,92 @@
|
|||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QTextEdit" name="txtMain"/>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox">
|
||||
<property name="text">
|
||||
<string>启动服务</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnAppend">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>130</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>插入一条记录</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnUpdate">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>130</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>更新一条记录</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnOpen">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>130</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>打开记录文件</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Box</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox">
|
||||
<property name="text">
|
||||
<string>启动运行时间记录</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnAppend">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>130</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>插入一条记录</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnUpdate">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>130</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>更新一条记录</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnOpen">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>130</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>打开记录文件</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
|
|
@ -24,7 +24,7 @@ int main(int argc, char *argv[])
|
|||
#endif
|
||||
|
||||
frmSaveRunTime w;
|
||||
w.setWindowTitle("保存运行时间");
|
||||
w.setWindowTitle("运行时间记录示例 V2022 (QQ: 517216493 WX: feiyangqingyun)");
|
||||
w.show();
|
||||
|
||||
return a.exec();
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
#include "saveruntime.h"
|
||||
#pragma execution_character_set("utf-8")
|
||||
|
||||
#include "saveruntime.h"
|
||||
#include "qmutex.h"
|
||||
#include "qdir.h"
|
||||
#include "qfile.h"
|
||||
|
@ -7,12 +9,6 @@
|
|||
#include "qtextstream.h"
|
||||
#include "qstringlist.h"
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#define NEWLINE "\r\n"
|
||||
#else
|
||||
#define NEWLINE "\n"
|
||||
#endif
|
||||
|
||||
QScopedPointer<SaveRunTime> SaveRunTime::self;
|
||||
SaveRunTime *SaveRunTime::Instance()
|
||||
{
|
||||
|
@ -72,6 +68,10 @@ void SaveRunTime::getDiffValue(const QDateTime &startTime, const QDateTime &endT
|
|||
|
||||
void SaveRunTime::start()
|
||||
{
|
||||
if (timerSave->isActive()) {
|
||||
return;
|
||||
}
|
||||
|
||||
//开始时间变量必须在这,在部分嵌入式系统上开机后的时间不准确比如是1970,而后会变成1999或者其他时间
|
||||
//会在getDiffValue函数执行很久很久
|
||||
startTime = QDateTime::currentDateTime();
|
||||
|
@ -84,6 +84,10 @@ void SaveRunTime::start()
|
|||
|
||||
void SaveRunTime::stop()
|
||||
{
|
||||
if (!timerSave->isActive()) {
|
||||
return;
|
||||
}
|
||||
|
||||
timerSave->stop();
|
||||
}
|
||||
|
||||
|
@ -116,7 +120,7 @@ void SaveRunTime::initLog()
|
|||
QString line = strID + strStartTime + strEndTime + strRunTime;
|
||||
|
||||
QTextStream stream(&file);
|
||||
stream << line << NEWLINE;
|
||||
stream << line << "\n";
|
||||
file.close();
|
||||
lastID = 0;
|
||||
}
|
||||
|
@ -154,7 +158,7 @@ void SaveRunTime::appendLog()
|
|||
QString line = strID + strStartTime + strEndTime + strRunTime;
|
||||
|
||||
QTextStream stream(&file);
|
||||
stream << line << NEWLINE;
|
||||
stream << line << "\n";
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
|
@ -205,7 +209,7 @@ void SaveRunTime::saveLog()
|
|||
content[content.count() - 1] = lastLine;
|
||||
|
||||
QTextStream stream(&file);
|
||||
stream << content.join("") << NEWLINE;
|
||||
stream << content.join("") << "\n";
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -152,9 +152,9 @@ void frmMain::initStyle()
|
|||
{
|
||||
//加载样式表
|
||||
QString qss;
|
||||
QFile file(":/qss/psblack.css");
|
||||
//QFile file(":/qss/psblack.css");
|
||||
//QFile file(":/qss/flatwhite.css");
|
||||
//QFile file(":/qss/lightblue.css");
|
||||
QFile file(":/qss/lightblue.css");
|
||||
if (file.open(QFile::ReadOnly)) {
|
||||
#if 1
|
||||
//用QTextStream读取样式文件不用区分文件编码 带bom也行
|
||||
|
|
|
@ -396,6 +396,9 @@
|
|||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QLCDNumber" name="lcdNumber">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="digitCount">
|
||||
<number>5</number>
|
||||
</property>
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
//设置不应用操作系统设置比如字体
|
||||
QApplication::setDesktopSettingsAware(false);
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5,14,0))
|
||||
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::Floor);
|
||||
#endif
|
||||
|
|
|
@ -643,15 +643,23 @@ QTabWidget::pane:bottom{bottom:-1px;}
|
|||
QTabWidget::pane:left{right:-1px;}
|
||||
QTabWidget::pane:right{left:-1px;}
|
||||
|
||||
QDialog {
|
||||
QDialog,QDial{
|
||||
background-color:#FFFFFF;
|
||||
color:#57595B;
|
||||
}
|
||||
|
||||
QDialogButtonBox > QPushButton {
|
||||
QDialogButtonBox>QPushButton{
|
||||
min-width:50px;
|
||||
}
|
||||
|
||||
QListView[noboder="true"],QTreeView[noboder="true"],QTabWidget[noboder="true"]::pane{
|
||||
border-width:0px;
|
||||
}
|
||||
|
||||
QToolBar>*,QStatusBar>*{
|
||||
margin:2px;
|
||||
}
|
||||
|
||||
*:disabled,QMenu::item:disabled{
|
||||
background:#FFFFFF;
|
||||
border-color:#E4E4E4;
|
||||
|
|
Before Width: | Height: | Size: 329 B After Width: | Height: | Size: 336 B |
Before Width: | Height: | Size: 374 B After Width: | Height: | Size: 370 B |
Before Width: | Height: | Size: 341 B After Width: | Height: | Size: 358 B |
Before Width: | Height: | Size: 333 B After Width: | Height: | Size: 332 B |
Before Width: | Height: | Size: 333 B After Width: | Height: | Size: 337 B |
Before Width: | Height: | Size: 369 B After Width: | Height: | Size: 376 B |
Before Width: | Height: | Size: 355 B After Width: | Height: | Size: 360 B |
Before Width: | Height: | Size: 339 B After Width: | Height: | Size: 361 B |
Before Width: | Height: | Size: 257 B After Width: | Height: | Size: 263 B |
Before Width: | Height: | Size: 443 B After Width: | Height: | Size: 444 B |
Before Width: | Height: | Size: 662 B After Width: | Height: | Size: 655 B |
Before Width: | Height: | Size: 733 B After Width: | Height: | Size: 740 B |
Before Width: | Height: | Size: 592 B After Width: | Height: | Size: 616 B |
Before Width: | Height: | Size: 590 B After Width: | Height: | Size: 639 B |
Before Width: | Height: | Size: 212 B After Width: | Height: | Size: 341 B |
Before Width: | Height: | Size: 285 B After Width: | Height: | Size: 331 B |
Before Width: | Height: | Size: 171 B After Width: | Height: | Size: 612 B |
Before Width: | Height: | Size: 178 B After Width: | Height: | Size: 646 B |
Before Width: | Height: | Size: 544 B After Width: | Height: | Size: 542 B |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
@ -643,15 +643,23 @@ QTabWidget::pane:bottom{bottom:-1px;}
|
|||
QTabWidget::pane:left{right:-1px;}
|
||||
QTabWidget::pane:right{left:-1px;}
|
||||
|
||||
QDialog {
|
||||
QDialog,QDial{
|
||||
background-color:#EAF7FF;
|
||||
color:#386487;
|
||||
}
|
||||
|
||||
QDialogButtonBox > QPushButton {
|
||||
QDialogButtonBox>QPushButton{
|
||||
min-width:50px;
|
||||
}
|
||||
|
||||
QListView[noboder="true"],QTreeView[noboder="true"],QTabWidget[noboder="true"]::pane{
|
||||
border-width:0px;
|
||||
}
|
||||
|
||||
QToolBar>*,QStatusBar>*{
|
||||
margin:2px;
|
||||
}
|
||||
|
||||
*:disabled,QMenu::item:disabled{
|
||||
background:#EAF7FF;
|
||||
border-color:#DEF0FE;
|
||||
|
|
Before Width: | Height: | Size: 343 B After Width: | Height: | Size: 348 B |
Before Width: | Height: | Size: 378 B After Width: | Height: | Size: 383 B |
Before Width: | Height: | Size: 357 B After Width: | Height: | Size: 364 B |
Before Width: | Height: | Size: 360 B After Width: | Height: | Size: 367 B |
Before Width: | Height: | Size: 349 B After Width: | Height: | Size: 348 B |
Before Width: | Height: | Size: 383 B After Width: | Height: | Size: 383 B |
Before Width: | Height: | Size: 362 B After Width: | Height: | Size: 364 B |
Before Width: | Height: | Size: 360 B After Width: | Height: | Size: 361 B |
Before Width: | Height: | Size: 264 B After Width: | Height: | Size: 269 B |
Before Width: | Height: | Size: 457 B After Width: | Height: | Size: 462 B |
Before Width: | Height: | Size: 674 B After Width: | Height: | Size: 670 B |
Before Width: | Height: | Size: 749 B After Width: | Height: | Size: 758 B |
Before Width: | Height: | Size: 574 B After Width: | Height: | Size: 636 B |
Before Width: | Height: | Size: 623 B After Width: | Height: | Size: 664 B |
Before Width: | Height: | Size: 237 B After Width: | Height: | Size: 351 B |
Before Width: | Height: | Size: 278 B After Width: | Height: | Size: 344 B |
Before Width: | Height: | Size: 180 B After Width: | Height: | Size: 613 B |
Before Width: | Height: | Size: 182 B After Width: | Height: | Size: 648 B |
Before Width: | Height: | Size: 551 B After Width: | Height: | Size: 554 B |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.4 KiB |
|
@ -643,15 +643,23 @@ QTabWidget::pane:bottom{bottom:-1px;}
|
|||
QTabWidget::pane:left{right:-1px;}
|
||||
QTabWidget::pane:right{left:-1px;}
|
||||
|
||||
QDialog {
|
||||
QDialog,QDial{
|
||||
background-color:#444444;
|
||||
color:#DCDCDC;
|
||||
}
|
||||
|
||||
QDialogButtonBox > QPushButton {
|
||||
QDialogButtonBox>QPushButton{
|
||||
min-width:50px;
|
||||
}
|
||||
|
||||
QListView[noboder="true"],QTreeView[noboder="true"],QTabWidget[noboder="true"]::pane{
|
||||
border-width:0px;
|
||||
}
|
||||
|
||||
QToolBar>*,QStatusBar>*{
|
||||
margin:2px;
|
||||
}
|
||||
|
||||
*:disabled,QMenu::item:disabled{
|
||||
background:#444444;
|
||||
border-color:#484848;
|
||||
|
|
Before Width: | Height: | Size: 332 B After Width: | Height: | Size: 335 B |
Before Width: | Height: | Size: 377 B After Width: | Height: | Size: 377 B |
Before Width: | Height: | Size: 348 B After Width: | Height: | Size: 352 B |
Before Width: | Height: | Size: 345 B After Width: | Height: | Size: 348 B |
Before Width: | Height: | Size: 335 B After Width: | Height: | Size: 335 B |
Before Width: | Height: | Size: 372 B After Width: | Height: | Size: 370 B |
Before Width: | Height: | Size: 348 B After Width: | Height: | Size: 354 B |
Before Width: | Height: | Size: 349 B After Width: | Height: | Size: 349 B |
Before Width: | Height: | Size: 255 B After Width: | Height: | Size: 257 B |
Before Width: | Height: | Size: 434 B After Width: | Height: | Size: 445 B |
Before Width: | Height: | Size: 612 B After Width: | Height: | Size: 623 B |
Before Width: | Height: | Size: 670 B After Width: | Height: | Size: 667 B |
Before Width: | Height: | Size: 587 B After Width: | Height: | Size: 593 B |
Before Width: | Height: | Size: 614 B After Width: | Height: | Size: 656 B |
Before Width: | Height: | Size: 211 B After Width: | Height: | Size: 326 B |
Before Width: | Height: | Size: 265 B After Width: | Height: | Size: 333 B |
Before Width: | Height: | Size: 173 B After Width: | Height: | Size: 572 B |
Before Width: | Height: | Size: 179 B After Width: | Height: | Size: 624 B |
Before Width: | Height: | Size: 508 B After Width: | Height: | Size: 501 B |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |