29 #include <QMouseEvent>
31 #include <qnamespace.h>
50 setAttribute(Qt::WA_TransparentForMouseEvents,
false);
58 QRubberBand::paintEvent(
event);
61 p.drawPixmap(0, 0,
minus);
71 if (
event->button() == Qt::LeftButton) {
77 parentWidget()->update();
89 setCursor(Qt::SizeAllCursor);
91 pix.setDevicePixelRatio(2);
106 if (!
king()->interface_locked) {
107 auto new_location =
event->globalPos() -
point;
108 if (new_location.x() < 0) {
109 new_location.setX(0);
110 }
else if (new_location.x() + width()
111 > parentWidget()->parentWidget()->width()) {
112 new_location.setX(parentWidget()->parentWidget()->width() - width());
114 if (new_location.y() < 0) {
115 new_location.setY(0);
116 }
else if (new_location.y() + height()
117 > parentWidget()->parentWidget()->height()) {
118 new_location.setY(parentWidget()->parentWidget()->height() - height());
120 parentWidget()->move(new_location);
129 if (!
king()->interface_locked) {
130 point =
event->globalPos() - parentWidget()->geometry().topLeft();
143 setCursor(Qt::ArrowCursor);
145 *pix = pix->scaledToHeight(12);
160 if (
king()->interface_locked) {
163 if (
event->button() == Qt::LeftButton) {
164 parentWidget()->hide();
174 if (
auto fcw = qobject_cast<fcwidget *>(parentWidget()); fcw) {
185 auto margins = QMargins();
186 if (edges & Qt::LeftEdge) {
189 if (edges & Qt::RightEdge) {
192 if (edges & Qt::TopEdge) {
195 if (edges & Qt::BottomEdge) {
198 setContentsMargins(margins);
211 if (
king()->interface_locked) {
214 if (
event->button() == Qt::LeftButton) {
218 event->setAccepted(
true);
227 auto flags = Qt::Edges();
230 flags |= Qt::LeftEdge;
232 &&
event->x() >= width() / 2) {
233 flags |= Qt::RightEdge;
237 flags |= Qt::TopEdge;
239 &&
event->y() >= height() / 2) {
240 flags |= Qt::BottomEdge;
251 if (
king()->interface_locked) {
258 setCursor(Qt::ArrowCursor);
269 if (
king()->interface_locked) {
274 if (
event->buttons() & Qt::LeftButton) {
277 auto new_rect = QRect(pos(),
size());
280 const auto target =
event->pos() + pos();
284 new_rect.setTop(target.y());
285 if (new_rect.height() < minimumHeight()) {
286 new_rect.setTop(new_rect.bottom() - minimumHeight());
289 new_rect.setBottom(target.y());
290 if (new_rect.height() < minimumHeight()) {
291 new_rect.setBottom(new_rect.top() + minimumHeight());
296 new_rect.setLeft(target.x());
297 if (new_rect.width() < minimumWidth()) {
298 new_rect.setLeft(new_rect.right() - minimumWidth());
301 new_rect.setRight(target.x());
302 if (new_rect.width() < minimumWidth()) {
303 new_rect.setRight(new_rect.left() + minimumWidth());
308 new_rect &= parentWidget()->rect();
310 resize(new_rect.size());
311 move(new_rect.topLeft());
318 if (flags == Qt::LeftEdge || flags == Qt::RightEdge) {
319 setCursor(Qt::SizeHorCursor);
320 }
else if (flags == Qt::TopEdge || flags == Qt::BottomEdge) {
321 setCursor(Qt::SizeVerCursor);
322 }
else if (flags == (Qt::TopEdge | Qt::LeftEdge)
323 || flags == (Qt::BottomEdge | Qt::RightEdge)) {
324 setCursor(Qt::SizeFDiagCursor);
325 }
else if (flags == (Qt::TopEdge | Qt::RightEdge)
326 || flags == (Qt::BottomEdge | Qt::LeftEdge)) {
327 setCursor(Qt::SizeBDiagCursor);
330 setCursor(Qt::ArrowCursor);
333 event->setAccepted(
true);
QIcon getIcon(const QString &id)
Returns icon by given name.
QPixmap * getPixmap(const QString &id)
Returns pixmap by given name, pixmap needs to be deleted by someone else.
static fcIcons * instance()
Returns instance of fc_icons.
class fc_client * king()
Return fc_client instance.