0315更新

main
parent 2f8f8d9a0f
commit 42d367c786

@ -57,7 +57,13 @@ QPushButton#deviceAddButton{
font-size: 20px;
padding-bottom: 8px;
padding-bottom: 5px;
border-top: none;
border-right: none;
border-left: none;
}
@ -70,6 +76,8 @@ QPushButton#addareabutton{
padding-top: 7px;
}
QPushButton#initAddDeviceButton, QPushButton#initAreaAddButton{
@ -80,6 +88,8 @@ QPushButton#initAddDeviceButton, QPushButton#initAreaAddButton{
background-color: rgba(255, 255, 255, 0);
border-radius: 5px;
}
QPushButton#initAddDeviceButton:hover, QPushButton#initAreaAddButton:hover, QPushButton#deviceAddButton:hover, QPushButton#addareabutton:hover{
@ -91,6 +101,8 @@ QPushButton#initAddDeviceButton:hover, QPushButton#initAreaAddButton:hover, QPus
border-radius: 3px;
margin-bottom: -4px
}
@ -151,6 +163,7 @@ QLineEdit#byteLineEdit{
font-size: 20px;
}
@ -159,6 +172,8 @@ QLineEdit#areaLineEdit {
font-size: 28px;
}
@ -168,12 +183,21 @@ QLineEdit#wirteDIDOareaLineEdit {
font-size: 16px;
}
QLineEdit#areaLineEdit {
font-size: 28px;
border-top: none;
border-left: none;
border-right: none;
border-bottom: 1px solid gary;
}

@ -11,11 +11,62 @@ QTabBar::close-button {
subcontrol-origin: padding;
border: none;
}
QTabBar::close-button:hover {
background-color: #cccccc;
}
QTabBar{
background-color: #D3E3FD;
}
QTabBar#areaTabBar::tab{
background: #D3E3FD;
width: 100px;
height: 35px;
font: 20px;
margin-left: 2px;
font-family: ".SFNSDisplay-Regular";
}
QTabBar#areaTabBar::tab:hover {
background-color: #A8C7FA;
font: bold;
border-radius: 5px;
}
QTabBar#areaTabBar::tab:selected {
background-color: #A8C7FA;
font: bold;
border-radius: 5px;
}
@ -29,9 +80,8 @@ QDockWidget{
font-family: ".SFNSDisplay-Regular";
/* border: 1px solid black;*/
border: none;
}
@ -86,22 +136,23 @@ QWidget#MainWindow{
background-color: white;
border: none;
}
QWidget#deviceWidget{
background-color: white;
border: 1px solid gray;
}
QTabWidget{
QTabWidget#areaTabWidget{
border: none;
background-color: white;
}
}

@ -16,13 +16,14 @@ from UI.DeviceDialogWidget import DeviceDialog
from PyQt5.QtWidgets import QApplication, QStyleOptionTab, QTabBar, QWidget
from PyQt5.QtGui import QPainter, QPen, QColor, QPainterPath, QPolygonF, QFontMetrics, QTextOption, QFont
from PyQt5.QtCore import Qt, QRectF, QPointF
from PyQt5.QtCore import Qt, QRectF, QPointF, QSizeF
class NewChromeTabStyle(QProxyStyle):
def drawControl(self, element, option, painter, widget):
# painter.save()
# painter.setPen(Qt.red);
# painter.restore();
margin = 4
if element == QStyle.CE_TabBarTabLabel:
tab = option
# print(type(tab))
@ -52,18 +53,19 @@ class NewChromeTabStyle(QProxyStyle):
painter.setRenderHint(QPainter.Antialiasing);
shapeRect = QRectF(tab.rect);
shapeRect.setY(shapeRect.y() + margin)
arcLen = shapeRect.height() / 2;
if (tab.state & QStyle.State_Selected):
painter.save();
pen = QPen(Qt.red);
pen = QPen(Qt.white);
pen.setWidthF(0.5);
painter.setPen(pen);
painter.restore();
painter.save();
shapeRect.setX(shapeRect.x() - arcLen);
shapeRect.setWidth(shapeRect.width() + arcLen *3/ 4);
shapeRect.setWidth(shapeRect.width() + arcLen *3/ 5);
path = QPainterPath();
@ -116,75 +118,38 @@ class NewChromeTabStyle(QProxyStyle):
arcRect1.y() + arcRect1.height()));
painter.setPen(Qt.NoPen);
painter.setBrush(Qt.blue);
painter.setBrush(Qt.white);
polygon = path.toFillPolygon();
painter.drawPolygon(polygon);
painter.setBrush(QColor('#D3E3FD'));
magPoint = shapeRect.topLeft()
magPoint.setY(magPoint.y() - margin)
painter.drawRect(QRectF(magPoint, QSizeF(shapeRect.width(), margin)))
painter.restore();
elif (tab.state & QStyle.State_MouseOver):
painter.save();
pen = QPen(Qt.black);
pen.setWidthF(0.5);
painter.setPen(pen);
painter.restore();
painter.save();
# 设置画笔颜色和宽度
painter.setBrush(QColor('#D3E3FD'));
painter.setPen(Qt.NoPen)
magPoint = shapeRect.topLeft()
magPoint.setY(magPoint.y() - margin)
painter.drawRect(QRectF(magPoint, QSizeF(shapeRect.width(), shapeRect.height() + 4)))
shapeRect.setX(shapeRect.x() - arcLen);
shapeRect.setWidth(shapeRect.width() + arcLen *3/ 4);
path = QPainterPath()
shapeRect.setX(shapeRect.x());
shapeRect.setWidth(shapeRect.width() - 15);
shapeRect.setHeight(shapeRect.height() - 4)
painter.setPen(QColor('#A8C7FA'))
arcRect1 = QRectF(shapeRect.x(),
shapeRect.y() + shapeRect.height() / 3,
arcLen,
shapeRect.height() * 2 / 3);
# 设置填充颜色(如果需要)
painter.setBrush(QColor('#A8C7FA'))
path.moveTo(QPointF(arcRect1.x(),
arcRect1.y() + arcRect1.height()));
# 圆角矩形的参数左上角坐标x, y宽度w高度h以及圆角半径r
radius = 5
painter.drawRoundedRect(shapeRect, radius, radius)
path.lineTo(QPointF(arcRect1.x() + arcRect1.width() / 2,
arcRect1.y() + arcRect1.height()));
path.arcTo(arcRect1, 270.0, 90.0);
path.lineTo(QPointF(arcRect1.x() + arcRect1.width(),
arcRect1.y()));
arcRect2 = QRectF(shapeRect.x() + arcRect1.width(),
shapeRect.y(),
arcLen,
shapeRect.height() * 2 / 3);
path.arcTo(arcRect2, 180.0, -90.0);
path.lineTo(QPointF(arcRect2.x() + shapeRect.width() - 2 * (arcRect2.x() + arcRect2.width()) + arcRect2.width() / 2,
arcRect2.y()));
arcRect3 = QRectF(shapeRect.x() + shapeRect.width() - 2 * arcRect1.width(),
shapeRect.y(),
arcRect1.width(),
shapeRect.height() * 2 / 3);
path.arcTo(arcRect3, 90.0, -90.0);
path.lineTo(QPointF(arcRect3.x() + arcRect3.width(),
arcRect3.y() + arcRect3.height()));
arcRect4 = QRectF(arcRect3.x() + arcRect3.width(),
arcRect3.y() + arcRect3.height() / 2,
arcRect1.width(),
shapeRect.height() * 2 / 3);
path.arcTo(arcRect4, 180.0, 90.0);
path.lineTo(QPointF(arcRect1.x(),
arcRect1.y() + arcRect1.height()));
painter.setPen(Qt.NoPen);
painter.setBrush(QColor("yellow"));
polygon = path.toFillPolygon();
painter.drawPolygon(polygon);
painter.restore();
@ -194,12 +159,24 @@ class NewChromeTabStyle(QProxyStyle):
shapeRect.setX(shapeRect.x() - arcLen);
shapeRect.setWidth(shapeRect.width() + arcLen / 2);
pen = QPen(Qt.white);
pen.setWidthF(0.5);
painter.setPen(pen);
pen = QPen(QColor('#D3E3FD'));
pen.setWidthF(0.1);
painter.setPen(pen)
painter.drawLine(shapeRect.bottomLeft(),shapeRect.bottomRight());
# painter.drawLine(QPointF(shapeRect.x() + arcLen*2/3 -1, shapeRect.height() / 3),
# QPointF(shapeRect.x() + arcLen*2/3 -1, shapeRect.height() * 2 / 3));
painter.setBrush(QColor('#D3E3FD'));
painter.drawRect(shapeRect)
magPoint = shapeRect.topLeft()
magPoint.setY(magPoint.y() - margin)
painter.drawRect(QRectF(magPoint, QSizeF(shapeRect.width(), margin)))
painter.restore();
# painter.save();
# painter.restore();
painter.restore();
else:
super(NewChromeTabStyle, self).drawControl(element, option, painter, widget);
@ -213,8 +190,13 @@ class DeviceTabBar(QTabBar):
def tabSizeHint(self, index):
newSize = QTabBar().tabSizeHint(index)
width = len(self.tabText(index)) * 20 + 100
newSize.setWidth(width)
newSize.setHeight(40)
newSize.setHeight(35)
# tabRect = QTabBar().tabRect(index)
# padding = 50
# tabRect.adjust(padding, padding, padding, padding)
return newSize
@ -275,12 +257,11 @@ class DeviceTab(QTabWidget):
self.titleName, pvUpperLimit, pvLowerLimit, pvUnit = dialog.getParameters()
self.deviceName = self.titleName + self.dataTypeAndModel
DeviceDB().addDevice(deviceName = self.deviceName, proType = self.proType , masterSlaveModel = self.masterSlaveModel, pvUpperLimit=pvUpperLimit, pvLowerLimit=pvLowerLimit, pvUnit=pvUnit)
areaTabWidget = AreaTabWidget(self)
if init:
self.removeTab(0)
tabIndex = self.count()
self.tabBar().setHidden(False)
self.addTab(areaTabWidget,str(self.titleName))
self.addTab(AreaTabWidget(self),str(self.titleName))
self.setCurrentIndex(tabIndex)
self.devicesManange.addDevice(proType=self.proType, masterSlaveModel = self.masterSlaveModel, deviceName = self.deviceName)
else:
@ -288,9 +269,8 @@ class DeviceTab(QTabWidget):
else:
self.deviceName = deviceName
self.titleName = self.deviceName[:-4]
areaTabWidget = AreaTabWidget(self)
self.tabBar().setHidden(False)
self.addTab(areaTabWidget,str(self.titleName))
self.addTab(AreaTabWidget(self),str(self.titleName))

@ -34,6 +34,7 @@ class RightAreaWidgets(QWidget):
def areaLayout(self):
areaLayout = QVBoxLayout()
areaLayout.setContentsMargins(0, 0, 0, 0)
if self.dataType in ['AI','AO']:
hLayout = QHBoxLayout()
hLayout.addWidget(QSplitter())
@ -61,6 +62,7 @@ class RightAreaWidgets(QWidget):
number = number
forceLayout = QHBoxLayout()
forceLayout.setContentsMargins(0, 0, 0, 0)
areaMessLabel = QLabel(str(self.dataType) + "{:<{}}".format(str(number), 2) + ": " + '字节长度: ' + str(self.byteLineEdit) + ' 当前值:' )
areaMessLabel.setObjectName('areaMessLabel')
areaValueLabel = QLabel('0')

@ -8,7 +8,7 @@ import sys
if __name__ == '__main__':
app = QApplication(sys.argv)
app.setStyle(QStyleFactory.create('fusion'))
app.setStyle(QStyleFactory.create('windowsvisio'))
app.setStyleSheet(CommonHelper.readQss('static/main.qss') + CommonHelper.readQss('static/Area.qss'))
Client.initDB()

Loading…
Cancel
Save