Пример #1
0
	bool HandlerChoiceDialog::AddCommon (const IInfo *ii, const QString& addedAs)
	{
		QString name;
		QString tooltip;
		QIcon icon;
		try
		{
			name = ii->GetName ();
			tooltip = ii->GetInfo ();
			icon = ii->GetIcon ();
		}
		catch (const std::exception& e)
		{
			qWarning () << Q_FUNC_INFO
				<< "could not query"
				<< e.what ()
				<< ii;
			return false;
		}
		catch (...)
		{
			qWarning () << Q_FUNC_INFO
				<< "could not query"
				<< ii;
			return false;
		}

		QRadioButton *but = new QRadioButton (name, this);
		but->setToolTip (tooltip);
		but->setIconSize (QSize (32, 32));
		but->setIcon (icon);
		but->setProperty ("AddedAs", "IDownload");
		but->setProperty ("PluginID", ii->GetUniqueID ());

		if (Buttons_->buttons ().isEmpty ())
			but->setChecked (true);

		Buttons_->addButton (but);
		Ui_.DownloadersLayout_->addWidget (but);

		Infos_ [name] = ii;

		Ui_.DownloadersLabel_->show ();

		if (Downloaders_.size () + Handlers_.size () == 1)
			populateLocationsBox ();

		return true;
	}
Пример #2
0
void QMwMaterialLayersWidget::UpdateLayersPanel()
{
    QGridLayout *layersLayout = (QGridLayout*)this->layersWidget->layout();

    QLayoutItem *child;
    while ((child = layersLayout->takeAt(0)) != 0)
    {
        delete child->widget();
        delete child;
    }

    if (this->material == 0)
        return;

    for (int layerIndex = 0; layerIndex < this->material->shaderSlots.count; layerIndex++)
    {
        QRadioButton *layerSelectRadioButton = new QRadioButton(this->layersWidget);
        layerSelectRadioButton->setChecked(layerIndex == this->selectedLayerIndex);
        layerSelectRadioButton->setProperty("layerIndex", QVariant(layerIndex));
        layerSelectRadioButton->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum);
        QObject::connect(layerSelectRadioButton, SIGNAL(clicked()), this, SLOT(LayerSelected()));
        layersLayout->addWidget(layerSelectRadioButton, layerIndex, 0);

        QComboBox *shaderOpComboBox = new QComboBox(this->layersWidget);
        this->SetShaderOpComboBox(shaderOpComboBox, layerIndex);
        QObject::connect(shaderOpComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(LayerShaderOperationChanged(int)));
        layersLayout->addWidget(shaderOpComboBox, layerIndex, 1);

        QComboBox *colorOpComboBox = new QComboBox(this->layersWidget);
        this->SetColorOpComboBox(colorOpComboBox, layerIndex);
        QObject::connect(colorOpComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(LayerColorOperationChanged(int)));
        layersLayout->addWidget(colorOpComboBox, layerIndex, 2);
    }
}
Пример #3
0
QuetzalChoiceDialog::QuetzalChoiceDialog(const char *title, const char *primary,
										 const char *secondary, int default_value,
										 const char *ok_text, GCallback ok_cb,
										 const char *cancel_text, GCallback cancel_cb,
										 void *user_data, va_list choices,
										 QWidget *parent)
			   : QuetzalRequestDialog(title, primary, secondary, PURPLE_REQUEST_CHOICE, user_data, parent)
{
	m_ok_cb = (PurpleRequestChoiceCb) ok_cb;
	m_cancel_cb = (PurpleRequestChoiceCb) cancel_cb;
	QPushButton *ok_button = buttonBox()->addButton(ok_text, QDialogButtonBox::AcceptRole);
	QPushButton *cancel_button = buttonBox()->addButton(cancel_text, QDialogButtonBox::RejectRole);
	connect(ok_button, SIGNAL(clicked()), this, SLOT(onOkClicked()));
	connect(cancel_button, SIGNAL(clicked()), this, SLOT(onCancelClicked()));
	const char *text;
	int id;
	int i = 1; // Label with description is situated at index 0
	while (!!(text = va_arg(choices, gchararray))) {
		id = va_arg(choices, int);
		QRadioButton *button = new QRadioButton(text, this);
		m_radios << button;
		button->setProperty("choiceId", id);
		boxLayout()->insertWidget(i++, button);
		if (id == default_value)
			button->setChecked(true);
	}
}
Пример #4
0
void PreferencesDialog::initialize(PreferencesTab initialTab, const persistence::Settings *settings, const QMap<QString, QString> &jamRecorders)
{
    Q_UNUSED(initialTab);
    this->settings = settings;
    this->jamRecorders = jamRecorders;
    this->jamRecorderCheckBoxes = QMap<QCheckBox *, QString>();
    this->jamDateFormatRadioButtons = QMap<const QRadioButton *, QString>();

    for (const auto &jamRecorder : jamRecorders.keys()) {
        QCheckBox *myCheckBox = new QCheckBox(this);
        myCheckBox->setObjectName(jamRecorder);
        myCheckBox->setText(jamRecorders.value(jamRecorder));
        ui->layoutRecorders->addWidget(myCheckBox);
        jamRecorderCheckBoxes[myCheckBox] = jamRecorder;
    }

    QDateTime now = QDateTime::currentDateTime();
    Qt::DateFormat dateFormat;
    QString nowString;
    QRadioButton *myRadioButton;

    dateFormat = Qt::TextDate;
    nowString = "Jam-" + now.toString(dateFormat).replace(QRegExp("[/:]"), "-").replace(QRegExp("[ ]"), "_");
    myRadioButton = new QRadioButton(this);
    myRadioButton->setObjectName("rbdfTextDate");
    myRadioButton->setText(nowString);
    myRadioButton->setProperty("buttonGroup", "rbDateFormat");
    ui->layoutDateFormats->addWidget(myRadioButton);
    jamDateFormatRadioButtons[myRadioButton] = "Qt::TextDate";

    dateFormat = Qt::ISODate;
    nowString = "Jam-" + now.toString(dateFormat).replace(QRegExp("[/:]"), "-").replace(QRegExp("[ ]"), "_");
    myRadioButton = new QRadioButton(this);
    myRadioButton->setObjectName("rbdfISODate");
    myRadioButton->setText(nowString);
    myRadioButton->setProperty("buttonGroup", "rbDateFormat");
    ui->layoutDateFormats->addWidget(myRadioButton);
    jamDateFormatRadioButtons[myRadioButton] = "Qt::ISODate";

    setupSignals();

    populateAllTabs();
}
Пример #5
0
static inline 
QRadioButton* buildRadioButton(QString text,
                               QString icon,
                               int mode,
                               QGroupBox *groupBox,
                               QHBoxLayout *hbox,
                               LogWidgetModel *m_viewmodel)
{
    QRadioButton *build = new QRadioButton(text, groupBox);

    build->setIcon(QIcon(QString(":/in/%0").arg(icon)));
    build->setProperty("mode", mode);
    build->setToolTip(build->text());
    hbox->addWidget(build);

    QObject::connect(build, SIGNAL(toggled(bool)), m_viewmodel, SLOT(changeMode(bool)));

    return build;
}
Пример #6
0
QWidget * PEUtils::makeConnectorForm(const QDomElement & connector, int index, QObject * slotHolder, bool alternating)
{
    QFrame * frame = new QFrame();
    if (alternating) {
        frame->setObjectName(index % 2 == 0 ? "NewPartsEditorConnector0Frame" : "NewPartsEditorConnector1Frame");
    }
    else {
        frame->setObjectName("NewPartsEditorConnectorFrame");
    }
    QVBoxLayout * mainLayout = new QVBoxLayout();
    mainLayout->setMargin(0);
	mainLayout->setContentsMargins(0, 0, 0, 0);
	mainLayout->setSpacing(0);

    QFrame * nameFrame = new QFrame();
    QHBoxLayout * nameLayout = new QHBoxLayout();

    QLabel * justLabel = new QLabel(QObject::tr("<b>Name:</b>"));
	justLabel->setObjectName("NewPartsEditorLabel");
    nameLayout->addWidget(justLabel);

    QLineEdit * nameEdit = new QLineEdit();
    nameEdit->setText(connector.attribute("name"));
	QObject::connect(nameEdit, SIGNAL(editingFinished()), slotHolder, SLOT(nameEntry()));
	nameEdit->setObjectName("NewPartsEditorLineEdit");
    nameEdit->setStatusTip(QObject::tr("Set the connectors's title"));
    nameEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
    nameEdit->setProperty("index", index);
    nameEdit->setProperty("type", "name");
    nameEdit->setProperty("id", connector.attribute("id"));
    nameLayout->addWidget(nameEdit);
    nameLayout->addSpacing(Spacing);

    HashRemoveButton * hashRemoveButton = new HashRemoveButton(NULL, NULL, NULL);
    hashRemoveButton->setProperty("index", index);
	QObject::connect(hashRemoveButton, SIGNAL(clicked(HashRemoveButton *)), slotHolder, SLOT(removeConnector()));
    nameLayout->addWidget(hashRemoveButton);

    nameFrame->setLayout(nameLayout);
    mainLayout->addWidget(nameFrame);



    QFrame * descriptionFrame = new QFrame();
    QHBoxLayout * descriptionLayout = new QHBoxLayout();

    justLabel = new QLabel(QObject::tr("<b>Description:</b>"));
	justLabel->setObjectName("NewPartsEditorLabel");
    descriptionLayout->addWidget(justLabel);

    QLineEdit * descriptionEdit = new QLineEdit();
    QDomElement description = connector.firstChildElement("description");
    descriptionEdit->setText(description.text());
	QObject::connect(descriptionEdit, SIGNAL(editingFinished()), slotHolder, SLOT(descriptionEntry()));
	descriptionEdit->setObjectName("NewPartsEditorLineEdit");
    descriptionEdit->setStatusTip(QObject::tr("Set the connectors's description"));
    descriptionEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
    descriptionEdit->setProperty("index", index);
    descriptionEdit->setProperty("type", "description");
    descriptionLayout->addWidget(descriptionEdit);

    descriptionFrame->setLayout(descriptionLayout);
    mainLayout->addWidget(descriptionFrame);



    QFrame * idFrame = new QFrame();
    QHBoxLayout * idLayout = new QHBoxLayout();

	justLabel = new QLabel(QObject::tr("<b>id:</b>"));
	justLabel->setObjectName("NewPartsEditorLabel");
    idLayout->addWidget(justLabel);

    justLabel = new QLabel(connector.attribute("id"));
	justLabel->setObjectName("NewPartsEditorLabel");
    idLayout->addWidget(justLabel);
    idLayout->addSpacerItem(new QSpacerItem(1, 1, QSizePolicy::Expanding));

    Connector::ConnectorType ctype = Connector::connectorTypeFromName(connector.attribute("type"));

	justLabel = new QLabel(QObject::tr("<b>type:</b>"));
	justLabel->setObjectName("NewPartsEditorLabel");
    idLayout->addWidget(justLabel);

    QRadioButton * radioButton = new QRadioButton(MaleSymbolString); 
	QObject::connect(radioButton, SIGNAL(clicked()), slotHolder, SLOT(typeEntry()));
    radioButton->setObjectName("NewPartsEditorRadio");
    if (ctype == Connector::Male) radioButton->setChecked(true); 
    radioButton->setProperty("value", Connector::Male);
    radioButton->setProperty("index", index);
    radioButton->setProperty("type", "radio");
    idLayout->addWidget(radioButton);

    radioButton = new QRadioButton(FemaleSymbolString); 
	QObject::connect(radioButton, SIGNAL(clicked()), slotHolder, SLOT(typeEntry()));
    radioButton->setObjectName("NewPartsEditorRadio");
    if (ctype == Connector::Female) radioButton->setChecked(true); 
    radioButton->setProperty("value", Connector::Female);
    radioButton->setProperty("index", index);
    radioButton->setProperty("type", "radio");
    idLayout->addWidget(radioButton);

    radioButton = new QRadioButton(QObject::tr("Pad")); 
	QObject::connect(radioButton, SIGNAL(clicked()), slotHolder, SLOT(typeEntry()));
    radioButton->setObjectName("NewPartsEditorRadio");
    if (ctype == Connector::Pad) radioButton->setChecked(true); 
    radioButton->setProperty("value", Connector::Pad);
    idLayout->addWidget(radioButton);
    radioButton->setProperty("index", index);
    radioButton->setProperty("type", "radio");
    idLayout->addSpacing(Spacing);

    idFrame->setLayout(idLayout);
    mainLayout->addWidget(idFrame);

    frame->setLayout(mainLayout);
    return frame;
}
Пример #7
0
AirportsWidget::AirportsWidget(MainObject *mOb, QWidget *parent) :
    QWidget(parent)
{

	mainObject = mOb;

    //* Main Layout
	QGridLayout *mainLayout = new QGridLayout();
    setLayout(mainLayout);
	mainLayout->setSpacing(10);
	int m = 10;
	mainLayout->setContentsMargins(m,m,m,m);

	//=====================================
	//** Top Startup Option Buttons
	QHBoxLayout *layoutTop = new QHBoxLayout();
	mainLayout->addLayout(layoutTop,0,0,1,2);

	buttonGroupUse = new QButtonGroup(this);
	buttonGroupUse->setExclusive(true);
	connect(buttonGroupUse, SIGNAL(buttonClicked(int)), this, SLOT(on_buttonGroupUse()));

	QRadioButton *radioButtonUseDefault = new QRadioButton(tr("Default (KSFO)"));
	radioButtonUseDefault->setChecked(true);
	layoutTop->addWidget(radioButtonUseDefault);
	buttonGroupUse->addButton(radioButtonUseDefault, USE_DEFAULT);

	QRadioButton *radioButtonUseAirport = new QRadioButton(tr("Start at Airport"));
	layoutTop->addWidget(radioButtonUseAirport);
	buttonGroupUse->addButton(radioButtonUseAirport, USE_AIRPORT);

	QRadioButton *radioButtonUseCoordinates = new QRadioButton(tr("Start at Coordinates"));
	layoutTop->addWidget(radioButtonUseCoordinates);
	buttonGroupUse->addButton(radioButtonUseCoordinates, USE_COORDINATES);

	layoutTop->addStretch(10);


	//=================================================================================
	//* Airport Details
	groupBoxAirport = new QGroupBox(this);
	groupBoxAirport->setTitle("Airport Details");
	mainLayout->addWidget(groupBoxAirport, 1, 0);

	QVBoxLayout *airportsContainerLayout = new QVBoxLayout();
	groupBoxAirport->setLayout(airportsContainerLayout);
	airportsContainerLayout->setContentsMargins(10,10,10,10);
	airportsContainerLayout->setSpacing(0);


	//==================================================================
	//** Airports Filter and Actions Top Bar
	QHBoxLayout *layoutAptTopBar = new QHBoxLayout();
	layoutAptTopBar->setContentsMargins(0,0,0,0);
	layoutAptTopBar->setSpacing(10);
	airportsContainerLayout->addLayout(layoutAptTopBar);

    //** Filter Code
	layoutAptTopBar->addWidget(new QLabel(tr("Filter").append(":")));

	//** Filter Buttons - TODO
	buttonGroupFilter = new QButtonGroup(this);
	buttonGroupFilter->setExclusive(true);


	//** Aiport Code Filter
    QRadioButton *buttCode = new QRadioButton();
    buttCode->setText("Code");
	buttCode->setProperty("filter_column_idx", QVariant(CA_CODE));
	buttCode->setChecked(true);
	layoutAptTopBar->addWidget(buttCode);
	buttonGroupFilter->addButton(buttCode, 0);

	//** Airport Name Filter
    QRadioButton *buttName = new QRadioButton();
    buttName->setText("Name");
	buttName->setProperty("filter_column_idx", QVariant(CA_NAME));
	layoutAptTopBar->addWidget(buttName);
	buttonGroupFilter->addButton(buttName, 1);

	//** Find Airport Text
    txtAirportsFilter = new QLineEdit();
	layoutAptTopBar->addWidget(txtAirportsFilter);
    txtAirportsFilter->setFixedWidth(100);
	connect(	txtAirportsFilter, SIGNAL(textChanged(QString)),
				this, SLOT(on_update_airports_filter())
	);

	layoutAptTopBar->addStretch(20);

	/* DEAD for now
	QPushButton *buttonImportAirports = new QPushButton(this);
	layoutAptTopBar->addWidget(buttonImportAirports);
	buttonImportAirports->setText("Reload");
	buttonImportAirports->setToolTip("Scan directories and reload cache");
	buttonImportAirports->setIcon(QIcon(":/icon/import"));
	buttonImportAirports->setFlat(true);
	connect(buttonImportAirports, SIGNAL(clicked()), this, SLOT(on_import_aptdat_clicked()) );
	*/

	QPushButton *buttonRefreshAirports = new QPushButton(this);
	layoutAptTopBar->addWidget(buttonRefreshAirports);
	buttonRefreshAirports->setText("Import");
	buttonRefreshAirports->setToolTip("Scan directories and reload cache");
	buttonRefreshAirports->setIcon(QIcon(":/icon/import"));
	buttonRefreshAirports->setFlat(true);
	connect(buttonRefreshAirports, SIGNAL(clicked()), this, SLOT(on_rescan_xml_clicked()) );


	//*==============================================================================
	//** Airports/Runways Splitter
	QSplitter *splitter = new QSplitter(this);
	airportsContainerLayout->addWidget(splitter);


	//=== Airport Widget + Layout
	QWidget *airportWidget = new QWidget();
	splitter->addWidget(airportWidget);
	QVBoxLayout *airportsLayout = new QVBoxLayout();
	airportsLayout->setContentsMargins(0,0,0,0);
	airportsLayout->setSpacing(0);
	airportWidget->setLayout(airportsLayout);

	/*  ======== NOTE ============
		# The Airports tree is a treeView
			## with a model/proxt to enable filtersing
			## and the columns constants a CA_
		# The Airport Info is a treeWidget
			## uses CI_ as the column constants
	*/

	//==============================================
	//** Airport Models
    model = new QStandardItemModel(this);
	model->setColumnCount(2);
    QStringList headerLabelsList;
	headerLabelsList << tr("Code") << tr("Name");
    model->setHorizontalHeaderLabels(headerLabelsList);

    proxyModel = new QSortFilterProxyModel(this);
    proxyModel->setSourceModel(model);
    proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
    proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
	proxyModel->setFilterKeyColumn( CA_NAME );

	//==============================================
	//**  TreeView aiports
	treeViewAirports = new QTreeView(this);
	airportsLayout->addWidget(treeViewAirports, 1, 0);
	treeViewAirports->setModel(proxyModel);

	treeViewAirports->setUniformRowHeights(true);
	treeViewAirports->setAlternatingRowColors(true);
	treeViewAirports->setRootIsDecorated(false);
	treeViewAirports->setSortingEnabled(true);
	treeViewAirports->sortByColumn(CA_NAME, Qt::AscendingOrder);
	treeViewAirports->setSelectionMode(QAbstractItemView::SingleSelection);
	treeViewAirports->setSelectionBehavior(QAbstractItemView::SelectRows);
	treeViewAirports->setEditTriggers(QAbstractItemView::NoEditTriggers);

	//** Headers and columns
	treeViewAirports->header()->setStretchLastSection(true);
	treeViewAirports->setColumnWidth(CA_CODE, 80);
	treeViewAirports->setColumnWidth(CA_NAME, 50);

	connect( treeViewAirports->selectionModel(),
			 SIGNAL( currentRowChanged(QModelIndex,QModelIndex) ),
			 this, SLOT( on_airport_tree_selected(QModelIndex,QModelIndex) )
	);

	//* StatusBar for Airports
	statusBarAirports = new QStatusBar();
	statusBarAirports->setSizeGripEnabled(false);
	airportsLayout->addWidget(statusBarAirports);
	statusBarAirports->showMessage("Idle");


	//========================================================
	//** Airport Info Widget
	QWidget *airportInfoWidget = new QWidget();
	splitter->addWidget(airportInfoWidget);
	QVBoxLayout *airportInfoLayout = new QVBoxLayout();
	airportInfoLayout->setContentsMargins(0,0,0,0);
	airportInfoLayout->setSpacing(0);
	airportInfoWidget->setLayout(airportInfoLayout);

	//=========================================================
	//* Airport Info TreeWidget
	treeWidgetAirportInfo = new QTreeWidget();
	airportInfoLayout->addWidget(treeWidgetAirportInfo, 3);
	treeWidgetAirportInfo->setAlternatingRowColors(true);
	treeWidgetAirportInfo->setRootIsDecorated(true);
	QTreeWidgetItem *headerItem = treeWidgetAirportInfo->headerItem();
	headerItem->setText(CI_NODE, tr("Startup Position"));
    headerItem->setText(1, tr("Width"));
    headerItem->setText(2, tr("Length"));
    headerItem->setText(3, tr("Lat"));
    headerItem->setText(4, tr("Lng"));
    headerItem->setText(5, tr("Alignment"));
	//treeWidgetAirportInfo->setColumnHidden(1,true);
	//treeWidgetAirportInfo->setColumnHidden(2,true);
	//treeWidgetAirportInfo->setColumnHidden(3,true);
	//treeWidgetAirportInfo->setColumnHidden(4,true);
	//treeWidgetAirportInfo->setColumnHidden(5,true);


	statusBarAirportInfo = new QStatusBar();
	statusBarAirportInfo->setSizeGripEnabled(false);
	airportInfoLayout->addWidget(statusBarAirportInfo);
	statusBarAirportInfo->showMessage("");


	splitter->setStretchFactor(0, 2);
	splitter->setStretchFactor(1, 2);



	//========================================================================================================
	//** Use Coordinates
	//====================================================================

	groupBoxUseCoordinates = new QGroupBox(this);
	groupBoxUseCoordinates->setTitle("Coordinates");
	groupBoxUseCoordinates->setMaximumWidth(300);
	mainLayout->addWidget(groupBoxUseCoordinates, 1, 2);
	QVBoxLayout *layoutCoordinates = new QVBoxLayout();
	groupBoxUseCoordinates->setLayout(layoutCoordinates);
	int space = 5;

	layoutCoordinates->addWidget(new QLabel(tr("Latitude (negative is west)")));
	txtLat = new QLineEdit();
	layoutCoordinates->addWidget(txtLat);

	layoutCoordinates->addSpacing(space);
	layoutCoordinates->addWidget(new QLabel(tr("Longtitude (negative is south)")));
	txtLng = new QLineEdit();
	layoutCoordinates->addWidget(txtLng);

	layoutCoordinates->addSpacing(space);
	layoutCoordinates->addWidget(new QLabel(tr("Altitude")));
	txtAltitude = new QLineEdit();
	layoutCoordinates->addWidget(txtAltitude);

	layoutCoordinates->addSpacing(space);
	layoutCoordinates->addWidget(new QLabel(tr("Heading")));
	txtHeading = new QLineEdit();
	layoutCoordinates->addWidget(txtHeading);

	layoutCoordinates->addSpacing(space);
	layoutCoordinates->addWidget(new QLabel(tr("Roll")));
	txtRoll = new QLineEdit();
	layoutCoordinates->addWidget(txtRoll);

	layoutCoordinates->addSpacing(space);
	layoutCoordinates->addWidget(new QLabel(tr("Pitch")));
	txtPitch = new QLineEdit();
	layoutCoordinates->addWidget(txtPitch);

	layoutCoordinates->addSpacing(space);
	layoutCoordinates->addWidget(new QLabel(tr("Airspeed")));
	txtAirspeed = new QLineEdit();
	layoutCoordinates->addWidget(txtAirspeed);


	layoutCoordinates->addStretch(20);

	//on_buttonGroupUse();

	connect(buttonGroupFilter, SIGNAL(buttonClicked(QAbstractButton*)),
			this, SLOT(on_update_airports_filter())
	);
}
Пример #8
0
TimeWeatherWidget::TimeWeatherWidget(MainObject *mOb, QWidget *parent) :
    QWidget(parent)
{
	mainObject = mOb;

	QHBoxLayout *mainLayout = new QHBoxLayout();
	setLayout(mainLayout);

	//===============================================================
	// Left Column with Time / Season
	//===============================================================
	QVBoxLayout *layTimeSeason = new QVBoxLayout();
	mainLayout->addLayout(layTimeSeason, 1);

	//===============================================================
	// Time group
	QStringList time_vals; //= are the values
	time_vals << "real" << "dawn" << "morning" << "noon" << "afternoon" << "dusk" << "evening" << "midnight";

	QStringList time_labels; //= are the labels
	time_labels << tr("Real time") << tr("Dawn") << tr("Morning") << tr("Noon") << tr("Afternoon") << tr("Dusk") << tr("Evening") << tr("Midnight");

	XGroupVBox *grpBoxTime = new XGroupVBox(tr("Time"));
	layTimeSeason->addWidget(grpBoxTime);
	buttonGroupTime = new QButtonGroup(this);
	buttonGroupTime->setExclusive(true);
	connect(buttonGroupTime, SIGNAL(buttonClicked(int)),
			this, SLOT(on_time_clicked())
	);

	for(int i=0;  i < time_vals.size(); i++){
		QRadioButton *butt = new QRadioButton();
		butt->setText(time_labels.at(i));
		butt->setProperty("value", QVariant(time_vals.at(i)));
		grpBoxTime->addWidget(butt);
		buttonGroupTime->addButton(butt, i);
	}
	buttonGroupTime->button(0)->setChecked(true);



	//===============================================================
	// Season group
	QStringList season_vals; //= values
	season_vals << "winter" << "summer";

	QStringList season_labels; // = labels
	season_labels << tr("Winter") << tr("Summer");

	XGroupVBox *grpBoxSeason = new XGroupVBox(tr("Season"));
	layTimeSeason->addWidget(grpBoxSeason);
	buttonGroupSeason = new QButtonGroup(this);
	buttonGroupSeason->setExclusive(true);
	connect(buttonGroupSeason, SIGNAL(buttonClicked(int)),
			this, SLOT(on_season_clicked(int))
	);

	for(int i=0;  i < season_vals.size(); i++){
		QRadioButton *buttS = new QRadioButton();
		buttS->setText(season_labels.at(i));
		buttS->setProperty("value", QVariant(season_vals.at(i).toLower()));
		grpBoxSeason->addWidget(buttS);
		buttonGroupSeason->addButton(buttS, i);
	}
	buttonGroupSeason->button(0)->setChecked(true);

	//= Add some stretch to column bottom
	layTimeSeason->addStretch(100);

	//= Add A Spacer in Middle Column
	mainLayout->addStretch(1);


	//===============================================================
	// Right Column with Metar
	//===============================================================
	QVBoxLayout *laymetar = new QVBoxLayout();
	mainLayout->addLayout(laymetar, 2);

	//===============================================================
	// Metar group
	QStringList metar_vals; //= values
	metar_vals << "none" << "live" << "custom";
	QStringList metar_labels; //= labels
	metar_labels << tr("None (default weather)") << tr("Fetch METAR data live") << tr("Set static METAR below");

	XGroupVBox *grpBoxMetar = new XGroupVBox(tr("METAR"));
	laymetar->setAlignment(Qt::AlignTop);
	laymetar->addWidget(grpBoxMetar);
	buttonGroupMetar = new QButtonGroup(this);
	buttonGroupMetar->setExclusive(true);
	connect(buttonGroupMetar, SIGNAL(buttonClicked(int)), this, SLOT(on_weather()));

	for(int i=0;  i < metar_vals.size(); i++){
		QRadioButton *buttM = new QRadioButton();
		buttM->setText(metar_labels.at(i));
		buttM->setProperty("value", QVariant(metar_vals.at(i)));
		grpBoxMetar->addWidget(buttM);
		buttonGroupMetar->addButton(buttM, i);
	}
	buttonGroupMetar->button(0)->setChecked(true);

	txtMetar = new QPlainTextEdit();
	txtMetar->setMaximumHeight(80);
	grpBoxMetar->addWidget(txtMetar);
	laymetar->addStretch(20);


	connect(this, SIGNAL(setx(QString,bool,QString)), mainObject->X, SLOT(set_option(QString,bool,QString)) );
	connect(mainObject->X, SIGNAL(upx(QString,bool,QString)), this, SLOT(on_upx(QString,bool,QString)));

}
Пример #9
0
EmoticonsWidget::EmoticonsWidget(QWidget *parent) :
    QMenu(parent)
{
    setStyleSheet(Style::getStylesheet(":/ui/emoticonWidget/emoticonWidget.css"));
    setLayout(&layout);
    layout.addWidget(&stack);

    QWidget* pageButtonsContainer = new QWidget;
    QHBoxLayout* buttonLayout = new QHBoxLayout;
    pageButtonsContainer->setLayout(buttonLayout);

    layout.addWidget(pageButtonsContainer);

    const int maxCols = 8;
    const int maxRows = 8;
    const int itemsPerPage = maxRows * maxCols;

    const QList<QStringList>& emoticons = SmileyPack::getInstance().getEmoticons();
    int itemCount = emoticons.size();
    int pageCount = ceil(float(itemCount) / float(itemsPerPage));
    int currPage = 0;
    int currItem = 0;
    int row = 0;
    int col = 0;

    // respect configured emoticon size
    const int px = Settings::getInstance().getEmojiFontPointSize();
    const QSize size(px, px);

    // create pages
    buttonLayout->addStretch();
    for (int i = 0; i < pageCount; i++)
    {
        QGridLayout* pageLayout = new QGridLayout;
        pageLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding), maxRows, 0);
        pageLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, maxCols);

        QWidget* page = new QWidget;
        page->setLayout(pageLayout);
        stack.addWidget(page);

        // page buttons are only needed if there is more than 1 page
        if (pageCount > 1)
        {
            QRadioButton* pageButton = new QRadioButton;
            pageButton->setProperty("pageIndex", i);
            pageButton->setCursor(Qt::PointingHandCursor);
            pageButton->setChecked(i == 0);
            buttonLayout->addWidget(pageButton);

            connect(pageButton, &QRadioButton::clicked, this, &EmoticonsWidget::onPageButtonClicked);
        }
    }
    buttonLayout->addStretch();

    for (const QStringList& set : emoticons)
    {
        QPushButton* button = new QPushButton;
        button->setIcon(SmileyPack::getInstance().getAsIcon(set[0]).pixmap(size));
        button->setToolTip(set.join(" "));
        button->setProperty("sequence", set[0]);
        button->setCursor(Qt::PointingHandCursor);
        button->setFlat(true);
        button->setIconSize(size);
        button->setFixedSize(size);

        connect(button, &QPushButton::clicked, this, &EmoticonsWidget::onSmileyClicked);

        qobject_cast<QGridLayout*>(stack.widget(currPage)->layout())->addWidget(button, row, col);

        col++;
        currItem++;

        // next row
        if (col >= maxCols)
        {
            col = 0;
            row++;
        }

        // next page
        if (currItem >= itemsPerPage)
        {
            row = 0;
            currItem = 0;
            currPage++;
        }
    }

    // calculates sizeHint
    layout.activate();
}