Skip to content
This repository has been archived by the owner on Oct 17, 2019. It is now read-only.

Nheko cancel normal system reboot/shutdown #353

Closed
Vascom opened this issue Jun 22, 2018 · 9 comments
Closed

Nheko cancel normal system reboot/shutdown #353

Vascom opened this issue Jun 22, 2018 · 9 comments
Labels
linux Linux specific issue

Comments

@Vascom
Copy link

Vascom commented Jun 22, 2018

System:

  • Nheko version: 0.4.3
  • Installation method: rpm from official Fedora repo
  • Operating System: Fedora 28
  • Qt version: 5.10.1
  • C++ compiler: 8.1.1
  • Desktop Environment: KDE 5

Actual behavior

Then nheko is run and I try reboot or shutdown system from menu it cancelled with message: "exit cancelled by program /usr/bin/nheko". And nheko winodow go to tray.

Expected behavior

Normal system reboot/shutdown by request.

Steps to reproduce

Just run nheko and try reboot system from KDE menu.

@mujx mujx added the linux Linux specific issue label Jun 22, 2018
@mujx
Copy link
Owner

mujx commented Jul 8, 2018

@Vascom Does this also happen when nheko is not configured to minimize to tray? (option from the settings menu)

@Vascom
Copy link
Author

Vascom commented Jul 9, 2018

Then not configured to minimize to tray system reboot normal.

@rdorsch
Copy link

rdorsch commented Jul 10, 2018

I confirm, also here if not configured to minimize to tray, reboot or logout is not cancelled by nheko.

@mujx
Copy link
Owner

mujx commented Jul 10, 2018

So the problem is within the following lines

nheko/src/MainWindow.cc

Lines 278 to 288 in cfaecaa

MainWindow::closeEvent(QCloseEvent *event)
{
// Decide whether or not we should enable tray for the current page.
bool pageSupportsTray =
!welcome_page_->isVisible() && !login_page_->isVisible() && !register_page_->isVisible();
if (isVisible() && pageSupportsTray && userSettings_->isTrayEnabled()) {
event->ignore();
hide();
}
}

specifically the event->ignore().

It's used to hide the window instead of closing it when "minimize to tray" is enabled. Not sure how we can implement "minimize to tray" while not ignoring the close event.

@Vascom
Copy link
Author

Vascom commented Jul 10, 2018

Can you check how it is realised in other applications?

@mujx
Copy link
Owner

mujx commented Jul 10, 2018

Can you check how it is realised in other applications?

I haven't found an example application yet. If you know any Qt apps with that functionality please let me know so I can take a closer look.

@Vascom
Copy link
Author

Vascom commented Jul 10, 2018

telegram-desktop for example.
It minimized to tray then close window and not cancel reboot.
But it seems the same as your https://github.com/telegramdesktop/tdesktop/blob/c7a4d67cfb63af74f6da6ca35aea9ad08cf65588/Telegram/SourceFiles/mainwindow.cpp#L754

@Vogtinator
Copy link

But it seems the same as your https://github.com/telegramdesktop/tdesktop/blob/c7a4d67cfb63af74f6da6ca35aea9ad08cf65588/Telegram/SourceFiles/mainwindow.cpp#L754

It's not.

Telegram has

if (Sandbox::isSavingSession()) {
	e->accept();
	App::quit();
} else {
...
}

So do it like

 MainWindow::closeEvent(QCloseEvent *event) 
 { 
         // Decide whether or not we should enable tray for the current page. 
         bool pageSupportsTray = 
           !welcome_page_->isVisible() && !login_page_->isVisible() && !register_page_->isVisible(); 
  
         if (!qApp->isSavingSession() && isVisible() && pageSupportsTray && userSettings_->isTrayEnabled()) { 
                 event->ignore(); 
                 hide(); 
         } 
 }

@Vascom
Copy link
Author

Vascom commented Jul 12, 2018

Thanks, this solved the problem.

@Vascom Vascom closed this as completed Jul 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
linux Linux specific issue
Projects
None yet
Development

No branches or pull requests

4 participants