SystemTray does not care about contentchange at quit bugfix

master
Denes Matetelki 14 years ago
parent f68dab9bd0
commit 497bda949e

@ -43,6 +43,8 @@ public slots:
void showMainToolbar(const bool &show = true);
void showStatusIconToolbar(const bool &show = true);
// handle changed content at quit
void quit();
protected:
@ -52,10 +54,6 @@ protected:
// show/hide toolbars, otherwise pass on the event to GraphWidget
void keyPressEvent(QKeyEvent *event);
private slots:
void quit();
private:
void setUpMainToolbar();

@ -14,20 +14,20 @@ class SystemTray : public QWidget
public:
explicit SystemTray(MainWindow *mainWindow, QWidget *parent = 0);
void setup();
void show();
private:
// access private member
void show() { m_systemTrayIcon->show(); }
MainWindow *m_mainWindow;
private:
QSystemTrayIcon *m_systemTrayIcon;
QMenu *m_trayIconMenu;
QAction *m_minimizeAction;
QAction *m_maximizeAction;
QAction *m_restoreAction;
QAction *m_quitAction;
QIcon *m_icon;
MainWindow *m_parent;
QSystemTrayIcon *m_systemTrayIcon;
QMenu *m_trayIconMenu;
QAction *m_minimizeAction;
QAction *m_maximizeAction;
QAction *m_restoreAction;
QAction *m_quitAction;
QIcon *m_icon;
};

@ -37,7 +37,7 @@ int main(int argc, char *argv[])
// system tray?
MainWindow w;
SystemTray systemtray(&w);
SystemTray *systemtray;
if (argParser.isSystemTray() or argParser.isShowMinimized())
{
if (!QSystemTrayIcon::isSystemTrayAvailable())
@ -48,8 +48,8 @@ int main(int argc, char *argv[])
return EXIT_FAILURE;
}
QApplication::setQuitOnLastWindowClosed(false);
systemtray.setup();
systemtray.show();
systemtray = new SystemTray(&w);
systemtray->show();
}
// open file if any

@ -313,6 +313,14 @@ void MainWindow::showStatusIconToolbar(const bool &show)
false);
}
void MainWindow::quit()
{
if (m_contentChanged && !closeFile())
return;
QApplication::instance()->quit();
}
void MainWindow::closeEvent(QCloseEvent * event)
{
m_contentChanged && !closeFile() ? event->ignore() : event->accept();
@ -338,15 +346,6 @@ void MainWindow::keyPressEvent(QKeyEvent *event)
QMainWindow::keyPressEvent(event);
}
void MainWindow::quit()
{
if (m_contentChanged && !closeFile())
return;
QApplication::instance()->quit();
}
void MainWindow::setUpMainToolbar()
{
// why can't I do this with qtcreator? (adding actions to toolbar)

@ -2,24 +2,27 @@
#include <QApplication>
void SystemTray::setup()
SystemTray::SystemTray(MainWindow *mainWindow, QWidget *parent)
: QWidget(parent),
m_parent(mainWindow)
{
m_systemTrayIcon = new QSystemTrayIcon(0);
m_minimizeAction = new QAction(tr("Mi&nimize"), m_systemTrayIcon);
connect(m_minimizeAction, SIGNAL(triggered()), m_mainWindow,
connect(m_minimizeAction, SIGNAL(triggered()), m_parent,
SLOT(hide()));
m_maximizeAction = new QAction(tr("Ma&ximize"), m_systemTrayIcon);
connect(m_maximizeAction, SIGNAL(triggered()), m_mainWindow,
connect(m_maximizeAction, SIGNAL(triggered()), m_parent,
SLOT(showMaximized()));
m_restoreAction = new QAction(tr("&Restore"), m_systemTrayIcon);
connect(m_restoreAction, SIGNAL(triggered()), m_mainWindow,
connect(m_restoreAction, SIGNAL(triggered()), m_parent,
SLOT(showNormal()));
m_quitAction = new QAction(tr("&Quit"), m_systemTrayIcon);
connect(m_quitAction, SIGNAL(triggered()), qApp,
connect(m_quitAction, SIGNAL(triggered()), m_parent,
SLOT(quit()));
m_trayIconMenu = new QMenu(this);
@ -34,15 +37,3 @@ void SystemTray::setup()
m_icon = new QIcon(":/qtmindmap.svg");
m_systemTrayIcon->setIcon(QIcon(":/qtmindmap.svg"));
}
SystemTray::SystemTray(MainWindow *mainWindow, QWidget *parent) :
QWidget(parent),
m_mainWindow(mainWindow)
{
}
void SystemTray::show()
{
m_systemTrayIcon->show();
}

Loading…
Cancel
Save