コード例 #1
0
/**
 *Opens an open file dialog.
 */
QString DeviceWidget::setOpenFileName()
{
    QFileDialog::Options options;
    QString selectedFilter;
    QString fwDirectoryStr;
    QDir fwDirectory;

    //Format filename for file chooser
#ifdef Q_OS_WIN
	fwDirectoryStr=QCoreApplication::applicationDirPath();
	fwDirectory=QDir(fwDirectoryStr);
	fwDirectory.cdUp();
	fwDirectory.cd("firmware");
	fwDirectoryStr=fwDirectory.absolutePath();
#elif defined Q_OS_LINUX
	fwDirectoryStr=QCoreApplication::applicationDirPath();
	fwDirectory=QDir(fwDirectoryStr);
    fwDirectory.cd("../../..");
    fwDirectoryStr=fwDirectory.absolutePath();
    fwDirectoryStr=fwDirectoryStr+"/fw_"+myDevice->lblBrdName->text().toLower()+"/fw_"+myDevice->lblBrdName->text().toLower()+".opfw";
#elif defined Q_OS_MAC
    fwDirectoryStr=QCoreApplication::applicationDirPath();
    fwDirectory=QDir(fwDirectoryStr);
    fwDirectory.cd("../../../../../..");
    fwDirectoryStr=fwDirectory.absolutePath();
    fwDirectoryStr=fwDirectoryStr+"/fw_"+myDevice->lblBrdName->text().toLower()+"/fw_"+myDevice->lblBrdName->text().toLower()+".opfw";
#endif
    QString fileName = QFileDialog::getOpenFileName(this,
                                                    tr("Select firmware file"),
                                                    fwDirectoryStr,
                                                    tr("Firmware Files (*.opfw *.bin)"),
                                                    &selectedFilter,
                                                    options);
    return fileName;
}
コード例 #2
0
ファイル: qtprinters.cpp プロジェクト: doniexun/kdevelop
    GdbProcess(const QString &program) : QProcess()
    {
        setProcessChannelMode(MergedChannels);
        // don't attempt to load .gdbinit in home (may cause unexpected results)
        QProcess::start("gdb", (QStringList() << "-nx" << (BINARY_PATH + '/' + program)));
        const bool started = waitForStarted();
        if (!started) {
            qDebug() << "Failed to start 'gdb' executable:" << errorString();
            Q_ASSERT(false);
            return;
        }

        QByteArray prompt = waitForPrompt();
        QVERIFY(!prompt.contains("No such file or directory"));
        execute("set confirm off");
        execute("set print pretty on");
        execute("set disable-randomization off"); // see https://phabricator.kde.org/D2188
        QList<QByteArray> p;
        QDir printersDir = QFileInfo(__FILE__).dir();
        printersDir.cdUp(); // go up to get to the main printers directory
        p << "python"
          << "import sys"
          << "sys.path.insert(0, '"+printersDir.path().toLatin1()+"')"
          << "from qt import register_qt_printers"
          << "register_qt_printers (None)"
          << "from kde import register_kde_printers"
          << "register_kde_printers (None)"
          << "end";
        foreach (const QByteArray &i, p) {
            write(i + "\n");
        }
コード例 #3
0
ファイル: bazaarutils.cpp プロジェクト: KDE/kdevplatform
QDir BazaarUtils::workingCopy(const QUrl& path)
{
    QDir dir = BazaarUtils::toQDir(path);
    while (!dir.exists(QStringLiteral(".bzr")) && dir.cdUp());

    return dir;
}
コード例 #4
0
ファイル: addcamera.cpp プロジェクト: kaajo/WebCamCap
void AddCamera::on_calibButton_clicked()
{
    QStringList arguments;

    QString usbid = m_ui->usbId->text();
    if(usbid == "")
    {
        usbid = "0";
    }

    arguments << usbid;
    arguments << "-w" << "7" << "-h" << "5" << "-pt" << "chessboard" << "-n" << "25";
    arguments << "-o" << m_ui->name->text() + ".yaml";

    QDir dir = QDir::current();
    dir.cdUp();
    dir.cd("Calib");

    QString path = dir.path() + "/Calib";

    QFile file(path);

    if(!file.exists())
    {
        qDebug() << "calib program does not exist in path:" << path;
    }

    m_calibApplication = new QProcess(this);
    m_calibApplication->start(path,  arguments);

    connect(m_calibApplication, SIGNAL(finished(int)), this, SLOT(readYaml(int)));
}
コード例 #5
0
QString BaseQtVersion::defaultDisplayName(const QString &versionString, const Utils::FileName &qmakePath,
                                          bool fromPath)
{
    QString location;
    if (qmakePath.isEmpty()) {
        location = QCoreApplication::translate("QtVersion", "<unknown>");
    } else {
        // Deduce a description from '/foo/qt-folder/[qtbase]/bin/qmake' -> '/foo/qt-folder'.
        // '/usr' indicates System Qt 4.X on Linux.
        QDir dir = qmakePath.toFileInfo().absoluteDir();
        do {
            const QString dirName = dir.dirName();
            if (dirName == QLatin1String("usr")) { // System-installed Qt.
                location = QCoreApplication::translate("QtVersion", "System");
                break;
            }
            if (dirName.compare(QLatin1String("bin"), Qt::CaseInsensitive)
                && dirName.compare(QLatin1String("qtbase"), Qt::CaseInsensitive)) {
                location = dirName;
                break;
            }
        } while (dir.cdUp());
    }

    return fromPath ?
        QCoreApplication::translate("QtVersion", "Qt %1 in PATH (%2)").arg(versionString, location) :
        QCoreApplication::translate("QtVersion", "Qt %1 (%2)").arg(versionString, location);
}
コード例 #6
0
ファイル: roottools.cpp プロジェクト: AllenWeb/hoststool-cpp
/**
 * @brief Remount the file path,the mount point will be found automatically.
 * @param file the path of file.
 * @param mountType  "rw" or "ro"
 */
bool RootTools::remount(QString file, QString mountType)
{
    if(mounts_.size() == 0){
        mounts_ = getMounts();
    }

    bool foundMount = false;
    int i = 0;
    QDir dir = QFileInfo(file).dir();

    while(!foundMount){
        for(i = 0; i < mounts_.size(); i++){
            if(dir.absolutePath() == mounts_[i][1]){
                foundMount = true;
                break;
            }
        }
        dir.cdUp();
        if(dir.isRoot())
            break;
    }
    if(!foundMount)
        return false;

    QString cmd = "mount -o " + mountType + ",remount " + mounts_[i][0] + " " + mounts_[i][1] + "\n";
    qDebug()<<"mount"<<cmd;
    shell_.write(cmd.toStdString().c_str(), cmd.size());
    shell_.waitForBytesWritten(100);

    return true;
}
コード例 #7
0
bool
LibraryParser::serialize(QDir home)
{
    // we write to root of all cyclists
    home.cdUp();

    // open file - truncate contents
    QString filename = home.canonicalPath() + "/library.xml";
    QFile file(filename);
    file.open(QFile::WriteOnly);
    file.resize(0);
    QTextStream out(&file);
    out.setCodec("UTF-8");


    // write out to file
    foreach (Library *l, ::libraries) {
        // begin document
        out << QString("<library name=\"%1\">\n").arg(l->name);

        // paths...
        foreach(QString p, l->paths)
            out << QString("\t<path>%1</path>\n").arg(p);

        // paths...
        foreach(QString r, l->refs)
            out << QString("\t<ref>%1</ref>\n").arg(r);

        // end document
        out << "</library>\n";
    }
コード例 #8
0
void QVaultImageNode::IExportImage()
{
    plVaultImageNode* img = fNode.upcastToImageNode();
    if (img == NULL)
        return;
    plVaultBlob blob = img->getImageData();

    QString fname = fImgTitle->text() + ".jpg";
    fname.replace(QRegExp("[\\\\/:*?\"<>|]"), "_");
    if (!ieDir.isEmpty())
        fname = ieDir + "/" + fname;
    fname = QFileDialog::getSaveFileName(this, tr("Export JPEG"), fname,
                                         "JPEG Files (*.jpg)", 0);

    if (!fname.isEmpty()) {
        QDir ieDirTmp = QDir(fname);
        ieDirTmp.cdUp();
        ieDir = ieDirTmp.absolutePath();

        FILE* xf = fopen(fname.toUtf8().data(), "wb");
        if (xf == NULL) {
            QMessageBox::critical(this, tr("Error saving JPEG"),
                                  tr("Could not open %1 for writing").arg(fname),
                                  QMessageBox::Ok);
            return;
        }
        fwrite((const uchar*)blob.getData() + 4, 1, blob.getSize() - 4, xf);
        fclose(xf);
    }
}
コード例 #9
0
ファイル: mainwindow.cpp プロジェクト: w3tl/gostunnel
void MainWindow::on_btnStart_clicked()
{
    if (!QFile(programPath).exists()) {
        QMessageBox::warning(this,
                             tr("Невозможно запустить процесс"),
                             tr("Не найден файл программы.\n"
                                "Возможно, не указан путь к файлу gostunnel.exe"));
        return;
    }
    if (ui->lwGroups->count() == 0) {
        return;
    }
    QString el = ui->lwGroups->currentItem()->text();
    QProcess *proc = connections.value(el);
    if (proc->pid() <= 0) {
        QDir wd = QDir(programPath);
        wd.cdUp();
        proc->setWorkingDirectory(wd.path());
        QStringList args;
        args << "--config" << programConfig
             << "-s" << el;
        connect(proc, SIGNAL(error(QProcess::ProcessError)),
                this, SLOT(processError(QProcess::ProcessError)));
        connect(proc, SIGNAL(finished(int,QProcess::ExitStatus)),
                this, SLOT(processFinished(int,QProcess::ExitStatus)));
        connect(proc, SIGNAL(stateChanged(QProcess::ProcessState)),
                this, SLOT(processStateChenged(QProcess::ProcessState)));
        connect(proc, SIGNAL(readyReadStandardError()),
                this, SLOT(processReadyReadError()));
        connect(proc, SIGNAL(started()),
                this, SLOT(processStarted()));
        ui->lwGroups->currentItem()->setBackgroundColor(QColor::fromRgb(255, 233, 113));
        proc->start(programPath, args);
    }
コード例 #10
0
	void FileSystemModel::cdUp ()
	{
		QDir root (m_rootPath);
		root.cdUp();
		m_rootPath = root.absolutePath();
		updateModel ();
	}
コード例 #11
0
 void Config::init()
 {
     QDir path = QGuiApplication::applicationDirPath();
     path.cdUp();
     
     resourceDir = path.absolutePath() + "/Resources";
 }
コード例 #12
0
ファイル: filesystemwidget.cpp プロジェクト: is00hcw/liteide
void FileSystemWidget::renameFolder()
{
    QFileInfo info = contextFileInfo();
    if (!info.isDir()) {
        return;
    }

    QString folderName = QInputDialog::getText(m_liteApp->mainWindow(),
                                               tr("Rename Folder"),tr("Folder Name"),
                                               QLineEdit::Normal,info.fileName());
    if (!folderName.isEmpty() && folderName != info.fileName()) {
        QDir dir = contextDir();
        dir.cdUp();
#ifdef Q_OS_WIN
        QString _old = info.filePath();
        QString _new = dir.path()+"/"+folderName;
        if (!MoveFileW(_old.toStdWString().c_str(),_new.toStdWString().c_str())) {
            QMessageBox::information(m_liteApp->mainWindow(),tr("Rename Folder"),
                                     tr("Failed to rename the folder!"));
        }
#else
        if (!dir.rename(info.fileName(),folderName)) {
            QMessageBox::information(m_liteApp->mainWindow(),tr("Rename Folder"),
                                     tr("Failed to rename the folder!"));
        }
#endif
    }
}
コード例 #13
0
void QtResourceView::selectResource(const QString &resource)
{
    QFileInfo fi(resource);
    QDir dir = fi.absoluteDir();
    if (fi.isDir())
        dir = QDir(resource);
    QString dirPath = dir.absolutePath();
    QMap<QString, QTreeWidgetItem *>::const_iterator it;
    while ((it = d_ptr->m_pathToItem.find(dirPath)) == d_ptr->m_pathToItem.constEnd()) {
        if (!dir.cdUp())
            break;
        dirPath = dir.absolutePath();
    }
    if (it != d_ptr->m_pathToItem.constEnd()) {
        QTreeWidgetItem *treeItem = it.value();
        d_ptr->m_treeWidget->setCurrentItem(treeItem);
        d_ptr->m_treeWidget->scrollToItem(treeItem);
        // expand all up to current one is done by qt
        // list widget is already propagated (currrent changed was sent by qt)
        QListWidgetItem *item = d_ptr->m_resourceToItem.value(resource);
        if (item) {
            d_ptr->m_listWidget->setCurrentItem(item);
            d_ptr->m_listWidget->scrollToItem(item);
        }
    }
}
コード例 #14
0
ファイル: main.cpp プロジェクト: mokerjoke/circa
bool fix_current_directory()
{
    // First step, we need to find the "ca" directory. If we're running from a Mac
    // bundle, then we'll need to walk up a few directories.

    while (true) {

        if (QDir("ca").exists())
            return true;

        // chdir to parent
        QDir current = QDir::current();
        current.cdUp();

        // If we reached the top, then fatal.
        if (current == QDir::current()) {
            QMessageBox msg;
            msg.setText("Fatal: Couldn't find the 'ca' directory");
            msg.exec();
            return false;
        }

        QDir::setCurrent(current.path());
    }
}
コード例 #15
0
int main(int argc, char *argv[])
{
	// DECLARATIONS BEFORE APPLICATION STARTS
	QApplication a(argc, argv);
	QDir	directory = QDir::current();

	while(directory.dirName() != "Class-Project")
	{
		directory.cdUp();
	}

	if(!directory.cd("Database-Files"))
	{
		directory.mkpath("Database-Files");
		directory.cd("Database-Files");
	}

	qDebug() << "Current Directory : " << directory.path();

	QFile::copy(":/CustomerDatabase.txt",(directory.path() +  "/CustomerList.txt"));
	QFile::copy(":/ProductDatabase.txt",(directory.path() +  "/ProductList.txt"));
	QFile::copy(":/Testimonials.txt",(directory.path()) + "/Testimonials.txt");

	// MAIN WINDOW HAS TO STAY DOWN HERE OR IT WILL TRY TO INITIALIZE BEFORE
	//	CHECKING FOR DIRECTORY
	MainProgramWindow MainProgramWindow;
	MainProgramWindow.setDatabaseStatus(false);
	// DISPLAYS MAIN WINDOW
    MainProgramWindow.show();

    return a.exec();
}
コード例 #16
0
ファイル: filebrowser.cpp プロジェクト: screscent/liteide
void FileBrowser::cdUp()
{
    QDir dir = m_fileModel->rootDirectory();
    if (!dir.path().isEmpty() && dir.cdUp()) {
        addFolderToRoot(dir.path());
    }
}
コード例 #17
0
ファイル: Test.cpp プロジェクト: Przemyslawmd/Fifteen
void Test::testCreateGraphicBoard( int testNumber )
{
    DataGraphic testData = Data::getTestGraphic( testNumber );

    QDir currentDir = QDir::currentPath();
    currentDir.cdUp();
    QImage image( currentDir.absolutePath() + "/Test/Images/" + testData.imagesPath + "initial.jpg" );

    unique_ptr< OptionsData > options ( new OptionsData );
    options->graphicMode = testData.mode;
    options->imageToLoad_4 = testData.isFourToBeLoaded;
    options->imageToLoad_5 = testData.isFiveToBeLoaded;
    options->imageToLoad_6 = testData.isSixToBeLoaded;
    options->imageToLoad_7 = testData.isSevenToBeLoaded;
    Options::receiveData( move( options ));

    ImageProvider& imageProvider = ImageProvider::getInstance();
    imageProvider.prepareGraphicBoard( image, testData.tileSize );
    vector< QImage* >& images = imageProvider.getImages( testData.size );

    int sizeInt = Mapped::boardSizeInt.at( testData.size );
    for ( int i = 0; i < sizeInt * sizeInt; i++ )
    {
        QImage image( currentDir.absolutePath() + "/Test/Images/" + testData.imagesPath + QString::number( i ) + ".bmp" );
        compareQImage( *images.at( i ), image );
    }
}
コード例 #18
0
ファイル: application.cpp プロジェクト: admhome/icqdesktop
    bool Application::updating()
    {
#ifdef _WIN32

        CHandle mutex(::CreateSemaphore(NULL, 0, 1, updater_singlton_mutex_name.c_str()));
        if (ERROR_ALREADY_EXISTS == ::GetLastError())
            return true;
        
        CRegKey key_software;

        if (ERROR_SUCCESS != key_software.Open(HKEY_CURRENT_USER, L"Software"))
            return false;

        CRegKey key_product;
        if (ERROR_SUCCESS != key_product.Create(key_software, (const wchar_t*) product_name.utf16()))
            return false;

        wchar_t version_buffer[1025];
        unsigned long len = 1024;
        if (ERROR_SUCCESS != key_product.QueryStringValue(L"update_version", version_buffer, &len))
            return false;

        QString version_update = QString::fromUtf16((const ushort*) version_buffer);

        core::tools::version_info info_current;
        core::tools::version_info info_update(version_update.toStdString());

        if (info_current < info_update)
        {
            wchar_t this_module_name[1024];
            if (!::GetModuleFileName(0, this_module_name, 1024))
                return false;

            QDir dir = QFileInfo(QString::fromUtf16((const ushort*) this_module_name)).absoluteDir();
            if (!dir.cdUp())
                return false;

            QString update_folder = dir.absolutePath() + "/" + updates_folder_short  + "/" + version_update;

            QDir update_dir(update_folder);
            if (update_dir.exists())
            {
                QString setup_name = update_folder + "/" + installer_exe_name;
                QFileInfo setup_info(setup_name);
                if (!setup_info.exists())
                    return false;

                mutex.Close();

                const auto command = QString("\"") + QDir::toNativeSeparators(setup_name) + "\"" + " " + update_final_command;
                QProcess::startDetached(command);

                return true;
            }
        }

#endif //_WIN32
        return false;
    }
コード例 #19
0
ファイル: sandbox.cpp プロジェクト: flashpig/mixxx
// static
SecurityTokenPointer Sandbox::openSecurityToken(const QDir& dir, bool create) {
    QDir walkDir = dir;
    QString walkDirCanonicalPath = walkDir.canonicalPath();
    if (sDebug) {
        qDebug() << "openSecurityToken QDir" << walkDirCanonicalPath << create;
    }

    if (!enabled()) {
        return SecurityTokenPointer();
    }

    QMutexLocker locker(&s_mutex);
    if (s_pSandboxPermissions == NULL) {
        return SecurityTokenPointer();
    }

    while (true) {
        // Look for a valid token in the cache.
        QHash<QString, SecurityTokenWeakPointer>::iterator it = s_activeTokens
                .find(walkDirCanonicalPath);
        if (it != s_activeTokens.end()) {
            SecurityTokenPointer pToken(it.value());
            if (pToken) {
                if (sDebug) {
                    qDebug() << "openSecurityToken QDir" << walkDirCanonicalPath
                             << "using cached token for" << pToken->m_path;
                }
                return pToken;
            }
        }

        // Next, check if the key exists in the config.
        ConfigKey key = keyForCanonicalPath(walkDirCanonicalPath);
        if (s_pSandboxPermissions->exists(key)) {
            SecurityTokenPointer pToken = openTokenFromBookmark(
                    dir.canonicalPath(),
                    s_pSandboxPermissions->getValueString(key));
            if (pToken) {
                return pToken;
            }
        }

        // Go one step higher and repeat.
        if (!walkDir.cdUp()) {
            // There's nothing higher. Bail.
            break;
        }
        walkDirCanonicalPath = walkDir.canonicalPath();
    }

    // Last chance: Try to create a token for this directory.
    if (create && createSecurityToken(dir.canonicalPath(), true)) {
        ConfigKey key = keyForCanonicalPath(dir.canonicalPath());
        return openTokenFromBookmark(
                dir.canonicalPath(),
                s_pSandboxPermissions->getValueString(key));
    }
    return SecurityTokenPointer();
}
コード例 #20
0
std::string QtZLFSManager::parentPath(const std::string &path) const
{
    QDir dir = QString::fromStdString(path);
    if (dir.absolutePath().toStdString() == path)
        return path;
    dir.cdUp();
    return dir.absolutePath().toStdString();
}
コード例 #21
0
Kit* MerTarget::createKit() const
{
    if (!isValid())
        return 0;
    const QString sysroot(m_sdk->sharedTargetsPath() + QLatin1Char('/') + m_name);

    FileName path = FileName::fromString(sysroot);
    if (!path.toFileInfo().exists()) {
        qWarning() << "Sysroot does not exist" << sysroot;
        return 0;
    }

    Kit *k = new Kit();
    k->setAutoDetected(true);
    k->setUnexpandedDisplayName(QString::fromLatin1("%1-%2").arg(m_sdk->virtualMachineName(), m_name));
    k->setIconPath(FileName::fromString(QLatin1String(Constants::MER_OPTIONS_CATEGORY_ICON)));
    SysRootKitInformation::setSysRoot(k, FileName::fromUserInput(sysroot));

    DeviceTypeKitInformation::setDeviceTypeId(k, Constants::MER_DEVICE_TYPE);
    k->setMutable(DeviceKitInformation::id(), true);

    const QString gdb = HostOsInfo::withExecutableSuffix(m_defaultGdb);
    QString gdbDir = QCoreApplication::applicationDirPath();
    if (HostOsInfo::isMacHost()) {
        QDir dir = QDir(gdbDir);
        dir.cdUp();
        dir.cdUp();
        dir.cdUp();
        gdbDir = dir.path();
    }
    FileName gdbFileName = FileName::fromString(gdbDir + QLatin1Char('/') + gdb);

    DebuggerItem debugger;
    debugger.setCommand(gdbFileName);
    debugger.setEngineType(GdbEngineType);
    const QString vmName = m_sdk->virtualMachineName();
    debugger.setUnexpandedDisplayName(QObject::tr("GDB for %1 %2").arg(vmName, m_name));
    debugger.setAutoDetected(true);
    debugger.setAbi(Abi::abiFromTargetTriplet(m_gccMachineDump)); // TODO is this OK?
    QVariant id = DebuggerItemManager::registerDebugger(debugger);
    DebuggerKitInformation::setDebugger(k, id);

    MerSdkKitInformation::setSdk(k,m_sdk);
    MerTargetKitInformation::setTargetName(k,name());
    return k;
}
コード例 #22
0
ファイル: BrowserView.cpp プロジェクト: SciBoy/douml
void BrowserView::set_project(QDir di) {
  dir = di;
  new BrowserNode(this, dir.dirName() + ".prj");
  setRootIsDecorated(TRUE/*FALSE*/);
  
  di.cdUp();
  setColumnText(0, di.path());
}
コード例 #23
0
void StudentDashBoard::viewVideos()
{
    QDir dir = QDir(qApp->applicationDirPath());
    qDebug()<<dir.cdUp()<<dir.path()<<qApp->applicationDirPath();
    QString basePath= dir.path()+"/videos";
    videoViewWin->setBasePath(basePath);
    videoViewWin->showFullScreen();
}
コード例 #24
0
ファイル: QxFileBrowser.cpp プロジェクト: corelon/paco
void QxFileBrowser::updateGotoMenu()
{
	for (int i = 0, n = cwdPast_.count(); i < n;  ++i) {
		if (!QDir(cwdPast_.at(i)).exists()) {
			cwdPast_.removeAt(i);
			--i;
			--n;
		}
	}
	
	if (gotoMenu_) {
		disconnect(gotoMenu_, 0, 0, 0);
		gotoMenu_->setAttribute(Qt::WA_DeleteOnClose, true); // destruction workaround, HACK
		gotoMenu_->close();
	}
	
	gotoMenu_ = new QMenu(this);
	{
		QFont font = gotoMenu_->font();
		font.setPixelSize(styleManager()->constant("dirOpenMenuFontSizePx"));
		gotoMenu_->setFont(font);
	}
	connect(gotoMenu_, SIGNAL(triggered(QAction*)), this, SLOT(cwdSet(QAction*)));
	actionToPath_.clear();
	
	QFileIconProvider iconProvider;
	QDir dir = QDir::current();
	while (!dir.isRoot()) {
		dir.cdUp();
		QAction* action = gotoMenu_->addAction(iconProvider.icon(QFileInfo(dir.path())), dir.isRoot() ? QDir::separator() : dir.dirName());
		actionToPath_[action] = dir.path();
	}
	
	gotoMenu_->addSeparator();
	
	recentMenu_ = gotoMenu_->addMenu(tr("Recent Places"));
	{
		QFont font = recentMenu_->font();
		font.setPixelSize(styleManager()->constant("dirOpenMenuFontSizePx"));
		recentMenu_->setFont(font);
	}
	// QxDesignHack::beautify(recentMenu_);
	connect(recentMenu_, SIGNAL(triggered(QAction*)), this, SLOT(cwdSet(QAction*)));
	
	int n = cwdPast_.count();
	recentMenu_->setDisabled(n == 0);
	
	for (int i = n-1; i >= 0; --i)
	{
		QString path = cwdPast_[i];
		QString name = path; // QFileInfo(path).fileName();
		if (name == QString()) name = QDir::separator();
		QAction* action = recentMenu_->addAction(iconProvider.icon(QFileInfo(path)), name);
		actionToPath_[action] = path;
	}
	
	gotoButton_->setMenu(gotoMenu_);
}
コード例 #25
0
ファイル: mainwindow.cpp プロジェクト: bundyo/phonegap
MainWindow::MainWindow(QGraphicsScene *parent) :
    QGraphicsView(parent) {

    QGraphicsScene *mainScene = new QGraphicsScene;
    setScene(mainScene);
    setFrameShape(QFrame::NoFrame);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
    setCacheMode( QGraphicsView::CacheBackground );
    setAttribute(Qt::WA_TranslucentBackground, false);
    setBackgroundBrush(QBrush(Qt::black, Qt::SolidPattern));

    QDir templateDir = QApplication::applicationDirPath();
    templateDir.cdUp();
    templateDir.cd("app");

    qDebug() << "Loading file: " << templateDir.filePath("index.html");

    QGraphicsScene *scene = new QGraphicsScene;
    QDeclarativeEngine *engine = new QDeclarativeEngine;
    QDeclarativeComponent component(engine, QUrl::fromLocalFile(QApplication::applicationDirPath() + QLatin1String("/../qml/browser.qml")));
    qDebug() << component.errors();

    notifier = new Notifier();
    QObject *comp = component.create();
    QMLDialog = comp->findChild<QDeclarativeItem*>("dialog");
    QMLGallery = comp->findChild<QDeclarativeItem*>("gallery");
    QMLWebView = comp->findChild<QDeclarativeItem*>("webView");
    engine->rootContext()->setContextProperty("notifier", notifier);

    ((QDeclarativeWebView*) QMLWebView)->setPage(new WebPage());
    QMLWebView->setProperty("pageUrl", "../app/index.html");
    ((QDeclarativeWebView*) QMLWebView)->page()->settings()->setAttribute(QWebSettings::LocalStorageEnabled, true);
    ((QDeclarativeWebView*) QMLWebView)->page()->settings()->setAttribute(QWebSettings::LocalStorageDatabaseEnabled, true);
    ((QDeclarativeWebView*) QMLWebView)->page()->settings()->setAttribute(QWebSettings::AcceleratedCompositingEnabled, true);
    ((QDeclarativeWebView*) QMLWebView)->page()->settings()->setAttribute(QWebSettings::TiledBackingStoreEnabled, true);
    ((QDeclarativeWebView*) QMLWebView)->settings()->enablePersistentStorage();
    QMLWebView->setCacheMode(QGraphicsItem::DeviceCoordinateCache);

    new Extensions(((QDeclarativeWebView*) QMLWebView));

    scene->addItem(qobject_cast<QGraphicsItem*>(comp));
    scene->setSceneRect(0,0,width(),height());
    scene->setItemIndexMethod(QGraphicsScene::NoIndex);

    QMLView = new QGraphicsView( this );
    QMLView->setScene( scene );
    QMLView->setGeometry(0,0,width(),height());
    QMLView->setStyleSheet( "background: transparent; border: none;" );
    QMLView->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
    QMLView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
    QMLView->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
    QMLView->setCacheMode( QGraphicsView::CacheBackground );
    QMLView->setFrameShape(QFrame::NoFrame);

    ((QDeclarativeWebView*) QMLWebView)->page()->mainFrame()->evaluateJavaScript("window._nativeReady = true"); // Tell PhoneGap that init is complete.
}
コード例 #26
0
ファイル: main.cpp プロジェクト: djayard/Winter2015
int main(int argc, char *argv[])
{
    QApplication A(argc, argv);
#ifdef Q_OS_MAC
    QDir::setCurrent(QCoreApplication::applicationDirPath());
    QDir Dir = QDir::current();
    Dir.cdUp();
    Dir.cdUp();
    Dir.cdUp();
    QDir::setCurrent(Dir.absolutePath());
#endif


    CFortEdit W;
    W.show();

    return A.exec();
}
コード例 #27
0
/**
 * @brief MainWindow::on_genButton_released - Should generate selenium
 *          code based off the stack of items.
 */
void MainWindow::on_genButton_released(){

    ui->webView->releaseKeyboard();
    testGenForm->show();

    QDir dir;
    while(!dir.cd("scripts")){ dir.cdUp(); }
    api->outPutUserActions()->create(dir.path().toStdString(), "seleniumFunc.py");
}
コード例 #28
0
/************************************************************
* ReadFile
* ----------------------------------------------------------
* Returns true only if it successfully reads
* Returns false if it fails to open, read or if there are no
*	customers in the database
* ----------------------------------------------------------
* File path is set when first establishing the database
*************************************************************/
bool CustomerList::ReadFile()
{
	bool readSuccessFull;
	QDir dataPath = QDir::current();
    QString inputData[9];

	readSuccessFull = false;

	while(dataPath.dirName() != "Class-Project")
	{
		dataPath.cdUp();
	}

	qDebug () << "Current dir path " << dataPath.dirName();

	dataPath.cd("Database-Files");

	QFile customerDataFile((dataPath.path() + "/CustomerList.txt"));

	// This checks if the file opens, if it does not, it will display an
	//  error message
	if(customerDataFile.open(QIODevice::ReadOnly | QIODevice::Text))
	{

		// Points Text stream to input file to read in.
		QTextStream inFile(&customerDataFile);
		while(!inFile.atEnd() && !this->isFull())
		{
											  // Data Type			| TXT FILE
			inputData[0] = inFile.readLine();       // Customer Name	| Line 1
			inputData[1] = inFile.readLine();        // Address Part 1		| Line 2
			inputData[2] = inFile.readLine();       // Address Part 2		| Line 3
			inputData[1] = inputData[1]                 // Concatenate          | N/A
						 + "\n"+ inputData[2];               // addresses
			inputData[3] = inFile.readLine();       // Customer Interest| Line 4
			inputData[4] = inFile.readLine();       // Customer Key		| Line 5
			inputData[5] = inFile.readLine();       // Passoword              | Line 6
			inputData[6] = inFile.readLine();       // Email                       | Line 7
			inputData[7] = inFile.readLine();       // Account ID            | Line 8
            inputData[8] = inFile.readLine();       // Access String         | Line 9

			// Adds the customer to customer list
			this->Enqueue(Customer(inputData[0], inputData[1], inputData[3],
								   inputData[4], inputData[5], inputData[6],
								   inputData[7].toLong(),         inputData[8]));
					inFile.skipWhiteSpace();
					inFile.flush();
		}
		// sets read true, flushes the Qtextstream buffer
		readSuccessFull = true;

		customerDataFile.flush();
		customerDataFile.close();
	}
	return readSuccessFull;

}// **** END METHOD **** //
コード例 #29
0
ファイル: test_plugins.cpp プロジェクト: HawkLane/UniSim
 QDir xmlModelsTestFolder() {
     QDir dir = FileLocations::location(FileLocationInfo::Plugins);
     dir.cdUp();
     dir.cdUp();
     dir.cd("xml");
     dir.cd("models");
     dir.cd("test");
     return dir;
 }
コード例 #30
0
ファイル: window_main.cpp プロジェクト: poixen/Cockatrice
void MainWindow::actCheckCardUpdates()
{
    if(cardUpdateProcess)
    {
        QMessageBox::information(this, tr("Information"), tr("A card database update is already running."));
        return;
    }

    cardUpdateProcess = new QProcess(this);
    connect(cardUpdateProcess, SIGNAL(error(QProcess::ProcessError)), this, SLOT(cardUpdateError(QProcess::ProcessError)));
    connect(cardUpdateProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(cardUpdateFinished(int, QProcess::ExitStatus)));

    // full "run the update" command; leave empty if not present
    QString updaterCmd;
    QString binaryName;
    QDir dir = QDir(QApplication::applicationDirPath());

#if defined(Q_OS_MAC)
    binaryName = getCardUpdaterBinaryName();

    // exit from the application bundle
    dir.cdUp();
    dir.cdUp();
    dir.cdUp();
    dir.cd(binaryName + ".app");
    dir.cd("Contents");
    dir.cd("MacOS");
#elif defined(Q_OS_WIN)
    binaryName = getCardUpdaterBinaryName() + ".exe";
#else
    binaryName = getCardUpdaterBinaryName();
#endif

    if(dir.exists(binaryName))
        updaterCmd = dir.absoluteFilePath(binaryName);

    if(updaterCmd.isEmpty())
    {
        QMessageBox::warning(this, tr("Error"), tr("Unable to run the card database updater: ") + dir.absoluteFilePath(binaryName));
        return;
    }

    cardUpdateProcess->start("\"" + updaterCmd + "\"");
}