示例#1
0
文件: clipboard.cpp 项目: smyhu/taot
Clipboard::Clipboard(QObject *parent)
    : QObject(parent)
    , m_clipboard(new bb::system::Clipboard(this))
    , m_text(QString::fromUtf8(m_clipboard->value("text/plain")))
    , m_clipboardWatcher(new QFileSystemWatcher(this))
{
    connect(m_clipboardWatcher, SIGNAL(fileChanged(QString)), SLOT(onFileChanged(QString)));
    connect(m_clipboardWatcher,
            SIGNAL(directoryChanged(QString)),
            SLOT(onDirectoryChanged(QString)));
    if (QFile::exists(CLIPBOARD_FILE_PATH))
        m_clipboardWatcher->addPath(CLIPBOARD_FILE_PATH);
    else
        m_clipboardWatcher->addPath(CLIPBOARD_PATH);
}
示例#2
0
void MainWindow::on_manualSyn_clicked()
{
    // 点击手动同步
    qDebug() << "onMannualSynClicked";
    click = true;
    if(!watchList.empty())
        enableInput(false);
    for(auto path : watchList)
    {
        QFileInfo check(path);
        if(check.isFile())
            onFileChanged(path);
        else if(check.isDir())
            onDirectoryChanged(path);
    }
}
示例#3
0
void MainWindow::init()
{
    watcher = new QFileSystemWatcher(this);
    timer = NULL;
    connect(watcher,SIGNAL(fileChanged(QString)),this,SLOT(onFileChanged(QString)));
    connect(watcher,SIGNAL(directoryChanged(QString)),this,SLOT(onDirectoryChanged(QString)));
    connect(ui->watchEdit,SIGNAL(textChanged()),this,SLOT(onWatchEditChanged()));
    connect(ui->compareEdit,SIGNAL(textChanged()),this,SLOT(onCompareEditChanged()));
    connect(ui->exceptEdit,SIGNAL(textChanged()),this,SLOT(onExceptEditChanged()));
    // 注册表
    pReg = new regeditHelper;
    connect(pReg,SIGNAL(getetInfoFinished(vector<pair<QString,bool>>)),this,SLOT(onGetRegInfo(vector<pair<QString,bool>>)));
    connect(ui->listWidget,SIGNAL(removeRegItem(QString)),pReg,SLOT(removeRegItem(QString)));
    connect(ui->listWidget,SIGNAL(enableRegItem(QString)),pReg,SLOT(enableRegItem(QString)));
    connect(ui->listWidget,SIGNAL(addRegItem(QString)),pReg,SLOT(addRegItem(QString)));
    pReg->refreshListView();
}
void HbSplashGenerator::doStart()
{
    qDebug() << PRE << "accessing theme";
    // Start listening to the theme-change-finished signal.
    HbTheme *theme = hbInstance->theme();
    connect(theme, SIGNAL(changeFinished()), SLOT(regenerate()));

    // Watch also the directories containing splashml files. Files may
    // be added/updated at any time.
    connect(&mFsWatcher, SIGNAL(directoryChanged(QString)), SLOT(onDirectoryChanged(QString)));
    foreach(const QString & dir, hbsplash_splashml_dirs()) {
        // Check for directory existence before calling addPath() to
        // avoid printing warnings.
        if (QDir(dir).exists()) {
            mFsWatcher.addPath(dir);
        }
    }

    // Regenerate screens on startup only when the theme, the language, the
    // number of files in the splash screen directory, or the splash screen
    // directory path is different than the recorded values. (or when
    // regeneration is forced via command line arg)
    QString lastTheme = mSettings->value(QLatin1String(last_theme_key)).toString();
    QString lastLang = mSettings->value(QLatin1String(last_lang_key)).toString();
    int lastFileCount = mSettings->value(QLatin1String(last_file_count_key)).toInt();
    QString lastOutputDir = mSettings->value(QLatin1String(last_output_dir_key)).toString();
    QString currentTheme = theme->name();
    QString currentLang = QLocale::system().name();
    QString currentOutputDir = hbsplash_output_dir();
    int currentFileCount = updateOutputDirContents(currentOutputDir);
    qDebug() << PRE << "last regen:" << lastTheme << lastLang << lastFileCount << lastOutputDir
             << "current:" << currentTheme << currentLang << currentFileCount << currentOutputDir;
    if (mForceRegen
            || currentFileCount == 0 // not having any files is wrong for sure
            || currentTheme != lastTheme
            || currentLang != lastLang
            || currentFileCount != lastFileCount
            || currentOutputDir != lastOutputDir) {
        QMetaObject::invokeMethod(this, "regenerate", Qt::QueuedConnection);
    }
}