leocad/common/lc_colorpicker.h

65 lines
1.3 KiB
C
Raw Normal View History

#pragma once
2013-08-09 06:57:18 +02:00
2023-04-30 04:48:30 +02:00
class lcColorList;
2013-08-09 06:57:18 +02:00
2023-05-16 06:02:17 +02:00
class lcColorPickerPopup : public QFrame
2013-08-09 06:57:18 +02:00
{
Q_OBJECT
public:
2023-05-16 06:02:17 +02:00
lcColorPickerPopup(QWidget* Parent = nullptr, int ColorIndex = 0, bool AllowNoColor = false);
virtual ~lcColorPickerPopup();
2013-08-09 06:57:18 +02:00
void exec();
signals:
2023-05-16 06:02:17 +02:00
void Changed(int ColorIndex);
void Selected(int ColorIndex);
void Hid();
2013-08-09 06:57:18 +02:00
public slots:
2023-05-16 06:02:17 +02:00
void ColorChanged(int ColorIndex);
void ColorSelected(int ColorIndex);
2013-08-09 06:57:18 +02:00
protected:
void showEvent(QShowEvent* ShowEvent) override;
void hideEvent(QHideEvent* HideEvent) override;
void mouseReleaseEvent(QMouseEvent* MouseEvent) override;
2013-08-09 06:57:18 +02:00
private:
2023-05-16 06:02:17 +02:00
QEventLoop* mEventLoop = nullptr;
lcColorList* mColorList = nullptr;
2013-08-09 06:57:18 +02:00
};
2023-05-16 06:02:17 +02:00
class lcColorPicker : public QPushButton
2013-08-09 06:57:18 +02:00
{
Q_OBJECT
public:
2023-05-16 06:02:17 +02:00
lcColorPicker(QWidget* Parent = nullptr, bool AllowNoColor = false);
virtual ~lcColorPicker();
2013-08-09 06:57:18 +02:00
2023-05-16 06:02:17 +02:00
int GetCurrentColor() const;
int GetCurrentColorCode() const;
void SetCurrentColor(int ColorIndex);
void SetCurrentColorCode(int ColorCode);
2013-08-09 06:57:18 +02:00
public slots:
2023-05-16 06:02:17 +02:00
void Changed(int ColorIndex);
void Selected(int ColorIndex);
2013-08-09 06:57:18 +02:00
signals:
2023-05-16 06:02:17 +02:00
void ColorChanged(int ColorIndex);
2013-08-09 06:57:18 +02:00
private slots:
2023-05-16 06:02:17 +02:00
void ButtonPressed(bool Toggled);
void PopupClosed();
2013-08-09 06:57:18 +02:00
2021-02-01 02:32:38 +01:00
protected:
void UpdateIcon();
2013-08-09 06:57:18 +02:00
2021-02-01 02:32:38 +01:00
int mCurrentColorIndex = 0;
int mInitialColorIndex = 0;
bool mAllowNoColor = false;
};