17#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
21 #include <QDesktopWidget>
23#include <QFontDatabase>
24#include <QApplication>
29QUIWidget::QUIWidget(QWidget *parent,
bool bQuitOnClose) : QDialog(parent)
31 setAttribute(Qt::WA_QuitOnClose, bQuitOnClose);
36QUIWidget::~QUIWidget()
41void QUIWidget::setStyle(QUIWidget::Style style)
43#if defined(DEBUG) || defined(_DEBUG)
44 QString qssFile =
":/qss/blue.css";
46 if (style == QUIWidget::Style_Silvery) {
47 qssFile =
":/qss/silvery.css";
48 }
else if (style == QUIWidget::Style_Blue) {
49 qssFile =
":/qss/blue.css";
50 }
else if (style == QUIWidget::Style_LightBlue) {
51 qssFile =
":/qss/lightblue.css";
52 }
else if (style == QUIWidget::Style_DarkBlue) {
53 qssFile =
":/qss/darkblue.css";
54 }
else if (style == QUIWidget::Style_Gray) {
55 qssFile =
":/qss/gray.css";
56 }
else if (style == QUIWidget::Style_LightGray) {
57 qssFile =
":/qss/lightgray.css";
58 }
else if (style == QUIWidget::Style_DarkGray) {
59 qssFile =
":/qss/darkgray.css";
60 }
else if (style == QUIWidget::Style_Black) {
61 qssFile =
":/qss/black.css";
62 }
else if (style == QUIWidget::Style_LightBlack) {
63 qssFile =
":/qss/lightblack.css";
64 }
else if (style == QUIWidget::Style_DarkBlack) {
65 qssFile =
":/qss/darkblack.css";
66 }
else if (style == QUIWidget::Style_PSBlack) {
67 qssFile =
":/qss/psblack.css";
68 }
else if (style == QUIWidget::Style_FlatBlack) {
69 qssFile =
":/qss/flatblack.css";
70 }
else if (style == QUIWidget::Style_FlatWhite) {
71 qssFile =
":/qss/flatwhite.css";
76 if (file.open(QFile::ReadOnly)) {
77 QString qss = QLatin1String(file.readAll());
78 QString paletteColor = qss.mid(20, 7);
79 qApp->setPalette(QPalette(QColor(paletteColor)));
80 qApp->setStyleSheet(qss);
86void QUIWidget::setStyle(
const QString &qssFile)
90 if (file.open(QFile::ReadOnly)) {
91 QString qss = QLatin1String(file.readAll());
92 QString paletteColor = qss.mid(20, 7);
93 qApp->setPalette(QPalette(QColor(paletteColor)));
94 qApp->setStyleSheet(qss);
99void QUIWidget::setFormInCenter(QWidget *frm)
101 Q_ASSERT(frm !=
nullptr);
102 int frmX = frm->width();
103 int frmY = frm->height();
104#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
106 int deskWidth = w.availableGeometry().width();
107 int deskHeight = w.availableGeometry().height();
109 QScreen* pScreen = qApp->primaryScreen();
111 int deskWidth = pScreen->availableGeometry().width();
112 int deskHeight = pScreen->availableGeometry().height();
114 QPoint movePoint(deskWidth / 2 - frmX / 2, deskHeight / 2 - frmY / 2);
115 frm->move(movePoint);
118void QUIWidget::getQssColor(
const QString &qss, QString &textColor, QString &panelColor, QString &borderColor,
119 QString &normalColorStart, QString &normalColorEnd,
120 QString &darkColorStart, QString &darkColorEnd, QString &highColor)
124 QString flagTextColor =
"TextColor:";
125 int indexTextColor = str.indexOf(flagTextColor);
127 if (indexTextColor >= 0) {
128 textColor = str.mid(indexTextColor + flagTextColor.length(), 7);
131 QString flagPanelColor =
"PanelColor:";
132 int indexPanelColor = str.indexOf(flagPanelColor);
134 if (indexPanelColor >= 0) {
135 panelColor = str.mid(indexPanelColor + flagPanelColor.length(), 7);
138 QString flagBorderColor =
"BorderColor:";
139 int indexBorderColor = str.indexOf(flagBorderColor);
141 if (indexBorderColor >= 0) {
142 borderColor = str.mid(indexBorderColor + flagBorderColor.length(), 7);
145 QString flagNormalColorStart =
"NormalColorStart:";
146 int indexNormalColorStart = str.indexOf(flagNormalColorStart);
148 if (indexNormalColorStart >= 0) {
149 normalColorStart = str.mid(indexNormalColorStart + flagNormalColorStart.length(), 7);
152 QString flagNormalColorEnd =
"NormalColorEnd:";
153 int indexNormalColorEnd = str.indexOf(flagNormalColorEnd);
155 if (indexNormalColorEnd >= 0) {
156 normalColorEnd = str.mid(indexNormalColorEnd + flagNormalColorEnd.length(), 7);
159 QString flagDarkColorStart =
"DarkColorStart:";
160 int indexDarkColorStart = str.indexOf(flagDarkColorStart);
162 if (indexDarkColorStart >= 0) {
163 darkColorStart = str.mid(indexDarkColorStart + flagDarkColorStart.length(), 7);
166 QString flagDarkColorEnd =
"DarkColorEnd:";
167 int indexDarkColorEnd = str.indexOf(flagDarkColorEnd);
169 if (indexDarkColorEnd >= 0) {
170 darkColorEnd = str.mid(indexDarkColorEnd + flagDarkColorEnd.length(), 7);
173 QString flagHighColor =
"HighColor:";
174 int indexHighColor = str.indexOf(flagHighColor);
176 if (indexHighColor >= 0) {
177 highColor = str.mid(indexHighColor + flagHighColor.length(), 7);
181void QUIWidget::setTranslator(
const QString &qmFile)
183 QTranslator *translator =
new QTranslator(qApp);
184 if(translator->load(qmFile))
185 qApp->installTranslator(translator);
188void QUIWidget::setCode()
190#if (QT_VERSION <= QT_VERSION_CHECK(5,0,0))
192 QTextCodec *codec = QTextCodec::codecForName(
"gbk");
194 QTextCodec *codec = QTextCodec::codecForName(
"utf-8");
196 QTextCodec::setCodecForLocale(codec);
197 QTextCodec::setCodecForCStrings(codec);
198 QTextCodec::setCodecForTr(codec);
199#elif (QT_VERSION < QT_VERSION_CHECK(6,0,0))
200 QTextCodec *codec = QTextCodec::codecForName(
"utf-8");
201 QTextCodec::setCodecForLocale(codec);
205void QUIWidget::showMessageBoxInfo(
const QString &info,
int closeSec)
207 QUIMessageBox::Instance()->setMessage(info, 0, closeSec);
208 QUIMessageBox::Instance()->show();
211void QUIWidget::showMessageBoxError(
const QString &info,
int closeSec)
213 QUIMessageBox::Instance()->setMessage(info, 2, closeSec);
214 QUIMessageBox::Instance()->show();
217int QUIWidget::showMessageBoxQuestion(
const QString &info)
220 msg.setMessage(info, 1);
224QString QUIWidget::showInputBox(
bool &ok,
const QString &title,
int type,
int closeSec,
225 QString defaultValue,
bool pwd)
228 input.setParameter(title, type, closeSec, defaultValue, pwd);
230 return input.getValue();
233bool QUIWidget::eventFilter(QObject *obj, QEvent *evt)
235 static QPoint mousePoint;
236 static bool mousePressed =
false;
238 QMouseEvent *
event =
static_cast<QMouseEvent *
>(evt);
239 if (event->type() == QEvent::MouseButtonPress) {
240 if (event->button() == Qt::LeftButton) {
242 mousePoint =
event->globalPos() - this->pos();
245 }
else if (event->type() == QEvent::MouseButtonRelease) {
246 mousePressed =
false;
248 }
else if (event->type() == QEvent::MouseMove) {
249 if (!max && mousePressed && (event->buttons() & Qt::LeftButton)) {
250 this->move(event->globalPos() - mousePoint);
253 }
else if (event->type() == QEvent::MouseButtonDblClick) {
256 if (this->btnMenu_Max->isVisible()) {
257 this->on_btnMenu_Max_clicked();
260 }
else if (event->type() == QEvent::Hide) {
261 if (obj == mainWidget) {
266 return QDialog::eventFilter(obj, evt);
269QLabel *QUIWidget::getLabIco()
const
271 return this->lab_Ico;
274QLabel *QUIWidget::getLabTitle()
const
276 return this->lab_Title;
279QToolButton *QUIWidget::getBtnMenu()
const
281 return this->btnMenu;
284QPushButton *QUIWidget::getBtnMenuMin()
const
286 return this->btnMenu_Min;
289QPushButton *QUIWidget::getBtnMenuMax()
const
291 return this->btnMenu_Max;
294QPushButton *QUIWidget::getBtnMenuMClose()
const
296 return this->btnMenu_Close;
299QString QUIWidget::getTitle()
const
304Qt::Alignment QUIWidget::getAlignment()
const
306 return this->alignment;
309QSize QUIWidget::sizeHint()
const
311 return QSize(600, 450);
314QSize QUIWidget::minimumSizeHint()
const
316 return QSize(200, 150);
319void QUIWidget::initControl()
321 this->setObjectName(QString::fromUtf8(
"QUIWidget"));
322 this->resize(900, 750);
323 verticalLayout1 =
new QVBoxLayout(
this);
324 verticalLayout1->setSpacing(0);
325 verticalLayout1->setContentsMargins(11, 11, 11, 11);
326 verticalLayout1->setObjectName(QString::fromUtf8(
"verticalLayout1"));
327 verticalLayout1->setContentsMargins(1, 1, 1, 1);
328 widgetMain =
new QWidget(
this);
329 widgetMain->setObjectName(QString::fromUtf8(
"widgetMain"));
330 widgetMain->setStyleSheet(QString::fromUtf8(
""));
331 widgetMain->setFocusPolicy(Qt::NoFocus);
332 verticalLayout2 =
new QVBoxLayout(widgetMain);
333 verticalLayout2->setSpacing(0);
334 verticalLayout2->setContentsMargins(11, 11, 11, 11);
335 verticalLayout2->setObjectName(QString::fromUtf8(
"verticalLayout2"));
336 verticalLayout2->setContentsMargins(0, 0, 0, 0);
337 widget_title =
new QWidget(widgetMain);
338 widget_title->setObjectName(QString::fromUtf8(
"widget_title"));
339 widget_title->setFocusPolicy(Qt::NoFocus);
340 QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
341 sizePolicy.setHorizontalStretch(0);
342 sizePolicy.setVerticalStretch(0);
343 sizePolicy.setHeightForWidth(widget_title->sizePolicy().hasHeightForWidth());
344 widget_title->setSizePolicy(sizePolicy);
345 widget_title->setMinimumSize(QSize(0, 30));
346 horizontalLayout4 =
new QHBoxLayout(widget_title);
347 horizontalLayout4->setSpacing(0);
348 horizontalLayout4->setContentsMargins(11, 11, 11, 11);
349 horizontalLayout4->setObjectName(QString::fromUtf8(
"horizontalLayout4"));
350 horizontalLayout4->setContentsMargins(0, 0, 0, 0);
351 lab_Ico =
new QLabel(widget_title);
352 lab_Ico->setObjectName(QString::fromUtf8(
"lab_Ico"));
353 lab_Ico->setFocusPolicy(Qt::NoFocus);
354 QSizePolicy sizePolicy1(QSizePolicy::Minimum, QSizePolicy::Preferred);
355 sizePolicy1.setHorizontalStretch(0);
356 sizePolicy1.setVerticalStretch(0);
357 sizePolicy1.setHeightForWidth(lab_Ico->sizePolicy().hasHeightForWidth());
358 lab_Ico->setSizePolicy(sizePolicy1);
359 lab_Ico->setMinimumSize(QSize(30, 0));
360 lab_Ico->setAlignment(Qt::AlignCenter);
362 horizontalLayout4->addWidget(lab_Ico);
364 lab_Title =
new QLabel(widget_title);
365 lab_Title->setObjectName(QString::fromUtf8(
"lab_Title"));
366 QSizePolicy sizePolicy2(QSizePolicy::Expanding, QSizePolicy::Preferred);
367 sizePolicy2.setHorizontalStretch(0);
368 sizePolicy2.setVerticalStretch(0);
369 sizePolicy2.setHeightForWidth(lab_Title->sizePolicy().hasHeightForWidth());
370 lab_Title->setSizePolicy(sizePolicy2);
371 lab_Title->setFocusPolicy(Qt::NoFocus);
372 lab_Title->setAlignment(Qt::AlignLeading | Qt::AlignLeft | Qt::AlignVCenter);
374 horizontalLayout4->addWidget(lab_Title);
376 widget_menu =
new QWidget(widget_title);
377 widget_menu->setObjectName(QString::fromUtf8(
"widget_menu"));
378 sizePolicy1.setHeightForWidth(widget_menu->sizePolicy().hasHeightForWidth());
379 widget_menu->setSizePolicy(sizePolicy1);
380 widget_menu->setFocusPolicy(Qt::NoFocus);
381 horizontalLayout =
new QHBoxLayout(widget_menu);
382 horizontalLayout->setSpacing(0);
383 horizontalLayout->setContentsMargins(11, 11, 11, 11);
384 horizontalLayout->setObjectName(QString::fromUtf8(
"horizontalLayout"));
385 horizontalLayout->setContentsMargins(0, 0, 0, 0);
386 btnMenu =
new QToolButton(widget_menu);
387 btnMenu->setObjectName(QString::fromUtf8(
"btnMenu"));
388 QSizePolicy sizePolicy3(QSizePolicy::Fixed, QSizePolicy::Expanding);
389 sizePolicy3.setHorizontalStretch(0);
390 sizePolicy3.setVerticalStretch(0);
391 sizePolicy3.setHeightForWidth(btnMenu->sizePolicy().hasHeightForWidth());
392 btnMenu->setSizePolicy(sizePolicy3);
393 btnMenu->setMinimumSize(QSize(30, 0));
394 btnMenu->setMaximumSize(QSize(30, 16777215));
395 btnMenu->setFocusPolicy(Qt::NoFocus);
396 btnMenu->setPopupMode(QToolButton::InstantPopup);
398 horizontalLayout->addWidget(btnMenu);
400 btnMenu_Min =
new QPushButton(widget_menu);
401 btnMenu_Min->setObjectName(QString::fromUtf8(
"btnMenu_Min"));
402 QSizePolicy sizePolicy4(QSizePolicy::Minimum, QSizePolicy::Expanding);
403 sizePolicy4.setHorizontalStretch(0);
404 sizePolicy4.setVerticalStretch(0);
405 sizePolicy4.setHeightForWidth(btnMenu_Min->sizePolicy().hasHeightForWidth());
406 btnMenu_Min->setSizePolicy(sizePolicy4);
407 btnMenu_Min->setMinimumSize(QSize(30, 0));
408 btnMenu_Min->setMaximumSize(QSize(30, 16777215));
409 btnMenu_Min->setCursor(QCursor(Qt::ArrowCursor));
410 btnMenu_Min->setFocusPolicy(Qt::NoFocus);
412 horizontalLayout->addWidget(btnMenu_Min);
414 btnMenu_Max =
new QPushButton(widget_menu);
415 btnMenu_Max->setObjectName(QString::fromUtf8(
"btnMenu_Max"));
416 sizePolicy3.setHeightForWidth(btnMenu_Max->sizePolicy().hasHeightForWidth());
417 btnMenu_Max->setSizePolicy(sizePolicy3);
418 btnMenu_Max->setMinimumSize(QSize(30, 0));
419 btnMenu_Max->setMaximumSize(QSize(30, 16777215));
420 btnMenu_Max->setCursor(QCursor(Qt::ArrowCursor));
421 btnMenu_Max->setFocusPolicy(Qt::NoFocus);
423 horizontalLayout->addWidget(btnMenu_Max);
425 btnMenu_Close =
new QPushButton(widget_menu);
426 btnMenu_Close->setObjectName(QString::fromUtf8(
"btnMenu_Close"));
427 sizePolicy3.setHeightForWidth(btnMenu_Close->sizePolicy().hasHeightForWidth());
428 btnMenu_Close->setSizePolicy(sizePolicy3);
429 btnMenu_Close->setMinimumSize(QSize(30, 0));
430 btnMenu_Close->setMaximumSize(QSize(30, 16777215));
431 btnMenu_Close->setCursor(QCursor(Qt::ArrowCursor));
432 btnMenu_Close->setFocusPolicy(Qt::NoFocus);
434 horizontalLayout->addWidget(btnMenu_Close);
435 horizontalLayout4->addWidget(widget_menu);
436 verticalLayout2->addWidget(widget_title);
438 widget =
new QWidget(widgetMain);
439 widget->setObjectName(QString::fromUtf8(
"widget"));
440 widget->setFocusPolicy(Qt::NoFocus);
441 verticalLayout3 =
new QVBoxLayout(widget);
442 verticalLayout3->setSpacing(0);
443 verticalLayout3->setContentsMargins(11, 11, 11, 11);
444 verticalLayout3->setObjectName(QString::fromUtf8(
"verticalLayout3"));
445 verticalLayout3->setContentsMargins(0, 0, 0, 0);
447 verticalLayout2->addWidget(widget);
448 verticalLayout1->addWidget(widgetMain);
450 connect(this->btnMenu_Min, SIGNAL(clicked(
bool)),
this, SLOT(on_btnMenu_Min_clicked()));
451 connect(this->btnMenu_Max, SIGNAL(clicked(
bool)),
this, SLOT(on_btnMenu_Max_clicked()));
452 connect(this->btnMenu_Close, SIGNAL(clicked(
bool)),
this, SLOT(on_btnMenu_Close_clicked()));
455void QUIWidget::initForm()
458 setIcon(QUIWidget::Lab_Ico, QChar(0xf072), 11);
459 setIcon(QUIWidget::BtnMenu, QChar(0xf0d7));
460 setIcon(QUIWidget::BtnMenu_Min, QChar(0xf068));
461 setIcon(QUIWidget::BtnMenu_Max, QChar(0xf096));
462 setIcon(QUIWidget::BtnMenu_Close, QChar(0xf00d));
465 setTitle(
"QUI Demo");
466 setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
467 setVisible(QUIWidget::BtnMenu,
false);
471 location = this->geometry();
472 this->setProperty(
"form",
true);
473 this->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint);
476 this->installEventFilter(
this);
477 this->widget_title->installEventFilter(
this);
479#if defined(DEBUG) || defined(_DEBUG)
484 name << tr(
"Silvery") << tr(
"Blue") << tr(
"Light blue") << tr(
"Dark blue")
485 << tr(
"Gray") << tr(
"Light gray") << tr(
"Dark gray") << tr(
"Black")
486 << tr(
"Light black") << tr(
"Dark black") << tr(
"PS black")
487 << tr(
"Flat black") << tr(
"Flat white");
488 foreach (QString str, name) {
489 QAction *action =
new QAction(str,
this);
490 this->btnMenu->addAction(action);
491 connect(action, SIGNAL(triggered(
bool)),
this, SLOT(changeStyle()));
496void QUIWidget::changeStyle()
498 QAction *act = (QAction *)sender();
499 QString name = act->text();
500 QString qssFile =
":/qss/blue.css";
502 if (name == tr(
"Silvery")) {
503 qssFile =
":/qss/silvery.css";
504 setStyle(QUIWidget::Style_Silvery);
505 }
else if (name == tr(
"Blue")) {
506 qssFile =
":/qss/blue.css";
507 setStyle(QUIWidget::Style_Blue);
508 }
else if (name == tr(
"Light blue")) {
509 qssFile =
":/qss/lightblue.css";
510 setStyle(QUIWidget::Style_LightBlue);
511 }
else if (name == tr(
"Dark blue")) {
512 qssFile =
":/qss/darkblue.css";
513 setStyle(QUIWidget::Style_DarkBlue);
514 }
else if (name == tr(
"Gray")) {
515 qssFile =
":/qss/gray.css";
516 setStyle(QUIWidget::Style_Gray);
517 }
else if (name == tr(
"Light gray")) {
518 qssFile =
":/qss/light gray.css";
519 setStyle(QUIWidget::Style_LightGray);
520 }
else if (name == tr(
"Dark gray")) {
521 qssFile =
":/qss/darkgray.css";
522 setStyle(QUIWidget::Style_DarkGray);
523 }
else if (name == tr(
"Black")) {
524 qssFile =
":/qss/black.css";
525 setStyle(QUIWidget::Style_Black);
526 }
else if (name == tr(
"Light black")) {
527 qssFile =
":/qss/lightblack.css";
528 setStyle(QUIWidget::Style_LightBlack);
529 }
else if (name == tr(
"Dark black")) {
530 qssFile =
":/qss/darkblack.css";
531 setStyle(QUIWidget::Style_DarkBlack);
532 }
else if (name == tr(
"PS black")) {
533 qssFile =
":/qss/psblack.css";
534 setStyle(QUIWidget::Style_PSBlack);
535 }
else if (name == tr(
"Flat black")) {
536 qssFile =
":/qss/flatblack.css";
537 setStyle(QUIWidget::Style_FlatBlack);
538 }
else if (name == tr(
"Flat white")) {
539 qssFile =
":/qss/flatwhite.css";
540 setStyle(QUIWidget::Style_FlatWhite);
543 emit sigChangeStyle(qssFile);
546void QUIWidget::setIcon(QUIWidget::Widget widget, QChar str, quint32 size)
548 if (widget == QUIWidget::Lab_Ico) {
549 IconHelper::Instance()->setIcon(this->lab_Ico, str, size);
550 }
else if (widget == QUIWidget::BtnMenu) {
551 IconHelper::Instance()->setIcon(this->btnMenu, str, size);
552 }
else if (widget == QUIWidget::BtnMenu_Min) {
553 IconHelper::Instance()->setIcon(this->btnMenu_Min, str, size);
554 }
else if (widget == QUIWidget::BtnMenu_Max) {
555 IconHelper::Instance()->setIcon(this->btnMenu_Max, str, size);
556 }
else if (widget == QUIWidget::BtnMenu_Close) {
557 IconHelper::Instance()->setIcon(this->btnMenu_Close, str, size);
561void QUIWidget::setPixmap(QUIWidget::Widget widget,
const QString &file,
const QSize &size)
563 QPixmap pix = QPixmap(file);
565 pix = pix.scaled(size, Qt::KeepAspectRatio);
567 if (widget == QUIWidget::Lab_Ico) {
568 this->lab_Ico->setPixmap(pix);
569 }
else if (widget == QUIWidget::BtnMenu) {
570 this->btnMenu->setIcon(QIcon(file));
571 }
else if (widget == QUIWidget::BtnMenu_Min) {
572 this->btnMenu_Min->setIcon(QIcon(file));
573 }
else if (widget == QUIWidget::BtnMenu_Max) {
574 this->btnMenu_Max->setIcon(QIcon(file));
575 }
else if (widget == QUIWidget::BtnMenu_Close) {
576 this->btnMenu_Close->setIcon(QIcon(file));
580void QUIWidget::setVisible(QUIWidget::Widget widget,
bool visible)
582 if (widget == QUIWidget::Lab_Ico) {
583 this->lab_Ico->setVisible(visible);
584 }
else if (widget == QUIWidget::BtnMenu) {
585 this->btnMenu->setVisible(visible);
586 }
else if (widget == QUIWidget::BtnMenu_Min) {
587 this->btnMenu_Min->setVisible(visible);
588 }
else if (widget == QUIWidget::BtnMenu_Max) {
589 this->btnMenu_Max->setVisible(visible);
590 }
else if (widget == QUIWidget::BtnMenu_Close) {
591 this->btnMenu_Close->setVisible(visible);
595void QUIWidget::setOnlyCloseBtn()
597 this->btnMenu->setVisible(
false);
598 this->btnMenu_Min->setVisible(
false);
599 this->btnMenu_Max->setVisible(
false);
602void QUIWidget::setTitleHeight(
int height)
604 this->widget_title->setFixedHeight(height);
607void QUIWidget::setBtnWidth(
int width)
609 this->lab_Ico->setFixedWidth(width);
610 this->btnMenu->setFixedWidth(width);
611 this->btnMenu_Min->setFixedWidth(width);
612 this->btnMenu_Max->setFixedWidth(width);
613 this->btnMenu_Close->setFixedWidth(width);
616void QUIWidget::setTitle(
const QString &title)
618 if (this->title != title) {
620 this->lab_Title->setText(title);
621 this->setWindowTitle(this->lab_Title->text());
625void QUIWidget::setAlignment(Qt::Alignment alignment)
627 if (this->alignment != alignment) {
628 this->alignment = alignment;
629 this->lab_Title->setAlignment(alignment);
633void QUIWidget::setMainWidget(QWidget *mainWidget,
bool bUsed)
635 Q_ASSERT(mainWidget);
637 if (this->mainWidget == 0) {
639 this->widget->layout()->addWidget(mainWidget);
641 resize(mainWidget->width(), mainWidget->height() + this->widget_title->height());
643 this->mainWidget = mainWidget;
644 this->mainWidget->installEventFilter(
this);
648 this->setTitle(mainWidget->windowTitle());
649 QIcon icon = mainWidget->windowIcon();
651 this->lab_Ico->setPixmap(icon.pixmap(lab_Ico->size()));
658void QUIWidget::on_btnMenu_Min_clicked()
663void QUIWidget::on_btnMenu_Max_clicked()
666 setIcon(QUIWidget::BtnMenu_Max, QChar(0xf096));
667 this->setGeometry(location);
669 setIcon(BtnMenu_Max, QChar(0xf24d));
670 location = this->geometry();
671#if QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
672 this->setGeometry(qApp->primaryScreen()->availableGeometry());
674 this->setGeometry(qApp->desktop()->availableGeometry());
681void QUIWidget::on_btnMenu_Close_clicked()
685 bClose = mainWidget->close();
690void QUIWidget::resizeEvent(QResizeEvent *event)
694 widget_title->setVisible(
false);
696 widget_title->setVisible(
true);
697 QDialog::resizeEvent(event);
700void QUIWidget::showEvent(QShowEvent *event)
704 widget_title->setVisible(
false);
706 widget_title->setVisible(
true);
708 QDialog::showEvent(event);
712QUIMessageBox::QUIMessageBox(QWidget *parent) : QDialog(parent)
718QUIMessageBox::~QUIMessageBox()
723void QUIMessageBox::initControl()
725 this->setObjectName(QString::fromUtf8(
"QUIMessageBox"));
726 this->resize(280, 150);
727 verticalLayout1 =
new QVBoxLayout(
this);
728 verticalLayout1->setSpacing(0);
729 verticalLayout1->setObjectName(QString::fromUtf8(
"verticalLayout1"));
730 verticalLayout1->setContentsMargins(1, 1, 1, 1);
731 widget_title =
new QWidget(
this);
732 widget_title->setObjectName(QString::fromUtf8(
"widget_title"));
733 QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
734 sizePolicy.setHorizontalStretch(0);
735 sizePolicy.setVerticalStretch(0);
736 sizePolicy.setHeightForWidth(widget_title->sizePolicy().hasHeightForWidth());
737 widget_title->setSizePolicy(sizePolicy);
738 widget_title->setMinimumSize(QSize(0, 30));
739 horizontalLayout3 =
new QHBoxLayout(widget_title);
740 horizontalLayout3->setSpacing(0);
741 horizontalLayout3->setObjectName(QString::fromUtf8(
"horizontalLayout3"));
742 horizontalLayout3->setContentsMargins(0, 0, 0, 0);
743 lab_Ico =
new QLabel(widget_title);
744 lab_Ico->setObjectName(QString::fromUtf8(
"lab_Ico"));
745 QSizePolicy sizePolicy1(QSizePolicy::Minimum, QSizePolicy::Preferred);
746 sizePolicy1.setHorizontalStretch(0);
747 sizePolicy1.setVerticalStretch(0);
748 sizePolicy1.setHeightForWidth(lab_Ico->sizePolicy().hasHeightForWidth());
749 lab_Ico->setSizePolicy(sizePolicy1);
750 lab_Ico->setMinimumSize(QSize(31, 0));
751 lab_Ico->setAlignment(Qt::AlignCenter);
753 horizontalLayout3->addWidget(lab_Ico);
755 lab_Title =
new QLabel(widget_title);
756 lab_Title->setObjectName(QString::fromUtf8(
"lab_Title"));
757 lab_Title->setStyleSheet(QString::fromUtf8(
""));
758 lab_Title->setAlignment(Qt::AlignLeading | Qt::AlignLeft | Qt::AlignVCenter);
760 horizontalLayout3->addWidget(lab_Title);
762 labTime =
new QLabel(widget_title);
763 labTime->setObjectName(QString::fromUtf8(
"labTime"));
764 QSizePolicy sizePolicy2(QSizePolicy::Expanding, QSizePolicy::Preferred);
765 sizePolicy2.setHorizontalStretch(0);
766 sizePolicy2.setVerticalStretch(0);
767 sizePolicy2.setHeightForWidth(labTime->sizePolicy().hasHeightForWidth());
768 labTime->setSizePolicy(sizePolicy2);
769 labTime->setAlignment(Qt::AlignCenter);
771 horizontalLayout3->addWidget(labTime);
773 widget_menu =
new QWidget(widget_title);
774 widget_menu->setObjectName(QString::fromUtf8(
"widget_menu"));
775 sizePolicy1.setHeightForWidth(widget_menu->sizePolicy().hasHeightForWidth());
776 widget_menu->setSizePolicy(sizePolicy1);
777 horizontalLayout4 =
new QHBoxLayout(widget_menu);
778 horizontalLayout4->setSpacing(0);
779 horizontalLayout4->setObjectName(QString::fromUtf8(
"horizontalLayout4"));
780 horizontalLayout4->setContentsMargins(0, 0, 0, 0);
781 btnMenu_Close =
new QPushButton(widget_menu);
782 btnMenu_Close->setObjectName(QString::fromUtf8(
"btnMenu_Close"));
783 QSizePolicy sizePolicy3(QSizePolicy::Minimum, QSizePolicy::Expanding);
784 sizePolicy3.setHorizontalStretch(0);
785 sizePolicy3.setVerticalStretch(0);
786 sizePolicy3.setHeightForWidth(btnMenu_Close->sizePolicy().hasHeightForWidth());
787 btnMenu_Close->setSizePolicy(sizePolicy3);
788 btnMenu_Close->setMinimumSize(QSize(30, 0));
789 btnMenu_Close->setMaximumSize(QSize(30, 16777215));
790 btnMenu_Close->setCursor(QCursor(Qt::ArrowCursor));
791 btnMenu_Close->setFocusPolicy(Qt::NoFocus);
792 btnMenu_Close->setFlat(
true);
794 horizontalLayout4->addWidget(btnMenu_Close);
795 horizontalLayout3->addWidget(widget_menu);
796 verticalLayout1->addWidget(widget_title);
798 widgetMain =
new QWidget(
this);
799 widgetMain->setObjectName(QString::fromUtf8(
"widgetMain"));
800 widgetMain->setStyleSheet(QString::fromUtf8(
""));
801 verticalLayout2 =
new QVBoxLayout(widgetMain);
802 verticalLayout2->setSpacing(5);
803 verticalLayout2->setObjectName(QString::fromUtf8(
"verticalLayout2"));
804 verticalLayout2->setContentsMargins(5, 5, 5, 5);
805 frame =
new QFrame(widgetMain);
806 frame->setObjectName(QString::fromUtf8(
"frame"));
807 frame->setFrameShape(QFrame::Box);
808 frame->setFrameShadow(QFrame::Sunken);
809 verticalLayout4 =
new QVBoxLayout(frame);
810 verticalLayout4->setObjectName(QString::fromUtf8(
"verticalLayout4"));
811 verticalLayout4->setContentsMargins(-1, 9, -1, -1);
812 horizontalLayout1 =
new QHBoxLayout();
813 horizontalLayout1->setObjectName(QString::fromUtf8(
"horizontalLayout1"));
814 labIcoMain =
new QLabel(frame);
815 labIcoMain->setObjectName(QString::fromUtf8(
"labIcoMain"));
816 labIcoMain->setMinimumSize(QSize(30, 30));
817 labIcoMain->setMaximumSize(QSize(30, 30));
818 labIcoMain->setStyleSheet(QString::fromUtf8(
"border-image: url(:/image/msg_info.png);"));
820 horizontalLayout1->addWidget(labIcoMain);
822 horizontalSpacer1 =
new QSpacerItem(5, 0, QSizePolicy::Minimum, QSizePolicy::Minimum);
824 horizontalLayout1->addItem(horizontalSpacer1);
826 labInfo =
new QLabel(frame);
827 labInfo->setObjectName(QString::fromUtf8(
"labInfo"));
828 QSizePolicy sizePolicy4(QSizePolicy::Expanding, QSizePolicy::Expanding);
829 sizePolicy4.setHorizontalStretch(0);
830 sizePolicy4.setVerticalStretch(0);
831 sizePolicy4.setHeightForWidth(labInfo->sizePolicy().hasHeightForWidth());
832 labInfo->setSizePolicy(sizePolicy4);
833 labInfo->setMinimumSize(QSize(0, 33));
834 labInfo->setScaledContents(
false);
835 labInfo->setWordWrap(
true);
837 horizontalLayout1->addWidget(labInfo);
840 verticalLayout4->addLayout(horizontalLayout1);
842 horizontalLayout2 =
new QHBoxLayout();
843 horizontalLayout2->setObjectName(QString::fromUtf8(
"horizontalLayout2"));
844 horizontalSpacer2 =
new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
846 horizontalLayout2->addItem(horizontalSpacer2);
848 btnOk =
new QPushButton(frame);
849 btnOk->setObjectName(QString::fromUtf8(
"btnOk"));
850 btnOk->setMinimumSize(QSize(80, 0));
851 btnOk->setFocusPolicy(Qt::StrongFocus);
852 btnOk->setStyleSheet(QString::fromUtf8(
""));
854 icon.addFile(QString::fromUtf8(
":/image/btn_ok.png"), QSize(), QIcon::Normal, QIcon::Off);
855 btnOk->setIcon(icon);
857 horizontalLayout2->addWidget(btnOk);
859 btnCancel =
new QPushButton(frame);
860 btnCancel->setObjectName(QString::fromUtf8(
"btnCancel"));
861 btnCancel->setMinimumSize(QSize(80, 0));
862 btnCancel->setFocusPolicy(Qt::StrongFocus);
863 btnCancel->setStyleSheet(QString::fromUtf8(
""));
865 icon1.addFile(QString::fromUtf8(
":/image/btn_close.png"), QSize(), QIcon::Normal, QIcon::Off);
866 btnCancel->setIcon(icon1);
868 horizontalLayout2->addWidget(btnCancel);
869 verticalLayout4->addLayout(horizontalLayout2);
870 verticalLayout2->addWidget(frame);
871 verticalLayout1->addWidget(widgetMain);
873 widget_title->raise();
877 this->btnOk->setText(tr(
"OK"));
878 this->btnCancel->setText(tr(
"Cancel"));
880 connect(this->btnOk, SIGNAL(clicked()),
this, SLOT(on_btnOk_clicked()));
881 connect(this->btnMenu_Close, SIGNAL(clicked(
bool)),
this, SLOT(on_btnMenu_Close_clicked()));
882 connect(this->btnCancel, SIGNAL(clicked()),
this, SLOT(on_btnMenu_Close_clicked()));
885void QUIMessageBox::initForm()
887 IconHelper::Instance()->setIcon(this->lab_Ico, QChar(0xf072), 11);
888 IconHelper::Instance()->setIcon(this->btnMenu_Close, QChar(0xf00d), 9);
890 this->setProperty(
"form",
true);
891 this->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowStaysOnTopHint);
892 this->setFixedSize(280, 150);
893 this->setWindowTitle(this->lab_Title->text());
898 this->labIcoMain->setFixedSize(30, 30);
900 QList<QPushButton *> btns1 = this->frame->findChildren<QPushButton *>();
902 foreach (QPushButton *btn, btns1) {
903 btn->setMinimumWidth(width);
904 btn->setIconSize(QSize(iconWidth, iconHeight));
910 QTimer *timer =
new QTimer(
this);
911 timer->setInterval(1000);
912 connect(timer, SIGNAL(timeout()),
this, SLOT(checkSec()));
915 this->installEventFilter(
this);
918void QUIMessageBox::checkSec()
924 if (currentSec < closeSec) {
930 QString str = tr(
"Turn off countdown %1 s").arg(closeSec - currentSec + 1);
931 this->labTime->setText(str);
934void QUIMessageBox::setMessage(
const QString &msg,
int type,
int closeSec)
936 this->closeSec = closeSec;
937 this->currentSec = 0;
938 this->labTime->clear();
943 this->labIcoMain->setStyleSheet(
"border-image: url(:/image/msg_info.png);");
944 this->btnCancel->setVisible(
false);
945 this->lab_Title->setText(tr(
"Prompt"));
946 }
else if (type == 1) {
947 this->labIcoMain->setStyleSheet(
"border-image: url(:/image/msg_question.png);");
948 this->lab_Title->setText(tr(
"Query"));
949 }
else if (type == 2) {
950 this->labIcoMain->setStyleSheet(
"border-image: url(:/image/msg_error.png);");
951 this->btnCancel->setVisible(
false);
952 this->lab_Title->setText(tr(
"Error"));
955 this->labInfo->setText(msg);
956 this->setWindowTitle(this->lab_Title->text());
959void QUIMessageBox::closeEvent(QCloseEvent *)
965bool QUIMessageBox::eventFilter(QObject *obj, QEvent *evt)
967 static QPoint mousePoint;
968 static bool mousePressed =
false;
970 QMouseEvent *
event =
static_cast<QMouseEvent *
>(evt);
971 if (event->type() == QEvent::MouseButtonPress) {
972 if (event->button() == Qt::LeftButton) {
974 mousePoint =
event->globalPos() - this->pos();
977 }
else if (event->type() == QEvent::MouseButtonRelease) {
978 mousePressed =
false;
980 }
else if (event->type() == QEvent::MouseMove) {
981 if (mousePressed && (event->buttons() && Qt::LeftButton)) {
982 this->move(event->globalPos() - mousePoint);
987 return QWidget::eventFilter(obj, evt);
990void QUIMessageBox::on_btnOk_clicked()
996void QUIMessageBox::on_btnMenu_Close_clicked()
1004QUIInputBox::QUIInputBox(QWidget *parent) : QDialog(parent)
1006 this->initControl();
1010QUIInputBox::~QUIInputBox()
1015void QUIInputBox::initControl()
1017 this->setObjectName(QString::fromUtf8(
"QUIInputBox"));
1018 this->resize(260, 166);
1019 verticalLayout1 =
new QVBoxLayout(
this);
1020 verticalLayout1->setSpacing(0);
1021 verticalLayout1->setObjectName(QString::fromUtf8(
"verticalLayout1"));
1022 verticalLayout1->setContentsMargins(1, 1, 1, 1);
1023 widget_title =
new QWidget(
this);
1024 widget_title->setObjectName(QString::fromUtf8(
"widget_title"));
1025 QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
1026 sizePolicy.setHorizontalStretch(0);
1027 sizePolicy.setVerticalStretch(0);
1028 sizePolicy.setHeightForWidth(widget_title->sizePolicy().hasHeightForWidth());
1029 widget_title->setSizePolicy(sizePolicy);
1030 widget_title->setMinimumSize(QSize(0, 30));
1031 horizontalLayout1 =
new QHBoxLayout(widget_title);
1032 horizontalLayout1->setSpacing(0);
1033 horizontalLayout1->setObjectName(QString::fromUtf8(
"horizontalLayout1"));
1034 horizontalLayout1->setContentsMargins(0, 0, 0, 0);
1035 lab_Ico =
new QLabel(widget_title);
1036 lab_Ico->setObjectName(QString::fromUtf8(
"lab_Ico"));
1037 QSizePolicy sizePolicy1(QSizePolicy::Minimum, QSizePolicy::Preferred);
1038 sizePolicy1.setHorizontalStretch(0);
1039 sizePolicy1.setVerticalStretch(0);
1040 sizePolicy1.setHeightForWidth(lab_Ico->sizePolicy().hasHeightForWidth());
1041 lab_Ico->setSizePolicy(sizePolicy1);
1042 lab_Ico->setMinimumSize(QSize(31, 0));
1043 lab_Ico->setAlignment(Qt::AlignCenter);
1045 horizontalLayout1->addWidget(lab_Ico);
1047 lab_Title =
new QLabel(widget_title);
1048 lab_Title->setObjectName(QString::fromUtf8(
"lab_Title"));
1049 lab_Title->setStyleSheet(QString::fromUtf8(
""));
1050 lab_Title->setAlignment(Qt::AlignLeading | Qt::AlignLeft | Qt::AlignVCenter);
1052 horizontalLayout1->addWidget(lab_Title);
1054 labTime =
new QLabel(widget_title);
1055 labTime->setObjectName(QString::fromUtf8(
"labTime"));
1056 QSizePolicy sizePolicy2(QSizePolicy::Expanding, QSizePolicy::Preferred);
1057 sizePolicy2.setHorizontalStretch(0);
1058 sizePolicy2.setVerticalStretch(0);
1059 sizePolicy2.setHeightForWidth(labTime->sizePolicy().hasHeightForWidth());
1060 labTime->setSizePolicy(sizePolicy2);
1061 labTime->setAlignment(Qt::AlignCenter);
1063 horizontalLayout1->addWidget(labTime);
1065 widget_menu =
new QWidget(widget_title);
1066 widget_menu->setObjectName(QString::fromUtf8(
"widget_menu"));
1067 sizePolicy1.setHeightForWidth(widget_menu->sizePolicy().hasHeightForWidth());
1068 widget_menu->setSizePolicy(sizePolicy1);
1069 horizontalLayout2 =
new QHBoxLayout(widget_menu);
1070 horizontalLayout2->setSpacing(0);
1071 horizontalLayout2->setObjectName(QString::fromUtf8(
"horizontalLayout2"));
1072 horizontalLayout2->setContentsMargins(0, 0, 0, 0);
1073 btnMenu_Close =
new QPushButton(widget_menu);
1074 btnMenu_Close->setObjectName(QString::fromUtf8(
"btnMenu_Close"));
1075 QSizePolicy sizePolicy3(QSizePolicy::Minimum, QSizePolicy::Expanding);
1076 sizePolicy3.setHorizontalStretch(0);
1077 sizePolicy3.setVerticalStretch(0);
1078 sizePolicy3.setHeightForWidth(btnMenu_Close->sizePolicy().hasHeightForWidth());
1079 btnMenu_Close->setSizePolicy(sizePolicy3);
1080 btnMenu_Close->setMinimumSize(QSize(30, 0));
1081 btnMenu_Close->setMaximumSize(QSize(30, 16777215));
1082 btnMenu_Close->setCursor(QCursor(Qt::ArrowCursor));
1083 btnMenu_Close->setFocusPolicy(Qt::NoFocus);
1084 btnMenu_Close->setFlat(
true);
1086 horizontalLayout2->addWidget(btnMenu_Close);
1087 horizontalLayout1->addWidget(widget_menu);
1088 verticalLayout1->addWidget(widget_title);
1090 widgetMain =
new QWidget(
this);
1091 widgetMain->setObjectName(QString::fromUtf8(
"widgetMain"));
1092 widgetMain->setStyleSheet(QString::fromUtf8(
""));
1093 verticalLayout2 =
new QVBoxLayout(widgetMain);
1094 verticalLayout2->setSpacing(5);
1095 verticalLayout2->setObjectName(QString::fromUtf8(
"verticalLayout2"));
1096 verticalLayout2->setContentsMargins(5, 5, 5, 5);
1097 frame =
new QFrame(widgetMain);
1098 frame->setObjectName(QString::fromUtf8(
"frame"));
1099 frame->setFrameShape(QFrame::Box);
1100 frame->setFrameShadow(QFrame::Sunken);
1101 verticalLayout3 =
new QVBoxLayout(frame);
1102 verticalLayout3->setObjectName(QString::fromUtf8(
"verticalLayout3"));
1103 labInfo =
new QLabel(frame);
1104 labInfo->setObjectName(QString::fromUtf8(
"labInfo"));
1105 labInfo->setScaledContents(
false);
1106 labInfo->setWordWrap(
true);
1108 verticalLayout3->addWidget(labInfo);
1110 txtValue =
new QLineEdit(frame);
1111 txtValue->setObjectName(QString::fromUtf8(
"txtValue"));
1113 verticalLayout3->addWidget(txtValue);
1115 cboxValue =
new QComboBox(frame);
1116 cboxValue->setObjectName(QString::fromUtf8(
"cboxValue"));
1118 verticalLayout3->addWidget(cboxValue);
1120 lay =
new QHBoxLayout();
1121 lay->setObjectName(QString::fromUtf8(
"lay"));
1122 horizontalSpacer =
new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
1124 lay->addItem(horizontalSpacer);
1126 btnOk =
new QPushButton(frame);
1127 btnOk->setObjectName(QString::fromUtf8(
"btnOk"));
1128 btnOk->setMinimumSize(QSize(80, 0));
1129 btnOk->setStyleSheet(QString::fromUtf8(
""));
1131 icon.addFile(QString::fromUtf8(
":/image/btn_ok.png"), QSize(), QIcon::Normal, QIcon::Off);
1132 btnOk->setIcon(icon);
1134 lay->addWidget(btnOk);
1136 btnCancel =
new QPushButton(frame);
1137 btnCancel->setObjectName(QString::fromUtf8(
"btnCancel"));
1138 btnCancel->setMinimumSize(QSize(80, 0));
1139 btnCancel->setStyleSheet(QString::fromUtf8(
""));
1141 icon1.addFile(QString::fromUtf8(
":/image/btn_close.png"), QSize(), QIcon::Normal, QIcon::Off);
1142 btnCancel->setIcon(icon1);
1144 lay->addWidget(btnCancel);
1145 verticalLayout3->addLayout(lay);
1146 verticalLayout2->addWidget(frame);
1147 verticalLayout1->addWidget(widgetMain);
1149 setTabOrder(txtValue, btnOk);
1150 setTabOrder(btnOk, btnCancel);
1152 this->lab_Title->setText(tr(
"Input box"));
1153 this->btnOk->setText(tr(
"OK"));
1154 this->btnCancel->setText(tr(
"Cancel"));
1156 connect(this->btnOk, SIGNAL(clicked()),
this, SLOT(on_btnOk_clicked()));
1157 connect(this->btnMenu_Close, SIGNAL(clicked(
bool)),
this, SLOT(on_btnMenu_Close_clicked()));
1158 connect(this->btnCancel, SIGNAL(clicked()),
this, SLOT(on_btnMenu_Close_clicked()));
1161void QUIInputBox::initForm()
1164 IconHelper::Instance()->setIcon(this->lab_Ico, QChar(0xf072), 11);
1165 IconHelper::Instance()->setIcon(this->btnMenu_Close, QChar(0xf00d), 9);
1167 this->setProperty(
"form",
true);
1168 this->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowStaysOnTopHint);
1169 this->setFixedSize(280, 150);
1170 this->setWindowTitle(this->lab_Title->text());
1174 int iconHeight = 18;
1176 QList<QPushButton *> btns = this->frame->findChildren<QPushButton *>();
1178 foreach (QPushButton *btn, btns) {
1179 btn->setMinimumWidth(width);
1180 btn->setIconSize(QSize(iconWidth, iconHeight));
1186 QTimer *timer =
new QTimer(
this);
1187 timer->setInterval(1000);
1188 connect(timer, SIGNAL(timeout()),
this, SLOT(checkSec()));
1191 this->installEventFilter(
this);
1194void QUIInputBox::checkSec()
1196 if (closeSec == 0) {
1200 if (currentSec < closeSec) {
1206 QString str = tr(
"Turn off countdown %1 s").arg(closeSec - currentSec + 1);
1207 this->labTime->setText(str);
1210void QUIInputBox::setParameter(
const QString &title,
int type,
int closeSec,
1211 QString defaultValue,
bool pwd)
1213 this->closeSec = closeSec;
1214 this->currentSec = 0;
1215 this->labTime->clear();
1216 this->labInfo->setText(title);
1221 this->cboxValue->setVisible(
false);
1222 this->txtValue->setPlaceholderText(defaultValue);
1225 this->txtValue->setEchoMode(QLineEdit::Password);
1227 }
else if (type == 1) {
1228 this->txtValue->setVisible(
false);
1229 this->cboxValue->addItems(defaultValue.split(
"|"));
1233QString QUIInputBox::getValue()
const
1238void QUIInputBox::closeEvent(QCloseEvent *)
1244bool QUIInputBox::eventFilter(QObject *obj, QEvent *evt)
1246 static QPoint mousePoint;
1247 static bool mousePressed =
false;
1249 QMouseEvent *
event =
static_cast<QMouseEvent *
>(evt);
1250 if (event->type() == QEvent::MouseButtonPress) {
1251 if (event->button() == Qt::LeftButton) {
1252 mousePressed =
true;
1253 mousePoint =
event->globalPos() - this->pos();
1256 }
else if (event->type() == QEvent::MouseButtonRelease) {
1257 mousePressed =
false;
1259 }
else if (event->type() == QEvent::MouseMove) {
1260 if (mousePressed && (event->buttons() && Qt::LeftButton)) {
1261 this->move(event->globalPos() - mousePoint);
1266 return QWidget::eventFilter(obj, evt);
1269void QUIInputBox::on_btnOk_clicked()
1271 if (this->txtValue->isVisible()) {
1272 value = this->txtValue->text();
1273 }
else if (this->cboxValue->isVisible()) {
1274 value = this->cboxValue->currentText();
1281void QUIInputBox::on_btnMenu_Close_clicked()
1288IconHelper::IconHelper(QObject *) : QObject(qApp)
1290 int fontId = QFontDatabase::addApplicationFont(
":/image/fontawesome-webfont.ttf");
1291 QStringList fontName = QFontDatabase::applicationFontFamilies(fontId);
1293 if (fontName.count() > 0) {
1294 iconFont = QFont(fontName.at(0));
1296 qDebug() <<
"load fontawesome-webfont.ttf error";
1301void IconHelper::setIcon(QLabel *lab, QChar c, quint32 size)
1303 iconFont.setPointSize(size);
1304 lab->setFont(iconFont);
1308void IconHelper::setIcon(QAbstractButton *btn, QChar c, quint32 size)
1310 iconFont.setPointSize(size);
1311 btn->setFont(iconFont);