-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7d57542
commit 0c481d0
Showing
5 changed files
with
73 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// clang-format off | ||
// SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]> | ||
// clang-format on | ||
// SPDX-FileContributor: Andrew Hayzen <[email protected]> | ||
// | ||
// SPDX-License-Identifier: MIT OR Apache-2.0 | ||
|
||
#pragma once | ||
|
||
#include <QtWidgets/QPushButton> |
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 |
---|---|---|
|
@@ -5,3 +5,6 @@ | |
|
||
mod qapplication; | ||
pub use qapplication::QApplication; | ||
|
||
mod qpushbutton; | ||
pub use qpushbutton::QPushButton; |
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,8 @@ | ||
// clang-format off | ||
// SPDX-FileCopyrightText: 2024 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]> | ||
// clang-format on | ||
// SPDX-FileContributor: Andrew Hayzen <[email protected]> | ||
// | ||
// SPDX-License-Identifier: MIT OR Apache-2.0 | ||
|
||
#include "cxx-qt-lib-extras/qpushbutton.h" |
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,50 @@ | ||
// SPDX-FileCopyrightText: 2024 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]> | ||
// SPDX-FileContributor: Andrew Hayzen <[email protected]> | ||
// | ||
// SPDX-License-Identifier: MIT OR Apache-2.0 | ||
|
||
#[cxx_qt::bridge] | ||
mod ffi { | ||
unsafe extern "C++" { | ||
include!("cxx-qt-lib/qstring.h"); | ||
type QString = cxx_qt_lib::QString; | ||
} | ||
|
||
unsafe extern "C++Qt" { | ||
include!("cxx-qt-lib-extras/qpushbutton.h"); | ||
|
||
#[qobject] | ||
type QPushButton; | ||
|
||
// TODO: we should use upcasting methods here and implement QAbstractButton and QWidget | ||
// so that we don't need to duplicate all of the methods | ||
|
||
/// This signal is emitted when the button is activated (i.e., pressed down then released while the mouse cursor is inside the button) | ||
#[qsignal] | ||
fn clicked(self: Pin<&mut QPushButton>, checked: bool); | ||
|
||
/// Set the text shown on the button | ||
#[rust_name = "set_text"] | ||
fn setText(self: Pin<&mut QPushButton>, text: &QString); | ||
|
||
/// Shows the widget and its child widgets. | ||
fn show(self: Pin<&mut QPushButton>); | ||
} | ||
|
||
#[namespace = "rust::cxxqtlib1"] | ||
unsafe extern "C++Qt" { | ||
include!("cxx-qt-lib/common.h"); | ||
|
||
#[doc(hidden)] | ||
#[rust_name = "qpushbutton_init_default"] | ||
fn make_unique() -> UniquePtr<QPushButton>; | ||
} | ||
} | ||
|
||
impl ffi::QPushButton { | ||
pub fn new() -> cxx::UniquePtr<Self> { | ||
ffi::qpushbutton_init_default() | ||
} | ||
} | ||
|
||
pub use ffi::QPushButton; |