#ifndef TIMEZONEMAP_H
#define TIMEZONEMAP_H

#include <QFrame>
#include <QLabel>
#include <QResizeEvent>
#include <QStringListModel>
#include <QRadioButton>
#include <QGSettings>

#include "zoneinfo.h"
#include "poplist.h"
#include "toolpop.h"
#include "popmenu.h"
#include "dotlabel.h"

#define STYLE_GSETTINGS_ID    "org.ukui.style"
#define STYLE_GSETTINGS_KEY   "styleName"
#define STYLE_GSETTINGS_VALUE "style-name"

QDebug& operator<<(QDebug& debug, const ZoneInfo& info);

class TimezoneMap : public QFrame
{
    Q_OBJECT
public:
    explicit TimezoneMap(QWidget* parent = nullptr);
    ~TimezoneMap();

    QString getTimezone() ;//获得选择的时区

Q_SIGNALS:
    void timezoneSelected(QString timezone);
public slots:
    void setTimezone(QString timezone);

protected:
    void mousePressEvent(QMouseEvent* event);

    void resizeEvent(QResizeEvent* event);
private:
    void initUI();
    void mark(); //标记
    void popupZoneList(QPoint pos);

    QPoint zoneInfoToPosition(ZoneInfo_ zone, int mapWidth, int mapHeight);

private:
    ZoneInfo*    m_zoninfo;
    ZoneInfo_    m_currentZone;
    ZoneinfoList m_totalZones;
    ZoneinfoList m_nearestZones;

    // 圆点
    Dotlabel* m_dot = nullptr;

    QGSettings *m_styleGsetting;

    ToolPop* m_singleList;
    PopMenu *m_popmenu;
    QPixmap loadPixmap(const QString &path);

    QLabel* backgroundLabel;

private slots:
    void popListActiveSlot(int index);
    void styleGsettingsChanged(QString key);
};

#endif // TIMEZONEMAP_H
