void MigrateDialog::ask()
{
    QPushButton *btn = cancelButton();
    QPoint p = btn->mapToGlobal(QPoint(0, 0));
    QRect rc(p.x(), p.y(), btn->width(), btn->height());
    BalloonMsg::ask(NULL, i18n("Cancel convert?"), this, SLOT(cancel(void*)), NULL, &rc);
}
示例#2
0
void ColorWidget::set_colors(const QList<QString>& colors)
{
    qDeleteAll(_buttons);
    _buttons.clear();

    _colors = colors;
    for (int i = 0; i < _colors.size(); ++i)
    {
        QPushButton* b = new QPushButton(this);
        b->setFixedWidth(b->height());
        b->setStyleSheet(QString("background-color: #%1; color: #ffffff;").arg(_colors[i]));
        _buttons << b;
        _layout->addWidget(b);
        _mapper->setMapping(b, i);
        connect(b, SIGNAL(clicked()), _mapper, SLOT(map()));
    }

    if (_colors.isEmpty())
    {
        button_pressed(-1);
    }
    else
    {
        button_pressed(0);
    }
}
示例#3
0
void VerticalTabWidget::setCurrentIndex(int index)
{
  int yPos = 25;

  for(unsigned i = 0; i < m_tabButtons.size(); i++)
  {
    QPushButton * button = m_tabButtons[i];

    button->move(0,yPos);

    yPos = yPos + button->height();

    QString imagePath;

    QString style;

    if (i == static_cast<unsigned>(index))
    {
      imagePath = m_selectedPixmaps[i];

      // Ignore clicks to the already active tab
      if(currentIndex != index){
        currentIndex = index;

        style.append("QPushButton { background-color: blue; background-image: url(\"");
        style.append(imagePath);
        style.append("\"); border: none; background-repeat: 0; }");

        button->setStyleSheet(style);

        currentIndex = index;

        emit tabSelected(m_ids[index]);
      }
    }
    else
    {
      if (button->isEnabled()){
        imagePath = m_unSelectedPixmaps[i];
        style.append("QPushButton { background-image: url(\"");
        style.append(imagePath);
        style.append("\"); border: none; background-color: red; background-repeat: 0; }");
      }
      else {
        imagePath = m_disabledPixmaps[i];
        style.append("QPushButton { background-image: url(\"");
        style.append(imagePath);
        style.append("\"); border: none; background-color: red; background-repeat: 0; }");
      }

      button->setStyleSheet(style);
    }
  }
}
示例#4
0
void MyWidget::resizeEvent( QResizeEvent * )
{
    int startx      = 10;
    int starty      = quit->y() + quit->height() + 10;
    int valueWidth  = (width() - startx - 10 - 3*5)/4;
    int valueHeight = (height() - starty - 10 - 3*5)/4;
    for( int i = 0 ; i < 16 ; i++ )
	value[i]->setGeometry( startx + (i%4)*(5+valueWidth),
			       starty + (i/4)*(5+valueHeight),
                               valueWidth, valueHeight );
}
示例#5
0
void KNoteBook::paintEvent(QPaintEvent *)
{
  //debug("KNoteBook::paintEvent");
  // Check to see if there are any buttons.
  QPushButton *tmp = 0L;
  int w = width(), h = height(), s = 2;
  int tw = pnote->tabbar->width();
  int boffs = 4, toffs = pnote->tabbar->height() + 1;
  if( pnote->ok && pnote->ok->isVisible() )
    tmp = pnote->ok;
  else if(pnote->cancel && pnote->cancel->isVisible())
    tmp = pnote->cancel;
  else if(pnote->def && pnote->def->isVisible())
    tmp = pnote->def;
  else if(pnote->help && pnote->help->isVisible())
    tmp = pnote->help;
  if(tmp)
    boffs = tmp->height() + 4;

  // start painting widget
  QPainter paint;
  paint.begin( this );
  QPen pen( white, 1 );
  paint.setPen( pen );

  // left outer
  paint.drawLine( s, h-(boffs), s, toffs-1);

  // top outer
  paint.drawLine( tw+s , toffs, w-s, toffs);
  
  // right inner
  paint.drawLine( w-(s*3) , toffs+(s*2)+1, w-(s*3), h-(boffs+(s+1)));

  // bottom inner
  paint.drawLine( (s*3)+1 , h-(boffs+(s*2)-1), w-(s*3), h-(boffs+(s*2)-1));

  pen.setColor( black );
  paint.setPen( pen );

  // right outer
  paint.drawLine( w-s , toffs+1, w-s, h-(boffs));

  // bottom outer
  paint.drawLine( w-s , h-(boffs), s+1, h-(boffs));

  // left inner
  paint.drawLine( s*3 , h-(boffs+(s+1)), s*3, toffs+((s*2)+1) );

  // top inner
  paint.drawLine( (s*3)+1, toffs+(s*2), w-(s*3), toffs+(s*2));

  paint.end();
}
示例#6
0
void qmainstackwidget::set_editsearch()
{
	edit_search = new QLineEdit(this);
	edit_search->setGeometry(0, 110, 283, 25);
	edit_search->setFont(QFont("Timers", 10, QFont::StyleOblique));
	edit_search->setStyleSheet("QLineEdit{border: 2px solid rgb(22, 154, 218);padding: 0 8px;background: rgb(21, 127, 178);selection-background-color: darkgray;color:rgb(240, 255, 255);}");
	QPushButton *search = new QPushButton(this);
	search->setFlat(true);
	QPixmap pix;
	pix.load("search.jpg");
	pix = pix.scaled(18, 18);
	QIcon icon_search(pix);
	search->setIcon(icon_search);
	search->setFixedSize(18, 18);
	search->move(edit_search->width() - search->width() - 2, (edit_search->height() - search->height()) / 2);
	search->setGeometry(263, 115, search->width(), search->height());
	search->setStyleSheet("QPushButton{ border-image:url(search.png); }"
		"QPushButton:press{border-image:url(search_press.png);}"
		"QPushButton:hover{border-image:url(search_hover.png);}");
	search->setCursor(QCursor(Qt::PointingHandCursor));
}
ApplicationsMenuApplet::ApplicationsMenuApplet(void)
  : Applet()
{
  if(QIcon::themeName() == "hicolor" ||
     QIcon::themeName().isEmpty())
  {
    QIcon::setThemeName("nuvola"); // kde
    if(QIcon::fromTheme("start-here").isNull())
      QIcon::setThemeName("gnome"); // gnome
    if(QIcon::fromTheme("start-here").isNull())
      QIcon::setThemeName("hicolor"); // default
  }

  qDebug() << "using theme:" << QIcon::themeName();

//  QIcon::setThemeSearchPaths(CXDGDirs::iconDirectories());
  QPushButton* button = new QPushButton();
  button->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
  button->setMenu(m_menu = new QMenu());
  button->setText("Applications");
  button->setIcon(QIcon::fromTheme("start-here").pixmap(button->height(), button->height()));
  setWidget(button);
}
示例#8
0
void KNoteBook::resizeEvent(QResizeEvent *)
{
  //debug("KNote, resizing");

  pnote->tabbar->setGeometry( 2, 2, width()-3, pnote->tabbar->sizeHint().height());

  // Check to see if there are any buttons.
  QPushButton *tmp = 0L;
  int x = 8, y = pnote->tabbar->height() + 7;
  int cx = width() - 14, cy = height()-(pnote->tabbar->height()+14);
  if( pnote->ok && pnote->ok->isVisible() )
    tmp = pnote->ok;
  else if(pnote->cancel && pnote->cancel->isVisible())
    tmp = pnote->cancel;
  else if(pnote->def && pnote->def->isVisible())
    tmp = pnote->def;
  else if(pnote->help && pnote->help->isVisible())
    tmp = pnote->help;
  if(tmp)
    cy -= (tmp->height());

  if(pnote->currentwiz)
    pnote->currentwiz->setGeometry( x, y, cx, cy );

  int offs = 2;
  if(pnote->ok && pnote->ok->isVisible())
  {
    pnote->ok->setGeometry(offs, height()-(pnote->ok->height()+2),
                           pnote->ok->width(), pnote->ok->height());
    offs += 5 + pnote->ok->width();
  }
  if(pnote->cancel && pnote->cancel->isVisible())
  {
    pnote->cancel->setGeometry(offs, height()-(pnote->cancel->height()+2),
                           pnote->cancel->width(), pnote->cancel->height());
    offs += 5 + pnote->cancel->width();
  }
  if(pnote->def && pnote->def->isVisible())
    pnote->def->setGeometry(offs, height()-(pnote->def->height()+2),
                           pnote->def->width(), pnote->def->height());
  if(pnote->help && pnote->help->isVisible())
    pnote->help->setGeometry(width()-(pnote->help->width()+1),
                             height()-(pnote->help->height()+2),
                             pnote->help->width(), pnote->help->height());

  //debug("KNote, resize - done");
}
示例#9
0
VPiano::VPiano() : QMainWindow()
{
	QWidget *central = new QWidget(this);
	QVBoxLayout *vb = new QVBoxLayout;
	QHBoxLayout *octaves = new QHBoxLayout;

	QSignalMapper *octaveSignalMapper = new QSignalMapper(this);

	for(int i = 0; i < 9; i++)
	{
		QString title;
		title.setNum(i);
		QPushButton *o = new QPushButton(title, central);
		o->setFixedSize(fontMetrics().width(title)*4, o->height());
		QString shortcut;
		shortcut.setNum(i+1);
		o->setShortcut(QKeySequence(QString("F") + shortcut));
		octaves->addWidget(o);

		connect(o, SIGNAL(clicked()), octaveSignalMapper, SLOT(map()));
		octaveSignalMapper->setMapping(o, i);
	}

	OctaveRangeWidget *octRange = new OctaveRangeWidget(central);
	octaves->addWidget(octRange);

	QSlider *velocity = new QSlider(Qt::Horizontal, central);
	velocity->setMinimum(1);
	velocity->setMaximum(127);
	velocity->setValue(96); // TODO: read prev value from config
	velocity->setToolTip(tr("Velocity"));
	octaves->addWidget(velocity);

	QSpinBox *channel = new QSpinBox(central);
	channel->setPrefix(tr("Ch ", "Midi Channel number"));
	channel->setMinimum(0);
	channel->setMaximum(127);
	channel->setValue(0); // TODO: read prev value from config
	channel->setToolTip(tr("Select MIDI channel number to send messages to"));
	octaves->addWidget(channel);

	vb->addLayout(octaves);

	QHBoxLayout *keyarea = new QHBoxLayout;

	KeyboardWidget *kw = new KeyboardWidget(central);
	keyarea->addWidget(kw);

	QVBoxLayout *rightside = new QVBoxLayout;

	QSlider *pitchWheel = new QSlider(Qt::Vertical, central);
	pitchWheel->setMinimum(-64);
	pitchWheel->setMaximum(63);
	pitchWheel->setValue(0); // TODO: read prev value from config
	pitchWheel->setToolTip(tr("Pitch wheel"));

	rightside->addWidget(pitchWheel);

	QCheckBox *porta = new QCheckBox(central);
	porta->setToolTip(tr("Enable portamento"));

	rightside->addWidget(porta);
	keyarea->addLayout(rightside);

	vb->addLayout(keyarea);

	central->setLayout(vb);
	setCentralWidget(central);
	setWindowTitle(tr("Virtual MIDI keyboard"));

	// TODO: connect pitchWheel
	connect(octaveSignalMapper, SIGNAL(mapped(int)), kw, SLOT(octaveSelected(int)));
	connect(channel, SIGNAL(valueChanged(int)), kw, SLOT(midiChannelSelected(int)));
	connect(kw, SIGNAL(highlightOctaves(int,int)), octRange, SLOT(highlightOctaves(int,int)));

	kw->octaveSelected(0); // TODO: use value read from config
}