// Called from WSD and handled inside the kit. virtual bool filterKitMessage(const std::shared_ptr<Poco::Net::WebSocket> &ws, std::string &message) override { std::string token = LOOLProtocol::getFirstToken(message.c_str(), message.length()); if (token == "unit-getfontlist:") { std::string fontListReply = getFontList() + "\n"; ws->sendFrame(fontListReply.c_str(), fontListReply.length()); return true; } return false; }
// Called in the forkit after forking the kit virtual void launchedKit(int /* pid */) override { // Open websocket connection between the child process and WSD. Poco::Net::HTTPClientSession cs("127.0.0.1", MasterPortNumber); cs.setTimeout(0); Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, std::string(UNIT_URI)); Poco::Net::HTTPResponse response; auto ws = std::make_shared<Poco::Net::WebSocket>(cs, request, response); ws->setReceiveTimeout(0); Log::info("Fetching font list from forkit"); std::string fontListMsg = getFontList() + "\n"; ws->sendFrame(fontListMsg.c_str(), fontListMsg.length()); }
void KFontChooser::getFontList( QStrList &list, bool fixed ) { // Use KDE fonts if there is a KDE font list and check that the fonts // exist on the server where the desktop is running. QStrList lstSys, lstKDE; if ( fixed ) { getFontList( lstSys, "-*-*-*-*-*-*-*-*-*-*-m-*-*-*" ); getFontList( lstSys, "-*-*-*-*-*-*-*-*-*-*-c-*-*-*" ); } else getFontList( lstSys, "-*-*-*-*-*-*-*-*-*-*-p-*-*-*" ); if ( !kapp->getKDEFonts( &lstKDE ) ) { list = lstSys; return; } for( int i = 0; i < (int) lstKDE.count(); i++ ) { if ( lstSys.find( lstKDE.at( i ) ) != -1 ) { list.append( lstKDE.at( i ) ); } } }
KFontChooser::KFontChooser( QWidget *parent, const char *name ) : QWidget( parent, name ) { int i; fnt = QFont( "helvetica", 12 ); changed = False; QBoxLayout *topLayout = new QVBoxLayout( this, 10, 5 ); topLayout->addStretch( 5 ); QBoxLayout *stackLayout = new QVBoxLayout( 4 ); topLayout->addLayout( stackLayout ); cmbFont = new QComboBox( false, this ); cmbFont->setFixedHeight( cmbFont->sizeHint().height() ); getFontList( fixedList, true ); getFontList( fontList ); cmbFont->insertStrList( &fontList ); QStrListIterator it( fontList ); for ( i = 0; it.current(); ++it, i++ ) { if ( !strcmp( fnt.family(), it.current() ) ) cmbFont->setCurrentItem( i ); } connect( cmbFont, SIGNAL( activated( const char * ) ), SLOT( slotSelectFont( const char * ) ) ); QLabel *label = new QLabel( cmbFont, i18n("&Typeface"), this ); label->adjustSize(); label->setMinimumSize( label->size() ); stackLayout->addWidget( label ); stackLayout->addWidget( cmbFont ); cbBold = new QCheckBox( i18n("&Bold"), this ); cbBold->setMinimumSize( cbBold->sizeHint() ); cbBold->setChecked( fnt.bold() ); connect( cbBold, SIGNAL( toggled( bool ) ), SLOT( slotFontBold( bool ) ) ); topLayout->addWidget( cbBold ); cbItalic = new QCheckBox( i18n("&Italic"), this ); cbItalic->setMinimumSize( cbItalic->sizeHint() ); cbItalic->setChecked( fnt.italic() ); connect( cbItalic, SIGNAL( toggled( bool ) ), SLOT( slotFontItalic( bool ) ) ); topLayout->addWidget( cbItalic ); QBoxLayout *pushLayout = new QHBoxLayout( 2 ); topLayout->addLayout( pushLayout ); stackLayout = new QVBoxLayout( 4 ); pushLayout->addLayout( stackLayout, 10 ); pushLayout->addSpacing( 10 ); sbSize = new KNumericSpinBox( this ); sbSize->setStep( 1 ); sbSize->setRange( 8, 16 ); sbSize->setValue( 12 ); sbSize->adjustSize(); connect( sbSize, SIGNAL( valueDecreased() ), SLOT( slotFontSize() ) ); connect( sbSize, SIGNAL( valueIncreased() ), SLOT( slotFontSize() ) ); label = new QLabel( sbSize, i18n("&Size"), this ); label->setMinimumSize( label->sizeHint() ); cmbCharset = new QComboBox( false, this ); cmbCharset->adjustSize(); cmbCharset->setInsertionPolicy( QComboBox::NoInsertion ); connect( cmbCharset, SIGNAL( activated( const char * ) ), SLOT( slotCharset( const char * ) ) ); sbSize->setFixedHeight( cmbCharset->height() ); sbSize->setMinimumWidth(sbSize->width()); cmbCharset->setFixedHeight( cmbCharset->height() ); cmbCharset->setMinimumWidth( cmbCharset->width()); stackLayout->addWidget( label ); stackLayout->addWidget( sbSize ); stackLayout = new QVBoxLayout( 4 ); pushLayout->addLayout( stackLayout, 30 ); label = new QLabel( cmbCharset, i18n("&Character set"), this ); label->adjustSize(); label->setMinimumSize( label->size() ); stackLayout->addWidget( label ); stackLayout->addWidget( cmbCharset ); topLayout->activate(); fillCharsetCombo(); }
void GLEDrawingObject::initialiseProperties() { QVariantMap validList; // This property describes the fill colour for a solid object // or for text propertyDescriptions[FillColour].description = tr("Fill Colour"); propertyDescriptions[FillColour].type = QVariant::Color; propertyDescriptions[FillColour].defaultValue = QColor(); propertyDescriptions[FillColour].validValues = QList<QVariant>(); // The line colour propertyDescriptions[LineColour].description = tr("Line Colour"); propertyDescriptions[LineColour].type = QVariant::Color; propertyDescriptions[LineColour].defaultValue = QColor(); propertyDescriptions[LineColour].validValues = QList<QVariant>(); // The line width propertyDescriptions[LineWidth].description = tr("Line Width"); propertyDescriptions[LineWidth].type = QVariant::Double; propertyDescriptions[LineWidth].defaultValue = 0.05; propertyDescriptions[LineWidth].validValues = QList<QVariant>(); // The line style propertyDescriptions[LineStyle].description = tr("Line Style"); propertyDescriptions[LineStyle].type = QVariant::String; propertyDescriptions[LineStyle].defaultValue = QString("0"); propertyDescriptions[LineStyle].validValues = QList<QVariant>(); // The string contained in a text object (and possible some other // objects as well such as boxes in a flow chart) propertyDescriptions[Text].description = tr("Text"); propertyDescriptions[Text].type = QVariant::String; propertyDescriptions[Text].defaultValue = QString(""); propertyDescriptions[Text].validValues = QList<QVariant>(); // The font used for a given text string propertyDescriptions[FontName].description = tr("Font Name"); propertyDescriptions[FontName].type = QVariant::Int; propertyDescriptions[FontName].defaultValue = 0; propertyDescriptions[FontName].validValues = getFontList(); // The font used for a given text string propertyDescriptions[FontStyle].description = tr("Font Style"); propertyDescriptions[FontStyle].type = QVariant::Int; propertyDescriptions[FontStyle].defaultValue = 0; propertyDescriptions[FontStyle].validValues = getFontStyles(); // The font size propertyDescriptions[FontSize].description = tr("Font Size"); propertyDescriptions[FontSize].type = QVariant::Double; propertyDescriptions[FontSize].defaultValue = 0.3633; propertyDescriptions[FontSize].validValues = QList<QVariant>(); // The text alignment (e.g. CC) propertyDescriptions[Alignment].description = tr("Text Alignment"); propertyDescriptions[Alignment].type = QVariant::Int; propertyDescriptions[Alignment].defaultValue = 0; validList.clear(); validList[tr("Object Centre")] = GLEJustifyCC; validList[tr("Top Right")] = GLEJustifyTR; validList[tr("Top Left")] = GLEJustifyTL; validList[tr("Bottom Right")] = GLEJustifyBR; validList[tr("Bottom Left")] = GLEJustifyBL; validList[tr("Left Centre")] = GLEJustifyLC; validList[tr("Right Centre")] = GLEJustifyRC; validList[tr("Top Centre")] = GLEJustifyTC; validList[tr("Bottom Centre")] = GLEJustifyBC; validList[tr("Left Baseline")] = GLEJustifyLeft; validList[tr("Right Baseline")] = GLEJustifyRight; validList[tr("Centre Baseline")] = GLEJustifyCenter; propertyDescriptions[Alignment].validValues = validList; // The reference point name propertyDescriptions[RefPointName].description = tr("Reference"); propertyDescriptions[RefPointName].type = QVariant::String; propertyDescriptions[RefPointName].defaultValue = QString("bl"); propertyDescriptions[RefPointName].validValues = QList<QVariant>(); // The centre of any object (by bounding box) propertyDescriptions[ObjectCentre].description = tr("Object Centre Point"); propertyDescriptions[ObjectCentre].type = QVariant::PointF; propertyDescriptions[ObjectCentre].defaultValue = QPointF(0.0,0.0); propertyDescriptions[ObjectCentre].validValues = QList<QVariant>(); // The centre of a circle or arc propertyDescriptions[CircleCentre].description = tr("Circle Centre Point"); propertyDescriptions[CircleCentre].type = QVariant::PointF; propertyDescriptions[CircleCentre].defaultValue = QPointF(0.0,0.0); propertyDescriptions[CircleCentre].validValues = QList<QVariant>(); // The radius for a circle or arc propertyDescriptions[Radius].description = tr("Radius"); propertyDescriptions[Radius].type = QVariant::Double; propertyDescriptions[Radius].defaultValue = 0.0; propertyDescriptions[Radius].validValues = QList<QVariant>(); // The major axis radius for an ellipse propertyDescriptions[MajorAxisRadius].description = tr("Major Axis Radius"); propertyDescriptions[MajorAxisRadius].type = QVariant::Double; propertyDescriptions[MajorAxisRadius].defaultValue = 0.0; propertyDescriptions[MajorAxisRadius].validValues = QList<QVariant>(); // The minor axis radius for an ellipse propertyDescriptions[MinorAxisRadius].description = tr("Minor Axis Radius"); propertyDescriptions[MinorAxisRadius].type = QVariant::Double; propertyDescriptions[MinorAxisRadius].defaultValue = 0.0; propertyDescriptions[MinorAxisRadius].validValues = QList<QVariant>(); // The major axis angle for an ellipse propertyDescriptions[MajorAxisAngle].description = tr("Major Axis Angle"); propertyDescriptions[MajorAxisAngle].type = QVariant::Double; propertyDescriptions[MajorAxisAngle].defaultValue = 0.0; propertyDescriptions[MajorAxisAngle].validValues = QList<QVariant>(); // This hasn't been decided on yet, but will probably be an int // (enumerated) from a list of PNGs. propertyDescriptions[ArrowHeadPresence].description = tr("Arrow Heads"); propertyDescriptions[ArrowHeadPresence].type = QVariant::Int; propertyDescriptions[ArrowHeadPresence].defaultValue = 0; validList.clear(); validList[tr("None")] = 0; validList[tr("Start")] = GLEHasArrowStart; validList[tr("End")] = GLEHasArrowEnd; validList[tr("Both")] = GLEHasArrowStart | GLEHasArrowEnd; propertyDescriptions[ArrowHeadPresence].validValues = validList; propertyDescriptions[ArrowHeadSize].description = tr("Arrow Head Size"); propertyDescriptions[ArrowHeadSize].type = QVariant::Double; // Check the default size propertyDescriptions[ArrowHeadSize].defaultValue = 1.0; propertyDescriptions[ArrowHeadSize].validValues = QList<QVariant>(); // This hasn't been decided on yet, but will probably be an int // (enumerated) from a list of PNGs. propertyDescriptions[ArrowHeadStyle].description = tr("Arrow Head Style"); propertyDescriptions[ArrowHeadStyle].type = QVariant::Invalid; propertyDescriptions[ArrowHeadStyle].defaultValue = QVariant(); propertyDescriptions[ArrowHeadStyle].validValues = QList<QVariant>(); // The start point for a line propertyDescriptions[StartPoint].description = tr("Start Point"); propertyDescriptions[StartPoint].type = QVariant::PointF; propertyDescriptions[StartPoint].defaultValue = QPointF(0.0,0.0); propertyDescriptions[StartPoint].validValues = QList<QVariant>(); // The end point for a line propertyDescriptions[EndPoint].description = tr("End Point"); propertyDescriptions[EndPoint].type = QVariant::PointF; propertyDescriptions[EndPoint].defaultValue = QPointF(0.0,0.0); propertyDescriptions[EndPoint].validValues = QList<QVariant>(); // Object width propertyDescriptions[Width].description = tr("Width"); propertyDescriptions[Width].type = QVariant::Double; propertyDescriptions[Width].defaultValue = 0.0; propertyDescriptions[Width].validValues = QList<QVariant>(); // Object height propertyDescriptions[Height].description = tr("Height"); propertyDescriptions[Height].type = QVariant::Double; propertyDescriptions[Height].defaultValue = 0.0; propertyDescriptions[Height].validValues = QList<QVariant>(); }