Beispiel #1
0
void MainHost::SaveProjectFile(bool saveAs)
{
    QString filename;

    if(currentProjectFile.isEmpty() || saveAs) {
        QString lastDir = GetSetting("lastProjectDir").toString();
        filename = QFileDialog::getSaveFileName(mainWindow, tr("Save Project"), lastDir, tr("Project Files (*.%1)").arg(PROJECT_FILE_EXTENSION));

        if(filename.isEmpty())
            return;

        if(!filename.endsWith(PROJECT_FILE_EXTENSION, Qt::CaseInsensitive)) {
            filename += ".";
            filename += PROJECT_FILE_EXTENSION;
        }
    } else {
        filename = currentProjectFile;
    }

    if(ProjectFile::SaveToProjectFile(this,filename)) {
        SetSetting("lastProjectDir",QFileInfo(filename).absolutePath());
        ConfigDialog::AddRecentProjectFile(filename,this);
        currentProjectFile = filename;
        emit currentFileChanged();
    }
}
void FolderNavigationWidget::setAutoSynchronization(bool sync)
{
    if (sync == m_autoSync)
        return;

    m_autoSync = sync;

    if (m_autoSync) {
        connect(Core::DocumentManager::instance(), SIGNAL(currentFileChanged(QString)),
                this, SLOT(setCurrentFile(QString)));
        setCurrentFile(Core::DocumentManager::currentFile());
    } else {
        disconnect(Core::DocumentManager::instance(), SIGNAL(currentFileChanged(QString)),
                this, SLOT(setCurrentFile(QString)));
    }
}
Beispiel #3
0
	void GraffitiTab::handleTagsFetched (const QString& filename)
	{
		const auto& curIdx = Ui_.FilesList_->selectionModel ()->currentIndex ();
		const auto& curInfo = curIdx.data (FilesModel::Roles::MediaInfoRole).value<MediaInfo> ();
		if (curInfo.LocalPath_ == filename)
			currentFileChanged (curIdx);
	}
Beispiel #4
0
void MainHost::LoadProjectFile(const QString &filename)
{
    if(!programsModel->userWantsToUnloadProject())
        return;

    QString name = filename;

    if(name.isEmpty()) {
        QString lastDir = GetSetting("lastProjectDir").toString();
        name = QFileDialog::getOpenFileName(mainWindow, tr("Open a Project file"), lastDir, tr("Project Files (*.%1)").arg(PROJECT_FILE_EXTENSION));
    }

    if(name.isEmpty())
        return;

    undoStack.clear();

    if(ProjectFile::LoadFromFile(this,name)) {
        ConfigDialog::AddRecentProjectFile(name,this);
        currentProjectFile = name;
    } else {
        ConfigDialog::RemoveRecentProjectFile(name,this);
        ClearProject();
    }
    emit currentFileChanged();
}
Beispiel #5
0
	void GraffitiTab::SetupViews ()
	{
		FSModel_->setRootPath (QDir::rootPath ());
		FSModel_->setFilter (QDir::Dirs | QDir::NoDotAndDotDot);
		FSModel_->setReadOnly (true);
		Ui_.DirectoryTree_->setModel (FSModel_);
		Ui_.DirectoryTree_->sortByColumn (0, Qt::AscendingOrder);

		auto idx = FSModel_->index (QDir::homePath ());
		while (idx.isValid ())
		{
			Ui_.DirectoryTree_->expand (idx);
			idx = idx.parent ();
		}

		Ui_.FilesList_->setModel (FilesModel_);

		connect (Ui_.FilesList_->selectionModel (),
				SIGNAL (currentRowChanged (QModelIndex, QModelIndex)),
				this,
				SLOT (currentFileChanged (QModelIndex)));

		connect (Ui_.PathLine_,
				SIGNAL (activated (QString)),
				this,
				SLOT (handlePathLine ()));
	}
Monofin *MainWindow::createMonofin()
{
    Monofin *monofin = new Monofin;
    connect(monofin, SIGNAL(lineFinished(bool)), this, SLOT(finishedLine(bool)));
    connect(monofin, SIGNAL(currentFileChanged()), this, SLOT(updateRecentFileActions()));
    _mdiArea->addSubWindow(monofin, Qt::SubWindow);
    return monofin;
}
Beispiel #7
0
void FolderNavigationWidget::setAutoSynchronization(bool sync)
{
    if (sync == m_autoSync)
        return;

    m_autoSync = sync;

    Core::FileManager *fileManager = Core::ICore::instance()->fileManager();
    if (m_autoSync) {
        connect(fileManager, SIGNAL(currentFileChanged(QString)),
                this, SLOT(setCurrentFile(QString)));
        setCurrentFile(fileManager->currentFile());
    } else {
        disconnect(fileManager, SIGNAL(currentFileChanged(QString)),
                this, SLOT(setCurrentFile(QString)));
    }
}
Beispiel #8
0
void FileBackend::prev()
{
	if (files.size() > 1) {
		if (this->currentFile == this->files.begin()) {
			this->currentFile = this->files.end();
		}
		this->currentFile--;
		emit currentFileChanged();
	}
}
Beispiel #9
0
void FileBackend::next()
{
	if (files.size() > 1) {
		this->currentFile++;
		if (this->currentFile == this->files.end()) {
			this->currentFile = this->files.begin();
		}
		emit currentFileChanged();
	}
}
Beispiel #10
0
void FileBackend::setArguments(const QStringList& arguments)
{
	status = Status::Loading;
	emit statusChanged();
	this->files.clear();
	if (!arguments.empty()) {
		QFileInfo info(arguments.at(0));
		reader.setFileName(info.absoluteFilePath());
		if (info.exists() && info.isFile() && reader.canRead()) {
			this->initFromSingleFile(info);
		}
	}
	status = (this->getCurrentFile() != nullptr) ? Status::Ready : Status::Empty;
	emit statusChanged();
	emit currentFileChanged();
}
Beispiel #11
0
void MainHost::ClearSetup()
{
    if(!programsModel->userWantsToUnloadSetup())
        return;

    undoStack.clear();

    EnableSolverUpdate(false);
    SetupHostContainer();
    EnableSolverUpdate(true);
    if(mainWindow)
        mainWindow->viewConfig->LoadFromRegistry();

    ConfigDialog::AddRecentSetupFile("",this);
    currentSetupFile = "";
    emit currentFileChanged();
}
Beispiel #12
0
void HostModel::addHost(Host *host)
{
    Q_ASSERT(host);

    beginInsertRows(QModelIndex(), m_hosts.count(), m_hosts.count());
    m_hosts.append(host);
    connect(host, SIGNAL(nameChanged(QString)), this, SLOT(onHostChanged()));
    connect(host, SIGNAL(addressChanged(QString)), this, SLOT(onHostChanged()));
    connect(host, SIGNAL(portChanged(int)), this, SLOT(onHostChanged()));
    connect(host, SIGNAL(followTreeSelectionChanged(bool)), this, SLOT(onHostChanged()));
    connect(host, SIGNAL(currentFileChanged(QString)), this, SLOT(onHostChanged()));
    connect(host, SIGNAL(xOffsetChanged(int)), this, SLOT(onHostChanged()));
    connect(host, SIGNAL(yOffsetChanged(int)), this, SLOT(onHostChanged()));
    connect(host, SIGNAL(rotationChanged(int)), this, SLOT(onHostChanged()));
    connect(host, SIGNAL(onlineChanged(bool)), this, SLOT(onHostChanged()));

    endInsertRows();
}
Beispiel #13
0
void MainHost::ClearProject()
{
    if(!programsModel->userWantsToUnloadProject())
        return;

    undoStack.clear();

    EnableSolverUpdate(false);
    SetupProjectContainer();
    SetupProgramContainer();
    SetupGroupContainer();
    EnableSolverUpdate(true);

    programsModel->BuildDefaultModel();

    ConfigDialog::AddRecentProjectFile("",this);
    currentProjectFile = "";
    emit currentFileChanged();
}
Beispiel #14
0
/*!

*/
void Monofin::setCurrentFile(const QString &fileName)
{
    qDebug() << QString("entering Monofin::setCurrentFile(%1)...").arg(fileName);
    _curFile = fileName;
    setWindowModified(false);

    QString shownName = tr("(Untitled %1)").arg(documentNumber);
    _isUntitled = true;

    if (!_curFile.isEmpty()) {
        shownName = strippedName(_curFile);
        qDebug() << QString("setting current file name %1").arg(shownName);
        _isUntitled = false;
        emit currentFileChanged();
    }

    setWindowTitle(tr("%1[*]").arg(shownName));
    qDebug("leaving Monofin::setCurrentFile...");
}
Beispiel #15
0
	void GraffitiTab::revert ()
	{
		const auto& modified = FilesModel_->GetModified ();
		if (modified.isEmpty ())
			return;

		if (QMessageBox::question (this,
				"LMP Graffiti",
				tr ("Do you really want to revert changes to %n file(s)?", 0, modified.size ()),
				QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes)
			return;

		QList<MediaInfo> origs;
		for (const auto& pair : modified)
			origs << pair.second;
		FilesModel_->SetInfos (origs);

		Save_->setEnabled (false);
		Revert_->setEnabled (false);

		currentFileChanged (Ui_.FilesList_->currentIndex ());
	}
//==============================================================================
// Load File
//==============================================================================
bool ViewerWindow::loadFile(const QString& aFileName, const QString& aPanelName)
{
    // Init Mime Database
    QMimeDatabase mimeDatabase;

    // Get Mime Tpye
    mime = mimeDatabase.mimeTypeForFile(aFileName).name();

    // Reset File Is New
    fileIsNew = false;

    qDebug() << "ViewerWindow::loadFile - aFileName: " << aFileName << " - mime: " << mime;

    // Set File Name
    fileName = aFileName;
    // Emit Content Source Changed
    emit contentSourceChanged(fileName);

    // Set Context Properties
    QQmlContext* ctx = ui->quickWidget->rootContext();
    // Set Context Properties - Viewer Content
    ctx->setContextProperty(DEFAULT_IMAGE_VIEWER_CONTENT, fileName);

    // Edit Mode & Check Mime Type - Load All Files As Text in Edit Mode
    if (isSupportedTextMime(editMode, mime)) {
        // Quick Widget Set Visible
        ui->quickWidget->setVisible(false);
        // Text Edit Set Visible
        ui->textEdit->setVisible(true);

        // Set Active Widget
        activeWidget = ui->textEdit;

        // Init File
        QFile file(aFileName);

        // Open File
        if (file.open(QIODevice::ReadOnly)) {
            // Init Text Stream
            QTextStream textStream(&file);

            // Check Mime Again
            if (mime.startsWith(QString(DEFAULT_MIME_PREFIX_APP) + QString(DEFAULT_MIME_XML)) ||
                mime.startsWith(QString(DEFAULT_MIME_PREFIX_APP) + QString(DEFAULT_MIME_SHELLSCRIPT))) {
                // Load From File
                ui->textEdit->setPlainText(textStream.readAll());
            } else {
                // Load From File
                ui->textEdit->setText(textStream.readAll());
            }

            // Reset Dirty Flag
            dirty = false;

            // Close File
            file.close();
            // Update Window Title
            updateWindowTitle();
        }

    } else if (!editMode && mime.startsWith(DEFAULT_MIME_PREFIX_IMAGE)) {

        // Text Edit Set Visible
        ui->textEdit->setVisible(false);
        // Quick Widget Set Visible
        ui->quickWidget->setVisible(true);

        // Set Active Widget
        activeWidget = ui->quickWidget;

        // Set Source
        ui->quickWidget->setSource(QUrl("qrc:/qml/ImageViewer.qml"));

        // Check Image Browser
        if (!imageBrowser) {
            // Create Image Browser
            imageBrowser = new ImageBrowser(fileName, aPanelName);

            // Connect Signals
            connect(imageBrowser, SIGNAL(currentIndexChanged(int)), this, SLOT(imageBrowserCurrentIndexChanged(int)));
            connect(imageBrowser, SIGNAL(currentFileChanged(QString)), this, SLOT(imageBrowserCurrentFileChanged(QString)));
            connect(imageBrowser, SIGNAL(currentFileChanged(QString)), this, SIGNAL(currentImageFileChanged(QString)));
            connect(imageBrowser, SIGNAL(selectCurrent()), this, SLOT(handleImageBrowserSelection()));

            // Set Context Properties
            QQmlContext* ctx = ui->quickWidget->rootContext();
            // Set Context Properties - Image Browser
            ctx->setContextProperty(DEFAULT_IMAGE_BROWSER, imageBrowser);
        }