~mateo-salta/nitroshare/nitroshare

« back to all changes in this revision

Viewing changes to src/CTrayIcon.cpp

  • Committer: Nathan Osman
  • Date: 2012-06-18 15:36:04 UTC
  • Revision ID: admin@quickmediasolutions.com-20120618153604-zhah626i56drwin5
Added a lot of skeleton code including the settings dialog and implemented the tray icon.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* NitroShare - A simple network file sharing tool.
 
2
   Copyright (C) 2012 Nathan Osman
 
3
 
 
4
   This program is free software: you can redistribute it and/or modify
 
5
   it under the terms of the GNU General Public License as published by
 
6
   the Free Software Foundation, either version 3 of the License, or
 
7
   (at your option) any later version.
 
8
 
 
9
   This program is distributed in the hope that it will be useful,
 
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
   GNU General Public License for more details.
 
13
 
 
14
   You should have received a copy of the GNU General Public License
 
15
   along with this program.  If not, see <http://www.gnu.org/licenses/>. */
 
16
 
 
17
#include <QCoreApplication>
 
18
#include <QIcon>
 
19
 
 
20
#include <CSettingsDialog.h>
 
21
#include <CTrayIcon.h>
 
22
 
 
23
CTrayIcon::CTrayIcon()
 
24
    : QSystemTrayIcon(NULL), m_pc_menu("Send File To")
 
25
{
 
26
    // Initialize the icon
 
27
    setIcon(QIcon(":/icons/light.png"));
 
28
    CreateMenu();
 
29
 
 
30
    // Display the icon
 
31
    setVisible(true);
 
32
}
 
33
 
 
34
void CTrayIcon::OnSettings()
 
35
{
 
36
    CSettingsDialog().exec();
 
37
}
 
38
 
 
39
void CTrayIcon::CreateMenu()
 
40
{
 
41
    QMenu * menu = new QMenu;
 
42
 
 
43
    menu->addMenu(&m_pc_menu);
 
44
    menu->addSeparator();
 
45
    menu->addAction("Settings", this, SLOT(OnSettings()));
 
46
    menu->addAction("About");
 
47
    menu->addSeparator();
 
48
    menu->addAction("Exit", QCoreApplication::instance(), SLOT(quit()));
 
49
 
 
50
    setContextMenu(menu);
 
51
}