예제 #1
0
void Network::onDataReceived()
{
    const QByteArray arr = _socket.readAll();
    const QString link = getValue(arr, "url");
    emit linkReceived(link);
    _socket.disconnectFromHost();
}
예제 #2
0
void EventReceiver::received(const QString &url)
{
	RetroShareLink link(url);
	if (link.valid()) {
		MainWindow::raiseWindow();

		emit linkReceived(link.toUrl());
	}
}
예제 #3
0
bool Application::pxAppInit()
{
    QLocalSocket socket;
    socket.connectToServer(APP_NAME);
    if (socket.waitForConnected(500)) {
        qDebug() << "Application allready launched!";
        return false;
    }
    _localServer = new QLocalServer(this);

    if (!_localServer->listen(APP_NAME)) {
        QLocalServer::removeServer(APP_NAME);
        _localServer->listen(APP_NAME);
    }

    QString homePath = QDir::homePath();
    QString settingsFile = homePath + "/" + SETTINGS_FILE;
    _settings = new QSettings(settingsFile, QSettings::IniFormat, this);

    initLanguages();

    _configWidget = new ConfigWidget(_settings, _languages);
    QObject::connect(_configWidget, SIGNAL(settingsChanged()), this, SLOT(setupHotkeys()));

    _configWidget->init();

    //_shortcutScreenFull = new QxtGlobalShortcut;
    //_shortcutScreenPart = new QxtGlobalShortcut;
    //_shortcutTextShare = new QxtGlobalShortcut;

    connectDisconectHotkeys(true);
    connect(_configWidget, SIGNAL(showSignal(bool)), this, SLOT(connectDisconectHotkeys(bool)));

    _trayIconMenu = new QMenu;
    _trayIconMenu->addAction(tr("About"), this, SLOT(aboutDialog()));
    _trayIconMenu->addAction("", this, SLOT(processCodeShare()));
    _trayIconMenu->addAction("", this, SLOT(processScreenshotFull()));
    _trayIconMenu->addAction("", this, SLOT(processScreenshotPart()));
    _trayIconMenu->addAction(tr("Configure"), _configWidget, SLOT(show()));
    _trayIconMenu->addSeparator();
    _trayIconMenu->addAction(tr("Exit"), this, SLOT(quit()));                   // Tray menu

    setupHotkeys();

    _trayIcon = new QSystemTrayIcon(QIcon(":/icons/icon.png"), this);
    connect(_trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
            SLOT(trayIconClicked(QSystemTrayIcon::ActivationReason)));
    _trayIcon->setContextMenu(_trayIconMenu);                                   // Tray icon

    _network = new Network(_settings, this);
    connect(_network, SIGNAL(linkReceived(QString)), SLOT(linkAvaliable(QString)));     // Network

    this->setQuitOnLastWindowClosed(false);

    _trayIcon->show();
    QFile file(settingsFile);

    if (!file.exists())
        _configWidget->show();
    return true;
}