Пример #1
0
void Options::setEditorFont(const QFont &font)
{
    this->font = font;
    emit editorFontChanged(font);
}
Пример #2
0
//*****************************************************************************
mlMainWindow::mlMainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::mlMainWindow),
    uniConverter(0) {

    ui->setupUi(this);

    //-------------------------------------------------------------------------
    // Load the mapping file
    QByteArray map;
    QFile mfile(":/maps/maps/mollana-urdu.tec");
    if( mfile.open( QIODevice::ReadOnly ) ) {
        qDebug() << "Internal Urdu mapping file loaded...";
        map = mfile.readAll();
        mfile.close();
        qDebug() << "Map size: " << map.size() << "";
    } else {
        qDebug() << "Unable to open Internal Urdu mapping file for reading...\n";
        //raise exception
        return;
    }

    //-------------------------------------------------------------------------
    // Create the converter
    uniConverter = new TECkitConverter( map );
    if( !uniConverter->isValid() ) {
        qDebug() << "Unable to create Unicode TECkit converter...";
        //raise exception
        return;
    }

    //-------------------------------------------------------------------------
    // Toolbars
    ui->mainToolBar->addAction( ui->actionNew );
    ui->mainToolBar->addAction( ui->actionOpen );
    ui->mainToolBar->addAction( ui->actionSave );
    ui->mainToolBar->addSeparator();

    ui->mainToolBar->addAction( ui->actionUndo );
    ui->mainToolBar->addAction( ui->actionRedo );
    ui->mainToolBar->addSeparator();

    ui->mainToolBar->addAction( ui->actionCopy );
    ui->mainToolBar->addAction( ui->actionCut );
    ui->mainToolBar->addAction( ui->actionPaste );
    ui->mainToolBar->addSeparator();

    ui->mainToolBar->addAction( ui->actionUnicodeViewFont );
    ui->mainToolBar->addAction( ui->actionWordWrap );
    ui->mainToolBar->addSeparator();

    //-------------------------------------------------------------------------
    // Signal/Slots
    connect(ui->actionNew,      SIGNAL(triggered()),
            this,               SLOT(newFile()) );
    connect(ui->actionOpen,     SIGNAL(triggered()),
            this,               SLOT(open()) );
    connect(ui->actionSave,     SIGNAL(triggered()),
            this,               SLOT(save()) );
    connect(ui->actionSaveAs,   SIGNAL(triggered()),
            this,               SLOT(saveAs()) );
    connect(ui->actionQuit,     SIGNAL(triggered()),
            this,               SLOT(close()) );
    connect(ui->actionSelectAll,SIGNAL(triggered()),
            ui->tbxEditor,      SLOT(selectAll()) );
    connect(ui->actionEditorFont,
                                SIGNAL(triggered()),
            this,               SLOT(editorFontChanged()) );
    connect(ui->actionUnicodeViewFont,
                                SIGNAL(triggered()),
            this,               SLOT(unicodeFontChanged()) );
    connect(ui->actionAbout,    SIGNAL(triggered()),
            this,               SLOT(about()) );

    connect(ui->tbxEditor->document(),
                                SIGNAL(contentsChanged()),
            this,               SLOT(documentModified()) );

    // Copy, Cut & Paste
    connect(ui->actionCut,      SIGNAL(triggered()),
            ui->tbxEditor,      SLOT(cut()) );
    connect(ui->actionCopy,     SIGNAL(triggered()),
            ui->tbxEditor,      SLOT(copy()) );
    connect(ui->actionPaste,    SIGNAL(triggered()),
            ui->tbxEditor,      SLOT(paste()) );

    connect(ui->tbxEditor,      SIGNAL(copyAvailable(bool)),
            ui->actionCopy,     SLOT(setEnabled(bool)) );
    connect(ui->tbxEditor,      SIGNAL(copyAvailable(bool)),
            ui->actionCut,      SLOT(setEnabled(bool)) );

    // Undo & Redo
    connect(ui->actionUndo,     SIGNAL(triggered()),
            ui->tbxEditor,      SLOT(undo()) );
    connect(ui->actionCopy,     SIGNAL(triggered()),
            ui->tbxEditor,      SLOT(redo()) );

    connect(ui->tbxEditor,      SIGNAL(undoAvailable(bool)),
            ui->actionUndo,     SLOT(setEnabled(bool)) );
    connect(ui->tbxEditor,      SIGNAL(redoAvailable(bool)),
            ui->actionRedo,     SLOT(setEnabled(bool)) );

    connect(ui->actionWordWrap, SIGNAL(toggled(bool)),
            this,               SLOT(wordWrapChanged(bool)) );

    connect(ui->actionUnicodeOutput,
                                SIGNAL(toggled(bool)),
            ui->dckUnicodeOutput,
                                SLOT(setVisible(bool)) );

    connect(ui->tbxEditor,      SIGNAL(textChanged()),
            this,               SLOT(translateText()) );

    //-------------------------------------------------------------------------
    QFont f = ui->tbxUnicodeView->font();
    f.setStyleStrategy(QFont::PreferAntialias);
    ui->tbxUnicodeView->setFont(f);

    //-------------------------------------------------------------------------
    // Start with a new file
    newFile();
}