diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8df47d5 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.qm diff --git a/main.cpp b/main.cpp index 8bd9a6f..30ba2fb 100644 --- a/main.cpp +++ b/main.cpp @@ -7,6 +7,7 @@ #include #include "mainwindow.h" +#include "systemtray.h" void printUsage() @@ -82,7 +83,8 @@ int main(int argc, char *argv[]) } // system tray? - MainWindow w(isSystemTray or isShowMinimized); + MainWindow w; + SystemTray systemtray(&w); if (isSystemTray or isShowMinimized) { if (!QSystemTrayIcon::isSystemTrayAvailable()) @@ -93,7 +95,9 @@ int main(int argc, char *argv[]) return EXIT_FAILURE; } QApplication::setQuitOnLastWindowClosed(false); - w.showSysTray(); +// w.showSysTray(); + systemtray.setup(); + systemtray.show(); } if (!isShowMinimized) w.show(); diff --git a/mainwindow.cpp b/mainwindow.cpp index 6bc3e9b..484dda6 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -30,7 +30,7 @@ extern void exportScaneToPng(QGraphicsScene *scene, */ -MainWindow::MainWindow(bool isSystemtray, QWidget *parent) : +MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), m_ui(new Ui::MainWindow), m_aboutDialog(0) @@ -49,8 +49,6 @@ MainWindow::MainWindow(bool isSystemtray, QWidget *parent) : m_graphicsView = new GraphWidget(m_ui->centralWidget); setCentralWidget(m_graphicsView); - - if (isSystemtray) setupSystemTray(); } MainWindow::~MainWindow() @@ -104,35 +102,6 @@ void MainWindow::exportScene() } } -void MainWindow::setupSystemTray() -{ - m_systemTrayIcon = new QSystemTrayIcon(0); - - m_minimizeAction = new QAction(tr("Mi&nimize"), m_systemTrayIcon); - connect(m_minimizeAction, SIGNAL(triggered()), this, SLOT(hide())); - - m_maximizeAction = new QAction(tr("Ma&ximize"), m_systemTrayIcon); - connect(m_maximizeAction, SIGNAL(triggered()), this, SLOT(showMaximized())); - - m_restoreAction = new QAction(tr("&Restore"), m_systemTrayIcon); - connect(m_restoreAction, SIGNAL(triggered()), this, SLOT(showNormal())); - - m_quitAction = new QAction(tr("&Quit"), m_systemTrayIcon); - connect(m_quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); - - m_trayIconMenu = new QMenu(this); - m_trayIconMenu->addAction(m_minimizeAction); - m_trayIconMenu->addAction(m_maximizeAction); - m_trayIconMenu->addAction(m_restoreAction); - m_trayIconMenu->addSeparator(); - m_trayIconMenu->addAction(m_quitAction); - - m_systemTrayIcon->setContextMenu(m_trayIconMenu); - - m_icon = new QIcon(":/heart.svg"); - m_systemTrayIcon->setIcon(QIcon(":/heart.svg")); -} - void MainWindow::about() { qDebug() << __PRETTY_FUNCTION__; @@ -151,8 +120,3 @@ void MainWindow::aboutDestroyed() setEnabled(true); } - -void MainWindow::showSysTray() -{ - m_systemTrayIcon->show(); -} diff --git a/mainwindow.h b/mainwindow.h index 4ee6e25..483bf36 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -16,9 +16,8 @@ class MainWindow : public QMainWindow Q_OBJECT public: - explicit MainWindow(bool isSystemTray = false, QWidget *parent = 0); + explicit MainWindow(QWidget *parent = 0); ~MainWindow(); - void showSysTray(); public slots: void klakk(); @@ -28,20 +27,10 @@ public slots: private: - void setupSystemTray(); - Ui::MainWindow *m_ui; AboutDialog *m_aboutDialog; GraphWidget *m_graphicsView; - QSystemTrayIcon *m_systemTrayIcon; - MainWindow *m_mainWindow; - QMenu *m_trayIconMenu; - QAction *m_minimizeAction; - QAction *m_maximizeAction; - QAction *m_restoreAction; - QAction *m_quitAction; - QIcon *m_icon; }; #endif // MAINWINDOW_H diff --git a/qtmindmap.pro b/qtmindmap.pro index 93926aa..74d3ace 100644 --- a/qtmindmap.pro +++ b/qtmindmap.pro @@ -15,13 +15,15 @@ SOURCES += main.cpp\ aboutdialog.cpp \ graphwidget.cpp \ node.cpp \ - edge.cpp + edge.cpp \ + systemtray.cpp HEADERS += mainwindow.h \ aboutdialog.h \ graphwidget.h \ node.h \ - edge.h + edge.h \ + systemtray.h FORMS += mainwindow.ui \ aboutdialog.ui diff --git a/qtmindmap_hu.ts b/qtmindmap_hu.ts index d5e87c9..4fe339c 100644 --- a/qtmindmap_hu.ts +++ b/qtmindmap_hu.ts @@ -42,66 +42,80 @@ p, li { white-space: pre-wrap; } Fajl - + &Help Segitseg - + &New Uj - + &Open Megnyitas - + &Save Mentes - - + &Quit Kilepes - + &About QtMindMap A QtMindMap-rol - + &Close Bezaras - - Mi&nimize - &Talcara + + E&xport + - - Ma&ximize - Teljes &meret + + Export + - - &Restore - &Visszaallita + + Ctrl+X + + + + + Export MindMap to image + + + + + PNG image file (*.png) + + + + + MindMap exported as + QObject - + QtMindMap Error QtMindMap hiba - + I couldn't detect any system tray on this system. Nem talalhato talca a jelenlegi rendszerben. @@ -109,20 +123,24 @@ p, li { white-space: pre-wrap; } SystemTray + Mi&nimize - &Talcara + &Talcara + Ma&ximize - Teljes &meret + Teljes &meret + &Restore - &Visszaallita + &Visszaallita + &Quit - &Kilepes + &Kilepes diff --git a/systemtray.cpp b/systemtray.cpp new file mode 100644 index 0000000..e50ed7f --- /dev/null +++ b/systemtray.cpp @@ -0,0 +1,51 @@ +#include "systemtray.h" + +#include +#include + + +void SystemTray::setup() +{ + qDebug() << __PRETTY_FUNCTION__; + + m_systemTrayIcon = new QSystemTrayIcon(0); + + m_minimizeAction = new QAction(tr("Mi&nimize"), m_systemTrayIcon); + connect(m_minimizeAction, SIGNAL(triggered()), m_mainWindow, SLOT(hide())); + + m_maximizeAction = new QAction(tr("Ma&ximize"), m_systemTrayIcon); + connect(m_maximizeAction, SIGNAL(triggered()), m_mainWindow, SLOT(showMaximized())); + + m_restoreAction = new QAction(tr("&Restore"), m_systemTrayIcon); + connect(m_restoreAction, SIGNAL(triggered()), m_mainWindow, SLOT(showNormal())); + + m_quitAction = new QAction(tr("&Quit"), m_systemTrayIcon); + connect(m_quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); + + m_trayIconMenu = new QMenu(this); + m_trayIconMenu->addAction(m_minimizeAction); + m_trayIconMenu->addAction(m_maximizeAction); + m_trayIconMenu->addAction(m_restoreAction); + m_trayIconMenu->addSeparator(); + m_trayIconMenu->addAction(m_quitAction); + + m_systemTrayIcon->setContextMenu(m_trayIconMenu); + + m_icon = new QIcon(":/heart.svg"); + m_systemTrayIcon->setIcon(QIcon(":/heart.svg")); + + +} + +SystemTray::SystemTray(MainWindow *mainWindow, QWidget *parent) : + QWidget(parent), + m_mainWindow(mainWindow) +{ + qDebug() << __PRETTY_FUNCTION__; +} + + +void SystemTray::show() +{ + m_systemTrayIcon->show(); +} diff --git a/systemtray.h b/systemtray.h new file mode 100644 index 0000000..147f7e1 --- /dev/null +++ b/systemtray.h @@ -0,0 +1,34 @@ +#ifndef SYSTEMTRAY_H +#define SYSTEMTRAY_H + +#include +#include +#include +#include +#include "mainwindow.h" + +class SystemTray : public QWidget +{ + Q_OBJECT + +public: + + explicit SystemTray(MainWindow *mainWindow, QWidget *parent = 0); + void setup(); + void show(); + +private: + + MainWindow *m_mainWindow; + + QSystemTrayIcon *m_systemTrayIcon; + QMenu *m_trayIconMenu; + QAction *m_minimizeAction; + QAction *m_maximizeAction; + QAction *m_restoreAction; + QAction *m_quitAction; + QIcon *m_icon; + +}; + +#endif // SYSTEMTRAY_H