change QPushButton to QDialogButtonBox so Qt can do the text translations

pull/2/head
Hans P. Möller 4 years ago
parent be1a29219c
commit cea3cb0229

@ -25,7 +25,7 @@ import apt_pkg
from argparse import ArgumentParser
import gettext
from PyQt5.QtWidgets import (QWidget, QApplication, QLabel, QPushButton,
from PyQt5.QtWidgets import (QWidget, QApplication, QLabel, QDialogButtonBox,
QHBoxLayout, QVBoxLayout, QTreeWidget,
QTreeWidgetItem)
from PyQt5.QtCore import Qt
@ -51,8 +51,8 @@ class Dialog(QWidget):
self.depcache = apt_pkg.DepCache(self.cache)
self.initUI()
self.upgradeBtn.clicked.connect(self.call_upgrade)
self.closeBtn.clicked.connect(self.call_reject)
self.buttonBox.rejected.connect(self.call_reject)
self.buttonBox.clicked.connect(self.call_upgrade)
def initUI(self):
''' UI initialization '''
@ -64,14 +64,13 @@ class Dialog(QWidget):
self.tw.setHeaderLabels([_('Affected Packages')])
self.tw.setHeaderHidden(True)
self.upgradeBtn = QPushButton("Upgrade")
self.closeBtn = QPushButton("Close")
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Cancel |
QDialogButtonBox.Apply)
text = ""
hbox = QHBoxLayout()
hbox.addStretch(1)
hbox.addWidget(self.upgradeBtn)
hbox.addWidget(self.closeBtn)
hbox.addWidget(self.buttonBox)
hbox.addStretch(1)
vbox = QVBoxLayout()
@ -150,7 +149,8 @@ class Dialog(QWidget):
''' when close button is pressed, quit '''
app.quit()
def call_upgrade(self):
def call_upgrade(self, btnClicked):
if(self.buttonBox.buttonRole(btnClicked) == QDialogButtonBox.ApplyRole):
''' starts upgrade process '''
self.label.setText(_("Upgrading..."))
# TODO maybe open another thread so notifier won't freeze

Loading…
Cancel
Save