~mateo-salta/nitroshare/nitroshare

« back to all changes in this revision

Viewing changes to src/main/CTrayIcon.cpp

  • Committer: Nathan Osman
  • Date: 2012-07-03 22:45:37 UTC
  • Revision ID: admin@quickmediasolutions.com-20120703224537-ymuk5duhpzg4b63p
Made some more minor tweaks to the code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
#include <QFileDialog>
19
19
#include <QIcon>
20
20
#include <QMessageBox>
21
 
#include <QStringList>
22
21
 
23
22
#include <dialogs/CAboutDialog.h>
24
23
#include <dialogs/CMachineSelectionDialog.h>
43
42
       otherwise any error messages won't be displayed if the icon is hidden.
44
43
       First we create the context menu and set the icon. */
45
44
    CreateContextMenu();
46
 
    connect(&m_pc_menu, SIGNAL(aboutToShow()), SLOT(OnShowMachineList()));
 
45
    connect(&m_pc_menu, SIGNAL(aboutToShow()), SLOT(UpdateMachineList()));
47
46
 
48
47
    setIcon(QIcon(":/icons/light.png"));
49
48
    setVisible(true);
58
57
 
59
58
CTrayIcon::~CTrayIcon()
60
59
{
61
 
    /* Free all of the ShareBoxes. */
62
60
    qDeleteAll(m_shareboxes);
63
61
}
64
62
 
100
98
void CTrayIcon::OnError(QString message)
101
99
{
102
100
    if(Settings::Notify("Error"))
103
 
        showMessage("NitroShare Error", message, QSystemTrayIcon::Critical);
 
101
        showMessage(tr("NitroShare Error"), message, QSystemTrayIcon::Critical);
104
102
}
105
103
 
106
104
void CTrayIcon::OnInformation(QString message)
107
105
{
108
 
    showMessage("NitroShare Notification", message);
 
106
    showMessage(tr("NitroShare Notification"), message);
109
107
}
110
108
 
111
109
void CTrayIcon::OnRemoveShareBox()
120
118
void CTrayIcon::OnSendFiles()
121
119
{
122
120
    // Ask the user for the files they wish to send
123
 
    QStringList filenames = QFileDialog::getOpenFileNames(NULL, "Select Files to Send");
 
121
    QStringList filenames = QFileDialog::getOpenFileNames(NULL, tr("Select Files to Send"));
124
122
    if(filenames.size())
125
123
    {
126
124
        QAction * action = qobject_cast<QAction *>(sender());
137
135
        if(m_broadcast_server.AnyMachinesOnline())
138
136
        {
139
137
            CMachineSelectionDialog dialog(m_broadcast_server.GetMachineMap(),
140
 
                                           "Please select a machine to send these files to:");
 
138
                                           tr("Please select a machine to send these files to:"));
141
139
 
142
140
            if(dialog.exec()) id = dialog.GetMachineID();
143
141
            else              return;
144
142
        }
145
143
        else
146
144
        {
147
 
            QMessageBox::critical(NULL, "Error:", "There are currently no machines on the local network that can receive files.");
 
145
            QMessageBox::critical(NULL, tr("Error:"), tr("There are currently no machines on the local network that can receive files."));
148
146
            return;
149
147
        }
150
148
    }
152
150
       that the machine does indeed exist on the network currently. */
153
151
    else if(!m_broadcast_server.MachineExists(id))
154
152
    {
155
 
        QMessageBox::critical(NULL, "Error:", "This machine is currently offline.");
 
153
        QMessageBox::critical(NULL, tr("Error:"), tr("This machine is currently offline."));
156
154
        return;
157
155
    }
158
156
 
185
183
    }
186
184
}
187
185
 
188
 
void CTrayIcon::OnShowMachineList()
 
186
void CTrayIcon::UpdateMachineList()
189
187
{
190
188
    /* Clear the list and add each of the machines to it. */
191
 
    m_pc_menu.clear();
 
189
    QMenu * menu = qobject_cast<QMenu *>(sender());
 
190
    menu->clear();
192
191
 
193
192
    for(MachineMap::const_iterator i = m_broadcast_server.GetMachineMap().constBegin();
194
193
        i != m_broadcast_server.GetMachineMap().constEnd(); ++i)
195
194
    {
196
 
        QAction * action = m_pc_menu.addAction(i.value().name, this, SLOT(OnSendFiles()));
 
195
        QAction * action = menu->addAction(i.value().name, this, SLOT(OnSendFiles()));
197
196
        action->setData(i.key());
198
197
    }
199
198
}