コード例 #1
0
void KFileSystemWatcher::addPath(const QString &file)
{
  QFileSystemWatcher* watcher = availableWatcher();
  watcher->addPath(file);
  m_usedObjects[watcher]++;
  m_paths.insert(file, watcher);
}
コード例 #2
0
QvkWebcamWatcher::QvkWebcamWatcher()
{
  webcamCount = 0;
  QFileSystemWatcher * fileSystemWatcher = new QFileSystemWatcher();
  fileSystemWatcher->addPath( "/dev/" );
  connect( fileSystemWatcher, SIGNAL( directoryChanged( QString ) ), this, SLOT( myfileSystemWatcher( QString ) ) );
}
static PyObject *meth_QFileSystemWatcher_addPaths(PyObject *sipSelf, PyObject *sipArgs)
{
    PyObject *sipParseErr = NULL;

    {
        const QStringList* a0;
        int a0State = 0;
        QFileSystemWatcher *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "BJ1", &sipSelf, sipType_QFileSystemWatcher, &sipCpp, sipType_QStringList,&a0, &a0State))
        {
            Py_BEGIN_ALLOW_THREADS
            sipCpp->addPaths(*a0);
            Py_END_ALLOW_THREADS
            sipReleaseType(const_cast<QStringList *>(a0),sipType_QStringList,a0State);

            Py_INCREF(Py_None);
            return Py_None;
        }
    }

    /* Raise an exception if the arguments couldn't be parsed. */
    sipNoMethod(sipParseErr, sipName_QFileSystemWatcher, sipName_addPaths, doc_QFileSystemWatcher_addPaths);

    return NULL;
}
コード例 #4
0
ファイル: agentmanager.cpp プロジェクト: KDE/akonadi
    Q_FOREACH (const QString &path, pathList) {
        QFileSystemWatcher *watcher = new QFileSystemWatcher(this);
        watcher->addPath(path);

        connect(watcher, SIGNAL(directoryChanged(QString)),
                this, SLOT(updatePluginInfos()));
    }
コード例 #5
0
VlcEncodingSystem::VlcEncodingSystem(QObject *parent) : QObject(parent)
{
	QFileSystemWatcher	*watcher = new QFileSystemWatcher(this);

	connect(watcher, SIGNAL(directoryChanged(const QString &)), SLOT(OnChange(const QString &)));

	watcher->addPath(VlcStreamerApp::Instance()->QueueDir());
}
コード例 #6
0
void PropertyEditorView::setQmlDir(const QString &qmlDir)
{
    m_qmlDir = qmlDir;


    QFileSystemWatcher *watcher = new QFileSystemWatcher(this);
    watcher->addPath(m_qmlDir);
    connect(watcher, SIGNAL(directoryChanged(QString)), this, SLOT(reloadQml()));
}
コード例 #7
0
ファイル: buddylistmodel.cpp プロジェクト: creichert/phonion
BuddyListModel::BuddyListModel(QObject* parent)
  : QAbstractListModel(parent)
{
    QString blfile = QDir::currentPath() + "/apps/message/torchat/torchat/src/buddy-list.txt";
    QFileSystemWatcher* watcher = new QFileSystemWatcher(this);
    watcher->addPath(blfile);
    connect(watcher, SIGNAL(fileChanged(const QString&)), SLOT(onBuddyListChanged(const QString&)));
    onBuddyListChanged(blfile);
}
コード例 #8
0
void KFileSystemWatcher::removePath(const QString &file)
{
  QFileSystemWatcher* watcher = m_paths.value(file);
  if (!watcher)
    return;
  watcher->removePath(file);
  m_usedObjects[watcher]--;
  if (m_recentWatcher != watcher)
    m_recentWatcher = 0;
}
コード例 #9
0
ファイル: categoriesmodel.cpp プロジェクト: qmlos/shell
CategoriesModel::CategoriesModel(QObject *parent)
    : QAbstractListModel(parent)
    , m_allCategory(true)
{
    refresh();

    QFileSystemWatcher *watcher = new QFileSystemWatcher(this);
    watcher->addPaths(xdgApplicationsPaths());
    connect(watcher, &QFileSystemWatcher::directoryChanged, this, [this](const QString &) {
        refresh();
    });
}
コード例 #10
0
ファイル: fileengine.cpp プロジェクト: buschmann23/CMlyst
void FileEngine::loadSettings()
{
    Q_D(FileEngine);

    qCDebug(CMS_FILEENGINE) << "Loading settings" << QCoreApplication::applicationPid();

#if (QT_VERSION >= QT_VERSION_CHECK(5, 4, 1))
    QFileSystemWatcher *settingsWatch = qobject_cast<QFileSystemWatcher *>(sender());
    if (settingsWatch) {
        // On 5.4.1 the watch stops working once the file get's replaced
        // so make sure we watch it again
        settingsWatch->addPath(d->settingsInfo.absoluteFilePath());
    }
#endif

    // Make sure we read new things
    d->settings->sync();

    // Load main settings
    QHash<QString, QString> settings;
    d->settings->beginGroup(QStringLiteral("Main"));
    Q_FOREACH (const QString &key, d->settings->allKeys()) {
        settings.insert(key, d->settings->value(key).toString());
    }
    d->settings->endGroup();
    d->mainSettings = settings;

    // Load menus and menu locations
    d->settings->beginGroup(QStringLiteral("Menus"));
    QList<CMS::Menu *> menus;
    QHash<QString, CMS::Menu *> menuLocations;
    Q_FOREACH (const QString &menu, d->settings->childGroups()) {
        Menu *obj = d->createMenu(menu, this);

        bool added = false;
        Q_FOREACH (const QString &location, obj->locations()) {
            if (!menuLocations.contains(location)) {
                menuLocations.insert(location, obj);
                added = true;
            }
        }

        menus.append(obj);
    }
    d->settings->endGroup();
    d->menus = menus;
    d->menuLocations = menuLocations;

    // Store the last modified date
    d->mainSettingsDT = d->settingsInfo.lastModified();
}
コード例 #11
0
ファイル: workspacemanager.cpp プロジェクト: arip33/razor-qt
RazorWorkSpaceManager::RazorWorkSpaceManager(const QString & configId, RazorSettings * config)
    : DesktopPlugin(configId, config)
    , m_scene(0)
    , m_desktopCount(1)
{
    qDebug() << "RazorWorkSpaceManager::RazorWorkSpaceManager" << configId;
    DesktopConfig::instance()->config = config;
    DesktopConfig::instance()->configId = configId;

    m_scene = new DesktopScene(this);
    m_scene->setBackgroundBrush(Qt::transparent);

    setup();
    connect(razorApp, SIGNAL(themeChanged()), this, SLOT(setup()));
    QFileSystemWatcher *fw = new QFileSystemWatcher(this);
    fw->addPath(config->fileName());
    connect(fw, SIGNAL(fileChanged(QString)), this, SLOT(setup()));
}
コード例 #12
0
ファイル: fileengine.cpp プロジェクト: buschmann23/CMlyst
bool FileEngine::init(const QHash<QString, QString> &settings)
{
    Q_D(FileEngine);

    QString root = settings.value(QStringLiteral("root"));
    if (root.isEmpty()) {
        root = QDir::currentPath();
    }
    d->rootPath = root;
    d->pagesPath = root + QLatin1String("/pages");
    d->settingsInfo = d->rootPath.absoluteFilePath(QStringLiteral("site.conf"));
    d->settings = new QSettings(d->settingsInfo.absoluteFilePath(), QSettings::IniFormat);

    if (!d->pagesPath.exists() &&
            !d->pagesPath.mkpath(d->pagesPath.absolutePath())) {
        qCWarning(CMS_FILEENGINE) << "Failed to create pages path" << d->pagesPath.absolutePath();
        return false;
    }

    QFileSystemWatcher *watch = new QFileSystemWatcher(this);
    watch->addPath(d->pagesPath.absolutePath());
    connect(watch, &QFileSystemWatcher::directoryChanged,
            this, &FileEngine::loadPages);
    loadPages();

    // When the settings file changes the watcher stops
    // working, so it's better to watch for the settings directory
    QFileSystemWatcher *settingsWatch = new QFileSystemWatcher(this);
    settingsWatch->addPath(d->settingsInfo.absoluteFilePath());
    connect(settingsWatch, &QFileSystemWatcher::fileChanged,
            this, &FileEngine::loadSettings);
    loadSettings();

    if (!d->settings->isWritable()) {
        qCWarning(CMS_FILEENGINE) << "Settings file is not writable!" << d->settingsInfo.absoluteFilePath();
        return false;
    }

    return true;
}
コード例 #13
0
ファイル: reloader.cpp プロジェクト: barbac/qmlreloader
Reloader::Reloader(QtQuick2ApplicationViewer *viewer, const QString &path,
                   QObject *parent)
    : QObject(parent)
    , m_viewer(viewer)
{
    QFileInfo info(path);
    m_mainFile = info.absoluteFilePath();
    QString dirPath = info.absolutePath();
    qDebug() << "FILE" << m_mainFile;
    qDebug() << "DIR" << dirPath;

    QFileSystemWatcher *pathWatcher = new QFileSystemWatcher(this);
    bool success = pathWatcher->addPath(m_mainFile);
    Q_ASSERT(success);
    pathWatcher->addPath(dirPath);
    connect(pathWatcher, SIGNAL(directoryChanged(QString)), this, SLOT(timeIt()));

    m_timer = new QTimer(this);
    m_timer->setInterval(300);
    m_timer->setSingleShot(true);
    connect(m_timer, SIGNAL(timeout()), this, SLOT(reload()));
}
コード例 #14
0
ファイル: Library.cpp プロジェクト: BurrrY/Client
/** Library constructor
 * Initialize the library UI and generate an initial list of all the games available.
 * \param p Inherited palette configuration for setting StyleSheets.
 * \param parent Pointer to parent widget.
*/
Library::Library(QSettings* p, QWidget* parent)
    : QWidget(parent)
{
    this->setObjectName("libraryUI");
    this->setStyleSheet("QPushButton {"
                        "color: " + p->value("Primary/LightText").toString() + "; "
                        "background-color: " + p->value("Primary/DarkElement").toString() + "; "
                        "border: none; margin: 0px; padding: 0px;} "
                        "QPushButton:hover {"
                        "background-color: " + p->value("Primary/InactiveSelection").toString() + ";} "
                        "QListWidget {"
                        "background-color: " + p->value("Primary/TertiaryBase").toString() + "; "
                        "color: " + p->value("Primary/LightText").toString() + ";}"
                        "QLabel {"
                        "color: " + p->value("Primary/LightText").toString() + ";"
                        "font-family: SourceSansPro;"
                        "}");

    init(p);

    if (!db.init())
    {
        QMessageBox error;
        error.critical(0, tr("Error!"), tr("An error occurred while trying to load the database."));
        exit(EXIT_FAILURE);
    }

    QList<Game> games = db.getGames();
    for (auto game : games)
    {
        qDebug() << game.id << game.gameName << game.gameDirectory << game.executablePath;
    }

    QFileSystemWatcher* watcher = new QFileSystemWatcher;
    watcher->addPath(QDir(CONFIG_FOLDER).filePath("horizon.db"));
    connect(watcher, &QFileSystemWatcher::fileChanged, this, &Library::refreshGames);

    refreshGames();
}
コード例 #15
0
bool
AmarokEmbeddedSqlConnection::startServer( const int port, const QString &socketPath,
                                          const QString &pidPath )
{
    DEBUG_BLOCK
    Q_ASSERT( this->thread() == ThreadWeaver::Thread::currentThread() );

    if( !m_mysqld.isExecutable() )
    {
        warning() << __PRETTY_FUNCTION__ << m_mysqld.absoluteFilePath()
                  << "is not executable";
        return false;
    }

    if( !m_datadir.isReadable() )
    {
        warning() << __PRETTY_FUNCTION__ << m_datadir.absolutePath() << "is not readable";
        return false;
    }

    QEventLoop loop;
    QFileSystemWatcher watcher;
    QTimer timer;

    // Set conditions on which we stop waiting for the startup
    connect( &timer,   SIGNAL(timeout()),
             &loop,    SLOT(quit()), Qt::QueuedConnection );
    connect( &watcher, SIGNAL(fileChanged(QString)),
             &loop,    SLOT(quit()), Qt::QueuedConnection );
    connect( &m_srv,   SIGNAL(error(QProcess::ProcessError)),
             &loop,    SLOT(quit()), Qt::QueuedConnection );

    // Important: we use modification of pidfile as a cue that the server is ready
    // This is consistent with behavior of mysqld startup scripts
    watcher.addPath( pidPath );
    timer.start( SERVER_START_TIMEOUT );

    const QStringList args = QStringList()
         << "--no-defaults"
         << "--port=" + QString::number( port )
         << "--datadir=" + m_datadir.absolutePath()
         << "--default-storage-engine=MyISAM"
         << "--skip-grant-tables"
         << "--myisam-recover-options=FORCE"
         << "--key-buffer-size=16777216"
         << "--character-set-server=utf8"
         << "--collation-server=utf8_bin"
         << "--skip-innodb"
         << "--bind-address=localhost"
         << "--socket=" + socketPath
         << "--pid-file=" + pidPath;

    m_srv.start( m_mysqld.absoluteFilePath(), args );
    debug() << __PRETTY_FUNCTION__ << m_mysqld.absoluteFilePath() + " " + args.join(" ");

    // Wait for any of the startup conditions to be true
    loop.exec();

    if( m_srv.state() != QProcess::Running )
    {
        warning() << __PRETTY_FUNCTION__ << "error starting server application:"
                  << m_srv.errorString();
        return false;
    }

    return true;
}
コード例 #16
0
ファイル: ipsender.cpp プロジェクト: beowulf215/ipc_sender
void ipsender::populateList(sys &sys_1, QFileSystemWatcher &watched)
{
    if(!already_populated)
    {
        ssv = &sys_1;


    for (int i = 0; i < sys_1.index.size(); i++)
    {
        if(!QString::compare(localhost,sys_1.index[i].hostdns,Qt::CaseSensitive))
        {
            qDebug() << "Found a match for " << localhost << " on index " << i;
            subindex = sys_1.index[i].subindex;
            nameindex = sys_1.index[i].hostindex;
            break;
        }
    }

    for (int i = 0; i < sys_1.index.size(); i++)
    {
        if(sys_1.index[i].subindex == subindex && sys_1.index[i].hostindex == nameindex)
        {

            watched.addPath(sys_1.index[i].statuspath);
            w_info.push_back(watching());
            w_info[watchindex].subindex = subindex;
            w_info[watchindex].hostindex = nameindex;
            w_info[watchindex].in_interface = false;
            w_info[watchindex].procindex = sys_1.index[i].procindex;
            w_info[watchindex].dns_source = localhost;
            watchindex++;

            if(!sys_1.index[i].ifstatpath.isEmpty())
            {
                watched.addPath(sys_1.index[i].ifstatpath);
                w_info.push_back(watching());
                w_info[watchindex].subindex = subindex;
                w_info[watchindex].hostindex = nameindex;
                w_info[watchindex].in_interface = true;
                w_info[watchindex].procindex = sys_1.index[i].procindex;
                w_info[watchindex].dns_source = localhost;
                watchindex++;
            }
        }
    }



    qDebug() << "Watching list populated!";
    qDebug() << "Info on Watched Paths";

    for (int i = 0; i < w_info.size(); i++)
    {
        qDebug() << "Sub Index: " << w_info[i].subindex
                 << " Host Index: " << w_info[i].hostindex
                 << " Process Index: " << w_info[i].procindex
                 << " Interface?: " << w_info[i].in_interface
                 << " Source Host: " << w_info[i].dns_source
                 << " Status Path: " << watched.files()[i];
    }

    w_list = watched.files();

    watchindex = 0;
    selfPopulate(w_info, watched.files(), sys_1);
    already_populated = true;
    }

}
コード例 #17
0
void ControlPresencial::MonitorizaFicheros(QString str)
{
   // ControlPresencial* mc = new ControlPresencial;
qDebug() << "Monitoriza ficheros " << str;
 QFileSystemWatcher *watcher = new QFileSystemWatcher(this);
    if(str.contains("inicio")){
        QFile f("/home/pi/Desktop/RFID-US/errorconexion.log");
        f.open(QIODevice::ReadWrite);
        QFile f2("/home/pi/Desktop/RFID-US/erroraulas.log");
        f2.open(QIODevice::ReadWrite);
        QFile f3("/home/pi/Desktop/RFID-US/errorlector.log");
        f3.open(QIODevice::ReadWrite);
        QFile f4("/home/pi/Desktop/RFID-US/usuarioregistrado.log");
        f4.open(QIODevice::ReadWrite);
        QFile f5("/home/pi/Desktop/RFID-US/registro.xml");
        f5.open(QIODevice::ReadWrite);
        QFile f6("/home/pi/Desktop/RFID-US/oklector.log");
        f6.open(QIODevice::ReadWrite);
        QFile f7("/home/pi/Desktop/RFID-US/okconexion.log");
        f7.open(QIODevice::ReadWrite);
		QFile f8("/home/pi/Desktop/RFID-US/errorconexionregistro.log");
        f8.open(QIODevice::ReadWrite);
		QFile f9("/home/pi/Desktop/RFID-US/errorrecibido.log");
        f9.open(QIODevice::ReadWrite);
		QFile f10("/home/pi/Desktop/RFID-US/errordom2.log");
        f10.open(QIODevice::ReadWrite);
		QFile f11("/home/pi/Desktop/RFID-US/erroreneldom.log");
        f11.open(QIODevice::ReadWrite);
		QFile f12("/home/pi/Desktop/RFID-US/errorbbdd.log");
        f12.open(QIODevice::ReadWrite);
		QFile f13("/home/pi/Desktop/RFID-US/reintentarlector.log");
        f13.open(QIODevice::ReadWrite);
		
        QObject::connect(watcher, SIGNAL(fileChanged(QString)),this, SLOT(showModified(QString)));
        watcher->addPath("/home/pi/Desktop/RFID-US/errorconexion.log");
        watcher->addPath("/home/pi/Desktop/RFID-US/erroraulas.log");
        watcher->addPath("/home/pi/Desktop/RFID-US/errorlector.log");
        watcher->addPath("/home/pi/Desktop/RFID-US/usuarioregistrado.log");
        watcher->addPath("/home/pi/Desktop/RFID-US/registro.xml");
        watcher->addPath("/home/pi/Desktop/RFID-US/oklector.log");
        watcher->addPath("/home/pi/Desktop/RFID-US/okconexion.log");
		watcher->addPath("/home/pi/Desktop/RFID-US/errorconexionregistro.log");
		watcher->addPath("/home/pi/Desktop/RFID-US/errorrecibido.log");
		watcher->addPath("/home/pi/Desktop/RFID-US/errordom2.log");
		watcher->addPath("/home/pi/Desktop/RFID-US/erroreneldom.log");
		watcher->addPath("/home/pi/Desktop/RFID-US/errorbbdd.log");
		watcher->addPath("/home/pi/Desktop/RFID-US/reintentarlector.log");
           } else {
        QFile f(str);
        f.open(QIODevice::ReadWrite);
        qDebug() << "Creamos el fichero " << str;
        watcher->addPath(str);
    }
}