From 9d73e385153656ef998cc8f6378bb01ff36b2090 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 2 Nov 2016 19:24:07 +0100 Subject: [server] Rewrite positioning logic of connection frames This fixes sevceral bugs: * Frames moved into virtually expanded area (for keeping aspect ratio) could be out of bounds after a window resize before * Finding a free slot to place a frame was slightly sped up * Finding a free slot is not used when loading a room layout, as it was (still is) pretty sluggish for the user * Snap to grid worked incorrectly, did not pick closest grid position --- src/server/connectionframe/connectionframe.h | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'src/server/connectionframe/connectionframe.h') diff --git a/src/server/connectionframe/connectionframe.h b/src/server/connectionframe/connectionframe.h index 9d86c70..2549ae8 100644 --- a/src/server/connectionframe/connectionframe.h +++ b/src/server/connectionframe/connectionframe.h @@ -3,6 +3,8 @@ #include #include "../net/client.h" +class MainWindow; + /** * Class for representing the clients of current session, with a specific frame * displaying username and hostname for each one. @@ -29,11 +31,8 @@ private: QPoint _clickPoint; QPoint _previousPosition; - QPoint _currentPosition; - QPoint _gridPosition; - Client *_client; int _timerId, _timerCounter; @@ -45,22 +44,25 @@ private: void showDefaultThumb(); QLabel* addIcon(const QIcon* icon); + MainWindow *_mainWindow; + public: - ConnectionFrame(QWidget* parent, int width, int height); + + static bool paintDisabled; + + ConnectionFrame(MainWindow* main, QWidget* parent); virtual ~ConnectionFrame(); + const inline QPoint getGridPosition() const { return _gridPosition; } + void setGridPosition(int x, int y); + void setGridPosition(const QPoint& pos); + void updateGeometry(); + const QPixmap& getFramePixmap() const { return _remoteScreen; } - void setSize(int width, int height); - const inline QPoint& getPreviousPosition() const { return _previousPosition; } void assignClient(Client *client); void setSelection(bool selected); const inline bool isSelected() const { return _isSelected; } - inline void setGridPosition(QPoint pos) { _gridPosition = pos; } - inline QPoint getGridPosition() const { return _gridPosition; }; - const inline void setCurrentPosition(QPoint position) { _currentPosition = position; } - const inline QPoint& getCurrentPosition() const { return _currentPosition; } - const QString& computerId() const { return _computerId; } void setComputerId(QString computerId) { if (_client != NULL) return; _computerId = computerId; updateLabels(); } Client* client() const { return _client; } @@ -79,7 +81,7 @@ protected: void timerEvent(QTimerEvent* event); signals: - void frameMoved(bool activateTrash, ConnectionFrame* frame); + void frameMoved(ConnectionFrame* frame); void doubleClicked(ConnectionFrame* frame); void clicked(ConnectionFrame* frame); -- cgit v1.2.3-55-g7522