3 # This script scans the Quassel source for requested icons and imports the needed
4 # icons (and only them) from KDE's Oxygen theme.
5 # This relies on all icons being requested using one of the convenience constructors in
6 # (K)IconLoader, like this:
7 # widget->setIcon(SmallIcon("fubar"));
8 # Additional icons can be specified in extra-icons; you can also blacklist icons.
10 # NOTE: Unless you are a Quassel developer and need to bump the icons we ship, you shouldn'y
11 # need to use this script!
13 # USAGE: ./import/import_oxygen.pl $systhemefolder
14 # Run from the icon/ directory.
22 my $source = "../src";
23 my $output = "oxygen";
24 my $qrcfile_kde = "oxygen.qrc";
26 my $extrafile = "import/extra-icons";
27 my $blacklistfile = "import/blacklisted-icons";
34 # First, load the icon blacklist
35 open BLACKLIST, "<$blacklistfile" or die "Could not open $blacklistfile\n";
38 next unless my ($name) = /([-\w]+)\s*/;
39 $blacklist{$name} = 1;
43 # We now grep the source for things like SmallIcon("fubar") and generate size and name from that
44 print "Grepping $source for requested icons...\n";
45 my @results = `grep -r QIcon::fromTheme\\(\\" $source`;
47 next unless my ($name) = /\W+QIcon::fromTheme\(\"([-\w]+)/;
49 unless exists $blacklist{$name};
53 open EXTRA, "<$extrafile" or die "Could not open $extrafile\n";
56 next unless my ($name) = /([-\w]+)\s*/;
57 $req_icons{$name} = 1;
61 # Clean old output dir
62 print "Removing old $output...\n";
63 system("rm -rf $output");
68 print "Copying icons from $oxygen...\n";
69 opendir (BASEDIR, "$oxygen") or die "Could not open oxygen basedir\n";
70 foreach my $sizestr (readdir BASEDIR) {
71 next unless $sizestr =~ /\d+x\d+/;
72 opendir (SIZEDIR, "$oxygen/$sizestr") or die "Could not open dir $sizestr\n";
73 foreach my $cat (readdir SIZEDIR) {
74 next if $cat eq '.' or $cat eq '..';
75 #system "mkdir -p $output/$sizestr/$cat" and die "Could not create category dir\n";
76 system "mkdir -p $output/scalable/$cat" and die "Could not create category dir\n";
77 opendir (CATDIR, "$oxygen/$sizestr/$cat") or die "Could not open category dir\n";
78 foreach my $icon (readdir CATDIR) {
80 next unless exists $req_icons{$icon};
81 $scalables{$cat}{$icon} = 1;
82 system "mkdir -p $output/$sizestr/$cat" and die "Could not create category dir\n";
83 system "cp -a $oxygen/$sizestr/$cat/$icon.png $output/$sizestr/$cat"
84 and die "Error while copying file $sizestr/$cat/$icon.png\n";
85 #print "Copy: $oxygen/$sizestr/$cat/$icon.png\n";
86 $found_icons{$icon} = 1;
95 foreach my $cat (keys %scalables) {
96 system "mkdir -p $output/scalable/$cat" and die "Could not create category dir\n";
97 foreach my $scalable (keys %scalables{$cat}) {
98 system "cp -a $oxygen/scalable/$cat/$scalable.svgz $output/scalable/$cat/$scalable.svgz";
102 # Warn if we have still icons left
103 foreach my $icon (keys %req_icons) {
104 next if defined $found_icons{$icon};
105 print "Warning: Missing icon $icon\n";
110 generate_qrc($output, $qrcfile_kde);
113 system "cp $oxygen/AUTHORS $oxygen/CONTRIBUTING $oxygen/COPYING $oxygen/index.theme $output/";
117 ########################################################################################
123 find(\&push_icon_path, $dir);
124 my $files = join "\n", @file_list;
127 ." <qresource prefix=\"/icons\">\n"
132 open QRC, ">$qrcfile" or die "Could not open $qrcfile for writing!\n";
138 return unless /\.png$/;
140 push @file_list, " <file>$File::Find::name</file>";