lock icon for the root password dialog

This commit is contained in:
Vinicius Moreira
2019-09-12 12:56:55 -03:00
parent 6c9098906d
commit 5a8a5e6cac
4 changed files with 155 additions and 13 deletions

View File

@@ -428,7 +428,7 @@ class ArchManager(SoftwareManager):
self._update_progress(handler.watcher, 70, change_progress)
if check_install_output and 'conflict' in check_install_output[-1]:
conflicting_apps = [w[0] for w in re.findall(r'((\w|\-|\.)+)\s(and|are)', check_install_output[-1])]
conflict_msg = ' {} '.format(self.i18n['and']).join(conflicting_apps)
conflict_msg = ' {} '.format(self.i18n['and']).join([bold(c) for c in conflicting_apps])
if not handler.watcher.request_confirmation(title=self.i18n['arch.install.conflict.popup.title'],
body=self.i18n['arch.install.conflict.popup.body'].format(conflict_msg)):
handler.watcher.print(self.i18n['action.cancelled'])

138
bauh/resources/img/lock.svg Executable file
View File

@@ -0,0 +1,138 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
id="Capa_1"
x="0px"
y="0px"
viewBox="0 0 37.125 49.5"
xml:space="preserve"
sodipodi:docname="lock.svg"
width="37.125"
height="49.5"
inkscape:version="0.92.4 5da689c313, 2019-01-14"><metadata
id="metadata937"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
id="defs935" /><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1366"
inkscape:window-height="739"
id="namedview933"
showgrid="false"
showborder="false"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:zoom="0.90509668"
inkscape:cx="43.828193"
inkscape:cy="29.206802"
inkscape:window-x="0"
inkscape:window-y="432"
inkscape:window-maximized="1"
inkscape:current-layer="Capa_1" />
<g
id="g951"><g
id="g943"
transform="matrix(0.09667969,0,0,0.09667969,-6.1875002,0)"
style="fill:#000000;stroke:#000000;stroke-width:9.77332354">
<g
id="g941"
style="fill:#000000;stroke:#000000;stroke-width:9.77332354">
<path
d="m 437.333,192 h -32 V 149.333 C 405.333,66.99 338.344,0 256,0 173.656,0 106.667,66.99 106.667,149.333 V 192 h -32 C 68.771,192 64,196.771 64,202.667 V 469.334 C 64,492.865 83.135,512 106.667,512 H 405.334 C 428.865,512 448,492.865 448,469.333 V 202.667 C 448,196.771 443.229,192 437.333,192 Z M 287.938,414.823 c 0.333,3.01 -0.635,6.031 -2.656,8.292 -2.021,2.26 -4.917,3.552 -7.948,3.552 h -42.667 c -3.031,0 -5.927,-1.292 -7.948,-3.552 -2.021,-2.26 -2.99,-5.281 -2.656,-8.292 l 6.729,-60.51 C 219.865,346.365 213.334,333.792 213.334,320 c 0,-23.531 19.135,-42.667 42.667,-42.667 23.532,0 42.667,19.135 42.667,42.667 0,13.792 -6.531,26.365 -17.458,34.313 z M 341.333,192 H 170.667 V 149.333 C 170.667,102.281 208.948,64 256,64 c 47.052,0 85.333,38.281 85.333,85.333 V 192 Z"
id="path939"
inkscape:connector-curvature="0"
style="fill:#000000;stroke:#000000;stroke-width:9.77332354" />
</g>
</g><g
style="fill:#ffcc00"
transform="matrix(0.09667969,0,0,0.09667969,-6.1875002,0)"
id="g900">
<g
style="fill:#ffcc00"
id="g898">
<path
style="fill:#ffcc00"
inkscape:connector-curvature="0"
id="path896"
d="m 437.333,192 h -32 V 149.333 C 405.333,66.99 338.344,0 256,0 173.656,0 106.667,66.99 106.667,149.333 V 192 h -32 C 68.771,192 64,196.771 64,202.667 V 469.334 C 64,492.865 83.135,512 106.667,512 H 405.334 C 428.865,512 448,492.865 448,469.333 V 202.667 C 448,196.771 443.229,192 437.333,192 Z M 287.938,414.823 c 0.333,3.01 -0.635,6.031 -2.656,8.292 -2.021,2.26 -4.917,3.552 -7.948,3.552 h -42.667 c -3.031,0 -5.927,-1.292 -7.948,-3.552 -2.021,-2.26 -2.99,-5.281 -2.656,-8.292 l 6.729,-60.51 C 219.865,346.365 213.334,333.792 213.334,320 c 0,-23.531 19.135,-42.667 42.667,-42.667 23.532,0 42.667,19.135 42.667,42.667 0,13.792 -6.531,26.365 -17.458,34.313 z M 341.333,192 H 170.667 V 149.333 C 170.667,102.281 208.948,64 256,64 c 47.052,0 85.333,38.281 85.333,85.333 V 192 Z" />
</g>
</g></g>
<g
id="g902"
transform="translate(-237.4375,-231.25)">
</g>
<g
id="g904"
transform="translate(-237.4375,-231.25)">
</g>
<g
id="g906"
transform="translate(-237.4375,-231.25)">
</g>
<g
id="g908"
transform="translate(-237.4375,-231.25)">
</g>
<g
id="g910"
transform="translate(-237.4375,-231.25)">
</g>
<g
id="g912"
transform="translate(-237.4375,-231.25)">
</g>
<g
id="g914"
transform="translate(-237.4375,-231.25)">
</g>
<g
id="g916"
transform="translate(-237.4375,-231.25)">
</g>
<g
id="g918"
transform="translate(-237.4375,-231.25)">
</g>
<g
id="g920"
transform="translate(-237.4375,-231.25)">
</g>
<g
id="g922"
transform="translate(-237.4375,-231.25)">
</g>
<g
id="g924"
transform="translate(-237.4375,-231.25)">
</g>
<g
id="g926"
transform="translate(-237.4375,-231.25)">
</g>
<g
id="g928"
transform="translate(-237.4375,-231.25)">
</g>
<g
id="g930"
transform="translate(-237.4375,-231.25)">
</g>
</svg>

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

@@ -7,9 +7,9 @@ from PyQt5.QtGui import QPixmap, QIcon, QCursor
from PyQt5.QtNetwork import QNetworkAccessManager, QNetworkRequest
from PyQt5.QtWidgets import QTableWidget, QTableView, QMenu, QAction, QTableWidgetItem, QToolButton, QWidget, \
QHeaderView, QLabel, QHBoxLayout, QPushButton, QToolBar
from bauh.api.abstract.cache import MemoryCache
from bauh.api.abstract.model import PackageStatus
from bauh.util import resource
from bauh.util.html import strip_html
from bauh.view.qt import dialog

View File

@@ -2,9 +2,12 @@ import io
import os
import subprocess
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QInputDialog, QLineEdit
from bauh.api.abstract.view import MessageType
from bauh import ROOT_DIR
from bauh.api.abstract.view import MessageType
from bauh.commons import resource
from bauh.view.qt.dialog import show_message
@@ -14,24 +17,25 @@ def is_root():
def ask_root_password(locale_keys: dict):
dialog_pwd = QInputDialog()
dialog_pwd.setInputMode(QInputDialog.TextInput)
dialog_pwd.setTextEchoMode(QLineEdit.Password)
dialog_pwd.setWindowTitle(locale_keys['popup.root.title'])
dialog_pwd.setLabelText(locale_keys['popup.root.password'] + ':')
dialog_pwd.setCancelButtonText(locale_keys['popup.button.cancel'])
dialog_pwd.resize(400, 200)
diag = QInputDialog()
diag.setInputMode(QInputDialog.TextInput)
diag.setTextEchoMode(QLineEdit.Password)
diag.setWindowIcon(QIcon(resource.get_path('img/lock.svg', ROOT_DIR)))
diag.setWindowTitle(locale_keys['popup.root.title'])
diag.setLabelText(locale_keys['popup.root.password'] + ':')
diag.setCancelButtonText(locale_keys['popup.button.cancel'])
diag.resize(400, 200)
ok = dialog_pwd.exec_()
ok = diag.exec_()
if ok:
if not validate_password(dialog_pwd.textValue()):
if not validate_password(diag.textValue()):
show_message(title=locale_keys['popup.root.bad_password.title'],
body=locale_keys['popup.root.bad_password.body'],
type_=MessageType.ERROR)
ok = False
return dialog_pwd.textValue(), ok
return diag.textValue(), ok
def validate_password(password: str) -> bool: