make it closer to reality
This commit is contained in:
parent
cb5c8afe1b
commit
67282dbd74
4 changed files with 93 additions and 2 deletions
12
pom.xml
12
pom.xml
|
@ -15,6 +15,13 @@
|
||||||
<exec.mainClass>eu.m724.chaqt.Main</exec.mainClass>
|
<exec.mainClass>eu.m724.chaqt.Main</exec.mainClass>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>m724</id>
|
||||||
|
<url>https://git.m724.eu/api/packages/Minecon724/maven</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.qtjambi</groupId>
|
<groupId>io.qtjambi</groupId>
|
||||||
|
@ -26,6 +33,11 @@
|
||||||
<artifactId>qtjambi-native-linux-x64</artifactId>
|
<artifactId>qtjambi-native-linux-x64</artifactId>
|
||||||
<version>6.7.2</version>
|
<version>6.7.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>eu.m724</groupId>
|
||||||
|
<artifactId>chatapi</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
14
src/main/java/eu/m724/chaqt/ChatWindowViewModel.java
Normal file
14
src/main/java/eu/m724/chaqt/ChatWindowViewModel.java
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
package eu.m724.chaqt;
|
||||||
|
|
||||||
|
import eu.m724.chatapi.chat.Chat;
|
||||||
|
|
||||||
|
public class ChatWindowViewModel {
|
||||||
|
private ChatWindowWidget widget;
|
||||||
|
|
||||||
|
private Chat chat;
|
||||||
|
|
||||||
|
public ChatWindowViewModel(ChatWindowWidget widget, Chat chat) {
|
||||||
|
this.widget = widget;
|
||||||
|
this.chat = chat;
|
||||||
|
}
|
||||||
|
}
|
62
src/main/java/eu/m724/chaqt/ChatWindowWidget.java
Normal file
62
src/main/java/eu/m724/chaqt/ChatWindowWidget.java
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
package eu.m724.chaqt;
|
||||||
|
|
||||||
|
import eu.m724.chatapi.chat.Chat;
|
||||||
|
import io.qt.core.Qt;
|
||||||
|
import io.qt.widgets.*;
|
||||||
|
|
||||||
|
public class ChatWindowWidget extends QWidget {
|
||||||
|
private ChatWindowViewModel viewModel;
|
||||||
|
|
||||||
|
private QVBoxLayout layout;
|
||||||
|
private QTextEdit textEdit;
|
||||||
|
|
||||||
|
public ChatWindowWidget(Chat chat) {
|
||||||
|
this.viewModel = new ChatWindowViewModel(this, chat);
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
this.layout = new QVBoxLayout();
|
||||||
|
layout.setAlignment(Qt.AlignmentFlag.AlignBottom); // or top?
|
||||||
|
|
||||||
|
QWidget widget = new QWidget();
|
||||||
|
widget.setLayout(layout);
|
||||||
|
|
||||||
|
QScrollArea scrollArea = new QScrollArea();
|
||||||
|
scrollArea.setWidgetResizable(true);
|
||||||
|
scrollArea.setWidget(widget);
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
this.textEdit = new QTextEdit();
|
||||||
|
textEdit.setPlaceholderText("Write a message...");
|
||||||
|
textEdit.textChanged.connect(this, "handleComposerType()");
|
||||||
|
|
||||||
|
QPushButton sendButton = new QPushButton("Send");
|
||||||
|
|
||||||
|
QHBoxLayout composerLayout = new QHBoxLayout();
|
||||||
|
composerLayout.addWidget(textEdit);
|
||||||
|
composerLayout.addWidget(sendButton, 0, Qt.AlignmentFlag.AlignBottom);
|
||||||
|
|
||||||
|
QWidget composerWidget = new QWidget();
|
||||||
|
composerWidget.setLayout(composerLayout);
|
||||||
|
|
||||||
|
handleComposerType(); // TODO make it resizable and fix it
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
QVBoxLayout mainLayout = new QVBoxLayout();
|
||||||
|
mainLayout.addWidget(scrollArea, 1);
|
||||||
|
mainLayout.addWidget(composerWidget);
|
||||||
|
setLayout(mainLayout);
|
||||||
|
|
||||||
|
for (int i=0; i<10; i++) {
|
||||||
|
QPushButton pushButton = new QPushButton("hello");
|
||||||
|
layout.addWidget(pushButton);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void handleComposerType() {
|
||||||
|
int height = (int) textEdit.document().size().height();
|
||||||
|
textEdit.setFixedHeight(height + textEdit.contentsMargins().top() + textEdit.contentsMargins().bottom());
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
package eu.m724.chaqt;
|
package eu.m724.chaqt;
|
||||||
|
|
||||||
|
import eu.m724.chatapi.chat.Chat;
|
||||||
import io.qt.widgets.QApplication;
|
import io.qt.widgets.QApplication;
|
||||||
import io.qt.widgets.QMessageBox;
|
import io.qt.widgets.QMessageBox;
|
||||||
|
|
||||||
|
@ -8,8 +9,10 @@ public class Main {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
QApplication.initialize(args);
|
QApplication.initialize(args);
|
||||||
|
|
||||||
HelloWorld hello = new HelloWorld();
|
Chat chat = new Chat();
|
||||||
hello.show();
|
|
||||||
|
ChatWindowWidget widget = new ChatWindowWidget(chat);
|
||||||
|
widget.show();
|
||||||
|
|
||||||
QApplication.exec();
|
QApplication.exec();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue