Showing the changes to interface/src/scripting/WebWindowClass.cpp (1 of 2 files). Show all
Unified · Split
| @@ -58,6 +58,7 @@ WebWindowClass::WebWindowClass(const QString& title, const QString& url, int wid · 57 unmodified lines | ||
| 58 | 58 | auto dialogWidget = new QDialog(Application::getInstance()->getWindow(), Qt::Window); |
| 59 | 59 | dialogWidget->setWindowTitle(title); |
| 60 | 60 | dialogWidget->resize(width, height); |
| 61 | + dialogWidget->installEventFilter(this); | |
| 61 | 62 | connect(dialogWidget, &QDialog::finished, this, &WebWindowClass::hasClosed); |
| 62 | 63 | |
| 63 | 64 | auto layout = new QVBoxLayout(dialogWidget); |
| @@ -93,6 +94,19 @@ WebWindowClass::WebWindowClass(const QString& title, const QString& url, int wid · 29 unmodified lines | ||
| 93 | 94 | WebWindowClass::~WebWindowClass() { |
| 94 | 95 | } |
| 95 | 96 | |
| 97 | +bool WebWindowClass::eventFilter(QObject* sender, QEvent* event) { | |
| 98 | + if (sender == _windowWidget) { | |
| 99 | + if (event->type() == QEvent::Move) { | |
| 100 | + emit moved(getPosition()); | |
| 101 | + } | |
| 102 | + if (event->type() == QEvent::Resize) { | |
| 103 | + emit resized(getSize()); | |
| 104 | + } | |
| 105 | + } | |
| 106 | + | |
| 107 | + return false; | |
| 108 | +} | |
| 109 | + | |
| 96 | 110 | void WebWindowClass::hasClosed() { |
| 97 | 111 | emit closed(); |
| 98 | 112 | } |
| @@ -122,6 +136,32 @@ void WebWindowClass::setURL(const QString& url) { · 23 unmodified lines | ||
| 122 | 136 | _webView->setUrl(url); |
| 123 | 137 | } |
| 124 | 138 | |
| 139 | +QSizeF WebWindowClass::getSize() const { | |
| 140 | + QSizeF size = _windowWidget->size(); | |
| 141 | + return size; | |
| 142 | +} | |
| 143 | + | |
| 144 | +void WebWindowClass::setSize(QSizeF size) { | |
| 145 | + setSize(size.width(), size.height()); | |
| 146 | +} | |
| 147 | + | |
| 148 | +void WebWindowClass::setSize(int width, int height) { | |
| 149 | + if (QThread::currentThread() != thread()) { | |
| 150 | + QMetaObject::invokeMethod(this, "setSize", Qt::AutoConnection, Q_ARG(int, width), Q_ARG(int, height)); | |
| 151 | + return; | |
| 152 | + } | |
| 153 | + _windowWidget->resize(width, height); | |
| 154 | +} | |
| 155 | + | |
| 156 | +glm::vec2 WebWindowClass::getPosition() const { | |
| 157 | + QPoint position = _windowWidget->pos(); | |
| 158 | + return glm::vec2(position.x(), position.y()); | |
| 159 | +} | |
| 160 | + | |
| 161 | +void WebWindowClass::setPosition(glm::vec2 position) { | |
| 162 | + setPosition(position.x, position.y); | |
| 163 | +} | |
| 164 | + | |
| 125 | 165 | void WebWindowClass::setPosition(int x, int y) { |
| 126 | 166 | if (QThread::currentThread() != thread()) { |
| 127 | 167 | QMetaObject::invokeMethod(this, "setPosition", Qt::AutoConnection, Q_ARG(int, x), Q_ARG(int, y)); |