93 lines
2.2 KiB
C
93 lines
2.2 KiB
C
|
#pragma once
|
|||
|
#pragma execution_character_set("utf-8")
|
|||
|
|
|||
|
#include <QWidget>
|
|||
|
#include <QLabel>
|
|||
|
#include <QPushButton>
|
|||
|
#include <QTimer>
|
|||
|
|
|||
|
enum ButtonType
|
|||
|
{
|
|||
|
MIN_BUTTON = 0, //<2F><>С<EFBFBD><D0A1><EFBFBD>رհ<D8B1>ť
|
|||
|
MIN_MAX_BUTTON , //<2F><>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>رհ<D8B1>ť
|
|||
|
ONLY_CLOSE_BUTTON //ֻ<>йرհ<D8B1>ť
|
|||
|
};
|
|||
|
|
|||
|
class MyTitleBar : public QWidget
|
|||
|
{
|
|||
|
Q_OBJECT
|
|||
|
|
|||
|
public:
|
|||
|
MyTitleBar(QWidget *parent = NULL);
|
|||
|
~MyTitleBar();
|
|||
|
|
|||
|
//<2F><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ
|
|||
|
void setBackgroundColor(int r, int g, int b);
|
|||
|
//<2F><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>
|
|||
|
void setTitleIcon(QString filePath);
|
|||
|
//<2F><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
void setTitleContent(QString titleContent);
|
|||
|
//<2F><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
void setTitleWidth(int width);
|
|||
|
//<2F><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϰ<EFBFBD>ť<EFBFBD><C5A5><EFBFBD><EFBFBD>
|
|||
|
void setButtonType(ButtonType buttonType);
|
|||
|
//<2F><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>еı<D0B5><C4B1><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>;<3B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Կ<EFBFBD>Ч<EFBFBD><D0A7>
|
|||
|
void setTitleRoll();
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD>ڵ<EFBFBD>λ<EFBFBD>ü<EFBFBD><C3BC><EFBFBD>С
|
|||
|
void saveRestoreInfo(const QPoint point, const QSize size);
|
|||
|
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD>ڵ<EFBFBD>λ<EFBFBD>ü<EFBFBD><C3BC><EFBFBD>С
|
|||
|
void getRestoreInfo(QPoint& point, QSize& size);
|
|||
|
|
|||
|
private:
|
|||
|
void paintEvent(QPaintEvent *event);
|
|||
|
void mouseDoubleClickEvent(QMouseEvent *event);
|
|||
|
void mousePressEvent(QMouseEvent *event);
|
|||
|
void mouseMoveEvent(QMouseEvent *event);
|
|||
|
void mouseReleaseEvent(QMouseEvent *event);
|
|||
|
//<2F><>ʼ<EFBFBD><CABC><EFBFBD>ؼ<EFBFBD>
|
|||
|
void initControl();
|
|||
|
//<2F>źŲ۵İ<DBB5><C4B0><EFBFBD>
|
|||
|
void initConnections();
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD>ļ<EFBFBD>
|
|||
|
void loadStyleSheet(const QString &sheetName);
|
|||
|
|
|||
|
signals:
|
|||
|
//<2F><>ť<EFBFBD><C5A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD>
|
|||
|
void signalButtonMinClicked();
|
|||
|
void signalButtonRestoreClicked();
|
|||
|
void signalButtonMaxClicked();
|
|||
|
void signalButtonCloseClicked();
|
|||
|
|
|||
|
private slots:
|
|||
|
//<2F><>ť<EFBFBD><C5A5><EFBFBD><EFBFBD><EFBFBD>IJۺ<C4B2><DBBA><EFBFBD>
|
|||
|
void onButtonMinClicked();
|
|||
|
void onButtonRestoreClicked();
|
|||
|
void onButtonMaxClicked();
|
|||
|
void onButtonCloseClicked();
|
|||
|
void onRollTitle();
|
|||
|
|
|||
|
private:
|
|||
|
QLabel* m_pIcon; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>
|
|||
|
QLabel* m_pTitleContent; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
QPushButton* m_pButtonMin; //<2F><>С<EFBFBD><D0A1><EFBFBD><EFBFBD>ť
|
|||
|
QPushButton* m_pButtonRestore; //<2F><><EFBFBD><EFBFBD>ԭ<EFBFBD><D4AD>ť
|
|||
|
QPushButton* m_pButtonMax; //<2F><><EFBFBD><EFBFBD>ť
|
|||
|
QPushButton* m_pButtonClose; //<2F>رհ<D8B1>ť
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ
|
|||
|
int m_colorR;
|
|||
|
int m_colorG;
|
|||
|
int m_colorB;
|
|||
|
//<2F><><EFBFBD><EFBFBD><F3BBAFA1><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
QPoint m_restorePos;
|
|||
|
QSize m_restoreSize;
|
|||
|
//<2F>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD>ڵı<DAB5><C4B1><EFBFBD>
|
|||
|
bool m_isPressed;
|
|||
|
QPoint m_startMovePos;
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7>ʱ<EFBFBD><CAB1>
|
|||
|
QTimer m_titleRollTimer;
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
QString m_titleContent;
|
|||
|
//<2F><>ť<EFBFBD><C5A5><EFBFBD><EFBFBD>
|
|||
|
ButtonType m_buttonType;
|
|||
|
};
|