macos: Add a sidebar icon
authorJocelyn Turcotte <jturcotte@woboq.com>
Fri, 28 Jul 2017 15:51:52 +0000 (17:51 +0200)
committerJocelyn Turcotte <jturcotte@woboq.com>
Mon, 31 Jul 2017 16:43:47 +0000 (18:43 +0200)
In the process, use an iconset to generate the icns using iconutil.
Also add some missing icon resolutions according to the guidelines.

Issue #296

cmake/modules/AddAppIconMacro.cmake
src/gui/CMakeLists.txt
theme/colored/owncloud-icon-1024.png [new file with mode: 0644]
theme/colored/owncloud-icon-16.png [new file with mode: 0644]
theme/colored/owncloud-sidebar-16.png [new file with mode: 0644]
theme/colored/owncloud-sidebar-18.png [new file with mode: 0644]
theme/colored/owncloud-sidebar-32.png [new file with mode: 0644]
theme/colored/owncloud-sidebar-36.png [new file with mode: 0644]
theme/colored/owncloud-sidebar-64.png [new file with mode: 0644]

index 3106b1bfaefe8230b8eb64a489e084d8cdd99577..dc833bd9d9329a02777e89caba77c4d588646ecf 100644 (file)
@@ -70,45 +70,64 @@ macro (KDE4_ADD_APP_ICON appsources pattern)
         endif(PNG2ICO_EXECUTABLE AND WINDRES_EXECUTABLE)
     endif(WIN32)
     if (APPLE)
-        # first convert image to a tiff using the Mac OS X "sips" utility,
-        # then use tiff2icns to convert to an icon
-        find_program(SIPS_EXECUTABLE NAMES sips)
-        find_program(TIFF2ICNS_EXECUTABLE NAMES tiff2icns)
-        if (SIPS_EXECUTABLE AND TIFF2ICNS_EXECUTABLE)
-            file(GLOB_RECURSE files  "${pattern}")
-            # we can only test for the 128-icon like that - we don't use patterns anymore
-            foreach (it ${files})
-                if (it MATCHES ".*128.*" )
-                    set (_icon ${it})
-                endif (it MATCHES ".*128.*")
-            endforeach (it)
+        file(GLOB_RECURSE files "${pattern}")
+        file(MAKE_DIRECTORY ${appsources}.iconset)
 
-            if (_icon)
-                
-                # first, get the basename of our app icon
-                add_custom_command(OUTPUT ${_outfilename}.icns ${outfilename}.tiff
-                                   COMMAND ${SIPS_EXECUTABLE} -s format tiff ${_icon} --out ${outfilename}.tiff
-                                   COMMAND ${TIFF2ICNS_EXECUTABLE} ${outfilename}.tiff ${_outfilename}.icns
-                                   DEPENDS ${_icon}
-                                   )
+        # List from:
+        # https://developer.apple.com/library/content/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/Optimizing/Optimizing.html#//apple_ref/doc/uid/TP40012302-CH7-SW4
+        foreach (it ${files})
+            if (it MATCHES ".*icon-16.*")
+                configure_file(${it} ${appsources}.iconset/icon_16x16.png COPYONLY)
+            elseif (it MATCHES ".*icon-32.*")
+                configure_file(${it} ${appsources}.iconset/icon_16x16@2x.png COPYONLY)
+                configure_file(${it} ${appsources}.iconset/icon_32x32.png COPYONLY)
+            elseif (it MATCHES ".*icon-64.*")
+                configure_file(${it} ${appsources}.iconset/icon_32x32@2x.png COPYONLY)
+            elseif (it MATCHES ".*icon-128.*")
+                configure_file(${it} ${appsources}.iconset/icon_128x128.png COPYONLY)
+            elseif (it MATCHES ".*icon-256.*")
+                configure_file(${it} ${appsources}.iconset/icon_128x128@2x.png COPYONLY)
+                configure_file(${it} ${appsources}.iconset/icon_256x256.png COPYONLY)
+            elseif (it MATCHES ".*icon-512.*")
+                configure_file(${it} ${appsources}.iconset/icon_256x256@2x.png COPYONLY)
+                configure_file(${it} ${appsources}.iconset/icon_512x512.png COPYONLY)
+            elseif (it MATCHES ".*icon-1024.*")
+                configure_file(${it} ${appsources}.iconset/icon_512x512@2x.png COPYONLY)
+            endif()
+        endforeach (it)
 
-                # This will register the icon into the bundle
-                set(MACOSX_BUNDLE_ICON_FILE ${appsources}.icns)
+        # Copy the sidebar icons in the main app bundle for the FinderSync extension to pick.
+        # https://developer.apple.com/library/content/documentation/General/Conceptual/ExtensibilityPG/Finder.html#//apple_ref/doc/uid/TP40014214-CH15-SW15
+        foreach (it ${files})
+            if (it MATCHES ".*sidebar-16.*")
+                configure_file(${it} ${appsources}.iconset/sidebar_16x16.png COPYONLY)
+            elseif (it MATCHES ".*sidebar-18.*")
+                configure_file(${it} ${appsources}.iconset/sidebar_18x18.png COPYONLY)
+            elseif (it MATCHES ".*sidebar-32.*")
+                configure_file(${it} ${appsources}.iconset/sidebar_16x16@2x.png COPYONLY)
+                configure_file(${it} ${appsources}.iconset/sidebar_32x32.png COPYONLY)
+            elseif (it MATCHES ".*sidebar-36.*")
+                configure_file(${it} ${appsources}.iconset/sidebar_18x18@2x.png COPYONLY)
+            elseif (it MATCHES ".*sidebar-64.*")
+                configure_file(${it} ${appsources}.iconset/sidebar_32x32@2x.png COPYONLY)
+            endif()
+        endforeach (it)
 
-                # Append the icns file to the sources list so it will be a dependency to the
-                # main target
-                list(APPEND ${appsources} ${_outfilename}.icns)
+        add_custom_command(OUTPUT ${_outfilename}.icns
+                           COMMAND echo === Building bundle icns with iconset:
+                           COMMAND ls -1 ${appsources}.iconset
+                           COMMAND iconutil -c icns -o ${_outfilename}.icns ${appsources}.iconset
+                           DEPENDS ${files}
+                           )
 
-                # Install the icon into the Resources dir in the bundle
-                set_source_files_properties(${_outfilename}.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
+        # This will register the icon into the bundle
+        set(MACOSX_BUNDLE_ICON_FILE ${appsources}.icns)
 
-            else(_icon)
-                # TODO - try to scale a non-128 icon...? Try to convert an SVG on the fly?
-                message(STATUS "Unable to find an 128x128 icon that matches pattern ${pattern} for variable ${appsources} - application will not have an application icon!")
-            endif(_icon)
+        # Append the icns file to the sources list so it will be a dependency to the
+        # main target
+        list(APPEND ${appsources} ${_outfilename}.icns)
 
-        else(SIPS_EXECUTABLE AND TIFF2ICNS_EXECUTABLE)
-            message(STATUS "Unable to find the sips and tiff2icns utilities - application will not have an application icon!")
-        endif(SIPS_EXECUTABLE AND TIFF2ICNS_EXECUTABLE)
+        # Install the icon into the Resources dir in the bundle
+        set_source_files_properties(${_outfilename}.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
     endif(APPLE)
 endmacro (KDE4_ADD_APP_ICON)
index 9011c07ab6e2aaab18b853d066f264e61e6c9561..2157d3cd6833b42d30f99ddc4d5042a14bb48d56 100644 (file)
@@ -232,7 +232,7 @@ if (NOT DEFINED APPLICATION_ICON_NAME)
     set(APPLICATION_ICON_NAME ${APPLICATION_SHORTNAME})
 endif()
 
-kde4_add_app_icon( ownCloud "${theme_dir}/colored/${APPLICATION_ICON_NAME}-icon*.png")
+kde4_add_app_icon( ownCloud "${theme_dir}/colored/${APPLICATION_ICON_NAME}-*.png")
 list(APPEND final_src ${ownCloud})
 set(ownCloud ${ownCloud_old})
 
diff --git a/theme/colored/owncloud-icon-1024.png b/theme/colored/owncloud-icon-1024.png
new file mode 100644 (file)
index 0000000..e32847c
Binary files /dev/null and b/theme/colored/owncloud-icon-1024.png differ
diff --git a/theme/colored/owncloud-icon-16.png b/theme/colored/owncloud-icon-16.png
new file mode 100644 (file)
index 0000000..5c01c4f
Binary files /dev/null and b/theme/colored/owncloud-icon-16.png differ
diff --git a/theme/colored/owncloud-sidebar-16.png b/theme/colored/owncloud-sidebar-16.png
new file mode 100644 (file)
index 0000000..5c01c4f
Binary files /dev/null and b/theme/colored/owncloud-sidebar-16.png differ
diff --git a/theme/colored/owncloud-sidebar-18.png b/theme/colored/owncloud-sidebar-18.png
new file mode 100644 (file)
index 0000000..bff6175
Binary files /dev/null and b/theme/colored/owncloud-sidebar-18.png differ
diff --git a/theme/colored/owncloud-sidebar-32.png b/theme/colored/owncloud-sidebar-32.png
new file mode 100644 (file)
index 0000000..721c04e
Binary files /dev/null and b/theme/colored/owncloud-sidebar-32.png differ
diff --git a/theme/colored/owncloud-sidebar-36.png b/theme/colored/owncloud-sidebar-36.png
new file mode 100644 (file)
index 0000000..27e415d
Binary files /dev/null and b/theme/colored/owncloud-sidebar-36.png differ
diff --git a/theme/colored/owncloud-sidebar-64.png b/theme/colored/owncloud-sidebar-64.png
new file mode 100644 (file)
index 0000000..5c6f17f
Binary files /dev/null and b/theme/colored/owncloud-sidebar-64.png differ