Example #1
0
void QSysMessagePanel::initUI()
{
    QWidget     *headw = new QWidget(this);
    IconButton  *closeB = QAppUtils::ref().getCloseIconBtn(headw);
    QHBoxLayout *headLay = new QHBoxLayout(headw);
    QWidget     *center = new QWidget(this);
    QWidget     *msgWid = new QWidget(center);
    QScrollArea *scroll = new QScrollArea(this);
    QVBoxLayout *vlay = new QVBoxLayout(this);
    QVBoxLayout *vlayMsg = new QVBoxLayout(center);
    int         width,height;


    vlay->setContentsMargins(0,0,0,0);
    vlayMsg->addWidget(msgWid);
    vlayMsg->addStretch();

    QAppUtils::ref().getScreenSize(width,height);
    center->setMinimumSize(width/4.1,height/1.3);
    scroll->setBackgroundRole(QPalette::Dark);
    scroll->setWidget(center);
    scroll->setMinimumSize(width/4,height/1.2);

    headLay->addStretch();
    headLay->addWidget(closeB);
    connect(closeB,SIGNAL(clicked()),this,SLOT(close()));
    m_lay = new QGridLayout(msgWid);
    m_lay->setContentsMargins(0,0,0,0);
    vlay->addWidget(headw);
    vlay->addWidget(scroll);
    vlay->addStretch();
}
EventVideoDownloadsWindow::EventVideoDownloadsWindow(QWidget *parent) :
    QFrame(parent)
{
    setAttribute(Qt::WA_DeleteOnClose, true);
    setMinimumSize(550, 300);
	setWindowTitle(tr("Bluecherry - Download Manager"));

    QVBoxLayout *layout = new QVBoxLayout(this);
    layout->setSpacing(2);
    layout->setMargin(2);

    QScrollArea *downloadArea = new QScrollArea(this);
    downloadArea->setBackgroundRole(QPalette::Base );
    downloadArea->move(0, 0);
    layout->addWidget(downloadArea);

    QFrame *downloadFrame = new QFrame;
    downloadFrame->setBackgroundRole(QPalette::Base);
    downloadFrame->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);

    m_downloadLayout = new QVBoxLayout(downloadFrame);
    m_downloadLayout->setDirection(QBoxLayout::Up);

    downloadArea->setWidget(downloadFrame);
    downloadArea->setWidgetResizable(true);

    QSettings settings;
    restoreGeometry(settings.value(QLatin1String("ui/downloadsWindow/geometry")).toByteArray());

    connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(saveSettings()));
}
Example #3
0
ImageWidget::ImageWidget(QWidget *parent) :
	QWidget(parent),
	m_stack(new QUndoStack(this)),
	m_filePath(QString()),
	m_imageLabel(new QLabel(this)),
	m_magnification(1.),
	m_flagAutoImageResize(true)
{
	// m_stack->setUndoLimit(5);	// 別に制限しなくていいんじゃね?
	connect(m_stack, SIGNAL(canUndoChanged(bool)), this, SIGNAL(canUndoChanged(bool)));
	connect(m_stack, SIGNAL(canRedoChanged(bool)), this, SIGNAL(canRedoChanged(bool)));
	connect(m_stack, SIGNAL(cleanChanged(bool)), this, SIGNAL(cleanChanged(bool)));
	connect(m_stack, SIGNAL(undoTextChanged(QString)), this, SIGNAL(undoTextChanged(QString)));
	connect(m_stack, SIGNAL(redoTextChanged(QString)), this, SIGNAL(redoTextChanged(QString)));

	m_imageLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
	QVBoxLayout *layout = new QVBoxLayout(this);
	layout->setMargin(0);
	QScrollArea *scrollArea = new QScrollArea(this);
	scrollArea->setWidgetResizable(true);
	scrollArea->setBackgroundRole(QPalette::Midlight);
	scrollArea->setWidget(m_imageLabel);
	layout->addWidget(scrollArea);
	setLayout(layout);
}
Example #4
0
Save::Save(QWidget *parent) : QDialog(parent)
{
	img = 0;
	setModal(false);
	setWindowFlags(Qt::Window);

	QHBoxLayout *layout = new QHBoxLayout(this);

	QVBoxLayout *sLayout = new QVBoxLayout;
	layout->addLayout(sLayout);

	QGroupBox *gbBlock = new QGroupBox(tr("Block size"));
	sLayout->addWidget(gbBlock);
	QHBoxLayout *gbBlockLayout = new QHBoxLayout(gbBlock);
	gbBlockLayout->addWidget(spBlockSize[0] = new QSpinBox);
	gbBlockLayout->addWidget(new QLabel(tr("x")));
	gbBlockLayout->addWidget(spBlockSize[1] = new QSpinBox);
	for (int i = 0; i != 2; i++) {
		spBlockSize[i]->setMinimum(1);
		spBlockSize[i]->setMaximum(2048);
		spBlockSize[i]->setValue(DEFSZ);
	}

	QGroupBox *gbCount = new QGroupBox(tr("Block count"));
	sLayout->addWidget(gbCount);
	QHBoxLayout *gbCountLayout = new QHBoxLayout(gbCount);
	gbCountLayout->addWidget(spBlockCount[0] = new QSpinBox);
	gbCountLayout->addWidget(new QLabel(tr("x")));
	gbCountLayout->addWidget(spBlockCount[1] = new QSpinBox);
	for (int i = 0; i != 2; i++) {
		spBlockCount[i]->setMinimum(1);
		spBlockCount[i]->setMaximum(1000);
		spBlockCount[i]->setValue(DEFCNT);
	}

	sLayout->addWidget(lFinalRes = new QLabel);

	QPushButton *pbRender = new QPushButton(tr("Render"));
	sLayout->addWidget(pbRender);

	QPushButton *pbSave = new QPushButton(tr("Save image"));
	sLayout->addWidget(pbSave);

	layout->addWidget(lwProgess = new QListWidget);

	QScrollArea *saOutput = new QScrollArea;
	saOutput->setBackgroundRole(QPalette::Dark);
	saOutput->setWidget(lOutput = new QLabel);
	layout->addWidget(saOutput, 4);

	for (int i = 0; i != 2; i++) {
		connect(spBlockSize[i], SIGNAL(valueChanged(int)), this, SLOT(updateRes()));
		connect(spBlockCount[i], SIGNAL(valueChanged(int)), this, SLOT(updateRes()));
	}
	connect(pbRender, SIGNAL(clicked(bool)), this, SLOT(render()));
	connect(pbSave, SIGNAL(clicked(bool)), this, SLOT(save()));
	updateRes();
}
void DenoisingWidget::on_pbPrepare_clicked()
{
    // prepare widget
    cleanWidget();

    QLayout *layout;
    if (Constants::showThresholdsWidgetSeparately) {
        QScrollArea* scrollArea = new QScrollArea();
        scrollArea->setBackgroundRole(QPalette::Window);
        scrollArea->setFrameShadow(QFrame::Plain);
        scrollArea->setFrameShape(QFrame::NoFrame);
        scrollArea->setWidgetResizable(true);

        QWidget* wdg = new QWidget();
        wdg->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
        wdg->setLayout(new QVBoxLayout(wdg));
        scrollArea->setWidget(wdg);
        scrollArea->show();

        layout = wdg->layout();
    } else {
        if (!ui->scrollAreaWidgetContents->layout()) {
            ui->scrollAreaWidgetContents->setLayout(new QVBoxLayout());
        }

        layout = ui->scrollAreaWidgetContents->layout();
    }

    // prepare signal (wavelet transform)
    m_denoisingManager->setSignal(*m_noisedAudioSignal.data());
    m_denoisingManager->prepareToDenoising(ui->cbWaveletType->currentText(), ui->sbLevel->value());
    PlotManager::plot(ui->inputTransformedSignalWidget, m_denoisingManager->transformedSignal());

    auto decomposition = m_denoisingManager->transformedDecomposition();
    m_itemsCount = decomposition.size();

    // initialize thresholds widgets
    for (auto item : decomposition) {
        auto wdg = new ThresholdsWidget(this);
        m_widgets.push_back(wdg);
        wdg->setSignalSource(item);
        layout->addWidget(wdg);
    }

    Q_ASSERT(m_itemsCount == m_widgets.size());
}
Example #6
0
GenericHistogramWindow::GenericHistogramWindow(GenericHistogramView* view) : _view(view)
{
    QScrollArea* scrollArea = new QScrollArea();
    scrollArea->setWidget(_view);
    scrollArea->setBackgroundRole(QPalette::Dark);
    scrollArea->setAlignment(Qt::AlignCenter);

    initStatusBar();

    QVBoxLayout* layout = new QVBoxLayout();
    layout->addWidget(_view->getGraphicalHistogram());
    layout->addWidget(_statusBar);
    this->setLayout(layout);

    connect(_view, SIGNAL(leftClickedValue(int, std::vector<int>)), this, SLOT(showLeftClickedValue(int, std::vector<int>)));
    connect(_view, SIGNAL(rightClickedValue(int, std::vector<int>)), this, SLOT(showRightClickedValue(int, std::vector<int>)));
    connect(_view, SIGNAL(hoveredValue(int, std::vector<int>)), this, SLOT(showHoveredValue(int, std::vector<int>)));
}
MainWindow::MainWindow(QWidget* parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    imageViewer = new ImageViewer(this);
    connect(imageViewer, SIGNAL(imageUpdated()), this, SLOT(updateTitle()));

    QScrollArea* scrollArea = new QScrollArea(this);
    scrollArea->setBackgroundRole(QPalette::NoRole);
    scrollArea->setWidget(imageViewer);
    this->setCentralWidget(scrollArea);

    setupToolbar();
    setWindowTitle(QString("%1 %2").arg(PROGRAM_NAME).arg(PROGRAM_VER));

    if (QFile(DEFAULT_IMG).exists())
        loadImage(DEFAULT_IMG);
}
Example #8
0
void MainWindow::initializeNewTab(const bool &isOpen, const QString &filePath)
{
    ImageArea *imageArea;
    QString fileName(tr("Untitled Image"));
    if(isOpen && filePath.isEmpty())
    {
        imageArea = new ImageArea(isOpen, "", this);
        fileName = imageArea->getFileName();
    }
    else if(isOpen && !filePath.isEmpty())
    {
        imageArea = new ImageArea(isOpen, filePath, this);
        fileName = imageArea->getFileName();
    }
    else
    {
        imageArea = new ImageArea(false, "", this);
    }
    if (!imageArea->getFileName().isNull())
    {
        QScrollArea *scrollArea = new QScrollArea();
        scrollArea->setAttribute(Qt::WA_DeleteOnClose);
        scrollArea->setBackgroundRole(QPalette::Dark);
        scrollArea->setWidget(imageArea);

        mTabWidget->addTab(scrollArea, fileName);
        mTabWidget->setCurrentIndex(mTabWidget->count()-1);

        mUndoStackGroup->addStack(imageArea->getUndoStack());
        connect(imageArea, SIGNAL(sendPrimaryColorView()), mToolbar, SLOT(setPrimaryColorView()));
        connect(imageArea, SIGNAL(sendSecondaryColorView()), mToolbar, SLOT(setSecondaryColorView()));
        connect(imageArea, SIGNAL(sendRestorePreviousInstrument()), this, SLOT(restorePreviousInstrument()));
        connect(imageArea, SIGNAL(sendSetInstrument(InstrumentsEnum)), this, SLOT(setInstrument(InstrumentsEnum)));
        connect(imageArea, SIGNAL(sendNewImageSize(QSize)), this, SLOT(setNewSizeToSizeLabel(QSize)));
        connect(imageArea, SIGNAL(sendCursorPos(QPoint)), this, SLOT(setNewPosToPosLabel(QPoint)));
        connect(imageArea, SIGNAL(sendColor(QColor)), this, SLOT(setCurrentPipetteColor(QColor)));
        connect(imageArea, SIGNAL(sendEnableCopyCutActions(bool)), this, SLOT(enableCopyCutActions(bool)));
        connect(imageArea, SIGNAL(sendEnableSelectionInstrument(bool)), this, SLOT(instumentsAct(bool)));

        setWindowTitle(QString("%1 - EasyPaint").arg(fileName));
    }
Example #9
0
DvbEpgDialog::DvbEpgDialog(DvbManager *manager_, QWidget *parent) : KDialog(parent),
	manager(manager_)
{
	setButtons(KDialog::Close);
	setCaption(i18nc("@title:window", "Program Guide"));

	QWidget *widget = new QWidget(this);
	QBoxLayout *mainLayout = new QHBoxLayout(widget);

	epgChannelTableModel = new DvbEpgChannelTableModel(this);
	epgChannelTableModel->setManager(manager);
	channelView = new QTreeView(widget);
	channelView->setMaximumWidth(30 * fontMetrics().averageCharWidth());
	channelView->setModel(epgChannelTableModel);
	channelView->setRootIsDecorated(false);
	channelView->setUniformRowHeights(true);
	connect(channelView->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
		this, SLOT(channelActivated(QModelIndex)));
	mainLayout->addWidget(channelView);

	QBoxLayout *rightLayout = new QVBoxLayout();
	QBoxLayout *boxLayout = new QHBoxLayout();

	KAction *scheduleAction = new KAction(QIcon::fromTheme(QLatin1String("media-record")),
		i18nc("@action:inmenu tv show", "Record Show"), this);
	connect(scheduleAction, SIGNAL(triggered()), this, SLOT(scheduleProgram()));

	QPushButton *pushButton =
		new QPushButton(scheduleAction->icon(), scheduleAction->text(), widget);
	connect(pushButton, SIGNAL(clicked()), this, SLOT(scheduleProgram()));
	boxLayout->addWidget(pushButton);

	boxLayout->addWidget(new QLabel(i18nc("@label:textbox", "Search:"), widget));

	epgTableModel = new DvbEpgTableModel(this);
	epgTableModel->setEpgModel(manager->getEpgModel());
	connect(epgTableModel, SIGNAL(layoutChanged()), this, SLOT(checkEntry()));
	KLineEdit *lineEdit = new KLineEdit(widget);
	lineEdit->setClearButtonShown(true);
	connect(lineEdit, SIGNAL(textChanged(QString)),
		epgTableModel, SLOT(setContentFilter(QString)));
	boxLayout->addWidget(lineEdit);
	rightLayout->addLayout(boxLayout);

	epgView = new QTreeView(widget);
	epgView->addAction(scheduleAction);
	epgView->header()->setResizeMode(QHeaderView::ResizeToContents);
	epgView->setContextMenuPolicy(Qt::ActionsContextMenu);
	epgView->setMinimumWidth(75 * fontMetrics().averageCharWidth());
	epgView->setModel(epgTableModel);
	epgView->setRootIsDecorated(false);
	epgView->setUniformRowHeights(true);
	connect(epgView->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
		this, SLOT(entryActivated(QModelIndex)));
	rightLayout->addWidget(epgView);

	contentLabel = new QLabel(widget);
	contentLabel->setAlignment(Qt::AlignLeft | Qt::AlignTop);
	contentLabel->setMargin(5);
	contentLabel->setWordWrap(true);

	QScrollArea *scrollArea = new QScrollArea(widget);
	scrollArea->setBackgroundRole(QPalette::Light);
	scrollArea->setMinimumHeight(12 * fontMetrics().height());
	scrollArea->setWidget(contentLabel);
	scrollArea->setWidgetResizable(true);
	rightLayout->addWidget(scrollArea);
	mainLayout->addLayout(rightLayout);
	setMainWidget(widget);
}
Example #10
0
void FeatureEval::initialize2(PluginManager * pm) {
    ne_ = pm->findPlugin<NormalEstimator>();
    if (ne_ == nullptr) {
        qDebug() << "Normal estimator plugin needed for normal viz";
        return;
    }

    // GUI STUFF
    visualise_on_ = true;
    function_idx_ = 0;
    layer_idx_ = -1;

    // PARAMS
    subsample_res_ = 0.1;
    subsample_res_2_ = 0.2;
    search_radius_ = 0.2;
    max_nn_ = 20;
    bins_ = 20;

    // Set up viz tab
    depth_widget_ = new QWidget(0);
    tab_idx_ = core_->mw_->addTab(depth_widget_, "Feature visualisation");

    QVBoxLayout * tablayout = new QVBoxLayout(depth_widget_);
    QScrollArea * scrollarea = new QScrollArea();
    scrollarea->setBackgroundRole(QPalette::Dark);
    tablayout->addWidget(scrollarea);
    image_container_ = new QLabel();
    scrollarea->setWidget(image_container_);


    // set up settings
    is_enabled_ = false;
    enable_ = new QAction(QIcon(":/images/featureeval.png"), "Correlate and visualise", 0);
    enable_->setCheckable(true);

    connect(enable_, SIGNAL(triggered()), this, SLOT(enable()));
    mw_->toolbar_->addAction(enable_);
    time = 0;
    settings_ = new QWidget();
    QVBoxLayout * layout = new QVBoxLayout(settings_);
    settings_->setLayout(layout);
    mw_->tooloptions_->addWidget(settings_);

    // settings widgets
    layout->addWidget(new QLabel("Feature"));
    feature_cb_ = new QComboBox(settings_);
    layout->addWidget(feature_cb_);

    // round up parameters
    param_map_["subsample_res"].f = &subsample_res_;
    param_map_["subsample_res.small"].f = &subsample_res_;
    param_map_["subsample_res.big"].f = &subsample_res_2_;
    param_map_["bins"].i =  &bins_;
    param_map_["search_radius"].f = &search_radius_;
    param_map_["max_nn"].i = &max_nn_;

    // round up functions
    feature_cb_->addItem("Difference of normals", (int)functions_.size());
    functions_.push_back(std::bind(&FeatureEval::difference_of_normals, this));
    name_to_function_["difference_of_normals"] = functions_[functions_.size()-1];

    feature_cb_->addItem("intensity_histogram", (int)functions_.size());
    functions_.push_back(std::bind(&FeatureEval::intensity_histogram, this));
    name_to_function_["intensity_histogram"] = functions_[functions_.size()-1];

    feature_cb_->addItem("Fast point feature histograms", (int)functions_.size());
    functions_.push_back(std::bind(&FeatureEval::fast_point_feature_histogram, this));
    name_to_function_["fast_point_feature_histogram"] = functions_[functions_.size()-1];

    feature_cb_->addItem("Curvature", (int)functions_.size());
    functions_.push_back(std::bind(&FeatureEval::curvature, this));
    name_to_function_["curvature"] = functions_[functions_.size()-1];

    feature_cb_->addItem("Distance standard deviation", (int)functions_.size());
    functions_.push_back(std::bind(&FeatureEval::distance_standard_deviation, this));
    name_to_function_["distance_standard_deviation"] = functions_[functions_.size()-1];

    feature_cb_->addItem("Normal standard deviation", (int)functions_.size());
    functions_.push_back(std::bind(&FeatureEval::normal_standard_deviation, this));
    name_to_function_["normal_standard_deviation"] = functions_[functions_.size()-1];

    feature_cb_->addItem("Eigen ratio", (int)functions_.size());
    functions_.push_back(std::bind(&FeatureEval::pca_eigen_value_ratio, this));
    name_to_function_["pca_eigen_value_ratio"] = functions_[functions_.size()-1];

    feature_cb_->addItem("PCA", (int)functions_.size());
    functions_.push_back(std::bind(&FeatureEval::pca, this));
    name_to_function_["pca"] = functions_[functions_.size()-1];

    feature_cb_->addItem("eigen_plane_consine_similarity", (int)functions_.size());
    functions_.push_back(std::bind(&FeatureEval::eigen_plane_consine_similarity, this));
    name_to_function_["eigen_plane_consine_similarity"] = functions_[functions_.size()-1];

    feature_cb_->addItem("intensity", (int)functions_.size());
    functions_.push_back(std::bind(&FeatureEval::intensity, this));
    name_to_function_["intensity"] = functions_[functions_.size()-1];

//    layout->addWidget(new QLabel("Correlate with layer:"));
//    layer_cb_ = new QComboBox(settings_);
//    layout->addWidget(layer_cb_);


    // Downsample settings
    QDoubleSpinBox * downsample_sb = new QDoubleSpinBox();
    downsample_sb->setAccelerated(true);
    downsample_sb->setMinimum(0.001);
    downsample_sb->setMaximum(1);
    downsample_sb->setValue(subsample_res_);
    connect(downsample_sb, static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), [=] (double value){
        subsample_res_ = value;
    });

    layout->addWidget(new QLabel("Downsample resolution (meters)"));
    layout->addWidget(downsample_sb);


    QDoubleSpinBox * downsample_sb2 = new QDoubleSpinBox();
    downsample_sb2->setAccelerated(true);
    downsample_sb2->setMinimum(0.001);
    downsample_sb2->setMaximum(1);
    downsample_sb2->setValue(subsample_res_2_);
    connect(downsample_sb2, static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), [=] (double value){
        subsample_res_2_ = value;
    });

    QLabel * sb2_label = new QLabel("Downsample resolution 2 (meters)");
    layout->addWidget(sb2_label);
    layout->addWidget(downsample_sb2);

    // feature change
    connect(feature_cb_, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [=] (int idx){
        function_idx_ = feature_cb_->itemData(idx).toInt();
        sb2_label->setVisible(function_idx_ == 0);
        downsample_sb2->setVisible(function_idx_ == 0);
        qDebug() << "changed";
    });

    // Run button
    QPushButton * run = new QPushButton("Correlate and visualise");
    connect(run, &QPushButton::clicked, [=] (){
        if(function_idx_ != -1){
            qDebug() << "call!";
            functions_[function_idx_]();
        }

    });
    layout->addWidget(run);

    layout->addStretch();

    connect(ll_, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(layersModified()));
}
Example #11
0
CRunGui::CRunGui():Env()
{
	//Env=new CEnvironment();

	//setting of central widget of the window
    QWidget *mainWidget = new QWidget;
    setCentralWidget(mainWidget);

	newEnvDialog = new NewEnvDialog (this);


	//non-gui attributes:
//	Env=NULL;Env is now non dynamic attribute.
//	emit envIsEmpty(true); No need
	NumSteps=-1;
	
	Timer = new QTimer(this);
	connect(Timer,SIGNAL(timeout()),this,SLOT(make1Step()));
	
	//ComboBox - Type of view
	QLabel *typeViewLabel = new QLabel(tr("Type of view: "));
	typeViewLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); 

	TypeViewCombo = new QComboBox;
	TypeViewCombo->addItem(TYPE_VIEW_1);
    TypeViewCombo->addItem(TYPE_VIEW_2);
    TypeViewCombo->addItem(TYPE_VIEW_3);
    TypeViewCombo->addItem(TYPE_VIEW_4);
    TypeViewCombo->addItem(TYPE_VIEW_5);
    TypeViewCombo->addItem(TYPE_VIEW_6);
    TypeViewCombo->addItem(TYPE_VIEW_7);


	TypeViewCombo->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);

	 QVBoxLayout * typeViewLayout= new QVBoxLayout();
	 typeViewLayout->addWidget(typeViewLabel);
	 typeViewLayout->addWidget(TypeViewCombo);
	 //typeViewLayout->addStretch(1);
	
	//Field
	Field= new CField(&Env);

    connect(TypeViewCombo, SIGNAL(currentIndexChanged(const QString &)),Field, SLOT(setTypeView(const QString &)));
	connect(this,SIGNAL(envChanged()),Field,SLOT(renewField()));
	connect (Field,SIGNAL(cellDetails(int,int)),this,SLOT(showCellDetails(int,int)));


	//Legend
	CLegend * legend = new CLegend();
	connect(TypeViewCombo, SIGNAL(activated(const QString &)),legend, SLOT(setTypeView(const QString &)));

	//ScrollArea
	QScrollArea * scrollArea = new QScrollArea ();
	scrollArea->setBackgroundRole(QPalette::Dark);
	scrollArea->setWidget(Field); 

	//Zoom
	ZoomSlid = new ZoomSlider(tr("Zoom: "));
	ZoomSlid->setDisabled(true);
	connect(ZoomSlid,SIGNAL(valueChanged(int)),Field,SLOT(setZoom(int)));


	//Growing Flowers Ratio Slider
	GFSlider = new QSlider(Qt::Horizontal);
	GFSlider->setRange(0, FLOWERGROWINGRATIO_NUM-1);
	GFSlider->setValue(FLOWERGROWINGRATIO_INIT);
	GFSlider->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); 
	connect(GFSlider,SIGNAL(valueChanged(int)),this,SLOT(FlowerGrowingRatioInEnvChanged(int)));

	QLabel * GFLabel=new QLabel("Ratio of growth of flowers: ");
	GFLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); 

	QVBoxLayout * GFLayout= new QVBoxLayout();
	GFLayout->addWidget(GFLabel);
	GFLayout->addWidget(GFSlider);


	//connect(this,SIGNAL(envIsEmpty(bool)),ZoomSlid,SLOT(setDisabled(bool)));
	
	//CheckBox for display
	DisplayCheck = new QCheckBox(tr("&Display On"));
	//DisplayCheck->resize(100,30);
	//DisplayCheck->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
	connect(DisplayCheck, SIGNAL(stateChanged(int)),this,SLOT(DisplayChanged(int)));
	DisplayCheck->setCheckState(Qt::Checked);
	
	//CheckBox for LearningOn
	LearningCheck = new QCheckBox(tr("&Learning On"));
	connect(LearningCheck, SIGNAL(stateChanged(int)),this,SLOT(LearningChanged(int)));
	if (Env.LearningOn) LearningCheck->setCheckState(Qt::Checked);
	else LearningCheck->setCheckState(Qt::Unchecked);
	
	QVBoxLayout * checksLayout= new QVBoxLayout();
	checksLayout->addWidget(DisplayCheck);
	checksLayout->addWidget(LearningCheck);

	//Time LCD
	
     TimeLCD = new LabeledLCD(tr("Time"));
     

	//Start, Stop, Make n steps buttons
	 RunBut = new QPushButton(tr("&Run"));
	 RunBut-> setCheckable(true);
	 NumStepsSpin = new QSpinBox();
	 NumStepsSpin ->setMaximum(MAXTIME);
	 NumStepsSpin->setMinimum(1);
	 NumStepsSpin->setValue(100);
	 MakeNStepsBut = new QPushButton(tr("&Make steps"));
	 MakeNStepsBut-> setCheckable(true);

	RunBut->setDisabled(true);MakeNStepsBut->setDisabled(true);NumStepsSpin->setDisabled(true);

	connect(RunBut,SIGNAL(toggled(bool)),MakeNStepsBut,SLOT(setDisabled(bool)));
	connect(MakeNStepsBut,SIGNAL(toggled(bool)),RunBut,SLOT(setDisabled(bool)));
	connect(RunBut,SIGNAL(toggled(bool)),NumStepsSpin,SLOT(setDisabled(bool)));
	
	connect(MakeNStepsBut,SIGNAL(toggled(bool)),this,SLOT(runNSteps(bool)));
	connect(RunBut,SIGNAL(toggled(bool)),this,SLOT(run(bool)));

	//If there is no environment opened, all buttons are disabled
	connect(this, SIGNAL(envIsEmpty(bool)),RunBut,SLOT(setDisabled(bool)));
	connect(this, SIGNAL(envIsEmpty(bool)),NumStepsSpin,SLOT(setDisabled(bool)));
	connect(this, SIGNAL(envIsEmpty(bool)),MakeNStepsBut,SLOT(setDisabled(bool)));


	
	 //Legend Field:
	 

	 QVBoxLayout * rightLayout= new QVBoxLayout();
	 rightLayout->addWidget(TimeLCD);
	 //rightLayout->addStretch(1);
	 rightLayout->addWidget(RunBut);
	 rightLayout->addWidget(NumStepsSpin);
	 rightLayout->addWidget(MakeNStepsBut);
	 rightLayout->addStretch(1);
	 rightLayout->addLayout(checksLayout,Qt::AlignHCenter);
	 rightLayout->addWidget(legend);


	 
	//numBeetles LCD
	NumBeetlesLCD = new LabeledLCD(tr("Beetles"));

	//numFlowers LCD     
	NumFlowersLCD = new LabeledLCD(tr("Flowers"));

	 //numBirths LCD	
	NumBirthsLCD= new LabeledLCD(tr("Births"));

	 //Bottom layout strip
	QHBoxLayout * bottomLayout= new QHBoxLayout();
	bottomLayout->addWidget(NumBeetlesLCD);
	bottomLayout->addWidget(NumFlowersLCD);
	bottomLayout->addWidget(NumBirthsLCD);
	
//	QMessageBox::information(this,"MyApp","7");
    QGridLayout * gridLayout = new QGridLayout;
    //gridLayout->setMargin(5);
	gridLayout->addWidget(scrollArea,0,0,1,2);
	gridLayout->addLayout(typeViewLayout,1,2);
	gridLayout->addWidget(ZoomSlid,1,0);
	gridLayout->addLayout(GFLayout,1,1);//DisplayCheck,1,1,Qt::AlignHCenter);
	gridLayout->addLayout(rightLayout,0,2);
	gridLayout->addLayout(bottomLayout,2,0,1,3);
	//gridLayout->addLayout(
	gridLayout->setRowStretch(0, 1);
    mainWidget->setLayout(gridLayout);

//	QMessageBox::information(this,"MyApp","8");
	//creation of menu and its actions
    createActions();
    createMenus();

	QString message = tr("Environment can be opened or created in the menu in \"File\" section.");
    statusBar()->showMessage(message);
	
//	QMessageBox::information(this,"MyApp","9");

    setWindowTitle(tr("Abeetles"));
    setMinimumSize(400, 520);
    resize(480, 530);
	renewAllChildren();
	
	
//	QMessageBox::information(this,"MyApp","10");

}
Example #12
0
    OLD_MAIN(QWidget* pParent = nullptr)
        : QMainWindow(pParent)
    {
        Q_INIT_RESOURCE(Resources);

        // Settings persistence
        ReadSettings();

        // Appearance LUT
        PlayerApperances appearances;

        // Build player table model from file
        PlayerTableModel* playerTableModel = new PlayerTableModel(this);
        playerTableModel->LoadHittingProjections(appearances);
        playerTableModel->LoadPitchingProjections(appearances);
        playerTableModel->CalculateHittingScores();
        playerTableModel->CalculatePitchingScores();
        playerTableModel->InitializeTargetValues();

        // Draft delegate
        DraftDelegate* draftDelegate = new DraftDelegate(playerTableModel);
        LinkDelegate* linkDelegate = new LinkDelegate(this);
        TagDelegate* tagDelegate = new TagDelegate(this);

        // Hitter sort-model
        PlayerSortFilterProxyModel* hitterSortFilterProxyModel = new PlayerSortFilterProxyModel(Player::Hitter);
        hitterSortFilterProxyModel->setSourceModel(playerTableModel);
        hitterSortFilterProxyModel->setSortRole(PlayerTableModel::RawDataRole);

        // Hitter table view
        QTableView* hitterTableView = MakeTableView(hitterSortFilterProxyModel, true, PlayerTableModel::COLUMN_Z);
        hitterTableView->setItemDelegateForColumn(FindColumn(hitterSortFilterProxyModel, PlayerTableModel::COLUMN_DRAFT_BUTTON), draftDelegate);
        hitterTableView->setItemDelegateForColumn(FindColumn(hitterSortFilterProxyModel, PlayerTableModel::COLUMN_ID_LINK), linkDelegate);
        hitterTableView->setItemDelegateForColumn(FindColumn(hitterSortFilterProxyModel, PlayerTableModel::COLUMN_FLAG), tagDelegate);
        hitterTableView->setEditTriggers(QAbstractItemView::DoubleClicked | QAbstractItemView::SelectedClicked);

        // Context menu
        QMenu* contextMenu = new QMenu();
        contextMenu->addAction("&Remove Player");

        // Apply to hitter table view
        hitterTableView->setContextMenuPolicy(Qt::CustomContextMenu);
        connect(hitterTableView, &QWidget::customContextMenuRequested, [=](const QPoint& pos) {
            QPoint globalPos = hitterTableView->mapToGlobal(pos);
            QAction* selectedItem = contextMenu->exec(globalPos);
            if (selectedItem) {
                auto proxyIndex = hitterTableView->indexAt(pos);
                auto srcIndex = hitterSortFilterProxyModel->mapToSource(proxyIndex);
                playerTableModel->RemovePlayer(srcIndex.row());
            }
        });

        // Pitcher sort-model
        PlayerSortFilterProxyModel* pitcherSortFilterProxyModel = new PlayerSortFilterProxyModel(Player::Pitcher);
        pitcherSortFilterProxyModel->setSourceModel(playerTableModel);
        pitcherSortFilterProxyModel->setSortRole(PlayerTableModel::RawDataRole);
        
        // Pitcher table view
        QTableView* pitcherTableView = MakeTableView(pitcherSortFilterProxyModel, true, PlayerTableModel::COLUMN_Z);
        pitcherTableView->setItemDelegateForColumn(FindColumn(pitcherSortFilterProxyModel, PlayerTableModel::COLUMN_DRAFT_BUTTON), draftDelegate);
        pitcherTableView->setItemDelegateForColumn(FindColumn(pitcherSortFilterProxyModel, PlayerTableModel::COLUMN_ID_LINK), linkDelegate);
        pitcherTableView->setItemDelegateForColumn(FindColumn(pitcherSortFilterProxyModel, PlayerTableModel::COLUMN_FLAG), tagDelegate);
        pitcherTableView->setEditTriggers(QAbstractItemView::DoubleClicked | QAbstractItemView::SelectedClicked);

        // Top/Bottom splitter
        QSplitter* topBottomSplitter = new QSplitter(Qt::Vertical);
        topBottomSplitter->setContentsMargins(5, 5, 5, 5);

        // Hitter/Pitcher tab View
        enum PlayerTableTabs { Hitters, Pitchers, Unknown };
        QTabWidget* hitterPitcherTabs = new QTabWidget(this);
        hitterPitcherTabs->insertTab(PlayerTableTabs::Hitters, hitterTableView, "Hitters");
        hitterPitcherTabs->insertTab(PlayerTableTabs::Pitchers, pitcherTableView, "Pitchers");
        topBottomSplitter->addWidget(hitterPitcherTabs);

        // Tab lookup helper
        auto CaterogyToTab = [](uint32_t catergory) 
        {
            switch (catergory)
            {
            case Player::Hitter:
                return PlayerTableTabs::Hitters;
            case Player::Pitcher:
                return PlayerTableTabs::Pitchers;
            default:
                return PlayerTableTabs::Unknown;
            }
        };

        // Drafted filter action
        QAction* filterDrafted = new QAction(this);
        connect(filterDrafted, &QAction::toggled, hitterSortFilterProxyModel, &PlayerSortFilterProxyModel::OnFilterDrafted);
        connect(filterDrafted, &QAction::toggled, pitcherSortFilterProxyModel, &PlayerSortFilterProxyModel::OnFilterDrafted);
        filterDrafted->setText(tr("Drafted"));
        filterDrafted->setToolTip("Toggle Drafted Players");
        filterDrafted->setCheckable(true);
        filterDrafted->toggle();

        QAction* filterReplacement = new QAction(this);
        connect(filterReplacement, &QAction::toggled, hitterSortFilterProxyModel, &PlayerSortFilterProxyModel::OnFilterReplacement);
        connect(filterReplacement, &QAction::toggled, pitcherSortFilterProxyModel, &PlayerSortFilterProxyModel::OnFilterReplacement);
        filterReplacement->setText(tr("($1)"));
        filterReplacement->setToolTip("Toggle replacements players with value under $1");
        filterReplacement->setCheckable(true);
        filterReplacement->toggle();

        // NL filter action
        QAction* filterNL = new QAction(this);
        connect(filterNL, &QAction::toggled, hitterSortFilterProxyModel, &PlayerSortFilterProxyModel::OnFilterNL);
        connect(filterNL, &QAction::toggled, pitcherSortFilterProxyModel, &PlayerSortFilterProxyModel::OnFilterNL);
        filterNL->setText(tr("NL"));
        filterNL->setToolTip("Toggle National Leauge");
        filterNL->setCheckable(true);
        filterNL->toggle();

        // AL filter action
        QAction* filterAL = new QAction(this);
        connect(filterAL, &QAction::toggled, hitterSortFilterProxyModel, &PlayerSortFilterProxyModel::OnFilterAL);
        connect(filterAL, &QAction::toggled, pitcherSortFilterProxyModel, &PlayerSortFilterProxyModel::OnFilterAL);
        filterAL->setText(tr("AL"));
        filterAL->setToolTip("Toggle American Leauge");
        filterAL->setCheckable(true);
        filterAL->toggle();

        // FA filter action
        QAction* filterFA = new QAction(this);
        connect(filterFA, &QAction::toggled, hitterSortFilterProxyModel, &PlayerSortFilterProxyModel::OnFilterFA);
        connect(filterFA, &QAction::toggled, pitcherSortFilterProxyModel, &PlayerSortFilterProxyModel::OnFilterFA);
        filterFA->setText(tr("FA"));
        filterFA->setToolTip("Toggle Free Agents");
        filterFA->setCheckable(true);
        filterAL->toggle();
        filterAL->toggle();

        // General filter group
        QActionGroup* generalFilters = new QActionGroup(this);
        generalFilters->addAction(filterAL);
        generalFilters->addAction(filterNL);
        generalFilters->addAction(filterFA);
        generalFilters->setExclusive(false);

        // Starter filter action
        QAction* filterStarter = new QAction(this);
        connect(filterStarter, &QAction::toggled, pitcherSortFilterProxyModel, &PlayerSortFilterProxyModel::OnFilterSP);
        filterStarter->setText(tr("SP"));
        filterStarter->setToolTip("Toggle Starting Pitchers");
        filterStarter->setCheckable(true);
        filterStarter->toggle();

        // Relief filter action
        QAction* filterRelief = new QAction(this);
        connect(filterRelief, &QAction::toggled, pitcherSortFilterProxyModel, &PlayerSortFilterProxyModel::OnFilterRP);
        filterRelief->setText(tr("RP"));
        filterRelief->setToolTip("Toggle Relief Pitchers");
        filterRelief->setCheckable(true);
        filterRelief->toggle();

        // Pitching filter group
        QActionGroup* pitchingFilters = new QActionGroup(this);
        pitchingFilters->addAction(filterStarter);
        pitchingFilters->addAction(filterRelief);
        pitchingFilters->setExclusive(false);

        // Hitting filter group
        QActionGroup* hittingFilters = new QActionGroup(this);
        hittingFilters->setExclusive(false);

        // Filter helper
        auto MakeHitterFilter = [=](QString text, QString toolTip, const auto& onFilterFn) -> QAction* 
        {
            QAction* action = new QAction(this);
            connect(action, &QAction::toggled, hitterSortFilterProxyModel, onFilterFn);
            action->setText(text);
            action->setToolTip(toolTip);
            action->setCheckable(true);
            action->toggle();
            hittingFilters->addAction(action);

            return action;
        };

        // Hitter filters
        QAction* filterC  = MakeHitterFilter("C",  "Filter Catchers",           &PlayerSortFilterProxyModel::OnFilterC);
        QAction* filter1B = MakeHitterFilter("1B", "Filter 1B",                 &PlayerSortFilterProxyModel::OnFilter1B);
        QAction* filter2B = MakeHitterFilter("2B", "Filter 2B",                 &PlayerSortFilterProxyModel::OnFilter2B);
        QAction* filterSS = MakeHitterFilter("SS", "Filter SS",                 &PlayerSortFilterProxyModel::OnFilterSS);
        QAction* filter3B = MakeHitterFilter("3B", "Filter 3B",                 &PlayerSortFilterProxyModel::OnFilter3B);
        QAction* filterOF = MakeHitterFilter("OF", "Filter Outfielders",        &PlayerSortFilterProxyModel::OnFilterOF);
        QAction* filterCI = MakeHitterFilter("CI", "Filter Corner Infielders",  &PlayerSortFilterProxyModel::OnFilterCI);
        QAction* filterMI = MakeHitterFilter("MI", "Filter Middle Infielders",  &PlayerSortFilterProxyModel::OnFilterMI);
        QAction* filterDH = MakeHitterFilter("DH", "Filter Designated Hitters", &PlayerSortFilterProxyModel::OnFilterDH);
        QAction* filterU  = MakeHitterFilter("U",  "Filter Utility",            &PlayerSortFilterProxyModel::OnFilterU);

        // Menu spacer
        QWidget* spacer = new QWidget(this);
        spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);

        // Completion Widget
        QCompleter* completer = new QCompleter(this);
        completer->setModel(playerTableModel);
        completer->setCompletionColumn(PlayerTableModel::COLUMN_NAME);
        completer->setFilterMode(Qt::MatchContains);
        completer->setCaseSensitivity(Qt::CaseInsensitive);

        // Select
        auto HighlightPlayerInTable = [=](const QModelIndex& srcIdx)
        {
            // Lookup catergory
            auto catergoryIdx = srcIdx.model()->index(srcIdx.row(), PlayerTableModel::COLUMN_CATERGORY);
            auto catergory = srcIdx.model()->data(catergoryIdx).toUInt();

            // Change to tab
            hitterPitcherTabs->setCurrentIndex(CaterogyToTab(catergory));

            // Select row
            if (catergory == Player::Catergory::Hitter) {
                auto proxyModel = dynamic_cast<QSortFilterProxyModel*>(hitterTableView->model());
                auto proxyIdx = proxyModel->mapFromSource(srcIdx);
                hitterTableView->selectRow(proxyIdx.row());
                hitterTableView->setFocus();
            } else if (catergory == Player::Catergory::Pitcher) {
                auto proxyModel = dynamic_cast<QSortFilterProxyModel*>(pitcherTableView->model());
                auto proxyIdx = proxyModel->mapFromSource(srcIdx);
                pitcherTableView->selectRow(proxyIdx.row());
                pitcherTableView->setFocus();
            }
        };

        // Select the target 
        connect(completer, static_cast<void (QCompleter::*)(const QModelIndex&)>(&QCompleter::activated), [=](const QModelIndex& index) {

            // Get player index
            QAbstractProxyModel* proxyModel = dynamic_cast<QAbstractProxyModel*>(completer->completionModel());
            auto srcIdx = proxyModel->mapToSource(index);
            
            // Highlight this player
            HighlightPlayerInTable(srcIdx);
        });


        // Search widget
        QLineEdit* playerSearch = new QLineEdit(this);
        playerSearch->setCompleter(completer);

        // Main toolbar
        QToolBar* toolbar = new QToolBar("Toolbar");
        toolbar->addWidget(new QLabel(" Status: ", this));
        toolbar->addActions(QList<QAction*>{filterDrafted, filterReplacement});
        toolbar->addSeparator();
        toolbar->addWidget(new QLabel(" Leagues: ", this));
        toolbar->addActions(QList<QAction*>{filterAL, filterNL, filterFA});
        toolbar->addSeparator();
        toolbar->addWidget(new QLabel(" Positions: ", this));
        toolbar->addActions(QList<QAction*>{filterStarter, filterRelief});
        toolbar->addActions(QList<QAction*>{filterC, filter1B, filter2B, filterSS, filter3B, filterOF, filterCI, filterMI, filterDH, filterU});
        toolbar->addWidget(spacer);
        toolbar->addWidget(new QLabel("Player Search: ", this));
        toolbar->addWidget(playerSearch);
        toolbar->setFloatable(false);
        toolbar->setMovable(false);
        QMainWindow::addToolBar(toolbar);

        // Helper to adjust filters
        auto ToggleFilterGroups = [=](int index)
        {
            switch (index)
            {
            case uint32_t(PlayerTableTabs::Hitters):
                pitchingFilters->setVisible(false);
                hittingFilters->setVisible(true);
                break;
            case uint32_t(PlayerTableTabs::Pitchers):
                pitchingFilters->setVisible(true);
                hittingFilters->setVisible(false);
                break;
            default:
                break;
            }
        };

        // Set default filter group
        ToggleFilterGroups(hitterPitcherTabs->currentIndex());

        //---------------------------------------------------------------------
        // Bottom Section
        //---------------------------------------------------------------------

        // Owner widget
        QHBoxLayout* ownersLayout = new QHBoxLayout(this);
        ownersLayout->setSizeConstraint(QLayout::SetNoConstraint);

        // Owner models
        std::vector<OwnerSortFilterProxyModel*> vecOwnerSortFilterProxyModels;

        // Owner labels
        QList<QLabel*>* pVecOwnerLabels;
        pVecOwnerLabels = new QList<QLabel*>();
        pVecOwnerLabels->append(new QLabel("--"));
        for (auto i = 1u; i <= DraftSettings::Get().OwnerCount; i++) {
            pVecOwnerLabels->append(new QLabel(DraftSettings::Get().OwnerNames[i]));
        }

        // Update label helper
        auto UpdateOwnerLabels = [=]() {
            for (auto i = 1u; i <= DraftSettings::Get().OwnerCount; i++) {
                pVecOwnerLabels->at(i)->setText(DraftSettings::Get().OwnerNames[i]);
            }
        };

        // Initialize
        UpdateOwnerLabels();

        // Loop owners
        for (uint32_t ownerId = 1; ownerId <= DraftSettings::Get().OwnerCount; ownerId++) {

            // V-Layout per owner
            QVBoxLayout* perOwnerLayout = new QVBoxLayout(this);
            ownersLayout->addLayout(perOwnerLayout);
            perOwnerLayout->setSizeConstraint(QLayout::SetNoConstraint);

            // Proxy model for this owner
            OwnerSortFilterProxyModel* ownerSortFilterProxyModel = new OwnerSortFilterProxyModel(ownerId, playerTableModel, this);
            vecOwnerSortFilterProxyModels.push_back(ownerSortFilterProxyModel);

            // Owner name label
            pVecOwnerLabels->at(ownerId)->setAlignment(Qt::AlignCenter);
            perOwnerLayout->addWidget(pVecOwnerLabels->at(ownerId));

            // Per-owner roster table view
            const uint32_t tableWidth = 225;
            QTableView* ownerRosterTableView = MakeTableView(ownerSortFilterProxyModel, true, 0);
            ownerRosterTableView->setMinimumSize(tableWidth, 65);
            ownerRosterTableView->setMaximumSize(tableWidth, 4096);
            ownerRosterTableView->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
            perOwnerLayout->addWidget(ownerRosterTableView);

            // XXX: This should be a form layout...
            QGridLayout* ownerSummaryGridLayout = new QGridLayout(this);
            ownerSummaryGridLayout->setSpacing(0);
            ownerSummaryGridLayout->addWidget(MakeLabel("Budget: "),     0, 0);
            ownerSummaryGridLayout->addWidget(MakeLabel("# Hitters: "),  1, 0);
            ownerSummaryGridLayout->addWidget(MakeLabel("# Pitchers: "), 2, 0);
            ownerSummaryGridLayout->addWidget(MakeLabel("Max Bid: "),    3, 0);

            QLabel* budgetLabel = MakeLabel();
            QLabel* numHittersLabel = MakeLabel();
            QLabel* numPitchersLabel = MakeLabel();
            QLabel* maxBidLabel = MakeLabel();

            // Helper
            auto UpdateLabels = [=]()
            {
                budgetLabel->setText(QString("$%1").arg(ownerSortFilterProxyModel->GetRemainingBudget()));
                numHittersLabel->setText(QString("%1 / %2").arg(ownerSortFilterProxyModel->Count(Player::Hitter)).arg(DraftSettings::Get().HitterCount));
                numPitchersLabel->setText(QString("%1 / %2").arg(ownerSortFilterProxyModel->Count(Player::Pitcher)).arg(DraftSettings::Get().PitcherCount));
                maxBidLabel->setText(QString("$%1").arg(ownerSortFilterProxyModel->GetMaxBid()));
            };

            // Update labels when a draft event happens
            connect(playerTableModel, &PlayerTableModel::DraftedEnd, [=]() {
                UpdateLabels();
            });

            UpdateLabels();

            ownerSummaryGridLayout->addWidget(budgetLabel,      0, 1);
            ownerSummaryGridLayout->addWidget(numHittersLabel,  1, 1);
            ownerSummaryGridLayout->addWidget(numPitchersLabel, 2, 1);
            ownerSummaryGridLayout->addWidget(maxBidLabel,      3, 1);

            QSpacerItem* spacer = new QSpacerItem(1, 1, QSizePolicy::Preferred, QSizePolicy::Preferred);

            ownerSummaryGridLayout->addItem(spacer, 0, 2);
            ownerSummaryGridLayout->addItem(spacer, 1, 2);
            ownerSummaryGridLayout->addItem(spacer, 2, 2);
            ownerSummaryGridLayout->addItem(spacer, 3, 2);
            perOwnerLayout->addLayout(ownerSummaryGridLayout);

            perOwnerLayout->addSpacerItem(spacer);
        }

        // Owner widget
        QWidget* scrollAreaWidgetContents = new QWidget(this);
        scrollAreaWidgetContents->setLayout(ownersLayout);
        scrollAreaWidgetContents->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);

        // Owner scroll area
        QScrollArea* ownerScrollArea = new QScrollArea(this);
        ownerScrollArea->setWidget(scrollAreaWidgetContents);
        ownerScrollArea->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
        ownerScrollArea->setBackgroundRole(QPalette::Light);
        ownerScrollArea->setFrameShape(QFrame::NoFrame);
        ownerScrollArea->setWidgetResizable(true);

        // Target value widget
        QWidget* targetValueWidget = new QWidget(this);
        QFormLayout* targetValueLayout = new QFormLayout(this);
        targetValueWidget->setLayout(targetValueLayout);
        auto values = {
            PlayerTableModel::COLUMN_AVG,
            PlayerTableModel::COLUMN_HR,
            PlayerTableModel::COLUMN_R,
            PlayerTableModel::COLUMN_RBI,
            PlayerTableModel::COLUMN_SB,
            PlayerTableModel::COLUMN_SO,
            PlayerTableModel::COLUMN_ERA,
            PlayerTableModel::COLUMN_WHIP,
            PlayerTableModel::COLUMN_W,
            PlayerTableModel::COLUMN_SV,
        };
        for (auto value : values) {
            auto name = playerTableModel->headerData(value, Qt::Horizontal, Qt::DisplayRole).toString();
            auto target = QString::number(playerTableModel->GetTargetValue(value), 'f', 3);
            targetValueLayout->addRow(name, new QLabel(target));
        }

        // Player scatter plot
        PlayerScatterPlotChart* chartView = new PlayerScatterPlotChart(playerTableModel, hitterSortFilterProxyModel, this);
        connect(hitterSortFilterProxyModel,  &QSortFilterProxyModel::layoutChanged, chartView, &PlayerScatterPlotChart::Update);
        connect(pitcherSortFilterProxyModel, &QSortFilterProxyModel::layoutChanged, chartView, &PlayerScatterPlotChart::Update);
        connect(playerTableModel, &QAbstractItemModel::dataChanged, chartView, &PlayerScatterPlotChart::Update);

        // Summary view
        SummaryWidget* summary = new SummaryWidget(playerTableModel, vecOwnerSortFilterProxyModels, this);

        // Bottom tabs
        enum BottomSectionTabs { Rosters, Summary, Targets, ChartView, Log };
        QTabWidget* bottomTabs = new QTabWidget(this);
        topBottomSplitter->addWidget(bottomTabs);
        bottomTabs->insertTab(BottomSectionTabs::Rosters, ownerScrollArea, "Rosters");
        bottomTabs->insertTab(BottomSectionTabs::Summary, summary, "Summary");
        bottomTabs->insertTab(BottomSectionTabs::Targets, targetValueWidget, "Targets");
        bottomTabs->insertTab(BottomSectionTabs::ChartView, chartView, "Scatter Chart");
        bottomTabs->insertTab(BottomSectionTabs::Log, GlobalLogger::Get(), "Log");

        // Make top section 3x the size of the bottom
        topBottomSplitter->setStretchFactor(0, 3);
        topBottomSplitter->setStretchFactor(1, 1);

        //----------------------------------------------------------------------
        // Connections
        //----------------------------------------------------------------------

        // Connect tab filters
        connect(hitterPitcherTabs, &QTabWidget::currentChanged, this, [=](int index) {
            
            // Update filters
            ToggleFilterGroups(index);

            // Update chart view
            switch (index)
            {
            case PlayerTableTabs::Hitters:
                chartView->SetProxyModel(hitterSortFilterProxyModel);
                break;
            case PlayerTableTabs::Pitchers:
                chartView->SetProxyModel(pitcherSortFilterProxyModel);
                break;
            default:
                break;
            }
        });

        // Connect chart click
        connect(chartView, &PlayerScatterPlotChart::PlayerClicked, this, [=](const QModelIndex& index) {
            HighlightPlayerInTable(index);
        });
        
        // Connect summary model
        connect(playerTableModel, &PlayerTableModel::DraftedEnd, summary, &SummaryWidget::OnDraftedEnd);

        //----------------------------------------------------------------------
        // Main
        //----------------------------------------------------------------------

        // Set as main window
        QMainWindow::setCentralWidget(topBottomSplitter);

        // Create main menu bar
        QMenuBar* mainMenuBar = new QMenuBar();
        QMainWindow::setMenuBar(mainMenuBar);
        
        // Main Menu > File menu
        QMenu* fileMenu = mainMenuBar->addMenu("&File");

        // File dialog helper
        auto GetFileDialog = [&](QFileDialog::AcceptMode mode) -> QFileDialog*
        {
            QFileDialog* dialog = new QFileDialog(this);
            dialog->setWindowModality(Qt::WindowModal);
            dialog->setAcceptMode(mode);
            dialog->setNameFilter("CSV files (*.csv)");
            return dialog;
        };

        // Ask for the save location 
        auto SetSaveAsFile = [=]()
        {
            QStringList files;
            auto dialog = GetFileDialog(QFileDialog::AcceptSave);
            if (dialog->exec()) {
                files = dialog->selectedFiles();
            } else {
                return false;
            }
            m_currentFile = files.at(0);
            return true;
        };

        // Update title bar
        auto UpdateApplicationName = [this]()
        {
            auto name = QString("fbb -- %1").arg(QFileInfo(m_currentFile).fileName());
            QCoreApplication::setApplicationName(name);
            setWindowTitle(name);
        };

        // Main Menu > File menu > Save action
        QAction* saveResultsAction = new QAction("&Save Results", this);
        connect(saveResultsAction, &QAction::triggered, [=](bool checked) {
            if (m_currentFile.isEmpty()) {
                SetSaveAsFile();
            }
            GlobalLogger::AppendMessage(QString("Saving file: %1...").arg(m_currentFile));
            UpdateApplicationName();
            return playerTableModel->SaveDraftStatus(m_currentFile);
        });
        fileMenu->addAction(saveResultsAction);

        // Main Menu > File menu > Save As action
        QAction* saveResultsAsAction = new QAction("Save Results &As...", this);
        connect(saveResultsAsAction, &QAction::triggered, [=](bool checked) {
            SetSaveAsFile();
            GlobalLogger::AppendMessage(QString("Saving file: %1...").arg(m_currentFile));
            UpdateApplicationName();
            return playerTableModel->SaveDraftStatus(m_currentFile);
        });
        fileMenu->addAction(saveResultsAsAction);
        
        // Main Menu > File menu > Load action
        QAction* loadResultsAction = new QAction("&Load Results...", this);
        connect(loadResultsAction, &QAction::triggered, [=](bool checked) {
            auto dialog = GetFileDialog(QFileDialog::AcceptOpen);
            QStringList files;
            if (dialog->exec()) {
                files = dialog->selectedFiles();
            } else {
                return false;
            }
            m_currentFile = files.at(0);
            GlobalLogger::AppendMessage(QString("Loading file: %1...").arg(m_currentFile));
            UpdateApplicationName();
            return playerTableModel->LoadDraftStatus(m_currentFile);
        });
        fileMenu->addAction(loadResultsAction);

        // Main Menu > File menu
        QMenu* settingsMenu = mainMenuBar->addMenu("&Settings");

        // Main Menu > Settings menu > Options action
        QAction* settingsAction = new QAction("&Settings...", this);
        connect(settingsAction, &QAction::triggered, [=](bool checked) {
            DraftSettingsDialog draftSettingsDialog;
            if (draftSettingsDialog.exec()) {
                UpdateOwnerLabels();
            }
        });
        settingsMenu->addAction(settingsAction);

        // Main Menu > Settings menu > Options action
        QAction* demoDataAction = new QAction("&DemoData...", this);
        connect(demoDataAction, &QAction::triggered, [=](bool checked) {
            playerTableModel->DraftRandom();
        });
        settingsMenu->addAction(demoDataAction);

        // show me
        QMainWindow::show();
    }
Example #13
0
void Renderer::CreateLayouts() {

	QVBoxLayout *general_layout = new QVBoxLayout;

	// Scroll areas that contains the output image
	QScrollArea *scroll = new QScrollArea;
	scroll->setWidget(image_label_);
	scroll->setBackgroundRole(QPalette::Dark);

	// Group containing the load-related widgets (load zoneplate, image)
	QGroupBox *load = new QGroupBox("Load...");
	QPushButton *load_zone_plate = new QPushButton("Load Zoneplate");
	QPushButton *load_image = new QPushButton("Load Image...");
	QHBoxLayout *layout_load = new QHBoxLayout;
	layout_load->addWidget(load_zone_plate);
	layout_load->addWidget(load_image);
	load->setLayout(layout_load);
	general_layout->addWidget(load);

	// Group containing the resolution-related widgets
	QGroupBox *dimensions = new QGroupBox("Resolution");
	QHBoxLayout *layout_dims = new QHBoxLayout;
	x_dim_ = new QSpinBox; x_dim_->setMinimum(1); x_dim_->setMaximum(1024); x_dim_->setValue(512);
	y_dim_ = new QSpinBox; y_dim_->setMinimum(1); y_dim_->setMaximum(1024); y_dim_->setValue(512);
	QPushButton *change_dimensions = new QPushButton("Change Resolution");
	layout_dims->addWidget(x_dim_);
	layout_dims->addWidget(y_dim_);
	layout_dims->addWidget(change_dimensions);
	dimensions->setLayout(layout_dims);
	general_layout->addWidget(dimensions);

	// Group containing widgets related to the chosen filter
	QGroupBox *filter_parameters = new QGroupBox("Filter and Support");
	QVBoxLayout *filter_parameters_layout = new QVBoxLayout;
	QComboBox *filter_choice = new QComboBox;
	filter_choice->addItem("Box");
	filter_choice->addItem("Bartlett");
	filter_choice->addItem("Welch");
	filter_choice->addItem("Parzen");
	filter_choice->addItem("Hammer");
	filter_choice->addItem("Blackman");
	filter_choice->addItem("Lanczos");
	filter_choice->addItem("Gauss");
	filter_choice->addItem("Mitchell");
	filter_choice->addItem("Dippé");
	filter_choice->addItem("Cook");
	QDoubleSpinBox *support_spin = new QDoubleSpinBox;
	support_spin->setMinimum(0); support_spin->setMaximum(1000); support_spin->setValue(1);
	filter_parameters_layout->addWidget(filter_choice);
	filter_parameters_layout->addWidget(support_spin);
	filter_parameters->setLayout(filter_parameters_layout);
	general_layout->addWidget(filter_parameters);

	// Group containing all paramters about the zoneplate
	zone_plate_modifier_ = new QWidget;
	QHBoxLayout *layout_zone_plate = new QHBoxLayout;
	QSpinBox *size_spin = new QSpinBox; size_spin->setMinimum(1); size_spin->setMaximum(1000); size_spin->setValue(50);
	QSlider *size_slider = new QSlider(Qt::Horizontal);  size_slider->setMinimum(1); size_slider->setMaximum(1000); size_slider->setValue(50);
	freq_spin_ = new QDoubleSpinBox; freq_spin_->setMinimum(0); freq_spin_->setMaximum(1000); freq_spin_->setValue(50);

	QGroupBox *group_size = new QGroupBox("Support Size");
	QVBoxLayout *group_size_layout = new QVBoxLayout;
	group_size_layout->addWidget(size_spin);
	group_size_layout->addWidget(size_slider);
	group_size->setLayout(group_size_layout);
	layout_zone_plate->addWidget(group_size);

	group_freq_ = new QGroupBox("Fixed Frequency");
	QVBoxLayout *group_freq__layout = new QVBoxLayout;
	group_freq__layout->addWidget(freq_spin_);
	group_freq_->setLayout(group_freq__layout);
	group_freq_->setCheckable(true);
	group_freq_->setChecked(false);
	layout_zone_plate->addWidget(group_freq_);

	zone_plate_modifier_->setLayout(layout_zone_plate);
	general_layout->addWidget(zone_plate_modifier_);

	general_layout->addWidget(scroll);

	// Sets the global layout.
	setLayout(general_layout);

	// Creates the needed connections.
	CreateConnections(change_dimensions, load_zone_plate, load_image, size_spin, size_slider, support_spin, filter_choice);

}
Example #14
0
TUIMainWindow::TUIMainWindow(QWidget *parent)
    : QMainWindow(parent)
    , port(31802)
    , lastID(-10)
    , serverSN(NULL)
    , clientSN(NULL)
    , dialog(NULL)
    , sConn(NULL)
    , clientConn(NULL)
    , lastElement(NULL)
{
    // init some values
    appwin = this;

#if !defined _WIN32_WCE && !defined ANDROID_TUI
    port = covise::coCoviseConfig::getInt("port", "COVER.TabletPC", 31802);
#else
    port = 31802;
#endif
#ifndef _WIN32
    signal(SIGPIPE, SIG_IGN); // otherwise writes to a closed socket kill the application.
#endif

    // initialize two timer
    // timer.....waits for disconneting vrb clients

    timer = new QTimer(this);
    connect(timer, SIGNAL(timeout()), this, SLOT(timerDone()));

// create the menus and toolbar buttons
//createMenubar();
#ifndef _WIN32_WCE
    createToolbar();
#endif

    // widget that contains the main windows(mainFrame)

    QWidget *w;
#ifdef _WIN32_WCE
    QScrollArea *scrollArea = new QScrollArea;
    scrollArea->setBackgroundRole(QPalette::Dark);
    w = scrollArea;
#else
    w = new QWidget(this);
    QScrollArea *scrollArea = new QScrollArea();
    scrollArea->setBackgroundRole(QPalette::Dark);
    scrollArea->setWidgetResizable(true);
    scrollArea->setWidget(w);
#endif

    QVBoxLayout *vbox = new QVBoxLayout(w);

// main windows
#ifdef _WIN32_WCE
    mainFrame = new QFrame(w);
    mainFrame->setContentsMargins(1, 1, 1, 1);
#else
    mainFrame = new QFrame();
    mainFrame->setFrameStyle(QFrame::WinPanel | QFrame::Sunken);
    mainFrame->setContentsMargins(2, 2, 2, 2);
#endif
    vbox->addWidget(mainFrame, 1);

    // main layout
    mainGrid = new QGridLayout(mainFrame);

    setFont(mainFont);

#ifdef _WIN32_WCE
    setWindowTitle("COVISE: PocketUI");
    setCentralWidget(w);
#else
    setWindowTitle("COVISE: TabletUI");
    setCentralWidget(scrollArea);
#endif

    // set a logo &size
    setWindowIcon(QPixmap(logo));
#ifdef _WIN32_WCE
    setMaximumWidth(480);
    setMaximumHeight(480);
#else
    resize(800, 600);
#endif
}
TextEdit::TextEdit(QWidget *parent)
  : QMainWindow(parent)
{
  setToolButtonStyle(Qt::ToolButtonFollowStyle);
  setupFileActions();
  setupEditActions();
  setupTextActions();

  {
//    QMenu *helpMenu = new QMenu(tr("Help"), this);
//    menuBar()->addMenu(helpMenu);
//    helpMenu->addAction(tr("About"), this, SLOT(about()));
//    helpMenu->addAction(tr("About &Qt"), qApp, SLOT(aboutQt()));
  }

  textEdit = new QTextEdit(this);
  //////////////////////////////////////////////////
  connect(textEdit, SIGNAL(currentCharFormatChanged(QTextCharFormat)),
          this, SLOT(currentCharFormatChanged(QTextCharFormat)));
  connect(textEdit, SIGNAL(cursorPositionChanged()),
          this, SLOT(cursorPositionChanged()));

  ///////////
  //setCentralWidget(textEdit);
  //blank=new Blank(this);
  //setCentralWidget(blank);


  //create a transparent canvas and put it on the top of textEdit
  image =new MyCanvas(900,800,this);
  textEdit->setFixedSize(QSize(800,800));
  textEdit->setBackgroundRole(QPalette::Light);   //scrollArea对象的背景色设为Dark
  image->setFixedSize(QSize(800,800));
  image->setStyleSheet(QString::fromUtf8("border:1px solid #000000;"));

  QScrollArea* scrollArea = new QScrollArea;
  scrollArea->setFixedSize(QSize(1800,900));
  //scrollArea->setWidget(image);     //将画布添加到scrollArea中
  scrollArea->setBackgroundRole(QPalette::Light);   //scrollArea对象的背景色设为Dark
  //scrollArea->setBackgroundColor(QColor::white);

//    QStackedLayout *stackedLayout = new QStackedLayout;
//    stackedLayout->addWidget(image);
//    stackedLayout->addWidget(textEdit);
//    stackedLayout->setStackingMode(QStackedLayout::StackAll);

  QHBoxLayout* hLayout=new QHBoxLayout();
  hLayout->addWidget(textEdit);
  hLayout->addWidget(image);
//  scrollArea->setLayout(stackedLayout);
  scrollArea->setLayout(hLayout);
  //scrollArea->setGeometry(QRect(50,50,800,800));



  setCentralWidget(scrollArea);    //将scrollArea加入到主窗口的中心区new QPainter(this);
  scrollArea->setAlignment(Qt::AlignHCenter);
  //after canvas handle the mouse-drag event, emit it to the edittext for farther handling
  connect(image,SIGNAL(mouseMoveSig(QMouseEvent*)),this,SLOT(onMouseMove(QMouseEvent*)));
  //connect(image,SIGNAL(mouseMoveSig(QMouseEvent*)),textEdit,SLOT(mouseMoveEvent(QMouseEvent*)));
  //connect(image,SIGNAL(mouseMoveSig(QMouseEvent*)),textEdit,SLOT(cursorPositionChanged(QMouseEvent*)));
  //connect(this,SIGNAL(mouseMoveSig(QMouseEvent*)),image,SLOT(mouseMoveSlot(QMouseEvent*)));
  //connect(textEdit,SIGNAL(mouseMoveEvent(QMouseEvent*)),image,SLOT(mouseMoveSlot(QMouseEvent*)));

  // textEdit->setFocus();
  setCurrentFileName(QString());

  fontChanged(textEdit->font());
  colorChanged(textEdit->textColor());
  alignmentChanged(textEdit->alignment());

  connect(textEdit->document(), SIGNAL(modificationChanged(bool)),
          actionSave, SLOT(setEnabled(bool)));
  connect(textEdit->document(), SIGNAL(modificationChanged(bool)),
          this, SLOT(setWindowModified(bool)));
  connect(textEdit->document(), SIGNAL(undoAvailable(bool)),
          actionUndo, SLOT(setEnabled(bool)));
  connect(textEdit->document(), SIGNAL(redoAvailable(bool)),
          actionRedo, SLOT(setEnabled(bool)));

  setWindowModified(textEdit->document()->isModified());
  actionSave->setEnabled(textEdit->document()->isModified());
  actionUndo->setEnabled(textEdit->document()->isUndoAvailable());
  actionRedo->setEnabled(textEdit->document()->isRedoAvailable());

  connect(actionUndo, SIGNAL(triggered()), textEdit, SLOT(undo()));
  connect(actionRedo, SIGNAL(triggered()), textEdit, SLOT(redo()));

  actionCut->setEnabled(false);
  actionCopy->setEnabled(false);

  connect(actionCut, SIGNAL(triggered()), textEdit, SLOT(cut()));
  connect(actionCopy, SIGNAL(triggered()), textEdit, SLOT(copy()));
  connect(actionPaste, SIGNAL(triggered()), textEdit, SLOT(paste()));

  connect(textEdit, SIGNAL(copyAvailable(bool)), actionCut, SLOT(setEnabled(bool)));
  connect(textEdit, SIGNAL(copyAvailable(bool)), actionCopy, SLOT(setEnabled(bool)));

#ifndef QT_NO_CLIPBOARD
  connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged()));
#endif

  //QString initialFile = ":/data/example.html";
  QString initialFile = ":/data/test.txt";
  const QStringList args = QCoreApplication::arguments();
  if (args.count() == 2)
    initialFile = args.at(1);

  if (!load(initialFile))
    fileNew();
}