Skip to content

Commit

Permalink
开发环境从Vs转到Clion了
Browse files Browse the repository at this point in the history
实现了RadioButton
  • Loading branch information
zjhzzy committed Jul 24, 2023
1 parent 10ac82a commit 176a61e
Show file tree
Hide file tree
Showing 22 changed files with 716 additions and 797 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -396,3 +396,11 @@ FodyWeavers.xsd

# JetBrains Rider
*.sln.iml
.idea/modules.xml
.idea/misc.xml
.idea/qmlSettings.xml
.idea/FlareUI.iml
.idea/.name
.idea/.gitignore
*/cmake-build-debug/
*/cmake-build-release/
151 changes: 88 additions & 63 deletions BaseButton.cpp
Original file line number Diff line number Diff line change
@@ -1,65 +1,90 @@
#include "BaseButton.h"

void BaseButton::enterEvent(QEnterEvent* event) {
QAbstractButton::enterEvent(event);
isAbove = true;
update();
emit moveAbove();
}

void BaseButton::leaveEvent(QEvent* event) {
QAbstractButton::leaveEvent(event);
isAbove = false;
update();
emit leaveAbove();
}

void BaseButton::mousePressEvent(QMouseEvent* event) {
QAbstractButton::mousePressEvent(event);
isPress = true;
update();
}

void BaseButton::mouseReleaseEvent(QMouseEvent* event) {
QAbstractButton::mouseReleaseEvent(event);
isPress = false;
update();
}

BaseButton::BaseButton(QWidget *parent)
: QAbstractButton(parent),
xRadius(0),yRadius(0),
isAbove(false),isPress(false){
}

BaseButton::~BaseButton()
{}

f32 BaseButton::XRadius() {
return xRadius;
}

f32 BaseButton::YRadius() {
return yRadius;
}

bool BaseButton::IsPress() {
return isPress;
}

bool BaseButton::IsAbove() {
return isAbove;
}

void BaseButton::setXRadius(const f32& Radius) {
xRadius = Radius;
}

void BaseButton::setYRadius(const f32& Radius) {
yRadius = Radius;
}

void BaseButton::setRadius(const f32& Xradius, const f32& Yradius) {
setXRadius(Xradius);
setYRadius(Yradius);
}
namespace Flare {
void BaseButton::enterEvent(QEnterEvent *event) {
QAbstractButton::enterEvent(event);
isAbove = true;
update();
emit moveAbove();
}

void BaseButton::leaveEvent(QEvent *event) {
QAbstractButton::leaveEvent(event);
isAbove = false;
update();
emit leaveAbove();
}

void BaseButton::mousePressEvent(QMouseEvent *event) {
QAbstractButton::mousePressEvent(event);
isPress = true;
update();
}

void BaseButton::mouseReleaseEvent(QMouseEvent *event) {
QAbstractButton::mouseReleaseEvent(event);
isPress = false;
update();
}

BaseButton::BaseButton(QWidget *parent) :
QAbstractButton(parent),
isAbove(false), isPress(false),
isIcon(false), buttonIcon(new QIcon()),
buttonHoverIcon(new QIcon()),
buttonPressedIcon(new QIcon()) {
}

BaseButton::~BaseButton() {
delete buttonHoverIcon;
delete buttonIcon;
delete buttonPressedIcon;
}


bool BaseButton::IsPress() const {
return isPress;
}

bool BaseButton::IsAbove() const {
return isAbove;
}

void Flare::BaseButton::setAllIcon(const QIcon &icon) {
isIcon = true;
*buttonHoverIcon = icon;
*buttonIcon = icon;
*buttonPressedIcon = icon;
}

Flare::BaseButton::Icon Flare::BaseButton::Icon::setAllIcon(const QIcon &icon) {
buttonIcon = icon;
buttonHoverIcon = icon;
buttonPressedIcon = icon;
return *this;
}

void Flare::BaseButton::setIcon(const Icon &icon) {
isIcon = true;
*buttonIcon = icon.buttonIcon;
*buttonHoverIcon = icon.buttonHoverIcon;
*buttonPressedIcon = icon.buttonPressedIcon;
}

bool Flare::BaseButton::isSetIcon() const {
return isIcon;
}

QIcon BaseButton::ButtonIcon() {
return *buttonIcon;
}

QIcon BaseButton::ButtonHoverIcon() {
return *buttonHoverIcon;
}

QIcon BaseButton::ButtonPressedIcon() {
return *buttonPressedIcon;
}

}
54 changes: 54 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
cmake_minimum_required(VERSION 3.25)
project(Flare)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# 设置输出目录
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin)

# 添加自定义宏定义
add_definitions(-DFLARE_LIB)

# 包含头文件目录
include_directories(include/FlareUI)

set(CMAKE_PREFIX_PATH "C:/Qt/6.6.0/msvc2019_64")

# 查找并链接 Qt 库
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Gui Widgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui Widgets)

# 添加目标源文件
set(SOURCES
BaseButton.cpp
PushButton.cpp
ListView.cpp
Widget.cpp
FlareColor.cpp
SystemIcon.cpp
ProgressBar.cpp
RadioButton.cpp
include/FlareUI/BaseButton.h
include/FlareUI/PushButton.h
include/FlareUI/ListView.h
include/FlareUI/Widget.h
include/FlareUI/FlareColor.h
include/FlareUI/SystemIcon.h
include/FlareUI/ProgressBar.h
include/FlareUI/RadioButton.h)

# 生成静态库目标
add_library(Flare STATIC ${SOURCES})

# 链接 Qt 库
target_link_libraries(Flare PRIVATE
Qt6::Core
Qt6::Gui
Qt6::Widgets
)
25 changes: 0 additions & 25 deletions Flare.sln

This file was deleted.

Loading

0 comments on commit 176a61e

Please sign in to comment.