88 lines
2.7 KiB
C++
88 lines
2.7 KiB
C++
#ifndef TITLEBAR_H
|
|
#define TITLEBAR_H
|
|
|
|
#include <QWidget>
|
|
#include <QToolButton>
|
|
#include <QMouseEvent>
|
|
#include <QDesktopWidget>
|
|
#include <QToolBar>
|
|
#include <QAction>
|
|
#include <iostream>
|
|
#include <QLabel>
|
|
#include <QMenu>
|
|
|
|
#include "buttonmenu.h"
|
|
|
|
#pragma execution_character_set("utf-8")
|
|
|
|
enum ButtonType
|
|
{
|
|
MIN_BUTTON = 0, // 最小化和关闭按钮;
|
|
MIN_MAX_BUTTON , // 最小化、最大化和关闭按钮;
|
|
ONLY_CLOSE_BUTTON // 只有关闭按钮;
|
|
};
|
|
|
|
class TitleBar : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit TitleBar(QWidget *parent = nullptr);
|
|
~TitleBar();
|
|
public:
|
|
void setPath(QString path){ m_path = path;}
|
|
void TitleBarInit();
|
|
void translateBtn();
|
|
void SignalSlotsInit();
|
|
void CreateActions();
|
|
void switchMenu();
|
|
void setScreenSize();
|
|
protected:
|
|
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; //拖动界面
|
|
void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
|
|
void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
|
|
void mouseDoubleClickEvent(QMouseEvent *event) Q_DECL_OVERRIDE; // 双击标题栏进行界面的最大化/还原
|
|
bool eventFilter(QObject *obj, QEvent *event) Q_DECL_OVERRIDE; // 设置界面标题与图标
|
|
private:
|
|
void updateMaximize(); //最大化/还原
|
|
private:
|
|
QString m_path;
|
|
int m_oldIndex = 0;
|
|
// 移动窗口的变量;
|
|
bool m_isPressed = false;
|
|
QPoint m_startMovePos;
|
|
QPoint m_mouse_move;
|
|
// 按钮类型;
|
|
ButtonType m_buttonType;
|
|
QPushButton* m_pButtonMax; // 最大化按钮;
|
|
QLabel *m_pIconLabel = nullptr;
|
|
ButtonMenu *m_FileButton = nullptr;
|
|
ButtonMenu *m_SetButton = nullptr;
|
|
QToolButton *m_ZhButton = nullptr;
|
|
QToolButton *m_EnButton = nullptr;
|
|
QToolButton *m_UserButton = nullptr;
|
|
QToolButton *m_pMinimizeButton = nullptr;
|
|
QToolButton *m_pMaximizeButton = nullptr;
|
|
QToolButton *m_pCloseButton = nullptr;
|
|
private slots:
|
|
void onClicked(); // 进行最小化、最大化/还原、关闭操作
|
|
void OnOpenProject(QString); // 打开方案
|
|
void OnSaveProject(QString); // 保存方案
|
|
void OnCloseProject();
|
|
void OnShowResultTable(); //显示结果统计表
|
|
//中英文切换按钮
|
|
void On_SwitchToEnglish(); //切换成英文
|
|
void On_SwitchToChinese(); //切换成中文
|
|
|
|
void On_ConnectToHost(QString,QString,bool);
|
|
signals:
|
|
void mouseRecover();
|
|
void switchLanguageSignal(QString language); //切换语言信号
|
|
void close_mainwidget();
|
|
void OpenProjectSignal(QString);
|
|
void SaveProjectSignal(QString);
|
|
void showStatisticalTableSignal();
|
|
void ConnectToHostSignal(QString,QString);
|
|
};
|
|
|
|
#endif // TITLEBAR_H
|