Skip to content

Commit

Permalink
Adkustment to the QColor PR
Browse files Browse the repository at this point in the history
cc #213

 - rename some generic type name that are inside the QColor class in C++
 - Fix warnings
 - make documentation actual documentation
  • Loading branch information
ogoffart committed Nov 19, 2021
1 parent 638562e commit c7274e8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion qttypes/src/gui/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
mod qcolor;
pub use self::qcolor::{NameFormat, QColor, QRgb, QRgba64, Spec};
pub use self::qcolor::{QColor, QColorNameFormat, QColorSpec, QRgb, QRgba64};
17 changes: 9 additions & 8 deletions qttypes/src/gui/qcolor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ impl Into<u64> for QRgba64 {
#[repr(u32)]
#[derive(Clone, Copy, PartialEq, Debug)]
#[allow(non_camel_case_types)]
pub enum NameFormat {
// #RRGGBB A "#" character followed by three two-digit hexadecimal numbers (i.e. #RRGGBB).
pub enum QColorNameFormat {
/// #RRGGBB A "#" character followed by three two-digit hexadecimal numbers (i.e. #RRGGBB).
HexRgb = 0,
//#AARRGGBB A "#" character followed by four two-digit hexadecimal numbers (i.e. #AARRGGBB).
///#AARRGGBB A "#" character followed by four two-digit hexadecimal numbers (i.e. #AARRGGBB).
HexArgb = 1,
}

Expand All @@ -86,7 +86,7 @@ pub enum NameFormat {
#[repr(u32)]
#[derive(Clone, Copy, PartialEq, Debug)]
#[allow(non_camel_case_types)]
pub enum Spec {
pub enum QColorSpec {
Invalid = 0,
Rgb = 1,
Hsv = 2,
Expand Down Expand Up @@ -295,7 +295,7 @@ impl QColor {
})
}

pub fn convert_to(&self, color_spec: Spec) -> QColor {
pub fn convert_to(&self, color_spec: QColorSpec) -> QColor {
cpp!(unsafe [self as "const QColor*", color_spec as "QColor::Spec"] -> QColor as "QColor" {
return self->convertTo(color_spec);
})
Expand Down Expand Up @@ -557,7 +557,7 @@ impl QColor {
})
}

pub fn name_with_format(&self, format: NameFormat) -> QString {
pub fn name_with_format(&self, format: QColorNameFormat) -> QString {
cpp!(unsafe [self as "const QColor*", format as "QColor::NameFormat"] -> QString as "QString" {
return self->name(format);
})
Expand Down Expand Up @@ -749,8 +749,8 @@ impl QColor {
})
}

pub fn spec(&self) -> Spec {
cpp!(unsafe [self as "const QColor*"] -> Spec as "QColor::Spec" { return self->spec(); })
pub fn spec(&self) -> QColorSpec {
cpp!(unsafe [self as "const QColor*"] -> QColorSpec as "QColor::Spec" { return self->spec(); })
}

pub fn to_cmyk(&self) -> QColor {
Expand Down Expand Up @@ -809,6 +809,7 @@ impl QColor {
}
}

#[cfg(test)]
mod tests {
use super::*;

Expand Down
2 changes: 1 addition & 1 deletion qttypes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ mod core;
pub use crate::core::{qreal, QByteArray, QString, QUrl};

mod gui;
pub use crate::gui::{NameFormat, QColor, QRgb, QRgba64, Spec};
pub use crate::gui::{QColor, QColorNameFormat, QColorSpec, QRgb, QRgba64};
#[cfg(no_qt)]
mod no_qt {
pub fn panic<T>() -> T {
Expand Down

0 comments on commit c7274e8

Please sign in to comment.