qt/LedOK/program/sendprogramdialog.h
2023-08-07 09:04:53 +08:00

52 lines
1.7 KiB
C++

#ifndef SENDPROGRAMDIALOG_H
#define SENDPROGRAMDIALOG_H
#include "globaldefine.h"
#include "gutil/qgui.h"
#include <QDialog>
#include <QCheckBox>
#include <QProxyStyle>
#include <QApplication>
class SendProgramDialog : public QDialog {
Q_OBJECT
public:
explicit SendProgramDialog(QString, QWidget *parent = nullptr);
signals:
void stopAllThd();
protected slots:
void refresh();
protected:
void closeEvent(QCloseEvent *event) override;
void sendNext();
void addRow(LedCard);
void updRow(int, LedCard);
Table *table;
QCheckBox *fdCheckAll;
int mWaitCnt{0};
QLabel *label;
QString mProgName;
QString m_strUrl;
enum {isSending = Qt::UserRole};
};
class ViewItemStyle : public QProxyStyle {
public:
ViewItemStyle() : QProxyStyle(QApplication::style()) {}
QRect subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const override {
auto res = QProxyStyle::subElementRect(element, option, widget);
if(option && option->type==QStyleOption::SO_ViewItem && ((QStyleOptionViewItem*)option)->features & QStyleOptionViewItem::HasCheckIndicator && ((QStyleOptionViewItem*)option)->index.internalId()==0) res.setLeft(res.x() + 6);
return res;
}
int pixelMetric(QStyle::PixelMetric metric, const QStyleOption *option, const QWidget *widget) const override {
auto res = QProxyStyle::pixelMetric(metric, option, widget);
if(metric==PM_FocusFrameHMargin && option && option->type==QStyleOption::SO_ViewItem && ((QStyleOptionViewItem*)option)->features & QStyleOptionViewItem::HasCheckIndicator) res += 4;
return res;
}
};
#endif // SENDPROGRAMDIALOG_H