-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
实现了RadioButton
- Loading branch information
Showing
22 changed files
with
716 additions
and
797 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) |
Oops, something went wrong.