예제 #1
0
파일: MainMenu.cpp 프로젝트: izissise/PFA
void	MainMenu::construct(const sf::Texture &texture, Settings &set,
			    const std::vector<APanelScreen *> &panels)
{
  Widget	*wBackground = new Widget("background", {0, 0, SIZEX, SIZEY});
  Widget	*wMback = new Widget("menuback", {30, 100, 300, 600});
  Widget	*wMenuTitle = new Widget("menu-title", {30, 100, 300, 70},
  					 sf::Text("MAIN", _font["default"], 40));
  Widget	*wPlay = new Widget("play", {50, 200, 260, 60},
  				    sf::Text("PLAY ONLINE", _font["default"], 30));
  Widget	*wOpt = new Widget("opt", {50, 280, 260, 60},
				   sf::Text("OPTION", _font["default"], 30));
  Widget	*wQuit = new Widget("quit", {50, 360, 260, 60},
				    sf::Text("QUIT", _font["default"], 30));

  createBgPanel(texture, wBackground, wMback, wMenuTitle);
  createPlayButton(wPlay);
  createOptButton(wOpt);
  createQuitButton(wQuit);

  wPlay->addObserver(this);
  wPlay->addObserver(panels[1]);
  wOpt->addObserver(panels[0]);

  _widgets.push_back(wBackground);
  _widgets.push_back(wMback);
  _widgets.push_back(wMenuTitle);
  _widgets.push_back(wPlay);
  _widgets.push_back(wOpt);
  _widgets.push_back(wQuit);
  resizeWidgets({std::stof(set.getCvarList().getCvar("r_width")),
	std::stof(set.getCvarList().getCvar("r_height"))});
}
예제 #2
0
void ImageViewer::setText(const QString& text) {
    QFont labelFont;
    labelFont.setPointSize(24);
    labelFont.setItalic(true);
    imageLabel->setText(text);
    imageLabel->setAlignment(Qt::AlignCenter);
    imageLabel->setFont(labelFont);
    resizeWidgets();
}
예제 #3
0
파일: mainwindow.cpp 프로젝트: Dgzt/ketris
void MainWindow::paintEvent( QPaintEvent* pe )
{
    QWidget::paintEvent( pe );
	
	//If the window was resized, then resize the main window's widgets
	if( windowResized ){
		//Becouse no resize the widgets again at the next if block
		statusBarVisible = statusBar()->isVisible();
		
		resizeWidgets();
		windowResized = false;
	}
	
	//If change the statusbar's status, then resize the widgets
	if( statusBarVisible != statusBar()->isVisible() ){
		statusBarVisible = statusBar()->isVisible();
		
		resizeWidgets();
	}
}
예제 #4
0
void ImageViewer::loadFile(const QString &fileName, const QString& extension, bool loadInfo) {
    fileName_ = fileName;
    extension_ = extension.trimmed().toLower();

    clearWidgets();
    
    if(fileName.isEmpty() || extension.isEmpty()) return;
    
    if (!QFileInfo(fileName).exists()) {
        setText(notFoundMessage_); 
        return;
    }
    
    if (loadInfo) {
        if (extension_ == "mrc" || extension_ == "map" || extension_ == "mrcs") {
            mrcHeader header(fileName);
            mrcInfo->setHeader(fileName, header);
            widgets->setCurrentWidget(mrcInfo);
        } else {
            fileInfo->setFile(fileName);
            widgets->setCurrentWidget(fileInfo);
        }
    } else {
        QImage image;
        if (extension_ == "mrc") {
            
            //Check if a png preview is available
            if(QFileInfo(fileName+".png").exists()) {
                if(QFileInfo(fileName).lastModified().toMSecsSinceEpoch() <= QFileInfo(fileName+".png").lastModified().toMSecsSinceEpoch()) {
                    image = QImage(fileName+".png");
                } else {
                    qDebug() << fileName << "had PNG, but is older, Time(MRC, PNG): " << QFileInfo(fileName).lastModified().toMSecsSinceEpoch() << QFileInfo(fileName+".png").lastModified().toMSecsSinceEpoch();
                    mrcImage tempImage(fileName);
                    image = *(tempImage.getImage());
                }
            } else {
                mrcImage tempImage(fileName);
                image = *(tempImage.getImage());
            }
        } else {
            image = QImage(fileName);
        }

        if (image.isNull()) {
            setNotSupportedText();
            return;
        }
        imageLabel->setPixmap(QPixmap::fromImage(image));
        resizeWidgets();
    }
}
예제 #5
0
void GraphicalBoardFrame::expandToSize(const QSize &maxSize)
{
    m_maxSize = maxSize;

    // if empty we delay this call
    if (m_boardSize.isEmpty())
        return;
    else
    {
        // TODO we get here too often while resizing

        // do calculations in terms of one axis, arbitrarily, width
        QSize lastCandidate;
        QSize candidate(0, 0);
        do
        {
            lastCandidate = candidate;
            candidate += m_boardSize;
        }
        while (candidate.width() < m_maxSize.width() && candidate.height() < m_maxSize.height());

        const int maxWidth = lastCandidate.width();

        const double numBlocksWidthwise = ((double)m_boardSize.width() + s_markOtherLengthMultiplier);

        m_sideLength = (int)floor((maxWidth - frameWidth() * 2) / numBlocksWidthwise);

        if (m_sideLength < 0)
            m_sideLength = 0;

        resizeWidgets(m_sideLength);

        const int shorterMarkWidth = markAt(QSize(0, 0))->size().width();
        const int shorterMarkHeight = markAt(QSize(0, 0))->size().height();
        m_tilesOffset.setX(shorterMarkWidth);
        m_tilesOffset.setY(shorterMarkHeight);

        m_sizeForBoard.setWidth(shorterMarkWidth + m_boardSize.width() * m_sideLength);
        m_sizeForBoard.setHeight(shorterMarkHeight + m_boardSize.height() * m_sideLength);
        setMaximumSize(m_sizeForBoard + QSize(frameWidth() * 2, frameWidth() * 2));

        prepare();
    }
}
예제 #6
0
DescrGeneratorInterface::DescrGeneratorInterface (QWidget* parent, MainWindow* window) :
    QWidget(parent),
    parentWindow(window),
    labelMainTemplate(new QLabel("Main Template", this)),
    editMainTemplate(new QLineEdit(this)),
    buttonMainTemplate(new QPushButton("Apri", this)),
    labelResourcesTemplate(new QLabel("Res. Template", this)),
    editResourcesTemplate(new QLineEdit(this)),
    buttonResourcesTemplate(new QPushButton("Apri", this)),
    labelVideoResourcesTemplate(new QLabel("Video Res. Template", this)),
    editVideoResourcesTemplate(new QLineEdit(this)),
    buttonVideoResourcesTemplate(new QPushButton("Apri", this)),
    labelVideoTemplate(new QLabel("Video Template", this)),
    editVideoTemplate(new QLineEdit(this)),
    buttonVideoTemplate(new QPushButton("Apri", this)),
    labelCatMerc(new QLabel("Cat. Merc.", this)),
    editCatMerc(new QLineEdit(this)),
    labelNatura(new QLabel("Natura", this)),
    editNatura(new QLineEdit(this)),
    labelFile(new QLabel("File destinazione", this)),
    editFile(new QLineEdit(this)),
    buttonFile(new QPushButton("Scegli", this)),
    buttonCrea(new QPushButton("Crea", this)),
    layoutButton(new QHBoxLayout),
    gridLayout(new QGridLayout(this)),
    progress(new QProgressBar(this)),
    worker_thread(0),
    generator(0)
{
    setLayout(gridLayout);

    resizeWidgets();
    layoutWidgets();
    connectWidgets();
    loadConfig();
}
예제 #7
0
void ImageViewer::resizeEvent(QResizeEvent* event) {
    QFrame::resizeEvent(event);
    resizeWidgets();
}