Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
VoiEiSeOnSuomiServine committed Mar 22, 2024
2 parents 37ade12 + 53cacd4 commit d2c2e23
Show file tree
Hide file tree
Showing 5 changed files with 131 additions and 19 deletions.
103 changes: 103 additions & 0 deletions .idea/editor.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions include/Zephyr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class Zephyr : public QWidget {
void showBubble(const QString& text, qsizetype duration);
void showContextMenu(const QPoint &pos);

void enableMouseTracking();
void disableMouseTracking();
void enableMouseTracking() const;
void disableMouseTracking() const;

void lookLeft();
void lookRight();
Expand Down
11 changes: 9 additions & 2 deletions src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ int main(int argc, char* argv[]) {
});
introtimer.start(50);

QTimer::singleShot(5000, &test, [&]() {
QTimer::singleShot(5000, &test, [&] {
introtimer.stop();

test.stopAnimation();
Expand All @@ -74,9 +74,16 @@ int main(int argc, char* argv[]) {
test.showBubble("ZE... RA? ZERA-ORA!", 3000);
});

QTimer::singleShot(8000, &test, [&]() {
QTimer::singleShot(8000, &test, [&] {
test.enableMouseTracking();
});
//
// auto winlist = PlatformSpecific::X11::GetWindowList();
//
// foreach(const auto& i, winlist) {
// qDebug() << i;
// }


int code = app.exec();

Expand Down
8 changes: 5 additions & 3 deletions src/X11/WindowList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ QList<std::pair<QString, QPoint>> PlatformSpecific::X11::GetWindowList() {
XFree(windowName);
}

list.push_back({
name, {x, y}
});
if(!name.isEmpty()) {
list.push_back({
name, {x, y}
});
}
}

XFree(children);
Expand Down
24 changes: 12 additions & 12 deletions src/Zephyr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,28 +163,28 @@ void Zephyr::showBubble(const QString& text, qsizetype duration) {
move({after_coords.x(), after_coords.y() - bubble_height});

QTimer::singleShot(duration, this, [&](){
auto after_coords = geometry();
auto bubble_height = bubble->height();
auto coords = geometry();
auto after_bubble_height = bubble->height();

bubble->hide();

auto cur_size = size();
cur_size.setHeight(cur_size.height() - bubble_height);
setFixedSize(cur_size);
auto sz = size();
sz.setHeight(sz.height() - after_bubble_height);
setFixedSize(sz);

move({after_coords.x(), after_coords.y() + bubble_height});
move({coords.x(), coords.y() + after_bubble_height});
});
}

void Zephyr::showContextMenu(const QPoint &pos) {
QMenu contextMenu(tr("Context menu"), this);

contextMenu.addAction(tr("About"), this, [&](){
contextMenu.addAction(tr("About"), this, [&] {
auto* window = new AboutWindow();
window->show();
});

contextMenu.addAction(tr("Exit"), this, [&](){
contextMenu.addAction(tr("Exit"), this, [&]{
QApplication::quit();
});

Expand All @@ -196,7 +196,7 @@ void Zephyr::lookLeft() {
return;
}

for(auto animation : animations) {
for(const auto animation : animations) {
animation->mirror(true, false);
}

Expand All @@ -208,18 +208,18 @@ void Zephyr::lookRight() {
return;
}

for(auto animation : animations) {
for(const auto animation : animations) {
animation->mirror(true, false);
}

looking_direction = true;
}

void Zephyr::enableMouseTracking() {
void Zephyr::enableMouseTracking() const {
mouse_tracker_thread->start();
}

void Zephyr::disableMouseTracking() {
void Zephyr::disableMouseTracking() const {
mouse_tracker_thread->quit();
}

Expand Down

0 comments on commit d2c2e23

Please sign in to comment.