Esempio n. 1
0
bool PhDocumentWindow::eventFilter(QObject *sender, QEvent *event)
{
	switch (event->type()) {
	case QEvent::FileOpen:
		{
			QString fileName = static_cast<QFileOpenEvent*>(event)->file();
			PHDEBUG << "File dragged on the application dock icon (MacOS):" + fileName;
			openDocument(fileName);
			break;
		}
	case QEvent::DragEnter: // Accept and process a file drop on the window
		event->accept();
		break;
	case QEvent::Drop:
		{
			const QMimeData* mimeData = static_cast<QDropEvent *>(event)->mimeData();

			// If there is one file (not more) we open it
			if (mimeData->urls().length() == 1) {
				QString fileName = mimeData->urls().first().toLocalFile();
				PHDEBUG << "File dragged on the application window:" + fileName;
				openDocument(fileName);
			}
			break;
		}
	default:
		break;
	}

	return PhWindow::eventFilter(sender, event);
}
Esempio n. 2
0
static void cb_open_ok (UiForm sendingForm, int /* narg */, Stackel /* args */, const char32 * /* sendingString */,
	Interpreter /* interpreter */, const char32 * /* invokingButtonTitle */, bool /* modified */, I)
{
	iam (TextEditor);
	MelderFile file = UiFile_getFile (sendingForm);
	openDocument (me, file);
}
Esempio n. 3
0
/*----------------------------------------------------------openDtdAsDocument-+
| This calls permits to open a single DTD as the main document.               |
| Neither DTD start, nor DTD_REQUEST will be issued.                          |
| However, DTD_END is issued.                                                 |
+----------------------------------------------------------------------------*/
bool Yasp3::openDtdAsDocument(EntitySolverBase & solverArg)
{
   if (!openDocument(solverArg)) {
      return false;
   }
   return true;
}
Esempio n. 4
0
bool KraftDoc::reloadDocument()
{
  mPositions.clear();
  mRemovePositions.clear();

  return openDocument( mDocID.toString() );
}
Esempio n. 5
0
void PhDocumentWindow::onOpenRecentDocumentTriggered()
{
	QString fileName = sender()->objectName();
	PHDEBUG << fileName;
	checkFilePermission(fileName);
	openDocument(fileName);
}
static bool launchWebBrowser(const QUrl &url)
{
    if (!url.isValid())
        return false;
    if (url.scheme() == QLatin1String("mailto"))
        return openDocument(url);

    if (launch(url, QLatin1String("xdg-open")))
        return true;
    if (launch(url, QString::fromLocal8Bit(getenv("DEFAULT_BROWSER"))))
        return true;
    if (launch(url, QString::fromLocal8Bit(getenv("BROWSER"))))
        return true;

    // Use the X11->desktopEnvironment value if X11 is non-NULL,
    //  otherwise just attempt to launch command regardless of the desktop environment
    if ((!X11 || (X11 && X11->desktopEnvironment == DE_GNOME)) && launch(url, QLatin1String("gnome-open"))) {
        return true;
    } else {
        if ((!X11 || (X11 && X11->desktopEnvironment == DE_KDE)) && launch(url, QLatin1String("kfmclient openURL")))
            return true;
    }

    if (launch(url, QLatin1String("firefox")))
        return true;
    if (launch(url, QLatin1String("mozilla")))
        return true;
    if (launch(url, QLatin1String("netscape")))
        return true;
    if (launch(url, QLatin1String("opera")))
        return true;
    return false;
}
int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QMainWindow::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: openDocument(); break;
        case 1: saveDocument(); break;
        case 2: closeDocument(); break;
        case 3: newDocument(); break;
        case 4: addShape(); break;
        case 5: removeShape(); break;
        case 6: setShapeColor(); break;
        case 7: addSnowman(); break;
        case 8: addRobot(); break;
        case 9: about(); break;
        case 10: aboutQt(); break;
        case 11: updateActions(); break;
        default: ;
        }
        _id -= 12;
    }
    return _id;
}
Esempio n. 8
0
void SportsmenReport::writeBody(const char *headers[], uint length)
{
    sheet = openDocument();
    for(uint i = 0; i < length; ++i)
    {
        QAxObject *range = sheet->querySubObject("Range(const QString&)",
                                                 QString('A'+i) + QString::number(1));
        range->dynamicCall("SetValue(const QVariant&)", QObject::tr(headers[i]));
        range->querySubObject("Font")->setProperty("Bold", true);
        range->querySubObject("Borders")->setProperty("LineStyle", xlSingle);
    }
    int rowid = 2, fieldsCount = length;
    while(query->next())
    {
        fieldsCount = query->record().count();
        for(int i = 0; i < fieldsCount; ++i)
        {
            QAxObject *range = sheet->querySubObject("Range(const QString&)",
                                                     QString('A'+i) + QString::number(rowid));
            range->dynamicCall("SetValue(const QVariant&)", QVariant(query->value(i).value<QString>()));
        }
        rowid++;
    }
    QAxObject *exported = sheet->querySubObject("Range(const QString&)",
                            (QString("A2:") + (QString('A'+(fieldsCount-1)) + QString::number(rowid-1))));
    exported->querySubObject("Borders")->setProperty("LineStyle", xlSingle);

    QAxObject *font = exported->querySubObject("Font");
    font->setProperty("Name", QObject::tr("Arial"));
    font->setProperty("Size", 10);

    sheet->querySubObject("Columns")->dynamicCall("AutoFit()");
}
Esempio n. 9
0
void MainWindow::menuItemSelected (int menuItemID,
                                   int topLevelMenuIndex)
{
    if (menuItemID >= 100 && menuItemID < 200)
    {
        // open a file from the "recent files" menu
        JucerDocument* const newDoc
            = ObjectTypes::loadDocumentFromFile (StoredSettings::getInstance()->recentFiles.getFile (menuItemID - 100),
                                                 true);

        if (newDoc != 0)
            openDocument (newDoc);
    }
    else if (menuItemID == 200)
    {
        LookAndFeel::setDefaultLookAndFeel (oldLook);
    }
    else if (menuItemID == 201)
    {
        LookAndFeel::setDefaultLookAndFeel (nullptr);
    }
    else if (menuItemID >= 300 && menuItemID < 400)
    {
        if (getActiveDocument() != 0)
        {
            getActiveDocument()->setSnappingGrid (snapSizes [menuItemID - 300],
                                                  getActiveDocument()->isSnapActive (false),
                                                  getActiveDocument()->isSnapShown());
        }
    }
}
Esempio n. 10
0
bool MainWindow::perform (const InvocationInfo& info)
{
    if (info.commandID >= CommandIDs::newDocumentBase
         && info.commandID < CommandIDs::newDocumentBase + ObjectTypes::numDocumentTypes)
    {
        const int index = info.commandID - CommandIDs::newDocumentBase;
        openDocument (ObjectTypes::createNewDocument (index));

        return true;
    }

    switch (info.commandID)
    {
    case CommandIDs::open:
        openFile (File::nonexistent);
        break;

    case CommandIDs::showPrefs:
        PrefsPanel::show();
        break;

    case CommandIDs::useTabbedWindows:
        if (multiDocHolder->getLayoutMode() == MultiDocumentPanel::MaximisedWindowsWithTabs)
            multiDocHolder->setLayoutMode (MultiDocumentPanel::FloatingWindows);
        else
            multiDocHolder->setLayoutMode (MultiDocumentPanel::MaximisedWindowsWithTabs);

        break;

    default:
        return false;
    }

    return true;
}
Esempio n. 11
0
PDF::PDF( const QString& uri )
    : pdfDoc_( 0 )
    , pdfPage_( 0 )
    , pageNumber_( INVALID_PAGE_NUMBER )
{
    openDocument( uri );
}
Esempio n. 12
0
/*!
    Constructs a NotesDemo dialog which is a child of \a parent and has the given window
    \a flags.
 */
NotesDemo::NotesDemo( QWidget *parent, Qt::WindowFlags flags )
    : QDialog( parent, flags )
{
    // Create a new document selector which lists documents with the MIME type text/plain
    // sorted so the most recently edited documents appear first.
    documentSelector = new QDocumentSelector;

    documentSelector->setFilter( QContentFilter::mimeType( "text/plain" ) );
    documentSelector->setSortMode( QDocumentSelector::ReverseChronological );

    // Enable the new document option so a 'New' document selection appears at the start of the
    // documents list and in the context menu.
    documentSelector->enableOptions( QDocumentSelector::NewDocument );

    // Connect to the newSelected() and documentSelected() signal so we're notified when the user
    // selects a document.
    connect( documentSelector, SIGNAL(newSelected()),
             this, SLOT(newDocument()) );
    connect( documentSelector, SIGNAL(documentSelected(QContent)),
             this, SLOT(openDocument(QContent)) );

    // Construct the text editor widget.
    editor = new QTextEdit;

    // Create a new stacked layout and add the document selector and text editor widgets to it.
    // As the layout is given the dialog as a parent it is automatically set as the layout for
    // the dialog, and the widgets added to it are re-parented to the dialog.  The document
    // will be the initial widget shown as it was added to the layout first.
    layout = new QStackedLayout( this );

    layout->addWidget( documentSelector );
    layout->addWidget( editor );
}
Esempio n. 13
0
void KPlatoWork_MainWindow::slotFileOpen()
{
    const QUrl file = QFileDialog::getOpenFileUrl( 0, QString(), QUrl(), "*.planwork" );
    if ( ! file.isEmpty() ) {
        openDocument( file );
    }
}
static bool launchWebBrowser(const QUrl &url)
{
    if (!url.isValid())
        return false;
    if (url.scheme() == QLatin1String("mailto"))
        return openDocument(url);

    if (launch(url, QLatin1String("xdg-open")))
        return true;
    if (launch(url, QString::fromLocal8Bit(getenv("DEFAULT_BROWSER"))))
        return true;
    if (launch(url, QString::fromLocal8Bit(getenv("BROWSER"))))
        return true;

    if (X11->desktopEnvironment == DE_GNOME && launch(url, QLatin1String("gnome-open"))) {
        return true;
    } else {
        if (X11->desktopEnvironment == DE_KDE && launch(url, QLatin1String("kfmclient openURL")))
            return true;
    }

    if (launch(url, QLatin1String("firefox")))
        return true;
    if (launch(url, QLatin1String("mozilla")))
        return true;
    if (launch(url, QLatin1String("netscape")))
        return true;
    if (launch(url, QLatin1String("opera")))
        return true;
    return false;
}
Esempio n. 15
0
void KPlatoWork_MainWindow::slotFileOpen()
{
    QString file = KFileDialog::getOpenFileName( KUrl(), "*.planwork" );
    if ( ! file.isEmpty() ) {
        openDocument( file );
    }
}
Esempio n. 16
0
void TechnicalReport::makeReport()
{
    QString category = "", vcat;
    sheet = openDocument();
    currentRow = 1;
    const double widths[] = {
        2,
        82,
    };
    for(uint i = 0; i < sizeof(widths)/sizeof(*widths); ++i)
    {
        sheet->querySubObject("Columns(const QString&)", QString("%1:%1").arg(QString('A' + i)))
             ->setProperty("ColumnWidth", widths[i]);
    }
    while(query->next())
    {
        vcat = query->value(1).toString();
        if(currentRow == 1)
        {
            writeSuperHeader();
        }
        if(category != vcat)
        {
            category = vcat;
            writeHeader();
        }
        writeLine();
    }
    sheet->querySubObject("Columns")->setProperty("WrapText", true);
}
Esempio n. 17
0
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    setupUi(this);

    QWidget *w = documentTabs->widget(0);
    documentTabs->removeTab(0);
    delete w;

    connect(actionOpen, SIGNAL(triggered()), this, SLOT(openDocument()));
    connect(actionClose, SIGNAL(triggered()), this, SLOT(closeDocument()));
    connect(actionNew, SIGNAL(triggered()), this, SLOT(newDocument()));
    connect(actionSave, SIGNAL(triggered()), this, SLOT(saveDocument()));
    connect(actionExit, SIGNAL(triggered()), this, SLOT(close()));
    connect(actionRed, SIGNAL(triggered()), this, SLOT(setShapeColor()));
    connect(actionGreen, SIGNAL(triggered()), this, SLOT(setShapeColor()));
    connect(actionBlue, SIGNAL(triggered()), this, SLOT(setShapeColor()));
    connect(actionAddCircle, SIGNAL(triggered()), this, SLOT(addShape()));
    connect(actionAddRectangle, SIGNAL(triggered()), this, SLOT(addShape()));
    connect(actionAddTriangle, SIGNAL(triggered()), this, SLOT(addShape()));
    connect(actionRemoveShape, SIGNAL(triggered()), this, SLOT(removeShape()));
    connect(actionAddRobot, SIGNAL(triggered()), this, SLOT(addRobot()));
    connect(actionAddSnowman, SIGNAL(triggered()), this, SLOT(addSnowman()));
    connect(actionAbout, SIGNAL(triggered()), this, SLOT(about()));
    connect(actionAboutQt, SIGNAL(triggered()), this, SLOT(aboutQt()));

    connect(undoLimit, SIGNAL(valueChanged(int)), this, SLOT(updateActions()));
    connect(documentTabs, SIGNAL(currentChanged(int)), this, SLOT(updateActions()));

    actionOpen->setShortcut(QString("Ctrl+O"));
    actionClose->setShortcut(QString("Ctrl+W"));
    actionNew->setShortcut(QString("Ctrl+N"));
    actionSave->setShortcut(QString("Ctrl+S"));
    actionExit->setShortcut(QString("Ctrl+Q"));
    actionRemoveShape->setShortcut(QString("Del"));
    actionRed->setShortcut(QString("Alt+R"));
    actionGreen->setShortcut(QString("Alt+G"));
    actionBlue->setShortcut(QString("Alt+B"));
    actionAddCircle->setShortcut(QString("Alt+C"));
    actionAddRectangle->setShortcut(QString("Alt+L"));
    actionAddTriangle->setShortcut(QString("Alt+T"));

    m_undoGroup = new QUndoGroup(this);
    undoView->setGroup(m_undoGroup);
    undoView->setCleanIcon(QIcon(":/icons/ok.png"));

    QAction *undoAction = m_undoGroup->createUndoAction(this);
    QAction *redoAction = m_undoGroup->createRedoAction(this);
    undoAction->setIcon(QIcon(":/icons/undo.png"));
    redoAction->setIcon(QIcon(":/icons/redo.png"));
    menuShape->insertAction(menuShape->actions().at(0), undoAction);
    menuShape->insertAction(undoAction, redoAction);

    toolBar->addAction(undoAction);
    toolBar->addAction(redoAction);

    newDocument();
    updateActions();
};
Esempio n. 18
0
/*
 * A matter of convenience pressing Key_Select will cause a document to be opened
 */
void TextViewer::keyPressEvent(QKeyEvent *e)
{
    if ( e->key() == Qt::Key_Select){
        e->accept();
        openDocument();
    }else{
        QMainWindow::keyPressEvent(e);
    }
}
Esempio n. 19
0
bool MainWindow::openFile (const File& file)
{
    JucerDocument* newDoc = ObjectTypes::loadDocumentFromFile (file, true);

    if (newDoc != 0)
        openDocument (newDoc);

    return newDoc != 0;
}
Esempio n. 20
0
bool QWindowsServices::openUrl(const QUrl &url)
{
    const QString scheme = url.scheme();
    if (scheme.isEmpty())
        return openDocument(url);
    if (scheme == QStringLiteral("mailto") && launchMail(url))
        return true;
    return shellExecute(QLatin1String(url.toEncoded()));
}
Esempio n. 21
0
void DBusAdaptor::mime_open(QString aText)
{
    QUrl path = QUrl::fromEncoded(aText.toUtf8());

    if (!QFile::exists(path.path()))
        path = QUrl(aText.toUtf8());

    if (path.isValid() && QFile::exists(path.path()))
        emit openDocument(path.path());
}
Esempio n. 22
0
void MainWindow::open()
{
    const auto formats = ImageIO::supportedImageFormats(ImageFormatInfo::CanRead);
    const auto filters = tr("All Files (*);;") + mimeTypesToFilters(formatsToMimeTypes(formats));
    const auto path = QFileDialog::getOpenFileName(this, tr("open"), QString(), filters);
    if (path.isEmpty())
        return;

    openDocument(QUrl::fromLocalFile(path));
}
Esempio n. 23
0
void PulkaReport::makeReport()
{
    QString category = "", vcat;
    sheet = openDocument();
    currentPage = 1;
    bool start = true;
    uint draw_number;
    excel->querySubObject("ActiveWindow")->setProperty("Zoom", 75);
    const double widths[] = {
        21.29,
        13.29,
        7,
        7,
        7,
        7,
        7,
        7,
        7,
        7,
        7,
        21.29,
        13.29,
    };
    for(uint i = 0; i < sizeof(widths)/sizeof(*widths); ++i)
    {
        sheet->querySubObject("Columns(const QString&)", QString("%1:%1").arg(QString('A' + i)))
             ->setProperty("ColumnWidth", widths[i]);
    }
    while(query->next())
    {
        vcat = query->value(2).toString();
        draw_number = query->value(6).toUInt();
        if(start || category != vcat || draw_number > 16)
        {
            if(!start)
            {
                writeFooter();
            }
            else
            {
                start = false;
            }
            if(draw_number > 16)
                draw_number -= 16;
            category = vcat;
            writeHeader(category, query->value(0).toString(), query->value(1).toDate());
        }
        writeRec(draw_number);
    }
    writeFooter();
    sheet->querySubObject("PageSetup")->setProperty("Zoom", 90);
    sheet->querySubObject("PageSetup")->setProperty("Orientation", xlLandscape);
    sheet->querySubObject("PageSetup")->setProperty("PrintQuality", 600);
}
Esempio n. 24
0
bool QGenericUnixServices::openUrl(const QUrl &url)
{
    if (url.scheme() == QLatin1String("mailto"))
        return openDocument(url);

    if (m_webBrowser.isEmpty() && !detectWebBrowser(desktopEnvironment(), true, &m_webBrowser)) {
        qWarning("%s: Unable to detect a web browser to launch '%s'", Q_FUNC_INFO, qPrintable(url.toString()));
        return false;
    }
    return launch(m_webBrowser, url);
}
Esempio n. 25
0
void TourWidgetPrivate::openFile()
{
    if ( overrideModifications() ) {
        QString const filename = QFileDialog::getOpenFileName( q, QObject::tr( "Open Tour" ), QDir::homePath(), QObject::tr( "KML Tours (*.kml)" ) );
        if ( !filename.isEmpty() ) {
            ParsingRunnerManager manager( m_widget->model()->pluginManager() );
            GeoDataDocument* document = manager.openFile( filename );
            m_playback.setBaseUrl( QUrl::fromLocalFile( filename ) );
            openDocument( document );
        }
    }
}
Esempio n. 26
0
void TextEditTestWindow::on_actionOpen_triggered()
{
	PHDEBUG << _settings->lastDocumentFolder();
	if(checkDocumentModification()) {
		QString fileName = QFileDialog::getOpenFileName(this, "Open a text file...", _settings->lastDocumentFolder(), "Text file (*.txt)");

		if(QFile::exists(fileName)) {
			if(!openDocument(fileName))
				QMessageBox::critical(this, "", tr("Unable to open ") + fileName);
		}
	}
}
Esempio n. 27
0
void VideoTestWindow::on_actionOpen_triggered()
{
	_mediaPanelDialog.hide();
	QString fileName = QFileDialog::getOpenFileName(this, tr("Open Movie"), _settings->lastDocumentFolder());
	if(QFile::exists(fileName)) {
		if(!openDocument(fileName))
			QMessageBox::critical(this, "Error", "Unable to open " + fileName);
	}

	if(_settings->displayMediaPanel())
		_mediaPanelDialog.show();
}
Esempio n. 28
0
void PhDocumentWindow::processArg(int argc, char *argv[])
{
#warning /// @todo move to PhApplication
	for(int i = 1; i < argc; i++) {
		if(QFile::exists(argv[i]))
			_settings->setCurrentDocument(argv[i]);
	}
	if(QFile::exists(_settings->currentDocument()))
		openDocument(_settings->currentDocument());
	else
		updateRecentDocumentMenu();
}
Esempio n. 29
0
static void menu_cb_reopen (TextEditor me, EDITOR_ARGS_DIRECT) {
	if (my name [0]) {
		try {
			openDocument (me, & my file);
		} catch (MelderError) {
			Melder_flushError ();
			return;
		}
	} else {
		Melder_throw (U"Cannot reopen from disk, because the text has never been saved yet.");
	}
}
Esempio n. 30
0
bool TourWidgetPrivate::openFile( const QString &filename )
{
    if ( overrideModifications() ) {
        if ( !filename.isEmpty() ) {
            ParsingRunnerManager manager( m_widget->model()->pluginManager() );
            GeoDataDocument* document = manager.openFile( filename );
            m_playback.setBaseUrl( QUrl::fromLocalFile( filename ) );
            return openDocument( document );
        }
    }

    return false;
}