mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 13:10:04 +00:00 
			
		
		
		
	location markers part2 initial clang-tidy changes
This commit is contained in:
		
							parent
							
								
									cac89129af
								
							
						
					
					
						commit
						7ab12e7b4b
					
				
					 6 changed files with 66 additions and 52 deletions
				
			
		|  | @ -168,7 +168,7 @@ void MarkerManager::Impl::ReadMarkerSettings() | ||||||
| 
 | 
 | ||||||
|    boost::json::value markerJson = nullptr; |    boost::json::value markerJson = nullptr; | ||||||
|    { |    { | ||||||
|       std::unique_lock lock(markerRecordLock_); |       const std::unique_lock lock(markerRecordLock_); | ||||||
| 
 | 
 | ||||||
|       // Determine if marker settings exists
 |       // Determine if marker settings exists
 | ||||||
|       if (std::filesystem::exists(markerSettingsPath_)) |       if (std::filesystem::exists(markerSettingsPath_)) | ||||||
|  | @ -188,9 +188,9 @@ void MarkerManager::Impl::ReadMarkerSettings() | ||||||
|             { |             { | ||||||
|                auto record = boost::json::value_to<MarkerRecord>(markerEntry); |                auto record = boost::json::value_to<MarkerRecord>(markerEntry); | ||||||
| 
 | 
 | ||||||
|                types::MarkerId id    = NewId(); |                const types::MarkerId id    = NewId(); | ||||||
|                size_t          index = markerRecords_.size(); |                const size_t          index = markerRecords_.size(); | ||||||
|                record.markerInfo_.id = id; |                record.markerInfo_.id       = id; | ||||||
|                markerRecords_.emplace_back( |                markerRecords_.emplace_back( | ||||||
|                   std::make_shared<MarkerRecord>(record.markerInfo_)); |                   std::make_shared<MarkerRecord>(record.markerInfo_)); | ||||||
|                idToIndex_.emplace(id, index); |                idToIndex_.emplace(id, index); | ||||||
|  | @ -218,7 +218,7 @@ void MarkerManager::Impl::WriteMarkerSettings() | ||||||
| { | { | ||||||
|    logger_->info("Saving location marker settings"); |    logger_->info("Saving location marker settings"); | ||||||
| 
 | 
 | ||||||
|    std::shared_lock lock(markerRecordLock_); |    const std::shared_lock lock(markerRecordLock_); | ||||||
|    auto markerJson = boost::json::value_from(markerRecords_); |    auto markerJson = boost::json::value_from(markerRecords_); | ||||||
|    util::json::WriteJsonFile(markerSettingsPath_, markerJson); |    util::json::WriteJsonFile(markerSettingsPath_, markerJson); | ||||||
| } | } | ||||||
|  | @ -263,7 +263,7 @@ MarkerManager::MarkerManager() : p(std::make_unique<Impl>(this)) | ||||||
|                            // Read Marker settings on startup
 |                            // Read Marker settings on startup
 | ||||||
|                            main::Application::WaitForInitialization(); |                            main::Application::WaitForInitialization(); | ||||||
|                            { |                            { | ||||||
|                               std::unique_lock lock(p->markerIconsLock_); |                               const std::unique_lock lock(p->markerIconsLock_); | ||||||
|                               p->markerIcons_.reserve( |                               p->markerIcons_.reserve( | ||||||
|                                  defaultMarkerIcons_.size()); |                                  defaultMarkerIcons_.size()); | ||||||
|                               for (auto& icon : defaultMarkerIcons_) |                               for (auto& icon : defaultMarkerIcons_) | ||||||
|  | @ -295,7 +295,7 @@ size_t MarkerManager::marker_count() | ||||||
| 
 | 
 | ||||||
| std::optional<types::MarkerInfo> MarkerManager::get_marker(types::MarkerId id) | std::optional<types::MarkerInfo> MarkerManager::get_marker(types::MarkerId id) | ||||||
| { | { | ||||||
|    std::shared_lock lock(p->markerRecordLock_); |    const std::shared_lock lock(p->markerRecordLock_); | ||||||
|    if (!p->idToIndex_.contains(id)) |    if (!p->idToIndex_.contains(id)) | ||||||
|    { |    { | ||||||
|       return {}; |       return {}; | ||||||
|  | @ -313,7 +313,7 @@ std::optional<types::MarkerInfo> MarkerManager::get_marker(types::MarkerId id) | ||||||
| 
 | 
 | ||||||
| std::optional<size_t> MarkerManager::get_index(types::MarkerId id) | std::optional<size_t> MarkerManager::get_index(types::MarkerId id) | ||||||
| { | { | ||||||
|    std::shared_lock lock(p->markerRecordLock_); |    const std::shared_lock lock(p->markerRecordLock_); | ||||||
|    if (!p->idToIndex_.contains(id)) |    if (!p->idToIndex_.contains(id)) | ||||||
|    { |    { | ||||||
|       return {}; |       return {}; | ||||||
|  | @ -325,7 +325,7 @@ void MarkerManager::set_marker(types::MarkerId          id, | ||||||
|                                const types::MarkerInfo& marker) |                                const types::MarkerInfo& marker) | ||||||
| { | { | ||||||
|    { |    { | ||||||
|       std::unique_lock lock(p->markerRecordLock_); |       const std::unique_lock lock(p->markerRecordLock_); | ||||||
|       if (!p->idToIndex_.contains(id)) |       if (!p->idToIndex_.contains(id)) | ||||||
|       { |       { | ||||||
|          return; |          return; | ||||||
|  | @ -336,9 +336,9 @@ void MarkerManager::set_marker(types::MarkerId          id, | ||||||
|          logger_->warn("id in idToIndex_ but out of range!"); |          logger_->warn("id in idToIndex_ but out of range!"); | ||||||
|          return; |          return; | ||||||
|       } |       } | ||||||
|       std::shared_ptr<MarkerManager::Impl::MarkerRecord>& markerRecord = |       const std::shared_ptr<MarkerManager::Impl::MarkerRecord>& markerRecord = | ||||||
|          p->markerRecords_[index]; |          p->markerRecords_[index]; | ||||||
|       markerRecord->markerInfo_ = marker; |       markerRecord->markerInfo_    = marker; | ||||||
|       markerRecord->markerInfo_.id = id; |       markerRecord->markerInfo_.id = id; | ||||||
| 
 | 
 | ||||||
|       add_icon(marker.iconName); |       add_icon(marker.iconName); | ||||||
|  | @ -351,7 +351,7 @@ types::MarkerId MarkerManager::add_marker(const types::MarkerInfo& marker) | ||||||
| { | { | ||||||
|    types::MarkerId id; |    types::MarkerId id; | ||||||
|    { |    { | ||||||
|       std::unique_lock lock(p->markerRecordLock_); |       const std::unique_lock lock(p->markerRecordLock_); | ||||||
|       id = p->NewId(); |       id = p->NewId(); | ||||||
|       size_t index = p->markerRecords_.size(); |       size_t index = p->markerRecords_.size(); | ||||||
|       p->idToIndex_.emplace(id, index); |       p->idToIndex_.emplace(id, index); | ||||||
|  | @ -368,7 +368,7 @@ types::MarkerId MarkerManager::add_marker(const types::MarkerInfo& marker) | ||||||
| void MarkerManager::remove_marker(types::MarkerId id) | void MarkerManager::remove_marker(types::MarkerId id) | ||||||
| { | { | ||||||
|    { |    { | ||||||
|       std::unique_lock lock(p->markerRecordLock_); |       const std::unique_lock lock(p->markerRecordLock_); | ||||||
|       if (!p->idToIndex_.contains(id)) |       if (!p->idToIndex_.contains(id)) | ||||||
|       { |       { | ||||||
|          return; |          return; | ||||||
|  | @ -399,7 +399,7 @@ void MarkerManager::remove_marker(types::MarkerId id) | ||||||
| void MarkerManager::move_marker(size_t from, size_t to) | void MarkerManager::move_marker(size_t from, size_t to) | ||||||
| { | { | ||||||
|    { |    { | ||||||
|       std::unique_lock lock(p->markerRecordLock_); |       const std::unique_lock lock(p->markerRecordLock_); | ||||||
|       if (from >= p->markerRecords_.size() || to >= p->markerRecords_.size()) |       if (from >= p->markerRecords_.size() || to >= p->markerRecords_.size()) | ||||||
|       { |       { | ||||||
|          return; |          return; | ||||||
|  | @ -430,7 +430,7 @@ void MarkerManager::move_marker(size_t from, size_t to) | ||||||
| 
 | 
 | ||||||
| void MarkerManager::for_each(std::function<MarkerForEachFunc> func) | void MarkerManager::for_each(std::function<MarkerForEachFunc> func) | ||||||
| { | { | ||||||
|    std::shared_lock lock(p->markerRecordLock_); |    const std::shared_lock lock(p->markerRecordLock_); | ||||||
|    for (auto marker : p->markerRecords_) |    for (auto marker : p->markerRecords_) | ||||||
|    { |    { | ||||||
|       func(marker->markerInfo_); |       func(marker->markerInfo_); | ||||||
|  | @ -440,12 +440,12 @@ void MarkerManager::for_each(std::function<MarkerForEachFunc> func) | ||||||
| void MarkerManager::add_icon(const std::string& name, bool startup) | void MarkerManager::add_icon(const std::string& name, bool startup) | ||||||
| { | { | ||||||
|    { |    { | ||||||
|       std::unique_lock lock(p->markerIconsLock_); |       const std::unique_lock lock(p->markerIconsLock_); | ||||||
|       if (p->markerIcons_.contains(name)) |       if (p->markerIcons_.contains(name)) | ||||||
|       { |       { | ||||||
|          return; |          return; | ||||||
|       } |       } | ||||||
|       std::shared_ptr<boost::gil::rgba8_image_t> image = |       const std::shared_ptr<boost::gil::rgba8_image_t> image = | ||||||
|          ResourceManager::LoadImageResource(name); |          ResourceManager::LoadImageResource(name); | ||||||
| 
 | 
 | ||||||
|       auto icon = types::MarkerIconInfo(name, -1, -1, image); |       auto icon = types::MarkerIconInfo(name, -1, -1, image); | ||||||
|  | @ -464,7 +464,7 @@ void MarkerManager::add_icon(const std::string& name, bool startup) | ||||||
| std::optional<types::MarkerIconInfo> | std::optional<types::MarkerIconInfo> | ||||||
| MarkerManager::get_icon(const std::string& name) | MarkerManager::get_icon(const std::string& name) | ||||||
| { | { | ||||||
|    std::shared_lock lock(p->markerIconsLock_); |    const std::shared_lock lock(p->markerIconsLock_); | ||||||
|    if (p->markerIcons_.contains(name)) |    if (p->markerIcons_.contains(name)) | ||||||
|    { |    { | ||||||
|       return p->markerIcons_.at(name); |       return p->markerIcons_.at(name); | ||||||
|  | @ -476,7 +476,7 @@ MarkerManager::get_icon(const std::string& name) | ||||||
| const std::unordered_map<std::string, types::MarkerIconInfo> | const std::unordered_map<std::string, types::MarkerIconInfo> | ||||||
| MarkerManager::get_icons() | MarkerManager::get_icons() | ||||||
| { | { | ||||||
|    std::shared_lock lock(p->markerIconsLock_); |    const std::shared_lock lock(p->markerIconsLock_); | ||||||
|    return p->markerIcons_; |    return p->markerIcons_; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -492,7 +492,7 @@ std::shared_ptr<MarkerManager> MarkerManager::Instance() | ||||||
|    static std::weak_ptr<MarkerManager> markerManagerReference_ {}; |    static std::weak_ptr<MarkerManager> markerManagerReference_ {}; | ||||||
|    static std::mutex                   instanceMutex_ {}; |    static std::mutex                   instanceMutex_ {}; | ||||||
| 
 | 
 | ||||||
|    std::unique_lock lock(instanceMutex_); |    const std::unique_lock lock(instanceMutex_); | ||||||
| 
 | 
 | ||||||
|    std::shared_ptr<MarkerManager> markerManager = |    std::shared_ptr<MarkerManager> markerManager = | ||||||
|       markerManagerReference_.lock(); |       markerManagerReference_.lock(); | ||||||
|  |  | ||||||
|  | @ -72,9 +72,10 @@ void MarkerLayer::Impl::ReloadMarkers() | ||||||
|       { |       { | ||||||
|          // must use local ID, instead of reference to marker in event handler
 |          // must use local ID, instead of reference to marker in event handler
 | ||||||
|          // callback.
 |          // callback.
 | ||||||
|          types::MarkerId id = marker.id; |          const types::MarkerId id = marker.id; | ||||||
| 
 | 
 | ||||||
|          std::shared_ptr<gl::draw::GeoIconDrawItem> icon = geoIcons_->AddIcon(); |          const std::shared_ptr<gl::draw::GeoIconDrawItem> icon = | ||||||
|  |             geoIcons_->AddIcon(); | ||||||
| 
 | 
 | ||||||
|          geoIcons_->SetIconTexture(icon, marker.iconName, 0); |          geoIcons_->SetIconTexture(icon, marker.iconName, 0); | ||||||
|          geoIcons_->SetIconLocation(icon, marker.latitude, marker.longitude); |          geoIcons_->SetIconLocation(icon, marker.latitude, marker.longitude); | ||||||
|  |  | ||||||
|  | @ -30,7 +30,12 @@ static const auto        logger_    = scwx::util::Logger::Create(logPrefix_); | ||||||
| class EditMarkerDialog::Impl | class EditMarkerDialog::Impl | ||||||
| { | { | ||||||
| public: | public: | ||||||
|    explicit Impl(EditMarkerDialog* self) : self_ {self} {} |    explicit Impl(EditMarkerDialog* self) : | ||||||
|  |        self_ {self}, | ||||||
|  |        deleteButton_ {self_->ui->buttonBox->addButton( | ||||||
|  |           "Delete", QDialogButtonBox::DestructiveRole)} | ||||||
|  |    { | ||||||
|  |    } | ||||||
| 
 | 
 | ||||||
|    void show_color_dialog(); |    void show_color_dialog(); | ||||||
|    void show_icon_file_dialog(); |    void show_icon_file_dialog(); | ||||||
|  | @ -49,8 +54,8 @@ public: | ||||||
| 
 | 
 | ||||||
|    std::shared_ptr<manager::MarkerManager> markerManager_ = |    std::shared_ptr<manager::MarkerManager> markerManager_ = | ||||||
|       manager::MarkerManager::Instance(); |       manager::MarkerManager::Instance(); | ||||||
|    types::MarkerId editId_; |    types::MarkerId editId_ {0}; | ||||||
|    bool            adding_; |    bool            adding_ {false}; | ||||||
|    std::string     setIconOnAdded_ {""}; |    std::string     setIconOnAdded_ {""}; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | @ -75,8 +80,6 @@ EditMarkerDialog::EditMarkerDialog(QWidget* parent) : | ||||||
|                                 QString(""), |                                 QString(""), | ||||||
|                                 QString::fromStdString(markerIcon.second.name)); |                                 QString::fromStdString(markerIcon.second.name)); | ||||||
|    } |    } | ||||||
|    p->deleteButton_ = |  | ||||||
|       ui->buttonBox->addButton("Delete", QDialogButtonBox::DestructiveRole); |  | ||||||
|    p->connect_signals(); |    p->connect_signals(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -94,8 +97,8 @@ void EditMarkerDialog::setup(double latitude, double longitude) | ||||||
| { | { | ||||||
|    // By default use foreground color as marker color, mainly so the icons
 |    // By default use foreground color as marker color, mainly so the icons
 | ||||||
|    // are vissable in the dropdown menu.
 |    // are vissable in the dropdown menu.
 | ||||||
|    QColor color = QWidget::palette().color(QWidget::foregroundRole()); |    const QColor color = QWidget::palette().color(QWidget::foregroundRole()); | ||||||
|    p->editId_   = p->markerManager_->add_marker(types::MarkerInfo( |    p->editId_         = p->markerManager_->add_marker(types::MarkerInfo( | ||||||
|       "", |       "", | ||||||
|       latitude, |       latitude, | ||||||
|       longitude, |       longitude, | ||||||
|  | @ -120,7 +123,8 @@ void EditMarkerDialog::setup(types::MarkerId id) | ||||||
|    p->editId_ = id; |    p->editId_ = id; | ||||||
|    p->adding_ = false; |    p->adding_ = false; | ||||||
| 
 | 
 | ||||||
|    std::string iconColorStr = util::color::ToArgbString(marker->iconColor); |    const std::string iconColorStr = | ||||||
|  |       util::color::ToArgbString(marker->iconColor); | ||||||
|    p->set_icon_color(iconColorStr); |    p->set_icon_color(iconColorStr); | ||||||
| 
 | 
 | ||||||
|    int iconIndex = |    int iconIndex = | ||||||
|  | @ -139,8 +143,8 @@ void EditMarkerDialog::setup(types::MarkerId id) | ||||||
| 
 | 
 | ||||||
| types::MarkerInfo EditMarkerDialog::get_marker_info() const | types::MarkerInfo EditMarkerDialog::get_marker_info() const | ||||||
| { | { | ||||||
|    QString                   colorName = ui->iconColorLineEdit->text(); |    const QString                   colorName = ui->iconColorLineEdit->text(); | ||||||
|    boost::gil::rgba8_pixel_t color = |    const boost::gil::rgba8_pixel_t color = | ||||||
|       util::color::ToRgba8PixelT(colorName.toStdString()); |       util::color::ToRgba8PixelT(colorName.toStdString()); | ||||||
| 
 | 
 | ||||||
|    return types::MarkerInfo( |    return types::MarkerInfo( | ||||||
|  | @ -159,7 +163,7 @@ void EditMarkerDialog::Impl::show_color_dialog() | ||||||
|    dialog->setAttribute(Qt::WA_DeleteOnClose); |    dialog->setAttribute(Qt::WA_DeleteOnClose); | ||||||
|    dialog->setOption(QColorDialog::ColorDialogOption::ShowAlphaChannel); |    dialog->setOption(QColorDialog::ColorDialogOption::ShowAlphaChannel); | ||||||
| 
 | 
 | ||||||
|    QColor initialColor(self_->ui->iconColorLineEdit->text()); |    const QColor initialColor(self_->ui->iconColorLineEdit->text()); | ||||||
|    if (initialColor.isValid()) |    if (initialColor.isValid()) | ||||||
|    { |    { | ||||||
|       dialog->setCurrentColor(initialColor); |       dialog->setCurrentColor(initialColor); | ||||||
|  | @ -170,7 +174,7 @@ void EditMarkerDialog::Impl::show_color_dialog() | ||||||
|                     self_, |                     self_, | ||||||
|                     [this](const QColor& qColor) |                     [this](const QColor& qColor) | ||||||
|                     { |                     { | ||||||
|                        QString colorName = |                        const QString colorName = | ||||||
|                           qColor.name(QColor::NameFormat::HexArgb); |                           qColor.name(QColor::NameFormat::HexArgb); | ||||||
|                        self_->ui->iconColorLineEdit->setText(colorName); |                        self_->ui->iconColorLineEdit->setText(colorName); | ||||||
|                        set_icon_color(colorName.toStdString()); |                        set_icon_color(colorName.toStdString()); | ||||||
|  | @ -180,7 +184,6 @@ void EditMarkerDialog::Impl::show_color_dialog() | ||||||
| 
 | 
 | ||||||
| void EditMarkerDialog::Impl::show_icon_file_dialog() | void EditMarkerDialog::Impl::show_icon_file_dialog() | ||||||
| { | { | ||||||
| 
 |  | ||||||
|    auto* dialog = new QFileDialog(self_); |    auto* dialog = new QFileDialog(self_); | ||||||
| 
 | 
 | ||||||
|    dialog->setFileMode(QFileDialog::ExistingFile); |    dialog->setFileMode(QFileDialog::ExistingFile); | ||||||
|  | @ -192,7 +195,7 @@ void EditMarkerDialog::Impl::show_icon_file_dialog() | ||||||
|                     self_, |                     self_, | ||||||
|                     [this](const QString& file) |                     [this](const QString& file) | ||||||
|                     { |                     { | ||||||
|                        std::string path = |                        const std::string path = | ||||||
|                           QDir::toNativeSeparators(file).toStdString(); |                           QDir::toNativeSeparators(file).toStdString(); | ||||||
|                        setIconOnAdded_ = path; |                        setIconOnAdded_ = path; | ||||||
|                        markerManager_->add_icon(path); |                        markerManager_->add_icon(path); | ||||||
|  | @ -224,13 +227,12 @@ void EditMarkerDialog::Impl::connect_signals() | ||||||
|    connect(self_->ui->iconColorLineEdit, |    connect(self_->ui->iconColorLineEdit, | ||||||
|            &QLineEdit::textEdited, |            &QLineEdit::textEdited, | ||||||
|            self_, |            self_, | ||||||
|            [=, this](const QString& text) |            [this](const QString& text) { set_icon_color(text.toStdString()); }); | ||||||
|            { set_icon_color(text.toStdString()); }); |  | ||||||
| 
 | 
 | ||||||
|    connect(self_->ui->iconColorButton, |    connect(self_->ui->iconColorButton, | ||||||
|            &QAbstractButton::clicked, |            &QAbstractButton::clicked, | ||||||
|            self_, |            self_, | ||||||
|            [=, this]() { show_color_dialog(); }); |            [this]() { show_color_dialog(); }); | ||||||
| 
 | 
 | ||||||
|    connect(self_->ui->iconFileOpenButton, |    connect(self_->ui->iconFileOpenButton, | ||||||
|            &QPushButton::clicked, |            &QPushButton::clicked, | ||||||
|  | @ -242,13 +244,13 @@ void EditMarkerDialog::Impl::connect_signals() | ||||||
|            self_, |            self_, | ||||||
|            [this]() |            [this]() | ||||||
|            { |            { | ||||||
|               std::string color = |               const std::string color = | ||||||
|                  self_->ui->iconColorLineEdit->text().toStdString(); |                  self_->ui->iconColorLineEdit->text().toStdString(); | ||||||
|               set_icon_color(color); |               set_icon_color(color); | ||||||
| 
 | 
 | ||||||
|               if (setIconOnAdded_ != "") |               if (setIconOnAdded_ != "") | ||||||
|               { |               { | ||||||
|                  int i = self_->ui->iconComboBox->findData( |                  const int i = self_->ui->iconComboBox->findData( | ||||||
|                     QString::fromStdString(setIconOnAdded_)); |                     QString::fromStdString(setIconOnAdded_)); | ||||||
|                  if (i >= 0) |                  if (i >= 0) | ||||||
|                  { |                  { | ||||||
|  | @ -269,9 +271,9 @@ void EditMarkerDialog::Impl::set_icon_color(const std::string& color) | ||||||
|    self_->ui->iconComboBox->clear(); |    self_->ui->iconComboBox->clear(); | ||||||
|    for (auto& markerIcon : markerManager_->get_icons()) |    for (auto& markerIcon : markerManager_->get_icons()) | ||||||
|    { |    { | ||||||
|       int i = |       const int i = | ||||||
|          iconComboBox->findData(QString::fromStdString(markerIcon.second.name)); |          iconComboBox->findData(QString::fromStdString(markerIcon.second.name)); | ||||||
|       QIcon icon = get_colored_icon(markerIcon.second, color); |       const QIcon icon = get_colored_icon(markerIcon.second, color); | ||||||
|       if (i < 0) |       if (i < 0) | ||||||
|       { |       { | ||||||
|          iconComboBox->addItem( |          iconComboBox->addItem( | ||||||
|  |  | ||||||
|  | @ -27,7 +27,7 @@ public: | ||||||
|    void setup(double latitude, double longitude); |    void setup(double latitude, double longitude); | ||||||
|    void setup(types::MarkerId id); |    void setup(types::MarkerId id); | ||||||
| 
 | 
 | ||||||
|    types::MarkerInfo get_marker_info() const; |    [[nodiscard]] types::MarkerInfo get_marker_info() const; | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|    class Impl; |    class Impl; | ||||||
|  |  | ||||||
|  | @ -102,7 +102,7 @@ void MarkerSettingsWidgetImpl::ConnectSignals() | ||||||
|             return; |             return; | ||||||
|          } |          } | ||||||
| 
 | 
 | ||||||
|          bool itemSelected = selected.size() > 0; |          const bool itemSelected = selected.size() > 0; | ||||||
|          self_->ui->removeButton->setEnabled(itemSelected); |          self_->ui->removeButton->setEnabled(itemSelected); | ||||||
|       }); |       }); | ||||||
|    QObject::connect(self_->ui->markerView, |    QObject::connect(self_->ui->markerView, | ||||||
|  | @ -110,7 +110,7 @@ void MarkerSettingsWidgetImpl::ConnectSignals() | ||||||
|                     self_, |                     self_, | ||||||
|                     [this](const QModelIndex& index) |                     [this](const QModelIndex& index) | ||||||
|                     { |                     { | ||||||
|                        int row = index.row(); |                        const int row = index.row(); | ||||||
|                        if (row < 0) |                        if (row < 0) | ||||||
|                        { |                        { | ||||||
|                           return; |                           return; | ||||||
|  |  | ||||||
|  | @ -20,11 +20,22 @@ void modulateColors_(QImage& image, const QColor& color) | ||||||
|       QRgb* line = reinterpret_cast<QRgb*>(image.scanLine(y)); |       QRgb* line = reinterpret_cast<QRgb*>(image.scanLine(y)); | ||||||
|       for (int x = 0; x < image.width(); ++x) |       for (int x = 0; x < image.width(); ++x) | ||||||
|       { |       { | ||||||
|          QRgb& rgb   = line[x]; |          QRgb& rgb = line[x]; | ||||||
|          int   red   = qRed(rgb) * color.redF(); |          /* clang-format off
 | ||||||
|          int   green = qGreen(rgb) * color.greenF(); |           * NOLINTBEGIN(cppcoreguidelines-narrowing-conversions, bugprone-narrowing-conversions) | ||||||
|          int   blue  = qBlue(rgb) * color.blueF(); |           * qRed/qGreen/qBlue/qAlpha return values 0-255, handlable by float | ||||||
|          int   alpha = qAlpha(rgb) * color.alphaF(); |           * redF/greenF/blueF/alphaF are all 0-1, so output is 0-255 | ||||||
|  |           * Rounding is fine for this. | ||||||
|  |           * clang-format on | ||||||
|  |           */ | ||||||
|  |          const int red   = qRed(rgb) * color.redF(); | ||||||
|  |          const int green = qGreen(rgb) * color.greenF(); | ||||||
|  |          const int blue  = qBlue(rgb) * color.blueF(); | ||||||
|  |          const int alpha = qAlpha(rgb) * color.alphaF(); | ||||||
|  |          /* clang-format off
 | ||||||
|  |           * NOLINTEND(cppcoreguidelines-narrowing-conversions, bugprone-narrowing-conversions) | ||||||
|  |           * clang-format on | ||||||
|  |           */ | ||||||
| 
 | 
 | ||||||
|          rgb = qRgba(red, green, blue, alpha); |          rgb = qRgba(red, green, blue, alpha); | ||||||
|       } |       } | ||||||
|  | @ -47,7 +58,7 @@ QPixmap modulateColors(const QPixmap& pixmap, const QColor& color) | ||||||
| 
 | 
 | ||||||
| QIcon modulateColors(const QIcon& icon, const QSize& size, const QColor& color) | QIcon modulateColors(const QIcon& icon, const QSize& size, const QColor& color) | ||||||
| { | { | ||||||
|    QPixmap pixmap = modulateColors(icon.pixmap(size), color); |    const QPixmap pixmap = modulateColors(icon.pixmap(size), color); | ||||||
|    return QIcon(pixmap); |    return QIcon(pixmap); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 AdenKoperczak
						AdenKoperczak