| 2013 | } |
| 2014 | |
| 2015 | bool WidgetInfo::ColorChangedInternal(const char *setting, bool supportAlpha) |
| 2016 | { |
| 2017 | const char *desc = obs_property_description(property); |
| 2018 | long long val = obs_data_get_int(view->settings, setting); |
| 2019 | QColor color = color_from_int(val); |
| 2020 | QColor::NameFormat format; |
| 2021 | |
| 2022 | QColorDialog::ColorDialogOptions options; |
| 2023 | |
| 2024 | if (supportAlpha) { |
| 2025 | options |= QColorDialog::ShowAlphaChannel; |
| 2026 | } |
| 2027 | |
| 2028 | #ifdef __linux__ |
| 2029 | // TODO: Revisit hang on Ubuntu with native dialog |
| 2030 | options |= QColorDialog::DontUseNativeDialog; |
| 2031 | #endif |
| 2032 | |
| 2033 | color = QColorDialog::getColor(color, view, QT_UTF8(desc), options); |
| 2034 | |
| 2035 | #ifdef __APPLE__ |
| 2036 | // TODO: Revisit when QTBUG-42661 is fixed |
| 2037 | widget->window()->raise(); |
| 2038 | #endif |
| 2039 | |
| 2040 | if (!color.isValid()) |
| 2041 | return false; |
| 2042 | |
| 2043 | if (supportAlpha) { |
| 2044 | format = QColor::HexArgb; |
| 2045 | } else { |
| 2046 | color.setAlpha(255); |
| 2047 | format = QColor::HexRgb; |
| 2048 | } |
| 2049 | |
| 2050 | QLabel *label = static_cast<QLabel *>(widget); |
| 2051 | label->setText(color.name(format)); |
| 2052 | QPalette palette = QPalette(color); |
| 2053 | label->setPalette(palette); |
| 2054 | label->setStyleSheet( |
| 2055 | QString("background-color :%1; color: %2;") |
| 2056 | .arg(palette.color(QPalette::Window).name(format)) |
| 2057 | .arg(palette.color(QPalette::WindowText).name(format))); |
| 2058 | |
| 2059 | obs_data_set_int(view->settings, setting, color_to_int(color)); |
| 2060 | |
| 2061 | return true; |
| 2062 | } |
| 2063 | |
| 2064 | bool WidgetInfo::ColorChanged(const char *setting) |
| 2065 | { |
nothing calls this directly
no test coverage detected