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

Loading…
Cancel
Save