- Bring main window to foreground when it is minimized on exit confirmation

This commit is contained in:
Christophe Dumez 2007-03-29 20:24:23 +00:00
commit 2f065bd9ea
2 changed files with 5 additions and 2 deletions

View file

@ -129,6 +129,7 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent){
connect(options, SIGNAL(status_changed(const QString&, bool)), this, SLOT(OptionsSaved(const QString&, bool))); connect(options, SIGNAL(status_changed(const QString&, bool)), this, SLOT(OptionsSaved(const QString&, bool)));
// Configure BT session according to options // Configure BT session according to options
configureSession(true); configureSession(true);
force_exit = false;
// Resume unfinished torrents // Resume unfinished torrents
BTSession.resumeUnfinishedTorrents(); BTSession.resumeUnfinishedTorrents();
// Add torrent given on command line // Add torrent given on command line
@ -401,7 +402,7 @@ void GUI::displayDLListMenu(const QPoint& pos){
// Necessary if we want to close the window // Necessary if we want to close the window
// in one time if "close to systray" is enabled // in one time if "close to systray" is enabled
void GUI::forceExit(){ void GUI::forceExit(){
hide(); force_exit = true;
close(); close();
} }
@ -808,13 +809,14 @@ void GUI::showAbout(){
void GUI::closeEvent(QCloseEvent *e){ void GUI::closeEvent(QCloseEvent *e){
QSettings settings("qBittorrent", "qBittorrent"); QSettings settings("qBittorrent", "qBittorrent");
bool goToSystrayOnExit = settings.value("Options/Misc/Behaviour/GoToSystrayOnExit", false).toBool(); bool goToSystrayOnExit = settings.value("Options/Misc/Behaviour/GoToSystrayOnExit", false).toBool();
if(goToSystrayOnExit && !this->isHidden()){ if(!force_exit && goToSystrayOnExit && !this->isHidden()){
hide(); hide();
e->ignore(); e->ignore();
return; return;
} }
if(settings.value("Options/Misc/Behaviour/ConfirmOnExit", true).toBool()){ if(settings.value("Options/Misc/Behaviour/ConfirmOnExit", true).toBool()){
show(); show();
showNormal();
if(QMessageBox::question(this, if(QMessageBox::question(this,
tr("Are you sure you want to quit?")+" -- "+tr("qBittorrent"), tr("Are you sure you want to quit?")+" -- "+tr("qBittorrent"),
tr("Are you sure you want to quit qBittorrent?"), tr("Are you sure you want to quit qBittorrent?"),

View file

@ -81,6 +81,7 @@ class GUI : public QMainWindow, private Ui::MainWindow{
SearchListDelegate *SearchDelegate; SearchListDelegate *SearchDelegate;
unsigned int nbTorrents; unsigned int nbTorrents;
QLabel *connecStatusLblIcon; QLabel *connecStatusLblIcon;
bool force_exit;
// Preview // Preview
previewSelect *previewSelection; previewSelect *previewSelection;
QProcess *previewProcess; QProcess *previewProcess;