1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- #include <gui/gui.h>
- #include <ui_gui.h>
- #include <QDebug>
- GUI::GUI(QWidget *parent) :
- QMainWindow(parent, Qt::Window | Qt::FramelessWindowHint),
- ui_(new Ui::GUI), dx_(-100000), dy_(-100000)
- {
- ui_->setupUi(this);
- setWindowTitle("Супер-мега-клёвая-игрушка-название-которой-мы-ещё-не-придумали");
- }
- GUI::~GUI()
- {
- delete ui_;
- }
- QWidget* GUI::mainContentScene() {
- return ui_->main_content_;
- }
- void GUI::mouseMoveEvent( QMouseEvent* e ) {
- if( e->buttons() | Qt::LeftButton ) {
- QPoint pt=mapFromGlobal(QCursor::pos());
- if (dx_ != -100000 && dy_ != -100000)
- setGeometry(pos().x() + ( pt.x() - dx_ ), pos().y() + ( pt.y() - dy_ ), width(), height());
- }
- }
- void GUI::mousePressEvent( QMouseEvent* e ) {
- if(e->button() == Qt::LeftButton) {
- QPoint pt = mapFromGlobal(QCursor::pos());
- QWidget* child=childAt(pt);
- if (child == 0) {
- dx_ = -100000;
- dy_ = -100000;
- return;
- }
- QString cname = child->objectName();
- if (cname == "window_top_border_" || cname == "window_bottom_border_"
- || cname == "window_topleft_border_" || cname == "window_topright_border_"
- || cname == "window_right_border_" || cname == "window_left_border_"
- || cname == "window_botright_border_" || cname == "window_botleft_border_") {
- dx_ = pt.x();
- dy_ = pt.y();
- } else {
- dx_ = -100000;
- dy_ = -100000;
- }
- }
- }
- void GUI::mouseReleaseEvent( QMouseEvent* e ) {
- if( e->button() == Qt::LeftButton ) {
- dx_ = -100000;
- dy_ = -100000;
- }
- }
|