Example #1
0
static void qt_palette_from_color(QPalette &pal, const QColor & button)
{
    QColor bg = button,
           btn = button,
           fg, base;
    int h, s, v;
    bg.getHsv(&h, &s, &v);
    if(v > 128) {
        fg   = Qt::black;
        base = Qt::white;
    } else {
        fg   = Qt::white;
        base = Qt::black;
    }
    //inactive and active are the same..
    pal.setColorGroup(QPalette::Active, QBrush(fg), QBrush(btn), QBrush(btn.lighter(150)),
                      QBrush(btn.darker()), QBrush(btn.darker(150)), QBrush(fg), QBrush(Qt::white),
                      QBrush(base), QBrush(bg));
    pal.setColorGroup(QPalette::Inactive, QBrush(fg), QBrush(btn), QBrush(btn.lighter(150)),
                      QBrush(btn.darker()), QBrush(btn.darker(150)), QBrush(fg), QBrush(Qt::white),
                      QBrush(base), QBrush(bg));
    pal.setColorGroup(QPalette::Disabled, QBrush(btn.darker()), QBrush(btn), QBrush(btn.lighter(150)),
                      QBrush(btn.darker()), QBrush(btn.darker(150)), QBrush(btn.darker()),
                      QBrush(Qt::white), QBrush(bg), QBrush(bg));
}
Example #2
0
static void qt_palette_from_color(QPalette &pal, const QColor &button)
{
    int h, s, v;
    button.getHsv(&h, &s, &v);
    // inactive and active are the same..
    const QBrush whiteBrush = QBrush(Qt::white);
    const QBrush blackBrush = QBrush(Qt::black);
    const QBrush baseBrush = v > 128 ? whiteBrush : blackBrush;
    const QBrush foregroundBrush = v > 128 ? blackBrush : whiteBrush;
    const QBrush buttonBrush = QBrush(button);
    const QBrush buttonBrushDark = QBrush(button.darker());
    const QBrush buttonBrushDark150 = QBrush(button.darker(150));
    const QBrush buttonBrushLight150 = QBrush(button.lighter(150));
    pal.setColorGroup(QPalette::Active, foregroundBrush, buttonBrush, buttonBrushLight150,
                      buttonBrushDark, buttonBrushDark150, foregroundBrush, whiteBrush,
                      baseBrush, buttonBrush);
    pal.setColorGroup(QPalette::Inactive, foregroundBrush, buttonBrush, buttonBrushLight150,
                      buttonBrushDark, buttonBrushDark150, foregroundBrush, whiteBrush,
                      baseBrush, buttonBrush);
    pal.setColorGroup(QPalette::Disabled, buttonBrushDark, buttonBrush, buttonBrushLight150,
                      buttonBrushDark, buttonBrushDark150, buttonBrushDark,
                      whiteBrush, buttonBrush, buttonBrush);
}
    void PlayerWidget::_setup_color_scheme(int profile)
    {
	QPalette p;
	QColor base, bright, light, mid, dark;

	switch(profile) {
        // case 0: // default
	case 1: // Blue
	    bright.setRgb(0xff, 0xff, 0xff, 0xff); // white
	    light.setRgb(0x76, 0xc6, 0xf5, 0xff); // light blue
	    mid.setRgb(68, 141, 189, 0xff); // average
	    dark.setRgb(0x12, 0x55, 0x85, 0xff); // dark blue
	    base = light;
	    break;
	default: // Yellow
	    bright.setRgb(0xff, 0xff, 0xff, 0xff); //white
	    light.setRgb(0xe5, 0xd7, 0x3a, 0xff); // yellow
	    mid.setRgb(114, 107, 29, 0xff); // average
	    dark.setRgb(0, 0, 0, 0xff); // black
	    base = light;
	}

	p.setColorGroup(QPalette::Active,
			dark, // Window Text
			light, // button
			light, // light
			dark, // dark
			mid, // mid
			dark, // text
			bright, // bright text
			base, // base
			light // window
	    );

	setPalette(p);
    }
Example #4
0
EXPORT void disableWidget(QWidget *w)
{
    QPalette pal = w->palette();
    pal.setColorGroup(
        QPalette::Disabled,
        pal.brush( QPalette::Active, QPalette::WindowText ),
        pal.brush( QPalette::Active, QPalette::Button ),
        pal.brush( QPalette::Active, QPalette::Light ),
        pal.brush( QPalette::Active, QPalette::Dark ),
        pal.brush( QPalette::Active, QPalette::Mid ),
        pal.brush( QPalette::Active, QPalette::Text ),
        pal.brush( QPalette::Active, QPalette::BrightText ),
        pal.brush( QPalette::Active, QPalette::Base ),
        pal.brush( QPalette::Active, QPalette::Window )
    );
    w->setPalette(pal);
    if (w->inherits("QLineEdit")){
        static_cast<QLineEdit*>(w)->setReadOnly(true);
    }else if (w->inherits("QTextEdit")){
        static_cast<QTextEdit*>(w)->setReadOnly(true);
    }else{
        w->setEnabled(false);
    }
}
Example #5
0
GameBoard::GameBoard(QWidget* parent)
:QWidget(parent)
{
  
  spacemap = new SpaceMap(this);
  spacemap->setGeometry(0, 0, 550, 550);
  
  planet_info = new Planet_Info(this);
  planet_info->setGeometry(0, 0, 80, 80);

  controlInfo = new QLabel("SDSDSDSDS");
  controlInfo->setGeometry(0, 0, 530, 10);

  endTurn = new QPushButton("End Turn");
  endTurn->setFixedSize(75, 25);
  //  endTurn->setGeometry(0, 0, 75, 25);
  
  shipNumber = new QLineEdit();
  shipNumber->setFixedSize(75, 25);
  shipNumber->setVisible(false);

  displayInfo = new QTextEdit();
  displayInfo->setFixedSize(630, 150);
  //  displayInfo->setGeometry(0, 0, 550, 50);
  
  // QPalette mainPal;
  //mainPal.setColor(QPalette::Window, Qt::black);
  //mainPal.setColor(QPalette::Text, Qt::white);
  //mainPal.setColor(QPalette::WindowText, Qt::white);
  //mainPal.setColor(backgroundRole(), Qt::black);
  QColor col(Qt::green);
  QPalette mainPal;
  mainPal.setColorGroup( QPalette::Active, Qt::white, Qt::black, col.light(), col.dark(), col, col.dark(75), col.dark(75), col.dark(), Qt::black );
  mainPal.setColorGroup( QPalette::Inactive, Qt::white, Qt::black, col.light(), col.dark(), col, col.dark(75), col.dark(75), col.dark(), Qt::black );
  mainPal.setColorGroup( QPalette::Disabled, Qt::white, Qt::black, col.light(), col.dark(), col, col.dark(75), col.dark(75), col.dark(), Qt::black );

  QColor colo(Qt::black);
  QPalette pal;
  pal.setColorGroup(QPalette::Active, Qt::white, Qt::black, col.light(), col.dark(), col, col.dark(75), colo.light(), colo.light(), Qt::darkGreen );

  this->setAutoFillBackground(true);
  spacemap->setAutoFillBackground(true);
  
  
  this->setPalette(mainPal);
  planet_info->setPalette(mainPal);
  spacemap->setPalette(pal);
  controlInfo->setPalette(mainPal);
  endTurn->setPalette(mainPal);
  displayInfo->setPalette(pal);
  shipNumber->setPalette(mainPal);
  

  this->setMouseTracking(true);
  
  QHBoxLayout* qhbLayout = new QHBoxLayout();
  qhbLayout->addWidget(controlInfo);
  qhbLayout->addWidget(shipNumber);
  qhbLayout->addWidget(endTurn);

  QVBoxLayout* qvbLayout = new QVBoxLayout();
  qvbLayout->addLayout(qhbLayout);
  qvbLayout->addWidget(spacemap);
  qvbLayout->addWidget(displayInfo);
  
  QHBoxLayout* qhbLayoutGeneral = new QHBoxLayout();
  qhbLayoutGeneral->addLayout(qvbLayout);
  qhbLayoutGeneral->addWidget(planet_info);
  
  //this->setFocusPolicy(Qt::StrongFocus);
  //shipNumber->setFocusPolicy(Qt::StrongFocus);
  this->setLayout(qhbLayoutGeneral);
  
  connect(spacemap, SIGNAL(overPlanet(Planet*)), this, SLOT(onDisplayPlanet(Planet*)));
  connect(endTurn, SIGNAL(pressed()), this, SLOT(onTurnButton()));
  connect(shipNumber, SIGNAL(returnPressed()), this, SLOT(onShipNumberSelect()));
}
Example #6
0
    QPalette create_default_palette()
    {
	QColor white( 0xff, 0xff, 0xff, 0xff );

	// Shades of navy...

	QColor navy_light(     0x00, 0x00, 0xa0, 0xff );
	QColor navy_mid_light( 0x00, 0x00, 0x90, 0xff );
	QColor navy(           0x00, 0x00, 0x70, 0xff );
	QColor navy_mid_dark(  0x00, 0x00, 0x90, 0xff );
	QColor navy_dark(      0x00, 0x00, 0xb0, 0xff );


	QColor windowText;
	QColor button;
	QColor light;
	QColor dark;
	QColor mid;
	QColor text;
	QColor bright_text;
	QColor base;
	QColor window;

	// Active colors                Qt's description
	windowText =  white;         // Text on top of 'window' color.
	button =      navy_mid_light;// Color for a button.
	light =       navy_light;    // lighter than 'button'
	dark =        dark;          // Darker than 'button'
	mid =         navy_mid_dark; // between button and dark
	text =        white;         // foreground color for 'base'
	bright_text = white;         // diff from windowText and contrasts with dark
	base =        navy_light;    // e.g. background for text entry
	window =      navy;          // Gen'l purpose background color

	// Get a head start...
	QPalette pal = QApplication::palette();

	pal.setColorGroup( QPalette::Active,
			   windowText,
			   button,
			   light,
			   dark,
			   mid,
			   text,
			   bright_text,
			   base,
			   window
	    );

	pal.setColorGroup( QPalette::Disabled,
			   windowText,
			   button,
			   light,
			   dark,
			   mid,
			   text,
			   bright_text,
			   base,
			   window
	    );

	pal.setColorGroup( QPalette::Inactive,
			   windowText,
			   button,
			   light,
			   dark,
			   mid,
			   text,
			   bright_text,
			   base,
			   window
	    );

	pal.setColorGroup( QPalette::Normal,
			   windowText,
			   button,
			   light,
			   dark,
			   mid,
			   text,
			   bright_text,
			   base,
			   window
	    );

	return pal;
    }