11from krita import *
2- from PyQt5 import uic
2+ try :
3+ from PyQt6 import uic
4+ except :
5+ from PyQt5 import uic
36import re
47import os
58import subprocess
@@ -37,7 +40,7 @@ def doneClicked(self):
3740 data = {}
3841 for row in range (0 ,self .model .rowCount ()):
3942 index = self .model .index (row ,0 )
40- rec = index .data (Qt .UserRole + 1 )
43+ rec = index .data (Qt .ItemDataRole . UserRole + 1 )
4144 if rec ['category' ] not in data :
4245 data [rec ['category' ]]= { 'text' :rec ['categoryText' ], 'actions' :[] }
4346 newRec = {}
@@ -56,18 +59,18 @@ def newItem(self, name=None, data=None):
5659 if not data :
5760 data = self .defaultForm
5861 item = QStandardItem (name )
59- item .setData (data , Qt .UserRole + 1 )
62+ item .setData (data , Qt .ItemDataRole . UserRole + 1 )
6063 self .model .appendRow (item )
6164 index = self .model .indexFromItem (item )
62- self .centralWidget .listView .selectionModel ().select (index , QtCore .QItemSelectionModel .ClearAndSelect )
65+ self .centralWidget .listView .selectionModel ().select (index , QtCore .QItemSelectionModel .SelectionFlag . ClearAndSelect )
6366 def deleteItem (self ):
6467 items = self .centralWidget .listView .selectionModel ().selectedIndexes ()
6568 for item in items :
6669 self .model .removeRow (item .row (),item .parent ())
6770 def openItem (self , old , new ):
6871 items = self .centralWidget .listView .selectionModel ().selectedIndexes ()
6972 for item in items :
70- data = item .data (Qt .UserRole + 1 )
73+ data = item .data (Qt .ItemDataRole . UserRole + 1 )
7174 print ("open form" , data )
7275 if data :
7376 self .loadForm (self .centralWidget , data )
@@ -78,8 +81,8 @@ def saveItem(self):
7881 self .saveForm (self .centralWidget , data )
7982 print ("SAVE" , data , item )
8083
81- self .model .setData (item ,data , Qt .UserRole + 1 )
82- self .model .setData (item ,data ['action.name' ], Qt .DisplayRole )
84+ self .model .setData (item ,data , Qt .ItemDataRole . UserRole + 1 )
85+ self .model .setData (item ,data ['action.name' ], Qt .ItemDataRole . DisplayRole )
8386 self .defaultForm ['category' ]= data ['category' ]
8487 self .defaultForm ['categoryText' ]= data ['categoryText' ]
8588
@@ -104,7 +107,7 @@ def loadForm(self, form, items):
104107 w .setCurrentIndex (w .findText (v ))
105108 elif isinstance (w ,QListView ) and w .model ():
106109 index = w .model ().match (w .model ().index (0 , 0 ),
107- Qt .DisplayRole ,
110+ Qt .ItemDataRole . DisplayRole ,
108111 v ,
109112 1 );
110113 items [name ]= w .setCurrentIndex (index )
@@ -127,7 +130,7 @@ def saveForm(self, form, items):
127130 else :
128131 items [name ]= w .currentText ()
129132 elif isinstance (w ,QListView ) and w .model ():
130- items [name ]= w .currentIndex ().data (Qt .DisplayRole )
133+ items [name ]= w .currentIndex ().data (Qt .ItemDataRole . DisplayRole )
131134
132135
133136 def getData (self , data ):
@@ -384,7 +387,7 @@ def gitRemotePath(self):
384387
385388
386389 def projectPath (self ):
387- destDir = QFileDialog .getExistingDirectory (None , 'Select Project Directory' ,QDir .homePath (), QFileDialog .ShowDirsOnly )
390+ destDir = QFileDialog .getExistingDirectory (None , 'Select Project Directory' ,QDir .homePath (), QFileDialog .Option . ShowDirsOnly )
388391 self .centralWidget .projectPathLabel .setText (destDir )
389392
390393 def writeToFile (self ,path ,s ):
@@ -406,9 +409,9 @@ def downloadKritaAPI(self):
406409
407410 if os .path .isfile (respath + ".KritaAPI." + ver + ".zip" ):
408411 return True
409- msgbox = QMessageBox (QMessageBox .Question ,'Would you like to download the API details automatically?' ,
410- '' , QMessageBox .Yes | QMessageBox .No )
411- msgbox .setTextFormat (Qt .RichText )
412+ msgbox = QMessageBox (QMessageBox .Icon . Question ,'Would you like to download the API details automatically?' ,
413+ '' , QMessageBox .StandardButton . Yes | QMessageBox . StandardButton .No )
414+ msgbox .setTextFormat (Qt .TextFormat . RichText )
412415
413416 msgbox .setText ("""Developer Tools would like to connect to the internet to download Krita API details.
414417This process will only access Krita's offical git repository at invent.kde.org.
@@ -426,23 +429,23 @@ def downloadKritaAPI(self):
426429Would you like to download the API details(less than 200kb of data) automatically?
427430""" )
428431
429- if msgbox .exec () == QMessageBox .Yes :
432+ if msgbox .exec () == QMessageBox .StandardButton . Yes :
430433 getAPI = GetKritaAPI ()
431434 res = {}
432435 try :
433436 res = getAPI .updateData (ver )
434437 except :
435- QMessageBox (QMessageBox .Warning ,'Failed!' , "Failed to download API details! Make sure you have internet connection and your python urlib ssl is working properly" ).exec ()
438+ QMessageBox (QMessageBox .Icon . Warning ,'Failed!' , "Failed to download API details! Make sure you have internet connection and your python urlib ssl is working properly" ).exec ()
436439 return False
437440 print ("RES" , res )
438441
439442 if res ['status' ] == 0 :
440- msgbox = QMessageBox (QMessageBox .Warning ,'Error' ,str (res ['error' ]))
443+ msgbox = QMessageBox (QMessageBox .Icon . Warning ,'Error' ,str (res ['error' ]))
441444
442445 msgbox .exec ()
443446 return False
444447 else :
445- QMessageBox (QMessageBox .Information ,'Success!' , "API details have been downloaded successfully!" ).exec ()
448+ QMessageBox (QMessageBox .Icon . Information ,'Success!' , "API details have been downloaded successfully!" ).exec ()
446449 else :
447450 return False
448451
0 commit comments