예제 #1
0
파일: mainwindow.cpp 프로젝트: delor/turtle
void MainWindow::newFile()
{
    //if (okToContinue()) {
    renderArea->clearAll(); // wyczyść pixmapę
    historyList->clear();
    cmdLineEdit->clear();
    setCurrentFile("");
    //}
}
예제 #2
0
void MainGui::addHdrViewer(pfs::Frame* hdr_pfs_frame, QString fname) {
	HdrViewer *newhdr=new HdrViewer(this, qtpfsgui_options->negcolor, qtpfsgui_options->naninfcolor, false);
	newhdr->updateHDR(hdr_pfs_frame);
	newhdr->filename=fname;
	newhdr->setWindowTitle(fname);
	mdiArea->addSubWindow(newhdr);
	newhdr->show();
	setCurrentFile(fname);
}
예제 #3
0
void MdiChild::setView(MdiChild *mdiChild)
{
	_document = mdiChild->view();
	setDocument(_document);
	bool modified = document()->isModified();
	setCurrentFile(_document->fileName());
	document()->setModified(modified);
	isUntitled = mdiChild->isUntitled;
	setWindowModified(modified);
	setWindowTitle(userFriendlyCurrentFile() + "[*]");

	connect(_document, SIGNAL(contentsChanged()),
		this, SLOT(documentContentsChanged()));
	connect(document(), SIGNAL(modificationChanged(bool)),
		this, SLOT(documentWasModified()));
	connect(_document, SIGNAL(fileNameChanged(QString)),
		this, SLOT(setCurrentFile(QString)));
}
예제 #4
0
bool MainWindow::loadFile(const QString &fileName)
{
    if(spreadsheet->readFile(fileName))
    {
        setCurrentFile(fileName);
        return true;
    }
    return false;
}
예제 #5
0
bool MainWindow::saveFile(const QString &fileName)
{
    if(!spreadsheet->writeFile(fileName)) {
        statusBar()->showMessage(tr("Saving canceled"), 2000);
        return false;
    }
    setCurrentFile(fileName);
    statusBar()->showMessage(tr("File saved"), 2000);
    return true;
}
예제 #6
0
void FilenameComponent::filesDropped (const StringArray& filenames, int, int)
{
    isFileDragOver = false;
    repaint();

    const File f (filenames[0]);

    if (f.exists() && (f.isDirectory() == isDir))
        setCurrentFile (f, true);
}
예제 #7
0
void MainWindow::openDir(const QDir & dir)
{
    if(db->open(dir)) {
        setCurrentFile(dir.path());
        pisoar->setCurrentDir(db->dirBase());
        tabs->show();
    }
    else
        tabs->hide();
}
bool MyChild::saveFile(QString fileName)
{
    if (!(fileName.endsWith(".htm", Qt::CaseInsensitive) || fileName.endsWith(".html", Qt::CaseInsensitive))) {
        fileName += ".html"; // 默认保存为 HTML 文档
    }
    QTextDocumentWriter writer(fileName);
    bool success = writer.write(this->document());
    if (success)
        setCurrentFile(fileName);
    return success;
}
예제 #9
0
bool MainWindow::loadFile(const QString &fileName)
{
    if (!spreadsheet->readFile(fileName)) {
        statusBar()->showMessage(tr("Loading canceled"), 2000);
        return false;
    }

    setCurrentFile(fileName);
    statusBar()->showMessage(tr("File loaded"), 2000);
    return true;
}
예제 #10
0
void MainWindow::
loadProject(
  QString filename)
{
  setCurrentFile(filename);
  QApplication::setOverrideCursor(Qt::WaitCursor);
  QFile file(filename);
  if(!file.open(QFile::ReadOnly | QFile::Text))
  {
    QMessageBox::warning(NULL, "Load project", "Cannot open project file.");
    QApplication::restoreOverrideCursor();
    return;
  }
  config.setProjectDirFromFile(filename);

  QDomDocument doc;
  QString errorStr;
  int errorLine, errorColumn;
  if(!doc.setContent(&file, false, &errorStr, &errorLine, &errorColumn))
  {
    QMessageBox::warning(NULL, "Load project",
        QString("Parse error at line %1 column %2 :").arg(errorLine).
	        arg(errorColumn) + errorStr);
    QApplication::restoreOverrideCursor();
    return;
  }
  QDomElement root = doc.documentElement();
  if(root.tagName() == WarperController::xmlTag2D)
  {
    controler = new WarperController(this, &projectSettings);
    controler->set3D(false);
    bool success=controler->parseProject(root);
    projectSettings.m_fileName = filename;
    actionSaveProject->setEnabled(true);
    checkAndSwitch(success, ProjectProperties::warpingProject);
  }
  else if(root.tagName() == WarperController::xmlTag3D)
  {
    controler = new WarperController(this, &projectSettings);
    controler->set3D(true);
    bool success=controler->parseProject(root);
    projectSettings.m_fileName = filename;
    actionSaveProject->setEnabled(true);
    checkAndSwitch(success, ProjectProperties::warpingProject);
  }
  else
  {
    QMessageBox::warning(NULL, "Load project",
                         QString("Not a warping project"));
  }
  QApplication::restoreOverrideCursor();
  file.close();
  return;
}
예제 #11
0
bool Editor::openFile(const QString &fileName)
{
    bool ok = readFile(fileName);
    if (ok) {
        setCurrentFile(fileName);
        emit message(tr("File loaded"), 2000);
    } else {
        emit message(tr("Loading canceled"), 2000);
    }
    return ok;
}
예제 #12
0
파일: wmain.cpp 프로젝트: pewniak747/dicto
void WMain::saveFileAction(bool saveas) {
		if(cDocument->filename=="" || saveas) {
		cDocument->filename=QFileDialog::getSaveFileName(wMain,
											  tr("Choose file"), "./");
	}
	if(!cDocument->filename.endsWith(".dic") && !cDocument->filename.endsWith(".txt")) {
		cDocument->filename.append(".dic");
	}
	cDocument->saveToFile();
	setCurrentFile(cDocument->filename);
}
예제 #13
0
파일: wmain.cpp 프로젝트: pewniak747/dicto
void WMain::openFileAction(QString filename) {
	if(filename.isEmpty()) {
		filename=QFileDialog::getOpenFileName(wMain,
			tr("Choose file"),
			"./",
			tr("dicto files")+" (*.dic);;"+tr("text files")+" (*.txt);;"+tr("all files(*.*)"));
	}
	if(filename.isEmpty()) return;
	else cDocument->readFromFile(filename);
	
	setCurrentFile(filename);
}
예제 #14
0
파일: ImageDisplay.cpp 프로젝트: bpoje/dct
bool ImageDisplay::openFile(const QString &fileName)
{
	if (readFile(fileName))
	{
		setCurrentFile(fileName);
		return true;
	}
	else
	{
		return false;
	}
}
예제 #15
0
파일: ImageDisplay.cpp 프로젝트: bpoje/dct
bool ImageDisplay::writeFile(const QString &fileName)
{
	if (m_image.save(fileName, 0, -1))
	{
		setCurrentFile(fileName);
		return true;
	}
	else
	{
		return false;
	}
}
예제 #16
0
void PEditor::newFile() {
    tabWidget->addTab(new TextEditWidget(tabWidget), "");
    switchToTab(tabWidget->count() - 1);

    textEdit->getFont()->setPointSize(textSize);
    textEdit->getFont()->setFamily(textFont);
    textEdit->updateFont();
    textEdit->setLineNumbering(lineNumbering);

    connect(tabWidget->currentWidget(), SIGNAL(highlighting(bool)), this, SLOT(setSyntaxHighlightingMenuItem(bool)));
    setCurrentFile("");
}
예제 #17
0
bool MapWindow::saveFile(const QString & fileName)
{
    if(! mapData.saveMapXML(fileName))
    {
        QMessageBox::warning(this, tr("Map Editor"), tr("Cannot write file %1.").arg(fileName));
        return saveAs();
    }

    setCurrentFile(fileName);

    return true;
}
JsonEditorMain::JsonEditorMain(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::JsonEditorMain),
    newInsertText(tr("Insert new data")),
    treeViewColumnKey(tr("Node")),
    treeViewColumnValue(tr("Value")),
    treeViewColumnType(tr("Type"))
{
    ui->setupUi(this);
    connect(ui->menuCodeTools, SIGNAL(toggled(bool)), this, SLOT(toggleCodeToolbar(bool)));
    connect(ui->menuFindTools, SIGNAL(toggled(bool)), this, SLOT(toggleFindToolbar(bool)));
    connect(ui->menuFileTools, SIGNAL(toggled(bool)), this, SLOT(toggleFileToolbar(bool)));
    connect(ui->menuEditTools, SIGNAL(toggled(bool)), this, SLOT(toggleEditToolbar(bool)));
    connect(ui->menuRefresh, SIGNAL(triggered()), this, SLOT(refreshJsonTree()));
    connect(ui->menuInsertNode, SIGNAL(triggered()), this, SLOT(insertTreeNode()));
    connect(ui->menuInsertChild, SIGNAL(triggered()), this, SLOT(insertTreeChild()));
    connect(ui->menuDeleteNode, SIGNAL(triggered()), this, SLOT(deleteTreeNode()));
    connect(ui->jsonTree, SIGNAL(clicked(QModelIndex)), this, SLOT(updateActions()));
    connect(ui->menuFormat, SIGNAL(triggered()), this, SLOT(formatCode()));
    connect(ui->menuHelp, SIGNAL(triggered()), this, SLOT(showHelp()));
    connect(ui->jsonTree, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(dataEdit(QModelIndex)));


//    connect(ui->menuNewFile, SIGNAL(triggered()), this, SLOT(newFile()));
    connect(ui->menuOpenFile, SIGNAL(triggered()), this, SLOT(open()));
    connect(ui->menuSaveFile, SIGNAL(triggered()), this, SLOT(save()));
    connect(ui->menuSaveAs, SIGNAL(triggered()), this, SLOT(saveAs()));

    JSHighlighter * highlight = new JSHighlighter(ui->jsonCode->document());

    setCurrentFile("");

    textEdit = ui->jsonCode;
    connect(textEdit->document(), SIGNAL(contentsChanged()),
            this, SLOT(documentWasModified()));
    setUnifiedTitleAndToolBarOnMac(true);

    m_findDialog = new FindDialog(this);
    m_findDialog->setModal(false);
    m_findDialog->setTextEdit(textEdit);

    m_findReplaceDialog = new FindReplaceDialog(this);
    m_findReplaceDialog->setModal(false);
    m_findReplaceDialog->setTextEdit(textEdit);

    connect(ui->menuFind, SIGNAL(triggered()), m_findDialog, SLOT(show()));
    connect(ui->menuReplace, SIGNAL(triggered()), m_findReplaceDialog, SLOT(show()));

//    connect(ui->actionFindNext, SIGNAL(triggered()), m_findDialog, SLOT(findNext()));
//    connect(ui->actionFindPrevious, SIGNAL(triggered()), m_findDialog, SLOT(findPrev()));

    readSettings();
}
예제 #19
0
bool MainWindow::saveFile(const QString& fileName)
{
	if (!m_document->saveFile(fileName.toStdString()))
	{
		statusBar()->showMessage(tr("Saving failed"), 2000);
		return false;
	}

	setCurrentFile(fileName);
	statusBar()->showMessage(tr("File saved"), 2000);
	return true;
}
예제 #20
0
MainWindow::MainWindow()
    :documents()
{
    tabWidget = new QTabWidget(this);
    tabWidget -> setTabsClosable(true);
    tabWidget -> setUsesScrollButtons(true);
    tabWidget -> setDocumentMode(true);
    connect(tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int)));
    connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(currentTabChanged(int)));
    setCentralWidget(tabWidget);

	createActions();
	createMenus();
    createContextMenu(0);
	createToolBars();
	createStatusBar();
	readSettings();
    findDialog = 0;
    setWindowIcon(QIcon(":/images/pics/ss.png"));
	setCurrentFile("");

    //test
    setWindowModified(true);
    setCurrentFile(tr("data.sp"));
    setCurrentFile(tr("money.sp"));
    setCurrentFile(tr("students.sp"));
    setCurrentFile(tr("teachers.sp"));
    setCurrentFile(tr("total.sp"));
}
예제 #21
0
MainWindow::MainWindow(QWidget *parent)
	: QMainWindow(parent)
{
	// Buttons
	auto buttonsDock = new QDockWidget(tr("Buttons"));
	m_buttonsDockWidget = new QWidget(this);
	auto buttonsLayout = new QGridLayout;
	m_buttonsDockWidget->setLayout(buttonsLayout);
	buttonsDock->setObjectName("ButtonsDock");
	buttonsDock->setWidget(m_buttonsDockWidget);
	buttonsDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
	addDockWidget(Qt::LeftDockWidgetArea, buttonsDock);

	// Graph tree
	m_graphView = new GraphView(this);
	auto graphDock = new QDockWidget(tr("Graph"), this);
	graphDock->setObjectName("GraphDock");
	graphDock->setWidget(m_graphView->view());
	graphDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
	addDockWidget(Qt::LeftDockWidgetArea, graphDock);

	m_openGLView = new OpenGLView(this);
	setCentralWidget(m_openGLView);

	createActions();
	createMenus();

	statusBar();
	
	std::vector<QMenu*> menus = { m_fileMenu, m_toolsMenu, m_viewMenu, m_helpMenu };
	m_simpleGUI = std::make_shared<SimpleGUIImpl>(this, m_openGLView, m_buttonsDockWidget, menus);

	connect(m_graphView, &GraphView::itemOpened, [this](void* item) {
		m_simpleGUI->openPropertiesDialog(static_cast<GraphNode*>(item));
	});

	setWindowIcon(QIcon(":/share/icons/icon.png"));
	setCurrentFile("");
	setAcceptDrops(true);

	readSettings();

	loadModules();

	auto& factory = DocumentFactory::instance();
	if (factory.creatableDocuments().empty())
		m_newAction->setEnabled(false);
	if (factory.loadFilesFilter().empty())
		m_openAction->setEnabled(false);
}
예제 #22
0
파일: mainwindow.cpp 프로젝트: nabsha/gTail
void MainWindow::loadFile(const QString &fileName)
{
    logFile  = new QFile(fileName);
#ifndef QT_NO_CURSOR
    QApplication::setOverrideCursor(Qt::WaitCursor);
#endif
#ifndef QT_NO_CURSOR
    QApplication::restoreOverrideCursor();
#endif

    setCurrentFile(fileName);
    statusBar()->showMessage(tr("File loaded"), 2000);
    reloadFile();
}
예제 #23
0
MainWindow::MainWindow() :
    recentFiles( Persistent<RecentFiles>( "recentFiles" ) ), mainIcon_()
{
    createActions();
    createMenus();
    // createContextMenu();
    createToolBars();
    // createStatusBar();
    createCrawler();

    setAcceptDrops( true );

    // Default geometry
    const QRect geometry = QApplication::desktop()->availableGeometry( this );
    setGeometry( geometry.x() + 20, geometry.y() + 40,
            geometry.width() - 140, geometry.height() - 140 );

    // Send actions to the crawlerwidget
    connect( this, SIGNAL( followSet( bool ) ),
            crawlerWidget, SIGNAL( followSet( bool ) ) );
    connect( this, SIGNAL( optionsChanged() ),
            crawlerWidget, SLOT( applyConfiguration() ) );

    // Actions from the CrawlerWidget
    connect( crawlerWidget, SIGNAL( followDisabled() ),
            this, SLOT( disableFollow() ) );
    connect( crawlerWidget, SIGNAL( updateLineNumber( int ) ),
            this, SLOT( lineNumberHandler( int ) ) );

    readSettings();
    emit optionsChanged();

    // We start with the empty file
    setCurrentFile( "" );

    mainIcon_.addFile( ":/images/hicolor/16x16/glogg.png" );
    mainIcon_.addFile( ":/images/hicolor/24x24/glogg.png" );
    mainIcon_.addFile( ":/images/hicolor/32x32/glogg.png" );
    mainIcon_.addFile( ":/images/hicolor/48x48/glogg.png" );

    // Register for progress status bar
    connect( crawlerWidget, SIGNAL( loadingProgressed( int ) ),
            this, SLOT( updateLoadingProgress( int ) ) );
    connect( crawlerWidget, SIGNAL( loadingFinished( bool ) ),
            this, SLOT( displayNormalStatus( bool ) ) );

    setWindowIcon( mainIcon_ );
    setCentralWidget(crawlerWidget);
}
MainWindow::MainWindow()
{
    textEdit = new QTextEdit;
    setCentralWidget(textEdit);

    createActions();
    createMenus();

    readSettings();

    connect(textEdit->document(), SIGNAL(contentsChanged()),
            this, SLOT(documentWasModified()));

    setCurrentFile("");
}
예제 #25
0
FilenameComponent::FilenameComponent (const String& name,
                                      const File& currentFile,
                                      bool canEditFilename,
                                      bool isDirectory,
                                      bool isForSaving,
                                      const String& fileBrowserWildcard,
                                      const String& suffix,
                                      const String& textWhenNothingSelected)
    : Component (name),
      isDir (isDirectory),
      isSaving (isForSaving),
      wildcard (fileBrowserWildcard),
      enforcedSuffix (suffix)
{
    addAndMakeVisible (filenameBox);
    filenameBox.setEditableText (canEditFilename);
    filenameBox.setTextWhenNothingSelected (textWhenNothingSelected);
    filenameBox.setTextWhenNoChoicesAvailable (TRANS ("(no recently selected files)"));
    filenameBox.onChange = [this] { setCurrentFile (getCurrentFile(), true); };

    setBrowseButtonText ("...");

    setCurrentFile (currentFile, true, dontSendNotification);
}
예제 #26
0
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    textEdit = new QPlainTextEdit;
    setCentralWidget(textEdit);

    createAction();
    createMenu();
    createToolBar();
    createStatusBar();
    connectSignalSlot();

    readSettings();
    setCurrentFile("");
}
예제 #27
0
void ImageWindow::saveFile(const QString &fileName)
{
    QImage image = thread.image();

    QApplication::setOverrideCursor(Qt::WaitCursor);
    bool saved = image.save(fileName, imageFormat);
    QApplication::restoreOverrideCursor();

    if (saved) {
        setCurrentFile(fileName);
        statusBar()->showMessage(tr("File saved"), 2000);
    } else {
        statusBar()->showMessage(tr("Saving canceled"), 2000);
    }
}
예제 #28
0
bool MainWindow::saveFile(const QString &fileName)
{
    //std::cout << "save file\n";
    //just deal with spreadsheet
    Spreadsheet *ss = static_cast<Spreadsheet *> (tabWidget ->currentWidget());
    ss -> setFileName(fileName);

    if (!ss -> save())
    {
        statusBar() -> showMessage(tr("Saving canceled"), 2000);
        return false ;
    }
    setCurrentFile(fileName);
	statusBar()->showMessage(tr("File saved"), 2000);
	return true ;
}
예제 #29
0
파일: mdichild.cpp 프로젝트: raojun/MyEdi
//saveFile()
bool MdiChild::saveFile(const QString &fileName)
{
    QFile file(fileName);
    if(!file.open(QFile::WriteOnly|QFile::Text))
    {
        QMessageBox::warning(this,"多文档编辑器",tr("无法写入文件%1:\n%2.").arg(fileName).arg(file.errorString()));
        return false;
    }

    QTextStream out(&file);
    QApplication::setOverrideCursor(Qt::WaitCursor);
    out<<toPlainText();//以纯文本文件写入
    QApplication::restoreOverrideCursor();
    setCurrentFile(fileName);
    return true;
}
예제 #30
0
void MainFrm::loadFile()
{
    if (pFrmReports->isVisible())
        closeSecondaryFrm(pFrmReports);

    QString fileName = QFileDialog::getOpenFileName(this,
     tr("Open Project"), tr(""), tr("Project Files (*.xml)"));

    if (!fileName.isEmpty()){
        if (!readXMLFile(fileName))
            this->displayError(tr("Could not parse XML file! Are you sure this is a valid project file?"),true);
        else
            loadTabs();
            setCurrentFile(fileName);
            statusShow(tr("File loaded"));
    }
}