#ifndef JOINMEETINGDIALOG_H
#define JOINMEETINGDIALOG_H

#include "framelessbase.h"
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QListWidget>
#include <QTabWidget>
#include <QGroupBox>
#include <QStringList>

class QEventLoop;
class QCloseEvent;

class JoinMeetingDialog : public TDialog
{
    Q_OBJECT

public:
    // 兼容性映射：保持 JoinMeetingDialog::Accepted 可用
    enum DialogCode { Rejected = TDialog::Rejected, Accepted = TDialog::Accepted };

    explicit JoinMeetingDialog(QWidget *parent = nullptr);
    ~JoinMeetingDialog();

    // 获取选择的会议ID
    QString getSelectedMeetingId() const;
    
    // 设置可用的会议列表
    void setAvailableMeetings(const QStringList &meetingIds, const QStringList &meetingNames);

public slots:
    void accept() override;  // 验证后调用 TDialog::accept()
    void reject() override;  // 清理后调用 TDialog::reject()

private slots:
    void onMeetingItemClicked();
    void onMeetingIdChanged();
    void validateInput();

private:
    void setupUI();

    // UI组件
    QVBoxLayout *m_mainLayout;
    QTabWidget *m_tabWidget;
    
    // 手动输入标签页
    QWidget *m_manualTab;
    QVBoxLayout *m_manualLayout;
    QLabel *m_manualLabel;
    QLineEdit *m_meetingIdEdit;
    
    // 选择会议标签页
    QWidget *m_selectTab;
    QVBoxLayout *m_selectLayout;
    QLabel *m_selectLabel;
    QListWidget *m_meetingListWidget;
    
    // 按钮
    QHBoxLayout *m_buttonLayout;
    QPushButton *m_joinButton;
    QPushButton *m_cancelButton;
    
    // 数据
    QString m_selectedMeetingId;
    QStringList m_meetingIds;
    QStringList m_meetingNames;
};

#endif // JOINMEETINGDIALOG_H
