Ejemplo n.º 1
0
//! [0]
DragWidget::DragWidget(QWidget *parent)
    : QFrame(parent)
{
#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5) || defined(Q_WS_SIMULATOR)
#else
    setMinimumSize(200, 200);
#endif
    setFrameStyle(QFrame::Sunken | QFrame::StyledPanel);
    setAcceptDrops(true);

    QLabel *boatIcon = new QLabel(this);
    boatIcon->setPixmap(QPixmap(":/images/boat.png"));
    boatIcon->move(10, 10);
    boatIcon->show();
    boatIcon->setAttribute(Qt::WA_DeleteOnClose);

    QLabel *carIcon = new QLabel(this);
    carIcon->setPixmap(QPixmap(":/images/car.png"));
    carIcon->move(100, 10);
    carIcon->show();
    carIcon->setAttribute(Qt::WA_DeleteOnClose);

    QLabel *houseIcon = new QLabel(this);
    houseIcon->setPixmap(QPixmap(":/images/house.png"));
    houseIcon->move(10, 80);
    houseIcon->show();
    houseIcon->setAttribute(Qt::WA_DeleteOnClose);
}
Ejemplo n.º 2
0
//! [0]
DragWidget::DragWidget(QWidget *parent)
    : QFrame(parent)
{
    setMinimumSize(200, 200);
    setFrameStyle(QFrame::Sunken | QFrame::StyledPanel);
    setAcceptDrops(true);

    QLabel *boatIcon = new QLabel(this);
    boatIcon->setPixmap(QPixmap(":/images/boat.png"));
    boatIcon->move(20, 20);
    boatIcon->show();
    boatIcon->setAttribute(Qt::WA_DeleteOnClose);

    QLabel *carIcon = new QLabel(this);
    carIcon->setPixmap(QPixmap(":/images/car.png"));
    carIcon->move(120, 20);
    carIcon->show();
    carIcon->setAttribute(Qt::WA_DeleteOnClose);

    QLabel *houseIcon = new QLabel(this);
    houseIcon->setPixmap(QPixmap(":/images/house.png"));
    houseIcon->move(20, 120);
    houseIcon->show();
    houseIcon->setAttribute(Qt::WA_DeleteOnClose);
}
Ejemplo n.º 3
0
void Widget::Window(WeatherInfo *wi) {
    QVBoxLayout *mainFrame = new QVBoxLayout;
    QHBoxLayout *lineFrame = new QHBoxLayout;
    this->setWindowIcon(QIcon(":/weather.png"));

    QString text = QString("%1(%2)").arg(wi->GetCityName())
                   .arg(wi->GetCountry());
    QLabel *Label = new QLabel;
    Label->setAttribute(Qt::WA_DeleteOnClose);
    Label->setText(text);
    lineFrame->addWidget(Label);

    int c = wi->GetWeatherCount();
    int lastday = 0;
    for(int i = 0; i != c; i++) {
        uint dt = wi->GetKeyByIndex(i, { "dt" }).toUInt();
        QDateTime dt_txt;
        dt_txt.setTime_t(dt);
        int day = dt_txt.date().day();
        if(lastday != day) {
            mainFrame->addLayout(lineFrame);
            lineFrame = new QHBoxLayout;
        }

        QVBoxLayout *curFrame = new QVBoxLayout;
        QLabel *imglabel = new QLabel;
        imglabel->setAttribute(Qt::WA_DeleteOnClose);
        QString key = wi->GetKeyByIndex(i, { "weather"}).toList()[0].
                      toMap()["icon"].toString();
        imglabel->setPixmap(wi->GetImg(key));
        curFrame->addWidget(imglabel);

        QLabel *datetime = new QLabel;
        datetime->setAttribute(Qt::WA_DeleteOnClose);
        datetime->setText(dt_txt.toString(tr("ddd MM-dd:HH(t)")));
        curFrame->addWidget(datetime);

        QLabel *w = new QLabel;
        w->setAttribute(Qt::WA_DeleteOnClose);
        text = tr("%1 %4% %5")
               .arg(wi->GetKeyByIndex(i, { "main", "temp" }).toFloat())
               .arg(wi->GetKeyByIndex(i, { "main", "humidity" }).toFloat())
               .arg(wi->GetKeyByIndex(i, { "weather" }).
                    toList()[0].toMap()["description"].toString());
        w->setText(text);
        curFrame->addWidget(w);

        lineFrame->addLayout(curFrame);
        lastday = day;
    }
    setLayout(mainFrame);
    show();
}
Ejemplo n.º 4
0
void MainWindow::buildGameUi()
{
    // Create score board
    QLabel *scoreBoard = new QLabel();
    //scoreBoard->setAttribute(Qt::WA_TranslucentBackground);
    scoreBoard->setAlignment(Qt::AlignCenter);
    scoreBoard->setText("<font color='white'>SCORE</font>");
    QFont *font = new QFont();
    font->setPointSizeF(18);
    font->setBold(true);
    font->setFamily(QString("Adobe Devanagari"));
    scoreBoard->setFont(*font);
    scoreBoard->setGeometry(QRect(20,20,120,30));
    scene->addWidget(scoreBoard);
    otherSceneObjectList.push_back(scoreBoard);

    // score points
    scoreBoardPoints = new QLabel();
    scoreBoard->setAttribute(Qt::WA_TranslucentBackground);
    scoreBoardPoints->setNum(this->scorePoint);
    scoreBoardPoints->setFont(*font);
    scoreBoardPoints->setGeometry(QRect(200,20,90,30));
    scene->addWidget(scoreBoardPoints);
    otherSceneObjectList.push_back(scoreBoardPoints);
    // add timer to update
    connect(&timer, SIGNAL(timeout()), this,SLOT(updateScorePonit()));

    // Create birdleft board
    QLabel *birdLeftBoard = new QLabel();
    birdLeftBoard->setAttribute(Qt::WA_TranslucentBackground);
    birdLeftBoard->setAlignment(Qt::AlignCenter);
    birdLeftBoard->setText("<font color='white'>BIRD LEFT</font>");
    birdLeftBoard->setFont(*font);
    birdLeftBoard->setGeometry(QRect(20,50,150,30));
    scene->addWidget(birdLeftBoard);
    otherSceneObjectList.push_back(birdLeftBoard);

    // bird left num
    birdLeftNumbers = new QLabel();
    //scoreBoard->setAttribute(Qt::WA_TranslucentBackground);
    birdLeftNumbers->setNum(this->scorePoint);
    birdLeftNumbers->setFont(*font);
    birdLeftNumbers->setGeometry(QRect(200,50,90,30));
    scene->addWidget(birdLeftNumbers);
    otherSceneObjectList.push_back(birdLeftNumbers);
    // add timer to update
    connect(&timer, SIGNAL(timeout()), this,SLOT(updateBirdLeft()));
}
Ejemplo n.º 5
0
StatusBar::StatusBar( QWidget* parent )
    : QStatusBar( parent )
{
    // create labels
    QLabel* label;
    
    label = ( mLabels[ltCursorPosition] = new QLabel( this ) );
    label->setToolTip( tr( "Cursor position" ) );
    
    label = ( mLabels[ltSaveState] = new QLabel( this ) );
    label->setToolTip( tr( "Modification state of file" ) );
    
    label = ( mLabels[ltEOLMode] = new QLabel( this ) );
    label->setToolTip( tr( "EOL mode" ) );
    
    label = ( mLabels[ltIndentMode] = new QLabel( this ) );
    label->setToolTip( tr( "Indentation mode" ) );
    
    // add labels
    for ( int i = ltCursorPosition; i < ltIndentMode +1; i++ )
    {
        label = mLabels[ i ];
        addPermanentWidget( label );
        label->setMargin( 2 );
        label->setFrameStyle( QFrame::NoFrame );
        label->setAttribute( Qt::WA_MacSmallSize );
    }
    
    // force remove statusbar label frame
    setStyleSheet( "QStatusBar::item { border: 0px; }" );
    
    // connections
    connect( this, SIGNAL( messageChanged( const QString& ) ), this, SLOT( setMessage( const QString& ) ) );
}
Ejemplo n.º 6
0
void crobot::dropEvent(QDropEvent *event)
{
    if (event->mimeData()->hasFormat("application/x-dnditemdata")) {
        QByteArray itemData = event->mimeData()->data("application/x-dnditemdata");
        QDataStream dataStream(&itemData, QIODevice::ReadOnly);

        QPixmap pixmap;
        QPoint offset;
        dataStream >> pixmap >> offset;



        QLabel *newIcon = new QLabel(this);
        newIcon->setPixmap(pixmap);
        newIcon->move(event->pos() - offset);
        newIcon->show();
        newIcon->setAttribute(Qt::WA_DeleteOnClose);

        if (event->source() == this) {
            event->setDropAction(Qt::MoveAction);
            event->accept();
        } else {
            event->acceptProposedAction();
        }
    } else {
Ejemplo n.º 7
0
void tst_QWidget_window::tst_recreateWindow_QTBUG40817()
{
    QTabWidget tab;

    QWidget *w = new QWidget;
    tab.addTab(w, "Tab1");
    QVBoxLayout *vl = new QVBoxLayout(w);
    QLabel *lbl = new QLabel("HELLO1");
    lbl->setObjectName("label1");
    vl->addWidget(lbl);
    w = new QWidget;
    tab.addTab(w, "Tab2");
    vl = new QVBoxLayout(w);
    lbl = new QLabel("HELLO2");
    lbl->setAttribute(Qt::WA_NativeWindow);
    lbl->setObjectName("label2");
    vl->addWidget(lbl);

    tab.show();

    QVERIFY(QTest::qWaitForWindowExposed(&tab));

    QWindow *win = tab.windowHandle();
    win->destroy();
    QWindowPrivate *p = qt_window_private(win);
    p->create(true);
    win->show();

    tab.setCurrentIndex(1);
}
Ejemplo n.º 8
0
void tst_QWidget_window::tst_updateWinId_QTBUG40681()
{
    QWidget w;
    QVBoxLayout *vl = new QVBoxLayout(&w);
    QLabel *lbl = new QLabel("HELLO1");
    lbl->setAttribute(Qt::WA_NativeWindow);
    lbl->setObjectName("label1");
    vl->addWidget(lbl);
    w.setMinimumWidth(200);

    w.show();

    QVERIFY(QTest::qWaitForWindowExposed(&w));

    QCOMPARE(lbl->winId(), lbl->windowHandle()->winId());

     // simulate screen change and notification
    QWindow *win = w.windowHandle();
    w.windowHandle()->destroy();
    lbl->windowHandle()->destroy();
    w.windowHandle()->create();
    lbl->windowHandle()->create();
    QWindowPrivate *p = qt_window_private(win);
    p->emitScreenChangedRecursion(win->screen());

    QCOMPARE(lbl->winId(), lbl->windowHandle()->winId());
}
Ejemplo n.º 9
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    int x=QApplication::desktop()->width(),y=QApplication::desktop()->height();
    MainWindow w(x,y);
    Off off(x,y);
    off.setAttribute(Qt::WA_TranslucentBackground);
    off.setWindowFlags(Qt::WindowStaysOnTopHint|Qt::FramelessWindowHint|Qt::Tool);//最前端和透明
    w.setFixedSize(x,y);
    w.setAttribute(Qt::WA_TranslucentBackground);
    w.setWindowFlags(Qt::WindowStaysOnTopHint|Qt::FramelessWindowHint|Qt::Tool);//最前端和透明
    QImage image(":/image/3.png");
    QPixmap pixmap=QPixmap::fromImage(image.scaled(1477/2,1085/2));
    QLabel label;
    label.setFixedSize(1477/2,1085/2);
    label.setPixmap(pixmap);
    label.setAttribute(Qt::WA_TranslucentBackground);
    label.setWindowFlags(Qt::FramelessWindowHint|Qt::Tool|Qt::WindowStaysOnBottomHint);
    taskbar(label,x,y);
    label.show();
    off.show();
    w.show();
    QObject::connect(&off,SIGNAL(suspend_movie()),&w,SLOT(suspend()));
    QObject::connect(&off,SIGNAL(quit()),&a,SLOT(quit()));
    return a.exec();
}
Ejemplo n.º 10
0
void
GraphicalRack::setText(const Quackle::LetterString &text)
{
	// clear old labels
	while(m_layout->count()) {
		QLabel *label = qobject_cast<QLabel*>(m_layout->itemAt(0)->widget());
		if (!label) {
			break;
		}
		m_layout->removeWidget(label);
		label->close();
	}

	PixmapCacher::self()->invalidate();
	for (int i = text.size() - 1; i >= 0 ; --i) {
		QLabel *label = new QLabel;
        label->setAttribute (Qt::WA_DeleteOnClose);

		TileWidget tile;
		Quackle::Board::TileInformation info;
        info.isOnRack = true;
		info.letter = text[i];
		info.tileType = Quackle::Board::LetterTile;
		tile.setInformation(info);
		tile.setSideLength(50);
		tile.prepare();
	
		label->setPixmap(tile.tilePixmap());

		m_layout->insertWidget(0, label);
	}
}
Ejemplo n.º 11
0
void MainWindow::showAmbientOcclusionMaps()
{
  const GFX::Buffer<GFX::ColorF> &aoMap = ui->pdb->aoMap();
  int size = aoMap.height();
  int numAtoms = aoMap.width() / size;

  int w = (1000 / size);
  int h = numAtoms / w + 1;



  QImage image(w * size, h * size, QImage::Format_RGB32);


  for (int a = 0; a < numAtoms; ++a) {
    int b = a / w;
    for (int j = 0; j < size; ++j)
      for (int i = (a % w) * size; i < ((a + 1) % w) * size; ++i) {
        const GFX::Color &color = aoMap(i + a * size, j);
        image.setPixel(i, j + b * size, color.toARGB());
      }
  }

  QLabel *lbl = new QLabel;
  lbl->setAttribute(Qt::WA_DeleteOnClose);
  lbl->setPixmap(QPixmap::fromImage(image));
  lbl->show();
}
Ejemplo n.º 12
0
void NumberChoiceLive::chooseNumber(int number) {
	//numbers[number]->setText(QString(QChar(prizes[number])));
	QPixmap *prizeImage;
	
	switch(prizes[number]) {
		case 'B':
			if (isVisible()) QSound::play("media/sounds/PrizeBronze.wav");
			prizeImage = prizeBronze;
			break;
		case 'S':
			if (isVisible()) QSound::play("media/sounds/PrizeSilver.wav");
			prizeImage = prizeSilver;
			break;
		case 'G':
			if (isVisible()) QSound::play("media/sounds/PrizeGold.wav");
			prizeImage = prizeGold;
			break;
	}
	QPixmap smallerPrize = prizeImage->scaled(numbers[number]->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
	QLabel *medal = new QLabel(numbers[number]->parentWidget());
	medal->setAttribute(Qt::WA_DeleteOnClose);
	medal->setPixmap(smallerPrize);
	medal->resize(smallerPrize.size()); // Using . rather than -> with smallerPrize because smallerPrize isn't a pointer
	medal->move(numbers[number]->geometry().center() - medal->geometry().center());
	medal->show();
	connect(this, SIGNAL(resetAll(bool)), medal, SLOT(close()));
}
Ejemplo n.º 13
0
void DragWidget::loadIcon(const char filename[],
                          int x, int y) {
  QLabel* boatIcon = new QLabel(this);
  boatIcon->setPixmap(QPixmap(filename));
  boatIcon->move(x, y);
  boatIcon->show();
  boatIcon->setAttribute(Qt::WA_DeleteOnClose);
}
Ejemplo n.º 14
0
QGraphicsProxyWidget *
UpcomingEventsWidget::createLabel( const QString &text, QSizePolicy::Policy hPolicy )
{
    QLabel *label = new QLabel;
    label->setAttribute( Qt::WA_NoSystemBackground );
    label->setMinimumWidth( 10 );
    label->setSizePolicy( hPolicy, QSizePolicy::Preferred );
    label->setText( text );
    label->setWordWrap( false );
    QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget( this );
    proxy->setWidget( label );
    return proxy;
}
Ejemplo n.º 15
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    setAcceptDrops(true);
    QLabel *label = new QLabel(this);
    QPixmap pix(":/image/images/C_171.png");
    label->setPixmap(pix);
    label->resize(pix.size());
    label->move(100,100);
    label->setAttribute(Qt::WA_DeleteOnClose);
}
Ejemplo n.º 16
0
DragWidgetBin::DragWidgetBin(QWidget *parent)
    : QFrame(parent)
{
    setMinimumSize(100, 100);
    setMaximumSize(100, 100);
    setFrameStyle(QFrame::Sunken | QFrame::StyledPanel);
    setAcceptDrops(true);

    QLabel *binIcon = new QLabel(this);
    binIcon->setPixmap(QPixmap(":/images/bin.png"));
    binIcon->move(15, 15);
    binIcon->show();
    binIcon->setAttribute(Qt::WA_DeleteOnClose);
}
Ejemplo n.º 17
0
//create the icons that will seat on the shop tab widget
crobot::crobot(QWidget *parent) :
    QFrame(parent)
{
    //setFrameStyle(QFrame::Sunken | QFrame::StyledPanel);
    //setGeometry(0, 0, 300, 600);

    QLabel *boatIcon = new QLabel(this);
    boatIcon->setPixmap(QPixmap(":/images/boat.png"));
    boatIcon->move(10, 80);
    boatIcon->show();
    boatIcon->setAttribute(Qt::WA_DeleteOnClose);

    QLabel *carIcon = new QLabel(this);
    carIcon->setPixmap(QPixmap(":/images/car.png"));
    carIcon->move(100, 80);
    carIcon->show();
    carIcon->setAttribute(Qt::WA_DeleteOnClose);

    QLabel *houseIcon = new QLabel(this);
    houseIcon->setPixmap(QPixmap(":/images/house.png"));
    houseIcon->move(10, 240);
    houseIcon->show();
    houseIcon->setAttribute(Qt::WA_DeleteOnClose);
}
Ejemplo n.º 18
0
void SearchView::updateRecentKeywords() {
    // load
    QSettings settings;
    QStringList keywords = settings.value(recentKeywordsKey).toStringList();
    if (keywords == recentKeywords) return;
    recentKeywords = keywords;

    // cleanup
    QLayoutItem *item;
    while ((item = recentKeywordsLayout->takeAt(1)) != 0) {
        item->widget()->close();
        delete item;
    }

    recentKeywordsLabel->setVisible(!keywords.isEmpty());
    The::globalActions()->value("clearRecentKeywords")->setEnabled(!keywords.isEmpty());

    foreach (const QString &keyword, keywords) {
        QString link = keyword;
        QString display = keyword;
        if (keyword.startsWith("http://") || keyword.startsWith("https://")) {
            int separator = keyword.indexOf("|");
            if (separator > 0 && separator + 1 < keyword.length()) {
                link = keyword.left(separator);
                display = keyword.mid(separator+1);
            }
        }
        bool needStatusTip = false;
        if (display.length() > 24) {
            display.truncate(24);
            display.append("...");
            needStatusTip = true;
        }
        QLabel *itemLabel = new QLabel("<a href=\"" + link
                                       + "\" style=\"color:palette(text); text-decoration:none\">"
                                       + display + "</a>", this);
        itemLabel->setAttribute(Qt::WA_DeleteOnClose);
        itemLabel->setProperty("recentItem", true);
        itemLabel->setMaximumWidth(queryEdit->toWidget()->width() + watchButton->width());
        itemLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
        // Make links navigable with the keyboard too
        itemLabel->setTextInteractionFlags(Qt::LinksAccessibleByKeyboard | Qt::LinksAccessibleByMouse);
        if (needStatusTip)
            itemLabel->setStatusTip(link);
        connect(itemLabel, SIGNAL(linkActivated(QString)), this, SLOT(watchKeywords(QString)));
        recentKeywordsLayout->addWidget(itemLabel);
    }
Ejemplo n.º 19
0
//---------------------------------------------------------------------------
//  dropEvent
//
//! The event handler that receives drop events.
//
//! @param event the drop event
//---------------------------------------------------------------------------
void
GraphicalRack::dropEvent (QDropEvent* event)
{
    if (event->mimeData()->hasFormat (mime_type)) {
        QByteArray itemData = event->mimeData()->data (mime_type);
        QDataStream dataStream(&itemData, QIODevice::ReadOnly);

        QPixmap pixmap;
        QPoint sourcePos;
        QPoint offset;
        dataStream >> pixmap >> sourcePos >> offset;

        QLabel* droppedTile = new QLabel;
        droppedTile->setPixmap(pixmap);
        droppedTile->setAttribute (Qt::WA_DeleteOnClose);

        QPoint dropPos = event->pos() - offset;

        // Move the tile an extra half tile width in the direction of the
        // move.  This allows the tile to assume a new spot if it is dragged
        // more than halfway onto the spot.
        int extraMove = (sourcePos.x() < dropPos.x() ? 50 / 2
                                                     : -50 / 2);

        dropPos.setX(dropPos.x() + extraMove);

		for(int i = 0; i < m_layout->count(); ++i) {
			QLabel *label = qobject_cast<QLabel*>(m_layout->itemAt(i)->widget());
			if (!label) { // hit the stretcher
				m_layout->insertWidget(i, droppedTile);
				break;
			}
			if (dropPos.x() > label->pos().x()) {
				continue;
			}
			m_layout->insertWidget(i, droppedTile);
			break;
		}

        if (event->source() == this) {
            event->setDropAction (Qt::MoveAction);
            event->accept();
        } else {
            event->acceptProposedAction();
        }
    }
void Parameter_LED8x8_Form::initSetting()
{
    //this->setWindowState(Qt::WindowActive);
    this->installEventFilter(this);
    this->setFocus();

    this->setAttribute(Qt::WA_TranslucentBackground, true);
    //恩原来是tool
    this->setWindowFlags(Qt::FramelessWindowHint /*| Qt::Tool*/);

    pushButton->setWindowFlags(Qt::FramelessWindowHint);
    pushButton->setAttribute(Qt::WA_TranslucentBackground);

    for (int i = 0 ; i < 8 ; i ++){
        for (int j = 0 ; j < 8 ; j ++){
            ledState_[i*8+j] = 0;
        }
    }


    int widget_pos_x = (rect_.width() - widgetBg->width()) / 2;   //根据屏幕分辨率 计算窗体位置
    int widget_pos_y = (rect_.height() - widgetBg->height()) / 2;
    int bgi_pos_x = bgimage->x();
    int bgi_pos_y = bgimage->y();

    QPixmap singleLED_Dark("resource/images/parameter_input/LED_Matrix/ParameterSetup_8x8LED_Single_Dark.png");

    for (int i = 0 ; i < 8 ; i ++){
        for (int j = 0 ; j < 8 ; j ++){
            QLabel *p = new QLabel(this);
            p->setObjectName(QString::number((i*8+j)));

            p->move(widget_pos_x + bgi_pos_x + 5 + j*43,widget_pos_y + bgi_pos_y + 5 + i*43);
            p->resize(32,32);
            p->setPixmap(singleLED_Dark);

            p->setAttribute(Qt::WA_TranslucentBackground);
            LEDsList_.append(p);
            ledState_[j*8+i] = 0;
        }
    }

}
Ejemplo n.º 21
0
WaterWaveBtn::WaterWaveBtn(const QString& pngFile, QWidget *parent)
    : QWidget(parent)
{
    m_Movie = new QMovie(":/Resource/waterWave.gif");
	m_Movie->setCacheMode(QMovie::CacheAll);
	QLabel*	waterWaveLabel = new QLabel(this);
	waterWaveLabel->setMovie(m_Movie);
	waterWaveLabel->setAttribute(Qt::WA_TranslucentBackground,true);
	m_Movie->start();
	m_Movie->setPaused(true);
    LabelBtn* labelBtn = new LabelBtn(pngFile,":/Resource/sound.wav",this);
    int size = QPixmap(":/Resource/waterWave.gif").width();
	int gap = (size - labelBtn->width())/2;
	labelBtn->move(gap,gap);
	this->setFixedSize(size,size);

	this->setAttribute(Qt::WA_TranslucentBackground);
//	this->setWindowFlags(Qt::FramelessWindowHint|Qt::Window|Qt::WindowSystemMenuHint|Qt::WindowMinimizeButtonHint|Qt::WindowMaximizeButtonHint);

	connect(labelBtn, SIGNAL(clicked()), this, SLOT(showWaterWave()));
}
Ejemplo n.º 22
0
void ImageView::setGifAnimation(QString fileName) {
  /* the built-in gif reader gives the first frame, which won't
     be shown but is used for tracking position and dimensions */
  image_ = QImage(fileName);
  if(image_.isNull()) {
    if(imageItem_) {
      imageItem_->hide();
      imageItem_->setBrush(QBrush());
    }
    scene_->setSceneRect(0, 0, 0, 0);
  }
  else {
    scene_->clear();
    imageItem_ = nullptr; // it's deleted by clear();
    if(gifMovie_) {
      delete gifMovie_;
      gifMovie_ = nullptr;
    }
    QPixmap pix(image_.size());
    pix.fill(Qt::transparent);
    QGraphicsItem *gifItem = new QGraphicsPixmapItem(pix);
    QLabel *gifLabel = new QLabel();
    gifMovie_ = new QMovie(fileName);
    QGraphicsProxyWidget* gifWidget = new QGraphicsProxyWidget(gifItem);
    gifLabel->setAttribute(Qt::WA_NoSystemBackground);
    gifLabel->setMovie(gifMovie_);
    gifWidget->setWidget(gifLabel);
    gifMovie_->start();
    scene_->addItem(gifItem);
    scene_->setSceneRect(gifItem->boundingRect());
  }

  if(autoZoomFit_)
    zoomFit();
  queueGenerateCache(); // deletes the cache timer in this case
}
Ejemplo n.º 23
0
Window::Window(QWidget *parent, Qt::WindowFlags wf)
:	QMainWindow(parent, wf)
{
	QWidget* contents = new QWidget(this);
	setCentralWidget(contents);

	// Create preview
	m_preview = new QLabel(contents);
	m_preview->setFixedSize(80, 100);
	m_preview->setAutoFillBackground(true);
	{
		QPalette palette = m_preview->palette();
		palette.setColor(m_preview->backgroundRole(), Qt::black);
		m_preview->setPalette(palette);
	}

	// Create level display
	m_level = new QLabel("0", contents);
	m_level->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
	m_level->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
	m_level->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);

	// Create lines display
	m_lines = new QLabel("0", contents);
	m_lines->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
	m_lines->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
	m_lines->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);

	// Create score display
	m_score = new QLabel("0", contents);
	m_score->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
	m_score->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
	m_score->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);

	// Create scoreboard
	m_score_board = new ScoreBoard(this);

	// Create board
	m_board = new Board(contents);
	connect(m_board, &Board::pauseAvailable, this, &Window::pauseAvailable);
	connect(m_board, &Board::nextPieceAvailable, m_preview, &QLabel::setPixmap);
	connect(m_board, &Board::levelUpdated, m_level, static_cast<void (QLabel::*)(int)>(&QLabel::setNum));
	connect(m_board, &Board::linesRemovedUpdated, m_lines, static_cast<void (QLabel::*)(int)>(&QLabel::setNum));
	connect(m_board, &Board::scoreUpdated, this, &Window::scoreUpdated);
	connect(m_board, static_cast<void (Board::*)(int,int,int)>(&Board::gameOver), m_score_board, &ScoreBoard::addHighScore);
	connect(m_board, static_cast<void (Board::*)(int,int,int)>(&Board::gameOver), this, &Window::gameOver);
	connect(m_board, &Board::gameStarted, this, &Window::newGame);

	// Create overlay message
	QLabel* message = new QLabel(tr("Click to start a new game."), contents);
	message->setAttribute(Qt::WA_TransparentForMouseEvents);
	message->setAlignment(Qt::AlignCenter);
	message->setStyleSheet(
		"QLabel {"
			"background-color: rgba(255, 255, 255, 200);"
			"color: black;"
			"margin: 0;"
			"padding: 0.5em;"
			"border-radius: 0.5em;"
		"}");
	message->setWordWrap(true);
	connect(m_board, &Board::showMessage, message, &QLabel::show);
	connect(m_board, &Board::showMessage, message, &QLabel::setText);
	connect(m_board, &Board::hideMessage, message, &QLabel::hide);
	connect(m_board, &Board::hideMessage, message, &QLabel::clear);

	// Create menus
	QMenu* menu = menuBar()->addMenu(tr("&Game"));
	menu->addAction(tr("&New"), m_board, SLOT(newGame()), QKeySequence::New);
	m_pause_action = menu->addAction(tr("&Pause"), m_board, SLOT(pauseGame()), tr("P"));
	m_pause_action->setEnabled(false);
	m_resume_action = menu->addAction(tr("&Resume"), m_board, SLOT(resumeGame()), tr("P"));
	m_resume_action->setVisible(false);
	menu->addSeparator();
	menu->addAction(tr("&Scores"), m_score_board, SLOT(show()));
	menu->addSeparator();
	QAction* action = menu->addAction(tr("&Quit"), this, SLOT(close()), QKeySequence::Quit);
	action->setMenuRole(QAction::QuitRole);

	menu = menuBar()->addMenu(tr("&Settings"));
	menu->addAction(tr("Application &Language..."), this, SLOT(setLocale()));

	menu = menuBar()->addMenu(tr("&Help"));
	action = menu->addAction(tr("&About"), this, SLOT(about()));
	action->setMenuRole(QAction::AboutRole);
	action = menu->addAction(tr("About &Qt"), qApp, SLOT(aboutQt()));
	action->setMenuRole(QAction::AboutQtRole);

	// Layout window
	QGridLayout* layout = new QGridLayout(contents);
	layout->setMargin(12);
	layout->setSpacing(0);
	layout->setColumnStretch(0, 1);
	layout->setColumnMinimumWidth(1, 12);
	layout->setRowStretch(11, 1);
	layout->setRowMinimumHeight(2, 24);
	layout->setRowMinimumHeight(5, 24);
	layout->setRowMinimumHeight(8, 24);
	layout->addWidget(m_board, 0, 0, 12, 1);
	layout->addWidget(message, 0, 0, 12, 1, Qt::AlignCenter);
	layout->addWidget(new QLabel(tr("Next Piece"), contents), 0, 2, 1, 1, Qt::AlignCenter);
	layout->addWidget(m_preview, 1, 2, Qt::AlignCenter);
	layout->addWidget(new QLabel(tr("Level"), contents), 3, 2, 1, 1, Qt::AlignCenter);
	layout->addWidget(m_level, 4, 2);
	layout->addWidget(new QLabel(tr("Removed Lines"), contents), 6, 2, 1, 1, Qt::AlignCenter);
	layout->addWidget(m_lines, 7, 2);
	layout->addWidget(new QLabel(tr("Score"), contents), 9, 2, 1, 1, Qt::AlignCenter);
	layout->addWidget(m_score, 10, 2);

	// Restore window
	restoreGeometry(QSettings().value("Geometry").toByteArray());
}
Ejemplo n.º 24
0
Archivo: main.cpp Proyecto: tynn/H4KvT
int main(int argc, char **argv)
{
	Vals vals;

	/* the application */
	QApplication app(argc, argv);
	app.setApplicationName(APP_NAME);
	app.setWindowIcon(QIcon(":/icon"));
	Window window;

	/* translations */
	QTranslator qtr;
	if (qtr.load("qt_" + QLocale::system().name(), QTR_PATH))
		app.installTranslator(&qtr);

	QTranslator htr;
	if (htr.load("H4KvT_" + QLocale::system().name(), ":/"))
		app.installTranslator(&htr);

	/* display information */
	QTextEdit *text = new QTextEdit;
	text->setReadOnly(true);
	text->setLineWrapMode(QTextEdit::NoWrap);
	text->setToolTip(Window::tr("Drop any file for hashing"));
	QObject::connect(&window, &Window::idle, text, &QWidget::setEnabled);

	/* compare hash */
	QLineEdit *test = new QLineEdit;
	HexVal hexval;
	test->setValidator(&hexval);
	test->installEventFilter(&window);
	test->setToolTip(Window::tr("Compare hashes"));

	QObject::connect(test, &QLineEdit::textChanged,
		[&](const QString &newValue) { if (vals.name != "") {
			std::string hashVal = newValue.toStdString();
			std::transform(hashVal.begin(), hashVal.end(), hashVal.begin(), ::tolower);
			std::stringstream html;
			if (hashVal != "")
				html << "<style>.h" << hashVal << "{color:green}</style>";
			html << "<div style='margin-bottom:2; font-size:27px'><i><b>" << vals.name << "</b></i></div>";
			html << "<div style='margin-bottom:7; margin-left:23; font-size:13px'>" << vals.path << "</div>";
			if (!ALL(vals,"")) {
				html << "<div style='font-size:13px'><table>";
				if (vals.md5 != "")
					html << "<tr><td>md5: </td><td class='h" << vals.md5 << "'>" << vals.md5 << "</td</tr>";
				if (vals.sha1 != "")
					html << "<tr><td>sha1: </td><td class='h" << vals.sha1 << "'>" << vals.sha1 << "</td</tr>";
				if (vals.sha224 != "")
					html << "<tr><td>sha224: </td><td class='h" << vals.sha224 << "'>" << vals.sha224 << "</td</tr>";
				if (vals.sha256 != "")
					html << "<tr><td>sha256: </td><td class='h" << vals.sha256 << "'>" << vals.sha256 << "</td</tr>";
				if (vals.sha384 != "")
					html << "<tr><td>sha384: </td><td class='h" << vals.sha384 << "'>" << vals.sha384 << "</td</tr>";
				if (vals.sha512 != "")
					html << "<tr><td>sha512: </td><td class='h" << vals.sha512 << "'>" << vals.sha512 << "</td</tr>";
				html << "</table></div>";
			}
			int horizontal = text->horizontalScrollBar()->value();
			int vertical = text->verticalScrollBar()->value();
			text->setHtml(QString::fromStdString(html.str()));
			text->horizontalScrollBar()->setValue(horizontal);
			text->verticalScrollBar()->setValue(vertical);
			test->setStyleSheet(ANY(vals,hashVal) ? "color:green" : "");
		}});

	/* error messages */
	QLabel *error = new QLabel;
	error->setStyleSheet("color:red");

	/* test or error */
	QStackedWidget *stack = new QStackedWidget;
	delete stack->layout();
	stack->setLayout(new Stack);
	stack->addWidget(error);
	stack->addWidget(test);
	stack->setCurrentIndex(1);

	/* toggle test or error */
	QPushButton *hash = new QPushButton(QIcon(":/icon"), "");
	hash->setCheckable(true);
	hash->setChecked(true);
	hash->setToolTip(Window::tr("Compare hashes"));
	QObject::connect(hash, &QPushButton::toggled, stack, &QStackedWidget::setCurrentIndex);

	/* store method */
	QSettings settings("H4KvT", "H4KvT");

	/* more methods */
	bool more;
	try {
		settings.setValue("MoreHashingMethods", more = moreOrLess());
	} catch (...) {
		more = settings.value("MoreHashingMethods", false).toBool();
	}

	/* hashing method */
	QComboBox *meth = new QComboBox;
	meth->addItem("md5");
	meth->addItem("sha1");
	if (more) meth->addItem("sha224");
	meth->addItem("sha256");
	if (more) meth->addItem("sha384");
	meth->addItem("sha512");
	meth->setToolTip(Window::tr("Hashing method"));
	meth->setCurrentText(settings.value("HashingMethod", "md5").toString());
	QObject::connect(&window, &Window::idle, meth, &QWidget::setEnabled);

	QObject::connect(meth, &QComboBox::currentTextChanged,
		[&](const QString &text) { settings.setValue("HashingMethod", text); });

	/* toolbar */
	QHBoxLayout *pane = new QHBoxLayout;
	pane->addWidget(hash, 0, Qt::AlignLeft);
	pane->addWidget(stack);
	pane->addWidget(meth, 0, Qt::AlignRight);

	/* main layout */
	QVBoxLayout *layout = new QVBoxLayout;
	layout->addWidget(text);
	layout->addLayout(pane);

	/* the window */
	window.centralWidget()->setLayout(layout);
	window.show();

	/* future hashing */
	QFutureWatcher<Vals> zu;
	QObject::connect(&zu, &QFutureWatcher<Vals>::finished,
		[&]() {
			Vals valsi = zu.future().result();
			window.idle(true);
			if (valsi.path == "") {
				error->setText(QString::fromStdString(valsi.name));
				hash->setChecked(false);
			} else {
				error->clear();
				vals += valsi;
				test->textChanged(test->text());
			}
		});

	QObject::connect(meth, &QComboBox::currentTextChanged,
		[&](const QString &text) { if (vals.name != "") {
			window.idle(false);
			zu.setFuture(QtConcurrent::run(&update, text, vals));
		}});

	QObject::connect(&window, &Window::fileDroped,
		[&](const QString &name, const QString &path) {
			window.idle(false);
			zu.setFuture(QtConcurrent::run(&update, meth->currentText(), Vals(name, path)));
		});

	/* hashing info */
	QGraphicsBlurEffect blur;
	blur.setBlurHints(QGraphicsBlurEffect::AnimationHint);

	QPropertyAnimation anim(&blur, "blurRadius");
	anim.setDuration(2000);
	anim.setLoopCount(-1);
	anim.setKeyValueAt(0, 0);
	anim.setKeyValueAt(0.5, 3);
	anim.setKeyValueAt(1, 0);

	QLabel *hashing = new QLabel;
	hashing->setPixmap(QPixmap(":/icon"));
	hashing->setAttribute(Qt::WA_TransparentForMouseEvents);
	hashing->setGraphicsEffect(&blur);
	hashing->hide();
	(new QHBoxLayout(text))->addWidget(hashing, 0, Qt::AlignCenter);

	QObject::connect(&blur, &QGraphicsBlurEffect::blurRadiusChanged,
		hashing, static_cast<void(QWidget::*)()>(&QWidget::update));

	QObject::connect(&window, &Window::idle,
		[&](bool idle) {
			if (idle) {
				hashing->hide();
				anim.stop();
			} else {
				hashing->show();
				anim.start();
			}
		});

	/* about app */
	QMenu about;
	QAction *action = about.addAction(QIcon(":/icon"), Window::tr("About %1").arg(APP_NAME));
	action->setMenuRole(QAction::AboutRole);
	QObject::connect(action, &QAction::triggered, &window, &Window::about);

	error->setContextMenuPolicy(Qt::NoContextMenu);
	hash->setContextMenuPolicy(Qt::NoContextMenu);
	meth->setContextMenuPolicy(Qt::NoContextMenu);
	window.setContextMenuPolicy(Qt::CustomContextMenu);
	QObject::connect(&window, &QWidget::customContextMenuRequested,
		[&about, &window](const QPoint &pos) { about.popup(window.mapToGlobal(pos)); });

	text->setContextMenuPolicy(Qt::CustomContextMenu);
	QObject::connect(text, &QWidget::customContextMenuRequested,
		[action, text](const QPoint &pos) {
			if (QMenu *m = text->createStandardContextMenu()) {
				m->insertAction(m->insertSeparator(m->actions()[0]), action);
				m->popup(text->mapToGlobal(pos));
			}
		});

	test->setContextMenuPolicy(Qt::CustomContextMenu);
	QObject::connect(test, &QWidget::customContextMenuRequested,
		[action, test](const QPoint &pos) {
			if (QMenu *m = test->createStandardContextMenu()) {
				m->insertAction(m->insertSeparator(m->actions()[0]), action);
				m->popup(test->mapToGlobal(pos));
			}
		});

	return app.exec();
}
Ejemplo n.º 25
0
void
CurrentTrack::init()
{
    DEBUG_BLOCK
    PERF_LOG( "Begin init" );

    // Call the base implementation.
    Context::Applet::init();

    setToolTip( i18n( "Right-click to configure" ) );

    m_ratingWidget = new RatingWidget( this );
    m_ratingWidget->setSpacing( 2 );
    m_ratingWidget->setMinimumSize( m_albumWidth + 10, 30 );
    m_ratingWidget->setMaximumSize( m_albumWidth + 10, 30 );
    connect( m_ratingWidget, SIGNAL(ratingChanged(int)), SLOT(trackRatingChanged(int)) );

    QLabel *collectionLabel = new QLabel( i18n( "Local Collection" ) );
    collectionLabel->setAttribute( Qt::WA_NoSystemBackground );
    collectionLabel->setAlignment( Qt::AlignCenter );
    m_collectionLabel = new QGraphicsProxyWidget( this );
    m_collectionLabel->setWidget( collectionLabel );

    m_title  = new TextScrollingWidget( this );
    m_artist = new TextScrollingWidget( this );
    m_album  = new TextScrollingWidget( this );
    m_byText = new QGraphicsSimpleTextItem( i18nc( "What artist is this track by", "By" ), this );
    m_onText = new QGraphicsSimpleTextItem( i18nc( "What album is this track on", "On" ), this );

    m_recentWidget = new RecentlyPlayedListWidget( this );
    m_recentHeader = new TextScrollingWidget( this );
    m_recentHeader->setDrawBackground( true );
    m_recentHeader->setAlignment( Qt::AlignLeft );
    QFont recentHeaderFont;
    recentHeaderFont.setPointSize( recentHeaderFont.pointSize() + 2 );
    m_recentHeader->setFont( recentHeaderFont );

    m_title->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
    m_artist->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
    m_album->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
    m_collectionLabel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
    m_recentHeader->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
    m_recentWidget->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
    m_recentWidget->setMinimumHeight( 10 );

    m_albumCover = new DropPixmapLayoutItem( this );
    m_albumCover->setPreferredSize( QSizeF( m_albumWidth, m_albumWidth ) );
    connect( m_albumCover, SIGNAL(imageDropped(QPixmap)), SLOT(coverDropped(QPixmap)) );

    const QBrush brush = normalBrush();
    m_title->setBrush( brush );
    m_artist->setBrush( brush );
    m_album->setBrush( brush );
    m_byText->setBrush( brush );
    m_onText->setBrush( brush );

    const QFont tinyFont = KGlobalSettings::smallestReadableFont();
    m_byText->setFont( tinyFont );
    m_onText->setFont( tinyFont );

    m_actionsLayout = new QGraphicsLinearLayout;
    m_actionsLayout->setMinimumWidth( 10 );
    m_actionsLayout->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
    QGraphicsLinearLayout *titlesLayout = new QGraphicsLinearLayout( Qt::Vertical );
    titlesLayout->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
    titlesLayout->setMinimumWidth( 10 );
    titlesLayout->setSpacing( 2 );
    titlesLayout->addItem( m_title );
    titlesLayout->addItem( m_artist );
    titlesLayout->addItem( m_album );
    titlesLayout->addItem( m_actionsLayout );
    titlesLayout->setItemSpacing( 2, 4 ); // a bit more spacing for the actions row

    const qreal pad = standardPadding();
    QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout( this );
    l->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
    l->addCornerAnchors( m_ratingWidget, Qt::BottomLeftCorner, l, Qt::BottomLeftCorner );
    l->addCornerAnchors( m_ratingWidget, Qt::BottomLeftCorner, m_collectionLabel, Qt::BottomLeftCorner );
    l->addCornerAnchors( m_ratingWidget, Qt::TopRightCorner, m_collectionLabel, Qt::TopRightCorner );
    l->addCornerAnchors( m_recentHeader, Qt::TopRightCorner, l, Qt::TopRightCorner );
    l->addAnchor( m_albumCover, Qt::AnchorBottom, m_ratingWidget, Qt::AnchorTop )->setSpacing( 4 );
    l->addAnchor( m_albumCover, Qt::AnchorHorizontalCenter, m_ratingWidget, Qt::AnchorHorizontalCenter );
    l->addAnchor( titlesLayout, Qt::AnchorTop, l, Qt::AnchorTop )->setSpacing( 18 );
    l->addAnchor( titlesLayout, Qt::AnchorRight, l, Qt::AnchorRight )->setSpacing( pad );
    l->addAnchors( m_recentWidget, m_recentHeader, Qt::Horizontal );
    l->addAnchor( m_recentWidget, Qt::AnchorTop, m_recentHeader, Qt::AnchorBottom );
    l->addAnchor( m_recentWidget, Qt::AnchorRight, m_recentHeader, Qt::AnchorRight );
    l->addAnchor( m_recentWidget, Qt::AnchorLeft, m_ratingWidget, Qt::AnchorRight )->setSpacing( pad * 2 );
    l->addAnchor( m_recentWidget, Qt::AnchorBottom, m_albumCover, Qt::AnchorBottom )->setSpacing( 20 );
    qreal midSpacing = qMax( m_byText->boundingRect().width(), m_onText->boundingRect().width() ) + pad;
    l->addAnchor( titlesLayout, Qt::AnchorLeft, m_ratingWidget, Qt::AnchorRight )->setSpacing( midSpacing );
    l->anchor( m_recentHeader, Qt::AnchorTop, l, Qt::AnchorTop )->setSpacing( 2 );

    // Read config
    KConfigGroup config = Amarok::config("Current Track Applet");
    const QString fontDesc = config.readEntry( "Font", QString() );
    QFont font;
    if( !fontDesc.isEmpty() )
        font.fromString( fontDesc );
    else
        font.setPointSize( font.pointSize() + 3 );

    m_showEditTrackDetailsAction = config.readEntry( "ShowEditTrackAction", true );

    m_title->setFont( font );
    m_artist->setFont( font );
    m_album->setFont( font );

    m_title->setAlignment( Qt::AlignLeft );
    m_artist->setAlignment( Qt::AlignLeft );
    m_album->setAlignment( Qt::AlignLeft );

    dataEngine( "amarok-current" )->setProperty( "coverWidth", m_albumWidth );
    dataEngine( "amarok-current" )->connectSource( "current", this );
    connect( The::paletteHandler(), SIGNAL(newPalette(QPalette)), SLOT(paletteChanged(QPalette)) );
    connect( CollectionManager::instance(), SIGNAL(collectionDataChanged(Collections::Collection*)),
             this, SLOT(queryCollection()), Qt::QueuedConnection );
    queryCollection();
    setView( Stopped );

    PERF_LOG( "Finished init" );
}
Ejemplo n.º 26
0
//TODO put this in a class
void MainWindow::createIntroductionWizard() {
	m_introWiz = new QWizard;

	//BioTracker::Core::Settings *disableIntroWiz = GET_CORESETTINGS(CORE_CONFIGURATION);
	BioTracker::Core::Settings *set = BioTracker::Util::TypedSingleton<BioTracker::Core::Settings>::getInstance(CORE_CONFIGURATION);
	bool disabled = set->getValueOrDefault<bool>("BiotrackerCore/Disable_Wizard", false);

	//dont show again checkbox
	QCheckBox* noShowCheck = new QCheckBox("Don't show this again");
	noShowCheck->setChecked(disabled);
	QObject::connect(noShowCheck, &QCheckBox::toggled, this, &MainWindow::toggleNoShowWiz);


	//introduction
	QWizardPage* p1 = new QWizardPage;
	{
		p1->setTitle("BioTracker 3 - Introduction");

		QPixmap logoImg(":/Logo/resources/logo/BT3-big.png");
		QPixmap scaledImg = logoImg.scaled(QSize(600, 400), Qt::KeepAspectRatio, Qt::SmoothTransformation);

		QLabel* imgLabel = new QLabel;
		imgLabel->setPixmap(scaledImg);
		imgLabel->setAttribute(Qt::WA_TranslucentBackground);
		imgLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
		imgLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);

		QFile file(":/Introduction/resources/introduction/intro.txt");
		QLabel *introLabel = new QLabel;
		introLabel->setWordWrap(true);

		//read introduction text from file
		QString line;
		if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
			QTextStream stream(&file);
			while (!stream.atEnd()) {
				line.append(stream.readLine() + "\n");
			}
			introLabel->setText(line);
		}
		file.close();

		QVBoxLayout *layout = new QVBoxLayout;
		layout->addWidget(imgLabel);
		QScrollArea* textScroll = new QScrollArea;
		textScroll->setFrameShape(QFrame::NoFrame);
		textScroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
		textScroll->setWidget(introLabel);
		textScroll->setWidgetResizable(true);
		layout->addWidget(textScroll);
		layout->setAlignment(Qt::AlignHCenter);
		p1->setLayout(layout);

	}

	//overview
	QWizardPage* p2 = new QWizardPage;
	{
		p2->setTitle("BioTracker 3 - Overview");
		QLabel *label = new QLabel("This is the BioTracker. Don't let yourself be overwhelmed as it is actually pretty simple.");
		label->setWordWrap(true);

		QPixmap overviewImg(":/Introduction/resources/introduction/images/BioTracker.PNG");
		QPixmap scaledImg = overviewImg.scaled(QSize(600, 400), Qt::KeepAspectRatio, Qt::SmoothTransformation);

		QLabel* imgLabel = new QLabel;
		imgLabel->setPixmap(scaledImg);
		imgLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
		//imgLabel->setScaledContents(true);

		QVBoxLayout *layout = new QVBoxLayout;
		layout->addWidget(imgLabel);
		QScrollArea* textScroll = new QScrollArea;
		textScroll->setFrameShape(QFrame::NoFrame);
		textScroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
		textScroll->setWidget(label);
		textScroll->setWidgetResizable(true);
		layout->addWidget(textScroll);
		layout->setAlignment(Qt::AlignHCenter);
		p2->setLayout(layout);
	}

	//toolbars
	QWizardPage* p3 = new QWizardPage;
	{
		p3->setTitle("BioTracker 3 - Toolbars");

		//image
		QPixmap overviewImg(":/Introduction/resources/introduction/images/toolbars.png");
		QPixmap scaledImg = overviewImg.scaled(QSize(600, 400), Qt::KeepAspectRatio, Qt::SmoothTransformation);
		QLabel* imgLabel = new QLabel;

		imgLabel->setPixmap(scaledImg);

		//read toolbar text from file
		QFile file(":/Introduction/resources/introduction/toolbars.txt");
		QLabel *label = new QLabel();
		label->setWordWrap(true);

		QString line;
		if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
			QTextStream stream(&file);
			while (!stream.atEnd()) {
				line.append(stream.readLine() + "\n");
			}
			label->setText(line);
		}
		file.close();


		QVBoxLayout *layout = new QVBoxLayout;
		layout->addWidget(imgLabel);
		QScrollArea* textScroll = new QScrollArea;
		textScroll->setFrameShape(QFrame::NoFrame);
		textScroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
		textScroll->setWidget(label);
		textScroll->setWidgetResizable(true);
		layout->addWidget(textScroll);
		layout->setAlignment(Qt::AlignHCenter);
		p3->setLayout(layout);
	}


	//right panel - overview
	QWizardPage* p4 = new QWizardPage;
	{
		p4->setTitle("BioTracker 3 - Right panel overview");

		//image
		QPixmap overviewImg(":/Introduction/resources/introduction/images/right_panel.png");
		QPixmap scaledImg = overviewImg.scaled(QSize(600, 400), Qt::KeepAspectRatio, Qt::SmoothTransformation);
		QLabel* imgLabel = new QLabel;
		imgLabel->setPixmap(scaledImg);

		//read right panel text from file
		QFile file(":/Introduction/resources/introduction/right_panel.txt");
		QLabel *label = new QLabel();
		label->setWordWrap(true);

		QString line;
		if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
			QTextStream stream(&file);
			while (!stream.atEnd()) {
				line.append(stream.readLine() + "\n");
			}
			label->setText(line);
		}
		file.close();


		QVBoxLayout *layout = new QVBoxLayout;
		layout->addWidget(imgLabel);
		QScrollArea* textScroll = new QScrollArea;
		textScroll->setFrameShape(QFrame::NoFrame);
		textScroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
		textScroll->setWidget(label);
		textScroll->setWidgetResizable(true);
		layout->addWidget(textScroll);
		layout->setAlignment(Qt::AlignHCenter);

		p4->setLayout(layout);
	}


	//how to track
	QWizardPage* p5 = new QWizardPage;
	{
		p5->setTitle("BioTracker 3 - Tracking");

		//image
		QPixmap overviewImg(":/Introduction/resources/introduction/images/tracking.png");
		QPixmap scaledImg = overviewImg.scaled(QSize(600, 400), Qt::KeepAspectRatio, Qt::SmoothTransformation);
		QLabel* imgLabel = new QLabel;
		imgLabel->setPixmap(scaledImg);

		//read tracking text from file
		QFile file(":/Introduction/resources/introduction/tracking.txt");
		QLabel *label = new QLabel();
		label->setWordWrap(true);

		QString line;
		if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
			QTextStream stream(&file);
			while (!stream.atEnd()) {
				line.append(stream.readLine() + "\n");
			}
			label->setText(line);
		}
		file.close();


		QVBoxLayout *layout = new QVBoxLayout;
		layout->addWidget(imgLabel);
		QScrollArea* textScroll = new QScrollArea;
		textScroll->setFrameShape(QFrame::NoFrame);
		textScroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
		textScroll->setWidget(label);
		textScroll->setWidgetResizable(true);
		layout->addWidget(textScroll);
		layout->setAlignment(Qt::AlignHCenter);

		p5->setLayout(layout);
	}

	//context menus
	QWizardPage* p6 = new QWizardPage;
	{
		p6->setTitle("BioTracker 3 - Context menus");

		//images
		QPixmap contextEntityImg(":/Introduction/resources/introduction/images/context_entity.png");
		QPixmap scaledImg1 = contextEntityImg.scaled(QSize(300, 400), Qt::KeepAspectRatio, Qt::SmoothTransformation);
		QLabel* imgEntityLabel = new QLabel;
		imgEntityLabel->setPixmap(scaledImg1);

		QPixmap contextVideoImg(":/Introduction/resources/introduction/images/context_video.png");
		QPixmap scaledImg2 = contextVideoImg.scaled(QSize(300, 400), Qt::KeepAspectRatio, Qt::SmoothTransformation);
		QLabel* imgVideoLabel = new QLabel;
		imgVideoLabel->setPixmap(scaledImg2);

		//read tracking text from file
		QFile file(":/Introduction/resources/introduction/context_menus.txt");
		QLabel *label = new QLabel();
		label->setWordWrap(true);

		QString line;
		if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
			QTextStream stream(&file);
			while (!stream.atEnd()) {
				line.append(stream.readLine() + "\n");
			}
			label->setText(line);
		}
		file.close();


		QVBoxLayout *outerLayout = new QVBoxLayout;
		QHBoxLayout *imgLayout = new QHBoxLayout;
		imgLayout->addWidget(imgEntityLabel);
		imgLayout->addWidget(imgVideoLabel);
		QFrame* imgFrame = new QFrame;
		imgFrame->setFrameStyle(QFrame::Panel | QFrame::Sunken);
		imgFrame->setLayout(imgLayout);

		outerLayout->addWidget(imgFrame);
		QScrollArea* textScroll = new QScrollArea;
		textScroll->setFrameShape(QFrame::NoFrame);
		textScroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
		textScroll->setWidget(label);
		textScroll->setWidgetResizable(true);
		outerLayout->addWidget(textScroll);
		outerLayout->addWidget(noShowCheck);

		outerLayout->setAlignment(Qt::AlignHCenter);

		p6->setLayout(outerLayout);
	}


	m_introWiz->addPage(p1);
	m_introWiz->addPage(p2);
	m_introWiz->addPage(p3);
	m_introWiz->addPage(p4);
	m_introWiz->addPage(p5);
	m_introWiz->addPage(p6);
	//m_introWiz->addPage(p7);


	m_introWiz->setWindowTitle("Introduction");
	if (!disabled) {
		QRect rec = QApplication::desktop()->availableGeometry();
		m_introWiz->resize(m_introWiz->width(), 500);
		m_introWiz->show();
		//m_introWiz->showMaximized();
	}
}
Ejemplo n.º 27
0
void ConfigWin::addWidgets(CityList &list)
{
    citylist = &list;
    QSharedPointer<QList<QString>> country = citylist->GetCountryList();
    for(QString str : *country) {
        cbNation.addItem(str);
    }
    QVBoxLayout *vbox = new QVBoxLayout;

    QHBoxLayout *bcb = new QHBoxLayout;
    QGridLayout *glc = new QGridLayout;
    QLabel *lbc = new QLabel(tr("Country:"));
    // lbc->setAttribute(Qt::WA_DeleteOnClose);
    lbc->setBuddy(&cbNation);
    glc->addWidget(lbc);
    glc->addWidget(&cbNation);
    bcb->addLayout(glc);
    QGridLayout *gln = new QGridLayout;
    QLabel *lbn = new QLabel(tr("City:"));
    // lbn->setAttribute(Qt::WA_DeleteOnClose);
    lbn->setBuddy(&cbCity);
    gln->addWidget(lbn);
    gln->addWidget(&cbCity);
    bcb->addLayout(gln);
    vbox->addLayout(bcb);

    QGridLayout *glci = new QGridLayout;
    QLabel *lbci = new QLabel(tr("City Information:"));
    lbci->setBuddy(&cbCityInfo);
    glci->addWidget(lbci);
    glci->addWidget(&cbCityInfo);
    vbox->addLayout(glci);

    QHBoxLayout *lbt = new QHBoxLayout;
    QGridLayout *gllang = new QGridLayout;
    QLabel *lblang = new QLabel(tr("Language:"));
    lblang->setBuddy(&cblang);
    gllang->addWidget(lblang);
    gllang->addWidget(&cblang);
    lbt->addLayout(gllang);
    QGridLayout *gltemp = new QGridLayout;
    QLabel *lbtemp = new QLabel(tr("Temperature:"));
    lbtemp->setBuddy(&cbtemp);
    gltemp->addWidget(lbtemp);
    gltemp->addWidget(&cbtemp);
    lbt->addLayout(gltemp);
    vbox->addLayout(lbt);

    for(const auto & item : WeatherLanguage) {
        cblang.addItem(item.fullName);
    }
    for(const auto & item : TemperatureType) {
        cbtemp.addItem(item.name);
    }

    QHBoxLayout *lbe = new QHBoxLayout;
    QGridLayout *glfreq = new QGridLayout;
    QLabel *lbFreq = new QLabel(tr("Update Frequency(min):"));
    lbFreq->setBuddy(&UpdateFreq);
    glfreq->addWidget(lbFreq);
    glfreq->addWidget(&UpdateFreq);
    lbe->addLayout(glfreq);
    QGridLayout *glclose = new QGridLayout;
    QLabel *lbClose = new QLabel(tr("AutoCloseWindow(s):"));
    lbClose->setAttribute(Qt::WA_DeleteOnClose);
    lbClose->setBuddy(&AutoClose);
    glclose->addWidget(lbClose);
    glclose->addWidget(&AutoClose);
    lbe->addLayout(glclose);
    vbox->addLayout(lbe);

    QHBoxLayout *lbs = new QHBoxLayout;
    QGridLayout *glapp = new QGridLayout;
    QLabel *lbAPPID = new QLabel(tr("APPID:"));
    lbAPPID->setBuddy(&APPID);
    glapp->addWidget(lbAPPID);
    glapp->addWidget(&APPID);
    lbs->addLayout(glapp);
    QGridLayout *glsubmit = new QGridLayout;

    QLabel *lbsubmit = new QLabel;// 仅用于占位
    Submit.setText(tr("Submit"));
    glsubmit->addWidget(lbsubmit);
    glsubmit->addWidget(&Submit);
    lbs->addLayout(glsubmit);
    vbox->addLayout(lbs);

    QWidget *wm = new QWidget;
    wm->setLayout(vbox);
    this->setCentralWidget(wm);

    QObject::connect(&cbNation, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
                     this, &ConfigWin::UpdateCBCity);
    QObject::connect(&cbCity, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
                     this, &ConfigWin::UpdateLBCityInfo);
    QObject::connect(&Submit, &QPushButton::clicked,
                     this, &ConfigWin::SubmitData);
}
Ejemplo n.º 28
0
void MainPanel::init()
{
    if (!db.init())
    {
        QMessageBox error;
        error.critical(0, "Error!", "An error occured while trying to load the database.");
        exit(EXIT_FAILURE);
        return;
    }

    stack = new QStackedWidget(this);

    QString style = getStylesheet(":/Styles/Content.css");
    // Prepare UI objects for each tab
    libraryPtr = new Library(db);
    libraryPtr->setStyleSheet(style);
    browserPtr = new Browser();
    browserPtr->setStyleSheet(style);
    stack->addWidget(libraryPtr);
    stack->addWidget(browserPtr);
    stack->setCurrentWidget(libraryPtr);

    // System layout
    QHBoxLayout* systemLayout = new QHBoxLayout;
    systemLayout->setSpacing(0);
    systemLayout->setMargin(8);

    // Header spacing
    QVBoxLayout* topLayout = new QVBoxLayout;
    topLayout->setMargin(0);

    // Header layout
    QHBoxLayout* headerLayout = new QHBoxLayout;
    headerLayout->setSpacing(0);
    headerLayout->setMargin(0);

    // Window title
    QLabel* windowTitle = new QLabel(this);
    windowTitle->setObjectName("windowTitle");
    windowTitle->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    windowTitle->setMinimumWidth(175);
    windowTitle->setMaximumWidth(175);
    windowTitle->setAlignment(Qt::AlignTop);
    windowTitle->setFont(QFont("Sansation", 18));
    windowTitle->setText("Project \nASCENSION");
    windowTitle->setStyleSheet("color: #7D818C;");
    windowTitle->setAttribute(Qt::WA_TransparentForMouseEvents);

    // Post-initialization header spacing
    topLayout->addLayout(systemLayout);
    topLayout->addLayout(headerLayout);
    topLayout->addSpacing(10);

    headerLayout->addSpacing(20);
    headerLayout->addWidget(windowTitle);
    headerLayout->addSpacing(40);

    // Header tabs
    libraryTab = new TabLabel(this);
    libraryTab = g_tabFactory(libraryTab, "libraryTab", "LIBRARY");
    headerLayout->addSpacing(8);
    headerLayout->addWidget(libraryTab);
    libraryTab->setStyleSheet("font-weight: bold; color: lightgreen;");

    storeTab = new TabLabel(this);
    storeTab = g_tabFactory(storeTab, "storeTab", "  STORE");
    headerLayout->addSpacing(8);
    headerLayout->addWidget(storeTab);

    modsTab = new TabLabel(this);
    modsTab = g_tabFactory(modsTab, "modsTab", " MODS");
    headerLayout->addSpacing(8);
    headerLayout->addWidget(modsTab);

    newsTab = new TabLabel(this);
    newsTab = g_tabFactory(newsTab, "newsTab", "NEWS");
    headerLayout->addSpacing(8);
    headerLayout->addWidget(newsTab);

    browserTab = new TabLabel(this);
    browserTab = g_tabFactory(browserTab, "browserTab", "BROWSER");
    headerLayout->addSpacing(8);
    headerLayout->addWidget(browserTab);

    activeTab = libraryTab;

    headerLayout->addStretch();

    // System buttons
    systemLayout->addStretch();

    // Minimize
    QPushButton* pushButtonMinimize = new QPushButton("", this);
    pushButtonMinimize->setObjectName("pushButtonMinimize");
    systemLayout->addWidget(pushButtonMinimize);
    QObject::connect(pushButtonMinimize, SIGNAL(clicked()), this, SLOT(pushButtonMinimize()));

    // Maximize
    QPushButton* pushButtonMaximize = new QPushButton("", this);
    pushButtonMaximize->setObjectName("pushButtonMaximize");
    systemLayout->addWidget(pushButtonMaximize);
    QObject::connect(pushButtonMaximize, SIGNAL(clicked()), this, SLOT(pushButtonMaximize()));

    // Close
    QPushButton* pushButtonClose = new QPushButton("", this);
    pushButtonClose->setObjectName("pushButtonClose");
    systemLayout->addWidget(pushButtonClose);
    QObject::connect(pushButtonClose, SIGNAL(clicked()), this, SLOT(pushButtonClose()));

    // Main panel layout
    QGridLayout* mainGridLayout = new QGridLayout();
    mainGridLayout->setSpacing(0);
    mainGridLayout->setMargin(0);
    setLayout(mainGridLayout);

    // Central widget
    QWidget* centralWidget = new QWidget(this);
    centralWidget->setObjectName("centralWidget");
    centralWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);

    // Main panel scroll area
    QScrollArea* scrollArea = new QScrollArea(this);
    scrollArea->setWidgetResizable(true);
    scrollArea->setObjectName("mainPanelScrollArea");
    scrollArea->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);

    // Vertical layout example
    QVBoxLayout* verticalLayout = new QVBoxLayout();
    verticalLayout->setSpacing(5);
    verticalLayout->setMargin(0);
    verticalLayout->setAlignment(Qt::AlignHCenter);
    verticalLayout->addLayout(topLayout, 1);

    verticalLayout->addWidget(stack, 4);

    // Connect signals
    connect(libraryTab, SIGNAL(clicked()), this, SLOT(setTabLibrary()));
    connect(browserTab, SIGNAL(clicked()), this, SLOT(setTabBrowser()));

    // Show
    centralWidget->setLayout(verticalLayout);
    scrollArea->setWidget(centralWidget);
    mainGridLayout->addWidget(scrollArea);
}
Ejemplo n.º 29
0
LibraryTypePage::LibraryTypePage(AddLibraryWizard *parent)
    : QWizardPage(parent)
{
    setTitle(tr("Library Type"));
    setSubTitle(tr("Choose the type of the library to link to"));

    QVBoxLayout *layout = new QVBoxLayout(this);

    m_internalRadio = new QRadioButton(tr("Internal library"), this);
    layout->addWidget(m_internalRadio);

    QLabel *internalLabel = new QLabel(tr("Links to a library "
                                    "that is located in your build "
                                    "tree.\nAdds the library and "
                                    "include paths to the .pro file."));

    internalLabel->setWordWrap(true);
    internalLabel->setAttribute(Qt::WA_MacSmallSize, true);
    layout->addWidget(internalLabel);

    m_externalRadio = new QRadioButton(tr("External library"), this);
    layout->addWidget(m_externalRadio);

    QLabel *externalLabel = new QLabel(tr("Links to a library "
                                    "that is not located in your "
                                    "build tree.\nAdds the library "
                                    "and include paths to the .pro file."));

    externalLabel->setWordWrap(true);
    externalLabel->setAttribute(Qt::WA_MacSmallSize, true);
    layout->addWidget(externalLabel);

    m_systemRadio = new QRadioButton(tr("System library"), this);
    layout->addWidget(m_systemRadio);

    QLabel *systemLabel = new QLabel(tr("Links to a system library."
                                    "\nNeither the path to the "
                                    "library nor the path to its "
                                    "includes is added to the .pro file."));

    systemLabel->setWordWrap(true);
    systemLabel->setAttribute(Qt::WA_MacSmallSize, true);
    layout->addWidget(systemLabel);

    m_packageRadio = new QRadioButton(tr("System package"), this);
    layout->addWidget(m_packageRadio);

    QLabel *packageLabel = new QLabel(tr("Links to a system library using pkg-config."));

    packageLabel->setWordWrap(true);
    packageLabel->setAttribute(Qt::WA_MacSmallSize, true);
    layout->addWidget(packageLabel);

    if (Utils::HostOsInfo::isWindowsHost()) {
        m_packageRadio->setVisible(false);
        packageLabel->setVisible(false);
    }

    // select the default
    m_internalRadio->setChecked(true);

    setProperty(Utils::SHORT_TITLE_PROPERTY, tr("Type"));
}
Ejemplo n.º 30
0
NewGeneMainWindow::NewGeneMainWindow(QWidget * parent) :
	QMainWindow(parent),
	NewGeneWidget(WidgetCreationInfo(this,
									 WIDGET_NATURE_GENERAL)),   // 'this' pointer is cast by compiler to proper Widget instance, which is already created due to order in which base classes appear in class definition
	ui(new Ui::NewGeneMainWindow),
	messager(parent),
	theSplash(nullptr),
	newInputDataset(false),
	newOutputDataset(false)
{

	NewGeneWidget::theMainWindow = this;

	connect(&messager, SIGNAL(DisplayMessageBox(STD_STRING)), this, SLOT(SignalMessageBox(STD_STRING)));

	try
	{

		// Instantiate Managers in main thread
		UIStatusManager::getManager(&messager);
		UIDocumentManager::getManager(&messager);
		UILoggingManager::getManager(&messager);
		UISettingsManager::getManager(&messager);
		UIModelManager::getManager(&messager);
		UIProjectManager::getManager(&messager);
		UIThreadManager::getManager(&messager);
		UITriggerManager::getManager(&messager);
		UIUIDataManager::getManager(&messager);
		UIUIActionManager::getManager(&messager);
		UIModelActionManager::getManager(&messager);

		UIMessager::ManagersInitialized = true;

		ui->setupUi(this);

		QLabel * labelLoadingSpinner { findChild<QLabel *>("labelLoadingSpinner") };

		if (labelLoadingSpinner)
		{
			QMovie * movieLoadingSpinner = new QMovie(":/bluespinner.gif");
			labelLoadingSpinner->setMask((new QPixmap(":/bluespinner.gif"))->mask());
			labelLoadingSpinner->setAttribute(Qt::WA_TranslucentBackground);
			labelLoadingSpinner->setMovie(movieLoadingSpinner);
			movieLoadingSpinner->start();
		}

		NewGeneTabWidget * pTWmain = findChild<NewGeneTabWidget *>("tabWidgetMain");

		if (pTWmain)
		{
			pTWmain->NewGeneUIInitialize();
		}

	}
	catch (boost::exception & e)
	{

		if (std::string const * error_desc = boost::get_error_info<newgene_error_description>(e))
		{
			boost::format msg(error_desc->c_str());
			QMessageBox msgBox;
			msgBox.setText(msg.str().c_str());
			msgBox.exec();
		}
		else
		{
			std::string the_error = boost::diagnostic_information(e);
			boost::format msg("Error: %1%");
			msg % the_error.c_str();
			QMessageBox msgBox;
			msgBox.setText(msg.str().c_str());
			msgBox.exec();
		}

		QCoreApplication::exit(-1);

	}
	catch (std::exception & e)
	{

		boost::format msg("Exception thrown: %1%");
		msg % e.what();
		QCoreApplication::exit(-1);

	}

}