| 334 | } |
| 335 | |
| 336 | void MainWindow::initSignals() |
| 337 | { |
| 338 | QObject::connect(GlobalObjects::mpvplayer, &MPVPlayer::stateChanged, this, [=](MPVPlayer::PlayState state){ |
| 339 | #ifdef Q_OS_WIN |
| 340 | if (winTaskbarProgress && state == MPVPlayer::Play && !GlobalObjects::mpvplayer->getCurrentFile().isEmpty()) |
| 341 | { |
| 342 | winTaskbarProgress->show(); |
| 343 | winTaskbarProgress->resume(); |
| 344 | } |
| 345 | else if (winTaskbarProgress && state == MPVPlayer::Pause && !GlobalObjects::mpvplayer->getCurrentFile().isEmpty()) |
| 346 | { |
| 347 | winTaskbarProgress->show(); |
| 348 | winTaskbarProgress->pause(); |
| 349 | } |
| 350 | else if (winTaskbarProgress && state == MPVPlayer::Stop) |
| 351 | { |
| 352 | winTaskbarProgress->hide(); |
| 353 | } |
| 354 | #endif |
| 355 | if (state == MPVPlayer::Stop) |
| 356 | { |
| 357 | auto geo = originalGeo; |
| 358 | if (isMaximized()) |
| 359 | { |
| 360 | showNormal(); |
| 361 | } |
| 362 | listWindow->setVisible(listShowState); |
| 363 | playerWindow->toggleListCollapseState(listShowState? listWindow->currentList() : -1); |
| 364 | setGeometry(geo); |
| 365 | } |
| 366 | #ifdef Q_OS_WIN |
| 367 | elaAppBar->setScreenSave(!(state == MPVPlayer::Play && !GlobalObjects::mpvplayer->getCurrentFile().isEmpty())); |
| 368 | #endif |
| 369 | }); |
| 370 | #ifdef Q_OS_WIN |
| 371 | QObject::connect(GlobalObjects::mpvplayer, &MPVPlayer::positionChanged, this, [this](int val) { |
| 372 | if (winTaskbarProgress && !GlobalObjects::mpvplayer->getCurrentFile().isEmpty()) |
| 373 | { |
| 374 | winTaskbarProgress->setValue(val); |
| 375 | } |
| 376 | }); |
| 377 | QObject::connect(GlobalObjects::mpvplayer, &MPVPlayer::durationChanged, this, [this](int duration){ |
| 378 | if (winTaskbarProgress) |
| 379 | { |
| 380 | winTaskbarProgress->setRange(0, duration); |
| 381 | } |
| 382 | }); |
| 383 | #endif |
| 384 | #ifdef KSERVICE |
| 385 | new EventListener(EventBus::getEventBus(), EventBus::EVENT_REQUIRE_LOGIN, [=](const EventParam *){ |
| 386 | KLogin login(this); |
| 387 | login.exec(); |
| 388 | }, this); |
| 389 | #endif |
| 390 | } |
| 391 | |
| 392 | void MainWindow::restoreSize() |
| 393 | { |
nothing calls this directly
no test coverage detected