1 #ifndef SETTINGS_H 2 #define SETTINGS_H 3 4 #include <QDialog> 5 #include <QPainter> 6 #include <QProxyStyle> 7 #include <QStyleOptionTab> 8 #include <QDate> 9 #include "about.h" 10 #include "preview.h" 11 #include "adas.h" 12 #include "reverseline.h" 13 #include "timesetting.h" 14 namespace Ui { 15 class Settings; 16 } 17 18 class Settings : public QDialog 19 { 20 Q_OBJECT 21 22 public: 23 explicit Settings(QWidget *parent = 0); 24 ~Settings(); 25 void FormInCenter(); 26 public slots: 27 28 private slots: 29 void on_returnButton_clicked(); 30 31 void on_previewButton_clicked(); 32 33 void on_AdasButton_clicked(); 34 35 void on_reverseLineButton_clicked(); 36 37 void on_timeSetButton_clicked(); 38 39 void on_aboutButton_clicked(); 40 41 private: 42 About *abouts; 43 Preview *previews; 44 ADAS *adass; 45 ReverseLine *reverselines; 46 TimeSetting *timesettings; 47 private: 48 Ui::Settings *ui; 49 50 }; 51 52 53 54 class CustomTabStyle : public QProxyStyle 55 { 56 public: CustomTabStyle(int x,int y)57 explicit CustomTabStyle(int x,int y):width(x),height(y){} sizeFromContents(ContentsType type,const QStyleOption * option,const QSize & size,const QWidget * widget)58 QSize sizeFromContents(ContentsType type, const QStyleOption *option, 59 const QSize &size, const QWidget *widget) const 60 { 61 QSize s = QProxyStyle::sizeFromContents(type, option, size, widget); 62 if (type == QStyle::CT_TabBarTab) { 63 s.transpose(); 64 s.rwidth() = this->width; 65 s.rheight() = this->height; 66 } 67 return s; 68 } 69 drawControl(ControlElement element,const QStyleOption * option,QPainter * painter,const QWidget * widget)70 void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const 71 { 72 if (element == CE_TabBarTabLabel) { 73 if(const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab*>(option)) { 74 QRect allRect = tab->rect; 75 76 if (tab->state & QStyle::State_Selected) { 77 painter->save(); 78 painter->setPen(0x89cfff); 79 painter->setBrush(QBrush(0x89cfff)); 80 painter->drawRect(allRect.adjusted(6, 6, -6, -6)); 81 painter->restore(); 82 } 83 QTextOption option; 84 option.setAlignment(Qt::AlignCenter); 85 if (tab->state & QStyle::State_Selected) { 86 painter->setPen(0xf8fcff); 87 } 88 else { 89 painter->setPen(0xf8fcff); 90 } 91 92 painter->drawText(allRect, tab->text, option); 93 return; 94 } 95 } 96 97 if (element == CE_TabBarTab) { 98 QProxyStyle::drawControl(element, option, painter, widget); 99 } 100 } 101 private: 102 int width; 103 int height; 104 }; 105 106 #endif // SETTINGS_H 107