summary refs log tree commit diff
path: root/src/EmojiPanel.cc
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2017-05-16 21:21:31 +0300
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2017-05-16 21:21:31 +0300
commitc470e49aa9d6c97e805eb193afab97e9e19814eb (patch)
tree1189eee2a50a65516a972c743ade5029c36a7c3e /src/EmojiPanel.cc
parentShow user info even if the display name or avatar are missing (diff)
downloadnheko-c470e49aa9d6c97e805eb193afab97e9e19814eb.tar.xz
Add geometry animation on emoji picker
Diffstat (limited to 'src/EmojiPanel.cc')
-rw-r--r--src/EmojiPanel.cc25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/EmojiPanel.cc b/src/EmojiPanel.cc
index afe664f1..4176be0e 100644
--- a/src/EmojiPanel.cc
+++ b/src/EmojiPanel.cc
@@ -44,8 +44,7 @@ EmojiPanel::EmojiPanel(QWidget *parent)
 
 	// TODO: Make it MainWindow aware
 	auto main_frame_ = new QFrame(this);
-	main_frame_->setMinimumSize(370, 350);
-	main_frame_->setMaximumSize(370, 350);
+	main_frame_->setMaximumSize(WIDTH, HEIGHT);
 
 	auto top_layout = new QVBoxLayout(this);
 	top_layout->addWidget(main_frame_);
@@ -150,16 +149,26 @@ EmojiPanel::EmojiPanel(QWidget *parent)
 
 	setLayout(top_layout);
 
-	// TODO: Add parallel animation with geometry
 	opacity_ = new QGraphicsOpacityEffect(this);
 	opacity_->setOpacity(1.0);
 
 	setGraphicsEffect(opacity_);
 
-	animation_ = new QPropertyAnimation(opacity_, "opacity", this);
-	animation_->setDuration(180);
-	animation_->setStartValue(1.0);
-	animation_->setEndValue(0.0);
+	opacity_anim_ = new QPropertyAnimation(opacity_, "opacity", this);
+	opacity_anim_->setDuration(ANIMATION_DURATION);
+	opacity_anim_->setStartValue(1);
+	opacity_anim_->setEndValue(0);
+
+	size_anim_ = new QPropertyAnimation(this);
+	size_anim_->setTargetObject(main_frame_);
+	size_anim_->setPropertyName("geometry");
+	size_anim_->setDuration(ANIMATION_DURATION);
+	size_anim_->setStartValue(QRect(0, 0, WIDTH, HEIGHT));
+	size_anim_->setEndValue(QRect(ANIMATION_OFFSET, ANIMATION_OFFSET, WIDTH - ANIMATION_OFFSET, HEIGHT - ANIMATION_OFFSET));
+
+	animation_ = new QParallelAnimationGroup(this);
+	animation_->addAnimation(opacity_anim_);
+	animation_->addAnimation(size_anim_);
 
 	connect(people_emoji, &EmojiCategory::emojiSelected, this, &EmojiPanel::emojiSelected);
 	connect(people_category, &QPushButton::clicked, [this, people_emoji]() {
@@ -201,7 +210,7 @@ EmojiPanel::EmojiPanel(QWidget *parent)
 		this->showEmojiCategory(flags_emoji);
 	});
 
-	connect(animation_, &QPropertyAnimation::finished, [this]() {
+	connect(animation_, &QAbstractAnimation::finished, [this]() {
 		if (animation_->direction() == QAbstractAnimation::Forward)
 			this->hide();
 	});