Esempio n. 1
0
QFont userfont::getFont()
{
	QString fontPath = QDir::homePath() + QString( "/.zuluCrypt/font" ) ;
	QFile x( fontPath );
	if( x.open( QIODevice::ReadOnly ) == false ){
		return m_parent->font() ;
		/*
		x.open( QIODevice::WriteOnly | QIODevice::Truncate ) ;
		QString s = QString( "Sans Serif\n8\nnormal\nnormal\n" ) ;
		x.write( s.toAscii() ) ;
		x.close();
		*/
	}else{
		QStringList xs = QString( x.readAll() ).split( "\n" ) ;
		x.close();
		QFont F ;
		F.setFamily( xs.at( 0 ) );
		F.setPointSize( xs.at( 1 ).toInt() );
		if( xs.at( 2 ) == QString( "normal" ) ){
			F.setStyle( QFont::StyleNormal );
		}else if( xs.at( 2 ) == QString( "italic" ) ){
			F.setStyle( QFont::StyleItalic );
		}else{
			F.setStyle( QFont::StyleOblique );
		}
		if( xs.at( 3 ) == QString( "normal" ) ){
			F.setWeight( QFont::Normal );
		}else{
			F.setWeight( QFont::Bold );
		}
		return F ;
	}
}
Esempio n. 2
0
void Widget::setupFont()
{
    Message& m = m_messageQueue.front();
    QFont font;
    QString name = m.data["fn"]->toString();
    // Trick to detect a font in XFD format.
    if (name.count('-') >= 4)
        font.setRawName(name);
    else {
        font.setPixelSize(m.data["fs"]->toInt());
        font.setFamily(name);
    }
    QString ss( m.data["fv"]->toString() );
    if (ss == "oblique")
		font.setStyle( QFont::StyleOblique );
	else if (ss == "italic")
		font.setStyle( QFont::StyleItalic );
	else if (ss == "ultra-light")
		font.setWeight( 13 );
	else if (ss == "light")
		font.setWeight( QFont::Light );
	else if (ss == "medium")
		font.setWeight( 50 );
	else if (ss == "semi-bold")
		font.setWeight( QFont::DemiBold );
	else if (ss == "bold")
		font.setWeight( QFont::Bold );
	else if (ss == "ultra-bold")
		font.setWeight( QFont::Black );
	else if (ss == "heavy")
		font.setWeight( 99 );
	else if (ss == "ultra-condensed")
		font.setStretch( QFont::UltraCondensed );
	else if (ss == "extra-condensed")
		font.setStretch( QFont::ExtraCondensed );
	else if (ss == "condensed")
		font.setStretch( QFont::Condensed );
	else if (ss == "semi-condensed")
		font.setStretch( QFont::SemiCondensed );
	else if (ss == "semi-expanded")
		font.setStretch( QFont::SemiExpanded );
	else if (ss == "expanded")
		font.setStretch( QFont::Expanded );
	else if (ss == "extra-expanded")
		font.setStretch( QFont::ExtraExpanded );
	else if (ss == "ultra-expanded")
		font.setStretch( QFont::UltraExpanded );
    QApplication::setFont(font);
}
QVariant Variable::data(int column, int role) const
{
    if (showError_) {
        if (role == Qt::FontRole) {
            QVariant ret = TreeItem::data(column, role);
            QFont font = ret.value<QFont>();
            font.setStyle(QFont::StyleItalic);
            return font;
        } else if (column == 1 && role == Qt::DisplayRole) {
            return i18n("Error");
        }
    }
    if (column == 1 && role == Qt::ForegroundRole)
    {
        // FIXME: returning hardcoded gray is bad,
        // but we don't have access to any widget, or pallette
        // thereof, at this point.
        if(!inScope_) return QColor(128, 128, 128);
        if(changed_) return QColor(255, 0, 0);
    }
    if (role == Qt::ToolTipRole) {
        return TreeItem::data(column, Qt::DisplayRole);
    }

    return TreeItem::data(column, role);
}
QFont GeneralConfig::getValueAsFont(const QString& key, const QString& subKey_1, const QString& subKey_2 ) const {
/*  -return a font based on the values from the keys */

    //define the return value
    QFont returnValue;

    //get a key-value list of the font properties
    QMap<QString, QVariant> fontProperties = getValue(key, subKey_1, subKey_2).toMap();

    //define a map of font styles for easy indexing using a string
    QMap<QString, QFont::Style> fontStyles;
    fontStyles["normal"] = QFont::StyleNormal;
    fontStyles["italic"] = QFont::StyleItalic;
    fontStyles["oblique"] = QFont::StyleOblique;

    //define a map of font weights for easy indexing using a string
    QMap<QString, QFont::Weight> fontWeights;//Light, Normal, DemiBold, Bold, Black
    fontWeights["light"] = QFont::Light;
    fontWeights["normal"] = QFont::Normal;
    fontWeights["demibold"] = QFont::DemiBold;
    fontWeights["bold"] = QFont::Bold;
    fontWeights["black"] = QFont::Black;

    //set the values for the font
    if ( fontProperties.contains("font_family") )
        returnValue.setFamily( fontProperties["font_family"].toString() );
    if ( fontProperties.contains("font_point_size") )
        returnValue.setPointSize( fontProperties["font_point_size"].toInt() );
    if ( fontProperties.contains("font_style") )
        returnValue.setStyle( fontStyles[ fontProperties["font_style"].toString() ] );
    if ( fontProperties.contains("font_weight") )
        returnValue.setWeight( fontWeights[ fontProperties["font_weight"].toString() ] );

    return returnValue;
}
Esempio n. 5
0
QFont stripStyleName(QFont &f, QFontDatabase &db)
{
    const QString &styleName = f.styleName();
    if (styleName.isEmpty()) {
        return f;
    } else {
        QFont g = (db.styleString(f) != styleName) ?
            db.font(f.family(), styleName, f.pointSize())
            : QFont(f.family(), f.pointSize(), f.weight());
        if (auto s = f.pixelSize() > 0) {
            g.setPixelSize(s);
        }
        g.setStyleHint(f.styleHint(), f.styleStrategy());
        g.setStyle(f.style());
        if (f.underline()) {
            g.setUnderline(true);
        }
        if (f.strikeOut()) {
            g.setStrikeOut(true);
        }
        if (f.fixedPitch()) {
            g.setFixedPitch(true);
        }
        return g;
    }
}
Esempio n. 6
0
QFont computeFont (const typename T::properties& props, int height)
{
  QFont f (fromStdString (props.get_fontname ()));

  static std::map<std::string, QFont::Weight> weightMap;
  static std::map<std::string, QFont::Style> angleMap;
  static bool mapsInitialized = false;

  if (! mapsInitialized)
    {
      weightMap[std::string ("normal")] = QFont::Normal;
      weightMap[std::string ("light")] = QFont::Light;
      weightMap[std::string ("demi")] = QFont::DemiBold;
      weightMap[std::string ("bold")] = QFont::Normal;

      angleMap[std::string ("normal")] = QFont::StyleNormal;
      angleMap[std::string ("italic")] = QFont::StyleItalic;
      angleMap[std::string ("oblique")] = QFont::StyleOblique;

      mapsInitialized = true;
    }

  f.setPointSizeF (props.get_fontsize_points (height));
  f.setWeight (weightMap[props.get_fontweight ()]);
  f.setStyle (angleMap[props.get_fontangle ()]);

  return f;
}
void FontSetupPage::changeFont(const QString &style)
{
    QFont font = m_plainTextEdit->font();
    bool bold = font.bold();
    QFont::Style italic = font.style();

    if (style == "Italic") {
        bold = false;
        italic = QFont::StyleItalic;
    } else if (style == "Bold") {
        bold = true;
        italic = QFont::StyleNormal;
    } else if (style == "Bold Italic") {
        bold = true;
        italic = QFont::StyleItalic;
    } else if (style == "Normal") {
        bold = false;
        italic = QFont::StyleNormal;
    }

    font.setBold(bold);
    font.setStyle(italic);
    m_plainTextEdit->setFont(font);

    m_font = font;
}
Esempio n. 8
0
void GeneralSettingsPage::apply()
{
    QFont newFont;
    const QString &family = m_ui.familyComboBox->currentFont().family();
    newFont.setFamily(family);

    int fontSize = 14;
    int currentIndex = m_ui.sizeComboBox->currentIndex();
    if (currentIndex != -1)
        fontSize = m_ui.sizeComboBox->itemData(currentIndex).toInt();
    newFont.setPointSize(fontSize);

    QString fontStyle = QLatin1String("Normal");
    currentIndex = m_ui.styleComboBox->currentIndex();
    if (currentIndex != -1)
        fontStyle = m_ui.styleComboBox->itemText(currentIndex);
    newFont.setBold(m_fontDatabase.bold(family, fontStyle));
    if (fontStyle.contains(QLatin1String("Italic")))
        newFont.setStyle(QFont::StyleItalic);
    else if (fontStyle.contains(QLatin1String("Oblique")))
        newFont.setStyle(QFont::StyleOblique);
    else
        newFont.setStyle(QFont::StyleNormal);

    const int weight = m_fontDatabase.weight(family, fontStyle);
    if (weight >= 0)    // Weight < 0 asserts...
        newFont.setWeight(weight);

    QHelpEngineCore *engine = &LocalHelpManager::helpEngine();
    engine->setCustomValue(QLatin1String("font"), newFont);

    if (newFont != m_font)
        emit fontChanged();

    QString homePage = m_ui.homePageLineEdit->text();
    if (homePage.isEmpty())
        homePage = Help::Constants::AboutBlank;
    engine->setCustomValue(QLatin1String("HomePage"), homePage);

    const int startOption = m_ui.helpStartComboBox->currentIndex();
    engine->setCustomValue(QLatin1String("StartOption"), startOption);

    const int helpOption = m_ui.contextHelpComboBox->currentIndex();
    engine->setCustomValue(QLatin1String("ContextHelpOption"), helpOption);

    // no need to call setup on the gui engine since we use only core engine
}
Esempio n. 9
0
	void CodeLineEdit::paintEvent(QPaintEvent *event)
	{
		if(!mMultiline)
			QLineEdit::paintEvent(event);

		if(mMultiline || mCode)
		{
			QPainter painter(this);

			if(mMultiline)
			{
				QStyleOptionFrameV3 panel;
				panel.initFrom(this);
				
				if(!mEmbedded)
				{
					panel.lineWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth, &panel, this);
					panel.midLineWidth = 0;
					panel.state |= QStyle::State_Sunken;
	
					style()->drawPrimitive(QStyle::PE_PanelLineEdit, &panel, &painter, this);
				}

				painter.setBrush(panel.palette.text());
				QFont italicFont = font();
				italicFont.setStyle(QFont::StyleItalic);
				painter.setFont(italicFont);

				QPalette pal = palette();
				pal.setCurrentColorGroup(QPalette::Disabled);

                style()->drawItemText(&painter, rect(), Qt::AlignCenter, pal, false, tr("Multiline, double-click to edit"), QPalette::Text);
			}

			if(mCode)
			{
				QPolygon polygon;
				QColor color;
		
				if(isEnabled())
					color = QColor(255, 0, 0, 200);
				else
					color = QColor(100, 0, 0, 200);
		
				painter.setPen(Qt::NoPen);
				
				int offset = (mEmbedded ? 0 : 4);
		
				polygon << QPoint(offset, offset)
						<< QPoint(6 + offset, offset)
						<< QPoint(offset, 6 + offset);
		
				painter.setBrush(QBrush(color));
				painter.drawPolygon(polygon);
			}
        }
    }
Esempio n. 10
0
void GameDesk::setPlayerName(QString nickname, int seq_number, int bottom_margin)
{
   if (scene == NULL)
      return;

   int x;
   int y;
   int board_size = (square_size + 2*square_margin)*(3*size - 2) + 2*window_margin;

   QColor color_brush;

   QFont  font;
   font.setStyle(QFont::StyleNormal);
   font.setStyleHint(QFont::Helvetica);
   //font.setCapitalization();
   font.setBold(true);
   font.setPixelSize(20);
   //font.setOverline(true);

   QGraphicsSimpleTextItem * g_text = new QGraphicsSimpleTextItem(nickname);
   g_text->setFont(font);

   int half_width_nickname = g_text->boundingRect().width() / 2;
   int height_nickname = g_text->boundingRect().height();

      switch (seq_number) {
      case 0:
         x = window_margin + square_size + 2*square_margin - half_width_nickname;
         y = board_size - 2*(square_size + square_margin) - bottom_margin;
         break;
      case 1:
         x = window_margin + square_size + 2*square_margin - half_width_nickname ;
         y = 2*(square_size + square_margin) + height_nickname;
         break;
      case 2:
         x = board_size - window_margin - square_size - 2*square_margin - half_width_nickname;
         y = 2 * (square_size + square_margin) + height_nickname;
         break;
      case 3:
         x = board_size - window_margin - square_size - 2*square_margin - half_width_nickname;
         y = board_size - 2*(square_size + square_margin) - bottom_margin;
         break;
      }

      QPen pen;
      pen.setColor(color_light[seq_number]);
      pen.setWidth(0);
      g_text->setPen(pen);

      g_text->setBrush(color_light[seq_number]);
      g_text->setPos(x, y);
      scene->addItem(g_text);
      players_name.append(g_text);
}
Esempio n. 11
0
QFont FontPanel::selectedFont() const
{
    QFont rc = m_familyComboBox->currentFont();
    const QString family = rc.family();
    rc.setPointSize(pointSize());
    const QString styleDescription = styleString();
    if (styleDescription.contains(QLatin1String("Italic")))
        rc.setStyle(QFont::StyleItalic);
    else if (styleDescription.contains(QLatin1String("Oblique")))
        rc.setStyle(QFont::StyleOblique);
    else
        rc.setStyle(QFont::StyleNormal);
    rc.setBold(m_fontDatabase.bold(family, styleDescription));

    // Weight < 0 asserts...
    const int weight = m_fontDatabase.weight(family, styleDescription);
    if (weight >= 0)
        rc.setWeight(weight);
    return rc;
}
Esempio n. 12
0
// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
// helpers
// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
void FileSystemBrowser::addGroupMarkToMenu( QString text )
{
    QFont   font;
            font.setBold( true );
            font.setStyle( QFont::StyleOblique );

    QAction* action = 0;

    action = _fileBrowserMenu.addAction( QString("~~~~~ %1 ~~~~~").arg(text) );
    action->setFont( font );
}
Esempio n. 13
0
QValidator::State IsDirValidator::validate(QString& input, int& /*pos*/) const
{
    QFileInfo fi(input);

    if(fi.isDir() && fi.isReadable())
    {
        pEdit->setFont(m_OrigFont);
        return QValidator::Acceptable;
    }

    QFont f = pEdit->font();
    f.setStyle(QFont::StyleItalic);
    pEdit->setFont(f);

    return QValidator::Intermediate;
}
Esempio n. 14
0
    DisplayNameDelegate( QAbstractItemView *view, QObject *parent = 0 )
      : QStyledItemDelegate( parent ), mMaxDescriptionWidth( 0 )
    {
      mDescriptions.append( i18n( "Short Name" ) );
      mDescriptions.append( i18n( "Full Name" ) );
      mDescriptions.append( i18n( "Reverse Name with Comma" ) );
      mDescriptions.append( i18n( "Reverse Name" ) );
      mDescriptions.append( i18n( "Organization" ) );
      mDescriptions.append( i18nc( "@item:inlistbox A custom name format", "Custom" ) );

      QFont font = view->font();
      font.setStyle( QFont::StyleItalic );
      QFontMetrics metrics( font );
      foreach ( const QString &description, mDescriptions ) {
        mMaxDescriptionWidth = qMax( mMaxDescriptionWidth, metrics.width( description ) );
      }
Esempio n. 15
0
bool myEventFilter(void *message) {
	// here we should have all requested bps events (no Qt events here)
    bps_event_t *event = (bps_event_t*)message;
    if (event) {
    	int domain = bps_event_get_domain(event);
    	if (domain == virtualkeyboard_get_domain()) {
    		unsigned int ec = bps_event_get_code(event);
    		 if (!bKBhidden && ec == VIRTUALKEYBOARD_EVENT_INFO){
    			int nNewKBHeight = virtualkeyboard_event_get_height(event);
    			virtualkeyboard_get_height(&nNewKBHeight);
    			if ( nNewKBHeight != nKBHeight){
    				nKBHeight = nNewKBHeight;
    				QRect r = QApplication::desktop()->screenGeometry(0);
    				if (r.width() > 800){
    					// Landscape
    					console->setGeometry(0, 0, r.width()-73, r.height()-nKBHeight);
    				}else{
    					// Portrait - keyboard is taller
    					console->setGeometry(0, 53, r.width(), r.height()-nKBHeight-53);
    				}
    			}
    		}
    		QRect r = QApplication::desktop()->screenGeometry(0);
    		if (ec == VIRTUALKEYBOARD_EVENT_VISIBLE){
				bKBhidden = false;
				nKBHeight = nMaxKBHeight;
				virtualkeyboard_change_options(VIRTUALKEYBOARD_LAYOUT_DEFAULT, VIRTUALKEYBOARD_ENTER_DEFAULT);
    		}else if (ec == VIRTUALKEYBOARD_EVENT_HIDDEN){
				bKBhidden = true;
				nKBHeight = 0;
    		}
			if (r.width() > 800) console->setGeometry(0, 0, r.width()-73, r.height()-nKBHeight); // Landscape
			else console->setGeometry(0, 103, r.width(), r.height()-nKBHeight-103); // Portrait

			//font = QFont(QString("Courier New"), 6);
			font.setPixelSize(mainWindow->nFontSize);
		    font.setStyle(QFont::StyleNormal);
		    font.setWeight(QFont::Normal);
			console->setTerminalFont(font);
    	}
   	}
 	mainEventFilter(message); // Call replaced event filter so we deliever everything to Qt that runs in background
	return false;
}
Esempio n. 16
0
void QSvgFontStyle::apply(QPainter *p, const QSvgNode *, QSvgExtraStates &states)
{
    m_oldQFont = p->font();
    m_oldSvgFont = states.svgFont;
    m_oldTextAnchor = states.textAnchor;
    m_oldWeight = states.fontWeight;

    if (m_textAnchorSet)
        states.textAnchor = m_textAnchor;

    QFont font = m_oldQFont;
    if (m_familySet) {
        states.svgFont = m_svgFont;
        font.setFamily(m_qfont.family());
    }

    if (m_sizeSet)
        font.setPointSizeF(m_qfont.pointSizeF());

    if (m_styleSet)
        font.setStyle(m_qfont.style());

    if (m_variantSet)
        font.setCapitalization(m_qfont.capitalization());

    if (m_weightSet) {
        if (m_weight == BOLDER) {
            states.fontWeight = qMin(states.fontWeight + 100, 900);
        } else if (m_weight == LIGHTER) {
            states.fontWeight = qMax(states.fontWeight - 100, 100);
        } else {
            states.fontWeight = m_weight;
        }
        font.setWeight(SVGToQtWeight(states.fontWeight));
    }

    p->setFont(font);
}
Esempio n. 17
0
//***************************************************************************
void Kwave::ScaleWidget::paintText(QPainter &p, int x, int y,
                                   bool reverse, const QString &text)
{
    QFont font;
    font.setStyleHint(QFont::SansSerif);
    font.setFixedPitch(true);
    font.setPixelSize(FONTSIZE);
    font.setWeight(0);
    font.setStyle(QFont::StyleNormal);
    p.setFont(font);
    QFontMetrics fm(font);

    if (reverse) {
	x += FONTSIZE + 2;
	y -= FONTSIZE + 2;
    }

    QRect rect = fm.boundingRect(text);
    const int th = rect.height();
    const int tw = rect.width();
    p.drawText(x, y, tw, th,
	((reverse) ? Qt::AlignLeft : Qt::AlignRight) | Qt::AlignBottom,
	text);
}
Esempio n. 18
0
void StyleLoader::loadComposite(QFont& value)
{
	QString family;
	int size;
	bool pixelSize;
	int weight;
	int style;
	bool underline;

	load("family", family);
	load("size", size);
	load("sizeIsInPixels", pixelSize);
	load("weight", weight);
	load("style", style);
	load("underline", underline);

	value = QFont();
	if ( !family.isEmpty() ) value.setFamily(family);
	value.setWeight(weight);
	if ( pixelSize ) value.setPixelSize(size);
	else value.setPointSize(size);
	value.setStyle((QFont::Style) style);
	value.setUnderline(underline);
}
Esempio n. 19
0
void QFontProto::setStyle(int style)
{
  QFont *item = qscriptvalue_cast<QFont*>(thisObject());
  if (item)
    item->setStyle((QFont::Style)style);
}
Esempio n. 20
0
NetworkDialog::NetworkDialog(bool client, QWidget* parent, const QUrl* url)
: QDialog(parent)
, m_publisher(0), m_client(client)
{
    QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
    QVBoxLayout *topLayout = new QVBoxLayout;
    setLayout(topLayout);
    m_okButton = buttonBox->button(QDialogButtonBox::Ok);
    m_okButton->setDefault(true);
    m_okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
    connect(buttonBox, &QDialogButtonBox::accepted, this, &NetworkDialog::slotOkClicked);
    connect(buttonBox, &QDialogButtonBox::rejected, this, &NetworkDialog::reject);

    QLabel* tmp;
    QWidget* main = new QWidget(this);

    QHBoxLayout* tmpLayout;
    QVBoxLayout* mainLayout = new QVBoxLayout;

    // feedback
    m_feedback = new QLabel(QLatin1Literal(""), this);
    m_feedback->setAlignment(Qt::AlignHCenter);
    {
        QFont font = m_feedback->font();
        font.setStyle(QFont::StyleItalic);
        m_feedback->setFont(font);
    }
    m_feedback->hide();
    mainLayout->addWidget(m_feedback);
    
    // nick
    tmp = new QLabel(i18n("&Nickname:"), main);
    m_nickname = new KLineEdit(main);
    m_nickname->setClearButtonShown(true);
    m_nickname->setText(Settings::findNick());
    tmp->setBuddy(m_nickname);
    tmpLayout = new QHBoxLayout;
    tmpLayout->addWidget(tmp);
    tmpLayout->addWidget(m_nickname, 1);
    mainLayout->addItem(tmpLayout);

    // client part
    if (m_client) {
        tmp = new QLabel(i18n("&Join game:"), main);
        m_games=new KComboBox(main);
        KDNSSD::ServiceBrowser* browser=new KDNSSD::ServiceBrowser(QLatin1Literal("_kbattleship._tcp"), true);
        m_games->setModel(new KDNSSD::ServiceModel(browser, this));
        tmp->setBuddy(m_games);
        tmpLayout = new QHBoxLayout;
        tmpLayout->addWidget(tmp);
        tmpLayout->addWidget(m_games, 1);
        connect(m_games, static_cast<void (KComboBox::*)(int)>(&KComboBox::currentIndexChanged), this, &NetworkDialog::serviceSelected);
        mainLayout->addItem(tmpLayout);
        
        QWidget* frame=new QWidget(main);
        QVBoxLayout* frameLayout = new QVBoxLayout;
        
        const QString hostName = url? url->host() : Settings::hostname();
        tmp = new QLabel(i18n("&Hostname:"), frame);
        m_hostname = new KLineEdit(main);
        m_hostname->setClearButtonShown(true);
        m_hostname->setText(hostName);
        tmp->setBuddy(m_hostname);
        tmpLayout = new QHBoxLayout;
        tmpLayout->addWidget(tmp);
        tmpLayout->addWidget(m_hostname, 1);
//TODO PORT QT5         tmpLayout->setSpacing(QDialog::spacingHint());
        frameLayout->addItem(tmpLayout);

        // port
        const int port = ( url && url->port() != -1 )? url->port(): Settings::port();
        tmp = new QLabel(i18n("&Port:"), main);
        m_port = new KPluralHandlingSpinBox(main);
        m_port->setRange(1, 99999);
        m_port->setValue(port);
        tmp->setBuddy(m_port);
        tmpLayout = new QHBoxLayout;
        tmpLayout->addWidget(tmp);
        tmpLayout->addStretch();
        tmpLayout->addWidget(m_port);
        frameLayout->addItem(tmpLayout);
        frame->setLayout(frameLayout);
        
        mainLayout->addWidget(frame);
        frame->setVisible(false);
        
        QPushButton* sw=new QPushButton(i18n("&Enter server address manually"), main);
        sw->setCheckable(true);
        connect(sw, &QPushButton::toggled, frame, &QWidget::setVisible);
        connect(sw, &QPushButton::toggled, m_games, &KComboBox::setDisabled);
        mainLayout->addWidget(sw);
        if(url) {
            sw->click();
        }
        
    }
    else {
        m_hostname = 0;
        m_games = 0;
    
        // port
        tmp = new QLabel(i18n("&Port:"), main);
        m_port = new KPluralHandlingSpinBox(main);
        m_port->setRange(1, 99999);
        m_port->setValue(Settings::port());
        tmp->setBuddy(m_port);
        tmpLayout = new QHBoxLayout;
        tmpLayout->addWidget(tmp);
        tmpLayout->addStretch();
        tmpLayout->addWidget(m_port);
        mainLayout->addItem(tmpLayout);
    }
    mainLayout->addStretch();
    
    main->setLayout(mainLayout);
    topLayout->addWidget(main);
    topLayout->addWidget(buttonBox);

    setWindowTitle(i18n("Network Parameters"));
    
    connect(this, &NetworkDialog::accepted, this, &NetworkDialog::savePreferences);
    
}
Esempio n. 21
0
static void generate_qpath( mlt_properties producer_properties )
{
	QPainterPath* qPath = static_cast<QPainterPath*>( mlt_properties_get_data( producer_properties, "_qpath", NULL ) );
	int outline = mlt_properties_get_int( producer_properties, "outline" );
	char* align = mlt_properties_get( producer_properties, "align" );
	char* style = mlt_properties_get( producer_properties, "style" );
	char* text = mlt_properties_get( producer_properties, "text" );
	char* encoding = mlt_properties_get( producer_properties, "encoding" );
	int pad = mlt_properties_get_int( producer_properties, "pad" );
	int offset = pad + ( outline / 2 );
	int width = 0;
	int height = 0;

	// Make the path empty
	*qPath = QPainterPath();

	// Get the strings to display
	QTextCodec *codec = QTextCodec::codecForName( encoding );
	QTextDecoder *decoder = codec->makeDecoder();
	QString s = decoder->toUnicode( text );
	delete decoder;
	QStringList lines = s.split( "\n" );

	// Configure the font
	QFont font;
	font.setPixelSize( mlt_properties_get_int( producer_properties, "size" ) );
	font.setFamily( mlt_properties_get( producer_properties, "family" ) );
	font.setWeight( ( mlt_properties_get_int( producer_properties, "weight" ) / 10 ) -1 );
	switch( style[0] )
	{
	case 'i':
	case 'I':
		font.setStyle( QFont::StyleItalic );
		break;
	}
	QFontMetrics fm( font );

	// Determine the text rectangle size
	height = fm.lineSpacing() * lines.size();
	for( int i = 0; i < lines.size(); ++i )
	{
		int line_width = fm.width( lines.at(i) );
		if( line_width > width ) width = line_width;
	}

	// Lay out the text in the path
	int x = 0;
	int y = fm.ascent() + 1 + offset;
	for( int i = 0; i < lines.size(); ++i )
	{
		QString line = lines.at(i);
		x = offset;
		switch( align[0] )
		{
			default:
			case 'l':
			case 'L':
				break;
			case 'c':
			case 'C':
				x += ( width - fm.width( line ) ) / 2;
				break;
			case 'r':
			case 'R':
				x += width - fm.width( line );
				break;
		}
		qPath->addText( x, y, font, line );
		y += fm.lineSpacing();
	}

	// Account for outline and pad
	width += offset * 2;
	height += offset * 2;
	// Sanity check
	if( width == 0 ) width = 1;
	if( height == 0 ) height = 1;
	mlt_properties_set_int( producer_properties, "meta.media.width", width );
	mlt_properties_set_int( producer_properties, "meta.media.height", height );
}
Esempio n. 22
0
FlightDataPrint::FlightDataPrint(Flight* currentFlight)
{
    QPrinter printer( QPrinter::ScreenResolution );

    printer.setDocName( "kflog-flight" );
    printer.setCreator( QString( "KFLog " ) + KFLOG_VERSION );
    printer.setOutputFileName( MainWindow::instance()->getApplicationDataDirectory() +
                               "/kflog-flight.pdf" );

    QPrintDialog dialog( &printer, MainWindow::instance() );

    dialog.setWindowTitle( QObject::tr("Print Flight") );
    dialog.setSizeGripEnabled ( true );
    dialog.setOptions( QAbstractPrintDialog::PrintToFile |
                       QAbstractPrintDialog::PrintSelection |
                       QAbstractPrintDialog::PrintPageRange |
                       QAbstractPrintDialog::PrintShowPageSize );

    if( dialog.exec() != QDialog::Accepted )
    {
        return;
    }

    QPainter painter;
    painter.begin( &printer );

    lasttime=0;

    QString temp;
    FlightPoint cPoint;

    QFont font;
    font.setPixelSize( 8 );
    font.setStyle( QFont::StyleItalic );
    font.setStyleHint( QFont::SansSerif );

    painter.setFont( font );

    QString msg = QString("%1created by KFLog %2 (www.kflog.org)")
                  .arg( QChar(Qt::Key_copyright) )
                  .arg( KFLOG_VERSION );

    painter.drawText( 25, 12, msg );

    font.setPixelSize( 18 );
    font.setWeight( QFont::Bold );

    painter.setFont( font );
    painter.setPen(QPen(Qt::black, 2));
    painter.drawText(50, 50, QObject::tr("Flight Analysis") + ":");
    painter.drawLine(50, 56, 545, 56);

    font.setPixelSize( 9 );
    font.setWeight( QFont::Normal );
    font.setItalic( true );

    painter.setFont( font );
    painter.drawText(50, 58, 495, 20, Qt::AlignTop | Qt::AlignRight,
                     QString(QObject::tr("File")) + ": " + currentFlight->getFileName());

    font.setItalic( false );
    painter.setFont( font );
    painter.drawText(50, 100, QObject::tr("Date") + ":");
    painter.drawText(125, 100, currentFlight->getDate());
    painter.drawText(50, 115, QObject::tr("Pilot") + ":");
    painter.drawText(125, 115, currentFlight->getPilot());
    painter.drawText(50, 130, QObject::tr("Glider") + ":");
    painter.drawText(125, 130, currentFlight->getGliderType() + " / " + currentFlight->getGliderRegistration());

    painter.setPen(QPen(Qt::black, 2));
    painter.drawLine(50, 175, 545, 175);

    font.setPixelSize( 12 );
    font.setWeight( QFont::Bold );
    painter.setFont( font );
    painter.drawText(50, 170, QObject::tr("Flight track") + ":");

    font.setWeight( QFont::Normal );
    font.setPixelSize( 9 );
    painter.setFont( font );
    painter.drawText(50, 190, QObject::tr("Duration") + ":");
    painter.drawText(125, 190,
                     printTime(currentFlight->getLandTime() - currentFlight->getStartTime(), true, true));

    cPoint = currentFlight->getPoint(currentFlight->getStartIndex());

    __printPositionData(&painter, &cPoint, 210, QObject::tr("Takeoff") + ":");

    cPoint = currentFlight->getPoint(currentFlight->getLandIndex());

    __printPositionData(&painter, &cPoint, 223, QObject::tr("Landing") + ":");

    cPoint = currentFlight->getPoint(Flight::H_MAX);

    __printPositionData(&painter, &cPoint, 248, QObject::tr("max. Altitude") + ":",
                        true, true);

    cPoint = currentFlight->getPoint(Flight::VA_MAX);

    __printPositionData(&painter, &cPoint, 261, QObject::tr("max. Vario") + ":",
                        true, true);

    cPoint = currentFlight->getPoint(Flight::VA_MIN);

    __printPositionData(&painter, &cPoint, 274, QObject::tr("min. Vario") + ":",
                        true, true);

    cPoint = currentFlight->getPoint(Flight::V_MAX);

    __printPositionData(&painter, &cPoint, 287, QObject::tr("max. Speed") + ":",
                        true, true);

    painter.setPen(QPen(Qt::black, 2));
    painter.drawLine(50, 340, 545, 340);

    font.setPixelSize( 12 );
    font.setWeight( QFont::Bold );
    painter.setFont( font );
    painter.drawText(50, 335, QObject::tr("Task") + ":");

    font.setPixelSize( 9 );
    font.setWeight( QFont::Normal );
    painter.setFont( font );

    painter.drawText(50, 355, QObject::tr("Type") + ":");

    temp = QObject::tr("%1  Track: %2  Points: %3")
           .arg(currentFlight->getTaskTypeString(true))
           .arg(currentFlight->getDistance(true))
           .arg(currentFlight->getPoints(true));

    painter.drawText(125, 355, temp);

    QList<Waypoint*> wpList = currentFlight->getOriginalWPList(); // use original task
    int yPos = 375;

    for( int loop = 0; loop < wpList.count(); loop++ )
    {
        __printPositionData( &painter, wpList.at( loop ), yPos );
        yPos += 13;
    }

    if( currentFlight->isOptimized() )
    {
        wpList = currentFlight->getWPList();
        yPos += 20;

        font.setPixelSize( 12 );
        font.setWeight( QFont::Bold );
        painter.setFont( font );
        painter.drawText(50, yPos, QObject::tr("Optimized Task") + ":");
        yPos += 5;

        painter.setPen(QPen(Qt::black, 2));
        painter.drawLine(50, yPos, 545, yPos);

        font.setPixelSize( 9 );
        font.setWeight( QFont::Normal );
        painter.setFont( font );
        yPos += 15;

        painter.drawText(50, yPos, QObject::tr("Type") + ":");

        temp = QObject::tr("%1  Track: %2  Points: %3").arg(
                   currentFlight->getTaskTypeString()).arg(
                   currentFlight->getDistance()).arg(
                   currentFlight->getPoints());
        painter.drawText(125, yPos, temp);
        yPos += 20;

        for(int loop = 0; loop < wpList.count(); loop++)
        {
            __printPositionData(&painter, wpList.at(loop), yPos);
            yPos += 13;
        }
    }

    painter.end();
}
void GeneralSettingsPage::apply()
{
    if (!m_ui) // page was never shown
        return;
    QFont newFont;
    const QString &family = m_ui->familyComboBox->currentFont().family();
    newFont.setFamily(family);

    int fontSize = 14;
    int currentIndex = m_ui->sizeComboBox->currentIndex();
    if (currentIndex != -1)
        fontSize = m_ui->sizeComboBox->itemData(currentIndex).toInt();
    newFont.setPointSize(fontSize);

    QString fontStyle = QLatin1String("Normal");
    currentIndex = m_ui->styleComboBox->currentIndex();
    if (currentIndex != -1)
        fontStyle = m_ui->styleComboBox->itemText(currentIndex);
    newFont.setBold(m_fontDatabase.bold(family, fontStyle));
    if (fontStyle.contains(QLatin1String("Italic")))
        newFont.setStyle(QFont::StyleItalic);
    else if (fontStyle.contains(QLatin1String("Oblique")))
        newFont.setStyle(QFont::StyleOblique);
    else
        newFont.setStyle(QFont::StyleNormal);

    const int weight = m_fontDatabase.weight(family, fontStyle);
    if (weight >= 0)    // Weight < 0 asserts...
        newFont.setWeight(weight);

    if (newFont != m_font) {
        m_font = newFont;
        HelpManager::setCustomValue(QLatin1String("font"), newFont);
        emit fontChanged();
    }

    QString homePage = QUrl::fromUserInput(m_ui->homePageLineEdit->text()).toString();
    if (homePage.isEmpty())
        homePage = Help::Constants::AboutBlank;
    m_ui->homePageLineEdit->setText(homePage);
    if (m_homePage != homePage) {
        m_homePage = homePage;
        HelpManager::setCustomValue(QLatin1String("HomePage"), homePage);
    }

    const int startOption = m_ui->helpStartComboBox->currentIndex();
    if (m_startOption != startOption) {
        m_startOption = startOption;
        HelpManager::setCustomValue(QLatin1String("StartOption"), startOption);
    }

    const int helpOption = m_ui->contextHelpComboBox->currentIndex();
    if (m_contextOption != helpOption) {
        m_contextOption = helpOption;
        HelpManager::setCustomValue(QLatin1String("ContextHelpOption"), helpOption);

        QSettings *settings = Core::ICore::settings();
        settings->beginGroup(QLatin1String(Help::Constants::ID_MODE_HELP));
        settings->setValue(QLatin1String("ContextHelpOption"), helpOption);
        settings->endGroup();

        emit contextHelpOptionChanged();
    }

    const bool close = m_ui->m_returnOnClose->isChecked();
    if (m_returnOnClose != close) {
        m_returnOnClose = close;
        HelpManager::setCustomValue(QLatin1String("ReturnOnClose"), close);
        emit returnOnCloseChanged();
    }
}
Esempio n. 24
0
void KviTopicWidget::paintColoredText(QPainter * p, QString text, const QPalette & cg, const QRect & rect)
{
	QFontMetrics fm(p->fontMetrics());
	bool curBold = false;
	bool curItalic = false;
	bool curUnderline = false;
	unsigned char curFore = KVI_LABEL_DEF_FORE; //default fore
	unsigned char curBack = KVI_LABEL_DEF_BACK; //default back
	int baseline = rect.top() + rect.height() - fm.descent() - 1;

	int curX = rect.x() + 1;     // is the margin
	int maxX = rect.width() - 2; // 2 is 1*margin
	unsigned int idx = 0;

	QFont::Style normalFontStyle = p->font().style();

	while((idx < (unsigned int)text.length()) && (curX < maxX))
	{
		unsigned short c = text[(int)idx].unicode();

		unsigned int start = idx;

		while((idx < (unsigned int)text.length()) && (c != KviControlCodes::Color) && (c != KviControlCodes::Bold) && (c != KviControlCodes::Italic) && (c != KviControlCodes::Underline) && (c != KviControlCodes::Reverse) && (c != KviControlCodes::Reset) && (c != KviControlCodes::Icon))
		{
			idx++;
			c = text[(int)idx].unicode();
		}

		int len = idx - start;
		int wdth;

		if(len > 0)
		{
			QString szText = text.mid(start, len);

			wdth = fm.width(szText);

			if(curFore == KVI_LABEL_DEF_FORE)
			{
				p->setPen(cg.text().color());
			}
			else
			{
				if(curFore > 16)
					p->setPen(cg.background().color());
				else
					p->setPen(KVI_OPTION_MIRCCOLOR(curFore));
			}

			if(curBack != KVI_LABEL_DEF_BACK)
			{
				if(curBack > 16)
				{
					p->fillRect(curX, rect.y() + 2, wdth, rect.height() - 4,
					    cg.text());
				}
				else
				{
					p->fillRect(curX, rect.y() + 2, wdth, rect.height() - 4,
					    KVI_OPTION_MIRCCOLOR(curBack));
				}
			}

			QFont newFont = p->font();
			newFont.setStyle((curItalic ^ (normalFontStyle != QFont::StyleNormal)) ? QFont::StyleItalic : QFont::StyleNormal);
			p->setFont(newFont);

			p->drawText(curX, baseline, szText.left(len));

			if(curBold)
				p->drawText(curX + 1, baseline, szText.left(len));
			if(curUnderline)
			{
				p->drawLine(curX, baseline + 1, curX + wdth, baseline + 1);
			}
		}
		else
		{
			wdth = 0;
		}

		curX += wdth;

		switch(c)
		{
			case KviControlCodes::Bold:
				curBold = !curBold;
				++idx;
				break;
			case KviControlCodes::Italic:
				curItalic = !curItalic;
				++idx;
				break;
			case KviControlCodes::Underline:
				curUnderline = !curUnderline;
				++idx;
				break;
			case KviControlCodes::Reverse:
			{
				char auxBack = curBack;
				curBack = curFore;
				curFore = auxBack;
			}
				++idx;
				break;
			case KviControlCodes::Reset:
				curFore = KVI_LABEL_DEF_FORE;
				curBack = KVI_LABEL_DEF_BACK;
				curBold = false;
				curItalic = false;
				curUnderline = false;
				++idx;
				break;
			case KviControlCodes::Color:
			{
				++idx;
				unsigned char fore;
				unsigned char back;
				idx = KviControlCodes::getUnicodeColorBytes(text, idx, &fore, &back);
				if(fore != KviControlCodes::NoChange)
				{
					curFore = fore;
					if(back != KviControlCodes::NoChange)
						curBack = back;
				}
				else
				{
					// only a CTRL+K
					curBack = KVI_LABEL_DEF_BACK;
					curFore = KVI_LABEL_DEF_FORE;
				}
			}
			break;
			case KviControlCodes::Icon:
			{
				++idx;

				unsigned int icoStart = idx;
				while((idx < (unsigned int)text.length()) && (text[(int)idx].unicode() > 32))
					idx++;

				KviCString lookupString = text.mid(icoStart, idx - icoStart);

				KviTextIcon * icon = g_pTextIconManager->lookupTextIcon(lookupString.ptr());
				if(icon)
				{
					QPixmap * pigzmap = icon->pixmap();
					p->drawPixmap(curX, (baseline + 2) - pigzmap->height(), *(pigzmap));
					curX += pigzmap->width();
				}
				else
				{
					idx = icoStart;
				}
			}
			break;
		}
	}
}
Esempio n. 25
0
int main(int argc, char *argv[])
{
    // Let's search for programs first in our own 'app' folder
    QString oldPath = qgetenv("PATH");
    QString newPath = "app/native:"+oldPath;
    qputenv("PATH", newPath.toAscii().data());

    // We need to store our working folder somewhere, it is needed for ssh later
    int res = system ("echo -n `pwd`\"/data/\" > data/.myhome");
    if (res == -1){
    	fprintf(stderr, "Can't determine my home folder location, terminating");
    	exit(-1);
    }

	// Init file descriptors opening proper devices
	masterFdG = ::open("/dev/ptyp1", O_RDWR);
	slaveFdG = ::open("/dev/ttyp1", O_RDWR | O_NOCTTY);
	// And here is where magic begins
    pidG_ = fork();
    if (pidG_ == 0) {
        dup2(slaveFdG, STDIN_FILENO);
        dup2(slaveFdG, STDOUT_FILENO);
        dup2(slaveFdG, STDERR_FILENO);

        // reset all signal handlers
        struct sigaction act;
        sigemptyset(&act.sa_mask);
        act.sa_handler = SIG_DFL;
        act.sa_flags = 0;
        for (int sig = 1; sig < NSIG; sig++)
          sigaction(sig, &act, 0L);

        // All we want in child process is to have sh running
        const char *arglist[] = {"/bin/sh", "-l", NULL};
        execvp(arglist[0], (char**)arglist);
    } else if (pidG_ == -1) {
        // fork() failed
  	    qDebug() << "fork() failed:";
        pidG_ = 0;
        return false;
    }
    // Drop garbage that is shown when you start the app
    char cGarbage[72];
    read(masterFdG, cGarbage, 72);

    // needed for correct QT initialization
    //qputenv("QT_QPA_FONTDIR", "/usr/fonts/font_repository/dejavu-ttf-2.17"); // needed for correct QT initialization

    qputenv("QT_QPA_PLATFORM_PLUGIN_PATH", "/usr/lib/qt4/plugins/platforms");

    //QCoreApplication::addLibraryPath("app/native/lib"); // blackberry plugin does not load without this line

    QApplication app(argc, argv);

    mainWindow = new CMyMainWindow();
    QRect r = QApplication::desktop()->screenGeometry(0);
    mainWindow->resize(r.width()+1, r.height()+1);

    console = new QTermWidget(1, mainWindow);

    font = QFont(QString("Courier New"), 6);
    font.setPixelSize(mainWindow->nFontSize);
    font.setStyle(QFont::StyleNormal);
    font.setWeight(QFont::Normal);
	console->setTerminalFont(font);

#ifndef BBQ10
    // We start the app with shown keyboard
	virtualkeyboard_change_options(VIRTUALKEYBOARD_LAYOUT_DEFAULT, VIRTUALKEYBOARD_ENTER_DEFAULT);
	if (r.width() > 800){
		// Landscape
		virtualkeyboard_get_height(&nKBHeight);
		console->setGeometry(0, 0, r.width()-73, r.height()-nKBHeight);
	}else{
		// Portrait - keyboard is higher
		virtualkeyboard_get_height(&nKBHeight);
		console->setGeometry(0, 103, r.width()+1, r.height()-nKBHeight-102);
	}
#else
	console->setGeometry(0, 0, r.width()+1, r.height()-103);
#endif
    console->setScrollBarPosition(QTermWidget::ScrollBarRight);

    // Our 'soft buttons' menu
    Menu = new CMyMenu(mainWindow);
    Menu->MenuInit();

    // Our system menu
    SystemMenu = new CMySystemMenu(mainWindow);
    SystemMenu->MenuInit();

    QObject::connect(console, SIGNAL(finished()), mainWindow, SLOT(close()));

    mainWindow->show();    

#ifndef BBQ10
    // Install event filter
    mainEventFilter = QAbstractEventDispatcher::instance()->setEventFilter(myEventFilter);

    // Show virtual keyboard
    QEvent event(QEvent::RequestSoftwareInputPanel);
    QApplication::sendEvent(console, &event);
    virtualkeyboard_get_height(&nMaxKBHeight); // Init maximum VK height

    virtualkeyboard_request_events(0); // To catch show/hide VK events
#endif
#ifdef BBQ10
    virtualKeyboard = new CMyVirtualKeyboard(mainWindow);
#endif
    return app.exec();
}
QString KicadSchematic2Svg::convertField(const QString & xString, const QString & yString, const QString & fontSizeString, const QString &orientation, 
					 const QString & hjustify, const QString & vjustify, const QString & t)
{
	QString text = t;
	bool notName = false;
	if (text.startsWith("~")) {
		notName = true;
		text.remove(0, 1);
	}

	int x = xString.toInt();
	int y = -yString.toInt();						// KiCad flips y-axis w.r.t. svg
	int fontSize = fontSizeString.toInt();

	bool rotate = (orientation == "V");
	QString rotation;
	QMatrix m;
	if (rotate) {
		m = QMatrix().translate(-x, -y) * QMatrix().rotate(-90) * QMatrix().translate(x, y);
		// store x, y, and r so they can be shifted correctly later
		rotation = QString("transform='%1' _x='%2' _y='%3' _r='-90'").arg(TextUtils::svgMatrix(m)).arg(x).arg(y);
	}

	QFont font;
	font.setFamily(OCRAFontName);
	font.setWeight(QFont::Normal);
	font.setPointSizeF(72.0 * fontSize / GraphicsUtils::StandardFritzingDPI);

	QString style;
	if (vjustify.contains("I")) {
		style += "font-style='italic' ";
		font.setStyle(QFont::StyleItalic);
	}
	if (vjustify.endsWith("B")) {
		style += "font-weight='bold' ";
		font.setWeight(QFont::Bold);
	}
	QString anchor = "middle";
	if (vjustify.startsWith("T")) {
		anchor = "end";
	}
	else if (vjustify.startsWith("B")) {
		anchor = "start";
	}
	if (hjustify.contains("L")) {
		anchor = "start";
	}
	else if (hjustify.contains("R")) {
		anchor = "end";
	}

	QFontMetricsF metrics(font);
	QRectF bri = metrics.boundingRect(text);

	// convert back to 1000 dpi
	QRectF brf(0, 0,
			   bri.width() * GraphicsUtils::StandardFritzingDPI / GraphicsUtils::SVGDPI, 
			   bri.height() * GraphicsUtils::StandardFritzingDPI / GraphicsUtils::SVGDPI);

	if (anchor == "start") {
		brf.translate(x, y - (brf.height() / 2));
	}
	else if (anchor == "end") {
		brf.translate(x - brf.width(), y - (brf.height() / 2));
	}
	else if (anchor == "middle") {
		brf.translate(x - (brf.width() / 2), y - (brf.height() / 2));
	}

	if (rotate) {
		brf = m.map(QPolygonF(brf)).boundingRect();
	}

	checkXLimit(brf.left());
	checkXLimit(brf.right());
	checkYLimit(brf.top());
	checkYLimit(brf.bottom());

	QString s = QString("<text x='%1' y='%2' font-size='%3' font-family='%8' stroke='none' fill='#000000' text-anchor='%4' %5 %6>%7</text>\n")
					.arg(x)		
					.arg(y + (fontSize / 3))		
					.arg(fontSize)		
					.arg(anchor)
					.arg(style)
					.arg(rotation)
					.arg(TextUtils::escapeAnd(unquote(text)))
                    .arg(OCRAFontName)
                    ;		
	if (notName) {
		s += QString("<line fill='none' stroke='#000000' x1='%1' y1='%2' x2='%3' y2='%4' stroke-width='2' />\n")
			.arg(brf.left())
			.arg(brf.top())
			.arg(rotate ? brf.left() : brf.right())
			.arg(rotate ? brf.bottom() : brf.top());
	}
	return s;
}
Esempio n. 27
0
/*
 * 功能:
 * 	  按钮text设置
 * 参数:
 * 	  无
 * 返回值:
 * 	  无
 */
void EnglishInput::setTextShow()
{
    if (m_latterStatus) {
        QFont font;
        font.setStyle(QFont::Style::StyleNormal);
        p_groupABC->button(35)->setFont(font);

        p_groupABC->button(36)->setHidden(false);
        p_groupABC->button(37)->setHidden(false);
        p_groupABC->button(38)->setHidden(false);
        p_groupABC->button(39)->setHidden(false);
        p_groupABC->button(40)->setHidden(false);
        p_groupABC->button(41)->setHidden(false);
        p_groupABC->button(42)->setHidden(false);
        p_groupABC->button(43)->setHidden(false);
        p_groupABC->button(44)->setHidden(false);
        p_groupABC->button(46)->setHidden(false);
        p_groupABC->button(53)->setHidden(false);
        p_groupABC->button(31)->resize((int)(0.1532 * m_currentWidth), (int)(0.0952 * m_currentHeight));
        p_groupABC->button(32)->setHidden(true);
        if (!m_upLatter) {
            p_groupABC->button(0)->setText("1");
            p_groupABC->button(1)->setText("2");
            p_groupABC->button(2)->setText("3");
            p_groupABC->button(3)->setText("4");
            p_groupABC->button(4)->setText("5");
            p_groupABC->button(5)->setText("6");
            p_groupABC->button(6)->setText("7");
            p_groupABC->button(7)->setText("8");
            p_groupABC->button(8)->setText("9");
            p_groupABC->button(9)->setText("0");
            p_groupABC->button(10)->setText("-");
            p_groupABC->button(11)->setText("q");
            p_groupABC->button(12)->setText("w");
            p_groupABC->button(13)->setText("e");
            p_groupABC->button(14)->setText("r");
            p_groupABC->button(15)->setText("t");
            p_groupABC->button(16)->setText("y");
            p_groupABC->button(17)->setText("u");
            p_groupABC->button(18)->setText("i");
            p_groupABC->button(19)->setText("o");
            p_groupABC->button(20)->setText("p");
            p_groupABC->button(21)->setText("+");
            p_groupABC->button(22)->setText("a");
            p_groupABC->button(23)->setText("s");
            p_groupABC->button(24)->setText("d");
            p_groupABC->button(25)->setText("f");
            p_groupABC->button(26)->setText("g");
            p_groupABC->button(27)->setText("h");
            p_groupABC->button(28)->setText("j");
            p_groupABC->button(29)->setText("k");
            p_groupABC->button(30)->setText("l");
            p_groupABC->button(31)->setText("Enter");
            p_groupABC->button(33)->setText("z");
            p_groupABC->button(34)->setText("x");
            p_groupABC->button(35)->setText("c");
            p_groupABC->button(36)->setText("v");
            p_groupABC->button(37)->setText("b");
            p_groupABC->button(38)->setText("n");
            p_groupABC->button(39)->setText("m");
            p_groupABC->button(40)->setText(",");
            p_groupABC->button(41)->setText(".");
            p_groupABC->button(42)->setText("/");
            p_groupABC->button(43)->setText("?");
            p_groupABC->button(44)->setText("Shift");
            p_groupABC->button(46)->setText("SPACE");
            p_groupABC->button(53)->setText("Shift");
        } else {
            p_groupABC->button(0)->setText("!");
            p_groupABC->button(1)->setText("@");
            p_groupABC->button(2)->setText("#");
            p_groupABC->button(3)->setText("$");
            p_groupABC->button(4)->setText("%");
            p_groupABC->button(5)->setText("^");
            p_groupABC->button(6)->setText("&&");
            p_groupABC->button(7)->setText("*");
            p_groupABC->button(8)->setText("(");
            p_groupABC->button(9)->setText(")");
            p_groupABC->button(10)->setText("-");
            p_groupABC->button(11)->setText("Q");
            p_groupABC->button(12)->setText("W");
            p_groupABC->button(13)->setText("E");
            p_groupABC->button(14)->setText("R");
            p_groupABC->button(15)->setText("T");
            p_groupABC->button(16)->setText("Y");
            p_groupABC->button(17)->setText("U");
            p_groupABC->button(18)->setText("I");
            p_groupABC->button(19)->setText("O");
            p_groupABC->button(20)->setText("P");
            p_groupABC->button(21)->setText("=");
            p_groupABC->button(22)->setText("A");
            p_groupABC->button(23)->setText("S");
            p_groupABC->button(24)->setText("D");
            p_groupABC->button(25)->setText("F");
            p_groupABC->button(26)->setText("G");
            p_groupABC->button(27)->setText("H");
            p_groupABC->button(28)->setText("J");
            p_groupABC->button(29)->setText("K");
            p_groupABC->button(30)->setText("L");
            p_groupABC->button(31)->setText("Enter");
            p_groupABC->button(33)->setText("Z");
            p_groupABC->button(34)->setText("X");
            p_groupABC->button(35)->setText("C");
            p_groupABC->button(36)->setText("V");
            p_groupABC->button(37)->setText("B");
            p_groupABC->button(38)->setText("N");
            p_groupABC->button(39)->setText("M");
            p_groupABC->button(40)->setText(",");
            p_groupABC->button(41)->setText(".");
            p_groupABC->button(42)->setText("/");
            p_groupABC->button(43)->setText(":");
            p_groupABC->button(44)->setText("Shift");
            p_groupABC->button(46)->setText("SPACE");
            p_groupABC->button(53)->setText("Shift");
        }
        p_groupABC->button(61)->setText(tr("SYMBOL"));
    } else {
        QFont font;
        font.setStyle(QFont::Style::StyleOblique);
        p_groupABC->button(35)->setFont(font);
        p_groupABC->button(36)->setHidden(true);

        p_groupABC->button(0)->setText("~");
        p_groupABC->button(1)->setText("!");
        p_groupABC->button(2)->setText("@");
        p_groupABC->button(3)->setText("#");
        p_groupABC->button(4)->setText("$");
        p_groupABC->button(5)->setText("%");
        p_groupABC->button(6)->setText("^");
        p_groupABC->button(7)->setText("&&");
        p_groupABC->button(8)->setText("*");
        p_groupABC->button(9)->setText("(");
        p_groupABC->button(10)->setText(")");
        p_groupABC->button(11)->setText("\"");
        p_groupABC->button(12)->setText("\'");
        p_groupABC->button(13)->setText(".");
        p_groupABC->button(14)->setText(":");
        p_groupABC->button(15)->setText("?");
        p_groupABC->button(16)->setText("—");
        p_groupABC->button(17)->setText("=");
        p_groupABC->button(18)->setText("+");
        p_groupABC->button(19)->setText("-");
        p_groupABC->button(20)->setText("/");
        p_groupABC->button(21)->setText("\\");
        p_groupABC->button(22)->setText("|");
        p_groupABC->button(23)->setText("<");
        p_groupABC->button(24)->setText(">");
        p_groupABC->button(25)->setText("{");
        p_groupABC->button(26)->setText("}");
        p_groupABC->button(27)->setText("[");
        p_groupABC->button(28)->setText("]");
        p_groupABC->button(29)->setText("·");
        p_groupABC->button(30)->setText("。");
        p_groupABC->button(31)->resize((int)(0.0714 * m_currentWidth), (int)(0.0952 * m_currentHeight));
        p_groupABC->button(32)->setHidden(false);
        p_groupABC->button(31)->setText("×");
        p_groupABC->button(32)->setText("÷");
        p_groupABC->button(33)->setText("¥");
        p_groupABC->button(34)->setText("±");
        p_groupABC->button(35)->setText("μ");
        p_groupABC->button(61)->setText(tr("ABC"));
        p_groupABC->button(37)->setHidden(true);
        p_groupABC->button(38)->setHidden(true);
        p_groupABC->button(39)->setHidden(true);
        p_groupABC->button(40)->setHidden(true);
        p_groupABC->button(41)->setHidden(true);
        p_groupABC->button(42)->setHidden(true);
        p_groupABC->button(43)->setHidden(true);
        p_groupABC->button(44)->setHidden(true);
        p_groupABC->button(46)->setHidden(true);
        p_groupABC->button(53)->setHidden(true);
    }
    p_groupABC->button(59)->setText(tr("Cancel"));
    p_groupABC->button(60)->setText(tr("OK"));
    p_groupABC->button(55)->setText("BS");
    p_groupABC->button(56)->setText("DEL");
    p_groupABC->button(57)->setText("←");
    p_groupABC->button(58)->setText("→");

}