Satoshi Yoneda 2 тижнів тому
батько
коміт
b2549f13af
6 змінених файлів з 25 додано та 2 видалено
  1. 10 2
      CMakeLists.txt
  2. 0 0
      i18n
  3. BIN
      icons/DupFind.ico
  4. 1 0
      include/ResultListModel.hpp
  5. 7 0
      src/MainWindow.cpp
  6. 7 0
      src/ResultListModel.cpp

+ 10 - 2
CMakeLists.txt

@@ -5,6 +5,9 @@ set(CMAKE_CXX_STANDARD 20)
 set(CMAKE_CXX_STANDARD_REQUIRED ON)
 option(USE_NATIVE_OPTIMIZATION "Optimize for the local machine" OFF)
 
+# WIndows用アイコン
+set(app_icon "${CMAKE_CURRENT_SOURCE_DIR}/icons/DupFind.ico")
+
 # 最適化と popcnt 命令出力のためのフラグ設定
 if(MSVC)
     add_compile_options(/arch:AVX2)
@@ -54,7 +57,12 @@ list(REMOVE_ITEM CORE_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/CmdMain.cpp")
 set_target_properties(DupFindCore PROPERTIES SOURCES "${CORE_SOURCES}")
 
 # GUI target
-add_executable(${PROJECT_NAME} src/main.cpp)
+#add_executable(${PROJECT_NAME} src/main.cpp)
+qt_add_executable(${PROJECT_NAME}
+    src/main.cpp
+    ${app_icon}
+)
+
 target_link_libraries(${PROJECT_NAME} PRIVATE DupFindCore)
 
 set_target_properties(${PROJECT_NAME} PROPERTIES
@@ -75,7 +83,7 @@ qt_add_translations(${PROJECT_NAME}
         translations/dupfind_pt.ts
         translations/dupfind_pl.ts
         translations/dupfind_ko.ts
-    RESOURCE translations.qrc
+    RESOURCE i18n
 )
 
 # CLI target

+ 0 - 0
translations.qrc → i18n


BIN
icons/DupFind.ico


+ 1 - 0
include/ResultListModel.hpp

@@ -35,6 +35,7 @@ public:
 
     const std::unordered_map<std::string, bool>& getCheckStates() const;
     QPixmap getThumbnail(const std::string& path) const;
+    void addThumbnail(const std::string& path, const QImage& image);
 
 private:
     void requestThumbnail(const std::string& path) const;

+ 7 - 0
src/MainWindow.cpp

@@ -1,5 +1,6 @@
 #include "MainWindow.hpp"
 #include "ImageHasher.hpp"
+#include <opencv2/imgproc.hpp>
 #include <QDateTime>
 #include <QDir>
 #include <QDirIterator>
@@ -771,6 +772,12 @@ void MainWindow::onUrlDownloadFinished(QNetworkReply *reply) {
   dropped.timestamp = QDateTime::currentSecsSinceEpoch();
   foundGroup.images.push_back(dropped);
 
+  // サムネイルをモデルに追加(URLパスだとQImageReaderで読めないため)
+  cv::Mat rgb;
+  cv::cvtColor(img, rgb, cv::COLOR_BGR2RGB);
+  QImage qimg(rgb.data, rgb.cols, rgb.rows, rgb.step, QImage::Format_RGB888);
+  m_model->addThumbnail(dropped.path, qimg.copy()); // copy to ensure data ownership
+
   for (const auto &cand : candidates) {
     bool match = false;
     if (m_strictMode) {

+ 7 - 0
src/ResultListModel.cpp

@@ -129,6 +129,13 @@ QPixmap ResultListModel::getThumbnail(const std::string& path) const {
     return QPixmap();
 }
 
+void ResultListModel::addThumbnail(const std::string& path, const QImage& image) {
+    if (!image.isNull()) {
+        m_thumbnails[path] = QPixmap::fromImage(image).scaled(150, 150, Qt::KeepAspectRatio, Qt::SmoothTransformation);
+        emitRowDataChangedForPath(path);
+    }
+}
+
 void ResultListModel::requestThumbnail(const std::string& path) const {
     if (m_loadingPaths.contains(path)) return;