877 |
880 |
878 lbuf = "" |
881 lbuf = "" |
879 |
882 |
880 return False |
883 return False |
881 |
884 |
882 def compileChangedResources(self): |
885 def __compileChangedResources(self): |
883 """ |
886 """ |
884 Public method to compile all changed resources to source files. |
887 Private method to compile all changed resources to source files. |
885 """ |
888 """ |
886 if self.hooks["compileChangedResources"] is not None: |
889 if Preferences.getProject("AutoCompileResources"): |
887 self.hooks["compileChangedResources"]( |
890 if self.hooks["compileChangedResources"] is not None: |
888 self.project.getProjectData(dataKey="RESOURCES") |
891 self.hooks["compileChangedResources"]( |
889 ) |
892 self.project.getProjectData(dataKey="RESOURCES") |
890 else: |
893 ) |
891 if len(self.project.getProjectData(dataKey="RESOURCES")) == 0: |
894 else: |
892 # The project does not contain resource files |
895 if len(self.project.getProjectData(dataKey="RESOURCES")) == 0: |
893 return |
896 # The project does not contain resource files |
894 |
897 return |
895 progress = EricProgressDialog( |
898 |
896 self.tr("Determining changed resources..."), |
899 progress = EricProgressDialog( |
897 self.tr("Abort"), |
900 self.tr("Determining changed resources..."), |
898 0, |
901 self.tr("Abort"), |
899 100, |
902 0, |
900 self.tr("%v/%m Resources"), |
903 100, |
901 self, |
904 self.tr("%v/%m Resources"), |
902 ) |
905 self, |
903 progress.setMinimumDuration(0) |
906 ) |
904 progress.setWindowTitle(self.tr("Resources")) |
907 progress.setMinimumDuration(0) |
905 |
908 progress.setWindowTitle(self.tr("Resources")) |
906 # get list of changed resources |
909 |
907 changedResources = [] |
910 # get list of changed resources |
908 progress.setMaximum(len(self.project.getProjectData(dataKey="RESOURCES"))) |
911 changedResources = [] |
909 for prog, fn in enumerate(self.project.getProjectData(dataKey="RESOURCES")): |
912 progress.setMaximum( |
910 progress.setValue(prog) |
913 len(self.project.getProjectData(dataKey="RESOURCES")) |
|
914 ) |
|
915 for prog, fn in enumerate( |
|
916 self.project.getProjectData(dataKey="RESOURCES") |
|
917 ): |
|
918 progress.setValue(prog) |
|
919 QApplication.processEvents() |
|
920 ifn = os.path.join(self.project.ppath, fn) |
|
921 if self.project.getProjectLanguage() == "Python3": |
|
922 dirname, filename = os.path.split(os.path.splitext(ifn)[0]) |
|
923 ofn = os.path.join( |
|
924 dirname, self.RCFilenameFormatPython.format(filename) |
|
925 ) |
|
926 elif self.project.getProjectLanguage() == "Ruby": |
|
927 dirname, filename = os.path.split(os.path.splitext(ifn)[0]) |
|
928 ofn = os.path.join( |
|
929 dirname, self.RCFilenameFormatRuby.format(filename) |
|
930 ) |
|
931 else: |
|
932 return |
|
933 if ( |
|
934 not os.path.exists(ofn) |
|
935 or os.stat(ifn).st_mtime > os.stat(ofn).st_mtime |
|
936 or self.__checkResourcesNewer(ifn, os.stat(ofn).st_mtime) |
|
937 ): |
|
938 changedResources.append(fn) |
|
939 progress.setValue(len(self.project.getProjectData(dataKey="RESOURCES"))) |
911 QApplication.processEvents() |
940 QApplication.processEvents() |
912 ifn = os.path.join(self.project.ppath, fn) |
941 |
913 if self.project.getProjectLanguage() == "Python3": |
942 if changedResources: |
914 dirname, filename = os.path.split(os.path.splitext(ifn)[0]) |
943 progress.setLabelText(self.tr("Compiling changed resources...")) |
915 ofn = os.path.join( |
944 progress.setMaximum(len(changedResources)) |
916 dirname, self.RCFilenameFormatPython.format(filename) |
945 progress.setValue(0) |
917 ) |
946 QApplication.processEvents() |
918 elif self.project.getProjectLanguage() == "Ruby": |
947 for prog, fn in enumerate(changedResources): |
919 dirname, filename = os.path.split(os.path.splitext(ifn)[0]) |
948 progress.setValue(prog) |
920 ofn = os.path.join( |
949 if progress.wasCanceled(): |
921 dirname, self.RCFilenameFormatRuby.format(filename) |
950 break |
922 ) |
951 proc = self.__compileQRC(fn, True, progress) |
923 else: |
952 if proc is not None: |
924 return |
953 while proc.state() == QProcess.ProcessState.Running: |
925 if ( |
954 QThread.msleep(100) |
926 not os.path.exists(ofn) |
955 QApplication.processEvents() |
927 or os.stat(ifn).st_mtime > os.stat(ofn).st_mtime |
956 else: |
928 or self.__checkResourcesNewer(ifn, os.stat(ofn).st_mtime) |
957 break |
929 ): |
958 progress.setValue(len(changedResources)) |
930 changedResources.append(fn) |
959 QApplication.processEvents() |
931 progress.setValue(len(self.project.getProjectData(dataKey="RESOURCES"))) |
|
932 QApplication.processEvents() |
|
933 |
|
934 if changedResources: |
|
935 progress.setLabelText(self.tr("Compiling changed resources...")) |
|
936 progress.setMaximum(len(changedResources)) |
|
937 progress.setValue(0) |
|
938 QApplication.processEvents() |
|
939 for prog, fn in enumerate(changedResources): |
|
940 progress.setValue(prog) |
|
941 if progress.wasCanceled(): |
|
942 break |
|
943 proc = self.__compileQRC(fn, True, progress) |
|
944 if proc is not None: |
|
945 while proc.state() == QProcess.ProcessState.Running: |
|
946 QThread.msleep(100) |
|
947 QApplication.processEvents() |
|
948 else: |
|
949 break |
|
950 progress.setValue(len(changedResources)) |
|
951 QApplication.processEvents() |
|
952 |
960 |
953 def handlePreferencesChanged(self): |
961 def handlePreferencesChanged(self): |
954 """ |
962 """ |
955 Public slot used to handle the preferencesChanged signal. |
963 Public slot used to handle the preferencesChanged signal. |
956 """ |
964 """ |