LeechCraft 0.6.70-19424-g027e980fd1
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
categoryselectorwindow.cpp
Go to the documentation of this file.
1/**********************************************************************
2 * LeechCraft - modular cross-platform feature rich internet client.
3 * Copyright (C) 2006-2014 Georg Rudoy
4 *
5 * Distributed under the Boost Software License, Version 1.0.
6 * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7 **********************************************************************/
8
10#include <QDialogButtonBox>
11#include <QMoveEvent>
12#include <QScreen>
13#include <QVBoxLayout>
14#include "categoryselector.h"
15
16namespace LC::Util
17{
19 : QDialog { parent }
20 , Selector_ { *new CategorySelector { this } }
21 {
22 setWindowTitle (tr ("Tags selector"));
23 setWindowFlags (Qt::Dialog | Qt::WindowStaysOnTopHint);
24 setMinimumHeight (screen ()->availableGeometry ().height () / 3 * 2);
25
26 const auto box = new QDialogButtonBox { this };
27 switch (buttons)
28 {
29 case Buttons::Close:
30 box->setStandardButtons (QDialogButtonBox::Close);
31 break;
33 box->setStandardButtons (QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
34 break;
35 }
36 connect (box,
37 &QDialogButtonBox::accepted,
38 this,
39 &QDialog::accept);
40 connect (box,
41 &QDialogButtonBox::rejected,
42 this,
43 &QDialog::reject);
44
45 const auto layout = new QVBoxLayout { this };
46 layout->addWidget (&Selector_);
47 layout->addWidget (box);
48 }
49
51 {
52 return Selector_;
53 }
54
56 {
57 QDialog::moveEvent (e);
58
59 const auto& pos = e->pos ();
60 const auto& avail = screen ()->availableGeometry ();
61 int dx = 0;
62 int dy = 0;
63 if (pos.x () + width () > avail.width ())
64 dx = width () + pos.x () - avail.width ();
65 if (pos.y () + height () > avail.height () &&
66 height () < avail.height ())
67 dy = height () + pos.y () - avail.height ();
68
69 if (dx || dy)
70 move (pos - QPoint { dx, dy });
71 }
72}
A checklist over a model of names.
CategorySelectorWindow(Buttons, QWidget *parent=nullptr)
void moveEvent(QMoveEvent *) override