Beispiel #1
0
bool MainWindow::loadFile(const QString &fileName)
{
    QImageReader reader(fileName);
    reader.setAutoTransform(true);

    QImage image2 = reader.read();
    if (image2.isNull()) {
        QMessageBox::information(this, QGuiApplication::applicationDisplayName(),
                                 tr("Cannot load %1.").arg(QDir::toNativeSeparators(fileName)));
        setWindowFilePath(QString());
        imageLabel->setPixmap(QPixmap());
        imageLabel->adjustSize();
        return false;
    }

    const QImage image = image2;
    imageLabel->setPrincipal(&image2);
    //imageLabel->adjustSize();
    pdis->resizePictureArea();
    updateActionsWithImage();

    //if (!fitToWindowAct->isChecked())

        //imageLabel->adjustSize();
        //QWidget *uu=ui->centralwidget();
        //uu->resize(image2.width(),image2.height());
        //pdis->adjustSize();

    setWindowFilePath(fileName);
    return true;
}
Beispiel #2
0
    void MainWindow::setCurrentFile(const QString& filename)
    {
        setWindowModified(false);
        if(filename.isEmpty())
        {
            setWindowFilePath("untitled.chr");
        }
        else
        {
            setWindowFilePath(filename);

            QSettings settings;
            QStringList recentFiles(settings.value("recentFiles").toStringList());
            recentFiles.removeAll(filename);
            recentFiles.prepend(filename);
            while(recentFiles.size() > MaxRecentCount)
            {
                recentFiles.removeLast();
            }

            settings.setValue("recentFiles", recentFiles);
            updateRecentFiles();
        }
        currentFile = filename;
    }
Beispiel #3
0
bool ImageViewer::loadFile(const QString &fileName)
{
    QImageReader reader(fileName);
    //reader.setAutoTransform(true);
    const QImage image = reader.read();
    if (image.isNull()) {
        QMessageBox::information(this, QGuiApplication::applicationDisplayName(),
                                 tr("Cannot load %1.").arg(QDir::toNativeSeparators(fileName)));
        setWindowFilePath(QString());
        imageLabel->setPixmap(QPixmap());
        imageLabel->adjustSize();
        return false;
    }
    imageLabel->setPixmap(QPixmap::fromImage(image));
    scaleFactor = 1.0;

    printAct->setEnabled(true);
    fitToWindowAct->setEnabled(true);
    updateActions();

    if (!fitToWindowAct->isChecked())
        imageLabel->adjustSize();

    setWindowFilePath(fileName);
    return true;
}
Beispiel #4
0
void MainWindow::canvasFileInfoChanged(const QFileInfo& fileinfo)
{
    if (fileinfo.fileName().isEmpty())
    {
        setWindowFilePath(QString());
        setWindowTitle("untitled[*] - Dunnart");
    }
    else
    {
        setWindowFilePath(fileinfo.absoluteFilePath());
        setWindowTitle(fileinfo.fileName() + "[*] - Dunnart");
    }
}
Beispiel #5
0
bool Forecast::loadFile(const QString &fileName, QLabel *lb)
{
    QImage image(fileName);
    if (image.isNull()) {
        //QMessageBox::information(this, QGuiApplication::applicationDisplayName(),
        // tr("Cannot load %1.").arg(QDir::toNativeSeparators(fileName)));
        qDebug()<<"Cannot load~~~";
        setWindowFilePath(QString());
        lb->setPixmap(QPixmap());
        lb->adjustSize();
        return false;
    }
//! [2] //! [3]
    QPixmap myPic = QPixmap::fromImage(image);
    QPixmap scaledPic(myPic.scaled(lb->width(),lb->height()));
    lb->setPixmap(scaledPic);
//! [3] //! [4]
//    scaleFactor = 1.0;

//    printAct->setEnabled(true);
//    fitToWindowAct->setEnabled(true);
//    updateActions();

//    if (!fitToWindowAct->isChecked())
    //ui->label_hw->adjustSize();

    // scrollArea->setWidgetResizable(true);
//    setWindowFilePath(fileName);
    return true;
}
void RecipeWidget::save(QString filepath)
{

    if(!filepath.isEmpty()) {
        setWindowFilePath(filepath);
    } else if(!isWindowModified()) {
        return;     // Don't do anything if the file would be the same
    }


    QDomDocument document("Recipe");
    document.appendChild(recipe()->toXml(document));

    if(windowFilePath().isEmpty()) {
        throw tr("File path is not valid");
    }
    QFile file(windowFilePath());

    if(!file.open(QIODevice::WriteOnly)) {
        throw tr("Failed to open ingredients file");
    }

    file.write(document.toString().toLatin1());
    file.flush();
    file.close();

    setWindowModified(false);
    refreshText();
    emit changed();
}
void MainWindowImpl::openFile(const QString &fileName)
{
    if (fileName.isEmpty())
        return;

    m_model->clear();
    QStringList list;
    list << tr("Shared Object") << tr("Resolved Path");
    m_model->setHorizontalHeaderLabels(list);

    QFileInfo fi(fileName);

    QList<QStandardItem *> items;
    items << new QStandardItem(fi.fileName());
    items << new QStandardItem(fileName);

    m_model->invisibleRootItem()->appendRow(items);
    d->libs.loadFile(fileName);
    d->stats = d->libs.getStatistics();
    addFile(fileName, m_model->item(0));
    d->libs.clear();

    m_ui->libView->expand(m_model->indexFromItem(items[0]));
    m_ui->libView->resizeColumnToContents(0);

    m_ui->statusbar->showMessage(statusBarStats());

    setWindowFilePath(fileName);
}
Beispiel #8
0
void MainWindow::on_action_Open_triggered()
{
    if (maybeSave()) {
        setWindowFilePath(QFileDialog::getOpenFileName(this, tr("Open File"), QDir::currentPath()));
        if (!windowFilePath().isEmpty())
            canvas->openImage(windowFilePath());
    }
}
Beispiel #9
0
void MainWindow::fileSaveAs(){
    QString fileName = QFileDialog::getSaveFileName(this,tr("Save File As"));
    if(NULL != fileName ){
        delete currentFile;
        currentFile = new QFile(fileName);
        setWindowFilePath(fileName);
        fileSave();
    }
}
Beispiel #10
0
bool MainWindow::loadFile(const QString &fileName)
{
    QImageReader reader(fileName);
    reader.setAutoTransform(true);
    const QImage image = reader.read();
    if (image.isNull()) {
        QMessageBox::information(this, QGuiApplication::applicationDisplayName(),
                                 tr("Cannot load %1.").arg(QDir::toNativeSeparators(fileName)));
        setWindowFilePath(QString());
        imageLabel->setPixmap(QPixmap());
        imageLabel->adjustSize();
        return false;
    }

    setWindowFilePath(fileName);
    loadImage(image);
    return true;
}
Beispiel #11
0
void MainWindow::openFile(QString const& fileName) 
{
   if (m_viewerModel.open(fileName)) {
      setWindowFilePath(fileName);
      Preferences::AddRecentFile(fileName);
      Preferences::LastFileAccessed(fileName);
      updateRecentFilesMenu();
   }
}
Beispiel #12
0
bool QImageWidget::loadFile(const QString &fileName)
{
    QImage image = QImage(fileName);
    if (image.isNull()) 
	{
        QMessageBox::information(this, QGuiApplication::applicationDisplayName(),
                                 tr("Cannot load %1.").arg(QDir::toNativeSeparators(fileName)));
        setWindowFilePath(QString());
        setPixmap(QPixmap());
        adjustSize();
        return false;
    }

	setImage(image);

    setWindowFilePath(fileName);
    return true;
}
Beispiel #13
0
void MainWindow::setCurrentFile(const QString &fileName) {
  curFile = fileName;

  QString shownName = curFile;
  if (curFile.isEmpty()) {
    shownName = "untitled.txt";
  }
  setWindowFilePath(shownName);
}
Beispiel #14
0
void MainWindow::fileNew(){
    if(NULL != currentFile){
        fileSave();
    }
    delete currentFile;
    ui->plainTextEdit->clear();
    ui->plainTextEdit->document()->setModified( true );
    ui->plainTextEdit->document()->setModified( false );
    setWindowFilePath( tr( "[New File]" ) );
}
void StackedChatWidget::onCurrentChanged(int index)
{
	if (index != m_stack->indexOf(m_chatWidget)) {
		if (m_currentSession)
			m_currentSession->setActive(false);
	}
	setWindowFilePath(m_stack->currentWidget()->windowTitle());
	//FIXME Symbian workaround
	onAboutToChangeIndex(index);
}
void InfoManage::setCurrentFile(const QString &fileName)
{
    curFile = fileName;
    //textEdit->document()->setModified(false);
    //setWindowModified(false);
    QString shownName = curFile;
    if (curFile.isEmpty())
        shownName = "untitled.txt";
    setWindowFilePath(shownName);
}
Beispiel #17
0
void MainWindow::newForm()
{
	if (saveChanges())
	{
		form->reset();
		setWindowFilePath(tr("Untitled"));
		setWindowModified(false);
		updateUi();
	}
}
Beispiel #18
0
void
Gui::onProjectNameChanged(const QString & filePath,
                          bool modified)
{
    // handles window title and appearance formatting
    // http://doc.qt.io/qt-4.8/qwidget.html#windowModified-prop
    setWindowModified(modified);
    // http://doc.qt.io/qt-4.8/qwidget.html#windowFilePath-prop
    setWindowFilePath(filePath.isEmpty() ? QString::fromUtf8(NATRON_PROJECT_UNTITLED) : filePath);
}
void JsonEditorMain::setCurrentFile(const QString &fileName)
{
    curFile = fileName;
    ui->jsonCode->document()->setModified(false);
    setWindowModified(false);

    QString shownName = curFile;
    if (curFile.isEmpty())
        shownName = "untitled.json";
    setWindowFilePath(shownName);
}
Beispiel #20
0
void MainWindow::openRecentFile()
{
	QAction* action = qobject_cast<QAction*>(sender());
	if (action && saveChanges())
	{
		const QString fileName = QDir::fromNativeSeparators(action->data().toString());
		setWindowFilePath(fileName);
		loadFile(fileName);
		updateRecentFile(fileName);
	}
}
Beispiel #21
0
void EditorFrame::setCurrentFile(const QString &fileName)
{
  mCurrentFile = fileName;
  setWindowModified(false);

  QString shownName = mCurrentFile;
  if (mCurrentFile.isEmpty()){
    shownName = "untitled";
  }
  setWindowFilePath(shownName);
}
Beispiel #22
0
void MainWindow::setCurrentFile(const QString &fileName)
{
    curFile = fileName;
    textEdit->document()->setModified(false);
    setWindowModified(false);

    QString shownNaem = curFile;
    if (curFile.isEmpty())
        shownNaem = "untitled.txt";
    setWindowFilePath(shownNaem);
}
void
MLABOsiriXBridgeControl::fieldChanged()
{
#if defined(MACOS)

  if (_windowFilePathField) {
    setWindowFilePath(_windowFilePathField->stringValue());
  }

#endif
}
void XmlWindow::setCurrentFile(const QString &fileName){
    curFile = fileName;
    buildAct->setIcon(QIcon(":/new/prefix1/icons/left-gray.png"));
    textEdit->document()->setModified(false);
    setWindowModified(false);

    QString shownName = curFile;
    if (curFile.isEmpty())
        shownName = "untitled.txt";
    setWindowFilePath(shownName);
}
Beispiel #25
0
bool MainWindow::loadFile(const QString &fileName)
{
    QImage image(fileName);
    if (image.isNull()) {
        QMessageBox::information(this, QGuiApplication::applicationDisplayName(),
                                 tr("Не вдалось завантажити %1.").arg(QDir::toNativeSeparators(fileName)));
        setWindowFilePath(QString());
        ui->imageLabel->setPixmap(QPixmap());
        ui->imageLabel->adjustSize();
        return false;
    }

    QPixmap pixmap(fileName);

    ui->imageLabel->setPixmap(pixmap);
    ui->imageLabel->setMask(pixmap.mask());

    setWindowFilePath(fileName);
    return true;

}
Beispiel #26
0
MainWindow::MainWindow()
{
    setAttribute(Qt::WA_DeleteOnClose);

    textEdit = new QTextEdit;
    setCentralWidget(textEdit);

    createActions();
    createMenus();
    (void)statusBar();

    setWindowFilePath(QString());
    resize(400, 300);
}
Beispiel #27
0
void RecentFiles::setCurrentName( const QString &name )
{
    _changed = true;

    setWindowFilePath( name );

    _names.removeAll( name );
    _names.prepend(   name );
    while( _names.size() > (int)_maxRecentItems )
        _names.removeLast();

    _updateRecentActions();
    _updateWindowTitle();
}
//-------------------------------------------------------------------------
bool MainWindow::loadSourceFile(const QString& fileSource, QPlainTextEdit *sourceCode)
{
  QFile data(fileSource);
  if (data.open(QFile::ReadOnly|QFile::Text))
  {
    QTextStream in(&data);
    QString content = in.readAll();
    sourceCode->setPlainText(content);
    sourceCode->setExtraSelections(QList<QTextEdit::ExtraSelection>());
    data.close();
    setWindowFilePath(fileSource);
    return true;
  }
  return false;
}
Beispiel #29
0
bool MainWindow::saveAs()
{
    QString filter = "All Files (*)";
    for (auto format : QImageWriter::supportedImageFormats()) {
        filter += ";;" + QString(format).toUpper() + " Files (*." + QString(format) + ")";
    }

    setWindowFilePath(QFileDialog::getSaveFileName(this, tr("Save As"), windowFilePath(), filter));
    if (windowFilePath().isEmpty()) {
        return false;
    }
    else {
        return canvas->saveImage(windowFilePath());
    }
}
Beispiel #30
0
void MainWindow::updateTitle()
{
    setWindowFilePath(_actualFile);

    QString title;
    if (_actualFile.isEmpty()) {
        title = tr("New file");
    } else {
        title = QFileInfo(_actualFile).fileName();
    }
    title.append("[*]");
    setWindowTitle(title);

    setWindowModified(_model.isChanged());
}