Example #1
0
CharCreateDialog::CharCreateDialog(Window *parent, int slot, Gender gender):
    Window(_("Create Character"), true, parent),
    mSlot(slot)
{
    mPlayer = new Player(0, 0, NULL);
    mPlayer->setGender(gender);

    int numberOfHairColors = ColorDB::size();

    mPlayer->setHairStyle(rand() % mPlayer->getNumOfHairstyles(),
                          rand() % numberOfHairColors);

    mNameField = new TextField("");
    mNameLabel = new Label(_("Name:"));
    mNextHairColorButton = new Button(">", "nextcolor", this);
    mPrevHairColorButton = new Button("<", "prevcolor", this);
    mHairColorLabel = new Label(_("Hair Color:"));
    mNextHairStyleButton = new Button(">", "nextstyle", this);
    mPrevHairStyleButton = new Button("<", "prevstyle", this);
    mHairStyleLabel = new Label(_("Hair Style:"));
    mCreateButton = new Button(_("Create"), "create", this);
    mCancelButton = new Button(_("Cancel"), "cancel", this);
    mBeingBox = new BeingBox(mPlayer);

    mBeingBox->setWidth(74);

    mNameField->setActionEventId("create");
    mNameField->addActionListener(this);

    fontChanged();

    setLocationRelativeTo(getParent());
    setVisible(true);

    mNameField->requestFocus();
}
ApplicationSettings::ApplicationSettings(QObject *parent): QObject(parent),
     m_baseFontSizeMin(-7), m_baseFontSizeMax(7),
     m_config(QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) +
              "/gcompris/" + GCOMPRIS_APPLICATION_NAME + ".conf", QSettings::IniFormat)
{
    // initialize from settings file or default

    // general group
    m_config.beginGroup(GENERAL_GROUP_KEY);
    m_isAudioEffectsEnabled = m_config.value(ENABLE_AUDIO_EFFECTS_KEY, true).toBool();
    m_isFullscreen = m_config.value(FULLSCREEN_KEY, true).toBool();
	m_isAudioVoicesEnabled = m_config.value(ENABLE_AUDIO_VOICES_KEY, true).toBool();
    m_isVirtualKeyboard = m_config.value(VIRTUALKEYBOARD_KEY,
            ApplicationInfo::getInstance()->isMobile()).toBool();
    m_locale = m_config.value(LOCALE_KEY, GC_DEFAULT_LOCALE).toString();
    m_font = m_config.value(FONT_KEY, GC_DEFAULT_FONT).toString();
    m_fontCapitalization = m_config.value(FONT_CAPITALIZATION, GC_DEFAULT_FONT_CAPITALIZATION).toUInt();
    m_isEmbeddedFont = m_config.value(IS_CURRENT_FONT_EMBEDDED, true).toBool();

// The default demo mode based on the platform
#if defined(WITH_ACTIVATION_CODE)
    m_isDemoMode = m_config.value(DEMO_KEY, true).toBool();
#else
    m_isDemoMode = m_config.value(DEMO_KEY, false).toBool();
#endif

#if defined(WITH_KIOSK_MODE)
    m_isKioskMode = m_config.value(KIOSK_KEY, true).toBool();
#else
    m_isKioskMode = m_config.value(KIOSK_KEY, false).toBool();
#endif

    // Option only useful if we are in demo mode (else all the activities are available and unlocked)
    // By default, all the activities are displayed (even locked ones)
    m_showLockedActivities = m_config.value(SHOW_LOCKED_ACTIVITIES_KEY, m_isDemoMode).toBool();
	m_sectionVisible = m_config.value(SECTION_VISIBLE, true).toBool();
	m_isAutomaticDownloadsEnabled = m_config.value(ENABLE_AUTOMATIC_DOWNLOADS,
            !ApplicationInfo::getInstance()->isMobile() && ApplicationInfo::isDownloadAllowed()).toBool();
    m_filterLevelMin = m_config.value(FILTER_LEVEL_MIN, 1).toUInt();
    m_filterLevelMax = m_config.value(FILTER_LEVEL_MAX, 6).toUInt();
	m_defaultCursor = m_config.value(DEFAULT_CURSOR, false).toBool();
	m_noCursor = m_config.value(NO_CURSOR, false).toBool();
    setBaseFontSize(m_config.value(BASE_FONT_SIZE_KEY, 0).toInt());

	m_config.sync();  // make sure all defaults are written back
    m_config.endGroup();

    // admin group
    m_config.beginGroup(ADMIN_GROUP_KEY);
    m_downloadServerUrl = m_config.value(DOWNLOAD_SERVER_URL_KEY, "http://gcompris.net").toString();
    m_config.endGroup();

    // internal group
    m_config.beginGroup(INTERNAL_GROUP_KEY);
    m_exeCount = m_config.value(EXE_COUNT_KEY, 0).toUInt();
    m_config.endGroup();

    // no group
    m_isBarHidden = false;

    connect(this, SIGNAL(showLockedActivitiesChanged()), this, SLOT(notifyShowLockedActivitiesChanged()));
	connect(this, SIGNAL(audioVoicesEnabledChanged()), this, SLOT(notifyAudioVoicesEnabledChanged()));
	connect(this, SIGNAL(audioEffectsEnabledChanged()), this, SLOT(notifyAudioEffectsEnabledChanged()));
	connect(this, SIGNAL(fullscreenChanged()), this, SLOT(notifyFullscreenChanged()));
    connect(this, SIGNAL(localeChanged()), this, SLOT(notifyLocaleChanged()));
    connect(this, SIGNAL(fontChanged()), this, SLOT(notifyFontChanged()));
    connect(this, SIGNAL(virtualKeyboardChanged()), this, SLOT(notifyVirtualKeyboardChanged()));
    connect(this, SIGNAL(automaticDownloadsEnabledChanged()), this, SLOT(notifyAutomaticDownloadsEnabledChanged()));
    connect(this, SIGNAL(filterLevelMinChanged()), this, SLOT(notifyFilterLevelMinChanged()));
    connect(this, SIGNAL(filterLevelMaxChanged()), this, SLOT(notifyFilterLevelMaxChanged()));
	connect(this, SIGNAL(sectionVisibleChanged()), this, SLOT(notifySectionVisibleChanged()));
    connect(this, SIGNAL(demoModeChanged()), this, SLOT(notifyDemoModeChanged()));
    connect(this, SIGNAL(kioskModeChanged()), this, SLOT(notifyKioskModeChanged()));
    connect(this, SIGNAL(downloadServerUrlChanged()), this, SLOT(notifyDownloadServerUrlChanged()));
    connect(this, SIGNAL(exeCountChanged()), this, SLOT(notifyExeCountChanged()));
    connect(this, SIGNAL(barHiddenChanged()), this, SLOT(notifyBarHiddenChanged()));
}
Example #3
0
void DevGUI::editorChanged()
{
	DevEditor * e = qobject_cast<DevEditor*>(Editor->currentWidget());

    if ( e ) {
		
		const QTextDocument *doc = e->document();
		
        disconnect(doc, SIGNAL(modificationChanged(bool)),
                   actionSave, SLOT(setEnabled(bool)));
        disconnect(doc, SIGNAL(modificationChanged(bool)),
                   this, SLOT(setWindowModified(bool)));
        disconnect(doc, SIGNAL(undoAvailable(bool)),
                   actionUndo, SLOT(setEnabled(bool)));
        disconnect(doc, SIGNAL(redoAvailable(bool)),
                   actionRedo, SLOT(setEnabled(bool)));

        disconnect(actionUndo, SIGNAL(triggered()), doc, SLOT(undo()));
        disconnect(actionRedo, SIGNAL(triggered()), doc, SLOT(redo()));

        disconnect(actionCut, SIGNAL(triggered()), e, SLOT(cut()));
        disconnect(actionCopy, SIGNAL(triggered()), e, SLOT(copy()));
        disconnect(actionPaste, SIGNAL(triggered()), e, SLOT(paste()));

        disconnect(e, SIGNAL(copyAvailable(bool)), actionCut, SLOT(setEnabled(bool)));
        disconnect(e, SIGNAL(copyAvailable(bool)), actionCopy, SLOT(setEnabled(bool)));

    }

    e = qobject_cast<DevEditor*>(Editor->currentWidget());
    if (!e)
        return;
    
	const QTextDocument *doc = e->document();
	
    fontChanged(doc->defaultFont());

    connect(doc, SIGNAL(modificationChanged(bool)),
            actionSave, SLOT(setEnabled(bool)));
    connect(doc, SIGNAL(modificationChanged(bool)),
            this, SLOT(setWindowModified(bool)));
    connect(doc, SIGNAL(undoAvailable(bool)),
            actionUndo, SLOT(setEnabled(bool)));
    connect(doc, SIGNAL(redoAvailable(bool)),
            actionRedo, SLOT(setEnabled(bool)));

    setWindowModified(e->isModified());
    actionSave->setEnabled(doc->isModified());
    actionUndo->setEnabled(doc->isUndoAvailable());
    actionRedo->setEnabled(doc->isRedoAvailable());

    connect(actionUndo, SIGNAL(triggered()), doc, SLOT(undo()));
    connect(actionRedo, SIGNAL(triggered()), doc, SLOT(redo()));

    const bool selection = e->textCursor().hasSelection();
    actionCut->setEnabled(selection);
    actionCopy->setEnabled(selection);

    connect(actionCut, SIGNAL(triggered()), e, SLOT(cut()));
    connect(actionCopy, SIGNAL(triggered()), e, SLOT(copy()));
    connect(actionPaste, SIGNAL(triggered()), e, SLOT(paste()));

    connect(e, SIGNAL(copyAvailable(bool)), actionCut, SLOT(setEnabled(bool)));
    connect(e, SIGNAL(copyAvailable(bool)), actionCopy, SLOT(setEnabled(bool)));
}
void WhiteBoardFontChooser::currentFontChanged(const QFont& font)
{
    m_font.setFamily(font.family());
    emit fontChanged(m_font);
}
Example #5
0
void TextEdit::currentCharFormatChanged(const QTextCharFormat &format)
{
    fontChanged(format.font());
    colorChanged(format.foreground().color());
}
Example #6
0
void MainWindow::optionsActionClicked()
{
	OptionsDialog options(this);
	moveToCenterOfScreen(&options);
	connect(&options, SIGNAL(fontChanged()), &poolWindow_, SIGNAL(fontChanged()));
	connect(&options, SIGNAL(fontChanged()), &collectionWindow_, SIGNAL(fontChanged()));
	connect(&options, SIGNAL(fontChanged()), &deckWindow_, SIGNAL(fontChanged()));
	options.exec();
	poolWindow_.updateShortcuts();
	collectionWindow_.updateShortcuts();
	deckWindow_.updateShortcuts();
	disconnect(&options, SIGNAL(fontChanged()), &poolWindow_, SIGNAL(fontChanged()));
	disconnect(&options, SIGNAL(fontChanged()), &collectionWindow_, SIGNAL(fontChanged()));
	disconnect(&options, SIGNAL(fontChanged()), &deckWindow_, SIGNAL(fontChanged()));
}
Example #7
0
void QStyleItem::setElementType(const QString &str)
{
    if (m_type == str)
        return;

    m_type = str;

    emit elementTypeChanged();
    if (m_styleoption) {
        delete m_styleoption;
        m_styleoption = 0;
    }

    // Only enable visible if the widget can animate
    if (str == "menu" || str == "menuitem") {
        m_itemType = (str == "menu") ? Menu : MenuItem;
    } else if (str == "item" || str == "itemrow" || str == "header") {
#ifdef Q_OS_MAC
        m_font.setPointSize(11.0);
        emit fontChanged();
#endif
        if (str == "header") {
            m_itemType = Header;
        } else {
            m_itemType = (str == "item") ? Item : ItemRow;
        }
    } else if (str == "groupbox") {
        m_itemType = GroupBox;
    } else if (str == "tab") {
        m_itemType = Tab;
    } else if (str == "tabframe") {
        m_itemType = TabFrame;
    } else if (str == "comboboxitem")  {
        // Gtk uses qobject cast, hence we need to separate this from menuitem
        // On mac, we temporarily use the menu item because it has more accurate
        // palette.
        m_itemType = ComboBoxItem;
    } else if (str == "toolbar") {
        m_itemType = ToolBar;
    } else if (str == "toolbutton") {
        m_itemType = ToolButton;
    } else if (str == "slider") {
        m_itemType = Slider;
    } else if (str == "frame") {
        m_itemType = Frame;
    } else if (str == "combobox") {
        m_itemType = ComboBox;
    } else if (str == "splitter") {
        m_itemType = Splitter;
    } else if (str == "progressbar") {
        m_itemType = ProgressBar;
    } else if (str == "button") {
        m_itemType = Button;
    } else if (str == "checkbox") {
        m_itemType = CheckBox;
    } else if (str == "radiobutton") {
        m_itemType = RadioButton;
    } else if (str == "edit") {
        m_itemType = Edit;
    } else if (str == "spinbox") {
        m_itemType = SpinBox;
    } else if (str == "scrollbar") {
        m_itemType = ScrollBar;
    } else if (str == "widget") {
        m_itemType = Widget;
    } else if (str == "focusframe") {
        m_itemType = FocusFrame;
    } else if (str == "dial") {
        m_itemType = Dial;
    } else if (str == "statusbar") {
        m_itemType = StatusBar;
    } else if (str == "machelpbutton") {
        m_itemType = MacHelpButton;
    } else if (str == "scrollareacorner") {
        m_itemType = ScrollAreaCorner;
    } else if (str == "menubar") {
        m_itemType = MenuBar;
    } else if (str == "menubaritem") {
        m_itemType = MenuBarItem;
    } else {
        m_itemType = Undefined;
    }
    updateSizeHint();
}
/** Constructor */
CreateBlogMsg::CreateBlogMsg(std::string cId ,QWidget* parent, Qt::WFlags flags)
: mBlogId(cId), QMainWindow (parent, flags)
{
	/* Invoke the Qt Designer generated object setup routine */
	ui.setupUi(this);

	setAttribute ( Qt::WA_DeleteOnClose, true );

	setupFileActions();
  setupEditActions();
  setupViewActions();
  setupInsertActions();
  setupParagraphActions();
  
  setAcceptDrops(true);
	setStartupText();
	
	newBlogMsg();
		
	ui.toolBar_2->addAction(ui.actionIncreasefontsize);
  ui.toolBar_2->addAction(ui.actionDecreasefontsize);
  ui.toolBar_2->addAction(ui.actionBlockquoute);
  ui.toolBar_2->addAction(ui.actionOrderedlist);
  ui.toolBar_2->addAction(ui.actionUnorderedlist);
  ui.toolBar_2->addAction(ui.actionBlockquoute);
  ui.toolBar_2->addAction(ui.actionCode);
  ui.toolBar_2->addAction(ui.actionsplitPost);
  
  setupTextActions();

	connect(ui.actionPublish, SIGNAL(triggered()), this, SLOT(sendMsg()));
	connect(ui.actionNew, SIGNAL(triggered()), this, SLOT (fileNew()));
	
	connect(ui.actionIncreasefontsize, SIGNAL (triggered()), this, SLOT (fontSizeIncrease()));
  connect(ui.actionDecreasefontsize, SIGNAL (triggered()), this, SLOT (fontSizeDecrease()));
  connect(ui.actionBlockquoute, SIGNAL (triggered()), this, SLOT (blockQuote()));
  connect(ui.actionCode, SIGNAL (triggered()), this, SLOT (toggleCode()));
  connect(ui.actionsplitPost, SIGNAL (triggered()), this, SLOT (addPostSplitter()));  
  connect(ui.actionOrderedlist, SIGNAL (triggered()), this, SLOT (addOrderedList()));
  connect(ui.actionUnorderedlist, SIGNAL (triggered()), this, SLOT (addUnorderedList()));

  //connect(webView, SIGNAL(loadFinished(bool)),this, SLOT(updateTextEdit()));
  connect( ui.msgEdit, SIGNAL( textChanged(const QString &)), this, SLOT(updateTextEdit()));
  
  connect( ui.msgEdit, SIGNAL(currentCharFormatChanged(QTextCharFormat)),
            this, SLOT(currentCharFormatChanged(QTextCharFormat)));
  connect( ui.msgEdit, SIGNAL(cursorPositionChanged()),
            this, SLOT(cursorPositionChanged()));
	
	QPalette palette = QApplication::palette();
  codeBackground = palette.color( QPalette::Active, QPalette::Midlight );
  
  fontChanged(ui.msgEdit->font());
  colorChanged(ui.msgEdit->textColor());
  alignmentChanged(ui.msgEdit->alignment());
  
    connect( ui.msgEdit->document(), SIGNAL(modificationChanged(bool)),
            actionSave, SLOT(setEnabled(bool)));
    connect( ui.msgEdit->document(), SIGNAL(modificationChanged(bool)),
            this, SLOT(setWindowModified(bool)));
    connect( ui.msgEdit->document(), SIGNAL(undoAvailable(bool)),
            actionUndo, SLOT(setEnabled(bool)));
    connect( ui.msgEdit->document(), SIGNAL(undoAvailable(bool)),
            ui.actionUndo, SLOT(setEnabled(bool)));        
    connect( ui.msgEdit->document(), SIGNAL(redoAvailable(bool)),
            actionRedo, SLOT(setEnabled(bool)));

    setWindowModified( ui.msgEdit->document()->isModified());
    actionSave->setEnabled( ui.msgEdit->document()->isModified());
    actionUndo->setEnabled( ui.msgEdit->document()->isUndoAvailable());
    ui.actionUndo->setEnabled( ui.msgEdit->document()->isUndoAvailable());
    actionRedo->setEnabled( ui.msgEdit->document()->isRedoAvailable());

    connect(actionUndo, SIGNAL(triggered()), ui.msgEdit, SLOT(undo()));
    connect(ui.actionUndo, SIGNAL(triggered()), ui.msgEdit, SLOT(undo()));
    connect(actionRedo, SIGNAL(triggered()), ui.msgEdit, SLOT(redo()));
    
    actionCut->setEnabled(false);
    actionCopy->setEnabled(false);

    connect(actionCut, SIGNAL(triggered()), ui.msgEdit, SLOT(cut()));
    connect(actionCopy, SIGNAL(triggered()), ui.msgEdit, SLOT(copy()));
    connect(actionPaste, SIGNAL(triggered()), ui.msgEdit, SLOT(paste()));
    
    connect(ui.msgEdit, SIGNAL(copyAvailable(bool)), actionCut, SLOT(setEnabled(bool)));
    connect(ui.msgEdit, SIGNAL(copyAvailable(bool)), actionCopy, SLOT(setEnabled(bool)));
    
#ifndef QT_NO_CLIPBOARD
    connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged()));
#endif
  
  //defaultCharFormat
  defaultCharFormat = ui.msgEdit->currentCharFormat();

  const QFont defaultFont = ui.msgEdit->document()->defaultFont();
  defaultCharFormat.setFont( defaultFont );
  defaultCharFormat.setForeground( ui.msgEdit->currentCharFormat().foreground() );
  defaultCharFormat.setProperty( QTextFormat::FontSizeAdjustment, QVariant( 0 ) );
  defaultCharFormat.setBackground( palette.color( QPalette::Active,
                                                    QPalette::Base ) );
  defaultCharFormat.setProperty( TextFormat::HasCodeStyle, QVariant( false ) );

  //defaultBlockFormat
  defaultBlockFormat = ui.msgEdit->textCursor().blockFormat();
  
}
Example #9
0
MailEditorMainWindow::MailEditorMainWindow(ATopLevelWindowsContainer* parent, AddressBookModel& abModel,
  IMailProcessor& mailProcessor, bool editMode) :
  ATopLevelWindow(parent),
  ui(new Ui::MailEditorWindow()),
  ABModel(abModel),
  MailProcessor(mailProcessor),
  FontCombo(nullptr),
  EditMode(editMode)
  {
  ui->setupUi(this);

  /** Disable these toolbars by default. They should be showed up on demand, when given action will
      be trigerred.
  */
  ui->fileAttachementToolBar->hide();
  ui->moneyAttachementToolBar->hide();
  ui->editToolBar->hide();
  ui->adjustToolbar->hide();
  ui->formatToolBar->hide();

  MoneyAttachement = new TMoneyAttachementWidget(ui->moneyAttachementToolBar);
  ui->moneyAttachementToolBar->addWidget(MoneyAttachement);

  FileAttachment = new TFileAttachmentWidget(ui->fileAttachementToolBar, editMode);
  ui->fileAttachementToolBar->addWidget(FileAttachment);

  MailFields = new MailFieldsWidget(*this, *ui->actionSend, abModel, editMode);

  /// Initially only basic mail fields (To: and Subject:) should be visible
  MailFields->showCcControls(false);
  MailFields->showBccControls(false);

  ui->mailFieldsToolBar->addWidget(MailFields);

  connect(MailFields, SIGNAL(subjectChanged(QString)), this, SLOT(onSubjectChanged(QString)));
  connect(MailFields, SIGNAL(recipientListChanged()), this, SLOT(onRecipientListChanged()));
  connect(FileAttachment, SIGNAL(attachmentListChanged()), this, SLOT(onAttachmentListChanged()));

  if(editMode)
    {
    /** Supplement definition of mailFieldSelectorToolbar since Qt Creator doesn't support putting
        into its context dedicated controls (like preconfigured toolbutton).

        Setup local menu for 'actionMailFields' toolButton (used to enable/disable additional mail
        field selection).
    */
    QMenu* mailFieldsMenu = new QMenu(this);
    mailFieldsMenu->addAction(ui->actionFrom);
    mailFieldsMenu->addAction(ui->actionCC);
    mailFieldsMenu->addAction(ui->actionBCC);

    /// Update state of sub-menu commands.
    ui->actionBCC->setChecked(MailFields->isFieldVisible(MailFieldsWidget::BCC_FIELDS));
    ui->actionCC->setChecked(MailFields->isFieldVisible(MailFieldsWidget::CC_FIELD));
    ui->actionFrom->setChecked(MailFields->isFieldVisible(MailFieldsWidget::FROM_FIELD));

    ui->actionMailFields->setMenu(mailFieldsMenu);
    ui->mainToolBar->insertAction(ui->actionShowFormatOptions, ui->actionMailFields);
    }

  setupEditorCommands();

  ui->messageEdit->setFocus();
  fontChanged(ui->messageEdit->font());
  colorChanged(ui->messageEdit->textColor());
  alignmentChanged(ui->messageEdit->alignment());

  QString subject = MailFields->getSubject();
  onSubjectChanged(subject);
  
  /// Clear modified flag
  ui->messageEdit->document()->setModified(false);
  setWindowModified(ui->messageEdit->document()->isModified());
  
  ui->actionSave->setEnabled(ui->messageEdit->document()->isModified());
  ui->actionUndo->setEnabled(ui->messageEdit->document()->isUndoAvailable());
  ui->actionRedo->setEnabled(ui->messageEdit->document()->isRedoAvailable());

  /// Setup command update ui related to 'save' option activity control and window modify marker.
  connect(ui->messageEdit->document(), SIGNAL(modificationChanged(bool)), ui->actionSave,
    SLOT(setEnabled(bool)));
  connect(ui->messageEdit->document(), SIGNAL(modificationChanged(bool)), this,
    SLOT(setWindowModified(bool)));
  connect(ui->messageEdit, SIGNAL(addAttachments(QStringList)), this, SLOT(onAddAttachments(QStringList)));

#ifndef QT_NO_CLIPBOARD
  connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(onClipboardDataChanged()));
#endif

  toggleReadOnlyMode();
  }
Example #10
0
KNFontDialog::KNFontDialog(QWidget *parent) :
    QDialog(parent)
{
#ifdef Q_OS_MACX
    setWindowFlags(Qt::Sheet);
#endif
    //Initial the layout.
    QGridLayout *mainLayout=new QGridLayout(this);
    setLayout(mainLayout);
    //Generate the caption.
    m_caption[0]=new QLabel(tr("Font"), this);
    mainLayout->addWidget(m_caption[0], 0, 0, 1, 1);
    m_caption[1]=new QLabel(tr("Size"), this);
    mainLayout->addWidget(m_caption[1], 0, 1, 1, 1);
    m_caption[2]=new QLabel(tr("Styles"), this);
    mainLayout->addWidget(m_caption[2], 4, 1, 1, 1);

    //Initial the font family combo box and list view.
    m_fontFamily=new QFontComboBox(this);
    m_fontFamily->setMaximumWidth(204);
    m_fontModel=m_fontFamily->model();
    connect(m_fontFamily, SIGNAL(currentIndexChanged(int)),
            this, SLOT(fontChanged(int)));
    mainLayout->addWidget(m_fontFamily, 1, 0, 1, 1);
    m_fontList=new QListView(this);
    m_fontList->setMaximumWidth(204);
    m_fontList->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    m_fontList->setModel(m_fontModel);
    m_fontList->setItemDelegate(m_fontFamily->itemDelegate());
    connect(m_fontList->selectionModel(), &QItemSelectionModel::currentRowChanged,
            [=](const QModelIndex &current, const QModelIndex &previous)
            {
                Q_UNUSED(previous)
                fontChanged(current.row());
            });
    mainLayout->addWidget(m_fontList, 2, 0, 4, 1);

    //Initial the size spin.
    m_sizeSpin=new QSpinBox(this);
    m_sizeSpin->setRange(1, 1296);
    connect(m_sizeSpin, SIGNAL(valueChanged(int)), this, SLOT(sizeChanged(int)));
    mainLayout->addWidget(m_sizeSpin, 1, 1, 1, 1);
    //Initial the slider box and standard font size list.
    QBoxLayout *sizeBox=new QBoxLayout(QBoxLayout::LeftToRight,
                                       mainLayout->widget());
    sizeBox->setContentsMargins(0,0,0,0);
    sizeBox->setSpacing(0);

    m_fontSizeList=new QListWidget(this);
    m_fontSizeList->setSelectionMode(QAbstractItemView::SingleSelection);
    m_fontSizeList->setMaximumWidth(70);
    m_standardSize<<6<<8<<9<<10<<11<<12<<13<<14<<18<<24<<36<<48<<64<<72<<96
                  <<144<<288;
    QStringList fontSizes;
    for(auto i=m_standardSize.begin(); i!=m_standardSize.end(); ++i)
    {
        fontSizes << QString::number(*i);
    }
    m_fontSizeList->addItems(fontSizes);
    connect(m_fontSizeList, &QListWidget::currentRowChanged,
            [=](const int &currentRow)
               {
                   sizeChanged(m_standardSize.at(currentRow));
               });
    sizeBox->addWidget(m_fontSizeList, 1);

    m_sizeSlider=new QSlider(Qt::Vertical, this);
    m_sizeSlider->setRange(1, 288);
    connect(m_sizeSlider, &QSlider::valueChanged, this, &KNFontDialog::sizeChanged);
    sizeBox->addWidget(m_sizeSlider);
    mainLayout->addLayout(sizeBox, 3, 1, 1, 1);

    //Initial the font styles box.
    QBoxLayout *stylesBox=new QBoxLayout(QBoxLayout::TopToBottom,
                                         mainLayout->widget());
    stylesBox->setContentsMargins(0,0,0,0);
    stylesBox->setSpacing(0);
    for(int i=0; i<FontStylesCount; i++)
    {
        m_fontStyles[i]=new QCheckBox(this);
        stylesBox->addWidget(m_fontStyles[i]);
        connect(m_fontStyles[i], SIGNAL(stateChanged(int)),
                this, SLOT(synchronizeFont()));
    }
    m_fontStyles[StyleBold]->setText(tr("Bold"));
    m_fontStyles[StyleItalic]->setText(tr("Italic"));
    m_fontStyles[StyleUnderline]->setText(tr("Underline"));
    m_fontStyles[StyleStrikeout]->setText(tr("Strike Out"));
    m_fontStyles[StyleKerning]->setText(tr("Kerning"));
    stylesBox->addStretch();
    mainLayout->addLayout(stylesBox, 5, 1, 1, 1);

    QBoxLayout *finalLayout=new QBoxLayout(QBoxLayout::TopToBottom,
                                           mainLayout->widget());
    //Initial the okay, cancel and preview.
    m_okayButton=new QPushButton(tr("OK"), this);
    connect(m_okayButton, SIGNAL(clicked()), this, SLOT(accept()));
    finalLayout->addWidget(m_okayButton);
    m_cancelButton=new QPushButton(tr("Cancel"), this);
    connect(m_cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
    finalLayout->addWidget(m_cancelButton);

    finalLayout->addStretch();

    m_caption[3]=new QLabel(tr("Sample"), this);
    finalLayout->addWidget(m_caption[3]);

    //Initial the preview edit.
    m_previewEdit=new QLineEdit(this);
    m_previewEdit->setAlignment(Qt::AlignCenter);
    m_previewEdit->setText(tr("AaBbYyZz"));
    m_previewEdit->setMinimumSize(205, 85);
    finalLayout->addWidget(m_previewEdit);
    mainLayout->addLayout(finalLayout, 0, 3, 6, 1);
}
Example #11
0
void MRichTextEdit::slotCurrentCharFormatChanged(const QTextCharFormat &format)
{
    fontChanged(format.font());
    bgColorChanged((format.background().isOpaque()) ? format.background().color() : QColor());
    f_link->setChecked(format.isAnchor());
}
Example #12
0
MRichTextEdit::MRichTextEdit(QWidget *parent)
    : QWidget(parent)
{
    setupUi(this);
    m_lastBlockList = 0;
    f_textedit->setTabStopWidth(40);

    connect(f_textedit, SIGNAL(currentCharFormatChanged(QTextCharFormat)),
            this,     SLOT(slotCurrentCharFormatChanged(QTextCharFormat)));
    connect(f_textedit, SIGNAL(cursorPositionChanged()),
            this,     SLOT(slotCursorPositionChanged()));

    m_fontsize_h1 = 18;
    m_fontsize_h2 = 16;
    m_fontsize_h3 = 14;
    m_fontsize_h4 = 12;

    fontChanged(f_textedit->font());
    bgColorChanged(f_textedit->textColor());

    // paragraph formatting

    m_paragraphItems    << tr("Standard")
                        << tr("Heading 1")
                        << tr("Heading 2")
                        << tr("Heading 3")
                        << tr("Heading 4")
                        << tr("Monospace");
    f_paragraph->addItems(m_paragraphItems);

    connect(f_paragraph, SIGNAL(activated(int)),
            this, SLOT(textStyle(int)));

    // undo & redo

    f_undo->setShortcut(QKeySequence::Undo);
    f_redo->setShortcut(QKeySequence::Redo);

    connect(f_textedit->document(), SIGNAL(undoAvailable(bool)),
            f_undo, SLOT(setEnabled(bool)));
    connect(f_textedit->document(), SIGNAL(redoAvailable(bool)),
            f_redo, SLOT(setEnabled(bool)));

    f_undo->setEnabled(f_textedit->document()->isUndoAvailable());
    f_redo->setEnabled(f_textedit->document()->isRedoAvailable());

    connect(f_undo, SIGNAL(clicked()), f_textedit, SLOT(undo()));
    connect(f_redo, SIGNAL(clicked()), f_textedit, SLOT(redo()));

    // cut, copy & paste
    f_cut->setShortcut(QKeySequence::Cut);
    f_copy->setShortcut(QKeySequence::Copy);
    f_paste->setShortcut(QKeySequence::Paste);

    f_cut->setEnabled(false);
    f_copy->setEnabled(false);

    connect(f_cut, SIGNAL(clicked()), f_textedit, SLOT(cut()));
    connect(f_copy, SIGNAL(clicked()), f_textedit, SLOT(copy()));
    connect(f_paste, SIGNAL(clicked()), f_textedit, SLOT(paste()));

    connect(f_textedit, SIGNAL(copyAvailable(bool)), f_cut, SLOT(setEnabled(bool)));
    connect(f_textedit, SIGNAL(copyAvailable(bool)), f_copy, SLOT(setEnabled(bool)));

#ifndef QT_NO_CLIPBOARD
    connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(slotClipboardDataChanged()));
#endif

    // link
    f_link->setShortcut(Qt::CTRL + Qt::Key_L);

    connect(f_link, SIGNAL(clicked(bool)), this, SLOT(textLink(bool)));

    // bold, italic & underline
    f_bold->setShortcut(Qt::CTRL + Qt::Key_B);
    f_italic->setShortcut(Qt::CTRL + Qt::Key_I);
    f_underline->setShortcut(Qt::CTRL + Qt::Key_U);

    connect(f_bold, SIGNAL(clicked()), this, SLOT(textBold()));
    connect(f_italic, SIGNAL(clicked()), this, SLOT(textItalic()));
    connect(f_underline, SIGNAL(clicked()), this, SLOT(textUnderline()));
    connect(f_strikeout, SIGNAL(clicked()), this, SLOT(textStrikeout()));

    // lists
    f_list_bullet->setShortcut(Qt::CTRL + Qt::Key_Minus);
    f_list_ordered->setShortcut(Qt::CTRL + Qt::Key_Equal);

    connect(f_list_bullet, SIGNAL(clicked(bool)), this, SLOT(listBullet(bool)));
    connect(f_list_ordered, SIGNAL(clicked(bool)), this, SLOT(listOrdered(bool)));

    // indentation
    f_indent_dec->setShortcut(Qt::CTRL + Qt::Key_Comma);
    f_indent_inc->setShortcut(Qt::CTRL + Qt::Key_Period);

    connect(f_indent_inc, SIGNAL(clicked()), this, SLOT(increaseIndentation()));
    connect(f_indent_dec, SIGNAL(clicked()), this, SLOT(decreaseIndentation()));

    // font size
    QFontDatabase db;
    foreach(int size, db.standardSizes())
    {
        f_fontsize->addItem(QString::number(size));
    }

    connect(f_fontsize, SIGNAL(activated(QString)), this, SLOT(textSize(QString)));
    f_fontsize->setCurrentIndex(f_fontsize->findText(QString::number(QApplication::font().pointSize())));


    // text background color
    QPixmap pix(16, 16);
    pix.fill(QApplication::palette().background().color());
    f_bgcolor->setIcon(pix);

    connect(f_bgcolor, SIGNAL(clicked()), this, SLOT(textBgColor()));

    // images
    connect(f_image, SIGNAL(clicked()), this, SLOT(insertImage()));
}
Example #13
0
void ChatWidget::resetFont()
{
	currentFont.fromString(Settings->getChatScreenFont());
	fontChanged();
	setFont();
}
Example #14
0
void ChatWidget::init(const std::string &peerId, const QString &title)
{
	this->peerId = peerId;
	this->title = title;

	ui->titleLabel->setText(title);

	std::string ownId = rsPeers->getOwnId();
	setName(QString::fromUtf8(rsPeers->getPeerName(ownId).c_str()));

	ChatLobbyId lid;
	if (rsMsgs->isLobbyId(peerId, lid)) {
		isChatLobby = true;
		chatStyle.setStyleFromSettings(ChatStyle::TYPE_PUBLIC);
	} else {
		chatStyle.setStyleFromSettings(ChatStyle::TYPE_PRIVATE);
	}

	currentColor.setNamedColor(PeerSettings->getPrivateChatColor(peerId));
	currentFont.fromString(PeerSettings->getPrivateChatFont(peerId));

	colorChanged();
	fontChanged();
	setColorAndFont();

	// load style
	PeerSettings->getStyle(peerId, "ChatWidget", style);

	if (!isChatLobby) {
		// initialize first status
		StatusInfo peerStatusInfo;
		// No check of return value. Non existing status info is handled as offline.
		rsStatus->getStatus(peerId, peerStatusInfo);
		updateStatus(QString::fromStdString(peerId), peerStatusInfo.status);

		// initialize first custom state string
		QString customStateString = QString::fromUtf8(rsMsgs->getCustomStateString(peerId).c_str());
		updatePeersCustomStateString(QString::fromStdString(peerId), customStateString);
	} else {
		// currently not possible
		ui->actionDeleteChatHistory->setVisible(false);
		ui->actionMessageHistory->setVisible(false);

		updateTitle();
	}

	if (rsHistory->getEnable(false)) {
		// get chat messages from history
		std::list<HistoryMsg> historyMsgs;
		int messageCount = Settings->getPrivateChatHistoryCount();
		if (messageCount > 0) {
			rsHistory->getMessages(peerId, historyMsgs, messageCount);

			std::list<HistoryMsg>::iterator historyIt;
			for (historyIt = historyMsgs.begin(); historyIt != historyMsgs.end(); historyIt++) {
				addChatMsg(historyIt->incoming, QString::fromUtf8(historyIt->peerName.c_str()), QDateTime::fromTime_t(historyIt->sendTime), QDateTime::fromTime_t(historyIt->recvTime), QString::fromUtf8(historyIt->message.c_str()), TYPE_HISTORY);
			}
		}
	}

	processSettings(true);
}
Example #15
0
Setup_Display::Setup_Display():
    mFullScreenEnabled(config.getValue("screen", false)),
    mOpenGLEnabled(config.getValue("opengl", 0)),
    mCustomCursorEnabled(config.getValue("customcursor", true)),
    mOpacity(config.getValue("guialpha", 0.8)),
    mMouseOpacity(config.getValue("mousealpha", 0.7)),
    mFps(config.getValue("fpslimit", 0)),
    mScreenWidth(graphics->getWidth()),
    mScreenHeight(graphics->getHeight()),
    mModeListModel(new ModeListModel()),
    mModeList(new ListBox(mModeListModel, "videomode", this)),
    mFsCheckBox(new CheckBox(_("Full screen"), mFullScreenEnabled)),
    mOpenGLCheckBox(new CheckBox(_("OpenGL"), mOpenGLEnabled)),
    mCustomCursorCheckBox(new CheckBox(_("Custom cursor"), mCustomCursorEnabled)),
    mAlphaSlider(new Slider(0.2, 1.0)),
    mMouseAlphaSlider(new Slider(0.2, 1.0)),
    mFpsCheckBox(new CheckBox(_("FPS Limit:"))),
    mFpsSlider(new Slider(5, 200)),
    mFontSize(config.getValue("fontSize", 11)),
    mFontSizeSlider(new Slider(8, 14)),
    mFontSizeLabel(new Label())
{
    setName(_("Display"));

    mScrollArea = new ScrollArea(mModeList);
    mScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
    mScrollArea->setWidth(90);

    mAlphaLabel = new Label(_("Gui opacity"));
    mMouseAlphaLabel = new Label(_("Mouse opacity"));
    mFpsLabel = new Label();
    mFontLabel = new Label(_("Font size"));

    mModeList->setEnabled(true);

#ifndef USE_OPENGL
    mOpenGLCheckBox->setEnabled(false);
#endif

    mAlphaSlider->setValue(mOpacity);
    mMouseAlphaSlider->setValue(mMouseOpacity);

    mFpsLabel->setCaption(toString(mFps));
    mFpsLabel->adjustSize();
    mFpsSlider->setValue(mFps);
    mFpsSlider->setEnabled(mFps > 0);
    mFpsCheckBox->setSelected(mFps > 0);

    mCustomCursorCheckBox->setActionEventId("customcursor");
    mAlphaSlider->setActionEventId("guialpha");
    mMouseAlphaSlider->setActionEventId("mousealpha");
    mFpsCheckBox->setActionEventId("fpslimitcheckbox");
    mFpsSlider->setActionEventId("fpslimitslider");
    mFontSizeSlider->setActionEventId("fontsizeslider");

    mCustomCursorCheckBox->addActionListener(this);
    mAlphaSlider->addActionListener(this);
    mMouseAlphaSlider->addActionListener(this);
    mFpsCheckBox->addActionListener(this);
    mFpsSlider->addActionListener(this);
    mFontSizeSlider->addActionListener(this);

    mFontSize = config.getValue("fontSize", 11);
    mFontSizeLabel->setCaption(strprintf(_("%d Point"), mFontSize));
    mFontSizeSlider->setValue(mFontSize);

    mFpsSlider->setStepLength(1.0);
    mFontSizeSlider->setStepLength(1.0);

    fontChanged();

    setDimension(gcn::Rectangle(0, 0, 325, 200));
}
Example #16
0
void Prefs::fontFamilyChanged(const QString family) {
    setValue("editor/fontfamily", family);
    emit fontChanged(family, getValue("editor/fontsize").toUInt());
}
void MainWindow::currentCharFormatChanged(const QTextCharFormat &format)
{
    fontChanged(format.font());
    colorChanged(format.foreground().color());
}
void GraphicTextDialog::currentCharFormatChanged(const QTextCharFormat &format)
{
    fontChanged(format.font());
    colorChanged(format.foreground().color());
    subSuperAlignmentChanged(format.verticalAlignment());
}
void CreateBlogMsg::currentCharFormatChanged(const QTextCharFormat &format)
{
    fontChanged(format.font());
    colorChanged(format.foreground().color());
}
GraphicTextDialog::GraphicTextDialog(GraphicText *text, Qucs::UndoOption opt, QWidget *parent)
: QDialog(parent), textItem(text), undoOption(opt)
{
    mainLayout = new QVBoxLayout(this);

    mainLayout->setSpacing(-1);
    toolBarLayout = new QHBoxLayout;
    mainLayout->addItem(toolBarLayout);
    toolBar = new QToolBar(this);

    toolBar->setIconSize(QSize(16, 16));
    toolBarLayout->addWidget(toolBar);
    toolBarLayout->setSpacing(-1);
    toolBarLayout->setContentsMargins(0,0,0,0);

    setupEditActions();
    setupTextActions();

    textEdit = new QTextEdit;
    if(textItem) {
        QString latex = Qucs::unicodeToLatex(textItem->richText());
        textEdit->setHtml(latex);
    }

    mainLayout->addWidget(textEdit);

    connect(textEdit, SIGNAL(currentCharFormatChanged(const QTextCharFormat &)),
            SLOT(currentCharFormatChanged(const QTextCharFormat &)));
    connect(textEdit, SIGNAL(cursorPositionChanged()), SLOT(cursorPositionChanged()));

    textEdit->setFocus();

    fontChanged(textEdit->font());
    colorChanged(textEdit->textColor());
    alignmentChanged(textEdit->alignment());
    subSuperAlignmentChanged(textEdit->currentCharFormat().verticalAlignment());

    connect(textEdit->document(), SIGNAL(undoAvailable(bool)),
            actionUndo, SLOT(setEnabled(bool)));
    connect(textEdit->document(), SIGNAL(redoAvailable(bool)),
            actionRedo, SLOT(setEnabled(bool)));

    actionUndo->setEnabled(textEdit->document()->isUndoAvailable());
    actionRedo->setEnabled(textEdit->document()->isRedoAvailable());

    connect(actionUndo, SIGNAL(triggered()), textEdit, SLOT(undo()));
    connect(actionRedo, SIGNAL(triggered()), textEdit, SLOT(redo()));

    actionCut->setEnabled(false);
    actionCopy->setEnabled(false);

    connect(actionCut, SIGNAL(triggered()), textEdit, SLOT(cut()));
    connect(actionCopy, SIGNAL(triggered()), textEdit, SLOT(copy()));
    connect(actionPaste, SIGNAL(triggered()), textEdit, SLOT(paste()));

    connect(textEdit, SIGNAL(copyAvailable(bool)), actionCut, SLOT(setEnabled(bool)));
    connect(textEdit, SIGNAL(copyAvailable(bool)), actionCopy, SLOT(setEnabled(bool)));

    connect(QApplication::clipboard(), SIGNAL(dataChanged()), SLOT(clipboardDataChanged()));

    QDialogButtonBox *buttonBox =
        new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
                Qt::Horizontal, this);

    buttonBox->button(QDialogButtonBox::Ok)->setText(tr("&OK"));

    connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
    connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
    mainLayout->addWidget(buttonBox);
    adjustSize();
}
Example #21
0
ThemeDialog::ThemeDialog(Theme& theme, QWidget* parent)
	: QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint),
	m_theme(theme)
{
	setWindowTitle(tr("Edit Theme"));
	setWindowModality(Qt::WindowModal);

	// Create name edit
	m_name = new QLineEdit(this);
	m_name->setText(m_theme.name());
	connect(m_name, SIGNAL(textChanged(QString)), this, SLOT(checkNameAvailable()));

	QHBoxLayout* name_layout = new QHBoxLayout;
	name_layout->setMargin(0);
	name_layout->addWidget(new QLabel(tr("Name:"), this));
	name_layout->addWidget(m_name);


	// Create scrollarea
	QWidget* contents = new QWidget(this);

	QScrollArea* scroll = new QScrollArea(this);
	scroll->setWidget(contents);
	scroll->setWidgetResizable(true);


	// Create text group
	QGroupBox* text_group = new QGroupBox(tr("Text"), contents);

	m_text_color = new ColorButton(text_group);
	m_text_color->setColor(m_theme.textColor());
	connect(m_text_color, SIGNAL(changed(QColor)), this, SLOT(renderPreview()));

	m_font_names = new FontComboBox(text_group);
	m_font_names->setEditable(false);
	m_font_names->setCurrentFont(m_theme.textFont());
	connect(m_font_names, SIGNAL(activated(int)), this, SLOT(fontChanged()));
	connect(m_font_names, SIGNAL(activated(int)), this, SLOT(renderPreview()));

	m_font_sizes = new QComboBox(text_group);
	m_font_sizes->setEditable(true);
	m_font_sizes->setMinimumContentsLength(3);
	connect(m_font_sizes, SIGNAL(editTextChanged(QString)), this, SLOT(renderPreview()));
	fontChanged();

	m_misspelled_color = new ColorButton(text_group);
	m_misspelled_color->setColor(m_theme.misspelledColor());
	connect(m_misspelled_color, SIGNAL(changed(QColor)), this, SLOT(renderPreview()));

	QHBoxLayout* font_layout = new QHBoxLayout;
	font_layout->addWidget(m_font_names);
	font_layout->addWidget(m_font_sizes);

	QFormLayout* text_layout = new QFormLayout(text_group);
	text_layout->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint);
	text_layout->addRow(tr("Color:"), m_text_color);
	text_layout->addRow(tr("Font:"), font_layout);
	text_layout->addRow(tr("Misspelled:"), m_misspelled_color);


	// Create background group
	QGroupBox* background_group = new QGroupBox(tr("Window Background"), contents);

	m_background_color = new ColorButton(background_group);
	m_background_color->setColor(m_theme.backgroundColor());
	connect(m_background_color, SIGNAL(changed(QColor)), this, SLOT(renderPreview()));

	m_background_image = new ImageButton(background_group);
	m_background_image->setImage(m_theme.backgroundImage(), m_theme.backgroundPath());
	connect(m_background_image, SIGNAL(changed(QString)), this, SLOT(imageChanged()));

	m_clear_image = new QPushButton(tr("Remove"), background_group);
	connect(m_clear_image, SIGNAL(clicked()), m_background_image, SLOT(unsetImage()));

	m_background_type = new QComboBox(background_group);
	m_background_type->addItems(QStringList() << tr("No Image") << tr("Tiled") << tr("Centered") << tr("Stretched") << tr("Scaled") << tr("Zoomed"));
	m_background_type->setCurrentIndex(m_theme.backgroundType());
	connect(m_background_type, SIGNAL(activated(int)), this, SLOT(renderPreview()));

	QVBoxLayout* image_layout = new QVBoxLayout;
	image_layout->setSpacing(0);
	image_layout->setMargin(0);
	image_layout->addWidget(m_background_image);
	image_layout->addWidget(m_clear_image);

	QFormLayout* background_layout = new QFormLayout(background_group);
	background_layout->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint);
	background_layout->addRow(tr("Color:"), m_background_color);
	background_layout->addRow(tr("Image:"), image_layout);
	background_layout->addRow(tr("Type:"), m_background_type);


	// Create foreground group
	QGroupBox* foreground_group = new QGroupBox(tr("Text Background"), contents);

	m_foreground_color = new ColorButton(foreground_group);
	m_foreground_color->setColor(m_theme.foregroundColor());
	connect(m_foreground_color, SIGNAL(changed(QColor)), this, SLOT(renderPreview()));

	m_foreground_opacity = new QSpinBox(foreground_group);
	m_foreground_opacity->setCorrectionMode(QSpinBox::CorrectToNearestValue);
	m_foreground_opacity->setSuffix(QLocale().percent());
	m_foreground_opacity->setRange(theme.foregroundOpacity().minimumValue(), theme.foregroundOpacity().maximumValue());
	m_foreground_opacity->setValue(m_theme.foregroundOpacity());
	connect(m_foreground_opacity, SIGNAL(valueChanged(int)), this, SLOT(renderPreview()));

	m_foreground_position = new QComboBox(foreground_group);
	m_foreground_position->addItems(QStringList() << tr("Left") << tr("Centered") << tr("Right") << tr("Stretched"));
	m_foreground_position->setCurrentIndex(m_theme.foregroundPosition());
	connect(m_foreground_position, SIGNAL(currentIndexChanged(int)), this, SLOT(positionChanged(int)));

	m_foreground_width = new QSpinBox(foreground_group);
	m_foreground_width->setCorrectionMode(QSpinBox::CorrectToNearestValue);
	m_foreground_width->setSuffix(tr(" pixels"));
	m_foreground_width->setRange(theme.foregroundWidth().minimumValue(), theme.foregroundWidth().maximumValue());
	m_foreground_width->setValue(m_theme.foregroundWidth());
	m_foreground_width->setEnabled(m_theme.foregroundPosition() != 3);
	connect(m_foreground_width, SIGNAL(valueChanged(int)), this, SLOT(renderPreview()));

	QFormLayout* foreground_layout = new QFormLayout(foreground_group);
	foreground_layout->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint);
	foreground_layout->addRow(tr("Color:"), m_foreground_color);
	foreground_layout->addRow(tr("Opacity:"), m_foreground_opacity);
	foreground_layout->addRow(tr("Position:"), m_foreground_position);
	foreground_layout->addRow(tr("Width:"), m_foreground_width);


	// Create rounding group
	m_round_corners = new QGroupBox(tr("Round Text Background Corners"), contents);
	m_round_corners->setCheckable(true);
	m_round_corners->setChecked(m_theme.roundCornersEnabled());
	connect(m_round_corners, SIGNAL(clicked()), this, SLOT(renderPreview()));

	m_corner_radius = new QSpinBox(m_round_corners);
	m_corner_radius->setCorrectionMode(QSpinBox::CorrectToNearestValue);
	m_corner_radius->setSuffix(tr(" pixels"));
	m_corner_radius->setRange(theme.cornerRadius().minimumValue(), theme.cornerRadius().maximumValue());
	m_corner_radius->setValue(m_theme.cornerRadius());
	connect(m_corner_radius, SIGNAL(valueChanged(int)), this, SLOT(renderPreview()));

	QFormLayout* corner_layout = new QFormLayout(m_round_corners);
	corner_layout->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint);
	corner_layout->addRow(tr("Radius:"), m_corner_radius);


	// Create blur group
	m_blur = new QGroupBox(tr("Blur Text Background"), contents);
	m_blur->setCheckable(true);
	m_blur->setChecked(m_theme.blurEnabled());
	connect(m_blur, SIGNAL(clicked()), this, SLOT(renderPreview()));

	m_blur_radius = new QSpinBox(m_blur);
	m_blur_radius->setCorrectionMode(QSpinBox::CorrectToNearestValue);
	m_blur_radius->setSuffix(tr(" pixels"));
	m_blur_radius->setRange(theme.blurRadius().minimumValue(), theme.blurRadius().maximumValue());
	m_blur_radius->setValue(m_theme.blurRadius());
	connect(m_blur_radius, SIGNAL(valueChanged(int)), this, SLOT(renderPreview()));

	QFormLayout* blur_layout = new QFormLayout(m_blur);
	blur_layout->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint);
	blur_layout->addRow(tr("Radius:"), m_blur_radius);


	// Create shadow group
	m_shadow = new QGroupBox(tr("Text Background Drop Shadow"), contents);
	m_shadow->setCheckable(true);
	m_shadow->setChecked(m_theme.shadowEnabled());
	connect(m_shadow, SIGNAL(clicked()), this, SLOT(renderPreview()));

	m_shadow_color = new ColorButton(m_shadow);
	m_shadow_color->setColor(m_theme.shadowColor());
	connect(m_shadow_color, SIGNAL(changed(QColor)), this, SLOT(renderPreview()));

	m_shadow_radius = new QSpinBox(m_shadow);
	m_shadow_radius->setCorrectionMode(QSpinBox::CorrectToNearestValue);
	m_shadow_radius->setSuffix(tr(" pixels"));
	m_shadow_radius->setRange(theme.shadowRadius().minimumValue(), theme.shadowRadius().maximumValue());
	m_shadow_radius->setValue(m_theme.shadowRadius());
	connect(m_shadow_radius, SIGNAL(valueChanged(int)), this, SLOT(renderPreview()));

	m_shadow_offset = new QSpinBox(m_shadow);
	m_shadow_offset->setCorrectionMode(QSpinBox::CorrectToNearestValue);
	m_shadow_offset->setSuffix(tr(" pixels"));
	m_shadow_offset->setRange(theme.shadowOffset().minimumValue(), theme.shadowOffset().maximumValue());
	m_shadow_offset->setValue(m_theme.shadowOffset());
	connect(m_shadow_offset, SIGNAL(valueChanged(int)), this, SLOT(renderPreview()));

	QFormLayout* shadow_layout = new QFormLayout(m_shadow);
	shadow_layout->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint);
	shadow_layout->addRow(tr("Color:"), m_shadow_color);
	shadow_layout->addRow(tr("Radius:"), m_shadow_radius);
	shadow_layout->addRow(tr("Vertical Offset:"), m_shadow_offset);


	// Create margins group
	QGroupBox* margins_group = new QGroupBox(tr("Margins"), contents);

	m_foreground_margin = new QSpinBox(margins_group);
	m_foreground_margin->setCorrectionMode(QSpinBox::CorrectToNearestValue);
	m_foreground_margin->setSuffix(tr(" pixels"));
	m_foreground_margin->setRange(theme.foregroundMargin().minimumValue(), theme.foregroundMargin().maximumValue());
	m_foreground_margin->setValue(m_theme.foregroundMargin());
	connect(m_foreground_margin, SIGNAL(valueChanged(int)), this, SLOT(renderPreview()));

	m_foreground_padding = new QSpinBox(margins_group);
	m_foreground_padding->setCorrectionMode(QSpinBox::CorrectToNearestValue);
	m_foreground_padding->setSuffix(tr(" pixels"));
	m_foreground_padding->setRange(theme.foregroundPadding().minimumValue(), theme.foregroundPadding().maximumValue());
	m_foreground_padding->setValue(m_theme.foregroundPadding());
	connect(m_foreground_padding, SIGNAL(valueChanged(int)), this, SLOT(renderPreview()));

	QFormLayout* margins_layout = new QFormLayout(margins_group);
	margins_layout->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint);
	margins_layout->addRow(tr("Window:"), m_foreground_margin);
	margins_layout->addRow(tr("Page:"), m_foreground_padding);


	// Create line spacing group
	QGroupBox* line_spacing = new QGroupBox(tr("Line Spacing"), contents);

	m_line_spacing_type = new QComboBox(line_spacing);
	m_line_spacing_type->setEditable(false);
	m_line_spacing_type->addItems(QStringList() << tr("Single") << tr("1.5 Lines") << tr("Double") << tr("Proportional"));
	m_line_spacing_type->setCurrentIndex(3);

	m_line_spacing = new QSpinBox(line_spacing);
	m_line_spacing->setSuffix(QLocale().percent());
	m_line_spacing->setRange(theme.lineSpacing().minimumValue(), theme.lineSpacing().maximumValue());
	m_line_spacing->setValue(m_theme.lineSpacing());
	m_line_spacing->setEnabled(false);

	switch (m_theme.lineSpacing()) {
	case 100: m_line_spacing_type->setCurrentIndex(0); break;
	case 150: m_line_spacing_type->setCurrentIndex(1); break;
	case 200: m_line_spacing_type->setCurrentIndex(2); break;
	default: m_line_spacing->setEnabled(true); break;
	}
	connect(m_line_spacing_type, SIGNAL(currentIndexChanged(int)), this, SLOT(lineSpacingChanged(int)));
	connect(m_line_spacing_type, SIGNAL(currentIndexChanged(int)), this, SLOT(renderPreview()));
	connect(m_line_spacing, SIGNAL(valueChanged(int)), this, SLOT(renderPreview()));

	QFormLayout* line_spacing_layout = new QFormLayout(line_spacing);
	line_spacing_layout->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint);
	line_spacing_layout->addRow(tr("Type:"), m_line_spacing_type);
	line_spacing_layout->addRow(tr("Height:"), m_line_spacing);


	// Create paragraph spacing group
	QGroupBox* paragraph_spacing = new QGroupBox(tr("Paragraph Spacing"), contents);

	m_tab_width = new QSpinBox(paragraph_spacing);
	m_tab_width->setSuffix(tr(" pixels"));
	m_tab_width->setRange(theme.tabWidth().minimumValue(), theme.tabWidth().maximumValue());
	m_tab_width->setValue(m_theme.tabWidth());
	connect(m_tab_width, SIGNAL(valueChanged(int)), this, SLOT(renderPreview()));

	m_spacing_above_paragraph = new QSpinBox(paragraph_spacing);
	m_spacing_above_paragraph->setSuffix(tr(" pixels"));
	m_spacing_above_paragraph->setRange(theme.spacingAboveParagraph().minimumValue(), theme.spacingAboveParagraph().maximumValue());
	m_spacing_above_paragraph->setValue(m_theme.spacingAboveParagraph());
	connect(m_spacing_above_paragraph, SIGNAL(valueChanged(int)), this, SLOT(renderPreview()));

	m_spacing_below_paragraph = new QSpinBox(paragraph_spacing);
	m_spacing_below_paragraph->setSuffix(tr(" pixels"));
	m_spacing_below_paragraph->setRange(theme.spacingBelowParagraph().minimumValue(), theme.spacingBelowParagraph().maximumValue());
	m_spacing_below_paragraph->setValue(m_theme.spacingBelowParagraph());
	connect(m_spacing_below_paragraph, SIGNAL(valueChanged(int)), this, SLOT(renderPreview()));

	m_indent_first_line = new QCheckBox(tr("Indent first line"), paragraph_spacing);
	m_indent_first_line->setChecked(m_theme.indentFirstLine());
	connect(m_indent_first_line, SIGNAL(toggled(bool)), this, SLOT(renderPreview()));

	QFormLayout* paragraph_spacing_layout = new QFormLayout(paragraph_spacing);
	paragraph_spacing_layout->setFieldGrowthPolicy(QFormLayout::FieldsStayAtSizeHint);
	paragraph_spacing_layout->addRow(tr("Tab Width:"), m_tab_width);
	paragraph_spacing_layout->addRow(tr("Above:"), m_spacing_above_paragraph);
	paragraph_spacing_layout->addRow(tr("Below:"), m_spacing_below_paragraph);
	paragraph_spacing_layout->addRow("", m_indent_first_line);


	// Create preview
	m_preview_text = new QTextEdit;
	m_preview_text->setFrameStyle(QFrame::NoFrame);
	m_preview_text->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	m_preview_text->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	QFile file(":/lorem.txt");
	if (file.open(QFile::ReadOnly)) {
		m_preview_text->setPlainText(QString::fromLatin1(file.readAll()));
		file.close();
	}

	m_preview = new QLabel(this);
	m_preview->setAlignment(Qt::AlignCenter);
	m_preview->setFrameStyle(QFrame::Sunken | QFrame::StyledPanel);

	QPixmap pixmap(480, 270);
	pixmap.fill(palette().window().color());
	m_preview->setPixmap(pixmap);

	m_theme_renderer = new ThemeRenderer(this);
	connect(m_theme_renderer, SIGNAL(rendered(QImage,QRect,Theme)), this, SLOT(renderPreview(QImage,QRect,Theme)));
	renderPreview();


	// Lay out dialog
	QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this);
	m_ok = buttons->button(QDialogButtonBox::Ok);
	connect(buttons, SIGNAL(accepted()), this, SLOT(accept()));
	connect(buttons, SIGNAL(rejected()), this, SLOT(reject()));

	QVBoxLayout* groups_layout = new QVBoxLayout(contents);
	groups_layout->addWidget(text_group);
	groups_layout->addWidget(background_group);
	groups_layout->addWidget(foreground_group);
	groups_layout->addWidget(m_round_corners);
	groups_layout->addWidget(m_blur);
	groups_layout->addWidget(m_shadow);
	groups_layout->addWidget(margins_group);
	groups_layout->addWidget(line_spacing);
	groups_layout->addWidget(paragraph_spacing);

	QGridLayout* layout = new QGridLayout(this);
	layout->setColumnStretch(0, 1);
	layout->setRowStretch(1, 1);
	layout->setRowMinimumHeight(2, layout->margin());
	layout->addLayout(name_layout, 0, 0, 1, 2);
	layout->addWidget(scroll, 1, 0, 1, 1);
	layout->addWidget(m_preview, 1, 1, 1, 1, Qt::AlignCenter);
	layout->addWidget(buttons, 3, 0, 1, 2);

	resize(QSettings().value("ThemeDialog/Size", sizeHint()).toSize());
}
Example #22
0
{
    ui->setupUi(this);
    ui->layoutDirection->setCurrentIndex(layoutDirection() != Qt::LeftToRight);

    foreach (QString styleName, QStyleFactory::keys()) {
        ui->style->addItem(styleName);
        if (style()->objectName().toLower() == styleName.toLower())
            ui->style->setCurrentIndex(ui->style->count() - 1);
    }

    connect(ui->layoutDirection, SIGNAL(activated(int)),
            this, SLOT(layoutDirectionChanged(int)));
    connect(ui->spacing, SIGNAL(valueChanged(int)),
            this, SLOT(spacingChanged(int)));
    connect(ui->fontComboBox, SIGNAL(currentFontChanged(QFont)),
            this, SLOT(fontChanged(QFont)));
    connect(ui->style, SIGNAL(activated(QString)),
            this, SLOT(styleChanged(QString)));
}

EmbeddedDialog::~EmbeddedDialog()
{
    delete ui;
}

void EmbeddedDialog::layoutDirectionChanged(int index)
{
    setLayoutDirection(index == 0 ? Qt::LeftToRight : Qt::RightToLeft);
}

void EmbeddedDialog::spacingChanged(int spacing)
Example #23
0
 void Widget::setFont(Font* font)
 {
     mCurrentFont = font;
     fontChanged();
 }
Example #24
0
EditorWidget::EditorWidget(QString theme, QWidget *parent) :
	QWidget(parent),
	editor_rich_text(new EditorRichText(this)),
	editor_plain_text(new CodeEditor(this, CodeEditor::Html)),
	pag_stacked(new QStackedWidget(this)),
	m_state(Clean),
	m_initialPag(RichTextIndex)
{
	m_theme = theme;
	m_color = editor_rich_text->textColor();

	connect(editor_plain_text, SIGNAL(textChanged()), this, SLOT(plainTextChanged()));
	connect(editor_rich_text, SIGNAL(textChanged()), this, SLOT(richTextChanged()));
	connect(editor_rich_text, SIGNAL(simplifyRichTextChanged(bool)), this, SLOT(richTextChanged()));
	connect(editor_rich_text, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(currentCharFormatChanged(QTextCharFormat)));
	connect(editor_rich_text, SIGNAL(cursorPositionChanged()), this, SLOT(cursorPositionChanged()));

	list_smile = new QListWidget(this);
	list_smile->setMaximumSize(QSize(155, 16777215));
	list_smile->setMovement(QListView::Static);
	list_smile->setResizeMode(QListView::Adjust);
	list_smile->setViewMode(QListView::IconMode);
	connect(list_smile, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(list_smile_itemDoubleClicked(QListWidgetItem*)));

	toolbar_find_replace = new QWidget(this);
	toolbar_find_replace->setMinimumSize(QSize(0, 30));

	QVBoxLayout *main_layout = new QVBoxLayout(this);
	main_layout->setContentsMargins(0, 0, 0, 0);
	main_layout->setSpacing(4);

		QHBoxLayout *toolbar_layout = new QHBoxLayout();
		toolbar_layout->setContentsMargins(0, 0, 0, 0);
		toolbar_layout->setSpacing(10);

			QToolBar *toolbar_edit = new QToolBar(this);
			toolbar_edit->setMinimumSize(QSize(0, 30));
			toolbar_edit->setIconSize(QSize(20, 20));
			toolbar_edit->setStyleSheet("QToolBar{border:0px;}");
		// Save Pdf
		/*		m_pdf_action = createAction(QIcon(m_theme +"img16/pdf.png"), tr("Exportar a PDF") +"...", false, toolbar_edit);
				m_pdf_action->setPriority(QAction::LowPriority);
				m_pdf_action->setShortcut(Qt::CTRL + Qt::Key_D);
				connect(m_pdf_action, SIGNAL(triggered()), this, SLOT(on_edit_export_pdf()));
			toolbar_edit->addAction(m_pdf_action);
			toolbar_edit->addSeparator();*/
		// combos font and size
				QWidget *toolbar_font_input = new QWidget(this);
				QHBoxLayout *combofont_layout = new QHBoxLayout(toolbar_font_input);
				combofont_layout->setContentsMargins(0, 0, 2, 0);
					m_font_input = new QFontComboBox(toolbar_edit);
					connect(m_font_input, SIGNAL(activated(QString)), this, SLOT(on_edit_font(QString)));
				combofont_layout->addWidget(m_font_input);
					m_font_size_input = new QComboBox(toolbar_edit);
					QFontDatabase font_db;
					foreach(int size, font_db.standardSizes())
						m_font_size_input->addItem(QString::number(size));
					connect(m_font_size_input, SIGNAL(activated(QString)), this, SLOT(on_edit_font_size(QString)));
				combofont_layout->addWidget(m_font_size_input);
			//	combofont_layout->setStretch(0, 1);

			toolbar_edit->addWidget(toolbar_font_input);
			toolbar_edit->addSeparator();
		// cut, copy, paste
				m_cut_action = createAction(QIcon(m_theme +"img16/edit_cut.png"), tr("Cortar"), false, toolbar_edit);
				m_cut_action->setPriority(QAction::LowPriority);
				m_cut_action->setShortcut(QKeySequence::Cut);
				connect(m_cut_action, SIGNAL(triggered()), this, SLOT(on_edit_cut()));
			toolbar_edit->addAction(m_cut_action);
				m_copy_action = createAction(QIcon(m_theme +"img16/edit_copy.png"), tr("Copiar"), false, toolbar_edit);
				m_copy_action->setPriority(QAction::LowPriority);
				m_copy_action->setShortcut(QKeySequence::Copy);
				connect(m_copy_action, SIGNAL(triggered()), this, SLOT(on_edit_copy()));
			toolbar_edit->addAction(m_copy_action);
				m_paste_action = createAction(QIcon(m_theme +"img16/edit_paste.png"), tr("Pegar"), false, toolbar_edit);
				m_paste_action->setPriority(QAction::LowPriority);
				m_paste_action->setShortcut(QKeySequence::Paste);
				connect(m_paste_action, SIGNAL(triggered()), this, SLOT(on_edit_paste()));
			toolbar_edit->addAction(m_paste_action);
			toolbar_edit->addSeparator();
		// undo, redo
				m_undo_action = createAction(QIcon(m_theme +"img16/edit_deshacer.png"), tr("Deshacer"), false, toolbar_edit);
				m_undo_action->setShortcut(QKeySequence::Undo);
				connect(m_undo_action, SIGNAL(triggered()), this, SLOT(on_edit_undo()));
			toolbar_edit->addAction(m_undo_action);
				m_redo_action = createAction(QIcon(m_theme +"img16/edit_rehacer.png"), tr("Rehacer"), false, toolbar_edit);
				m_redo_action->setPriority(QAction::LowPriority);
				m_redo_action->setShortcut(QKeySequence::Redo);
				connect(m_redo_action, SIGNAL(triggered()), this, SLOT(on_edit_redo()));
			toolbar_edit->addAction(m_redo_action);
			toolbar_edit->addSeparator();
		// bold, italic, underline, ,
				m_bold_action = createAction(QIcon(m_theme +"img16/edit_negrita.png"), tr("Negrita"), true, toolbar_edit);
				m_bold_action->setPriority(QAction::LowPriority);
				m_bold_action->setShortcut(Qt::CTRL + Qt::Key_B);
				connect(m_bold_action, SIGNAL(triggered()), this, SLOT(on_edit_bold()));
			toolbar_edit->addAction(m_bold_action);
				m_italic_action = createAction(QIcon(m_theme +"img16/edit_cursiva.png"), tr("Cursiva"), true, toolbar_edit);
				m_italic_action->setPriority(QAction::LowPriority);
				m_italic_action->setShortcut(Qt::CTRL + Qt::Key_I);
				connect(m_italic_action, SIGNAL(triggered()), this, SLOT(on_edit_italic()));
			toolbar_edit->addAction(m_italic_action);
				m_underline_action = createAction(QIcon(m_theme +"img16/edit_subrayada.png"), tr("Subrayado"), true, toolbar_edit);
				m_underline_action->setPriority(QAction::LowPriority);
				m_underline_action->setShortcut(Qt::CTRL + Qt::Key_U);
				connect(m_underline_action, SIGNAL(triggered()), this, SLOT(on_edit_underline()));
			toolbar_edit->addAction(m_underline_action);
			toolbar_edit->addSeparator();
		// align: left, center, right, justify
				QActionGroup *grp = new QActionGroup(toolbar_edit);
				connect(grp, SIGNAL(triggered(QAction*)), this, SLOT(on_edit_text_align(QAction*)));
				if (QApplication::isLeftToRight()) {
					m_align_left_action   = createAction(QIcon(m_theme +"img16/edit_text_left.png"), tr("Izquierdo"), true, grp);
					m_align_center_action = createAction(QIcon(m_theme +"img16/edit_text_center.png"), tr("Centro"), true, grp);
					m_align_right_action  = createAction(QIcon(m_theme +"img16/edit_text_right.png"), tr("Derecho"), true, grp);
				} else {
					m_align_right_action  = createAction(QIcon(m_theme +"img16/edit_text_right.png"), tr("Derecho"), true, grp);
					m_align_center_action = createAction(QIcon(m_theme +"img16/edit_text_center.png"), tr("Centro"), true, grp);
					m_align_left_action   = createAction(QIcon(m_theme +"img16/edit_text_left.png"), tr("Izquierdo"), true, grp);
				}
				m_align_justify_action = createAction(QIcon(m_theme +"img16/edit_text_justify.png"), tr("Justificado"), true, grp);
				m_align_left_action->setPriority(QAction::LowPriority);
				m_align_left_action->setShortcut(Qt::CTRL + Qt::Key_L);
				m_align_center_action->setPriority(QAction::LowPriority);
				m_align_center_action->setShortcut(Qt::CTRL + Qt::Key_E);
				m_align_right_action->setPriority(QAction::LowPriority);
				m_align_right_action->setShortcut(Qt::CTRL + Qt::Key_R);
				m_align_justify_action->setPriority(QAction::LowPriority);
				m_align_justify_action->setShortcut(Qt::CTRL + Qt::Key_J);
			toolbar_edit->addActions(grp->actions());
			toolbar_edit->addSeparator();
		// superscript, subscript
				m_valign_sup_action = createAction(QIcon(m_theme +"img16/edit_text_super.png"), tr("Superíndice"), true, toolbar_edit);
				connect(m_valign_sup_action, SIGNAL(triggered(bool)), this, SLOT(on_edit_valign_sup()));
			toolbar_edit->addAction(m_valign_sup_action);
				m_valign_sub_action = createAction(QIcon(m_theme +"img16/edit_text_subs.png"), tr("Subíndice"), true, toolbar_edit);
				connect(m_valign_sub_action, SIGNAL(triggered(bool)), this, SLOT(on_edit_valign_sub()));
			toolbar_edit->addAction(m_valign_sub_action);
			toolbar_edit->addSeparator();
		// image, link, color, simplify
				m_image_action = createAction(QIcon(m_theme +"img16/edit_imagen.png"), tr("Imagen"), false, toolbar_edit);
				connect(m_image_action, SIGNAL(triggered()), this, SLOT(on_edit_image()));
			toolbar_edit->addAction(m_image_action);
				m_link_action = createAction(QIcon(m_theme +"img16/edit_enlace.png"), tr("Enlace"), true, toolbar_edit);
				connect(m_link_action, SIGNAL(triggered(bool)), this, SLOT(on_edit_link(bool)));
			toolbar_edit->addAction(m_link_action);
				QPixmap pix(16, 16);
				pix.fill(Qt::black);
				m_color_action = createAction(QIcon(pix), tr("Color") +"...", false, toolbar_edit);
				connect(m_color_action, SIGNAL(triggered()), this, SLOT(on_edit_color()));
			toolbar_edit->addAction(m_color_action);
			toolbar_edit->addSeparator();
				m_simplify_richtext_action = createAction(QIcon(m_theme +"img16/edit_simplify_richtext.png"), tr("Simplificar") +" Html", true, toolbar_edit);
				m_simplify_richtext_action->setChecked(editor_rich_text->simplifyRichText());
				connect(m_simplify_richtext_action, SIGNAL(triggered(bool)), editor_rich_text, SLOT(setSimplifyRichText(bool)));
				connect(editor_rich_text, SIGNAL(simplifyRichTextChanged(bool)), m_simplify_richtext_action, SLOT(setChecked(bool)));
			toolbar_edit->addAction(m_simplify_richtext_action);

		toolbar_layout->addWidget(toolbar_edit);

			QToolBar *toolbar_opts = new QToolBar(this);
			toolbar_opts->setIconSize(QSize(20, 20));
			toolbar_opts->setMinimumSize(QSize(30, 30));
			toolbar_opts->setStyleSheet("QToolBar{border:0px;}");
				m_find_replace_text_action = createAction(QIcon(m_theme +"img16/edit_buscar.png"), tr("Buscar") +"/"+ tr("Reemplazar"), true, toolbar_opts);
				m_find_replace_text_action->setPriority(QAction::LowPriority);
				m_find_replace_text_action->setShortcut(QKeySequence::Find);
				connect(m_find_replace_text_action, SIGNAL(triggered(bool)), this, SLOT(on_show_find_replace(bool)));
			toolbar_opts->addAction(m_find_replace_text_action);
				m_rich_plain_action = createAction(QIcon(m_theme +"img16/script.png"), tr("Editor") +"/"+ tr("Código"), true, toolbar_opts);
				connect(m_rich_plain_action, SIGNAL(triggered(bool)), this, SLOT(on_show_source(bool)));
			toolbar_opts->addAction(m_rich_plain_action);
				m_smiles_action = createAction(QIcon(m_theme +"img16/smile.png"), tr("Smiles"), true, toolbar_opts);
				connect(m_smiles_action, SIGNAL(triggered(bool)), list_smile, SLOT(setVisible(bool)));
			toolbar_opts->addAction(m_smiles_action);

		toolbar_layout->addWidget(toolbar_opts);
		toolbar_layout->setStretch(0, 1);

	main_layout->addLayout(toolbar_layout);

		QHBoxLayout *edit_smiles_layout = new QHBoxLayout();
		edit_smiles_layout->setContentsMargins(0, 0, 0, 0);
		edit_smiles_layout->setSpacing(4);

			QWidget *rich_edit = new QWidget();
				QVBoxLayout *rich_edit_layout = new QVBoxLayout(rich_edit);
				rich_edit_layout->setContentsMargins(0, 0, 0, 0);
				rich_edit_layout->addWidget(editor_rich_text);
			pag_stacked->addWidget(rich_edit);

			QWidget *plain_edit = new QWidget();
				QVBoxLayout *plain_edit_layout = new QVBoxLayout(plain_edit);
				plain_edit_layout->setContentsMargins(0, 0, 0, 0);
				plain_edit_layout->addWidget(editor_plain_text);
			pag_stacked->addWidget(plain_edit);
			connect(pag_stacked, SIGNAL(currentChanged(int)), this, SLOT(pagIndexChanged(int)));

		edit_smiles_layout->addWidget(pag_stacked);
		edit_smiles_layout->addWidget(list_smile);

	main_layout->addLayout(edit_smiles_layout);

		QGridLayout *gridLayout = new QGridLayout(toolbar_find_replace);
		gridLayout->setSpacing(4);
		gridLayout->setContentsMargins(0, 0, 0, 0);
			QLabel *lb_find = new QLabel(tr("Buscar")+":", toolbar_find_replace);
		gridLayout->addWidget(lb_find, 0, 0, 1, 1);
			txt_find = new QLineEdit(toolbar_find_replace);
			txt_find->setMinimumSize(QSize(0, 24));
			connect(txt_find, SIGNAL(textChanged(QString)), this, SLOT(txtFindTextChanged(QString)));
		gridLayout->addWidget(txt_find, 0, 1, 1, 1);
			QToolButton *btnFindBack = createToolButton(QIcon(m_theme +"img16/edit_buscar_anterior.png"), tr("Buscar anterior"), toolbar_find_replace);
			btnFindBack->setShortcut(QKeySequence::FindPrevious);
			connect(btnFindBack, SIGNAL(clicked()), this, SLOT(btnFindBack_clicked()));
		gridLayout->addWidget(btnFindBack, 0, 2, 1, 1);
			QToolButton *btnFindNext = createToolButton(QIcon(m_theme +"img16/edit_buscar_siguiente.png"), tr("Buscar siguiente"), toolbar_find_replace);
			btnFindBack->setShortcut(QKeySequence::FindNext);
			connect(btnFindNext, SIGNAL(clicked()), this, SLOT(btnFindNext_clicked()));
		gridLayout->addWidget(btnFindNext, 0, 3, 1, 1);
			chkCaseSensitive = new QCheckBox(tr("Coincidir mayúsculas/minúsculas"), toolbar_find_replace);
			chkCaseSensitive->setChecked(false);
			connect(chkCaseSensitive, SIGNAL(toggled(bool)), this, SLOT(chkCaseSensitive_toggled(bool)));
		gridLayout->addWidget(chkCaseSensitive, 0, 5, 1, 1);
			QCheckBox *chkReplace = new QCheckBox(tr("Reemplazar por") +":", toolbar_find_replace);
			chkReplace->setChecked(false);
			connect(chkReplace, SIGNAL(toggled(bool)), this, SLOT(chkReplace_toggled(bool)));
		gridLayout->addWidget(chkReplace, 1, 0, 1, 1);
			txt_replace = new QLineEdit(toolbar_find_replace);
			txt_replace->setEnabled(false);
			txt_replace->setMinimumSize(QSize(0, 24));
		gridLayout->addWidget(txt_replace, 1, 1, 1, 1);
			btnReplace = createToolButton(QIcon(m_theme +"img16/edit_reemplazar.png"), tr("Reemplazar"), toolbar_find_replace);
			btnReplace->setEnabled(false);
			connect(btnReplace, SIGNAL(clicked()), this, SLOT(btnReplace_clicked()));
		gridLayout->addWidget(btnReplace, 1, 2, 1, 1);
			btnReplaceAndNext = createToolButton(QIcon(m_theme +"img16/edit_reemplazar.png"), tr("Reemplazar siguiente"), toolbar_find_replace);
			btnReplaceAndNext->setEnabled(false);
			connect(btnReplaceAndNext, SIGNAL(clicked()), this, SLOT(btnReplaceAndNext_clicked()));
		gridLayout->addWidget(btnReplaceAndNext, 1, 3, 1, 1);
			btnReplaceAll = createToolButton(QIcon(m_theme +"img16/edit_reemplazar.png"), tr("Reemplazar todo"), toolbar_find_replace);
			btnReplaceAll->setEnabled(false);
			connect(btnReplaceAll, SIGNAL(clicked()), this, SLOT(btnReplaceAll_clicked()));
		gridLayout->addWidget(btnReplaceAll, 1, 4, 1, 1);
			chkWholeWords = new QCheckBox(tr("Solo palabras completas"), toolbar_find_replace);
		gridLayout->addWidget(chkWholeWords, 1, 5, 1, 1);

	main_layout->addWidget(toolbar_find_replace);

#ifndef QT_NO_CLIPBOARD
	connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged()));
#endif

	showSource(m_initialPag == RichTextIndex ? false : true);
	showFindReplace(false);
	showSmiles(false);
	setTabStopWidth(40);

	fontChanged(editor_rich_text->font());
	colorChanged(editor_rich_text->textColor());
	alignmentChanged(editor_rich_text->alignment());
}
Example #25
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    createStatusBar();

    // Recent files
    for (int i = 0; i < MaxRecentFiles; ++i)
    {
	recentFileActions[i] = new QAction(this);
	recentFileActions[i]->setVisible(false);
	connect(recentFileActions[i], SIGNAL(triggered()), this, SLOT(openRecentFile()));
	ui->menuFile->insertAction(ui->actionExit, recentFileActions[i]);
    }
    recentFilesSeparator = ui->menuFile->insertSeparator(ui->actionExit);

    printer = new QPrinter;
    printer->setFullPage(true);
    printer->setPaperSize(QPrinter::Letter);
    printer->setPageMargins(.5, .5, .5, .5, QPrinter::Inch);

    report = new Report(printer, this);
    view = new ReportView(report, this);

    preview = new QPrintPreviewWidget(printer, this);
    setCentralWidget(preview);
    preview->fitToWidth();

    QFontComboBox* fontComboBox = new QFontComboBox;
    fontComboBox->setFontFilters(QFontComboBox::MonospacedFonts | QFontComboBox::ScalableFonts);
    fontComboBox->setCurrentFont(report->font().family());
    ui->fontToolBar->insertWidget(ui->actionBold, fontComboBox);
    connect(fontComboBox, SIGNAL(currentFontChanged(QFont)), report, SLOT(setFont(QFont)));

    pageNumberComboBox = new QComboBox;
    ui->viewToolBar->insertWidget(ui->actionNextPage, pageNumberComboBox);
    connect(pageNumberComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(currentPageChanged(int)));

    const qreal zoomFactors[] = { 12.5, 25, 50, 100, 125, 150, 200, 400, 800 };
    zoomComboBox = new QComboBox;
    for (unsigned int i = 0; i < sizeof(zoomFactors) / sizeof(*zoomFactors); ++i)
    {
	zoomComboBox->addItem(QString("%1%").arg(zoomFactors[i]));
    }
    zoomComboBox->setCurrentIndex(-1);
    ui->viewToolBar->insertWidget(ui->actionZoomOut, zoomComboBox);
    connect(zoomComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(zoomChanged(QString)));

    QActionGroup* orientationGroup = new QActionGroup(this);
    orientationGroup->addAction(ui->actionPortrait);
    orientationGroup->addAction(ui->actionLandscape);
    orientationChanged(report->orientation());

    QActionGroup* heightGroup = new QActionGroup(this);
    heightGroup->addAction(ui->action6LPI);
    heightGroup->addAction(ui->action8LPI);
    heightGroup->addAction(ui->action9LPI);
    heightGroup->setDisabled(ui->actionStretchFont->isEnabled());
    connect(ui->actionStretchFont, SIGNAL(toggled(bool)), heightGroup, SLOT(setDisabled(bool)));

    QActionGroup* widthGroup = new QActionGroup(this);
    widthGroup->addAction(ui->actionDefaultWidth);
    widthGroup->addAction(ui->action10CPI);
    widthGroup->addAction(ui->action12CPI);
    widthGroup->addAction(ui->action17CPI);
    widthGroup->setDisabled(ui->actionStretchFont->isEnabled());
    connect(ui->actionStretchFont, SIGNAL(toggled(bool)), widthGroup, SLOT(setDisabled(bool)));

    QActionGroup* pageGroup = new QActionGroup(this);
    pageGroup->addAction(ui->actionSinglePage);
    pageGroup->addAction(ui->actionFacingPages);
    pageGroup->addAction(ui->actionAllPages);
    ui->actionSinglePage->setChecked(preview->viewMode() == QPrintPreviewWidget::SinglePageView);
    ui->actionFacingPages->setChecked(preview->viewMode() == QPrintPreviewWidget::FacingPagesView);
    ui->actionAllPages->setChecked(preview->viewMode() == QPrintPreviewWidget::AllPagesView);

    connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(about()));
    connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(open()));
    connect(ui->actionOpenURL, SIGNAL(triggered()), this, SLOT(openUrl()));
    connect(ui->actionReload, SIGNAL(triggered()), this, SLOT(reload()));
    connect(ui->actionSaveAsPDF, SIGNAL(triggered()), this, SLOT(saveAsPdf()));
    connect(ui->actionPrint, SIGNAL(triggered()), this, SLOT(print()));
    connect(ui->actionPageSetup, SIGNAL(triggered()), this, SLOT(pageSetup()));
    connect(ui->actionEmail, SIGNAL(triggered()), this, SLOT(email()));
    connect(ui->actionCopy, SIGNAL(triggered()), this, SLOT(copy()));
    connect(ui->actionStretchFont, SIGNAL(toggled(bool)), report, SLOT(setStretchFont(bool)));
    connect(report, SIGNAL(stretchFontChanged(bool)), ui->actionStretchFont, SLOT(setChecked(bool)));
    connect(ui->actionBold, SIGNAL(toggled(bool)), report, SLOT(setBold(bool)));
    connect(ui->actionStripes, SIGNAL(toggled(bool)), report, SLOT(setStripes(bool)));
    connect(ui->actionStripeColor, SIGNAL(triggered()), this, SLOT(stripeColor()));
    connect(ui->actionColor, SIGNAL(triggered()), this, SLOT(fontColor()));
    connect(ui->action6LPI, SIGNAL(triggered()), this, SLOT(height6Lpi()));
    connect(ui->action8LPI, SIGNAL(triggered()), this, SLOT(height8Lpi()));
    connect(ui->action9LPI, SIGNAL(triggered()), this, SLOT(height9Lpi()));
    connect(ui->actionDefaultWidth, SIGNAL(toggled(bool)), this, SLOT(widthDefault()));
    connect(ui->action10CPI, SIGNAL(triggered()), this, SLOT(width10Cpi()));
    connect(ui->action12CPI, SIGNAL(triggered()), this, SLOT(width12Cpi()));
    connect(ui->action17CPI, SIGNAL(triggered()), this, SLOT(width17Cpi()));
    connect(ui->actionFirstPage, SIGNAL(triggered()), this, SLOT(firstPage()));
    connect(ui->actionPreviousPage, SIGNAL(triggered()), this, SLOT(previousPage()));
    connect(ui->actionNextPage, SIGNAL(triggered()), this, SLOT(nextPage()));
    connect(ui->actionLastPage, SIGNAL(triggered()), this, SLOT(lastPage()));
    connect(ui->actionFitWidth, SIGNAL(triggered()), preview, SLOT(fitToWidth()));
    connect(ui->actionFitHeight, SIGNAL(triggered()), preview, SLOT(fitInView()));
    connect(ui->actionPortrait, SIGNAL(triggered()), preview, SLOT(setPortraitOrientation()));
    connect(ui->actionLandscape, SIGNAL(triggered()), preview, SLOT(setLandscapeOrientation()));
    connect(ui->actionActualSize, SIGNAL(triggered()), this, SLOT(actualSize()));
    connect(ui->actionZoomIn, SIGNAL(triggered()), preview, SLOT(zoomIn()));
    connect(ui->actionZoomOut, SIGNAL(triggered()), preview, SLOT(zoomOut()));
    connect(ui->actionSinglePage, SIGNAL(triggered()), preview, SLOT(setSinglePageViewMode()));
    connect(ui->actionFacingPages, SIGNAL(triggered()), preview, SLOT(setFacingPagesViewMode()));
    connect(ui->actionAllPages, SIGNAL(triggered()), preview, SLOT(setAllPagesViewMode()));
    connect(ui->actionMainToolbar, SIGNAL(triggered(bool)), this, SLOT(toggleMainToolbar(bool)));
    connect(ui->actionViewToolbar, SIGNAL(triggered(bool)), this, SLOT(toggleViewToolbar(bool)));
    connect(ui->actionFontToolbar, SIGNAL(triggered(bool)), this, SLOT(toggleFontToolbar(bool)));
    connect(ui->actionStatusBar, SIGNAL(triggered(bool)), this, SLOT(toggleStatusBar(bool)));
    connect(ui->menuToolbars, SIGNAL(aboutToShow()), this, SLOT(updateToolbarMenu()));
    connect(ui->menuView, SIGNAL(aboutToShow()), this, SLOT(updateToolbarMenu()));
    connect(preview, SIGNAL(previewChanged()), this, SLOT(previewChanged()));

    connect(preview, SIGNAL(paintRequested(QPrinter*)), this, SLOT(paint(QPrinter*)));
    connect(report, SIGNAL(loaded()), preview, SLOT(updatePreview()));
    connect(report, SIGNAL(changed()), preview, SLOT(updatePreview()));
    connect(report, SIGNAL(loaded()), this, SLOT(documentLoaded()));
    connect(report, SIGNAL(orientationChanged(QPrinter::Orientation)), this, SLOT(orientationChanged(QPrinter::Orientation)));
    connect(report, SIGNAL(lpiChanged(int)), this, SLOT(lpiChanged(int)));
    connect(report, SIGNAL(cpiChanged(int)), this, SLOT(cpiChanged(int)));
    connect(report, SIGNAL(boldChanged(bool)), ui->actionBold, SLOT(setChecked(bool)));
    connect(report, SIGNAL(fontChanged(QFont)), fontComboBox, SLOT(setCurrentFont(QFont)));

    QSettings settings;
    restoreGeometry(settings.value("geometry").toByteArray());
    restoreState(settings.value("state").toByteArray());
    recentFiles = settings.value("recentFiles").toStringList();
    currentFolder = settings.value("currentFolder").toString();
    ui->statusBar->setVisible(settings.value("statusBar", true).toBool());

    updateRecentFileActions();

    zoomTimer = new QTimer(this);
    connect(zoomTimer, SIGNAL(timeout()), this, SLOT(updateZoom()));
    connect(preview, SIGNAL(previewChanged()), this, SLOT(updateZoom()));
    zoomTimer->start(1000);
}
Example #26
0
void EditorWidget::setDefaultFont(const QFont &font)
{
	editor_rich_text->setDefaultFont(font);
	fontChanged(editor_rich_text->font());
}
Example #27
0
TextEdit::TextEdit(QWidget *parent)
    : QMainWindow(parent)
{
    setToolButtonStyle(Qt::ToolButtonFollowStyle);
    setupFileActions();
    setupEditActions();
    setupTextActions();

    {
        QMenu *helpMenu = new QMenu(tr("Help"), this);
        menuBar()->addMenu(helpMenu);
        helpMenu->addAction(tr("About"), this, SLOT(about()));
        helpMenu->addAction(tr("About &Qt"), qApp, SLOT(aboutQt()));
    }

    textEdit = new QTextEdit(this);

    connect(textEdit, SIGNAL(currentCharFormatChanged(QTextCharFormat)),
            this, SLOT(currentCharFormatChanged(QTextCharFormat)));
    connect(textEdit, SIGNAL(cursorPositionChanged()),
            this, SLOT(cursorPositionChanged()));

    setCentralWidget(textEdit);
    textEdit->setFocus();
    setCurrentFileName(QString());

    fontChanged(textEdit->font());
    colorChanged(textEdit->textColor());
    alignmentChanged(textEdit->alignment());

    connect(textEdit->document(), SIGNAL(modificationChanged(bool)),
            actionSave, SLOT(setEnabled(bool)));
    connect(textEdit->document(), SIGNAL(modificationChanged(bool)),
            this, SLOT(setWindowModified(bool)));
    connect(textEdit->document(), SIGNAL(undoAvailable(bool)),
            actionUndo, SLOT(setEnabled(bool)));
    connect(textEdit->document(), SIGNAL(redoAvailable(bool)),
            actionRedo, SLOT(setEnabled(bool)));

    setWindowModified(textEdit->document()->isModified());
    actionSave->setEnabled(textEdit->document()->isModified());
    actionUndo->setEnabled(textEdit->document()->isUndoAvailable());
    actionRedo->setEnabled(textEdit->document()->isRedoAvailable());

    connect(actionUndo, SIGNAL(triggered()), textEdit, SLOT(undo()));
    connect(actionRedo, SIGNAL(triggered()), textEdit, SLOT(redo()));

    actionCut->setEnabled(false);
    actionCopy->setEnabled(false);

    connect(actionCut, SIGNAL(triggered()), textEdit, SLOT(cut()));
    connect(actionCopy, SIGNAL(triggered()), textEdit, SLOT(copy()));
    connect(actionPaste, SIGNAL(triggered()), textEdit, SLOT(paste()));

    connect(textEdit, SIGNAL(copyAvailable(bool)), actionCut, SLOT(setEnabled(bool)));
    connect(textEdit, SIGNAL(copyAvailable(bool)), actionCopy, SLOT(setEnabled(bool)));

#ifndef QT_NO_CLIPBOARD
    connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged()));
#endif

    QString initialFile = "/example.html";
    const QStringList args = QCoreApplication::arguments();
    if (args.count() == 2)
        initialFile = args.at(1);

    if (!load(initialFile))
        fileNew();
}
Example #28
0
void CDiaryEdit::slotCurrentCharFormatChanged(const QTextCharFormat &format)
{
    fontChanged(format.font());
    colorChanged(format.foreground().color());
}
Example #29
0
/** Default constructor */
PopupChatDialog::PopupChatDialog(const std::string &id, const QString &name, QWidget *parent, Qt::WFlags flags)
  : QWidget(parent, flags), dialogId(id), dialogName(name),
    lastChatTime(0), lastChatName("")
    
{
  /* Invoke Qt Designer generated QObject setup routine */
  ui.setupUi(this);

  newMessages = false;
  typing = false;
  m_manualDelete = false;
  peerStatus = 0;

  last_status_send_time = 0 ;
  chatStyle.setStyleFromSettings(ChatStyle::TYPE_PRIVATE);

  /* Hide or show the frames */
  showAvatarFrame(PeerSettings->getShowAvatarFrame(dialogId));
  ui.infoframe->setVisible(false);
  ui.statusmessagelabel->hide();

  connect(ui.avatarFrameButton, SIGNAL(toggled(bool)), this, SLOT(showAvatarFrame(bool)));

  connect(ui.sendButton, SIGNAL(clicked( ) ), this, SLOT(sendChat( ) ));
  connect(ui.addFileButton, SIGNAL(clicked() ), this , SLOT(addExtraFile()));

  connect(ui.textboldButton, SIGNAL(clicked()), this, SLOT(setFont()));  
  connect(ui.textunderlineButton, SIGNAL(clicked()), this, SLOT(setFont()));  
  connect(ui.textitalicButton, SIGNAL(clicked()), this, SLOT(setFont()));
  connect(ui.attachPictureButton, SIGNAL(clicked()), this, SLOT(addExtraPicture()));
  connect(ui.fontButton, SIGNAL(clicked()), this, SLOT(getFont())); 
  connect(ui.colorButton, SIGNAL(clicked()), this, SLOT(setColor()));
  connect(ui.emoteiconButton, SIGNAL(clicked()), this, SLOT(smileyWidget()));
  connect(ui.actionSave_Chat_History, SIGNAL(triggered()), this, SLOT(fileSaveAs()));
  connect(ui.actionClearOfflineMessages, SIGNAL(triggered()), this, SLOT(clearOfflineMessages()));


  connect(NotifyQt::getInstance(), SIGNAL(peerStatusChanged(const QString&, int)), this, SLOT(updateStatus(const QString&, int)));
  connect(NotifyQt::getInstance(), SIGNAL(peerHasNewCustomStateString(const QString&, const QString&)), this, SLOT(updatePeersCustomStateString(const QString&, const QString&)));

  connect(ui.chattextEdit,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(contextMenu(QPoint)));

  // Create the status bar
  resetStatusBar();

  ui.textboldButton->setIcon(QIcon(QString(":/images/edit-bold.png")));
  ui.textunderlineButton->setIcon(QIcon(QString(":/images/edit-underline.png")));
  ui.textitalicButton->setIcon(QIcon(QString(":/images/edit-italic.png")));
  ui.fontButton->setIcon(QIcon(QString(":/images/fonts.png")));
  ui.emoteiconButton->setIcon(QIcon(QString(":/images/emoticons/kopete/kopete020.png")));
  
  ui.textboldButton->setCheckable(true);
  ui.textunderlineButton->setCheckable(true);
  ui.textitalicButton->setCheckable(true);

  setAcceptDrops(true);
  ui.chattextEdit->setAcceptDrops(false);

  QMenu * toolmenu = new QMenu();
  toolmenu->addAction(ui.actionClear_Chat_History);
  toolmenu->addAction(ui.actionDelete_Chat_History);
  toolmenu->addAction(ui.actionSave_Chat_History);
  toolmenu->addAction(ui.actionClearOfflineMessages);
  toolmenu->addAction(ui.actionMessageHistory);
  //toolmenu->addAction(ui.action_Disable_Emoticons);
  ui.pushtoolsButton->setMenu(toolmenu);

  mCurrentColor.setNamedColor(PeerSettings->getPrivateChatColor(dialogId));
  mCurrentFont.fromString(PeerSettings->getPrivateChatFont(dialogId));

  colorChanged(mCurrentColor);
  fontChanged(mCurrentFont);

  updateAvatar() ;
  updatePeerAvatar(id) ;

  // load settings
  processSettings(true);

  // load style
  PeerSettings->getStyle(dialogId, "PopupChatDialog", style);

  // initialize first status
  StatusInfo peerStatusInfo;
  // No check of return value. Non existing status info is handled as offline.
  rsStatus->getStatus(dialogId, peerStatusInfo);
  updateStatus(QString::fromStdString(dialogId), peerStatusInfo.status);

  StatusInfo ownStatusInfo;
  if (rsStatus->getOwnStatus(ownStatusInfo)) {
    updateStatus(QString::fromStdString(ownStatusInfo.id), ownStatusInfo.status);
  }

  // initialize first custom state string
  QString customStateString = QString::fromUtf8(rsMsgs->getCustomStateString(dialogId).c_str());
  updatePeersCustomStateString(QString::fromStdString(dialogId), customStateString);

  if (Settings->valueFromGroup("Chat", QString::fromUtf8("PrivateChat_History"), true).toBool()) {
      historyKeeper.init(QString::fromStdString(RsInit::RsProfileConfigDirectory()) + "/chat_" + QString::fromStdString(dialogId) +  ".xml");

      // get offline chat messages
      std::list<ChatInfo> offlineChat;
      std::list<ChatInfo>::iterator offineChatIt;
      rsMsgs->getPrivateChatQueueCount(false) && rsMsgs->getPrivateChatQueue(false, dialogId, offlineChat);

      QList<IMHistoryItem> historyItems;
      int messageCount = Settings->getPrivateChatHistoryCount();
      if (messageCount > 0) {
          historyKeeper.getMessages(historyItems, messageCount);
      }
      foreach(IMHistoryItem item, historyItems) {
          for(offineChatIt = offlineChat.begin(); offineChatIt != offlineChat.end(); offineChatIt++) {
              /* are they public? */
              if ((offineChatIt->chatflags & RS_CHAT_PRIVATE) == 0) {
                  /* this should not happen */
                  continue;
              }

              QDateTime sendTime = QDateTime::fromTime_t(offineChatIt->sendTime);
              QString message = QString::fromStdWString(offineChatIt->msg);

              if (IMHistoryKeeper::compareItem(item, false, offineChatIt->rsid, sendTime, message)) {
                  // don't show offline message out of the history
                  break;
              }
          }

          if (offineChatIt == offlineChat.end()) {
              addChatMsg(item.incoming, item.id, item.name, item.sendTime, item.recvTime, item.messageText, TYPE_HISTORY, false);
          }
      }
  }
Example #30
0
//PROPERTY DefaultFont
void QQGeneralSettings::setDefaultFont(const QFont &font)
{
	m_defaultFont = font;
	ui->fontFamComboB->setCurrentFont(m_defaultFont);
	fontChanged(m_defaultFont);
}