コード例 #1
0
bool ICQClient::load(istream &s, string &nextPart)
{
    ICQUser::load(s, nextPart);
    for (;;){
        if (!strcmp(nextPart.c_str(), "[ContactList]")){
            contacts.load(s, nextPart);
            continue;
        }
        if (!strcmp(nextPart.c_str(), "[Group]")){
            ICQGroup *grp = new ICQGroup;
            if (grp->load(s, nextPart)){
                contacts.groups.push_back(grp);
            }else{
                delete grp;
            }
            continue;
        }
        if (!strcmp(nextPart.c_str(), "[User]")){
            ICQUser *u = new ICQUser;
            if (u->load(s, nextPart) && u->Uin() && (u->Uin() != Uin())){
                contacts.users.push_back(u);
            }else{
                delete u;
            }
            continue;
        }
        break;
    }
    if (*EncryptedPassword.c_str() == 0)
        storePassword(DecryptedPassword.c_str());
    setupProxy();
    ICQEvent e(EVENT_INFO_CHANGED);
    process_event(&e);
    return true;
}
コード例 #2
0
ScreenManager::ScreenManager(QVector<QRect> geometrys, QObject *parent)
    :QObject(parent),
    answerReceived(false)
{
    screensTotal = geometrys.size();
    server = QString("cropme.ru");

    connect(this, SIGNAL(signal_printToLog(QString)), &logger, SLOT(slot_writeLine(QString)));

    emit signal_printToLog(QString("Cropme started for %1 screens").arg(screensTotal));

    widgets = new Screenshot*[screensTotal];

    for(quint32 i=0; i < screensTotal; i++)
    {
        widgets[i] = new Screenshot(0, i);

        connect(widgets[i], SIGNAL(signal_printToLog(QString)), &logger, SLOT(slot_writeLine(QString)));
        connect(widgets[i], SIGNAL(signal_postToServer()), SLOT(slot_onScreenshotReady()));

        widgets[i]->buffer = &(this->buffer);
        widgets[i]->setGeometry(geometrys[i]);
        widgets[i]->show();
    }

    connect(&socket, SIGNAL(connected()), this, SLOT(slot_onConnect()));
    connect(&socket, SIGNAL(readyRead()), this, SLOT(slot_onReadyRead()));
    connect(&socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(slot_onSocketError(QAbstractSocket::SocketError)));

    setupProxy();
}
コード例 #3
0
ファイル: main.cpp プロジェクト: zhao07/qtupdater
int main(int argc, char **argv)
{
    try
    {
        QScopedPointer<QCoreApplication> app(

            #if defined(USE_SCRIPT_DEBUGGER)
                    new QApplication(argc, argv)
            #else
                    new QCoreApplication(argc, argv)
            #endif
                    );

        QString appInstallPath = QCoreApplication::applicationDirPath();
        QString appUserPath;
        QUrl updateScript;

        const QStringList args = QCoreApplication::arguments();
        Q_FOREACH(QString arg, args)
        {
            static const QString kAppInstallPathArg = "--app-install-path=";
            static const QString kAppUserPathArg = "--app-user-path=";
            static const QString kUpdateScriptArg = "--update-script=";

            if(arg.startsWith(kAppInstallPathArg))
            {
                appInstallPath = arg.remove(kAppInstallPathArg).simplified();
            }
            else if(arg.startsWith(kAppUserPathArg))
            {
                appUserPath = arg.remove(kAppUserPathArg).simplified();
            }
            else if(arg.startsWith(kUpdateScriptArg))
            {
                updateScript = arg.remove(kUpdateScriptArg).simplified();
            }
        }

        if(updateScript.isEmpty() && args.size() == 2)
        {
            updateScript = QUrl::fromLocalFile(args.at(1));
        }

        if(updateScript.isEmpty())
        {
            throw InvalidArgException("Update script path is not set");
        }

        setupProxy();
        Updater updater(updateScript, appInstallPath, appUserPath, app.data());
        return app->exec();
    }
    catch(std::exception &e)
    {
        qFatal("Inializing error: %s", e.what());
        return 1;
    }
}
コード例 #4
0
void FindSubtitlesWindow::on_configure_button_clicked()
{
    qDebug("FindSubtitlesWindow::on_configure_button_clicked");

    FindSubtitlesConfigDialog d(this);

    d.setUseProxy(use_proxy);
    d.setProxyHostname(proxy_host);
    d.setProxyPort(proxy_port);
    d.setProxyUsername(proxy_username);
    d.setProxyPassword(proxy_password);
    d.setProxyType(proxy_type);

    if (d.exec() == QDialog::Accepted) {
        use_proxy = d.useProxy();
        proxy_host = d.proxyHostname();
        proxy_port = d.proxyPort();
        proxy_username = d.proxyUsername();
        proxy_password = d.proxyPassword();
        proxy_type = d.proxyType();

        setupProxy();
    }
}
コード例 #5
0
ファイル: application.cpp プロジェクト: fastfwd/mirall
Application::Application(int &argc, char **argv) :
    SharedTools::QtSingleApplication(argc, argv),
    _tray(0),
#if QT_VERSION >= 0x040700
    _networkMgr(new QNetworkConfigurationManager(this)),
#endif
    _sslErrorDialog(0),
    _contextMenu(0),
    _theme(Theme::instance()),
    _updateDetector(0),
    _logBrowser(0),
    _showLogWindow(false),
    _logFlush(false),
    _helpOnly(false),
    _fileItemDialog(0),
    _statusDialog(0)
{
    setApplicationName( _theme->appNameGUI() );
    setWindowIcon( _theme->applicationIcon() );

    parseOptions(arguments());
    setupTranslations();
    setupLogBrowser();
    //no need to waste time;
    if ( _helpOnly ) return;

    connect( this, SIGNAL(messageReceived(QString)), SLOT(slotParseOptions(QString)));
    connect( Logger::instance(), SIGNAL(guiLog(QString,QString)),
             this, SLOT(slotShowTrayMessage(QString,QString)));
    // create folder manager for sync folder management
    _folderMan = new FolderMan(this);
    connect( _folderMan, SIGNAL(folderSyncStateChange(QString)),
             this,SLOT(slotSyncStateChange(QString)));
    _folderMan->setSyncEnabled(false);

    /* use a signal mapper to map the open requests to the alias names */
    _folderOpenActionMapper = new QSignalMapper(this);
    connect(_folderOpenActionMapper, SIGNAL(mapped(const QString &)),
            this, SLOT(slotFolderOpenAction(const QString &)));

    setQuitOnLastWindowClosed(false);

    _folderWizard = new FolderWizard;

    _owncloudSetupWizard = new OwncloudSetupWizard( _folderMan, _theme, this );
    connect( _owncloudSetupWizard, SIGNAL(ownCloudWizardDone(int)),
             this, SLOT(slotownCloudWizardDone(int)));

    _statusDialog = new StatusDialog( _theme );
    connect( _statusDialog, SIGNAL(addASync()), this, SLOT(slotAddFolder()) );

    connect( _statusDialog, SIGNAL(removeFolderAlias( const QString&)),
             SLOT(slotRemoveFolder(const QString&)));
    connect( _statusDialog, SIGNAL(enableFolderAlias(QString,bool)),
             SLOT(slotEnableFolder(QString,bool)));
    connect( _statusDialog, SIGNAL(infoFolderAlias(const QString&)),
             SLOT(slotInfoFolder( const QString&)));
    connect( _statusDialog, SIGNAL(openFolderAlias(const QString&)),
             SLOT(slotFolderOpenAction(QString)));

#if 0
#if QT_VERSION >= 0x040700
    qDebug() << "* Network is" << (_networkMgr->isOnline() ? "online" : "offline");
    foreach (const QNetworkConfiguration& netCfg, _networkMgr->allConfigurations(QNetworkConfiguration::Active)) {
        //qDebug() << "Network:" << netCfg.identifier();
    }
#endif
#endif
    setupActions();
    setupSystemTray();
    setupProxy();


    int cnt = _folderMan->setupFolders();
    _statusDialog->setFolderList( _folderMan->map() );

    QObject::connect( this, SIGNAL(messageReceived(QString)),
                         this, SLOT(slotOpenStatus()) );

    QTimer::singleShot( 0, this, SLOT( slotStartFolderSetup() ));

    MirallConfigFile cfg;
    if( !cfg.ownCloudSkipUpdateCheck() ) {
        QTimer::singleShot( 3000, this, SLOT( slotStartUpdateDetector() ));
    }

    connect( ownCloudInfo::instance(), SIGNAL(sslFailed(QNetworkReply*, QList<QSslError>)),
             this,SLOT(slotSSLFailed(QNetworkReply*, QList<QSslError>)));

    qDebug() << "Network Location: " << NetworkLocation::currentLocation().encoded();
}
コード例 #6
0
ファイル: Settings.cpp プロジェクト: boccman/MediaElch
/**
 * @brief Loads all settings
 */
void Settings::loadSettings()
{
    // Globals
    m_mainWindowSize = m_settings.value("MainWindowSize").toSize();
    m_mainWindowPosition = m_settings.value("MainWindowPosition").toPoint();
    m_mainSplitterState = m_settings.value("MainSplitterState").toByteArray();
    m_debugModeActivated = m_settings.value("DebugModeActivated", false).toBool();
    m_debugLogPath = m_settings.value("DebugLogPath").toString();
    m_useCache = m_settings.value("UseCache", true).toBool();

    // Proxy
    m_useProxy = m_settings.value("Proxy/Enable", false).toBool();
    m_proxyType = m_settings.value("Proxy/Type", 0).toInt();
    m_proxyHost = m_settings.value("Proxy/Host").toString();
    m_proxyPort = m_settings.value("Proxy/Port", 0).toInt();
    m_proxyUsername = m_settings.value("Proxy/Username").toString();
    m_proxyPassword = m_settings.value("Proxy/Password").toString();
    setupProxy();

    // Movie Directories
    m_movieDirectories.clear();
    int moviesSize = m_settings.beginReadArray("Directories/Movies");
    for (int i=0 ; i<moviesSize ; ++i) {
        m_settings.setArrayIndex(i);
        SettingsDir dir;
        dir.path = QDir::toNativeSeparators(m_settings.value("path").toString());
        dir.mediaCenterPath = m_settings.value("mediaCenterPath").toString();
        dir.separateFolders = m_settings.value("sepFolders", false).toBool();
        m_movieDirectories.append(dir);
    }
    m_settings.endArray();

    // TV Show Directories
    m_tvShowDirectories.clear();
    int tvShowSize = m_settings.beginReadArray("Directories/TvShows");
    for (int i=0 ; i<tvShowSize ; ++i) {
        m_settings.setArrayIndex(i);
        SettingsDir dir;
        dir.path = QDir::toNativeSeparators(m_settings.value("path").toString());
        dir.mediaCenterPath = m_settings.value("mediaCenterPath").toString();
        dir.separateFolders = m_settings.value("sepFolders", false).toBool();
        m_tvShowDirectories.append(dir);
    }
    m_settings.endArray();

    // Concert Directories
    m_concertDirectories.clear();
    int concertsSize = m_settings.beginReadArray("Directories/Concerts");
    for (int i=0 ; i<concertsSize ; ++i) {
        m_settings.setArrayIndex(i);
        SettingsDir dir;
        dir.path = QDir::toNativeSeparators(m_settings.value("path").toString());
        dir.mediaCenterPath = m_settings.value("mediaCenterPath").toString();
        dir.separateFolders = m_settings.value("sepFolders", false).toBool();
        m_concertDirectories.append(dir);
    }
    m_settings.endArray();

    m_excludeWords = m_settings.value("excludeWords").toString();

    // Scrapers
    foreach (ScraperInterface *scraper, Manager::instance()->scrapers()) {
        if (scraper->hasSettings())
            scraper->loadSettings();
    }
    foreach (TvScraperInterface *scraper, Manager::instance()->tvScrapers()) {
        if (scraper->hasSettings())
            scraper->loadSettings();
    }
    foreach (ConcertScraperInterface *scraper, Manager::instance()->concertScrapers()) {
        if (scraper->hasSettings())
            scraper->loadSettings();
    }

    // Media Centers
    m_mediaCenterInterface = m_settings.value("MediaCenterInterface", MediaCenterInterfaces::XbmcXml).toInt();
    m_xbmcMysqlHost        = m_settings.value("XbmcMysql/Host").toString();
    m_xbmcMysqlDatabase    = m_settings.value("XbmcMysql/Database").toString();
    m_xbmcMysqlUser        = m_settings.value("XbmcMysql/User").toString();
    m_xbmcMysqlPassword    = m_settings.value("XbmcMysql/Password").toString();
    m_xbmcSqliteDatabase   = m_settings.value("XbmcSqlite/Database").toString();
    m_xbmcThumbnailPath    = m_settings.value("XbmcThumbnailpath").toString();
    m_youtubePluginUrls    = m_settings.value("UseYoutubePluginURLs", false).toBool();

    // XBMC xml file
    QList<DataFile*> files;
    files << m_movieNfoFiles << m_moviePosterFiles << m_movieFanartFiles << m_tvShowPosterFiles << m_tvShowBannerFiles;
    int movieDataFileSize = m_settings.beginReadArray("DataFiles");
    for (int i=0 ; i<movieDataFileSize ; ++i) {
        m_settings.setArrayIndex(i);
        foreach (DataFile *file, files) {
            if (file->id() != m_settings.value("id").toInt())
                continue;
            file->setEnabled(m_settings.value("enabled").toBool());
            file->setPos(m_settings.value("pos").toInt());
        }
    }
    m_settings.endArray();

    qSort(m_movieNfoFiles.begin(), m_movieNfoFiles.end(), DataFile::lessThan);
    qSort(m_moviePosterFiles.begin(), m_moviePosterFiles.end(), DataFile::lessThan);
    qSort(m_movieFanartFiles.begin(), m_movieFanartFiles.end(), DataFile::lessThan);
    qSort(m_tvShowPosterFiles.begin(), m_tvShowPosterFiles.end(), DataFile::lessThan);
    qSort(m_tvShowBannerFiles.begin(), m_tvShowBannerFiles.end(), DataFile::lessThan);
}
コード例 #7
0
ファイル: Settings.cpp プロジェクト: boccman/MediaElch
/**
 * @brief Saves all settings
 */
void Settings::saveSettings()
{
    m_settings.setValue("DebugModeActivated", m_debugModeActivated);
    m_settings.setValue("DebugLogPath", m_debugLogPath);
    m_settings.setValue("UseCache", m_useCache);

    m_settings.setValue("XbmcMysql/Host", m_xbmcMysqlHost);
    m_settings.setValue("XbmcMysql/Database", m_xbmcMysqlDatabase);
    m_settings.setValue("XbmcMysql/User", m_xbmcMysqlUser);
    m_settings.setValue("XbmcMysql/Password", m_xbmcMysqlPassword);
    m_settings.setValue("XbmcSqlite/Database", m_xbmcSqliteDatabase);
    m_settings.setValue("MediaCenterInterface", m_mediaCenterInterface);
    m_settings.setValue("XbmcThumbnailpath", m_xbmcThumbnailPath);
    m_settings.setValue("UseYoutubePluginURLs", m_youtubePluginUrls);

    // Proxy
    m_settings.setValue("Proxy/Enable", m_useProxy);
    m_settings.setValue("Proxy/Type", m_proxyType);
    m_settings.setValue("Proxy/Host", m_proxyHost);
    m_settings.setValue("Proxy/Port", m_proxyPort);
    m_settings.setValue("Proxy/Username", m_proxyUsername);
    m_settings.setValue("Proxy/Password", m_proxyPassword);
    setupProxy();

    m_settings.beginWriteArray("Directories/Movies");
    for (int i=0, n=m_movieDirectories.count() ; i<n ; ++i) {
        m_settings.setArrayIndex(i);
        m_settings.setValue("path", m_movieDirectories.at(i).path);
        m_settings.setValue("mediaCenterPath", m_movieDirectories.at(i).mediaCenterPath);
        m_settings.setValue("sepFolders", m_movieDirectories.at(i).separateFolders);
    }
    m_settings.endArray();

    m_settings.beginWriteArray("Directories/TvShows");
    for (int i=0, n=m_tvShowDirectories.count() ; i<n ; ++i) {
        m_settings.setArrayIndex(i);
        m_settings.setValue("path", m_tvShowDirectories.at(i).path);
        m_settings.setValue("mediaCenterPath", m_tvShowDirectories.at(i).mediaCenterPath);
    }
    m_settings.endArray();

    m_settings.beginWriteArray("Directories/Concerts");
    for (int i=0, n=m_concertDirectories.count() ; i<n ; ++i) {
        m_settings.setArrayIndex(i);
        m_settings.setValue("path", m_concertDirectories.at(i).path);
        m_settings.setValue("mediaCenterPath", m_concertDirectories.at(i).mediaCenterPath);
        m_settings.setValue("sepFolders", m_concertDirectories.at(i).separateFolders);
    }
    m_settings.endArray();

    m_settings.setValue("excludeWords", m_excludeWords);

    foreach (ScraperInterface *scraper, Manager::instance()->scrapers()) {
        if (scraper->hasSettings())
            scraper->saveSettings();
    }
    foreach (TvScraperInterface *scraper, Manager::instance()->tvScrapers()) {
        if (scraper->hasSettings())
            scraper->saveSettings();
    }
    foreach (ConcertScraperInterface *scraper, Manager::instance()->concertScrapers()) {
        if (scraper->hasSettings())
            scraper->saveSettings();
    }

    qSort(m_movieNfoFiles.begin(), m_movieNfoFiles.end(), DataFile::lessThan);
    qSort(m_moviePosterFiles.begin(), m_moviePosterFiles.end(), DataFile::lessThan);
    qSort(m_movieFanartFiles.begin(), m_movieFanartFiles.end(), DataFile::lessThan);
    qSort(m_tvShowPosterFiles.begin(), m_tvShowPosterFiles.end(), DataFile::lessThan);
    qSort(m_tvShowBannerFiles.begin(), m_tvShowBannerFiles.end(), DataFile::lessThan);

    QList<DataFile*> files;
    files << m_movieNfoFiles << m_moviePosterFiles << m_movieFanartFiles << m_tvShowPosterFiles << m_tvShowBannerFiles;
    m_settings.beginWriteArray("DataFiles");
    int i=0;
    foreach (DataFile *file, files) {
        m_settings.setArrayIndex(i++);
        m_settings.setValue("id", file->id());
        m_settings.setValue("pos", file->pos());
        m_settings.setValue("enabled", file->enabled());
    }
コード例 #8
0
ファイル: application.cpp プロジェクト: EdenTrees/mirall
Application::Application(int &argc, char **argv) :
    SharedTools::QtSingleApplication(argc, argv),
    _tray(0),
#if QT_VERSION >= 0x040700
    _networkMgr(new QNetworkConfigurationManager(this)),
#endif
    _sslErrorDialog(0),
    _contextMenu(0),
    _theme(Theme::instance()),
    _updateDetector(0),
    _logBrowser(0),
    _showLogWindow(false),
    _logFlush(false),
    _helpOnly(false),
    _fileItemDialog(0)
{
    setApplicationName( _theme->appNameGUI() );
    setWindowIcon( _theme->applicationIcon() );

    parseOptions(arguments());
    setupTranslations();
    setupLogBrowser();
    //no need to waste time;
    if ( _helpOnly ) return;

#ifdef Q_OS_LINUX
        // HACK: bump the refcount for libgnutls by calling dlopen()
        // so gnutls, which is an dependency of libneon on some linux
        // distros, and does not cleanup it's FDs properly, does
        // not get unloaded. This works around a FD exhaustion crash
        // (#154). We are not using gnutls at all and it's fine
        // if loading fails, so no error handling is performed here.
        dlopen("libgnutls.so", RTLD_LAZY|RTLD_NODELETE);
#endif

    connect( this, SIGNAL(messageReceived(QString)), SLOT(slotParseOptions(QString)));
    connect( Logger::instance(), SIGNAL(guiLog(QString,QString)),
             this, SLOT(slotShowTrayMessage(QString,QString)));
    // create folder manager for sync folder management
    _folderMan = new FolderMan(this);
    connect( _folderMan, SIGNAL(folderSyncStateChange(QString)),
             this,SLOT(slotSyncStateChange(QString)));
    _folderMan->setSyncEnabled(false);

    /* use a signal mapper to map the open requests to the alias names */
    _folderOpenActionMapper = new QSignalMapper(this);
    connect(_folderOpenActionMapper, SIGNAL(mapped(const QString &)),
            this, SLOT(slotFolderOpenAction(const QString &)));

    setQuitOnLastWindowClosed(false);

    _folderWizard = new FolderWizard;

    _owncloudSetupWizard = new OwncloudSetupWizard( _folderMan, _theme, this );
    connect( _owncloudSetupWizard, SIGNAL(ownCloudWizardDone(int)),
             this, SLOT(slotownCloudWizardDone(int)));

    _statusDialog = new StatusDialog( _theme );
    connect( _statusDialog, SIGNAL(addASync()), this, SLOT(slotAddFolder()) );

    connect( _statusDialog, SIGNAL(removeFolderAlias( const QString&)),
             SLOT(slotRemoveFolder(const QString&)));
    connect( _statusDialog, SIGNAL(enableFolderAlias(QString,bool)),
             SLOT(slotEnableFolder(QString,bool)));
    connect( _statusDialog, SIGNAL(infoFolderAlias(const QString&)),
             SLOT(slotInfoFolder( const QString&)));
    connect( _statusDialog, SIGNAL(openFolderAlias(const QString&)),
             SLOT(slotFolderOpenAction(QString)));

#if 0
#if QT_VERSION >= 0x040700
    qDebug() << "* Network is" << (_networkMgr->isOnline() ? "online" : "offline");
    foreach (const QNetworkConfiguration& netCfg, _networkMgr->allConfigurations(QNetworkConfiguration::Active)) {
        //qDebug() << "Network:" << netCfg.identifier();
    }
#endif
#endif
    setupActions();
    setupSystemTray();
    setupProxy();


    int cnt = _folderMan->setupFolders();
    _statusDialog->setFolderList( _folderMan->map() );

    QObject::connect( this, SIGNAL(messageReceived(QString)),
                         this, SLOT(slotOpenStatus()) );

    QTimer::singleShot( 0, this, SLOT( slotStartFolderSetup() ));

    MirallConfigFile cfg;
    if( !cfg.ownCloudSkipUpdateCheck() ) {
        QTimer::singleShot( 3000, this, SLOT( slotStartUpdateDetector() ));
    }

    connect( ownCloudInfo::instance(), SIGNAL(sslFailed(QNetworkReply*, QList<QSslError>)),
             this,SLOT(slotSSLFailed(QNetworkReply*, QList<QSslError>)));

    qDebug() << "Network Location: " << NetworkLocation::currentLocation().encoded();
}
コード例 #9
0
ファイル: globe_plugin.cpp プロジェクト: a11656358/QGIS
void GlobePlugin::run()
{
  if ( mViewerWidget != 0 )
  {
    return;
  }
#ifdef GLOBE_SHOW_TILE_STATS
  QgsGlobeTileStatistics* tileStats = new QgsGlobeTileStatistics();
  connect( tileStats, SIGNAL( changed( int, int ) ), this, SLOT( updateTileStats( int, int ) ) );
#endif
  QSettings settings;

//    osgEarth::setNotifyLevel( osg::DEBUG_INFO );

  mOsgViewer = new osgViewer::Viewer();
  mOsgViewer->setThreadingModel( osgViewer::Viewer::SingleThreaded );
  mOsgViewer->setRunFrameScheme( osgViewer::Viewer::ON_DEMAND );
  // Set camera manipulator with default home position
  osgEarth::Util::EarthManipulator* manip = new osgEarth::Util::EarthManipulator();
  mOsgViewer->setCameraManipulator( manip );
  osgEarth::Util::Viewpoint viewpoint;
  viewpoint.focalPoint() = osgEarth::GeoPoint( osgEarth::SpatialReference::get( "wgs84" ), -90., 0., 0. );
  viewpoint.heading() = 0.;
  viewpoint.pitch() = -90.;
  viewpoint.range() = 2e7;

  manip->setHomeViewpoint( viewpoint, 1. );
  manip->home( 0 );

  setupProxy();

  // Tile stats label
#ifdef GLOBE_SHOW_TILE_STATS
  mStatsLabel = new osgEarth::Util::Controls::LabelControl( "", 10 );
  mStatsLabel->setPosition( 0, 0 );
  osgEarth::Util::Controls::ControlCanvas::get( mOsgViewer )->addControl( mStatsLabel.get() );
#endif

  mDockWidget = new QgsGlobeWidget( mQGisIface, mQGisIface->mainWindow() );
  connect( mDockWidget, SIGNAL( destroyed( QObject* ) ), this, SLOT( reset() ) );
  connect( mDockWidget, SIGNAL( layersChanged() ), this, SLOT( updateLayers() ) );
  connect( mDockWidget, SIGNAL( showSettings() ), this, SLOT( showSettings() ) );
  connect( mDockWidget, SIGNAL( refresh() ), this, SLOT( updateLayers() ) );
  connect( mDockWidget, SIGNAL( syncExtent() ), this, SLOT( syncExtent() ) );
  mQGisIface->addDockWidget( Qt::RightDockWidgetArea, mDockWidget );

  if ( getenv( "GLOBE_MAPXML" ) )
  {
    char* mapxml = getenv( "GLOBE_MAPXML" );
    QgsDebugMsg( mapxml );
    osg::Node* node = osgDB::readNodeFile( mapxml );
    if ( !node )
    {
      QgsDebugMsg( "Failed to load earth file " );
      return;
    }
    mMapNode = osgEarth::MapNode::findMapNode( node );
    mRootNode = new osg::Group();
    mRootNode->addChild( node );
  }
  else
  {
    QString cacheDirectory = settings.value( "cache/directory", QgsApplication::qgisSettingsDirPath() + "cache" ).toString();
    osgEarth::Drivers::FileSystemCacheOptions cacheOptions;
    cacheOptions.rootPath() = cacheDirectory.toStdString();

    osgEarth::MapOptions mapOptions;
    mapOptions.cache() = cacheOptions;
    osgEarth::Map *map = new osgEarth::Map( /*mapOptions*/ );

    // The MapNode will render the Map object in the scene graph.
    osgEarth::MapNodeOptions mapNodeOptions;
    mMapNode = new osgEarth::MapNode( map, mapNodeOptions );

    mRootNode = new osg::Group();
    mRootNode->addChild( mMapNode );

    osgEarth::Registry::instance()->unRefImageDataAfterApply() = false;

    // Add draped layer
    osgEarth::TileSourceOptions opts;
    opts.L2CacheSize() = 0;
    opts.tileSize() = 128;
    mTileSource = new QgsGlobeTileSource( mQGisIface->mapCanvas(), opts );

    osgEarth::ImageLayerOptions options( "QGIS" );
    options.driver()->L2CacheSize() = 0;
    options.cachePolicy() = osgEarth::CachePolicy::USAGE_NO_CACHE;
    mQgisMapLayer = new osgEarth::ImageLayer( options, mTileSource );
    map->addImageLayer( mQgisMapLayer );

    // Add layers to the map
    updateLayers();

    // Create the frustum highlight callback
    mFrustumHighlightCallback = new QgsGlobeFrustumHighlightCallback(
      mOsgViewer, mMapNode->getTerrain(), mQGisIface->mapCanvas(), QColor( 0, 0, 0, 50 ) );
  }

  mRootNode->addChild( osgEarth::Util::Controls::ControlCanvas::get( mOsgViewer ) );

  mAnnotationsGroup = new osg::Group();
  mRootNode->addChild( mAnnotationsGroup );
  foreach ( QgsBillBoardItem* item, QgsProject::instance()->billboardRegistry()->items() )
  {
    addBillboard( item );
  }
コード例 #10
0
ファイル: application.cpp プロジェクト: tallship/mirall
Application::Application(int &argc, char **argv) :
    SharedTools::QtSingleApplication(argc, argv),
    _tray(0),
    _sslErrorDialog(0),
#if QT_VERSION >= 0x040700
    _networkMgr(new QNetworkConfigurationManager(this)),
#endif
    _contextMenu(0),
    _theme(Theme::instance()),
    _updateDetector(0),
    _showLogWindow(false),
    _logFlush(false),
    _helpOnly(false),
    _logBrowser(0)
{
    setApplicationName( _theme->appName() );
    setWindowIcon( _theme->applicationIcon() );

    parseOptions(arguments());
    setupLogBrowser();
    //no need to waste time;
    if ( _helpOnly ) return;
    processEvents();

    QTranslator *qtTranslator = new QTranslator(this);
    qtTranslator->load(QLatin1String("qt_") + QLocale::system().name(),
                      QLibraryInfo::location(QLibraryInfo::TranslationsPath));
    installTranslator(qtTranslator);

    QTranslator *mirallTranslator = new QTranslator(this);
#ifdef Q_OS_LINUX
    // FIXME - proper path!
    mirallTranslator->load(QLatin1String("mirall_") + QLocale::system().name(), QLatin1String("/usr/share/mirall/i18n/"));
#endif
#ifdef Q_OS_MAC
    mirallTranslator->load(QLatin1String("mirall_") + QLocale::system().name(), applicationDirPath()+QLatin1String("/../translations") ); // path defaults to app dir.
#endif
#ifdef Q_OS_WIN32
    mirallTranslator->load(QLatin1String("mirall_") + QLocale::system().name(), applicationDirPath());
#endif

    installTranslator(mirallTranslator);

    connect( this, SIGNAL(messageReceived(QString)), SLOT(slotParseOptions(QString)));

    // create folder manager for sync folder management
    _folderMan = new FolderMan(this);
    connect( _folderMan, SIGNAL(folderSyncStateChange(QString)),
             this,SLOT(slotSyncStateChange(QString)));

    /* use a signal mapper to map the open requests to the alias names */
    _folderOpenActionMapper = new QSignalMapper(this);
    connect(_folderOpenActionMapper, SIGNAL(mapped(const QString &)),
            this, SLOT(slotFolderOpenAction(const QString &)));

    setQuitOnLastWindowClosed(false);

    _folderWizard = new FolderWizard;

    _owncloudSetupWizard = new OwncloudSetupWizard( _folderMan, _theme, this );
    connect( _owncloudSetupWizard, SIGNAL(ownCloudWizardDone(int)), SLOT(slotStartFolderSetup(int)));

    _statusDialog = new StatusDialog( _theme );
    connect( _statusDialog, SIGNAL(addASync()), this, SLOT(slotAddFolder()) );

    connect( _statusDialog, SIGNAL(removeFolderAlias( const QString&)),
             SLOT(slotRemoveFolder(const QString&)));

    connect( _statusDialog, SIGNAL(openLogBrowser()), this, SLOT(slotOpenLogBrowser()));

    connect( _statusDialog, SIGNAL(enableFolderAlias(QString,bool)),
             SLOT(slotEnableFolder(QString,bool)));
    connect( _statusDialog, SIGNAL(infoFolderAlias(const QString&)),
             SLOT(slotInfoFolder( const QString&)));
    connect( _statusDialog, SIGNAL(openFolderAlias(const QString&)),
             SLOT(slotFolderOpenAction(QString)));

#if QT_VERSION >= 0x040700
    qDebug() << "* Network is" << (_networkMgr->isOnline() ? "online" : "offline");
    foreach (const QNetworkConfiguration& netCfg, _networkMgr->allConfigurations(QNetworkConfiguration::Active)) {
        //qDebug() << "Network:" << netCfg.identifier();
    }
#endif

    setupActions();
    setupSystemTray();
    setupProxy();
    processEvents();

    QObject::connect( this, SIGNAL(messageReceived(QString)),
                         this, SLOT(slotOpenStatus()) );

    QTimer::singleShot( 0, this, SLOT( slotStartFolderSetup() ));

    MirallConfigFile cfg;
    if( !cfg.ownCloudSkipUpdateCheck() ) {
        QTimer::singleShot( 3000, this, SLOT( slotStartUpdateDetector() ));
    }

    connect( ownCloudInfo::instance(), SIGNAL(sslFailed(QNetworkReply*, QList<QSslError>)),
             this,SLOT(slotSSLFailed(QNetworkReply*, QList<QSslError>)));

    qDebug() << "Network Location: " << NetworkLocation::currentLocation().encoded();
}
コード例 #11
0
FindSubtitlesWindow::FindSubtitlesWindow(QWidget *parent, Qt::WindowFlags f)
    : QDialog(parent, f)
{
    setupUi(this);

    set = 0; // settings

    subtitles_for_label->setBuddy(file_chooser);

    progress->hide();

    connect(file_chooser, SIGNAL(fileChanged(QString)),
            this, SLOT(setMovie(QString)));
    connect(file_chooser, SIGNAL(textChanged(const QString &)),
            this, SLOT(updateRefreshButton()));

    connect(refresh_button, SIGNAL(clicked()),
            this, SLOT(refresh()));

    connect(download_button, SIGNAL(clicked()),
            this, SLOT(download()));

    /*
    connect( language_filter, SIGNAL(editTextChanged(const QString &)),
             this, SLOT(applyFilter(const QString &)) );
    */
    connect(language_filter, SIGNAL(activated(int)),
            this, SLOT(applyCurrentFilter()));

    table = new QStandardItemModel(this);
    table->setColumnCount(COL_USER + 1);

    proxy_model = new QSortFilterProxyModel(this);
    proxy_model->setSourceModel(table);
    proxy_model->setFilterKeyColumn(COL_LANG);
    proxy_model->setFilterRole(Qt::UserRole);

    view->setModel(proxy_model);
    view->setRootIsDecorated(false);
    view->setSortingEnabled(true);
    view->setAlternatingRowColors(true);
    view->header()->setSortIndicator(COL_LANG, Qt::AscendingOrder);
    view->setEditTriggers(QAbstractItemView::NoEditTriggers);
    view->setContextMenuPolicy(Qt::CustomContextMenu);

    connect(view, SIGNAL(activated(const QModelIndex &)),
            this, SLOT(itemActivated(const QModelIndex &)));
    connect(view->selectionModel(), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)),
            this, SLOT(currentItemChanged(const QModelIndex &, const QModelIndex &)));

    connect(view, SIGNAL(customContextMenuRequested(const QPoint &)),
            this, SLOT(showContextMenu(const QPoint &)));

    downloader = new SimpleHttp(this);

    connect(downloader, SIGNAL(downloadFailed(QString)),
            this, SLOT(showError(QString)));
    connect(downloader, SIGNAL(downloadFinished(QByteArray)),
            this, SLOT(downloadFinished()));
    connect(downloader, SIGNAL(downloadFinished(QByteArray)),
            this, SLOT(parseInfo(QByteArray)));
    connect(downloader, SIGNAL(stateChanged(int)),
            this, SLOT(updateRefreshButton()));

    connect(downloader, SIGNAL(connecting(QString)),
            this, SLOT(connecting(QString)));
    connect(downloader, SIGNAL(dataReadProgress(int, int)),
            this, SLOT(updateDataReadProgress(int, int)));

#ifdef DOWNLOAD_SUBS
    include_lang_on_filename = true;

    file_downloader = new FileDownloader(this);
    file_downloader->setModal(false);
    connect(file_downloader, SIGNAL(downloadFailed(QString)),
            this, SLOT(showError(QString)), Qt::QueuedConnection);
    connect(file_downloader, SIGNAL(downloadFinished(const QByteArray &)),
            this, SLOT(archiveDownloaded(const QByteArray &)), Qt::QueuedConnection);
#endif

    // Actions
    downloadAct = new QAction(this);
    downloadAct->setEnabled(false);
    connect(downloadAct, SIGNAL(triggered()), this, SLOT(download()));

    copyLinkAct = new QAction(this);
    copyLinkAct->setEnabled(false);
    connect(copyLinkAct, SIGNAL(triggered()), this, SLOT(copyLink()));

    context_menu = new QMenu(this);
    context_menu->addAction(downloadAct);
    context_menu->addAction(copyLinkAct);

    retranslateStrings();

    language_filter->setCurrentIndex(0);

    // Proxy
    use_proxy = false;
    proxy_type = QNetworkProxy::HttpProxy;
    proxy_host = "";
    proxy_port = 0;
    proxy_username = "";
    proxy_password = "";

    setupProxy();
}
コード例 #12
0
void FindSubtitlesWindow::setSettings(QSettings *settings)
{
    set = settings;
    loadSettings();
    setupProxy();
}