Exemplo n.º 1
0
static void createAndAppendFontSubMenu(const HitTestResult& result, ContextMenuItem& fontMenuItem)
{
    ContextMenu fontMenu(result);

#if PLATFORM(MAC)
    ContextMenuItem showFonts(ActionType, ContextMenuItemTagShowFonts, contextMenuItemTagShowFonts());
#endif
    ContextMenuItem bold(CheckableActionType, ContextMenuItemTagBold, contextMenuItemTagBold());
    ContextMenuItem italic(CheckableActionType, ContextMenuItemTagItalic, contextMenuItemTagItalic());
    ContextMenuItem underline(CheckableActionType, ContextMenuItemTagUnderline, contextMenuItemTagUnderline());
    ContextMenuItem outline(ActionType, ContextMenuItemTagOutline, contextMenuItemTagOutline());
#if PLATFORM(MAC)
    ContextMenuItem styles(ActionType, ContextMenuItemTagStyles, contextMenuItemTagStyles());
    ContextMenuItem showColors(ActionType, ContextMenuItemTagShowColors, contextMenuItemTagShowColors());
#endif

#if PLATFORM(MAC)
    fontMenu.appendItem(showFonts);
#endif
    fontMenu.appendItem(bold);
    fontMenu.appendItem(italic);
    fontMenu.appendItem(underline);
    fontMenu.appendItem(outline);
#if PLATFORM(MAC)
    fontMenu.appendItem(styles);
    fontMenu.appendItem(*separatorItem());
    fontMenu.appendItem(showColors);
#endif

    fontMenuItem.setSubMenu(&fontMenu);
}
void CRTFBuilder::normal()
{
	bold(false);
	italic(false);
	underline(false);
	strike(false);
}
Exemplo n.º 3
0
void FontResource::updateModelFromLogFont(const LOGFONT& logFont) {
	auto newFont = createFont (logFont);
	mFont->fontName (newFont->fontName());
	mFont->size (newFont->size());
	mFont->bold (newFont->bold());
	mFont->italic (newFont->italic());
	mFont->underline (newFont->underline());
}
Exemplo n.º 4
0
QFont Font::font() const
{
    QFont f = primaryFont()->getQtFont();
    f.setWeight(toQFontWeight(weight()));
    f.setItalic(italic());
    if (m_letterSpacing != 0)
        f.setLetterSpacing(QFont::AbsoluteSpacing, m_letterSpacing);
    if (m_wordSpacing != 0)
        f.setWordSpacing(m_wordSpacing);
    return f;
}
Exemplo n.º 5
0
FontEffects& FontEffects::operator+=(const FontEffects& eff)
{
    effects_.fx.weight=std::max(weight(), eff.weight());
    effects_.fx.italic=(italic() || eff.italic());
    effects_.fx.isSmall=(isSmall() || eff.isSmall());
    effects_.fx.strike=(strikeOut() || eff.strikeOut());
    effects_.fx.superscript=(superscript() || eff.superscript());
    effects_.fx.subscript=(subscript() || eff.subscript());
    effects_.fx.underline=std::max(underline(), eff.underline());
    return *this;            
}
Exemplo n.º 6
0
/**
 * This is a utility method to copy all the attributes of this
 * TextItem to \a other TextItem.
 */
void TextItem::copyAttributesTo(TextItem *other) const
{
    other->setDefaultTextColor(defaultTextColor());
    other->setHoverBrush(hoverBrush());
    other->setAcceptHoverEvents(acceptHoverEvents());
    other->setAlignment(alignment());
    other->setFont(font());
    other->setBold(bold());
    other->setItalic(italic());
    other->setUnderline(underline());
    other->setBackgroundBrush(backgroundBrush());
}
Exemplo n.º 7
0
QFont State::font(QFont base)
{
    if (bold())
        base.setBold(true);
    if (italic())
        base.setItalic(true);
    if (underline())
        base.setUnderline(true);
    if (strikeOut())
        base.setStrikeOut(true);
    if (!fontName().isEmpty())
        base.setFamily(fontName());
    if (fontSize() > 0)
        base.setPointSize(fontSize());
    return base;
}
Exemplo n.º 8
0
void
Format::copyTo (Format * to)
{
	if ( isBackgroundSet() )
		to->setBackground( background() );
	if ( isForegroundSet() )
		to->setForeground( foreground() );
	if ( isFontSet() )
		to->setFont( font() );
	if ( isItalicSet() )
		to->setItalic( italic() );
	if ( isPointsSet() )
		to->setPoints( points() );
	if ( isBoldSet() )
		to->setBold ( bold() );
}
Exemplo n.º 9
0
TQFont KateAttribute::font(const TQFont& ref)
{
  TQFont ret = ref;

  if (itemSet(Weight))
    ret.setWeight(weight());
  if (itemSet(Italic))
    ret.setItalic(italic());
  if (itemSet(Underline))
    ret.setUnderline(underline());
   if (itemSet(Overline))
    ret.setOverline(overline());
  if (itemSet(StrikeOut))
    ret.setStrikeOut(strikeOut());

  return ret;
}
Exemplo n.º 10
0
void TextZone::keyPressEvent(QKeyEvent *event)
{
    //    sounds->startSoundKeyAny();


    if(event->matches(QKeySequence::Italic))
        italic(!italicAct->isChecked());
    else if(event->matches(QKeySequence::Bold))
        bold(!boldAct->isChecked());
    //    else if(event->modifiers() == (Qt::ControlModifier|Qt::ShiftModifier) && event->key() == QKeySequence(tr("L")))    //: L for Left
    //        leftAlign(true);
    //    else if(event->modifiers() == (Qt::ControlModifier|Qt::ShiftModifier) && event->key() == QKeySequence(tr("R"))) //: R for Right
    //        rightAlign(true);
    //    else if(event->modifiers() == Qt::ControlModifier && event->key() == Qt::Key_E)
    //        center(true);
    //    else if(event->modifiers() == Qt::ControlModifier && event->key() == Qt::Key_J)
    //        justify(true);

#if QT_VERSION >= 0x050000
    else if(event->modifiers() == (Qt::ShiftModifier|Qt::ControlModifier) && event->key() == QVariant(QKeySequence(tr("V", "paste unformated"))).toInt())
        pasteWithoutFormatting();

#else
    else if(event->modifiers() == (Qt::ControlModifier | Qt::ShiftModifier) && event->key() == QKeySequence(tr("V", "paste unformated")))
        pasteWithoutFormatting();

#endif


    else if(event->key() == Qt::Key_Space){
        if(preventDoubleSpaceOption == true)
            preventDoubleSpace();
        else
            QTextEdit::keyPressEvent(event);

    }
    else{
        QTextEdit::keyPressEvent(event);
    }

}
Exemplo n.º 11
0
QString State::toCSS(const QString &gradientFolderPath, const QString &gradientFolderName, const QFont &baseFont)
{
    QString css;
    if (bold())
        css += " font-weight: bold;";
    if (italic())
        css += " font-style: italic;";
    if (underline() && strikeOut())
        css += " text-decoration: underline line-through;";
    else if (underline())
        css += " text-decoration: underline;";
    else if (strikeOut())
        css += " text-decoration: line-through;";
    if (textColor().isValid())
        css += " color: " + textColor().name() + ";";
    if (!fontName().isEmpty()) {
        QString fontFamily = Tools::cssFontDefinition(fontName(), /*onlyFontFamily=*/true);
        css += " font-family: " + fontFamily + ";";
    }
    if (fontSize() > 0)
        css += " font-size: " + QString::number(fontSize()) + "px;";
    if (backgroundColor().isValid()) {
        // Get the colors of the gradient and the border:
        QColor topBgColor;
        QColor bottomBgColor;
        Note::getGradientColors(backgroundColor(), &topBgColor, &bottomBgColor);
        // Produce the CSS code:
        QString gradientFileName = Basket::saveGradientBackground(backgroundColor(), font(baseFont), gradientFolderPath);
        css += " background: " + bottomBgColor.name() + " url('" + gradientFolderName + gradientFileName + "') repeat-x;";
        css += " border-top: solid " + topBgColor.name() + " 1px;";
        css += " border-bottom: solid " + Tools::mixColor(topBgColor, bottomBgColor).name() + " 1px;";
    }

    if (css.isEmpty())
        return "";
    else
        return "   .tag_" + id() + " {" + css + " }\n";
}
Exemplo n.º 12
0
    QVariant data(const QModelIndex &index, int role) const
    {
        if (!m_descriptions || !m_scheme)
            return QVariant();

        const FormatDescription &description = m_descriptions->at(index.row());

        switch (role) {
        case Qt::DisplayRole:
            return description.displayName();
        case Qt::ForegroundRole: {
            QColor foreground = m_scheme->formatFor(description.id()).foreground();
            if (foreground.isValid())
                return foreground;
            else
                return m_scheme->formatFor(C_TEXT).foreground();
        }
        case Qt::BackgroundRole: {
            QColor background = m_scheme->formatFor(description.id()).background();
            if (background.isValid())
                return background;
            else
                break;
        }
        case Qt::FontRole: {
            QFont font = m_baseFont;
            auto format = m_scheme->formatFor(description.id());
            font.setBold(format.bold());
            font.setItalic(format.italic());
            font.setUnderline(format.underlineStyle() != QTextCharFormat::NoUnderline);
            return font;
        }
        case Qt::ToolTipRole: {
            return description.tooltipText();
        }
        }
        return QVariant();
    }
Exemplo n.º 13
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
	// open database connection
    db = QSqlDatabase::addDatabase("QSQLITE");
    db.setDatabaseName("/Users/jdoud/dev/brainstorm.sqlite");
	if(!db.open())
	{
		qDebug() << db.lastError();
		qFatal("Failed to connect.");
	}

	// setup UI
    ui->setupUi(this);
	ui->toolBar->addWidget(ui->comboFonts);
	ui->toolBar->addWidget(ui->comboFontSizes);
	ui->toolBar->addWidget(ui->comboColors);

	// set text editor defaults
	ui->textNote->document()->setIndentWidth(20);
	ui->textNote->setTabStopWidth(20);
	ui->textNote->setTabChangesFocus(false);
	ui->actionIncrease_Indent->setShortcut(Qt::Key_Tab);
	ui->actionDecrease_Indent->setShortcut(Qt::Key_Backtab);

	// setup comboColors
	QPixmap pix(16, 16);
	pix.fill(Qt::white);
	ui->comboColors->addItem(pix, "");
	pix.fill(Qt::black);
	ui->comboColors->addItem(pix, "");
	pix.fill(Qt::red);
	ui->comboColors->addItem(pix, "");
	pix.fill(Qt::blue);
	ui->comboColors->addItem(pix, "");
	pix.fill(Qt::darkGreen);
	ui->comboColors->addItem(pix, "");
	pix.fill(Qt::gray);
	ui->comboColors->addItem(pix, "");


	// create system tray icon
	createActions();
	createTrayIcon();

	// create models
    categoriesModel = new QSqlTableModel();
	categoriesModel->setTable("categories");
	categoriesModel->setSort(1, Qt::AscendingOrder);
	categoriesModel->select();
	ui->listCategories->setModel(categoriesModel);
	ui->listCategories->setModelColumn(1);

    notesModel = new QSqlTableModel();
	notesModel->setTable("notes");
	ui->listNotes->setModel(notesModel);
	ui->listNotes->setModelColumn(2);

    // set splitter size
    QList<int> sizes;
    sizes << 230 << 150;
    ui->splitterLists->setSizes(sizes);
    sizes.clear();
    sizes << 230 << 600;
    ui->splitterNote->setSizes(sizes);

    // connect File menu slots
    connect(ui->actionNew_Category, SIGNAL(triggered()), this, SLOT(newCategory()));
    connect(ui->actionRename_Category, SIGNAL(triggered()), this, SLOT(renameCategory()));
    connect(ui->actionDelete_Category, SIGNAL(triggered()), this, SLOT(deleteCategory()));
    connect(ui->actionNew_Note, SIGNAL(triggered()), this, SLOT(newNote()));
    connect(ui->actionRename_Note, SIGNAL(triggered()), this, SLOT(renameNote()));
    connect(ui->actionSave_Note, SIGNAL(triggered()), this, SLOT(saveNote()));
    connect(ui->actionDelete_Note, SIGNAL(triggered()), this, SLOT(deleteNote()));
    connect(ui->actionQuit, SIGNAL(triggered()), this, SLOT(quit()));
    // connect Edit menu slots	
    connect(ui->actionFind_Replace, SIGNAL(triggered()), this, SLOT(findAndReplace()));
    // connect Format menu slots
    connect(ui->actionBold, SIGNAL(triggered()), this, SLOT(bold()));
    connect(ui->actionItalic, SIGNAL(triggered()), this, SLOT(italic()));
    connect(ui->actionUnderline, SIGNAL(triggered()), this, SLOT(underline()));
    connect(ui->actionStrikethrough, SIGNAL(triggered()), this, SLOT(strikethrough()));
    connect(ui->actionBullet_List, SIGNAL(triggered()), this, SLOT(bulletList()));
    connect(ui->actionNumber_List, SIGNAL(triggered()), this, SLOT(numberList()));
    connect(ui->actionIncrease_Indent, SIGNAL(triggered()), this, SLOT(increaseIndent()));
    connect(ui->actionDecrease_Indent, SIGNAL(triggered()), this, SLOT(decreaseIndent()));
    connect(ui->actionShow_Colors, SIGNAL(triggered()), this, SLOT(showColors()));
    connect(ui->actionShow_Fonts, SIGNAL(triggered()), this, SLOT(showFonts()));
    connect(ui->actionIncrease_Font, SIGNAL(triggered()), this, SLOT(increaseFont()));
    connect(ui->actionDecrease_Font, SIGNAL(triggered()), this, SLOT(decreaseFont()));
    connect(ui->actionReset_Font, SIGNAL(triggered()), this, SLOT(resetFont()));
    connect(ui->actionAlign_Left, SIGNAL(triggered()), this, SLOT(alignLeft()));
    connect(ui->actionAlign_Center, SIGNAL(triggered()), this, SLOT(alignCenter()));
    connect(ui->actionAlign_Right, SIGNAL(triggered()), this, SLOT(alignRight()));
    connect(ui->actionAlign_Justify, SIGNAL(triggered()), this, SLOT(alignJustify()));
    // connect View menu slots
    connect(ui->actionHide_Window, SIGNAL(triggered()), this, SLOT(hide()));
    connect(ui->actionPrevious_Category, SIGNAL(triggered()), this, SLOT(previousCategory()));
    connect(ui->actionNext_Category, SIGNAL(triggered()), this, SLOT(nextCategory()));
    connect(ui->actionPrevious_Note, SIGNAL(triggered()), this, SLOT(previousNote()));
    connect(ui->actionNext_Note, SIGNAL(triggered()), this, SLOT(nextNote()));
    // connect Help menu slots
    connect(ui->actionAbout_Brainstorm, SIGNAL(triggered()), this, SLOT(aboutBrainstorm()));
    connect(ui->actionAbout_Qt, SIGNAL(triggered()), this, SLOT(aboutQt()));
	// connect application slots
	connect(ui->textNote, SIGNAL(cursorPositionChanged()), this, SLOT(updateMenus()));
	connect(ui->textNote, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(updateMenus()));
    connect(ui->comboFonts, SIGNAL(activated(QString)), this, SLOT(setFont(QString)));
    connect(ui->comboFontSizes, SIGNAL(activated(QString)), this, SLOT(setFontSize(QString)));
    connect(ui->comboColors, SIGNAL(activated(int)), this, SLOT(setFontColor(int)));
	// connect category list slots
	connect(ui->listCategories->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(updateNoteList(QModelIndex)));
	// connect note list slots
	connect(ui->listNotes->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(updateNoteText(QModelIndex)));
	// connect text slots
	ui->textNote->installEventFilter((this));
	// connect system tray icon
    connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason)));

	// initialize default data
	ui->listCategories->selectionModel()->setCurrentIndex(categoriesModel->index(0, 1), QItemSelectionModel::SelectCurrent);

}
Exemplo n.º 14
0
#ifdef MANITOU_DATADIR
#include "icons.h"
#else
 #ifndef HTML_ICON
   #define HTML_ICON(a) QIcon(a)
 #endif
#endif

struct html_editor::action_type
html_editor::m_action_definitions[] = {
#define QN QT_TR_NOOP
#define NA QWebPage::NoWebAction

  // {name, shortcut, icon, WebAction
  {QN("Bold"), QN("Ctrl+B"), "icon-bold.png", SLOT(bold()), NA }
  ,{QN("Italic"), QN("Ctrl+I"), "icon-italic.png", SLOT(italic()), NA }
  ,{QN("Underline"), QN("Ctrl+U"), "icon-underline.png", SLOT(underline()), NA }
  ,{QN("Strike through"), QN("Ctrl+S"), "icon-strikethrough.png", SLOT(strikethrough()) , NA}
  ,{QN("Superscript"), NULL, "icon-superscript.png", SLOT(superscript()), NA }
  ,{QN("Subscript"), NULL, "icon-subscript.png", SLOT(subscript()), NA }

  // separator before 6
  ,{QN("Set foreground color"), NULL, "icon-foreground-color.png", SLOT(foreground_color()), NA }
  ,{QN("Set background color"), NULL, "icon-background-color.png", SLOT(background_color()), NA }
  ,{QN("Insert image"), NULL, "icon-image.png", SLOT(insert_image()), NA }
  ,{QN("Insert link"), NULL, "icon-link.png", SLOT(insert_link()), NA }
  ,{QN("Insert horizontal rule"), NULL, "icon-hr.png", SLOT(insert_hr()), NA }
  ,{QN("Insert unordered list"), NULL, "icon-bullet-list.png", SLOT(insert_unordered_list()), NA }
  ,{QN("Insert ordered list"), NULL, "icon-ordered-list.png", SLOT(insert_ordered_list()), NA }
  ,{QN("Remove format"), NULL, "icon-eraser.png", SLOT(remove_format()), NA }
  ,{QN("Cut"), NULL, "icon-cut.png", NULL, QWebPage::Cut }
Exemplo n.º 15
0
//! [4]
void MainWindow::createActions()
{
//! [5]
    newAct = new QAction(tr("&New"), this);
    newAct->setShortcuts(QKeySequence::New);
    newAct->setStatusTip(tr("Create a new file"));
    connect(newAct, SIGNAL(triggered()), this, SLOT(newFile()));
//! [4]

    openAct = new QAction(tr("&Open..."), this);
    openAct->setShortcuts(QKeySequence::Open);
    openAct->setStatusTip(tr("Open an existing file"));
    connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
//! [5]

    saveAct = new QAction(tr("&Save"), this);
    saveAct->setShortcuts(QKeySequence::Save);
    saveAct->setStatusTip(tr("Save the document to disk"));
    connect(saveAct, SIGNAL(triggered()), this, SLOT(save()));

    printAct = new QAction(tr("&Print..."), this);
    printAct->setShortcuts(QKeySequence::Print);
    printAct->setStatusTip(tr("Print the document"));
    connect(printAct, SIGNAL(triggered()), this, SLOT(print()));

    exitAct = new QAction(tr("E&xit"), this);
    exitAct->setShortcuts(QKeySequence::Quit);
    exitAct->setStatusTip(tr("Exit the application"));
    connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));

    undoAct = new QAction(tr("&Undo"), this);
    undoAct->setShortcuts(QKeySequence::Undo);
    undoAct->setStatusTip(tr("Undo the last operation"));
    connect(undoAct, SIGNAL(triggered()), this, SLOT(undo()));

    redoAct = new QAction(tr("&Redo"), this);
    redoAct->setShortcuts(QKeySequence::Redo);
    redoAct->setStatusTip(tr("Redo the last operation"));
    connect(redoAct, SIGNAL(triggered()), this, SLOT(redo()));

    cutAct = new QAction(tr("Cu&t"), this);
    cutAct->setShortcuts(QKeySequence::Cut);
    cutAct->setStatusTip(tr("Cut the current selection's contents to the "
                            "clipboard"));
    connect(cutAct, SIGNAL(triggered()), this, SLOT(cut()));

    copyAct = new QAction(tr("&Copy"), this);
    copyAct->setShortcuts(QKeySequence::Copy);
    copyAct->setStatusTip(tr("Copy the current selection's contents to the "
                             "clipboard"));
    connect(copyAct, SIGNAL(triggered()), this, SLOT(copy()));

    pasteAct = new QAction(tr("&Paste"), this);
    pasteAct->setShortcuts(QKeySequence::Paste);
    pasteAct->setStatusTip(tr("Paste the clipboard's contents into the current "
                              "selection"));
    connect(pasteAct, SIGNAL(triggered()), this, SLOT(paste()));

    boldAct = new QAction(tr("&Bold"), this);
    boldAct->setCheckable(true);
    boldAct->setShortcut(QKeySequence::Bold);
    boldAct->setStatusTip(tr("Make the text bold"));
    connect(boldAct, SIGNAL(triggered()), this, SLOT(bold()));

    QFont boldFont = boldAct->font();
    boldFont.setBold(true);
    boldAct->setFont(boldFont);

    italicAct = new QAction(tr("&Italic"), this);
    italicAct->setCheckable(true);
    italicAct->setShortcut(QKeySequence::Italic);
    italicAct->setStatusTip(tr("Make the text italic"));
    connect(italicAct, SIGNAL(triggered()), this, SLOT(italic()));

    QFont italicFont = italicAct->font();
    italicFont.setItalic(true);
    italicAct->setFont(italicFont);

    setLineSpacingAct = new QAction(tr("Set &Line Spacing..."), this);
    setLineSpacingAct->setStatusTip(tr("Change the gap between the lines of a "
                                       "paragraph"));
    connect(setLineSpacingAct, SIGNAL(triggered()), this, SLOT(setLineSpacing()));

    setParagraphSpacingAct = new QAction(tr("Set &Paragraph Spacing..."), this);
    setLineSpacingAct->setStatusTip(tr("Change the gap between paragraphs"));
    connect(setParagraphSpacingAct, SIGNAL(triggered()),
            this, SLOT(setParagraphSpacing()));

    aboutAct = new QAction(tr("&About"), this);
    aboutAct->setStatusTip(tr("Show the application's About box"));
    connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));

    aboutQtAct = new QAction(tr("About &Qt"), this);
    aboutQtAct->setStatusTip(tr("Show the Qt library's About box"));
    connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
    connect(aboutQtAct, SIGNAL(triggered()), this, SLOT(aboutQt()));

    leftAlignAct = new QAction(tr("&Left Align"), this);
    leftAlignAct->setCheckable(true);
    leftAlignAct->setShortcut(tr("Ctrl+L"));
    leftAlignAct->setStatusTip(tr("Left align the selected text"));
    connect(leftAlignAct, SIGNAL(triggered()), this, SLOT(leftAlign()));

    rightAlignAct = new QAction(tr("&Right Align"), this);
    rightAlignAct->setCheckable(true);
    rightAlignAct->setShortcut(tr("Ctrl+R"));
    rightAlignAct->setStatusTip(tr("Right align the selected text"));
    connect(rightAlignAct, SIGNAL(triggered()), this, SLOT(rightAlign()));

    justifyAct = new QAction(tr("&Justify"), this);
    justifyAct->setCheckable(true);
    justifyAct->setShortcut(tr("Ctrl+J"));
    justifyAct->setStatusTip(tr("Justify the selected text"));
    connect(justifyAct, SIGNAL(triggered()), this, SLOT(justify()));

    centerAct = new QAction(tr("&Center"), this);
    centerAct->setCheckable(true);
    centerAct->setShortcut(tr("Ctrl+E"));
    centerAct->setStatusTip(tr("Center the selected text"));
    connect(centerAct, SIGNAL(triggered()), this, SLOT(center()));

//! [6] //! [7]
    alignmentGroup = new QActionGroup(this);
    alignmentGroup->addAction(leftAlignAct);
    alignmentGroup->addAction(rightAlignAct);
    alignmentGroup->addAction(justifyAct);
    alignmentGroup->addAction(centerAct);
    leftAlignAct->setChecked(true);
//! [6]
}
Exemplo n.º 16
0
void FrmLegend::init()
{
    QFont normal("Times", 10, QFont::Normal);
    QFont italic("Times", 10, -1, true);
    QFont serifFont("Times", 13, QFont::Bold);

    //TODO: return errors here!

    levels = new QTreeWidgetItem(treeWidget);
    initTreeParent(serifFont,tr("Levels"),
        tr("Different herarchical instances"),levels);

    root = new QTreeWidgetItem(levels);
    initTreeChild(normal, italic,QIcon(QString::fromUtf8(":/app_new/exec.png")),tr("Root"),
        tr("Frame Root"),root);

    bin = new QTreeWidgetItem(levels);
    initTreeChild(normal, italic,QIcon(QString::fromUtf8(":/app_new/trashcan.png")),tr("Bin"),
        tr("Recycled Bin, where we store (permanent or temporarily) inactive instances"),bin);

    gls = new QTreeWidgetItem(levels);
    initTreeChild(normal, italic,QIcon(QString::fromUtf8(":/app_new/gls.png")),tr("Group of Landing Sites"),
        tr("A Group of Landing Sites, aggregating multiple landing sites"),gls);

    ls = new QTreeWidgetItem(levels);
    initTreeChild(normal, italic,QIcon(QString::fromUtf8(":/app_new/ls.png")),tr("Landing Site"),
        tr("A Site: can be a port, a collector vessel or simply a virtual aggregation of vessels"),ls);

    vessel = new QTreeWidgetItem(levels);
    initTreeChild(normal, italic,QIcon(QString::fromUtf8(":/app_new/vessel.png")),tr("Vessel"),
        tr("A vessel"),vessel);

    recycled = new QTreeWidgetItem(treeWidget);
    initTreeParent(serifFont,tr("Recycled"),
        tr("Items that are inactive (on the recycle bin)"),recycled);

    glsd = new QTreeWidgetItem(recycled);
    initTreeChild(normal, italic,QIcon(QString::fromUtf8(":/app_new/glsd.png")),tr("Group of Landing Sites"),
        tr("An inactive Group of Landing Sites"),glsd);

    lsd = new QTreeWidgetItem(recycled);
    initTreeChild(normal, italic,QIcon(QString::fromUtf8(":/app_new/lsd.png")),tr("Landing Site"),
        tr("An inactive Landing Site"),lsd);

    vesseld = new QTreeWidgetItem(recycled);
    initTreeChild(normal, italic,QIcon(QString::fromUtf8(":/app_new/vesseld.png")),tr("Vessel"),
        tr("An inactive vessel"),vesseld);

    status = new QTreeWidgetItem(treeWidget);
    initTreeParent(serifFont,tr("Vessel Status"),
        tr("Special statuses of the vessels, regarding different characteristics"),status);

    unmovable = new QTreeWidgetItem(status);
    initTreeChild(normal, italic,QIcon(QString::fromUtf8(":/app_new/vesself.png")),tr("Unmovable"),
        tr("A vessel that is flaged as unmovable (locked)"),unmovable);

    merged = new QTreeWidgetItem(status);
    initTreeChild(normal, italic,QIcon(QString::fromUtf8(":/app_new/unmovable.png")),tr("Merged"),
        tr("A vessel that is is merged from another temporary frame"),merged);

    treeWidget->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);

    treeWidget->expandAll();

    for (int col=0; col < treeWidget->model()->columnCount(); ++col) {
        treeWidget->header()->setResizeMode(col,QHeaderView::ResizeToContents);
    }

}
Exemplo n.º 17
0
void graph(FILE * fp)
{
   static char buf[BUFLNG], arg[BUFLNG / 2], xtype[16], ytype[16];
   static double xa, ya, xap, yap, xmin, xmax, ymin, ymax;
   static double xs = -NSCALE, ys = -NSCALE;
   int n, c;
   char *s, *p;
   double x, y, lpt, th, dt, lscale, rad;
   int is_grid, old_lbl = 0;
   char xory;

   h *= fct;
   w *= fct;

   for (n = 0; (s = fgets(buf, BUFLNG, fp));) {
      s = getarg(s, arg);
      if (s == NULL || *arg == '#');    /* comment line */
      else if ((!is_t && strcmp(arg, "x") == 0)
               || (is_t && strcmp(arg, "y") == 0)) {
         s = gettyp(s, xtype);
         if (sscanf(s, "%lf %lf %lf", &xmin, &xmax, &xa) != 3)
            xa = xmin;
         if (strncmp(xtype, "log", 3) == 0) {
            xmin = log10(xmin);
            xmax = log10(xmax);
            xa = log10(xa);
            is_xlog = (xtype[3] == '*') ? -1 : 1;
         }
         xfct = xl / (xmax - xmin);
         xap = (xa - xmin) * xfct;
         x00 = -xmin * xfct;
      } else if ((!is_t && strcmp(arg, "y") == 0)
                 || (is_t && strcmp(arg, "x") == 0)) {
         s = gettyp(s, ytype);
         if (sscanf(s, "%lf %lf %lf", &ymin, &ymax, &ya) != 3)
            ya = ymin;
         if (strncmp(ytype, "log", 3) == 0) {
            ymin = log10(ymin);
            ymax = log10(ymax);
            ya = log10(ya);
            is_ylog = (ytype[3] == '*') ? -1 : 1;
         }
         yfct = (yl) ? yl / (ymax - ymin) : 0;
         yap = (ya - ymin) * yfct;
         y00 = -ymin * yfct;
      } else if ((!is_t && strncmp(arg, "xscale", 6) == 0)
                 || (is_t && strncmp(arg, "yscale", 6) == 0)) {
         is_grid = *(arg + 6);
         if (type < 0 || (ya != ymin && ya != ymax)) {
            plot(0.0, yap, 3);
            plot(xl, yap, 2);
         }
         ys = yap - h - MSCALE;
         while ((s = getarg(s, p = arg)) != NULL) {
            if (*p != '"') {
               x = atof((is_number(*p)) ? p : p + 1);
               if (strncmp(xtype, "mel", 3) == 0)
                  x = argapf(x / nz(xmax, xmin),
                             atof(xtype + 3)) * nz(xmax, xmin);
               else if (is_xlog)
                  x = log10(x);
               x = (x - xmin) * xfct;
               lscale = (*p == 's') ? LSCALE / 2 : LSCALE;
               if (*p != '\\' && *p != '@') {
                  plot(x, yap, 3);
                  plot(x, yap + lscale, 2);
                  if (type > 0 && !is_grid && yap == 0) {
                     plot(x, yl, 3);
                     plot(x, yl - lscale, 2);
                  }
               } else if (*p == '\\')
                  ++p;
            }
            if (is_number(*p) || *p++ == '"')
               _symbol(x - sleng(p, h, w) / 2, ys - ysadj(), p, h, w, 0.0);
         }
      } else if ((!is_t && strncmp(arg, "yscale", 6) == 0)
                 || (is_t && strncmp(arg, "xscale", 6) == 0)) {
         is_grid = *(arg + 6);
         if (type < 0 || (xa != xmin && xa != xmax)) {
            plot(xap, 0.0, 3);
            plot(xap, yl, 2);
         }
         while ((s = getarg(s, p = arg)) != NULL) {
            if (*p != '"') {
               y = atof((is_number(*p)) ? p : p + 1);
               if (strncmp(ytype, "mel", 3) == 0)
                  y = argapf(y / nz(ymax, ymin),
                             atof(ytype + 3)) * nz(ymax, ymin);
               else if (is_ylog)
                  y = log10(y);
               y = (y - ymin) * yfct;
               lscale = (*p == 's') ? LSCALE / 2 : LSCALE;
               if (*p != '\\' && *p != '@') {
                  plot(xap, y, 3);
                  plot(xap + lscale, y, 2);
                  if (type > 0 && !is_grid && xap == 0) {
                     plot(xl, y, 3);
                     plot(xl - lscale, y, 2);
                  }
               } else if (*p == '\\')
                  ++p;
            }
            if (is_number(*p) || *p++ == '"') {
               x = xap - sleng(p, h, w) - MSCALE;
               if (x < xs)
                  xs = x;
               _symbol(x, y - h * 0.5, p, h, w, 0.0);
            }
         }
      } else if (strcmp(arg + 1, "grid") == 0) {
         draw_fig0(xbuf, ybuf, n, wf, hf, fct);
         if ((!is_t && (*arg == 'x')) || (is_t && (*arg == 'y'))) {
            ybuf[0] = 0;
            ybuf[1] = yl;
            while ((s = getarg(s, arg)) != NULL) {
               x = atof(arg);
               if (is_xlog)
                  x = log10(x);
               xbuf[0] = xbuf[1]
                   = (x - xmin) * xfct;
               draw_fig0(xbuf, ybuf, 2, wf, hf, fct);
            }
         } else {
            xbuf[0] = 0;
            xbuf[1] = xl;
            while ((s = getarg(s, arg)) != NULL) {
               y = atof(arg);
               if (is_ylog)
                  y = log10(y);
               ybuf[0] = ybuf[1]
                   = (y - ymin) * yfct;
               draw_fig0(xbuf, ybuf, 2, wf, hf, fct);
            }
         }
         n = 0;
      } else if (strcmp(arg + 1, "circle") == 0) {
         xory = *arg;
         s = getarg(s, arg);
         x = xt(atof(arg));
         s = getarg(s, arg);
         y = yt(atof(arg));
         swap(&x, &y);
         x = xfct * x + x00;
         y = yfct * y + y00;
         while ((s = getarg(s, arg)) != NULL) {
            if ((!is_t && xory == 'x') || (is_t && xory == 'y'))
               rad = xt(atof(arg)) * xfct;
            else
               rad = yt(atof(arg)) * yfct;
            pntstyl(ptyp);
            circle(x, y, rad, rad, 0., 360.);
         }
      } else if (strcmp(arg, "circle") == 0) {
         s = getarg(s, arg);
         x = xt(atof(arg));
         s = getarg(s, arg);
         y = yt(atof(arg));
         swap(&x, &y);
         x = xfct * x + x00;
         y = yfct * y + y00;
         while ((s = getarg(s, arg)) != NULL) {
            rad = atof(arg);
            pntstyl(ptyp);
            circle(x, y, rad, rad, 0., 360.);
         }
      } else if (strcmp(arg + 1, "name") == 0) {
         s = getname(s, p = arg + 1);
         if ((!is_t && *arg == 'x') || (is_t && *arg == 'y'))
            _symbol((xl - sleng(s, h, w)) / 2,
                    (*p) ? -atof(p) - h : ys - h - NSCALE, s, h, w, 0.0);
         else
            _symbol((*p) ? -atof(p) : xs - MSCALE,
                    (yl - sleng(s, h, w)) / 2, s, h, w, 90.0);
      } else if (strncmp(arg, "title", 5) == 0 || strncmp(arg, "print", 5) == 0) {
         sscanf(s, "%lf %lf", &x, &y);
         swap(&x, &y);
         if (*arg == 'p') {
            x = xfct * xt(x) + x00;
            y = yfct * yt(y) + y00;
         }
         s = gettxt_fig(s);
         th = getarg(s + strlen(s) + 1, arg) ? atof(arg) : 0;
         if (*(arg + 5)) {
            x -= rx(LADJ * h / 2, h / 2, th);
            y -= ry(LADJ * h / 2, h / 2, th);
         }
         _symbol(x, y, s, h, w, th);
      } else if (strcmp(arg, "eod") == 0 || strcmp(arg, "EOD") == 0) {
         draw_fig0(xbuf, ybuf, n, wf, hf, fct);
         n = 0;
      } else if (strcmp(arg, "pen") == 0) {
         n = flush(xbuf, ybuf, n, wf, hf, fct);
         pen(atoi(s));
      } else if (strcmp(arg, "join") == 0) {
         n = flush(xbuf, ybuf, n, wf, hf, fct);
         join(atoi(s));
      } else if (strcmp(arg, "csize") == 0) {
         if (sscanf(s, "%lf %lf", &h, &w) != 2)
            w = h;
      } else if (strcmp(arg, "hight") == 0) {
         if (sscanf(s, "%lf %lf", &mh, &mw) != 2)
            mw = mh;
      } else if (strcmp(arg, "line") == 0) {
         n = flush(xbuf, ybuf, n, wf, hf, fct);
         if (sscanf(s, "%d %lf", &ltype, &lpt) != 2) {
            if (ltype > 0)
               lpt = lpit[ltype - 1];
         }
         if (--ltype >= 0)
            mode(lmod[ltype], lpt);
      } else if (strcmp(arg, "italic") == 0)
         italic(atof(s));
      else if (strcmp(arg, "mark") == 0) {
         while (*s == ' ' || *s == '\t')
            ++s;
         if (*s == '\\' && *(s + 1) == '0')
            *label = '\0';
         else
            strcpy(label, s);
      } else if (strcmp(arg, "paint") == 0) {
         sscanf(s, "%d %lf %lf", &ptyp, &dhat, &that);
      } else if (strcmp(arg, "clip") == 0) {
         draw_fig0(xbuf, ybuf, n, wf, hf, fct);
         for (n = 0; (s = getarg(s, arg)) != NULL; ++n) {
            x = xt(atof(arg));
            if ((s = getarg(s, arg)) == NULL)
               break;
            y = yt(atof(arg));
            swap(&x, &y);
            xbuf[n] = xfct * x + x00;
            ybuf[n] = yfct * y + y00;
         }
         if (n == 0) {
            xclip0 = yclip0 = 0;
            xclip1 = xl;
            yclip1 = yl;
            swap(&xclip1, &yclip1);
         } else if (n == 2) {
            xclip0 = xbuf[0];
            yclip0 = ybuf[0];
            xclip1 = xbuf[1];
            yclip1 = ybuf[1];
         }
         n = 0;
      } else if (strcmp(arg, "box") == 0) {
         draw_fig0(xbuf, ybuf, n, wf, hf, fct);
         for (n = 0; (s = getarg(s, arg)) != NULL; ++n) {
            x = xt(atof(arg));
            if ((s = getarg(s, arg)) == NULL)
               break;
            y = yt(atof(arg));
            swap(&x, &y);
            xbuf[n] = xfct * x + x00;
            ybuf[n] = yfct * y + y00;
         }
         if (n == 2) {
            xbuf[2] = xbuf[1];
            ybuf[3] = ybuf[2] = ybuf[1];
            ybuf[1] = ybuf[0];
            xbuf[3] = xbuf[0];
            n = 4;
         }
         polyg(xbuf, ybuf, n, wf, hf, fct);
         n = 0;
      } else {
         x = xt(atof(arg));
         s = getarg(s, arg);
         y = yt(atof(arg));
         swap(&x, &y);
         xbuf[n] = x = xfct * x + x00;
         ybuf[n] = y = yfct * y + y00;
         if (is_in(x, y) && ((s = getarg(s, arg))
                             || *label || old_lbl > 0)) {
            c = 0;
            if (s || *label) {
               if (s == NULL)
                  s = getarg(label, arg);
               if (*arg == '\\' && (abs(c = atoi(arg + 1))) < 16)
                  mark(abs(c), &x, &y, 1, mh, 1);
               else if (abs(c) == 16) {
                  pntstyl(ptyp);
                  circle(x, y, mh / 2, mh / 2, 0., 360.);
               } else {
                  if (c) {
                     *arg = c;
                     *(arg + 1) = '\0';
                  }
                  _symbol(x - LADJ * h / 2, y - w / 2, arg, h, w, atof(s));
               }
            }
            if (c > 0)
               n = flush(xbuf, ybuf, n, wf, hf, fct);
            if ((c > 0 || old_lbl > 0) && n) {
               dt = atan2(y - ybuf[0], x - xbuf[0]);
               if (old_lbl > 0) {
                  xbuf[0] += MADJ * mh * cos(dt);
                  ybuf[0] += MADJ * mh * sin(dt);
               }
               if (c > 0) {
                  xbuf[1] -= MADJ * mh * cos(dt);
                  ybuf[1] -= MADJ * mh * sin(dt);
               }
               draw_fig0(xbuf, ybuf, 2, wf, hf, fct);
               xbuf[0] = x;
               ybuf[0] = y;
               n = 0;
            }
            old_lbl = c;
         }
         if (++n >= BUFLNG)
            n = flush(xbuf, ybuf, n, wf, hf, fct);
      }
   }
   draw_fig0(xbuf, ybuf, n, wf, hf, fct);
}
Exemplo n.º 18
0
void freetype::italic(bool _italic)
{
    italic(_italic ? 0.382 : 0);
}
Exemplo n.º 19
0
/*
 * This method contains a code snippet that was lifted and modified from ReText
 */
void MarkdownEditor::keyPressEvent(QKeyEvent* e)
{
    int key = e->key();

    QTextCursor cursor(this->textCursor());

    switch (key)
    {
        case Qt::Key_Return:
            if (!cursor.hasSelection())
            {
                if (e->modifiers() & Qt::ShiftModifier)
                {
                    // Insert Markdown-style line break
                    cursor.insertText("  ");
                }

                if (e->modifiers() & Qt::ControlModifier)
                {
                    cursor.insertText("\n");
                }
                else
                {
                    handleCarriageReturn();
                }
            }
            else
            {
                QPlainTextEdit::keyPressEvent(e);
            }
            break;
        case Qt::Key_Backspace:
            if (!handleBackspaceKey())
            {
                QPlainTextEdit::keyPressEvent(e);
            }
            break;
        case Qt::Key_Tab:
            handleIndent();
            break;
        case Qt::Key_Backtab:
            handleUnindent();
            break;
        case Qt::Key_Greater:
            if (cursor.hasSelection())
            {
                if (e->modifiers() & Qt::ControlModifier)
                {
                    removeBlockquote();
                }
                else
                {
                    insertBlockquote();
                }
            }
            else
            {
                QPlainTextEdit::keyPressEvent(e);
            }
            break;
        case Qt::Key_D:
            if (!(e->modifiers() & Qt::ControlModifier) || !toggleTaskComplete())
            {
                QPlainTextEdit::keyPressEvent(e);
            }
            break;
        default:
            if
            (
                (e->text().size() == 1) &&
                this->markupPairs.contains(e->text().at(0))
            )
            {
                if (!insertPairedCharacters(e->text().at(0)))
                {
                    QPlainTextEdit::keyPressEvent(e);
                }
            }
            else if (e->matches(QKeySequence::Cut))
            {
                cut();
            }
            else if (e->matches(QKeySequence::Bold))
            {
                bold();
            }
            else if (e->matches(QKeySequence::Italic))
            {
                italic();
            }
            else
            {
                QPlainTextEdit::keyPressEvent(e);
            }
            break;
    }
}
Exemplo n.º 20
0
// -------------------------------------------------------------------------------
void Editor::keyPressEvent( QKeyEvent* pKeyEv )
// -------------------------------------------------------------------------------
{
   if ( !pKeyEv )
      return;

   //std::cout<<"key = "<<pKeyEv->key();

   // If
   //   CTRL + S (save)  or
   //   ALT + left  cursor (history one back / previous entry) or
   //   ALT + right cursor (history one forward / next entry)
   //   CTRL + F (shortcut for "Searching")
   // is called, then ignore it.
   if( ( (pKeyEv->state() == Qt::ControlButton)  &&  (pKeyEv->key() == Qt::Key_S) ) ||
       ( (pKeyEv->state() == Qt::AltButton)      &&  (pKeyEv->key() == Qt::Key_Left) ) ||
       ( (pKeyEv->state() == Qt::AltButton)      &&  (pKeyEv->key() == Qt::Key_Right) ) ||
       ( (pKeyEv->state() == Qt::ControlButton)  &&  (pKeyEv->key() == Qt::Key_F) ) )
   {
      //std::cout<<" -> ignore"<<std::endl;
      pKeyEv->ignore();
   }
/*

   // if the shift button is down while pressing return or enter, insert a new paragraph
   else if  ( ( (pKeyEv->state() == Qt::ShiftButton ) || (pKeyEv->state() == Qt::ControlButton ) )
              &&
              ( (Qt::Key_Return == pKeyEv->key()) || (Qt::Key_Enter == pKeyEv->key()) )
            )
   {
      if ( LINEBREAK_MODERN == meLinebreakMode )
      {
         //std::cout<<" -> shift/ctrl + enter/return"<<std::endl;
         Q3TextEdit::keyPressEvent( new QKeyEvent( pKeyEv->type(),  Qt::Key_Return,
                                                  pKeyEv->ascii(), 0 ) );
      }
      else
      {
         Q3TextEdit::keyPressEvent( pKeyEv );
      }
   }
*/
   // Workaround Q3TextEdit's default Enter key behavior of adding a paragraph
   // Add control key pressed to it
   else if  ( (Qt::Key_Return == pKeyEv->key()) || (Qt::Key_Enter == pKeyEv->key()) )
   {
         Q3TextEdit::keyPressEvent( new QKeyEvent( pKeyEv->type(),  Qt::Key_Return,
                                                  pKeyEv->ascii(), Qt::ControlButton ) );
   }

   // CTRL + A -> select all
   else if ( (Qt::ControlButton == pKeyEv->state()) && (Qt::Key_A == pKeyEv->key()) )
   {
      selectAll();
   }

   // CTRL + B -> bold
   else if ( (Qt::ControlButton == pKeyEv->state()) && (Qt::Key_B == pKeyEv->key()) )
   {
      if ( Qt::RichText == textFormat() )
         setBold( !bold() );
   }

   // CTRL + I -> italic
   else if ( (Qt::ControlButton == pKeyEv->state()) && (Qt::Key_I == pKeyEv->key()) )
   {
      if ( Qt::RichText == textFormat() )
         setItalic( !italic() );
   }

   // CTRL + U -> underline
   else if ( (Qt::ControlButton == pKeyEv->state()) && (Qt::Key_U == pKeyEv->key()) )
   {
      if ( Qt::RichText == textFormat() )
         setUnderline( !underline() );
   }

   else
   {
      // otherwise call the super-method
      //std::cout<<std::endl;
      Q3TextEdit::keyPressEvent( pKeyEv );
   }
}
Exemplo n.º 21
0
int
main(int argc, char **argv) {
    QApplication a( argc, argv );
    QWidget w;
    QVBoxLayout *layout = new QVBoxLayout(&w);

    // with bug and direct rendering
    FontDisplay fd1(true, true);
    layout->addWidget(&fd1);

    FontDisplay fd2(false, true);
    layout->addWidget(&fd2);

    // with bug and indirect rendering: the real problem
    FontDisplay fd3(true, false);
    layout->addWidget(&fd3);

    FontDisplay fd4(false, false);
    layout->addWidget(&fd4);

    QLineEdit qle;
    layout->addWidget(&qle);

    QObject::connect(&qle, SIGNAL(textChanged(const QString &)),
                     &fd1,  SLOT(setText(const QString &)));
    QObject::connect(&qle, SIGNAL(textChanged(const QString &)),
                     &fd2,  SLOT(setText(const QString &)));
    QObject::connect(&qle, SIGNAL(textChanged(const QString &)),
                     &fd3,  SLOT(setText(const QString &)));
    QObject::connect(&qle, SIGNAL(textChanged(const QString &)),
                     &fd4,  SLOT(setText(const QString &)));

    QHBoxLayout *hlayout = new QHBoxLayout();
    layout->addLayout(hlayout);

    QCheckBox bold("bold");
    hlayout->addWidget(&bold);

    QObject::connect(&bold, SIGNAL(stateChanged(int)),
                     &fd1, SLOT(setBold(bool)));
    QObject::connect(&bold, SIGNAL(stateChanged(int)),
                     &fd2, SLOT(setBold(bool)));
    QObject::connect(&bold, SIGNAL(stateChanged(int)),
                     &fd3, SLOT(setBold(bool)));
    QObject::connect(&bold, SIGNAL(stateChanged(int)),
                     &fd4, SLOT(setBold(bool)));

    QCheckBox italic("italic");
    hlayout->addWidget(&italic);

    QObject::connect(&italic, SIGNAL(stateChanged(int)),
                     &fd1, SLOT(setItalic(bool)));
    QObject::connect(&italic, SIGNAL(stateChanged(int)),
                     &fd2, SLOT(setItalic(bool)));
    QObject::connect(&italic, SIGNAL(stateChanged(int)),
                     &fd3, SLOT(setItalic(bool)));
    QObject::connect(&italic, SIGNAL(stateChanged(int)),
                     &fd4, SLOT(setItalic(bool)));

    QSpinBox *fontsize = new QSpinBox(&w);
    fontsize->setValue(12);
    fontsize->setMinimum(1);
    hlayout->addWidget(fontsize);

    QObject::connect(fontsize, SIGNAL(valueChanged(int)),
                     &fd1, SLOT(setPointSize(int)));
    QObject::connect(fontsize, SIGNAL(valueChanged(int)),
                     &fd2, SLOT(setPointSize(int)));
    QObject::connect(fontsize, SIGNAL(valueChanged(int)),
                     &fd3, SLOT(setPointSize(int)));
    QObject::connect(fontsize, SIGNAL(valueChanged(int)),
                     &fd4, SLOT(setPointSize(int)));

    w.show();
    return a.exec();
}