def getObject(self): if self._o: return self._o self._o = QtCore.QObject() self._o.setObjectName("PySideObject") return self._o
def get_service_display_name(service): """ Returns the name to display of the given service. If there is no configured name for that service, then returns the same parameter :param service: the 'machine' service name :type service: str :rtype: str """ # qt translator method helper _tr = QtCore.QObject().tr # Correspondence for services and their name to display EIP_LABEL = _tr("Encrypted Internet") MX_LABEL = _tr("Encrypted Mail") service_display = { "openvpn": EIP_LABEL, "mx": MX_LABEL } # If we need to add a warning about eip needing # administrative permissions to start. That can be either # because we are running in standalone mode, or because we could # not find the needed privilege escalation mechanisms being operative. if flags.STANDALONE or is_missing_policy_permissions(): EIP_LABEL += " " + _tr("(will need admin password to start)") return service_display.get(service, service)
def populateList(self, lst): o = QtCore.QObject() o.setObjectName("obj") item = QtGui.QListWidgetItem("item0") item.setData(QtCore.Qt.UserRole, o) #item._data = o self.assert_(sys.getrefcount(o), 3) self.assert_(sys.getrefcount(item), 2) lst.addItem(item) self.assert_(sys.getrefcount(item), 3)
def username_checks(username): # translation helper _tr = QtCore.QObject().tr message = None if message is None and len(username) < 2: message = _tr("Username must have at least 2 characters") valid = USERNAME_VALIDATOR.validate(username, 0) valid_username = valid[0] == QtGui.QValidator.State.Acceptable if message is None and not valid_username: message = _tr("That username is not allowed. Try another.") return message is None, message
def _get_missing_complain_dialog(stuff): """ Create a dialog for notifying about missing helpers (but doing nothing). Used from non-standalone runs. :param stuff: list of missing items to display :type stuff: list :rtype: QtGui.QMessageBox instance """ msgstr = QtCore.QObject() msgstr.NO_HELPERS = msgstr.tr( "Some essential helper files are missing in your system.") msgstr.EXPLAIN = msgstr.tr( "Reinstall your debian packages, or make sure you place them by hand.") class ComplainDialog(QtGui.QDialog): def __init__(self, parent=None): super(ComplainDialog, self).__init__(parent) label = QtGui.QLabel(msgstr.NO_HELPERS) label.setAlignment(QtCore.Qt.AlignLeft) label2 = QtGui.QLabel(msgstr.EXPLAIN) label2.setAlignment(QtCore.Qt.AlignLeft) textedit = QtGui.QTextEdit() textedit.setText("\n".join(stuff)) ok = QtGui.QPushButton() ok.setText(self.tr("Ok, thanks")) self.ok = ok self.ok.clicked.connect(self.close) mainLayout = QtGui.QGridLayout() mainLayout.addWidget(label, 0, 0) mainLayout.addWidget(label2, 1, 0) mainLayout.addWidget(textedit, 2, 0) mainLayout.addWidget(ok, 3, 0) self.setLayout(mainLayout) msg = ComplainDialog() msg.setWindowTitle(msg.tr("Missing Bitmask helper files")) return msg
def password_checks(username, password, password2): """ Performs basic password checks to avoid really easy passwords. :param username: username provided at the registrarion form :type username: str :param password: password from the registration form :type password: str :param password2: second password from the registration form :type password: str :returns: (True, None, None) if all the checks pass, (False, message, field name) otherwise :rtype: tuple(bool, str, str) """ # translation helper _tr = QtCore.QObject().tr message = None field = None if message is None and password != password2: message = _tr("Passwords don't match") field = 'new_password_confirmation' if message is None and not password: message = _tr("Password is empty") field = 'new_password' if message is None and len(password) < 8: message = _tr("Password is too short") field = 'new_password' if message is None and password in WEAK_PASSWORDS: message = _tr("Password is too easy") field = 'new_password' if message is None and username == password: message = _tr("Password can't be the same as username") field = 'new_password' return message is None, message, field
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. """ Abstract LEAP connections. """ # TODO use zope.interface instead from abc import ABCMeta from PySide import QtCore from leap.common.check import leap_assert _tr = QtCore.QObject().tr class State(object): """ Abstract state class """ __metaclass__ = ABCMeta label = None short_label = None """ The different services should declare a ServiceConnection class that inherits from AbstractLEAPConnection, so an instance of such class can be used to inform the StateMachineBuilder of the particularities
def testGet(self): o = QtCore.QObject() setValue(o) self.assertEqual(o.property('test1'), ['Name'])
def __init__(self, main): self.main = main self.specs = [] self.spec_widgets = [] self.context = QtCore.QObject() self.dataSourceFactory = DataSourceFactory(self.context)
def generate_ui(self): #-------------------------------------------------------- #---- menuBar self.aboutAction = QtWidgets.QAction(u'About', QtCore.QObject(parent=self)) self.helpMenu = QtWidgets.QMenu('Help') self.helpMenu.addAction(self.aboutAction) self.menuBar = QtWidgets.QMenuBar() self.menuBar.addMenu(self.helpMenu) self.setMenuBar(self.menuBar) #-------------------------------------------------------- #---- toolBar self.tools = QtWidgets.QToolBar('tools') self.tools.setMovable(False) self.advMerge = QtWidgets.QAction(u'Advanced Merge', QtCore.QObject(parent=self)) self.addKey = QtWidgets.QAction(u'Additive Keyer', QtCore.QObject(parent=self)) self.addInvert = QtWidgets.QAction(u'Additive Inverse', QtCore.QObject(parent=self)) self.chromaBlur = QtWidgets.QAction(u'Chroma Blur', QtCore.QObject(parent=self)) self.colorDilate = QtWidgets.QAction(u'Color Dilate', QtCore.QObject(parent=self)) self.contrast = QtWidgets.QAction(u'Contrast', QtCore.QObject(parent=self)) self.ioGraph = QtWidgets.QAction(u"I/O Graph", QtCore.QObject(parent=self)) self.lift = QtWidgets.QAction(u'Lift', QtCore.QObject(parent=self)) self.multKey = QtWidgets.QAction(u'Multiplicative Keyer', QtCore.QObject(parent=self)) self.multInvert = QtWidgets.QAction(u'Multiplicative Inverse', QtCore.QObject(parent=self)) self.saturate = QtWidgets.QAction(u'Saturation', QtCore.QObject(parent=self)) self.saturate.setIcon(QtGui.QPixmap(":qrc/images/ToolbarImage.png")) self.toe = QtWidgets.QAction(u'Toe', QtCore.QObject(parent=self)) self.imageBtn = QtWidgets.QToolButton(parent=self) self.imageBtn.setToolTip('Image') #self.imageBtn.setPopupMode(QtWidgets.QToolButton.InstantPopup) self.imageBtn.setIcon(QtGui.QPixmap(":qrc/images/ToolbarImage.png")) self.imageMenu = QtWidgets.QMenu() self.imageBtn.setMenu(self.imageMenu) self.colorBtn = QtWidgets.QToolButton(parent=self) self.colorBtn.setToolTip('Color') self.colorBtn.setPopupMode(QtWidgets.QToolButton.InstantPopup) self.colorBtn.setIcon(QtGui.QPixmap(":qrc/images/ToolbarColor.png")) self.colorMenu = QtWidgets.QMenu() self.mathMenu = QtWidgets.QMenu('Math') self.mathMenu.addAction(self.addInvert) self.mathMenu.addAction(self.ioGraph) self.mathMenu.addAction(self.multInvert) self.colorMenu.addMenu(self.mathMenu) self.colorMenu.addAction(self.contrast) self.colorMenu.addAction(self.lift) self.colorMenu.addAction(self.saturate) self.colorMenu.addAction(self.toe) self.colorBtn.setMenu(self.colorMenu) self.filterBtn = QtWidgets.QToolButton(parent=self) self.filterBtn.setToolTip('Filter') self.filterBtn.setPopupMode(QtWidgets.QToolButton.InstantPopup) self.filterBtn.setIcon(QtGui.QPixmap(":qrc/images/ToolbarFilter.png")) self.filterMenu = QtWidgets.QMenu() self.filterMenu.addAction(self.chromaBlur) self.filterMenu.addAction(self.colorDilate) self.filterBtn.setMenu(self.filterMenu) self.keyerBtn = QtWidgets.QToolButton(parent=self) self.keyerBtn.setToolTip('Keyer') self.keyerBtn.setPopupMode(QtWidgets.QToolButton.InstantPopup) self.keyerBtn.setIcon(QtGui.QPixmap(":qrc/images/ToolbarKeyer.png")) self.keyerMenu = QtWidgets.QMenu() self.keyerMenu.addAction(self.addKey) self.keyerMenu.addAction(self.multKey) self.keyerBtn.setMenu(self.keyerMenu) self.mergeBtn = QtWidgets.QToolButton(parent=self) self.mergeBtn.setToolTip('Merge') self.mergeBtn.setPopupMode(QtWidgets.QToolButton.InstantPopup) self.mergeBtn.setIcon(QtGui.QPixmap(":qrc/images/ToolbarMerge.png")) self.mergeMenu = QtWidgets.QMenu() self.mergeMenu.addAction(self.advMerge) self.mergeBtn.setMenu(self.mergeMenu) self.tools.addWidget(self.imageBtn) self.tools.addWidget(self.colorBtn) self.tools.addWidget(self.filterBtn) self.tools.addWidget(self.keyerBtn) self.tools.addWidget(self.mergeBtn) self.addToolBar(QtCore.Qt.ToolBarArea.LeftToolBarArea, self.tools) #-------------------------------------------------------- #---- statusBar self.statusBar = QtWidgets.QStatusBar() self.statusBar.showMessage('This is a test message!') self.setStatusBar(self.statusBar) #-------------------------------------------------------- #---- centralWidget self.centralWidget = QtWidgets.QWidget() #self.centralWidget.setBackgroundRole() self.centralLayout = QtWidgets.QVBoxLayout() self.b1=QtWidgets.QPushButton("hello world!") self.b2=QtWidgets.QPushButton("hello another world!") self.centralLayout.addWidget(self.b1) self.centralLayout.addWidget(self.b2) self.centralWidget.setLayout(self.centralLayout) self.setCentralWidget(self.centralWidget)
def testReference(self): o = QtCore.QObject() m = MyObject(o) self.assertEqual(sys.getrefcount(o), 3) del m self.assertEqual(sys.getrefcount(o), 2)