コード例 #1
0
ファイル: qfontproto.cpp プロジェクト: Wushaowei001/xtuple-1
QString QFontProto::defaultFamily() const
{
  QFont *item = qscriptvalue_cast<QFont*>(thisObject());
  if (item)
    return item->defaultFamily();
  return QString();
}
コード例 #2
0
/*!
	\class SpreadsheetModel
	\brief  Model for the access to a Spreadsheet

	This is a model in the sense of Qt4 model/view framework which is used
	to access a Spreadsheet object from any of Qt4s view classes, typically a QTableView.
	Its main purposes are translating Spreadsheet signals into QAbstractItemModel signals
	and translating calls to the QAbstractItemModel read/write API into calls
	in the public API of Spreadsheet. In many cases a pointer to the addressed column
	is obtained by calling Spreadsheet::column() and the manipulation is done using the
	public API of column.

	\ingroup backend
*/
SpreadsheetModel::SpreadsheetModel(Spreadsheet* spreadsheet)
	: QAbstractItemModel(0), m_spreadsheet(spreadsheet), m_formula_mode(false) {
	updateVerticalHeader();
	updateHorizontalHeader();

	QFont font;
	font.setFamily(font.defaultFamily());
	QFontMetrics fm(font);
	m_defaultHeaderHeight = fm.height()+5;

	connect(m_spreadsheet, SIGNAL(aspectAboutToBeAdded(const AbstractAspect*,const AbstractAspect*,const AbstractAspect*)),
	        this, SLOT(handleAspectAboutToBeAdded(const AbstractAspect*,const AbstractAspect*,const AbstractAspect*)));
	connect(m_spreadsheet, SIGNAL(aspectAdded(const AbstractAspect*)),
	        this, SLOT(handleAspectAdded(const AbstractAspect*)));
	connect(m_spreadsheet, SIGNAL(aspectAboutToBeRemoved(const AbstractAspect*)),
	        this, SLOT(handleAspectAboutToBeRemoved(const AbstractAspect*)));
	connect(m_spreadsheet, SIGNAL(aspectRemoved(const AbstractAspect*,const AbstractAspect*,const AbstractAspect*)),
	        this, SLOT(handleAspectRemoved(const AbstractAspect*,const AbstractAspect*,const AbstractAspect*)));
	connect(m_spreadsheet, SIGNAL(aspectDescriptionChanged(const AbstractAspect*)),
	        this, SLOT(handleDescriptionChange(const AbstractAspect*)));

	for (int i=0; i < spreadsheet->columnCount(); i++) {
		beginInsertColumns(QModelIndex(), i, i);
		handleAspectAdded(spreadsheet->column(i));
	}
}
コード例 #3
0
ファイル: AspectTreeModel.cpp プロジェクト: asemke/labplot
AspectTreeModel::AspectTreeModel(AbstractAspect* root, QObject* parent)
	: QAbstractItemModel(parent),
	  m_root(root),
	  m_folderSelectable(true),
	  m_filterCaseSensitivity(Qt::CaseInsensitive),
	  m_matchCompleteWord(false) {

	QFont font;
	font.setFamily(font.defaultFamily());
	QFontMetrics fm(font);
	m_defaultHeaderHeight = fm.height();

	connect(m_root, SIGNAL(aspectDescriptionChanged(const AbstractAspect*)),
		this, SLOT(aspectDescriptionChanged(const AbstractAspect*)));
	connect(m_root, SIGNAL(aspectAboutToBeAdded(const AbstractAspect*,const AbstractAspect*,const AbstractAspect*)),
		this, SLOT(aspectAboutToBeAdded(const AbstractAspect*,const AbstractAspect*,const AbstractAspect*)));
	connect(m_root, SIGNAL(aspectAboutToBeRemoved(const AbstractAspect*)),
		this, SLOT(aspectAboutToBeRemoved(const AbstractAspect*)));
	connect(m_root, SIGNAL(aspectAdded(const AbstractAspect*)),
		this, SLOT(aspectAdded(const AbstractAspect*)));
	connect(m_root, SIGNAL(aspectRemoved(const AbstractAspect*,const AbstractAspect*,const AbstractAspect*)),
		this, SLOT(aspectRemoved()));
	connect(m_root, SIGNAL(aspectHiddenAboutToChange(const AbstractAspect*)),
		this, SLOT(aspectHiddenAboutToChange(const AbstractAspect*)));
	connect(m_root, SIGNAL(aspectHiddenChanged(const AbstractAspect*)),
		this, SLOT(aspectHiddenChanged(const AbstractAspect*)));
}
コード例 #4
0
ファイル: tst_qitemdelegate.cpp プロジェクト: redanium/qt
void tst_QItemDelegate::font_data()
{
    QTest::addColumn<QString>("itemText");
    QTest::addColumn<QString>("properties");
    QTest::addColumn<QFont>("itemFont");
    QTest::addColumn<QFont>("viewFont");

    QFont itemFont;
    itemFont.setItalic(true);
    QFont viewFont;

    QTest::newRow("foo italic")
            << QString("foo")
            << QString("italic")
            << itemFont
            << viewFont;

    itemFont.setItalic(true);

    QTest::newRow("foo bold")
            << QString("foo")
            << QString("bold")
            << itemFont
            << viewFont;

    itemFont.setFamily(itemFont.defaultFamily());

    QTest::newRow("foo family")
            << QString("foo")
            << QString("family")
            << itemFont
            << viewFont;
}
コード例 #5
0
ファイル: main.cpp プロジェクト: Chrizzldi/AwesomeBump
int main(int argc, char *argv[])
{



    QApplication app(argc, argv);

    // Chossing proper GUI style from config.ini file.
    QSettings settings("config.ini", QSettings::IniFormat);
    // Dude, this default style is really amazing...
    // Seriously?
    // No...
    QString guiStyle = settings.value("gui_style","DefaultAwesomeStyle").toString();
    app.setStyle(QStyleFactory::create( guiStyle ));

    QFont font;
    font.setFamily(font.defaultFamily());
    font.setPixelSize(10);
    app.setFont(font);

    // removing old log file
    QFile::remove(AB_LOG);


    qInstallMessageHandler(customMessageHandler);
    qDebug() << "Starting application:";

    QMessageBox msgBox;
    if(!checkOpenGL()){

        msgBox.setText("Fatal Error!");
        msgBox.setInformativeText("Sorry but it seems that your graphics card does not support openGL 4.0.\n"
                                  "Program will not run :(\n"
                                  "See log.txt file for more info.");
        msgBox.setStandardButtons(QMessageBox::Close);
        msgBox.show();

        return app.exec();
    }else{


        MainWindow window;
        window.setWindowTitle(AWESOME_BUMP_VERSION);
        window.resize(window.sizeHint());
        int desktopArea = QApplication::desktop()->width() *
                         QApplication::desktop()->height();
        int widgetArea = window.width() * window.height();
        if (((float)widgetArea / (float)desktopArea) < 0.75f)
            window.show();
        else
            window.showMaximized();

        return app.exec();

    }



}
コード例 #6
0
ファイル: label.cpp プロジェクト: EvorzStudios/plexydesk
QRectF Label::contents_bounding_rect() const {
  QFont font;
  font.setFamily(font.defaultFamily());
  font.setPixelSize(d->m_font_size);
  QFontMetrics metic(font);
  QRectF rect = metic.boundingRect(d->m_label_string);
  rect.setX(0.0);
  rect.setY(0.0);

  return rect;
}
コード例 #7
0
/*!
    \internal
*/
QWebSettings::QWebSettings()
    : d(new QWebSettingsPrivate)
{
    // Initialize our global defaults
    d->fontSizes.insert(QWebSettings::MinimumFontSize, 0);
    d->fontSizes.insert(QWebSettings::MinimumLogicalFontSize, 0);
    d->fontSizes.insert(QWebSettings::DefaultFontSize, 16);
    d->fontSizes.insert(QWebSettings::DefaultFixedFontSize, 13);

    QFont defaultFont;
    defaultFont.setStyleHint(QFont::Serif);
    d->fontFamilies.insert(QWebSettings::StandardFont, defaultFont.defaultFamily());
    d->fontFamilies.insert(QWebSettings::SerifFont, defaultFont.defaultFamily());

#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
    defaultFont.setStyleHint(QFont::Fantasy);
    d->fontFamilies.insert(QWebSettings::FantasyFont, defaultFont.defaultFamily());

    defaultFont.setStyleHint(QFont::Cursive);
    d->fontFamilies.insert(QWebSettings::CursiveFont, defaultFont.defaultFamily());
#else
    d->fontFamilies.insert(QWebSettings::FantasyFont, defaultFont.defaultFamily());
    d->fontFamilies.insert(QWebSettings::CursiveFont, defaultFont.defaultFamily());
#endif

    defaultFont.setStyleHint(QFont::SansSerif);
    d->fontFamilies.insert(QWebSettings::SansSerifFont, defaultFont.defaultFamily());

#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
    defaultFont.setStyleHint(QFont::Monospace);
#else
    defaultFont.setStyleHint(QFont::TypeWriter);
#endif
    d->fontFamilies.insert(QWebSettings::FixedFont, defaultFont.defaultFamily());

    d->attributes.insert(QWebSettings::AutoLoadImages, true);
    d->attributes.insert(QWebSettings::DnsPrefetchEnabled, false);
    d->attributes.insert(QWebSettings::JavascriptEnabled, true);
    d->attributes.insert(QWebSettings::SpatialNavigationEnabled, false);
    d->attributes.insert(QWebSettings::LinksIncludedInFocusChain, true);
    d->attributes.insert(QWebSettings::ZoomTextOnly, false);
    d->attributes.insert(QWebSettings::PrintElementBackgrounds, true);
    d->attributes.insert(QWebSettings::OfflineStorageDatabaseEnabled, false);
    d->attributes.insert(QWebSettings::OfflineWebApplicationCacheEnabled, false);
    d->attributes.insert(QWebSettings::LocalStorageEnabled, false);
    d->attributes.insert(QWebSettings::LocalContentCanAccessRemoteUrls, false);
    d->attributes.insert(QWebSettings::LocalContentCanAccessFileUrls, true);
    d->attributes.insert(QWebSettings::AcceleratedCompositingEnabled, true);
    d->attributes.insert(QWebSettings::WebGLEnabled, false);
    d->attributes.insert(QWebSettings::HyperlinkAuditingEnabled, false);
    d->attributes.insert(QWebSettings::TiledBackingStoreEnabled, false);
    d->attributes.insert(QWebSettings::FrameFlatteningEnabled, false);
    d->attributes.insert(QWebSettings::SiteSpecificQuirksEnabled, true);
    d->offlineStorageDefaultQuota = 5 * 1024 * 1024;
    d->defaultTextEncoding = QLatin1String("iso-8859-1");
}
コード例 #8
0
ファイル: main.cpp プロジェクト: cvilas/ugv1
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QFont font;
    font.setFamily(font.defaultFamily());
    font.setPointSize(8);
    a.setFont(font);

    MainWindow w;
    w.show();
    
    return a.exec();
}
コード例 #9
0
void tst_QFont::defaultFamily()
{
    QFETCH(QFont::StyleHint, styleHint);
    QFETCH(QString, defaultFamily);

    QFontDatabase db;
    if (!db.hasFamily(defaultFamily))
        QSKIP("Font family is not available on the system");

    QFont f;
    f.setStyleHint(styleHint);
    QCOMPARE(QFontDatabase::resolveFontFamilyAlias(f.defaultFamily()), QFontDatabase::resolveFontFamilyAlias(defaultFamily));

}
コード例 #10
0
ファイル: window.cpp プロジェクト: jpataias/scout-talker
// Method to create the main title
void Window::createTitle()
{
    // Creates the group box
    titleGroupBox = new QGroupBox();

    // Creates the Horizontal Box Layout for the group box
    QHBoxLayout *layout = new QHBoxLayout;

    // Creates the main title of the program label
    QLabel *mainTitle = new QLabel(tr("Scout Talker"));

    // Center aligns the label
    mainTitle->setAlignment(Qt::AlignCenter);

    QFont font;
    font.setFamily(font.defaultFamily()); // Sets the font as the default one
    font.setPointSize(20); // Sets font size
    font.setBold(true); // Sets font as bold

    // Changes the label font
    mainTitle->setFont(font);

    // Creates the main menu
    createMainMenu();

    // Set alignment of the layout
    layout->setAlignment(Qt::AlignCenter);

    // Add an empty space with the size of 50
    layout->insertSpacing(0, 50);

    // Add title widget to the layout
    layout->addWidget(mainTitle);

    // Add space between widgets
    layout->addSpacing(25);

    // Add button to the layout
    layout->addWidget(mainMenuButton);

    // Add an empty space with the size of 50
    layout->addSpacing(50);

    // Sets the group box layout
    titleGroupBox->setLayout(layout);
    // Command to remove border of Group Box
    titleGroupBox->setStyleSheet("QGroupBox {border: 0px solid gray;}");
}
コード例 #11
0
/*!
    \internal
*/
QWebSettings::QWebSettings()
    : d(new QWebSettingsPrivate)
{
    // Initialize our global defaults
    d->fontSizes.insert(QWebSettings::MinimumFontSize, 0);
    d->fontSizes.insert(QWebSettings::MinimumLogicalFontSize, 0);
    d->fontSizes.insert(QWebSettings::DefaultFontSize, 16);
    d->fontSizes.insert(QWebSettings::DefaultFixedFontSize, 13);

    QFont defaultFont;
    defaultFont.setStyleHint(QFont::Serif);
    d->fontFamilies.insert(QWebSettings::StandardFont, defaultFont.defaultFamily());
    d->fontFamilies.insert(QWebSettings::SerifFont, defaultFont.defaultFamily());

    defaultFont.setStyleHint(QFont::Fantasy);
    d->fontFamilies.insert(QWebSettings::FantasyFont, defaultFont.defaultFamily());

    defaultFont.setStyleHint(QFont::Cursive);
    d->fontFamilies.insert(QWebSettings::CursiveFont, defaultFont.defaultFamily());

    defaultFont.setStyleHint(QFont::SansSerif);
    d->fontFamilies.insert(QWebSettings::SansSerifFont, defaultFont.defaultFamily());

    defaultFont.setStyleHint(QFont::Monospace);
    d->fontFamilies.insert(QWebSettings::FixedFont, defaultFont.defaultFamily());

    d->attributes.insert(QWebSettings::AutoLoadImages, true);
    d->attributes.insert(QWebSettings::DnsPrefetchEnabled, false);
    d->attributes.insert(QWebSettings::JavascriptEnabled, true);
    d->attributes.insert(QWebSettings::SpatialNavigationEnabled, false);
    d->attributes.insert(QWebSettings::LinksIncludedInFocusChain, true);
    d->attributes.insert(QWebSettings::ZoomTextOnly, false);
    d->attributes.insert(QWebSettings::PrintElementBackgrounds, true);
    d->attributes.insert(QWebSettings::OfflineStorageDatabaseEnabled, false);
    d->attributes.insert(QWebSettings::OfflineWebApplicationCacheEnabled, false);
    d->attributes.insert(QWebSettings::LocalStorageEnabled, false);
    d->attributes.insert(QWebSettings::LocalContentCanAccessRemoteUrls, false);
    d->attributes.insert(QWebSettings::LocalContentCanAccessFileUrls, true);
    d->attributes.insert(QWebSettings::AcceleratedCompositingEnabled, true);
    d->attributes.insert(QWebSettings::WebGLEnabled, true);
    d->attributes.insert(QWebSettings::WebAudioEnabled, false);
    d->attributes.insert(QWebSettings::CSSRegionsEnabled, true);
    d->attributes.insert(QWebSettings::CSSCompositingEnabled, true);
    d->attributes.insert(QWebSettings::CSSGridLayoutEnabled, false);
    d->attributes.insert(QWebSettings::HyperlinkAuditingEnabled, false);
    d->attributes.insert(QWebSettings::TiledBackingStoreEnabled, false);
    d->attributes.insert(QWebSettings::FrameFlatteningEnabled, false);
    d->attributes.insert(QWebSettings::SiteSpecificQuirksEnabled, true);
    d->attributes.insert(QWebSettings::ScrollAnimatorEnabled, false);
    d->attributes.insert(QWebSettings::CaretBrowsingEnabled, false);
    d->attributes.insert(QWebSettings::NotificationsEnabled, true);
    d->offlineStorageDefaultQuota = 5 * 1024 * 1024;
    d->defaultTextEncoding = QLatin1String("iso-8859-1");
    d->thirdPartyCookiePolicy = AlwaysAllowThirdPartyCookies;
}
コード例 #12
0
ファイル: usersdialog.cpp プロジェクト: amarsman/qtpass
void UsersDialog::populateList(const QString &filter) {
  QRegExp nameFilter("*" + filter + "*");
  nameFilter.setPatternSyntax(QRegExp::Wildcard);
  nameFilter.setCaseSensitivity(Qt::CaseInsensitive);
  ui->listWidget->clear();
  if (userList) {
    for (QList<UserInfo>::iterator it = userList->begin();
         it != userList->end(); ++it) {
      UserInfo &user(*it);
      if (filter.isEmpty() || nameFilter.exactMatch(user.name)) {
        if (user.validity == '-' && !ui->checkBox->isChecked())
          continue;
        if (user.expiry.toTime_t() > 0 &&
            user.expiry.daysTo(QDateTime::currentDateTime()) > 0 &&
            !ui->checkBox->isChecked())
          continue;
        QString userText = user.name + "\n" + user.key_id;
        if (user.created.toTime_t() > 0) {
          userText += " " + tr("created") + " " +
                      user.created.toString(Qt::SystemLocaleShortDate);
        }
        if (user.expiry.toTime_t() > 0)
          userText += " " + tr("expires") + " " +
                      user.expiry.toString(Qt::SystemLocaleShortDate);
        QListWidgetItem *item = new QListWidgetItem(userText, ui->listWidget);
        item->setCheckState(user.enabled ? Qt::Checked : Qt::Unchecked);
        item->setData(Qt::UserRole, QVariant::fromValue(&user));
        if (user.have_secret) {
          // item->setForeground(QColor(32, 74, 135));
          item->setForeground(Qt::blue);
          QFont font;
          font.setFamily(font.defaultFamily());
          font.setBold(true);
          item->setFont(font);
        } else if (user.validity == '-') {
          item->setBackground(QColor(164, 0, 0));
          item->setForeground(Qt::white);
        } else if (user.expiry.toTime_t() > 0 &&
                   user.expiry.daysTo(QDateTime::currentDateTime()) > 0) {
          item->setForeground(QColor(164, 0, 0));
        }

        ui->listWidget->addItem(item);
      }
    }
  }
}
コード例 #13
0
void ScreenshotThumbView::drawText(QPainter *painter, const QColor &bgColor, const QColor &textColor)
{
    painter->save();
    QBrush roundedRectBrush = QBrush(bgColor);
    QPen roundedRectPen = QPen(roundedRectBrush, 1.0);
    QBrush textBrush = QBrush(textColor);
    QFont d;
    QFont f(d.defaultFamily(), 20, QFont::Normal);
    QRect textRect = QRect(0, 0, this->width() / 2, this->height() / 6);
    textRect.moveCenter(this->rect().center());

    painter->setBrush(roundedRectBrush);
    painter->setPen(roundedRectPen);
    painter->drawRoundedRect(textRect, 10.0, 10.0);

    painter->setFont(f);
    painter->setBrush(textBrush);
    painter->setPen(QPen(textBrush, 1.0));
    painter->drawText(this->rect(), Qt::AlignCenter, tr("Click to edit"));
    painter->restore();
}
コード例 #14
0
void tst_QFont::defaultFamily()
{
    QFETCH(QFont::StyleHint, styleHint);
    QFETCH(QStringList, acceptableFamilies);

    QFont f;
    QFontDatabase db;
    f.setStyleHint(styleHint);
    const QString familyForHint(f.defaultFamily());

    // it should at least return a family that is available.
    QVERIFY(db.hasFamily(familyForHint));

    bool isAcceptable = false;
    Q_FOREACH (const QString& family, acceptableFamilies) {
        if (!familyForHint.compare(family, Qt::CaseInsensitive)) {
            isAcceptable = true;
            break;
        }
    }
    QVERIFY2(isAcceptable, msgNotAcceptableFont(familyForHint, acceptableFamilies));
}
コード例 #15
0
void QWebPreferencesPrivate::initializeDefaultFontSettings()
{
    setFontSize(MinimumFontSize, 0);
    setFontSize(DefaultFontSize, 16);
    setFontSize(DefaultFixedFontSize, 13);

    QFont defaultFont;
    defaultFont.setStyleHint(QFont::Serif);
    setFontFamily(StandardFont, defaultFont.defaultFamily());
    setFontFamily(SerifFont, defaultFont.defaultFamily());

    defaultFont.setStyleHint(QFont::Fantasy);
    setFontFamily(FantasyFont, defaultFont.defaultFamily());

    defaultFont.setStyleHint(QFont::Cursive);
    setFontFamily(CursiveFont, defaultFont.defaultFamily());

    defaultFont.setStyleHint(QFont::SansSerif);
    setFontFamily(SansSerifFont, defaultFont.defaultFamily());

    defaultFont.setStyleHint(QFont::Monospace);
    setFontFamily(FixedFont, defaultFont.defaultFamily());
}
コード例 #16
0
GraphicDataDialog::GraphicDataDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::GraphicDataDialog),mBlackpen(Qt::black),
    mBluepen(Qt::blue),mRedpen(Qt::red)
{

    ui->setupUi(this);



    QFont defaultfont;
    int fontsize = defaultfont.defaultFamily().size();
    mBluepen.setWidth(BLUE_PEN_WIDTH);
    mBlackpen.setWidth(BLACK_PEN_WIDTH);
    mRedpen.setWidth(RED_PEN_WIDTH);
    mRedpen.setCapStyle( Qt::RoundCap);

    mpDataSensor = new DataSensorParser(this);


    mpGraphicScene = new QGraphicsScene(this);
    ui->graphicsView->setScene(mpGraphicScene);

    mLocalviewwidth = ui->graphicsView->width()-HORIZONTAL_EMPTY_SPACE;
    mLocalviewheight = ui->graphicsView->height()-VERTICAL_EMPTY_SPACE;


    int y_offset_from_window_border=mLocalviewheight/VERTICAL_VALUES_AVAILABLE_TO_PAINT*NEGATIV_VALUES;
    int x_scaled_system = Y_LABEL.size()*fontsize;
    int y_scaled_system = mLocalviewheight - y_offset_from_window_border;

    mMatrix.translate( x_scaled_system, y_scaled_system );
    mMatrix.scale( 1, -1 );

    mpGraphicScene->addLine(0, y_scaled_system, mLocalviewwidth, y_scaled_system,mBluepen);
    mpGraphicScene->addLine(x_scaled_system, 0, x_scaled_system, mLocalviewheight ,mBluepen);


    mYlbl.setPos(Y_LABEL_X_,Y_LABEL_Y);
    mYlbl.setPlainText(Y_LABEL);
    mYlbl.setDefaultTextColor(Qt::black);
    mpGraphicScene->addItem(&mYlbl);

    mXlbl.setPos(mLocalviewwidth-X_LABEL_X_OFFSET,y_scaled_system-X_LABEL_Y_OFFSET);
    mXlbl.setPlainText(X_LABEL);
    mXlbl.setDefaultTextColor(Qt::black);
    mpGraphicScene->addItem(&mXlbl);

    int pixelxlabel= mLocalviewheight/VERTICAL_VALUES_AVAILABLE_TO_PAINT;

    LabelGraphicItem *ptextitem;

    int grad = -NEGATIV_VALUES;
    int ytext= mLocalviewheight-fontsize/2;
    while (ytext > pixelxlabel +fontsize/2)
    {
        if  (grad != 0)
        {
             // skip label for origin point
             ptextitem = new LabelGraphicItem();
             ptextitem->setBoundingRect(x_scaled_system-Y_LABEL_SPACE_PIXEL,ytext, WIDTH_LABEL_Y , HEIGHT_LABEL_Y);
             ptextitem->setText(QString::number(grad));
             ptextitem->setDefaultTextColor(Qt::black);
             mpGraphicScene->addItem(ptextitem);
             mLabelList.append(ptextitem);
        }
        grad+=OFFSET_FOR_Y_LABELS;
        ytext-= pixelxlabel*OFFSET_FOR_Y_LABELS;
    }

    GraphicItem *pline;

    for (int liney=-NEGATIV_VALUES; liney <VERTICAL_VALUES_AVAILABLE_TO_PAINT-NEGATIV_VALUES; liney+=OFFSET_FOR_Y_LABELS)
    {

        pline = new GraphicItem(GraphicItem::linefigure);
        pline->setMatrix(mMatrix);
        pline->drawLine(X1_FOR_DASH_SYMBOL, liney*pixelxlabel , X2_FOR_DASH_SYMBOL,liney*pixelxlabel ,mBluepen);
        mpGraphicScene->addItem(pline);
        mGraphicDashList.append(pline);

   }

    this->paintMeasurePoints();

}
コード例 #17
0
ファイル: main.cpp プロジェクト: galaxymax/AwesomeBump
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    qDebug() << "Application dir:" << QApplication::applicationDirPath();
    qDebug() << "Data dir:" << _find_data_dir("");

    // Chossing proper GUI style from config.ini file.
    QSettings settings("config.ini", QSettings::IniFormat);
    // Dude, this default style is really amazing...
    // Seriously?
    // No...
    QString guiStyle = settings.value("gui_style","DefaultAwesomeStyle").toString();
    app.setStyle(QStyleFactory::create( guiStyle ));

    // Customize some elements:
    app.setStyleSheet("QGroupBox { font-weight: bold; } ");

    QFont font;
    font.setFamily(font.defaultFamily());
    font.setPixelSize(10);
    app.setFont(font);

    // removing old log file
    QFile::remove(AB_LOG);


    QGLFormat glFormat(QGL::SampleBuffers);

#if defined(Q_OS_LINUX) || defined(Q_OS_MAC)
     /*
     * Commenting out the next line because it causes rendering to fail.  QGLFormat::CoreProfile
     * disables all OpenGL functions that are depreciated as of OpenGL 3.0.  This fix is a workaround.
     * The full solution is to replace all depreciated OpenGL functions with their current implements.
    */
# if defined(Q_OS_MAC)
	glFormat.setProfile( QGLFormat::CoreProfile );
# endif
    glFormat.setVersion( GL_MAJOR, GL_MINOR );
#endif

    QGLFormat::setDefaultFormat(glFormat);


    qInstallMessageHandler(customMessageHandler);
    qDebug() << "Starting application:";

    if(!checkOpenGL()){

        AllAboutDialog msgBox;
        msgBox.setPixmap(":/resources/icon-off.png");
        msgBox.setText("Fatal Error!");

        msgBox.setInformativeText(QString("Sorry but it seems that your graphics card does not support openGL %1.%2.\n"
                                          "Program will not run :(\n"
                                          "See " AB_LOG " file for more info.").arg(GL_MAJOR).arg(GL_MINOR));

        msgBox.show();

        return app.exec();
    }else{

        MainWindow window;
        window.setWindowTitle(AWESOME_BUMP_VERSION);
        window.resize(window.sizeHint());
        int desktopArea = QApplication::desktop()->width() *
                         QApplication::desktop()->height();
        int widgetArea = window.width() * window.height();
        if (((float)widgetArea / (float)desktopArea) < 0.75f)
            window.show();
        else
            window.showMaximized();

        return app.exec();

    }



}
コード例 #18
0
void tst_QFontCache::clear()
{
#ifdef QT_BUILD_INTERNAL
    QFontEngine_startCollectingEngines();
#else
    // must not crash, at very least ;)
#endif

    QFontEngine *fontEngine = 0;

    {
        // we're never caching the box (and the "test") font engines
        // let's ensure we're not leaking them as well as the cached ones
        qt_setQtEnableTestFont(true);

        QFont f;
        f.setFamily("__Qt__Box__Engine__");
        f.exactMatch(); // loads engine
    }
    {
        QFontDatabase db;

        QFont f;
        f.setStyleHint(QFont::Serif);
        const QString familyForHint(f.defaultFamily());

        // it should at least return a family that is available
        QVERIFY(db.hasFamily(familyForHint));
        f.exactMatch(); // loads engine

        fontEngine = QFontPrivate::get(f)->engineForScript(QChar::Script_Common);
        QVERIFY(fontEngine);
        QVERIFY(QFontCache::instance()->engineCacheCount.value(fontEngine) > 0); // ensure it is cached

        // acquire the engine to use it somewhere else:
        // (e.g. like the we do in QFontSubset() or like QRawFont does in fromFont())
        fontEngine->ref.ref();

        // cache the engine once again; there is a special case when the engine is cached more than once
        QFontCache::instance()->insertEngine(QFontCache::Key(QFontDef(), 0, 0), fontEngine);
    }

    // use it:
    // e.g. fontEngine->stringToCMap(..);

    // and whilst it is alive, don't hesitate to add/remove the app-local fonts:
    // (QFontDatabase::{add,remove}ApplicationFont() clears the cache)
    QFontCache::instance()->clear();

    // release the acquired engine:
    if (fontEngine) {
        if (!fontEngine->ref.deref())
            delete fontEngine;
        fontEngine = 0;
    }

    // we may even exit the application now:
    QFontCache::instance()->cleanup();

#ifdef QT_BUILD_INTERNAL
    QList<QFontEngine *> leakedEngines = QFontEngine_stopCollectingEngines();
    for (int i = 0; i < leakedEngines.size(); ++i) qWarning() << i << leakedEngines.at(i) << leakedEngines.at(i)->ref.load();
    // and we are not leaking!
    QCOMPARE(leakedEngines.size(), 0);
#endif
}
コード例 #19
0
ファイル: main.cpp プロジェクト: illwieckz/AwesomeBump
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    qDebug() << "Application dir:" << QApplication::applicationDirPath();
    qDebug() << "Data dir:" << _find_data_dir("");

    // Chossing proper GUI style from config.ini file.
    QSettings settings("config.ini", QSettings::IniFormat);
    // Dude, this default style is really amazing...
    // Seriously?
    // No...
    QString guiStyle = settings.value("gui_style","DefaultAwesomeStyle").toString();
    app.setStyle(QStyleFactory::create( guiStyle ));

    // Customize some elements:
    app.setStyleSheet("QGroupBox { font-weight: bold; } ");

    QFont font;
    font.setFamily(font.defaultFamily());
    font.setPixelSize(10);
    app.setFont(font);

    // removing old log file
    QFile::remove(AB_LOG);


    QGLFormat glFormat(QGL::SampleBuffers);

#ifdef Q_OS_MAC
    glFormat.setProfile( QGLFormat::CoreProfile );
    glFormat.setVersion( 4, 1 );
#endif

#ifdef USE_OPENGL_330
#ifdef Q_OS_LINUX
    glFormat.setProfile( QGLFormat::CoreProfile );
    glFormat.setVersion( 3, 3 );
#endif
#endif

    QGLFormat::setDefaultFormat(glFormat);


    qInstallMessageHandler(customMessageHandler);
    qDebug() << "Starting application:";

    if(!checkOpenGL()){

        AllAboutDialog msgBox;
        msgBox.setPixmap(":/resources/icon-off.png");
        msgBox.setText("Fatal Error!");

#ifdef USE_OPENGL_330
        msgBox.setInformativeText("Sorry but it seems that your graphics card does not support openGL 3.3.\n"
                                  "Program will not run :(\n"
                                  "See " AB_LOG " file for more info.");
#else
        msgBox.setInformativeText("Sorry but it seems that your graphics card does not support openGL 4.0.\n"
                                  "Program will not run :(\n"
                                  "See " AB_LOG " file for more info.");
#endif


        msgBox.show();

        return app.exec();
    }else{

        MainWindow window;
        window.setWindowTitle(AWESOME_BUMP_VERSION);
        window.resize(window.sizeHint());
        int desktopArea = QApplication::desktop()->width() *
                         QApplication::desktop()->height();
        int widgetArea = window.width() * window.height();
        if (((float)widgetArea / (float)desktopArea) < 0.75f)
            window.show();
        else
            window.showMaximized();

        return app.exec();

    }



}
コード例 #20
0
ファイル: CQFontRenderer.cpp プロジェクト: bmoreau/COPASI
/**
 * Returns the font that matches the given FontSpec.
 */
QFont CQFontRenderer::getFont(const CLFontSpec& spec)
{
  // we only initialize the font database when it is needed for the first time,
  // hopefully this will resolve the crash under linux if it is instanciated to early.
  if (this->mpFontDatabase == NULL)
    {
      this->mpFontDatabase = new QFontDatabase();
    }

  // check if it is a generic font name (sand, serif or monospaced)
  // and try to find a fitting font
  // sans: helvetica or arial
  // serif: times, times new roman or garamond
  // monospaced: courier, courier new or monaco
  //std::cout << "Searching font for family \"" << spec.mFamily << "\" with size " << spec.mSize << " weight " << (spec.mWeight==CLText::WEIGHT_BOLD?(const char*)"bold":(const char*)"normal") << " and style " << (spec.mStyle==CLText::STYLE_ITALIC?(const char*)"italic":(const char*)"normal") << "." << std::endl;
  std::map<CLFontSpec, QFont>::iterator pos;
  pos = this->mFontMap.find(spec);
  QFont font;
  QString styleString;

  if (spec.mWeight == CLText::WEIGHT_BOLD)
    {
      styleString = "Bold";
    }

  if (spec.mStyle == CLText::STYLE_ITALIC)
    {
      styleString += " Italic";
    }

  styleString = styleString.trimmed();

  if (pos == this->mFontMap.end())
    {
      QString family(spec.mFamily.c_str());
      family = family.toLower();

      if (family == "sans")
        {
          // try helvetica and arial in this order
          QFont defaultFont;
          QString defaultFamily = defaultFont.defaultFamily();
          defaultFont = this->mpFontDatabase->font(defaultFamily, styleString, spec.mSize);
          CLFontSpec tempSpec = spec;
          tempSpec.mFamily = "helvetica";

          if (defaultFamily.contains(tempSpec.mFamily.c_str()))
            {
              font = defaultFont;
            }
          else
            {
              font = this->getFont(tempSpec);

              if (font == defaultFont)
                {
                  // if the font is the default font, we try the next one
                  tempSpec.mFamily = "arial";

                  if (defaultFamily.contains(tempSpec.mFamily.c_str()))
                    {
                      font = defaultFont;
                    }
                  else
                    {
                      font = this->getFont(tempSpec);
                    }
                }
            }
        }
      else if (family == "serif")
        {
          // try times, times new roman and garamond in this order
          QFont defaultFont;
          QString defaultFamily = defaultFont.defaultFamily();
          defaultFont = this->mpFontDatabase->font(defaultFamily, styleString, spec.mSize);
          CLFontSpec tempSpec = spec;
          tempSpec.mFamily = "times";

          if (defaultFamily.contains(tempSpec.mFamily.c_str()))
            {
              font = defaultFont;
            }
          else
            {
              font = this->getFont(tempSpec);

              if (font == defaultFont)
                {
                  // if the font is the default font, we try the next one
                  tempSpec.mFamily = "times new roman";

                  if (defaultFamily.contains(tempSpec.mFamily.c_str()))
                    {
                      font = defaultFont;
                    }
                  else
                    {
                      font = this->getFont(tempSpec);

                      if (font == defaultFont)
                        {
                          // if the font is the default font, we try the next one
                          tempSpec.mFamily = "garamond";

                          if (defaultFamily.contains(tempSpec.mFamily.c_str()))
                            {
                              font = defaultFont;
                            }
                          else
                            {
                              font = this->getFont(tempSpec);
                            }
                        }
                    }
                }
            }
        }
      else if (family == "monospaced")
        {
          // try courier, courier new and monaco in this order
          QFont defaultFont;
          QString defaultFamily = defaultFont.defaultFamily();
          defaultFont = this->mpFontDatabase->font(defaultFamily, styleString, spec.mSize);
          CLFontSpec tempSpec = spec;
          tempSpec.mFamily = "courier";

          if (defaultFamily.contains(tempSpec.mFamily.c_str()))
            {
              font = defaultFont;
            }
          else
            {
              font = this->getFont(tempSpec);

              if (font == defaultFont)
                {
                  // if the font is the default font, we try the next one
                  tempSpec.mFamily = "courier new";

                  if (defaultFamily.contains(tempSpec.mFamily.c_str()))
                    {
                      font = defaultFont;
                    }
                  else
                    {
                      font = getFont(tempSpec);

                      if (font == defaultFont)
                        {
                          // if the font is the default font, we try the next one
                          tempSpec.mFamily = "monaco";

                          if (defaultFamily.contains(tempSpec.mFamily.c_str()))
                            {
                              font = defaultFont;
                            }
                          else
                            {
                              font = this->getFont(tempSpec);
                            }
                        }
                    }
                }
            }
        }
      else
        {
          std::list<std::string> familyList;
          this->getFamilyList(spec.mFamily, familyList);
          // now create the font for one of the families in the list
          QFont defaultFont;
          QString defaultFamily = defaultFont.defaultFamily();
          defaultFont = this->mpFontDatabase->font(defaultFamily, styleString, spec.mSize);

          if (!familyList.empty())
            {
              // go through the list and check if there is a font in the that
              // does not return the default font for the given size and
              // style
              std::list<std::string>::const_iterator familyIt = familyList.begin(), familyEndit = familyList.end();

              while (familyIt != familyEndit)
                {
                  font = QFont(familyIt->c_str(), spec.mSize, (spec.mWeight == CLText::WEIGHT_BOLD) ? QFont::Bold : QFont::Normal, (spec.mStyle == CLText::STYLE_NORMAL) ? false : true);

                  if (font != defaultFont)
                    {
                      break;
                    }

                  ++familyIt;
                }
            }
          else
            {
              // return the default font
              font = defaultFont;
            }
        }

      this->mFontMap.insert(std::pair<CLFontSpec, QFont>(spec, font));
    }
  else
    {
      font = pos->second;
    }

  //std::cout << "Using font family \"" << font.mFamily().toLatin1().data() << "\" with size " << font.pointSize() << " weight " << (font.bold()?(const char*)"bold":(const char*)"normal") << " and style " << (font.italic()?(const char*)"italic":(const char*)"normal") << "." << std::endl;
  return font;
}
コード例 #21
0
OptionsDialog::OptionsDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::OptionsDialog),
    model(0),
    mapper(0),
    fRestartWarningDisplayed_Proxy(false),
    fRestartWarningDisplayed_Lang(false),
    fProxyIpValid(true)
{
    ui->setupUi(this);
	#ifdef Q_OS_ANDROID
 	 QFont font;
    font.setFamily(font.defaultFamily());
    QRect rec = QApplication::desktop()->screenGeometry();
    int fS=std::max(7,(int)rec.width()/80);
    font.setPointSize(fS);
    this->setFont(font);
    this->setFixedWidth((int)rec.width());
    this->setFixedHeight((int)(rec.height()*0.8));
	#endif

    /* Network elements init */
#ifndef USE_UPNP
    ui->mapPortUpnp->setEnabled(false);
#endif

    ui->proxyIp->setEnabled(false);
    ui->proxyPort->setEnabled(false);
    ui->proxyPort->setValidator(new QIntValidator(1, 65535, this));

    ui->socksVersion->setEnabled(false);
    ui->socksVersion->addItem("5", 5);
    ui->socksVersion->addItem("4", 4);
    ui->socksVersion->setCurrentIndex(0);

    connect(ui->connectSocks, SIGNAL(toggled(bool)), ui->proxyIp, SLOT(setEnabled(bool)));
    connect(ui->connectSocks, SIGNAL(toggled(bool)), ui->proxyPort, SLOT(setEnabled(bool)));
    connect(ui->connectSocks, SIGNAL(toggled(bool)), ui->socksVersion, SLOT(setEnabled(bool)));
    connect(ui->connectSocks, SIGNAL(clicked(bool)), this, SLOT(showRestartWarning_Proxy()));

    ui->proxyIp->installEventFilter(this);

    /* Window elements init */
#ifdef Q_OS_MAC
    ui->tabWindow->setVisible(false);
#endif

    /* Display elements init */
    QDir translations(":translations");
    ui->lang->addItem(QString("(") + tr("default") + QString(")"), QVariant(""));
    foreach(const QString &langStr, translations.entryList())
    {
        QLocale locale(langStr);

        /** check if the locale name consists of 2 parts (language_country) */
        if(langStr.contains("_"))
        {
#if QT_VERSION >= 0x040800
            /** display language strings as "native language - native country (locale name)", e.g. "Deutsch - Deutschland (de)" */
            ui->lang->addItem(locale.nativeLanguageName() + QString(" - ") + locale.nativeCountryName() + QString(" (") + langStr + QString(")"), QVariant(langStr));
#else
            /** display language strings as "language - country (locale name)", e.g. "German - Germany (de)" */
            ui->lang->addItem(QLocale::languageToString(locale.language()) + QString(" - ") + QLocale::countryToString(locale.country()) + QString(" (") + langStr + QString(")"), QVariant(langStr));
#endif
        }
        else
        {
#if QT_VERSION >= 0x040800
            /** display language strings as "native language (locale name)", e.g. "Deutsch (de)" */
            ui->lang->addItem(locale.nativeLanguageName() + QString(" (") + langStr + QString(")"), QVariant(langStr));
#else
            /** display language strings as "language (locale name)", e.g. "German (de)" */
            ui->lang->addItem(QLocale::languageToString(locale.language()) + QString(" (") + langStr + QString(")"), QVariant(langStr));
#endif
        }
    }

    ui->unit->setModel(new BitcoinUnits(this));

    /* Widget-to-option mapper */
    mapper = new MonitoredDataMapper(this);
    mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit);
    mapper->setOrientation(Qt::Vertical);

    /* enable apply button when data modified */
    connect(mapper, SIGNAL(viewModified()), this, SLOT(enableApplyButton()));
    /* disable apply button when new data loaded */
    connect(mapper, SIGNAL(currentIndexChanged(int)), this, SLOT(disableApplyButton()));
    /* setup/change UI elements when proxy IP is invalid/valid */
    connect(this, SIGNAL(proxyIpValid(QValidatedLineEdit *, bool)), this, SLOT(handleProxyIpValid(QValidatedLineEdit *, bool)));
}
コード例 #22
0
ファイル: winbardelegate.cpp プロジェクト: chrismayo/ONLIGHT
void WinBarDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const
{
    if(index.isValid() && index.data(ChannelData).isValid()){
        painter->save();
        painter->setRenderHint(QPainter::Antialiasing);

        /**************配置*****************/
        QRectF rect(option.rect.marginsAdded(margins));
        if(option.state & QStyle::State_Sunken && option.state & QStyle::State_HasFocus){
            rect.moveTo(rect.x() + 1, rect.y() + 1);
        }
        QRectF topRect(rect);
        topRect.setHeight(rect.height()/6);
        QFont font = option.font;
        font.setFamily(font.defaultFamily());

        /*****************色卡*****************/
        QRectF colorRect(topRect);
        colorRect.setHeight(topRect.height()/5 * 3);
        painter->setPen(QColor(0,0,0,0));
        painter->setBrush(QColor(index.data(ChannelColor).value<QColor>()));
        painter->drawRoundedRect(colorRect,5,5);

        /****************头部背景色**************/
        QRectF headRect(topRect);
        headRect.setTop(colorRect.center().y());
        painter->setBrush(QBrush(QColor(240,240,240)));
        painter->drawRect(headRect);

        /******************底部背景色*******************/
        QRectF bottomRect(rect);
        bottomRect.setTop(topRect.bottom() + 2);
        painter->setPen(QColor(0,0,0,0));
        painter->setBrush(QBrush(QColor(240,240,240)));
        painter->drawRect(bottomRect);

        /******************色柱********************/
        QRectF barRect(bottomRect);
        quint8 base = index.data(ChannelBarBase).toUInt();
        qreal mesureVal = index.data(ChannelData).toDouble();
        qreal rangeUpper = index.data(ChannelDispUpper).toDouble();
        qreal rangeDowner = index.data(ChannelDispDowner).toDouble();
        if(mesureVal >= 0){
            barRect.setTop(barRect.top() + barRect.height()/2 * (1 - mesureVal/rangeUpper));
        }else if(mesureVal < 0){
            barRect.setTop(barRect.top() + barRect.height()/2 * (1 + mesureVal/rangeDowner));
        }
        if(base == 1){
            barRect.setBottom(bottomRect.center().y());
        }else if(base == 2){
            barRect.setBottom(bottomRect.top());
        }
        painter->setPen(QColor(0,0,0,0));
        painter->setBrush(QColor(index.data(ChannelColor).value<QColor>()));
        painter->drawRect(barRect);

        /****************光泽效果*****************/
        QLinearGradient skinColor(rect.topLeft(),rect.topRight());
        skinColor.setColorAt(0,QColor(255,255,255,0));
        skinColor.setColorAt(0.09,QColor(255,255,255,0));
        skinColor.setColorAt(0.1,QColor(255,255,255,200));
        skinColor.setColorAt(0.13,QColor(255,255,255,200));
        skinColor.setColorAt(0.14,QColor(255,255,255,80));
        skinColor.setColorAt(0.50,QColor(0,0,0,20));
        skinColor.setColorAt(0.75,QColor(0,0,0,10));
        skinColor.setColorAt(0.76,QColor(255,255,255,30));
        skinColor.setColorAt(0.95,QColor(255,255,255,150));
        skinColor.setColorAt(0.96,QColor(255,255,255,0));
        skinColor.setColorAt(1,QColor(255,255,255,0));
        painter->setPen(QPen(QColor(200,230,255,0)));
        painter->setBrush(skinColor);
        painter->drawRect(rect);

        /*****************刻度*********************/
        qreal baseX = bottomRect.right();
        qreal baseY = bottomRect.top();
        qreal len = bottomRect.width()/8;
        quint8 count = index.data(ChannelBarDiv).toUInt();
        qreal span = bottomRect.height()/count;
        painter->setPen(Qt::black);
        painter->setBrush(QBrush(QColor(0,0,0,0)));
        for(quint8 i=1; i<count; ++i){
            painter->drawLine(baseX - len, baseY + i*span, baseX, baseY + i*span);
        }

        /**************量程*****************/
        QRectF valRect(bottomRect);
        valRect.setHeight(span);
        font.setPixelSize(valRect.height()/2);
        painter->setFont(font);
        painter->setPen(QPen(Qt::black,1));
        painter->drawText(valRect,QString::number(rangeUpper,'f',4));
        valRect.moveBottom(bottomRect.bottom());
        painter->drawText(valRect,Qt::AlignBottom,QString::number(rangeDowner,'f',4));

        /**************测量值*********************/
        valRect.moveBottom(barRect.top());
        if(valRect.top() < baseY + span){
            valRect.moveTop(baseY + span);
        }else if(valRect.bottom() > bottomRect.bottom() - 2 * span){
            valRect.moveBottom(bottomRect.bottom() - 2 * span);
        }
        painter->drawText(valRect,Qt::AlignBottom|Qt::AlignHCenter,QString::number(mesureVal,'f',4));

        /*******************单位***********************/
        valRect.moveTop(valRect.bottom());
        valRect.setRight(baseX - len);
        //painter->setPen(QColor(100,100,100));
        painter->drawText(valRect,Qt::AlignRight|Qt::AlignTop,index.data(ChannelUnit).toString());

        /****************标记********************/
        font.setPixelSize(headRect.height()/2);
        painter->setFont(font);
        painter->setPen(QColor(100,100,100));
        painter->drawText(headRect,Qt::AlignCenter,index.data(ChannelTag).toString());

        /*****************擦除头尾连接**********************/
        painter->setBrush(QBrush(QColor(0,0,0,0)));
        painter->setPen(QPen(Qt::black,1));
        painter->drawRect(bottomRect);
        painter->eraseRect(QRectF(topRect.bottomLeft(), bottomRect.topRight()));

        /*********************按压效果*************************/
        if(option.state & QStyle::State_Sunken && option.state & QStyle::State_HasFocus){
            painter->setPen(QPen(QColor(0,0,255,100),3));
            painter->setBrush(QBrush(QColor(180,180,180,50)));
            painter->drawRoundedRect(rect,6,6);
        }

        painter->restore();
    }
}