Ejemplo n.º 1
0
/**
 * Constructor for the main window
 */
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) {
    ui->setupUi(this);

    //Resize the image for the Mission Execution button
    QPixmap pixmap(":/res/longButtons/Mission_Execution_Button_Type_2.png");
    QIcon ButtonIcon(pixmap);
    ui->pushButton_8->setIcon(ButtonIcon);
    ui->pushButton_8->setIconSize(pixmap.rect().size()/13);

    //Resize the image for the Mission Planning button
    QPixmap pixmap2(":/res/longButtons/Mission_Planning_Button_Type_2.png");
    QIcon ButtonIcon2(pixmap2);
    ui->pushButton_9->setIcon(ButtonIcon2);
    ui->pushButton_9->setIconSize(pixmap2.rect().size()/13);

    //Resize the image for the Mission Recap button
    QPixmap pixmap3(":/res/longButtons/Mission_Recap_Button_Type_2.png");
    QIcon ButtonIcon3(pixmap3);
    ui->pushButton_7->setIcon(ButtonIcon3);
    ui->pushButton_7->setIconSize(pixmap3.rect().size()/13);

    //Resize the image for the Tutorial button
    QPixmap pixmap4(":/res/longButtons/Tutorial_Button_Type_2.png");
    QIcon ButtonIcon4(pixmap4);
    ui->pushButton_6->setIcon(ButtonIcon4);
    ui->pushButton_6->setIconSize(pixmap4.rect().size()/13);
}
QPixmap MainWindow::distortImg(QPixmap pixmap)
{
    QImage pixmapImg = pixmap.toImage();
    QPixmap pixmap2(pixmap.width(),pixmap.height());
    QPainter painter2(&pixmap2);

    // Distort text
    for(int x = 0; x < pixmap.width(); x++){
        for(int y = 0; y < pixmap.height(); y++){
            qsrand(x);
            float rand1 = qrand()%5;
            qsrand(y);
            float rand2 = qrand()%5;
            float sinx = sin(x/10+1)*5;
            float siny = qSin(y/10)*5;
            int newx = x+rand1+sinx;
            int newy = y+rand2+siny;
            if(newx < pixmap.width() && newy < pixmap.height()){
                if(rand1+rand2 > 1) {
                    painter2.setPen(pixmapImg.pixel(newx,newy));
                } else {
                    painter2.setPen(Qt::green);
                    painter2.drawRect(x,y,10,10);
                }
                painter2.drawRect(x,y,1,1);

            }
        }
    }

    ui->label->setPixmap(pixmap2);

    return pixmap2;

}
Ejemplo n.º 3
0
void FreeRegionGrabber::grabRect()
{
    QPolygon pol = selection;
    if ( !pol.isEmpty() )
    {
	grabbing = true;

        int xOffset = pixmap.rect().x() - pol.boundingRect().x();
        int yOffset = pixmap.rect().y() - pol.boundingRect().y();
        QPolygon translatedPol = pol.translated(xOffset, yOffset);

        QPixmap pixmap2(pol.boundingRect().size());
        pixmap2.fill(Qt::transparent);

        QPainter pt;
        pt.begin(&pixmap2);
        if (pt.paintEngine()->hasFeature(QPaintEngine::PorterDuff)) {
            pt.setRenderHints(QPainter::Antialiasing | QPainter::HighQualityAntialiasing | QPainter::SmoothPixmapTransform, true);
            pt.setBrush(Qt::black);
            pt.setPen(QPen(QBrush(Qt::black), 0.5));
            pt.drawPolygon(translatedPol);
            pt.setCompositionMode(QPainter::CompositionMode_SourceIn);
        } else {
            pt.setClipRegion(QRegion(translatedPol));
            pt.setCompositionMode(QPainter::CompositionMode_Source);
        }

        pt.drawPixmap(pixmap2.rect(), pixmap, pol.boundingRect());
        pt.end();

        emit freeRegionUpdated(pol);
        emit freeRegionGrabbed(pixmap2);
    }
}
Ejemplo n.º 4
0
LineEdit::LineEdit(QWidget *parent)
  : QLineEdit(parent)
{
  searchButton = new QToolButton(this);
  QPixmap pixmap1(":/lineeditimages/search.png");
  searchButton->setIcon(QIcon(pixmap1));
  searchButton->setIconSize(pixmap1.size());
  searchButton->setCursor(Qt::ArrowCursor);
  searchButton->setStyleSheet("QToolButton { border: none; padding: 0px; }");
  clearButton = new QToolButton(this);
  QPixmap pixmap2(":/lineeditimages/clear_left.png");
  clearButton->setIcon(QIcon(pixmap2));
  clearButton->setIconSize(pixmap2.size());
  clearButton->setCursor(Qt::ArrowCursor);
  clearButton->setStyleSheet("QToolButton { border: none; padding: 0px; }");
  clearButton->setToolTip(tr("Clear the text"));
  clearButton->hide();
  connect(clearButton, SIGNAL(clicked()), this, SLOT(clear()));
  connect(this, SIGNAL(textChanged(const QString&)), this, SLOT(updateCloseButton(const QString&)));
  int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
  setStyleSheet(QString("QLineEdit { padding-right: %1px; padding-left: %2px; border-radius: 10px; }").arg(clearButton->sizeHint().width() + frameWidth + 1).arg(clearButton->sizeHint().width() + frameWidth + 1));
#ifdef Q_WS_MAC
  setAttribute(Qt::WA_MacShowFocusRect, 0);
#endif
  QSize msz = minimumSizeHint();
  setMinimumSize(qMax(msz.width(), clearButton->sizeHint().width() + searchButton->sizeHint().width() + frameWidth * 2 + 2),
                 qMax(msz.height(), clearButton->sizeHint().height() + frameWidth * 2 + 2));
}
Ejemplo n.º 5
0
void Single_Player::Create()
{
    QPixmap pixmap1("Black_Circle");
    QPixmap pixmap2("white-circle");
    QIcon Icon1(pixmap1);
    QIcon Icon2(pixmap2);
    for(int i=0;i<8;i++)
     for(int j=0;j<8;j++)
     {
         array[i][j]=0;
         button[i][j].setParent(this);
         button[i][j].resize(30,30);
         button[i][j].setStyleSheet("background-color:grey");
         button[i][j].move(30*j+10+30,30*i+10);
         button[i][j].show();
     }
    array[3][3]=White;
    array[3][4]=Black;
    array[4][4]=White;
    array[4][3]=Black;
    for(int i=0;i<8;i++)
     for(int j=0;j<8;j++)
     {
         if(array[i][j]==Black)
         {
             button[i][j].setIcon(Icon1);
             button[i][j].setIconSize(QSize(20,20));
         }
         if(array[i][j]==White)
        {
             button[i][j].setIcon(Icon2);
             button[i][j].setIconSize(QSize(20,20));
        }
     }
}
Ejemplo n.º 6
0
Archivo: main.cpp Proyecto: ifhw/study
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    // 创建标准项模型
    QStandardItemModel model;
    // 获取模型的根项(Root Item),根项是不可见的
    QStandardItem *parentItem = model.invisibleRootItem();

    // 创建标准项item0,并设置显示文本,图标和工具提示
    QStandardItem *item0 = new QStandardItem;
    item0->setText("A");
    QPixmap pixmap0(50,50);
    pixmap0.fill("red");
    item0->setIcon(QIcon(pixmap0));
    item0->setToolTip("indexA");
    // 将创建的标准项作为根项的子项
    parentItem->appendRow(item0);
    // 将创建的标准项作为新的父项
    parentItem = item0;

    // 创建新的标准项,它将作为item0的子项
    QStandardItem *item1 = new QStandardItem;
    item1->setText("B");
    QPixmap pixmap1(50,50);
    pixmap1.fill("blue");
    item1->setIcon(QIcon(pixmap1));
    item1->setToolTip("indexB");
    parentItem->appendRow(item1);

    // 创建新的标准项,这里使用了另一种方法来设置文本、图标和工具提示
    QStandardItem *item2 = new QStandardItem;
    QPixmap pixmap2(50,50);
    pixmap2.fill("green");
    item2->setData("C", Qt::EditRole);
    item2->setData("indexC", Qt::ToolTipRole);
    item2->setData(QIcon(pixmap2), Qt::DecorationRole);
    parentItem->appendRow(item2);

    // 在树视图中显示模型
    QTreeView view;
    view.setModel(&model);
    view.show();

    // 获取item0的索引并输出item0的子项数目,然后输出了item1的显示文本和工具提示
    QModelIndex indexA = model.index(0, 0, QModelIndex());
    qDebug() << "indexA row count: " << model.rowCount(indexA);
    QModelIndex indexB = model.index(0, 0, indexA);
    qDebug() << "indexB text: " << model.data(indexB, Qt::EditRole).toString();
    qDebug() << "indexB toolTip: " << model.data(indexB, Qt::ToolTipRole).toString();

    return app.exec();
}
Ejemplo n.º 7
0
void StegoSaurus::resizeEvent(QResizeEvent * event)  
{
	//Set the label image
	if(ui.txtDryImg->text().isEmpty())
		return;
	QPixmap pixmap(ui.txtDryImg->text());
	pixmap= pixmap.scaledToHeight(ui.lblDryImgDisplay->height());
	ui.lblDryImgDisplay->setPixmap(pixmap);

	QPixmap pixmap2(ui.txtWetImg->text());
	pixmap2= pixmap2.scaledToHeight(ui.lblWetImgDisplay->height());
	ui.lblWetImgDisplay->setPixmap(pixmap2);
}
Ejemplo n.º 8
0
//This functions adds images to the selction button
void MainWindow::setupImageButtons()
{
    //arduino image
    QPixmap pixmap(":/images/arduino.png");
    QIcon ButtonIcon(pixmap);
    ui->arduinoButton->setIcon(ButtonIcon);
    ui->arduinoButton->setIconSize((QSize(80,80)));

    //rasb pi image
    QPixmap pixmap2(":/images/rasbpi.png");
    QIcon ButtonIcon2(pixmap2);
    ui->raspButton->setIcon(ButtonIcon2);
    ui->raspButton->setIconSize((QSize(80,80)));
}
/**
* \author Jules Gorny - ALCoV team, ISIT, UMR 6284 UdA – CNRS
**/
AskSomething::AskSomething(QString windowsTitle, QString labelText, bool pwType, bool browseNeed, QIcon icon, QWidget *parent) : QDialog(parent)
{
	this->setWindowIcon(icon);
	this->setWindowTitle(windowsTitle);

    m_answer = new QLineEdit(this);
	if( pwType )
		m_answer->setEchoMode(QLineEdit::Password);
	m_answerLbl = new QLabel(this);
	m_answerLbl->setText(labelText);
	connect(m_answer, SIGNAL(textChanged(QString)), this, SLOT(slot_textChanged(QString)));
	
    validateButton = new QPushButton(tr("Validate"));
	validateButton->setDefault( true );
	validateButton->setEnabled( false );

	QSpacerItem *Spacer1 = new QSpacerItem(10, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
	QSpacerItem *Spacer2 = new QSpacerItem(10, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
		
	QPushButton *browseButton;
	if( browseNeed )
	{
		browseButton = new QPushButton();
		browseButton->setGeometry(browseButton->x(), browseButton->y(), 40, 28);
		QPixmap pixmap2(Config::IMAGES_FOLDER + "browse.png");
		QIcon ButtonIcon2(pixmap2);	
		browseButton->setIcon(ButtonIcon2);
		browseButton->setIconSize(QSize(28,28));
		browseButton->setFlat(true);
		connect(browseButton, SIGNAL(clicked()), this, SLOT(slot_browse()));
	}

    connect(validateButton, SIGNAL(clicked()), this, SLOT(accept()));
	
    QVBoxLayout *Vlt = new QVBoxLayout;
    QHBoxLayout *Hlt = new QHBoxLayout;
    QHBoxLayout *HltLbl = new QHBoxLayout;
    Vlt->addWidget(m_answerLbl);
    HltLbl->addWidget(m_answer);
	if( browseNeed )
		HltLbl->addWidget(browseButton);
	Hlt->addItem(Spacer1);
    Hlt->addWidget(validateButton);
    Hlt->addItem(Spacer2);
    Vlt->addLayout(HltLbl);
    Vlt->addLayout(Hlt);

    setLayout(Vlt);
}
Ejemplo n.º 10
0
int main(int argc, char **argv) {
  QApplication app(argc, argv);

  QStandardItemModel model;
  QStandardItem *parentItem = model.invisibleRootItem();

  QStandardItem *item0 = new QStandardItem;
  item0->setText("A");
  QPixmap pixmap0(50, 50);
  pixmap0.fill("red");
  item0->setIcon(QIcon(pixmap0));
  item0->setToolTip("indexA");
  parentItem->appendRow(item0);

  parentItem = item0;
  QStandardItem *item1 = new QStandardItem;
  item1->setText("B");
  QPixmap pixmap1(50, 50);
  pixmap1.fill("blue");
  item1->setIcon(QIcon(pixmap1));
  item1->setToolTip("indexB");
  parentItem->appendRow(item1);

  QStandardItem *item2 = new QStandardItem;
  QPixmap pixmap2(50, 50);
  pixmap2.fill("green");
  item2->setData("C", Qt::EditRole);
  item2->setData("indexC", Qt::ToolTipRole);
  item2->setData(QIcon(pixmap2), Qt::DecorationRole);
  parentItem->appendRow(item2);

  QTreeView view;
  view.setModel(&model);
  view.show();

  QModelIndex indexA = model.index(0, 0, QModelIndex());
  qDebug() << "indexA row count: " << model.rowCount(indexA);
  QModelIndex indexB = model.index(0, 0, indexA);
  qDebug() << "indexB text: " << model.data(indexB, Qt::EditRole).toString();
  qDebug() << "indexB toolTip: " << model.data(indexB, Qt::ToolTipRole)
                                        .toString();

  return app.exec();
}
Ejemplo n.º 11
0
Principal::Principal(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::Principal)
{
    ui->setupUi(this);
    r = -1;
    QPixmap pixmap1("icon/add.png");
    QPixmap pixmap2("icon/conf.png");
    QPixmap pixmap3("icon/del.png");
    QPixmap pixmap4("icon/Sair.png");
    QPixmap pixmap5("icon/pasta.png");
    QPixmap pixmap6("icon/detalhe.png");
    QIcon ButtonIcon(pixmap1);
    QIcon ButtonIcon1(pixmap2);
    QIcon ButtonIcon2(pixmap3);
    QIcon ButtonIcon3(pixmap4);
    QIcon ButtonIcon4(pixmap5);
    QIcon ButtonIcon5(pixmap6);
    ui->add_3->setIcon(ButtonIcon);
    ui->add_3->setIconSize(pixmap1.rect().size());
    ui->add_3->setStyleSheet(styleSheet().append(QString("border-image:url(icon/1.png);")));
    ui->alterar->setIcon(ButtonIcon1);
    ui->alterar->setIconSize(pixmap1.rect().size());
    ui->alterar->setStyleSheet(styleSheet().append(QString("border-image:url(icon/1.png);")));
    ui->deletar->setIcon(ButtonIcon2);
    ui->deletar->setIconSize(pixmap1.rect().size());
    ui->deletar->setStyleSheet(styleSheet().append(QString("border-image:url(icon/1.png);")));
    ui->sair->setIcon(ButtonIcon3);
    ui->sair->setIconSize(pixmap1.rect().size());
    ui->sair->setStyleSheet(styleSheet().append(QString("border-image:url(icon/1.png);")));
    ui->pasta->setIcon(ButtonIcon4);
    ui->pasta->setIconSize(pixmap1.rect().size());
    ui->pasta->setStyleSheet(styleSheet().append(QString("border-image:url(icon/1.png);")));
    AnimeDao a;
    if(a.getStatus() == true){
        ui->statusBar->showMessage("Quantidade de Animes Cadastrados: "+QString::number(a.getLista().length()));
    }
    preencheTabela(a.getLista());
    QPixmap pixmap9("icon/icon.png");
    this->setWindowIcon(pixmap9);

}
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    QObject::connect(ui->Start, SIGNAL(clicked()),this,SLOT(on_Start_clicked()));
    connect(ui->Off, SIGNAL(clicked()), this, SLOT(close()));

    QPixmap pixmap("//home//student//logowat.png");

    ui->LogoWat->setPixmap(pixmap);
    ui->LogoWat->setMask(pixmap.mask());
    ui->LogoWat->show();

    QPixmap pixmap2("//home//student//logoitk.png");
    ui->LogoItk->setPixmap(pixmap2);
    ui->LogoItk->setMask(pixmap2.mask());
    ui->LogoItk->show();
   // ui->Qautor->setC
}
Ejemplo n.º 13
0
void TToolBox::createIcon()
{
    QPolygon m_pArrow(3);
    QPixmap pixmap (22,22);
    
    m_pArrow.setPoint(0, 0, 0);
    m_pArrow.setPoint(1, 10, 5);
    m_pArrow.setPoint(2, 0, 10);
    
    QPainter p(&pixmap);
    
    p.fillRect(pixmap.rect(), palette().background());
    p.setBrush(palette().foreground());
    p.translate(pixmap.width()/3, 5);
    p.drawConvexPolygon(m_pArrow);

    p.end();
    
    m_icon.addPixmap(pixmap, QIcon::Normal, QIcon::Off);
    
    ///////////
    
    QPixmap pixmap2(22,22);
    
    m_pArrow.setPoint(0, 0, 0);
    m_pArrow.setPoint(1, 5, 10);
    m_pArrow.setPoint(2, 10, 0);
    
    QPainter p2(&pixmap2);
    
    p2.fillRect(pixmap2.rect(), palette().background());
    p2.setBrush(palette().foreground());
    p2.translate(pixmap2.width()/3, 5);
    p2.drawConvexPolygon(m_pArrow);

    p2.end();
    
    m_icon.addPixmap(pixmap2, QIcon::Normal, QIcon::On);
}
Ejemplo n.º 14
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    QPixmap pixmap("://imagenes/adim.ico");
    QIcon ButtonIcon(pixmap);
    ui->pushButton->setIcon(ButtonIcon);
    ui->pushButton->setIconSize(pixmap.rect().size());

    QPixmap pixmap2("://imagenes/users.ico");
    QIcon ButtonIcon2(pixmap2);
    ui->pushButton_2->setIcon(ButtonIcon2);
    ui->pushButton_2->setIconSize(pixmap2.rect().size());

    QPixmap pixmap3("://imagenes/logout.ico");
    QIcon ButtonIcon3(pixmap3);
    ui->pushButton_3->setIcon(ButtonIcon3);
    ui->pushButton_3->setIconSize(pixmap3.rect().size());

    //this->miGrafo;

}
Ejemplo n.º 15
0
//This function clears the buttons's background and set them again
void Single_Player::Modify()
{
    QPixmap pixmap("None");
    QIcon icon(pixmap);
    for(int i=0;i<8;i++)
     for(int j=0;j<8;j++)
     {
         if(array[i][j]!=White && array[i][j]!=Black)
         {
         button[i][j].setIcon(icon);
         button[i][j].setIconSize(QSize(20,20));
     }
 }
    if(turn==white)
        ui->label->setText("White");
    if(turn==black)
        ui->label->setText("Black");
      QPixmap pixmap1("Black_Circle");
      QPixmap pixmap2("white-circle");
      QIcon Icon1(pixmap1);
      QIcon Icon2(pixmap2);
      for(int i=0;i<=7;i++)
          for(int j=0;j<=7;j++)
          {
              if(array[i][j]==Black)
           {
                  button[i][j].setIcon(Icon1);
                  button[i][j].setIconSize(QSize(20,20));
              }
              if(array[i][j]==White)
              {
                  button[i][j].setIcon(Icon2);
                  button[i][j].setIconSize(QSize(20,20));
              }
          }
      }
Ejemplo n.º 16
0
ImageWindows::ImageWindows(QImage image, QString name, QWidget *parent) :
    QWidget(parent),
    ui(new Ui::ImageWindows)
{
    ui->setupUi(this);

    imageLbl=new qlabel_image();

    //Signal émit par la class qlabel_image pour la lecture en dynamique de la position des pixels
    connect(imageLbl, SIGNAL(Mouse_Pos()), this, SLOT(Mouse_current_pos()));
    connect(imageLbl, SIGNAL(Mouse_Pressed()), this, SLOT(Mouse_pressed()));
    connect(imageLbl, SIGNAL(Mouse_ClickLeft()), this, SLOT(MouseClickLeft()));
    connect(imageLbl, SIGNAL(Mouse_ReleasePos()), this, SLOT(Mouse_release_pos()));
    imageLbl->setMouseTracking(true);

   // setFixedHeight(image.height());
   // setFixedWidth(image.width());
    image_ihm = image;
    m_coeffZoom=1;
    affichageImage(image_ihm,m_coeffZoom,ui->scrollArea_Image);
     /*QLabel *imageLabel = new QLabel;
     imageLabel->setBackgroundRole(QPalette::Base);
     imageLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
     imageLabel->setScaledContents(true);
     imageLabel -> setPixmap(QPixmap::fromImage(image));
     ui->scrollArea_Image->setBackgroundRole(QPalette::Dark);
     ui->scrollArea_Image->setWidget(imageLabel);

*/
    //ui ->label_Image -> setPixmap(QPixmap::fromImage(*image));
    QString txt =  QString::number(image.width())  + " x " + QString::number(image.height());
    ui->lbl_imageSize->setText(txt);

    if(image_ihm.isGrayscale())
        ui->lbl_imageDepth->setText("niveau de gris");
    else
        ui->lbl_imageDepth->setText("couleur");




    /*int index = pathImage.lastIndexOf("/");
    std::cout << "index : " << index;
    m_StrImageName = pathImage.left(index);*/
    m_StrImageName = name;
    setWindowTitle(m_StrImageName);


    QPixmap pixmap("actions/document-save-3.ico");
    QIcon ButtonIcon(pixmap);
    ui->pushB_Save->setIcon(ButtonIcon);
    QSize size = pixmap.rect().size();
    size.setHeight(size.height() -10);
    size.setWidth(size.width() -10);
    ui->pushB_Save->setIconSize(size);


    QPixmap pixmap2("actions/zoom-in-3.ico");
    QIcon ButtonIcon2(pixmap2);
    ui->pushB_ZoomIn->setIcon(ButtonIcon2);
    QSize size1 = pixmap2.rect().size();
    size1.setHeight(size1.height() -10);
    size1.setWidth(size1.width() -10);
    ui->pushB_ZoomIn->setIconSize(size1);


    QPixmap pixmap3("actions/zoom-out-3.ico");
    QIcon ButtonIcon3(pixmap3);
    ui->pushB_ZoomOut->setIcon(ButtonIcon3);
    QSize size2 = pixmap3.rect().size();
    size2.setHeight(size2.height() -10);
    size2.setWidth(size2.width() -10);
    ui->pushB_ZoomOut->setIconSize(size2);



}
Ejemplo n.º 17
0
CollectionWidget::CollectionWidget( QWidget* parent ):
        QWidget(parent)
{
    p = new CollectionWidgetPrivate;

    QPushButton *pushRandom =new QPushButton();
    QPixmap pixmap2(":shuffle.png");
    pushRandom->setIcon(QIcon(pixmap2));
    pushRandom->setIconSize(QSize(27,27));
    pushRandom->setMaximumWidth(40);
    pushRandom->setStyleSheet("QPushButton { border: none; padding: 0px; margin-left: 10px;max-height: 20px; margin-right: 4px;}");
    pushRandom->setToolTip(tr( "Random Tracks" ));

    p->searchEdit = new SearchEdit();
    p->searchEdit->setToolTip(tr( "Enter space-separated terms to filter collection" ));

    QVBoxLayout *mainLayout = new QVBoxLayout;
    QWidget *headWidget = new QWidget(this);
    headWidget->setMaximumHeight(38);

    QHBoxLayout *headWidgetLayout = new QHBoxLayout;
    headWidgetLayout->setMargin(0);
    headWidgetLayout->setSpacing(1);

    headWidgetLayout->addSpacerItem(new QSpacerItem(10, 0, QSizePolicy::Fixed, QSizePolicy::Expanding));
    headWidgetLayout->addWidget(p->searchEdit);
    headWidgetLayout->addWidget(pushRandom);
    headWidget->setLayout(headWidgetLayout);

    p->updater = new CollectionUpdater();

    p->timer = new QTimer( this );
    p->timer->setInterval(300);
    p->timer->setSingleShot(true);

    p->collectiontree = new CollectionTree(this);
    p->modeSelect = new ModeSelector(p->collectiontree);

    headWidget->raise();
    mainLayout->addWidget(headWidget);

    mainLayout->setMargin(0);
    mainLayout->setSpacing(0);
 
    connect(pushRandom,SIGNAL(clicked()),
            p->collectiontree,SLOT(triggerRandomSelection()) );

    connect ( p->modeSelect , SIGNAL(modeChanged(ModeSelector::modeType)),
            this, SLOT(onModeSelected(ModeSelector::modeType)));

    connect( p->searchEdit, SIGNAL( textChanged( const QString& ) ),
             this,           SLOT( onSetFilterTimeout() ) );

    connect( p->searchEdit, SIGNAL( trackDropped(QString)),
             this,           SIGNAL( trackDropped(QString)) );

    connect( p->collectiontree, SIGNAL(selectionChanged(QList<Track*>)),
             this,           SIGNAL(selectionChanged(QList<Track*>)));

    connect( p->collectiontree, SIGNAL(wantLoad(QList<Track*>,QString)),
             this,           SIGNAL(wantLoad(QList<Track*>,QString)));

    connect( p->updater, SIGNAL(changesDone()), p->collectiontree, SLOT(createTrunk()));
    connect( p->collectiontree, SIGNAL(rescan()), p->updater, SLOT(scan()));

    connect( p->timer, SIGNAL(timeout()), SLOT(onSetFilter())  );

    setFocusProxy( p->collectiontree ); //default object to get focus
    setMaximumWidth(400);

    //Pogressbar for re-read collection
    p->progress = new ProgressBar(this);
    p->progress->setValue(0);
    p->progress->setStyleSheet("* { margin-bottom: 3px; }");

    mainLayout->addWidget(p->collectiontree);


    // Read config values
    QSettings settings;
    p->modeSelect->setMode( static_cast<ModeSelector::modeType>(settings.value("TreeMode",ModeSelector::MODENONE).toUInt()));


    p->collectiontree->createTrunk();
    setLayout(mainLayout);

    connect(p->updater, SIGNAL(progressChanged(int)), p->progress,SLOT(setValue(int)));
    connect(p->progress, SIGNAL(stopped()), p->updater,SLOT(stop()));
    p->modeSelect->show();
}
Ejemplo n.º 18
0
void QgsGrassTools::runModule( QString name )
{
  if ( name.length() == 0 ) return;  // Section

#ifndef WIN32
  QgsGrassShell* sh = 0;
#endif

  QString path = QgsApplication::pkgDataPath() + "/grass/modules/" + name;
  QgsDebugMsg( QString( "path = %1" ).arg( path ) );
  QWidget *m;
  if ( name == "shell" )
  {
    // Set history file
    QString mapsetPath = QgsGrass::getDefaultGisdbase() + "/"
                         + QgsGrass::getDefaultLocation() + "/"
                         + QgsGrass::getDefaultMapset();

    // bash
    QString hist = "HISTFILE=" + mapsetPath + "/.bash_history";
    char *histChar = new char[hist.length()+1];
    strcpy( histChar, hist.toAscii().constData() );
    putenv( histChar );

    // csh/tcsh
#ifndef WIN32
    hist = "histfile=" + mapsetPath + "/.history";
    histChar = new char[hist.length()+1];
    strcpy( histChar, hist.toAscii().constData() );
    putenv( histChar );
#endif

#ifdef WIN32
    if ( !QProcess::startDetached( getenv( "COMSPEC" ) ) )
    {
      QMessageBox::warning( 0, "Warning", tr( "Cannot start command shell (%1)" ).arg( getenv( "COMSPEC" ) ) );
    }
    return;
#else

#ifdef HAVE_OPENPTY
    sh = new QgsGrassShell( this, mTabWidget );
    m = dynamic_cast<QWidget *>( sh );
#else
    QMessageBox::warning( 0, tr( "Warning" ), tr( "GRASS Shell is not compiled." ) );
#endif // HAVE_OPENPTY

#endif // ! WIN32
  }
  else
  {
    m = dynamic_cast<QWidget *>( new QgsGrassModule( this, name,
                                 mIface, path, mTabWidget ) );
  }

  int height = mTabWidget->iconSize().height();
  QPixmap pixmap = QgsGrassModule::pixmap( path, height );

  // Icon size in QT4 does not seem to be variable
  // -> put smaller icons in the middle
  QPixmap pixmap2( mTabWidget->iconSize() );
  QPalette pal;
  pixmap2.fill( pal.color( QPalette::Window ) );
  QPainter painter( &pixmap2 );
  int x = ( int )(( mTabWidget->iconSize().width() - pixmap.width() ) / 2 );
  painter.drawPixmap( x, 0, pixmap );
  painter.end();

  QIcon is;
  is.addPixmap( pixmap2 );
  mTabWidget->addTab( m, is, "" );


  mTabWidget->setCurrentIndex( mTabWidget->count() - 1 );

  // We must call resize to reset COLUMNS enviroment variable
  // used by bash !!!
#ifndef WIN32
  if ( sh ) sh->resizeTerminal();
#endif
}