File indexing completed on 2024-04-14 05:35:06

0001 #!/usr/bin/perl -w
0002 
0003 # Laurent Montel <montel@kde.org> (2014)
0004 # KIcon("...") => QIcon::fromTheme(QStringLiteral("..."))
0005 # find -iname "*.cpp" -o -iname "*.h"|xargs kde-dev-scripts/kf5/convert-kicon.pl
0006 
0007 use strict;
0008 use File::Basename;
0009 use lib dirname($0);
0010 use functionUtilkde;
0011 
0012 foreach my $file (@ARGV) {
0013 
0014     my $modified;
0015     open(my $FILE, "<", $file) or warn "We can't open file $file:$!\n";
0016     my @l = map {
0017         my $orig = $_;
0018         if (/KIcon\(\s*\)/ ) {
0019            s/KIcon\(\s*\)/QIcon()/;
0020         }
0021         s/\bKIcon\b\s*\(\s*(\"[^\"]*\")\s*\)/QIcon::fromTheme(QStringLiteral($1))/g;
0022         s/\bQIcon::fromTheme\b\s*\(\s*(\"[^\"]*\")\s*\)/QIcon::fromTheme(QStringLiteral($1))/g;
0023 
0024         s/\bKIcon\b\s*\(/QIcon::fromTheme(/g;
0025         s/\<KIcon\b\>/\<QIcon>/ =~ /#include/ ;
0026         s/\<kicon.h\b\>/\<QIcon>/ =~ /#include/ ;
0027 
0028         $modified ||= $orig ne $_;
0029         $_;
0030     } <$FILE>;
0031 
0032     if ($modified) {
0033         open (my $OUT, ">", $file);
0034         print $OUT @l;
0035         close ($OUT);
0036     }
0037 }
0038 
0039 functionUtilkde::diffFile( "@ARGV" );