Make windows snap to each other

This commit is contained in:
Thomas Frauendorfer 2008-02-29 12:30:47 +01:00
parent ab988d8496
commit 94ca829e98
12 changed files with 29 additions and 94 deletions

View file

@ -18,9 +18,9 @@
#include "playlistwindow.h"
#include <QMouseEvent>
#include <QMoveEvent>
#include <QResizeEvent>
#include <QPoint>
#include "Button.h"
#include "playlistwidget.h"
@ -28,7 +28,7 @@
#include "mainwindow.h"
PlaylistWindow::PlaylistWindow (QWidget *parent) : QMainWindow (parent)
PlaylistWindow::PlaylistWindow (QWidget *parent) : BaseWindow (parent)
{
QSettings s;
m_mw = dynamic_cast<MainWindow *>(parent);
@ -132,21 +132,6 @@ PlaylistWindow::resizeEvent (QResizeEvent *event)
}
}
void
PlaylistWindow::mousePressEvent (QMouseEvent *event)
{
m_diffx = event->pos ().x ();
m_diffy = event->pos ().y ();
}
void
PlaylistWindow::mouseMoveEvent (QMouseEvent *event)
{
move (event->globalPos().x() - m_diffx,
event->globalPos().y() - m_diffy);
}
void
PlaylistWindow::moveEvent (QMoveEvent *event)
{

View file

@ -18,14 +18,14 @@
#define __PLAYLISTWINDOW_H__
// Qt classes
#include <QMainWindow>
#include "basewindow.h"
class QEvent;
class QMouseEvent;
class QMoveEvent;
class QResizeEvent;
class QHideEvent;
class QShowEvent;
class QPoint;
// our own classes
class Button;
@ -33,7 +33,7 @@ class MainWindow;
class PlaylistWidget;
class PlaylistShade;
class PlaylistWindow : public QMainWindow {
class PlaylistWindow : public BaseWindow {
Q_OBJECT
public:
@ -51,21 +51,15 @@ class PlaylistWindow : public QMainWindow {
protected:
void hideEvent (QHideEvent *event);
void showEvent (QShowEvent *event);
void mousePressEvent (QMouseEvent *event);
void mouseMoveEvent (QMouseEvent *event);
void enterEvent (QEvent *event);
void leaveEvent (QEvent *event);
void moveEvent (QMoveEvent *event);
void resizeEvent (QResizeEvent *event);
private:
PlaylistWidget *m_playlist;
PlaylistShade *m_shaded;
int m_diffx;
int m_diffy;
Button *m_shadebtn;
Button *m_closebtn;
MainWindow *m_mw;