| 47 | #endif |
| 48 | |
| 49 | WindowPicker::WindowPicker() : QWidget(0), mCrosshair(":/icons/picker"), mWindowLabel(Q_NULLPTR), mTaken(false), mCurrentWindow(0) |
| 50 | { |
| 51 | #if defined(Q_OS_WIN) |
| 52 | setWindowFlags(Qt::SplashScreen | Qt::WindowStaysOnTopHint); |
| 53 | #elif defined(Q_OS_LINUX) |
| 54 | setWindowFlags(Qt::WindowStaysOnTopHint); |
| 55 | #endif |
| 56 | |
| 57 | setWindowTitle(tr("Lightscreen Window Picker")); |
| 58 | setStyleSheet("QWidget { color: #000; } #frame { padding: 7px 10px; border: 4px solid #232323; background-color: rgba(250, 250, 250, 255); }"); |
| 59 | |
| 60 | QLabel *helpLabel = new QLabel(tr("Grab the window picker by clicking and holding down the mouse button, then drag it to the window of your choice and release it to capture."), this); |
| 61 | helpLabel->setMinimumWidth(400); |
| 62 | helpLabel->setMaximumWidth(400); |
| 63 | helpLabel->setWordWrap(true); |
| 64 | |
| 65 | mWindowIcon = new QLabel(this); |
| 66 | mWindowIcon->setMinimumSize(22, 22); |
| 67 | mWindowIcon->setMaximumSize(22, 22); |
| 68 | mWindowIcon->setScaledContents(true); |
| 69 | |
| 70 | mWindowLabel = new QLabel(tr(" - Start dragging to select windows"), this); |
| 71 | mWindowLabel->setStyleSheet("font-weight: bold"); |
| 72 | |
| 73 | mCrosshairLabel = new QLabel(this); |
| 74 | mCrosshairLabel->setAlignment(Qt::AlignHCenter); |
| 75 | mCrosshairLabel->setPixmap(mCrosshair); |
| 76 | |
| 77 | QPushButton *closeButton = new QPushButton(tr("Close")); |
| 78 | connect(closeButton, &QPushButton::clicked, this, &WindowPicker::close); |
| 79 | |
| 80 | QHBoxLayout *windowLayout = new QHBoxLayout; |
| 81 | windowLayout->addWidget(mWindowIcon); |
| 82 | windowLayout->addWidget(mWindowLabel); |
| 83 | windowLayout->setMargin(0); |
| 84 | |
| 85 | QHBoxLayout *buttonLayout = new QHBoxLayout; |
| 86 | buttonLayout->addStretch(0); |
| 87 | buttonLayout->addWidget(closeButton); |
| 88 | buttonLayout->setMargin(0); |
| 89 | |
| 90 | QHBoxLayout *crosshairLayout = new QHBoxLayout; |
| 91 | crosshairLayout->addStretch(0); |
| 92 | crosshairLayout->addWidget(mCrosshairLabel); |
| 93 | crosshairLayout->addStretch(0); |
| 94 | crosshairLayout->setMargin(0); |
| 95 | |
| 96 | QVBoxLayout *fl = new QVBoxLayout; |
| 97 | fl->addWidget(helpLabel); |
| 98 | fl->addLayout(windowLayout); |
| 99 | fl->addLayout(crosshairLayout); |
| 100 | fl->addLayout(buttonLayout); |
| 101 | fl->setMargin(0); |
| 102 | |
| 103 | QFrame *frame = new QFrame(this); |
| 104 | frame->setObjectName("frame"); |
| 105 | frame->setLayout(fl); |
| 106 | |