37 |
38 |
38 @return string representing the error message |
39 @return string representing the error message |
39 """ |
40 """ |
40 return str(self.errorMessage) |
41 return str(self.errorMessage) |
41 |
42 |
|
43 |
42 class E5Action(QAction): |
44 class E5Action(QAction): |
43 """ |
45 """ |
44 Class implementing an Action class extending QAction. |
46 Class implementing an Action class extending QAction. |
45 """ |
47 """ |
46 def __init__(self, *args): |
48 def __init__(self, *args): |
47 """ |
49 """ |
48 Constructor |
50 Constructor |
49 |
51 |
50 @param args argument list of the constructor. This list is one of |
52 @param args argument list of the constructor. This list is one of |
51 <ul> |
53 <ul> |
52 <li>text (string), icon (QIcon), menu text (string), |
54 <li>text (string), icon (QIcon), menu text (string), |
53 accelarator (QKeySequence), alternative accelerator (QKeySequence), |
55 accelarator (QKeySequence), alternative accelerator (QKeySequence), |
54 parent (QObject), name (string), toggle (boolean)</li> |
56 parent (QObject), name (string), toggle (boolean)</li> |
55 <li>text (string), icon (QIcon), menu text (string), |
57 <li>text (string), icon (QIcon), menu text (string), |
56 accelarator (QKeySequence), alternative accelerator (QKeySequence), |
58 accelarator (QKeySequence), alternative accelerator (QKeySequence), |
57 parent (QObject), name (string)</li> |
59 parent (QObject), name (string)</li> |
58 <li>text (string), menu text (string), |
60 <li>text (string), menu text (string), |
59 accelarator (QKeySequence), alternative accelerator (QKeySequence), |
61 accelarator (QKeySequence), alternative accelerator (QKeySequence), |
60 parent (QObject), name (string), toggle (boolean)</li> |
62 parent (QObject), name (string), toggle (boolean)</li> |
61 <li>text (string), menu text (string), |
63 <li>text (string), menu text (string), |
62 accelarator (QKeySequence), alternative accelerator (QKeySequence), |
64 accelarator (QKeySequence), alternative accelerator (QKeySequence), |
63 parent (QObject), name (string)</li> |
65 parent (QObject), name (string)</li> |
64 </ul> |
66 </ul> |
65 """ |
67 """ |
66 if isinstance(args[1], QIcon): |
68 if isinstance(args[1], QIcon): |
67 icon = args[1] |
69 icon = args[1] |
68 incr = 1 |
70 incr = 1 |
69 else: |
71 else: |
70 icon = None |
72 icon = None |
71 incr = 0 |
73 incr = 0 |
72 if len(args) < 6+incr: |
74 if len(args) < 6 + incr: |
73 raise ArgumentsError( |
75 raise ArgumentsError( |
74 "Not enough arguments, {0:d} expected, got {1:d}".format( |
76 "Not enough arguments, {0:d} expected, got {1:d}".format( |
75 6 + incr, len(args))) |
77 6 + incr, len(args))) |
76 elif len(args) > 7+incr: |
78 elif len(args) > 7 + incr: |
77 raise ArgumentsError( |
79 raise ArgumentsError( |
78 "Too many arguments, max. {0:d} expected, got {1:d}".format( |
80 "Too many arguments, max. {0:d} expected, got {1:d}".format( |
79 7 + incr, len(args))) |
81 7 + incr, len(args))) |
80 |
82 |
81 parent = args[4+incr] |
83 parent = args[4 + incr] |
82 QAction.__init__(self, parent) |
84 QAction.__init__(self, parent) |
83 name = args[5+incr] |
85 name = args[5 + incr] |
84 if name: |
86 if name: |
85 self.setObjectName(name) |
87 self.setObjectName(name) |
86 |
88 |
87 if args[1+incr]: |
89 if args[1 + incr]: |
88 self.setText(args[1+incr]) |
90 self.setText(args[1 + incr]) |
89 |
91 |
90 if args[0]: |
92 if args[0]: |
91 self.setIconText(args[0]) |
93 self.setIconText(args[0]) |
92 if args[2+incr]: |
94 if args[2 + incr]: |
93 self.setShortcut(QKeySequence(args[2+incr])) |
95 self.setShortcut(QKeySequence(args[2 + incr])) |
94 |
96 |
95 if args[3+incr]: |
97 if args[3 + incr]: |
96 self.setAlternateShortcut(QKeySequence(args[3+incr])) |
98 self.setAlternateShortcut(QKeySequence(args[3 + incr])) |
97 |
99 |
98 if icon: |
100 if icon: |
99 self.setIcon(icon) |
101 self.setIcon(icon) |
100 |
102 |
101 if len(args) == 7+incr: |
103 if len(args) == 7 + incr: |
102 self.setCheckable(args[6+incr]) |
104 self.setCheckable(args[6 + incr]) |
103 |
105 |
104 self.__ammendToolTip() |
106 self.__ammendToolTip() |
105 |
107 |
106 def setAlternateShortcut(self, shortcut): |
108 def setAlternateShortcut(self, shortcut): |
107 """ |
109 """ |