Browse Source

Merge pull request #1 from Gilnobag/gui

[Gui => Dev] Base GUI structure implementation
Ivan Arkhipov 6 years ago
parent
commit
c5c33605b5

BIN
assets/window/thick_opaque-background.png


BIN
assets/window/thick_opaque-border-botleft.png


BIN
assets/window/thick_opaque-border-botright.png


BIN
assets/window/thick_opaque-border-bottom.png


BIN
assets/window/thick_opaque-border-left.png


BIN
assets/window/thick_opaque-border-right.png


BIN
assets/window/thick_opaque-border-top.png


BIN
assets/window/thick_opaque-border-topleft.png


BIN
assets/window/thick_opaque-border-topright.png


+ 40 - 0
client.pro

@@ -0,0 +1,40 @@
+#-------------------------------------------------
+#
+# Project created by QtCreator 2018-03-07T02:18:16
+#
+#-------------------------------------------------
+
+QT       += core gui
+
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+TARGET = client
+TEMPLATE = app
+
+# The following define makes your compiler emit warnings if you use
+# any feature of Qt which has been marked as deprecated (the exact warnings
+# depend on your compiler). Please consult the documentation of the
+# deprecated API in order to know how to port your code away from it.
+DEFINES += QT_DEPRECATED_WARNINGS
+
+# You can also make your code fail to compile if you use deprecated APIs.
+# In order to do so, uncomment the following line.
+# You can also select to disable deprecated APIs only up to a certain version of Qt.
+#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
+
+
+SOURCES += \
+        main.cpp \
+        gui.cpp \
+    recruitmentscene.cpp
+
+HEADERS += \
+        gui.h \
+    recruitmentscene.h
+
+FORMS += \
+        gui.ui \
+    recruitmentscene.ui
+
+RESOURCES += \
+    gui.qrc

+ 54 - 0
gui.cpp

@@ -0,0 +1,54 @@
+#include "gui.h"
+#include "ui_gui.h"
+#include "recruitmentscene.h"
+#include <QDebug>
+
+GUI::GUI(QWidget *parent) :
+    QMainWindow(parent, Qt::Window | Qt::FramelessWindowHint),
+    ui_(new Ui::GUI), dx_(0), dy_(0)
+{
+    ui_->setupUi(this);
+    rq_scene_ = new RecruitmentScene(ui_->main_content_);   /// Инициализируем графическую сцену
+    rq_scene_->show();
+    //rq_scene_->hide();
+}
+
+GUI::~GUI()
+{
+    delete ui_;
+}
+
+void GUI::mouseMoveEvent( QMouseEvent* e ) {
+    if( e->buttons() | Qt::LeftButton ) {
+        QPoint pt=mapFromGlobal(QCursor::pos());
+        QWidget* child=childAt(pt);
+        if (child == 0) {
+            setGeometry(pos().x() + ( e->x() - dx_ ), pos().y() + ( e->y() - dy_ ), width(), height());
+            return;
+        }
+        QString cname = child->metaObject()->className();
+        qDebug() << cname;
+        if (cname != "QPushButton" && cname != "QComboBox"){ // отключаем перетягивание при наведение на активные элементы
+            setGeometry(pos().x() + ( e->x() - dx_ ), pos().y() + ( e->y() - dy_ ), width(), height());
+        } else {
+            dx_ = e->x();
+            dy_ = e->y();
+        }
+    }
+}
+
+void GUI::mousePressEvent( QMouseEvent* e ) {
+    if( e->button() == Qt::LeftButton ) {
+        dx_ = e->x();
+        dy_ = e->y();
+        setCursor( Qt::OpenHandCursor );
+    }
+}
+
+void GUI::mouseReleaseEvent( QMouseEvent* e ) {
+    if( e->button() == Qt::LeftButton ) {
+        setCursor( Qt::ArrowCursor );
+        dx_ = e->x();
+        dy_ = e->y();
+    }
+}

+ 44 - 0
gui.h

@@ -0,0 +1,44 @@
+#ifndef GUI_H
+#define GUI_H
+
+#include <QMainWindow>
+#include <QGraphicsScene>
+#include <QMouseEvent>
+#include "recruitmentscene.h"
+
+namespace Ui {
+class GUI;
+}
+
+class GUI : public QMainWindow
+{
+    Q_OBJECT
+
+public:
+    explicit GUI(QWidget *parent = 0);
+    ~GUI();
+
+private:
+    Ui::GUI *ui_;
+    QGraphicsScene *scene_;
+    RecruitmentScene *rq_scene_;
+
+    QImage left_border_;
+    QImage left_up_corner_;
+    QImage up_border_;
+    QImage up_right_corner_;
+    QImage right_border_;
+    QImage right_bottom_corner_;
+    QImage bottom_border_;
+    QImage bottom_left_corner_;
+
+protected:
+    void mouseMoveEvent( QMouseEvent* e );
+    void mousePressEvent( QMouseEvent* e );
+    void mouseReleaseEvent( QMouseEvent* e );
+private:
+    int dx_;
+    int dy_;
+};
+
+#endif // GUI_H

+ 13 - 0
gui.qrc

@@ -0,0 +1,13 @@
+<RCC>
+    <qresource prefix="/">
+        <file>assets/window/thick_opaque-background.png</file>
+        <file>assets/window/thick_opaque-border-botleft.png</file>
+        <file>assets/window/thick_opaque-border-botright.png</file>
+        <file>assets/window/thick_opaque-border-bottom.png</file>
+        <file>assets/window/thick_opaque-border-left.png</file>
+        <file>assets/window/thick_opaque-border-right.png</file>
+        <file>assets/window/thick_opaque-border-top.png</file>
+        <file>assets/window/thick_opaque-border-topleft.png</file>
+        <file>assets/window/thick_opaque-border-topright.png</file>
+    </qresource>
+</RCC>

+ 156 - 0
gui.ui

@@ -0,0 +1,156 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>GUI</class>
+ <widget class="QMainWindow" name="GUI">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>1024</width>
+    <height>800</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>GUI</string>
+  </property>
+  <widget class="QWidget" name="centralWidget">
+   <widget class="QLabel" name="botleft_corner_">
+    <property name="geometry">
+     <rect>
+      <x>-3</x>
+      <y>758</y>
+      <width>45</width>
+      <height>45</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;img src=&quot;:/assets/window/thick_opaque-border-botleft.png&quot;/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+    </property>
+   </widget>
+   <widget class="QLabel" name="left_border_">
+    <property name="geometry">
+     <rect>
+      <x>-3</x>
+      <y>42</y>
+      <width>51</width>
+      <height>716</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>&lt;html&gt;&lt;head&gt;&lt;body&gt;
+&lt;div style=&quot;background:url(:/assets/window/thick_opaque-border-left.png);&quot; width=&quot;100%&quot; height=&quot;100%&quot; /&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;/div&gt;
+&lt;/body&gt;&lt;/html&gt;</string>
+    </property>
+   </widget>
+   <widget class="QLabel" name="topleft_corner_">
+    <property name="geometry">
+     <rect>
+      <x>-3</x>
+      <y>-3</y>
+      <width>45</width>
+      <height>45</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;img src=&quot;:/assets/window/thick_opaque-border-topleft.png&quot;/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+    </property>
+   </widget>
+   <widget class="QLabel" name="top_border_">
+    <property name="geometry">
+     <rect>
+      <x>42</x>
+      <y>-3</y>
+      <width>937</width>
+      <height>45</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;div style=&quot;background:url(:/assets/window/thick_opaque-border-top.png);&quot; width=&quot;100%&quot; height=&quot;100%&quot; /&gt;&lt;br&gt;&lt;br&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;</string>
+    </property>
+   </widget>
+   <widget class="QLabel" name="topright_corner_">
+    <property name="geometry">
+     <rect>
+      <x>979</x>
+      <y>-3</y>
+      <width>45</width>
+      <height>45</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;img src=&quot;:/assets/window/thick_opaque-border-topright.png&quot;/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+    </property>
+   </widget>
+   <widget class="QLabel" name="right_border_">
+    <property name="geometry">
+     <rect>
+      <x>979</x>
+      <y>42</y>
+      <width>45</width>
+      <height>716</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>&lt;html&gt;&lt;head&gt;&lt;body&gt;
+&lt;div style=&quot;background:url(:/assets/window/thick_opaque-border-right.png);&quot; width=&quot;100%&quot; height=&quot;100%&quot; /&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;/div&gt;
+&lt;/body&gt;&lt;/html&gt;</string>
+    </property>
+   </widget>
+   <widget class="QLabel" name="bottom_border_">
+    <property name="geometry">
+     <rect>
+      <x>42</x>
+      <y>758</y>
+      <width>937</width>
+      <height>45</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;div style=&quot;background:url(:/assets/window/thick_opaque-border-bottom.png);&quot; width=&quot;100%&quot; height=&quot;100%&quot; /&gt;&lt;br&gt;&lt;br&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;</string>
+    </property>
+   </widget>
+   <widget class="QLabel" name="botright_corner">
+    <property name="geometry">
+     <rect>
+      <x>979</x>
+      <y>758</y>
+      <width>45</width>
+      <height>45</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;img src=&quot;:/assets/window/thick_opaque-border-botright.png&quot;/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+    </property>
+   </widget>
+   <widget class="QLabel" name="background">
+    <property name="geometry">
+     <rect>
+      <x>42</x>
+      <y>42</y>
+      <width>938</width>
+      <height>716</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>&lt;html&gt;&lt;head&gt;&lt;body&gt;
+&lt;div style=&quot;background:url(:/assets/window/thick_opaque-background.png);&quot; width=&quot;100%&quot; height=&quot;100%&quot; /&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;/div&gt;
+&lt;/body&gt;&lt;/html&gt;</string>
+    </property>
+   </widget>
+   <widget class="QWidget" name="main_content_" native="true">
+    <property name="geometry">
+     <rect>
+      <x>40</x>
+      <y>40</y>
+      <width>941</width>
+      <height>721</height>
+     </rect>
+    </property>
+    <layout class="QGridLayout" name="content_"/>
+   </widget>
+  </widget>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections/>
+</ui>

+ 11 - 0
main.cpp

@@ -0,0 +1,11 @@
+#include "gui.h"
+#include "recruitmentscene.h"
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+    QApplication a(argc, argv);
+    GUI w;
+    w.show();
+    return a.exec();
+}

+ 14 - 0
recruitmentscene.cpp

@@ -0,0 +1,14 @@
+#include "recruitmentscene.h"
+#include "ui_recruitmentscene.h"
+
+RecruitmentScene::RecruitmentScene(QWidget *parent) :
+    QWidget(parent),
+    ui(new Ui::RecruitmentScene)
+{
+    ui->setupUi(this);
+}
+
+RecruitmentScene::~RecruitmentScene()
+{
+    delete ui;
+}

+ 22 - 0
recruitmentscene.h

@@ -0,0 +1,22 @@
+#ifndef RECRUITMENTSCENE_H
+#define RECRUITMENTSCENE_H
+
+#include <QWidget>
+
+namespace Ui {
+class RecruitmentScene;
+}
+
+class RecruitmentScene : public QWidget
+{
+    Q_OBJECT
+
+public:
+    explicit RecruitmentScene(QWidget *parent = 0);
+    ~RecruitmentScene();
+
+private:
+    Ui::RecruitmentScene *ui;
+};
+
+#endif // RECRUITMENTSCENE_H

+ 61 - 0
recruitmentscene.ui

@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>RecruitmentScene</class>
+ <widget class="QWidget" name="RecruitmentScene">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>1024</width>
+    <height>800</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <widget class="QPushButton" name="pushButton">
+   <property name="geometry">
+    <rect>
+     <x>250</x>
+     <y>40</y>
+     <width>211</width>
+     <height>151</height>
+    </rect>
+   </property>
+   <property name="cursor">
+    <cursorShape>PointingHandCursor</cursorShape>
+   </property>
+   <property name="text">
+    <string>PushButton</string>
+   </property>
+  </widget>
+  <widget class="QLabel" name="label">
+   <property name="geometry">
+    <rect>
+     <x>460</x>
+     <y>10</y>
+     <width>111</width>
+     <height>31</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600; color:#fff560;&quot;&gt;Выберите расу:&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+   </property>
+  </widget>
+  <widget class="QPushButton" name="pushButton_2">
+   <property name="geometry">
+    <rect>
+     <x>520</x>
+     <y>40</y>
+     <width>211</width>
+     <height>151</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string>PushButton</string>
+   </property>
+  </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>