0315更新

main
parent 2f8f8d9a0f
commit 42d367c786

@ -57,7 +57,13 @@ QPushButton#deviceAddButton{
font-size: 20px; 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; padding-top: 7px;
} }
QPushButton#initAddDeviceButton, QPushButton#initAreaAddButton{ QPushButton#initAddDeviceButton, QPushButton#initAreaAddButton{
@ -80,6 +88,8 @@ QPushButton#initAddDeviceButton, QPushButton#initAreaAddButton{
background-color: rgba(255, 255, 255, 0); background-color: rgba(255, 255, 255, 0);
border-radius: 5px;
} }
QPushButton#initAddDeviceButton:hover, QPushButton#initAreaAddButton:hover, QPushButton#deviceAddButton:hover, QPushButton#addareabutton:hover{ 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; border-radius: 3px;
margin-bottom: -4px margin-bottom: -4px
} }
@ -151,6 +163,7 @@ QLineEdit#byteLineEdit{
font-size: 20px; font-size: 20px;
} }
@ -159,6 +172,8 @@ QLineEdit#areaLineEdit {
font-size: 28px; font-size: 28px;
} }
@ -168,12 +183,21 @@ QLineEdit#wirteDIDOareaLineEdit {
font-size: 16px; font-size: 16px;
} }
QLineEdit#areaLineEdit { QLineEdit#areaLineEdit {
font-size: 28px; 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; subcontrol-origin: padding;
border: none;
} }
QTabBar::close-button:hover { QTabBar::close-button:hover {
background-color: #cccccc; 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,10 +80,9 @@ QDockWidget{
font-family: ".SFNSDisplay-Regular"; font-family: ".SFNSDisplay-Regular";
/* border: 1px solid black;*/
border: none; border: none;
} }
QDockWidget::title{ QDockWidget::title{
@ -86,22 +136,23 @@ QWidget#MainWindow{
background-color: white; background-color: white;
border: none;
} }
QWidget#deviceWidget{ QWidget#deviceWidget{
background-color: white; background-color: white;
border: 1px solid gray;
} }
QTabWidget#areaTabWidget{
QTabWidget{
border: none; border: none;
background-color: white; background-color: white;
} }

@ -16,13 +16,14 @@ from UI.DeviceDialogWidget import DeviceDialog
from PyQt5.QtWidgets import QApplication, QStyleOptionTab, QTabBar, QWidget from PyQt5.QtWidgets import QApplication, QStyleOptionTab, QTabBar, QWidget
from PyQt5.QtGui import QPainter, QPen, QColor, QPainterPath, QPolygonF, QFontMetrics, QTextOption, QFont 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): class NewChromeTabStyle(QProxyStyle):
def drawControl(self, element, option, painter, widget): def drawControl(self, element, option, painter, widget):
# painter.save() # painter.save()
# painter.setPen(Qt.red); # painter.setPen(Qt.red);
# painter.restore(); # painter.restore();
margin = 4
if element == QStyle.CE_TabBarTabLabel: if element == QStyle.CE_TabBarTabLabel:
tab = option tab = option
# print(type(tab)) # print(type(tab))
@ -52,18 +53,19 @@ class NewChromeTabStyle(QProxyStyle):
painter.setRenderHint(QPainter.Antialiasing); painter.setRenderHint(QPainter.Antialiasing);
shapeRect = QRectF(tab.rect); shapeRect = QRectF(tab.rect);
shapeRect.setY(shapeRect.y() + margin)
arcLen = shapeRect.height() / 2; arcLen = shapeRect.height() / 2;
if (tab.state & QStyle.State_Selected): if (tab.state & QStyle.State_Selected):
painter.save(); painter.save();
pen = QPen(Qt.red); pen = QPen(Qt.white);
pen.setWidthF(0.5); pen.setWidthF(0.5);
painter.setPen(pen); painter.setPen(pen);
painter.restore(); painter.restore();
painter.save(); painter.save();
shapeRect.setX(shapeRect.x() - arcLen); shapeRect.setX(shapeRect.x() - arcLen);
shapeRect.setWidth(shapeRect.width() + arcLen *3/ 4); shapeRect.setWidth(shapeRect.width() + arcLen *3/ 5);
path = QPainterPath(); path = QPainterPath();
@ -116,75 +118,38 @@ class NewChromeTabStyle(QProxyStyle):
arcRect1.y() + arcRect1.height())); arcRect1.y() + arcRect1.height()));
painter.setPen(Qt.NoPen); painter.setPen(Qt.NoPen);
painter.setBrush(Qt.blue); painter.setBrush(Qt.white);
polygon = path.toFillPolygon(); polygon = path.toFillPolygon();
painter.drawPolygon(polygon); 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(); painter.restore();
elif (tab.state & QStyle.State_MouseOver): elif (tab.state & QStyle.State_MouseOver):
painter.save();
pen = QPen(Qt.black);
pen.setWidthF(0.5);
painter.setPen(pen);
painter.restore();
painter.save(); 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.setX(shapeRect.x());
shapeRect.setWidth(shapeRect.width() + arcLen *3/ 4); shapeRect.setWidth(shapeRect.width() - 15);
shapeRect.setHeight(shapeRect.height() - 4)
path = QPainterPath() painter.setPen(QColor('#A8C7FA'))
arcRect1 = QRectF(shapeRect.x(),
shapeRect.y() + shapeRect.height() / 3,
arcLen,
shapeRect.height() * 2 / 3);
path.moveTo(QPointF(arcRect1.x(),
arcRect1.y() + arcRect1.height()));
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); # 设置填充颜色(如果需要)
painter.setBrush(QColor('#A8C7FA'))
path.lineTo(QPointF(arcRect1.x(), # 圆角矩形的参数左上角坐标x, y宽度w高度h以及圆角半径r
arcRect1.y() + arcRect1.height())); radius = 5
painter.drawRoundedRect(shapeRect, radius, radius)
painter.setPen(Qt.NoPen);
painter.setBrush(QColor("yellow"));
polygon = path.toFillPolygon();
painter.drawPolygon(polygon);
painter.restore(); painter.restore();
@ -194,12 +159,24 @@ class NewChromeTabStyle(QProxyStyle):
shapeRect.setX(shapeRect.x() - arcLen); shapeRect.setX(shapeRect.x() - arcLen);
shapeRect.setWidth(shapeRect.width() + arcLen / 2); shapeRect.setWidth(shapeRect.width() + arcLen / 2);
pen = QPen(Qt.white); pen = QPen(QColor('#D3E3FD'));
pen.setWidthF(0.5); pen.setWidthF(0.1);
painter.setPen(pen); 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: else:
super(NewChromeTabStyle, self).drawControl(element, option, painter, widget); super(NewChromeTabStyle, self).drawControl(element, option, painter, widget);
@ -213,8 +190,13 @@ class DeviceTabBar(QTabBar):
def tabSizeHint(self, index): def tabSizeHint(self, index):
newSize = QTabBar().tabSizeHint(index) newSize = QTabBar().tabSizeHint(index)
width = len(self.tabText(index)) * 20 + 100 width = len(self.tabText(index)) * 20 + 100
newSize.setWidth(width) newSize.setWidth(width)
newSize.setHeight(40) newSize.setHeight(35)
# tabRect = QTabBar().tabRect(index)
# padding = 50
# tabRect.adjust(padding, padding, padding, padding)
return newSize return newSize
@ -275,12 +257,11 @@ class DeviceTab(QTabWidget):
self.titleName, pvUpperLimit, pvLowerLimit, pvUnit = dialog.getParameters() self.titleName, pvUpperLimit, pvLowerLimit, pvUnit = dialog.getParameters()
self.deviceName = self.titleName + self.dataTypeAndModel self.deviceName = self.titleName + self.dataTypeAndModel
DeviceDB().addDevice(deviceName = self.deviceName, proType = self.proType , masterSlaveModel = self.masterSlaveModel, pvUpperLimit=pvUpperLimit, pvLowerLimit=pvLowerLimit, pvUnit=pvUnit) DeviceDB().addDevice(deviceName = self.deviceName, proType = self.proType , masterSlaveModel = self.masterSlaveModel, pvUpperLimit=pvUpperLimit, pvLowerLimit=pvLowerLimit, pvUnit=pvUnit)
areaTabWidget = AreaTabWidget(self)
if init: if init:
self.removeTab(0) self.removeTab(0)
tabIndex = self.count() tabIndex = self.count()
self.tabBar().setHidden(False) self.tabBar().setHidden(False)
self.addTab(areaTabWidget,str(self.titleName)) self.addTab(AreaTabWidget(self),str(self.titleName))
self.setCurrentIndex(tabIndex) self.setCurrentIndex(tabIndex)
self.devicesManange.addDevice(proType=self.proType, masterSlaveModel = self.masterSlaveModel, deviceName = self.deviceName) self.devicesManange.addDevice(proType=self.proType, masterSlaveModel = self.masterSlaveModel, deviceName = self.deviceName)
else: else:
@ -288,9 +269,8 @@ class DeviceTab(QTabWidget):
else: else:
self.deviceName = deviceName self.deviceName = deviceName
self.titleName = self.deviceName[:-4] self.titleName = self.deviceName[:-4]
areaTabWidget = AreaTabWidget(self)
self.tabBar().setHidden(False) 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): def areaLayout(self):
areaLayout = QVBoxLayout() areaLayout = QVBoxLayout()
areaLayout.setContentsMargins(0, 0, 0, 0)
if self.dataType in ['AI','AO']: if self.dataType in ['AI','AO']:
hLayout = QHBoxLayout() hLayout = QHBoxLayout()
hLayout.addWidget(QSplitter()) hLayout.addWidget(QSplitter())
@ -61,6 +62,7 @@ class RightAreaWidgets(QWidget):
number = number number = number
forceLayout = QHBoxLayout() forceLayout = QHBoxLayout()
forceLayout.setContentsMargins(0, 0, 0, 0)
areaMessLabel = QLabel(str(self.dataType) + "{:<{}}".format(str(number), 2) + ": " + '字节长度: ' + str(self.byteLineEdit) + ' 当前值:' ) areaMessLabel = QLabel(str(self.dataType) + "{:<{}}".format(str(number), 2) + ": " + '字节长度: ' + str(self.byteLineEdit) + ' 当前值:' )
areaMessLabel.setObjectName('areaMessLabel') areaMessLabel.setObjectName('areaMessLabel')
areaValueLabel = QLabel('0') areaValueLabel = QLabel('0')

@ -8,7 +8,7 @@ import sys
if __name__ == '__main__': if __name__ == '__main__':
app = QApplication(sys.argv) 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')) app.setStyleSheet(CommonHelper.readQss('static/main.qss') + CommonHelper.readQss('static/Area.qss'))
Client.initDB() Client.initDB()

Loading…
Cancel
Save