106 lines
4.3 KiB
Python
106 lines
4.3 KiB
Python
from PyQt5.QtWidgets import (QDialog, QVBoxLayout, QLabel, QLineEdit,
|
|
QPushButton, QMessageBox, QApplication)
|
|
from PyQt5.QtCore import Qt
|
|
from PyQt5.QtGui import QClipboard
|
|
|
|
from license_manager import LicenseManager
|
|
|
|
class RegistrationDialog(QDialog):
|
|
def __init__(self):
|
|
super().__init__()
|
|
self.setWindowTitle("Aktivasi ProBackup")
|
|
self.resize(400, 300)
|
|
self.setStyleSheet("""
|
|
QDialog { background-color: #282a36; color: #f8f8f2; font-family: "Segoe UI"; }
|
|
QLabel { color: #f8f8f2; font-size: 14px; }
|
|
QLineEdit { background-color: #44475a; border: 1px solid #6272a4; padding: 8px; color: #f8f8f2; border-radius: 4px; }
|
|
QPushButton { background-color: #6272a4; color: white; border: none; padding: 10px; border-radius: 4px; font-weight: bold; }
|
|
QPushButton:hover { background-color: #bd93f9; }
|
|
""")
|
|
|
|
self.hwid = LicenseManager.get_hardware_id()
|
|
self.verified = False
|
|
|
|
self.setup_ui()
|
|
|
|
def setup_ui(self):
|
|
layout = QVBoxLayout(self)
|
|
layout.setSpacing(15)
|
|
|
|
# Title
|
|
title = QLabel("Aktivasi Produk Diperlukan")
|
|
title.setStyleSheet("font-size: 18px; font-weight: bold; color: #ff5555;")
|
|
title.setAlignment(Qt.AlignCenter)
|
|
layout.addWidget(title)
|
|
|
|
# Info
|
|
info = QLabel("Untuk menggunakan aplikasi ini, silakan kirimkan ID Mesin di bawah ini ke administrator untuk mendapatkan Kunci Aktivasi.")
|
|
info.setWordWrap(True)
|
|
layout.addWidget(info)
|
|
|
|
# HWID Display
|
|
layout.addWidget(QLabel("ID Mesin Anda:"))
|
|
|
|
self.hwid_input = QLineEdit(self.hwid)
|
|
self.hwid_input.setReadOnly(True)
|
|
self.hwid_input.setStyleSheet("font-family: Consolas; font-size: 14px; color: #50fa7b;")
|
|
layout.addWidget(self.hwid_input)
|
|
|
|
copy_btn = QPushButton("Salin ID Mesin")
|
|
copy_btn.clicked.connect(self.copy_hwid)
|
|
layout.addWidget(copy_btn)
|
|
|
|
# Key Input
|
|
layout.addWidget(QLabel("Masukkan Kunci Aktivasi:"))
|
|
self.key_input = QLineEdit()
|
|
self.key_input.setPlaceholderText("Tempel kunci aktivasi disini...")
|
|
layout.addWidget(self.key_input)
|
|
|
|
# Actions
|
|
activate_btn = QPushButton("AKTIFKAN")
|
|
activate_btn.setStyleSheet("background-color: #50fa7b; color: #282a36;")
|
|
activate_btn.clicked.connect(self.verify_key)
|
|
layout.addWidget(activate_btn)
|
|
|
|
layout.addStretch()
|
|
|
|
def copy_hwid(self):
|
|
cb = QApplication.clipboard()
|
|
cb.setText(self.hwid)
|
|
QMessageBox.information(self, "Disalin", "ID Mesin telah disalin ke clipboard.")
|
|
|
|
def verify_key(self):
|
|
key = self.key_input.text().strip()
|
|
is_valid, status = LicenseManager.validate_license(key, self.hwid)
|
|
|
|
if is_valid:
|
|
LicenseManager.save_license(key)
|
|
if status == 'mb_changed':
|
|
QMessageBox.warning(self, "Peringatan Hardware",
|
|
"Aktivasi berhasil, namun terdeteksi MOTHERBOARD telah berubah.\n"
|
|
"Jika Anda mengganti hardware lagi, lisensi bisa tidak valid.")
|
|
elif status == 'cpu_changed':
|
|
QMessageBox.warning(self, "Peringatan Hardware",
|
|
"Aktivasi berhasil, namun terdeteksi PROCESSOR telah berubah.\n"
|
|
"Jika Anda mengganti hardware lagi, lisensi bisa tidak valid.")
|
|
else:
|
|
QMessageBox.information(self, "Sukses", "Aktivasi Berhasil! Terima kasih.")
|
|
self.verified = True
|
|
self.accept()
|
|
else:
|
|
if status == 'both_changed':
|
|
QMessageBox.critical(self, "Hardware Berubah",
|
|
"Motherboard DAN Processor terdeteksi berubah.\n\n"
|
|
"Lisensi tidak valid untuk hardware baru ini.\n"
|
|
"Silakan hubungi admin untuk aktivasi ulang.\n\n"
|
|
"WA: +62 817-0380-6655")
|
|
else:
|
|
QMessageBox.warning(self, "Gagal", "Kunci Aktivasi Salah. Silakan coba lagi.")
|
|
|
|
def closeEvent(self, event):
|
|
if not self.verified:
|
|
# If closed without verification, reject dialog
|
|
self.reject()
|
|
else:
|
|
event.accept()
|