#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Basic Example - Qt Modern Style
===============================

A simple example showing how to use qt_modern_style with a PyQt5 application.
"""

import sys

try:
    from PyQt5.QtWidgets import (
        QApplication,
        QMainWindow,
        QWidget,
        QVBoxLayout,
        QHBoxLayout,
        QPushButton,
        QLabel,
        QLineEdit,
        QCheckBox,
        QRadioButton,
        QComboBox,
        QSpinBox,
        QGroupBox,
    )
except ImportError:
    try:
        from PyQt6.QtWidgets import (
            QApplication,
            QMainWindow,
            QWidget,
            QVBoxLayout,
            QHBoxLayout,
            QPushButton,
            QLabel,
            QLineEdit,
            QCheckBox,
            QRadioButton,
            QComboBox,
            QSpinBox,
            QGroupBox,
        )
    except ImportError:
        try:
            from PySide6.QtWidgets import (
                QApplication,
                QMainWindow,
                QWidget,
                QVBoxLayout,
                QHBoxLayout,
                QPushButton,
                QLabel,
                QLineEdit,
                QCheckBox,
                QRadioButton,
                QComboBox,
                QSpinBox,
                QGroupBox,
            )
        except ImportError:
            from PySide2.QtWidgets import (
                QApplication,
                QMainWindow,
                QWidget,
                QVBoxLayout,
                QHBoxLayout,
                QPushButton,
                QLabel,
                QLineEdit,
                QCheckBox,
                QRadioButton,
                QComboBox,
                QSpinBox,
                QGroupBox,
            )

import qt_modern_style


class MainWindow(QMainWindow):
    """Main window with basic widgets."""

    def __init__(self):
        super().__init__()
        self.setWindowTitle("Qt Modern Style - Basic Example")
        self.setMinimumSize(500, 400)

        # Create central widget
        central_widget = QWidget()
        self.setCentralWidget(central_widget)

        # Create layout
        layout = QVBoxLayout(central_widget)
        layout.setSpacing(15)
        layout.setContentsMargins(20, 20, 20, 20)

        # Title
        title = QLabel("Qt Modern Style Demo")
        title.setStyleSheet("font-size: 16pt; font-weight: bold;")
        layout.addWidget(title)

        # Input group
        input_group = QGroupBox("Input Widgets")
        input_layout = QVBoxLayout(input_group)

        # Line edit
        name_layout = QHBoxLayout()
        name_label = QLabel("Name:")
        name_edit = QLineEdit()
        name_edit.setPlaceholderText("Enter your name...")
        name_layout.addWidget(name_label)
        name_layout.addWidget(name_edit)
        input_layout.addLayout(name_layout)

        # ComboBox
        combo_layout = QHBoxLayout()
        combo_label = QLabel("Option:")
        combo = QComboBox()
        combo.addItems(["Option 1", "Option 2", "Option 3"])
        combo_layout.addWidget(combo_label)
        combo_layout.addWidget(combo)
        input_layout.addLayout(combo_layout)

        # SpinBox
        spin_layout = QHBoxLayout()
        spin_label = QLabel("Number:")
        spin = QSpinBox()
        spin.setRange(0, 100)
        spin.setValue(42)
        spin_layout.addWidget(spin_label)
        spin_layout.addWidget(spin)
        input_layout.addLayout(spin_layout)

        layout.addWidget(input_group)

        # Options group
        options_group = QGroupBox("Options")
        options_layout = QVBoxLayout(options_group)

        # Checkboxes
        check1 = QCheckBox("Enable feature A")
        check1.setChecked(True)
        check2 = QCheckBox("Enable feature B")
        options_layout.addWidget(check1)
        options_layout.addWidget(check2)

        # Radio buttons
        radio1 = QRadioButton("Mode 1")
        radio1.setChecked(True)
        radio2 = QRadioButton("Mode 2")
        radio3 = QRadioButton("Mode 3")
        options_layout.addWidget(radio1)
        options_layout.addWidget(radio2)
        options_layout.addWidget(radio3)

        layout.addWidget(options_group)

        # Buttons
        button_layout = QHBoxLayout()

        # Normal button
        normal_btn = QPushButton("Normal")
        button_layout.addWidget(normal_btn)

        # Primary button
        primary_btn = QPushButton("Primary")
        primary_btn.setProperty("primary", True)
        button_layout.addWidget(primary_btn)

        # Danger button
        danger_btn = QPushButton("Danger")
        danger_btn.setProperty("danger", True)
        button_layout.addWidget(danger_btn)

        # Disabled button
        disabled_btn = QPushButton("Disabled")
        disabled_btn.setEnabled(False)
        button_layout.addWidget(disabled_btn)

        layout.addLayout(button_layout)

        # Add stretch
        layout.addStretch()

        # Status label
        status = QLabel("Ready")
        status.setProperty("muted", True)
        layout.addWidget(status)


def main():
    """Main entry point."""
    app = QApplication(sys.argv)

    # Apply the modern style
    qt_modern_style.apply(app)

    # Create and show window
    window = MainWindow()
    window.show()

    sys.exit(app.exec() if hasattr(app, "exec") else app.exec_())


if __name__ == "__main__":
    main()
