Skip to content

Commit

Permalink
Port to PyQt6
Browse files Browse the repository at this point in the history
  • Loading branch information
manateelazycat committed Mar 29, 2022
1 parent 51ace25 commit e78b3f2
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from PyQt5 import QtGui, QtCore
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QColor, QFont
from PyQt5.QtWidgets import QWidget, QLabel, QVBoxLayout
from PyQt6 import QtGui, QtCore
from PyQt6.QtCore import Qt
from PyQt6.QtGui import QColor, QFont
from PyQt6.QtWidgets import QWidget, QLabel, QVBoxLayout
from core.buffer import Buffer
import qrcode

Expand All @@ -38,8 +38,8 @@ def __init__(self, border, width, box_size):
self.width = width
self.box_size = box_size
size = (width + border * 2) * box_size
self._image = QtGui.QImage(size, size, QtGui.QImage.Format_RGB16)
self._image.fill(QtCore.Qt.white)
self._image = QtGui.QImage(size, size, QtGui.QImage.Format.Format_RGB16)
self._image.fill(QtCore.Qt.GlobalColor.white)

def pixmap(self):
return QtGui.QPixmap.fromImage(self._image)
Expand All @@ -50,7 +50,7 @@ def drawrect(self, row, col):
(col + self.border) * self.box_size,
(row + self.border) * self.box_size,
self.box_size, self.box_size,
QtCore.Qt.black)
QtCore.Qt.GlobalColor.black)

def save(self, stream, kind=None):
pass
Expand All @@ -61,32 +61,32 @@ def __init__(self, url, foreground_color):
self.setStyleSheet("background-color: transparent;")

self.file_name_font = QFont()
self.file_name_font.setPointSize(24)
self.file_name_font.setPointSize(48)

self.file_name_label = QLabel(self)
self.file_name_label.setText(url)
self.file_name_label.setFont(self.file_name_font)
self.file_name_label.setAlignment(Qt.AlignCenter)
self.file_name_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.file_name_label.setStyleSheet("color: {}".format(foreground_color))

self.qrcode_label = QLabel(self)

self.notify_font = QFont()
self.notify_font.setPointSize(12)
self.notify_font.setPointSize(24)
self.notify_label = QLabel(self)
self.notify_label.setText("Scan QR code above to copy data.")
self.notify_label.setFont(self.notify_font)
self.notify_label.setAlignment(Qt.AlignCenter)
self.notify_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.notify_label.setStyleSheet("color: {}".format(foreground_color))

layout = QVBoxLayout(self)
layout.setContentsMargins(0, 0, 0, 0)
layout.addStretch()
layout.addWidget(self.qrcode_label, 0, Qt.AlignCenter)
layout.addWidget(self.qrcode_label, 0, Qt.AlignmentFlag.AlignCenter)
layout.addSpacing(20)
layout.addWidget(self.file_name_label, 0, Qt.AlignCenter)
layout.addWidget(self.file_name_label, 0, Qt.AlignmentFlag.AlignCenter)
layout.addSpacing(40)
layout.addWidget(self.notify_label, 0, Qt.AlignCenter)
layout.addWidget(self.notify_label, 0, Qt.AlignmentFlag.AlignCenter)
layout.addStretch()

self.qrcode_label.setPixmap(qrcode.make(url, image_factory=Image).pixmap())

0 comments on commit e78b3f2

Please sign in to comment.