void playlistItemText::createPropertiesWidget() { // Absolutely always only call this once// assert (propertiesWidget == NULL); // Create a new widget and populate it with controls propertiesWidget = new QWidget; if (propertiesWidget->objectName().isEmpty()) propertiesWidget->setObjectName(QStringLiteral("playlistItemText")); // On the top level everything is layout vertically QVBoxLayout *vAllLaout = new QVBoxLayout(propertiesWidget); QFrame *line = new QFrame(propertiesWidget); line->setObjectName(QStringLiteral("line")); line->setFrameShape(QFrame::HLine); line->setFrameShadow(QFrame::Sunken); // First add the parents controls (duration) then the text spcific controls (font, text...) vAllLaout->addLayout( createStaticTimeController(propertiesWidget) ); vAllLaout->addWidget( line ); vAllLaout->addLayout( createTextController(propertiesWidget) ); // Insert a stretch at the bottom of the vertical global layout so that everything // gets 'pushed' to the top vAllLaout->insertStretch(3, 1); // Set the layout and add widget propertiesWidget->setLayout( vAllLaout ); }
KateProjectConfigPage::KateProjectConfigPage(QWidget *parent, KateProjectPlugin *plugin) : KTextEditor::ConfigPage(parent) , m_plugin(plugin) , m_changed(false) { QVBoxLayout *layout = new QVBoxLayout(this); layout->setMargin(0); QVBoxLayout *vbox = new QVBoxLayout; QGroupBox *group = new QGroupBox(i18n("Autoload repositories"), this); group->setWhatsThis(i18n( "Project plugin is able to autoload repository working copies when " "there is no .kateproject file defined yet.")); m_cbAutoGit = new QCheckBox(i18n("&Git"), this); vbox->addWidget(m_cbAutoGit); m_cbAutoSubversion = new QCheckBox(i18n("&Subversion"), this); vbox->addWidget(m_cbAutoSubversion); m_cbAutoMercurial = new QCheckBox(i18n("&Mercurial"), this); vbox->addWidget(m_cbAutoMercurial); vbox->addStretch(1); group->setLayout(vbox); layout->addWidget(group); layout->insertStretch(-1, 10); reset(); connect(m_cbAutoGit, &QCheckBox::stateChanged, this, &KateProjectConfigPage::slotMyChanged); connect(m_cbAutoSubversion, &QCheckBox::stateChanged, this, &KateProjectConfigPage::slotMyChanged); connect(m_cbAutoMercurial, &QCheckBox::stateChanged, this, &KateProjectConfigPage::slotMyChanged); }
SpreadDialog::SpreadDialog (QString &nam, QString &fs, QString &ss) : QTabDialog (0, "SpreadDialog", TRUE) { helpFile = "spread.html"; setCaption(tr("Spread Dialog")); QWidget *w = new QWidget(this); QVBoxLayout *vbox = new QVBoxLayout(w); vbox->setMargin(5); vbox->setSpacing(0); QGridLayout *grid = new QGridLayout(vbox, 1, 2); grid->setSpacing(5); grid->setColStretch(1, 1); QLabel *label = new QLabel(tr("Name"), w); grid->addWidget(label, 0, 0); name = new QLineEdit(nam, w); grid->addWidget(name, 0, 1); label = new QLabel(tr("First Symbol"), w); grid->addWidget(label, 1, 0); Config config; QString path; config.getData(Config::DataPath, path); firstSymbol = new SymbolButton(w, path, fs); grid->addWidget(firstSymbol, 1, 1); label = new QLabel(tr("Second Symbol"), w); grid->addWidget(label, 2, 0); secondSymbol = new SymbolButton(w, path, ss); grid->addWidget(secondSymbol, 2, 1); vbox->insertStretch(-1, 1); addTab(w, tr("Settings")); setOkButton(); setCancelButton(); setHelpButton(); QObject::connect(this, SIGNAL(helpButtonPressed()), this, SLOT(help())); resize(400, 300); }
DecodersForm::DecodersForm(QWidget *parent) : QDialog(parent), ui(new Ui::DecodersForm) { int i; GSList *ll; struct srd_decoder *dec; QWidget *pages[MAX_NUM_DECODERS]; ui->setupUi(this); for (ll = srd_list_decoders(), i = 0; ll; ll = ll->next, ++i) { dec = (struct srd_decoder *)ll->data; /* Add the decoder to the list. */ new QListWidgetItem(QString(dec->name), ui->listWidget); /* Add a page for the decoder details. */ pages[i] = new QWidget; /* Add some decoder data to that page. */ QVBoxLayout *l = new QVBoxLayout; l->addWidget(new QLabel("ID: " + QString(dec->id))); l->addWidget(new QLabel("Name: " + QString(dec->name))); l->addWidget(new QLabel("Long name: " + QString(dec->longname))); l->addWidget(new QLabel("Desc: " + QString(dec->desc))); l->addWidget(new QLabel("Long desc: " + QString(dec->longdesc))); l->addWidget(new QLabel("Author: " + QString(dec->author))); l->addWidget(new QLabel("Email: " + QString(dec->email))); l->addWidget(new QLabel("License: " + QString(dec->license))); l->insertStretch(-1); pages[i]->setLayout(l); /* Add the decoder's page to the stackedWidget. */ ui->stackedWidget->addWidget(pages[i]); } }
GolWindow::GolWindow() { board = new GolBoard; sidebar = new QWidget; scrollArea = new QScrollArea; scrollArea->setWidget(board); scrollArea->setWidgetResizable(false); setMinSizeScrollArea(); /* Controls */ QGroupBox *controlsBox = new QGroupBox("Controls"); createControlsBox(controlsBox); /* Preferences */ QGroupBox *prefsBox = new QGroupBox(tr("Preferences")); createPrefsBox(prefsBox); /* Statistics */ QGroupBox *statsBox = new QGroupBox(tr("Statistics")); createStatsBox(statsBox); /* put sidebar together */ QVBoxLayout *vbox = new QVBoxLayout(sidebar); vbox->addWidget(controlsBox, 0, Qt::AlignTop); vbox->addWidget(prefsBox, 0, Qt::AlignTop); vbox->addWidget(statsBox, 0, Qt::AlignTop); vbox->insertStretch(-1, 0); /* create signals */ createSignals(); /* put everything together */ QHBoxLayout *layout = new QHBoxLayout; layout->addWidget(sidebar, 0, Qt::AlignLeft|Qt::AlignTop); layout->addWidget(scrollArea); setWindowTitle(tr("Conway\'s Game of Life")); setLayout(layout); }
KeyBinder::KeyBinder(QWidget * parent, const QString & helpText, const QString & defaultText, const QString & resetButtonText) : QWidget(parent) { this->defaultText = defaultText; enableSignal = false; // Two-column tab layout QHBoxLayout * pageKeysLayout = new QHBoxLayout(this); pageKeysLayout->setSpacing(0); pageKeysLayout->setContentsMargins(0, 0, 0, 0); // Table for category list QVBoxLayout * catListContainer = new QVBoxLayout(); catListContainer->setContentsMargins(10, 10, 10, 10); catList = new QListWidget(); catList->setFixedWidth(180); catList->setStyleSheet("QListWidget::item { font-size: 14px; } QListWidget:hover { border-color: #F6CB1C; } QListWidget::item:selected { background: #150A61; color: yellow; }"); catList->setFocusPolicy(Qt::NoFocus); connect(catList, SIGNAL(currentRowChanged(int)), this, SLOT(changeBindingsPage(int))); catListContainer->addWidget(catList); pageKeysLayout->addLayout(catListContainer); // Reset all binds button if (!resetButtonText.isEmpty()) { QPushButton * btnResetAll = new QPushButton(resetButtonText); catListContainer->addWidget(btnResetAll); btnResetAll->setFixedHeight(40); catListContainer->setStretch(1, 0); catListContainer->setSpacing(10); connect(btnResetAll, SIGNAL(clicked()), this, SIGNAL(resetAllBinds())); } // Container for pages of key bindings QWidget * bindingsPagesContainer = new QWidget(); QVBoxLayout * rightLayout = new QVBoxLayout(bindingsPagesContainer); // Scroll area for key bindings QScrollArea * scrollArea = new QScrollArea(); scrollArea->setContentsMargins(0, 0, 0, 0); scrollArea->setWidget(bindingsPagesContainer); scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); scrollArea->setWidgetResizable(true); scrollArea->setFrameShape(QFrame::NoFrame); scrollArea->setStyleSheet("background: #130F2A;"); // Add key binding pages to bindings tab pageKeysLayout->addWidget(scrollArea); pageKeysLayout->setStretch(1, 1); // Custom help text QLabel * helpLabel = new QLabel(); helpLabel->setText(helpText); helpLabel->setStyleSheet("color: #130F2A; background: #F6CB1C; border: solid 4px #F6CB1C; border-radius: 10px; padding: auto 20px;"); helpLabel->setFixedHeight(24); rightLayout->addWidget(helpLabel, 0, Qt::AlignCenter); // Category list and bind table row heights const int rowHeight = 20; QSize catSize, headerSize; catSize.setHeight(36); headerSize.setHeight(24); // Category list header QListWidgetItem * catListHeader = new QListWidgetItem(tr("Category")); catListHeader->setSizeHint(headerSize); catListHeader->setFlags(Qt::NoItemFlags); catListHeader->setForeground(QBrush(QColor("#130F2A"))); catListHeader->setBackground(QBrush(QColor("#F6CB1C"))); catListHeader->setTextAlignment(Qt::AlignCenter); catList->addItem(catListHeader); // Populate bindingsPages = new QHBoxLayout(); bindingsPages->setContentsMargins(0, 0, 0, 0); rightLayout->addLayout(bindingsPages); QWidget * curPage = NULL; QVBoxLayout * curLayout = NULL; QTableWidget * curTable = NULL; bool bFirstPage = true; selectedBindTable = NULL; bindComboBoxCellMappings = new QHash<QObject *, QTableWidgetItem *>(); bindCellComboBoxMappings = new QHash<QTableWidgetItem *, QComboBox *>(); for (int i = 0; i < BINDS_NUMBER; i++) { if (cbinds[i].category != NULL) { // Add stretch at end of previous layout if (curLayout != NULL) curLayout->insertStretch(-1, 1); // Category list item QListWidgetItem * catItem = new QListWidgetItem(HWApplication::translate("binds (categories)", cbinds[i].category)); catItem->setSizeHint(catSize); catList->addItem(catItem); // Create new page curPage = new QWidget(); curLayout = new QVBoxLayout(curPage); curLayout->setSpacing(2); bindingsPages->addWidget(curPage); if (!bFirstPage) curPage->setVisible(false); } // Description if (cbinds[i].description != NULL) { QLabel * desc = new QLabel(HWApplication::translate("binds (descriptions)", cbinds[i].description)); curLayout->addWidget(desc, 0); QFrame * divider = new QFrame(); divider->setFrameShape(QFrame::HLine); divider->setFrameShadow(QFrame::Plain); curLayout->addWidget(divider, 0); } // New table if (cbinds[i].category != NULL || cbinds[i].description != NULL) { curTable = new QTableWidget(0, 2); curTable->verticalHeader()->setVisible(false); curTable->horizontalHeader()->setVisible(false); curTable->horizontalHeader()->setResizeMode(QHeaderView::Stretch); curTable->verticalHeader()->setDefaultSectionSize(rowHeight); curTable->setShowGrid(false); curTable->setStyleSheet("QTableWidget { border: none; } "); curTable->setSelectionBehavior(QAbstractItemView::SelectRows); curTable->setSelectionMode(QAbstractItemView::SingleSelection); curTable->setFocusPolicy(Qt::NoFocus); connect(curTable, SIGNAL(itemSelectionChanged()), this, SLOT(bindSelectionChanged())); connect(curTable, SIGNAL(itemClicked(QTableWidgetItem *)), this, SLOT(bindCellClicked(QTableWidgetItem *))); curLayout->addWidget(curTable, 0); } // Hidden combo box QComboBox * comboBox = CBBind[i] = new QComboBox(curTable); comboBox->setModel((QAbstractItemModel*)DataManager::instance().bindsModel()); comboBox->setVisible(false); comboBox->setFixedWidth(200); // Table row int row = curTable->rowCount(); QTableWidgetItem * nameCell = new QTableWidgetItem(HWApplication::translate("binds", cbinds[i].name)); nameCell->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); curTable->insertRow(row); curTable->setItem(row, 0, nameCell); QTableWidgetItem * bindCell = new QTableWidgetItem(comboBox->currentText()); bindCell->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); curTable->setItem(row, 1, bindCell); curTable->resizeColumnsToContents(); curTable->setFixedHeight(curTable->verticalHeader()->length() + 10); // Updates the text in the table cell connect(comboBox, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(bindChanged(const QString &))); // Map combo box and that row's cells to each other bindComboBoxCellMappings->insert(comboBox, bindCell); bindCellComboBoxMappings->insert(nameCell, comboBox); bindCellComboBoxMappings->insert(bindCell, comboBox); }
SettingsPageTerrainColors::SettingsPageTerrainColors(QWidget *parent) : QWidget(parent), colorsChanged(false), m_autoSip( true ) { setObjectName("SettingsPageTerrainColors"); setWindowFlags( Qt::Tool ); setWindowModality( Qt::WindowModal ); setAttribute(Qt::WA_DeleteOnClose); setWindowTitle( tr("Settings - Terrain Colors") ); if( parent ) { resize( parent->size() ); } // Layout used by scroll area QHBoxLayout *sal = new QHBoxLayout; // new widget used as container for the dialog layout. QWidget* sw = new QWidget; // Scroll area QScrollArea* sa = new QScrollArea; sa->setWidgetResizable( true ); sa->setFrameStyle( QFrame::NoFrame ); sa->setWidget( sw ); #ifdef QSCROLLER QScroller::grabGesture( sa->viewport(), QScroller::LeftMouseButtonGesture ); #endif #ifdef QTSCROLLER QtScroller::grabGesture( sa->viewport(), QtScroller::LeftMouseButtonGesture ); #endif // Add scroll area to its own layout sal->addWidget( sa ); QHBoxLayout *contentLayout = new QHBoxLayout(this); // Pass scroll area layout to the content layout. contentLayout->addLayout( sal ); /** * Altitude levels in meters to be displayed in color combo box. */ const char *altitudes[51] = { "< 0", "0", "10", "25", "50", "75", "100", "150", "200", "250", "300", "350", "400", "450", "500", "600", "700", "800", "900", "1000", "1250", "1500", "1750", "2000", "2250", "2500", "2750", "3000", "3250", "3500", "3750", "4000", "4250", "4500", "4750", "5000", "5250", "5500", "5750", "6000", "6250", "6500", "6750", "7000", "7250", "7500", "7750", "8000", "8250", "8500", "8750" }; // Determine pixmap size to be used for icons in dependency of the used font int size = QFontMetrics(font()).boundingRect("XM").height() - 2; pixmapSize = QSize( size, size ); QPixmap pixmap(pixmapSize); // load stored terrain colors into working list for( int i = 0; i < SIZEOF_TERRAIN_COLORS; i++ ) { QColor color = GeneralConfig::instance()->getTerrainColor(i); terrainColor[i] = color; } // load ground color groundColor = GeneralConfig::instance()->getGroundColor(); // put all widgets in a HBox layout QHBoxLayout *topLayout = new QHBoxLayout(sw); // create elevation color bar as image elevationImage = new ElevationColorImage( &terrainColor[0], this ); topLayout->addWidget( elevationImage ); // all editor widgets will be put into a group box to get a better view QGroupBox *editBox = new QGroupBox( tr("Color Selection"), this ); // put group box in an extra VBox layout to center it vertically QVBoxLayout *editAll = new QVBoxLayout; editAll->addStretch( 10 ); editAll->addWidget( editBox ); editAll->addStretch( 10 ); topLayout->addLayout( editAll ); // put all edit widgets (combo box and buttons) in a separate VBox layout QVBoxLayout *editLayout = new QVBoxLayout; editLayout->setSpacing( editLayout->spacing() * Layout::getIntScaledDensity() ); QLabel *label = new QLabel( tr("Terrain Level") ); editLayout->addWidget( label ); //-------------------------------------------------------------------------- // The users altitude unit (meters/feed) must be considered during // elevation display in the combo box. QString unit; elevationBox = new QComboBox( this ); #ifdef ANDROID QAbstractItemView* listView = elevationBox->view(); QScrollBar* lvsb = listView->verticalScrollBar(); lvsb->setStyleSheet( Layout::getCbSbStyle() ); #endif #ifdef QSCROLLER elevationBox->view()->setVerticalScrollMode( QAbstractItemView::ScrollPerPixel ); QScroller::grabGesture( elevationBox->view()->viewport(), QScroller::LeftMouseButtonGesture ); #endif #ifdef QTSCROLLER elevationBox->view()->setVerticalScrollMode( QAbstractItemView::ScrollPerPixel ); QtScroller::grabGesture( elevationBox->view()->viewport(), QtScroller::LeftMouseButtonGesture ); #endif if( Altitude::getUnit() == Altitude::meters ) { // use unit meter unit = "m"; for( int i = SIZEOF_TERRAIN_COLORS-1; i > 1; i-- ) { pixmap.fill( terrainColor[i] ); elevationBox->addItem( QIcon( pixmap ), QString(altitudes[i]) + unit ); } } else { // use unit feed unit = "ft"; for( int i = SIZEOF_TERRAIN_COLORS-1; i > 1; i-- ) { int altFeed = static_cast<int>(QString(altitudes[i]).toDouble() * 3.28095); pixmap.fill( terrainColor[i] ); elevationBox->addItem( QIcon( pixmap ), QString::number(altFeed) + unit ); } } pixmap.fill( terrainColor[1] ); elevationBox->addItem( QIcon( pixmap ), QString(altitudes[1]) ); pixmap.fill( terrainColor[0] ); elevationBox->addItem( QIcon( pixmap ), QString(altitudes[0]) ); // set index to level 0 elevationBox->setCurrentIndex( SIZEOF_TERRAIN_COLORS-2 ); editLayout->addWidget( elevationBox ); //-------------------------------------------------------------------------- // add push button for elevation color chooser dialog editColorButton = new QPushButton( tr("Terrain Color") ); // on click the color chooser dialog will be opened connect( editColorButton, SIGNAL(clicked()), this, SLOT(slot_editColor()) ); editLayout->addWidget( editColorButton ); //-------------------------------------------------------------------------- // add push button for ground color chooser dialog groundColorButton = new QPushButton( tr("Ground Color") ); pixmap.fill( groundColor ); groundColorButton->setIcon( QIcon(pixmap) ); // on click the color chooser dialog will be opened connect( groundColorButton, SIGNAL(clicked()), this, SLOT(slot_editGroundColor()) ); editLayout->addSpacing( 10 * Layout::getIntScaledDensity() ); editLayout->addWidget( groundColorButton ); editLayout->addSpacing( 20 * Layout::getIntScaledDensity() ); //-------------------------------------------------------------------------- // add button for assigning of default colors defaultColorButton = new QPushButton( tr("Color Defaults") ); // on click all colors are reset to the defaults connect( defaultColorButton, SIGNAL(clicked()), this, SLOT(slot_setColorDefaults()) ); editLayout->addWidget( defaultColorButton ); // add stretch items to posit editor widgets in the center of the VBox layout editLayout->insertStretch(0, 10 ); editLayout->addStretch( 10 ); editBox->setLayout(editLayout); //-------------------------------------------------------------------------- // add spin box for moving elevation zero line QGroupBox *setOffsetBox = new QGroupBox( tr("Elevation Offset"), this ); // put group box in an extra VBox layout to center it vertically QVBoxLayout *offsetLayout = new QVBoxLayout; offsetLayout->addStretch( 10 ); offsetLayout->addWidget( setOffsetBox ); offsetLayout->addStretch( 10 ); QVBoxLayout *spinboxLayout = new QVBoxLayout; elevationOffset = new QSpinBox; elevationOffset->setSingleStep(1); elevationOffset->setRange(-50, 50); connect( elevationOffset, SIGNAL(editingFinished()), MainWindow::mainWindow(), SLOT(slotCloseSip()) ); VarSpinBox* hspin = new VarSpinBox( elevationOffset ); spinboxLayout->addWidget(hspin); setOffsetBox->setLayout(spinboxLayout); topLayout->addLayout( offsetLayout ); topLayout->insertSpacing(1, 60 ); topLayout->addStretch( 10 ); QPushButton *cancel = new QPushButton(this); cancel->setIcon(QIcon(GeneralConfig::instance()->loadPixmap("cancel.png"))); cancel->setIconSize(QSize(Layout::getButtonSize(12), Layout::getButtonSize(12))); cancel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::QSizePolicy::Preferred); QPushButton *ok = new QPushButton(this); ok->setIcon(QIcon(GeneralConfig::instance()->loadPixmap("ok.png"))); ok->setIconSize(QSize(Layout::getButtonSize(12), Layout::getButtonSize(12))); ok->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::QSizePolicy::Preferred); QLabel *titlePix = new QLabel(this); titlePix->setAlignment( Qt::AlignCenter ); titlePix->setPixmap(GeneralConfig::instance()->loadPixmap("setup.png")); connect(ok, SIGNAL(pressed()), this, SLOT(slotAccept())); connect(cancel, SIGNAL(pressed()), this, SLOT(slotReject())); QVBoxLayout *buttonBox = new QVBoxLayout; buttonBox->setSpacing(0); buttonBox->addStretch(2); buttonBox->addWidget(cancel, 1); buttonBox->addSpacing(30); buttonBox->addWidget(ok, 1); buttonBox->addStretch(2); buttonBox->addWidget(titlePix); contentLayout->addLayout(buttonBox); load(); }
//создание интерфейса void MyServer::createGui(){ //панель управления логом prevButton = new QPushButton("<<",this); prevButton->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); prevButton->setEnabled(false); connect(prevButton, SIGNAL(clicked(bool)),this,SLOT(slotPrevButton())); nextButton = new QPushButton(">>",this); nextButton->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); nextButton->setEnabled(false); connect(nextButton,SIGNAL(clicked(bool)),this,SLOT(slotNextButton())); logNumber = new QLabel("1",this); logNumber->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); QHBoxLayout *logButtonsLayout = new QHBoxLayout; logButtonsLayout->addWidget(prevButton); logButtonsLayout->insertStretch(-1); logButtonsLayout->addWidget(logNumber); logButtonsLayout->insertStretch(-1); logButtonsLayout->addWidget(nextButton); //лог txtStack = new QStackedWidget(this); txtStack->setSizePolicy(QSizePolicy::Ignored,QSizePolicy::Expanding); txtStack->setFixedSize(screen.width()*PERCENT_OF_SCREEN*PERCENT_OF_SCREEN*0.7f, screen.height()*PERCENT_OF_SCREEN*0.7f); QTextEdit *txt = new QTextEdit(txtStack); txt->setReadOnly(true); txtStack->addWidget(txt); //левая панель сервера (лог и кнопки) QVBoxLayout *leftPanelLayout = new QVBoxLayout(); leftPanelLayout->addWidget(txtStack); leftPanelLayout->addLayout(logButtonsLayout); //правая панель (кнопки создания и удаления кораблей) QPushButton *createShipButton = new QPushButton ("Добавить корабль",this); createShipButton->setFixedWidth(createShipButton->sizeHint().width()*1.3); connect(createShipButton,SIGNAL(clicked()),this,SLOT(slotNewShip())); deleteShipButton = new QPushButton ("Удалить корабль",this); deleteShipButton->setFixedWidth(createShipButton->sizeHint().width()*1.3); deleteShipButton->setEnabled(false); connect(deleteShipButton,SIGNAL(clicked(bool)),this,SLOT(slotDeleteShip())); messageLabel=new QLabel("",this); QVBoxLayout *rightPanelLayout = new QVBoxLayout; rightPanelLayout->addWidget(createShipButton); rightPanelLayout->addWidget(deleteShipButton); rightPanelLayout->addWidget(messageLabel); rightPanelLayout->insertStretch(-1); QHBoxLayout *mainPanelLayout = new QHBoxLayout; mainPanelLayout->addLayout(leftPanelLayout); mainPanelLayout->addLayout(rightPanelLayout); setLayout(mainPanelLayout); setFixedSize(sizeHint().width(),sizeHint().height()); }
IndexDialog::IndexDialog (QString &nam, QString &l) : QTabDialog (0, "IndexDialog", TRUE) { helpFile = "indexes.html"; QWidget *w = new QWidget(this); QVBoxLayout *vbox = new QVBoxLayout(w); vbox->setMargin(5); vbox->setSpacing(5); QGridLayout *grid = new QGridLayout(vbox); grid->setColStretch(1, 1); grid->setSpacing(5); QLabel *label = new QLabel(tr("Name"), w); grid->addWidget(label, 0, 0); name = new QLineEdit(nam, w); grid->addWidget(name, 0, 1); QHBoxLayout *hbox = new QHBoxLayout(vbox); hbox->setSpacing(2); list = new QListView(w); list->addColumn(tr("Symbol"), 200); list->addColumn(tr("Weight"), -1); QObject::connect(list, SIGNAL(selectionChanged()), this, SLOT(buttonStatus())); hbox->addWidget(list); toolbar = new Toolbar(w, Toolbar::Vertical); hbox->addWidget(toolbar); QString s = "add"; QString s2 = tr("Add Item"); toolbar->addButton(s, insert, s2); QObject::connect(toolbar->getButton(s), SIGNAL(clicked()), this, SLOT(addItem())); s = "edit"; s2 = tr("Edit"); toolbar->addButton(s, edit, s2); QObject::connect(toolbar->getButton(s), SIGNAL(clicked()), this, SLOT(editItem())); s = "delete"; s2 = tr("Delete"); toolbar->addButton(s, deleteitem, s2); QObject::connect(toolbar->getButton(s), SIGNAL(clicked()), this, SLOT(deleteItem())); vbox->insertStretch(-1, 1); addTab(w, tr("Details")); setOkButton(tr("&OK")); setCancelButton(tr("&Cancel")); connect(this, SIGNAL(applyButtonPressed()), this, SLOT(accept())); setHelpButton(); QObject::connect(this, SIGNAL(helpButtonPressed()), this, SLOT(help())); setList(l); resize(325, 250); }
PlayerBox::PlayerBox(bool playerOne, QWidget* parent, const char* name) : QGroupBox(parent, name) { QHBoxLayout* l = new QHBoxLayout(this, PLAYERBOX_BORDERS, PLAYERBOX_HDISTANCEOFWIDGETS); // The card and "held" label arrays. m_cardWidgets = new CardWidget *[PokerHandSize]; m_heldLabels = new QLabel *[PokerHandSize]; QFont myFixedFont; myFixedFont.setPointSize(12); // Generate the 5 cards for (int i = 0; i < PokerHandSize; i++) { QVBoxLayout* vl = new QVBoxLayout(0); l->addLayout(vl, 0); QHBox* cardBox = new QHBox(this); vl->addWidget(cardBox, 0); cardBox->setFrameStyle(Box | Sunken); m_cardWidgets[i] = new CardWidget(cardBox); cardBox->setFixedSize(cardBox->sizeHint()); // Only add the "held" labels if this is the first player (the human one). if (playerOne) { QHBox* b = new QHBox(this); m_heldLabels[i] = new QLabel(b); m_heldLabels[i]->setText(i18n("Held")); b->setFrameStyle(Box | Sunken); b->setFixedSize(b->sizeHint()); m_cardWidgets[i]->heldLabel = m_heldLabels[i]; QHBoxLayout* heldLayout = new QHBoxLayout(0); heldLayout->addWidget(b, 0, AlignCenter); vl->insertLayout(0, heldLayout, 0); vl->insertStretch(0, 1); vl->addStretch(1); } } // Add the cash and bet labels. { QVBoxLayout* vl = new QVBoxLayout; l->addLayout(vl); vl->addStretch(); m_cashLabel = new QLabel(this); m_cashLabel->setFrameStyle(QFrame::WinPanel | QFrame::Sunken); m_cashLabel->setFont(myFixedFont); vl->addWidget(m_cashLabel, 0, AlignHCenter); vl->addStretch(); m_betLabel = new QLabel(this); m_betLabel->setFrameStyle(QFrame::WinPanel | QFrame::Sunken); m_betLabel->setFont(myFixedFont); vl->addWidget(m_betLabel, 0, AlignHCenter); vl->addStretch(); } QToolTip::add(m_cashLabel, i18n("Money of %1").arg("Player"));//change via showName() // Assume that we have a multiplayer game. m_singlePlayer = false; }
KateFileTreeConfigPage::KateFileTreeConfigPage(QWidget *parent, KateFileTreePlugin *fl) : KTextEditor::ConfigPage(parent), m_plug(fl), m_changed(false) { QVBoxLayout *layout = new QVBoxLayout(this); layout->setMargin(0); gbEnableShading = new QGroupBox(i18n("Background Shading"), this); gbEnableShading->setCheckable(true); layout->addWidget(gbEnableShading); QGridLayout *lo = new QGridLayout(gbEnableShading); kcbViewShade = new KColorButton(gbEnableShading); lViewShade = new QLabel(i18n("&Viewed documents' shade:"), gbEnableShading); lViewShade->setBuddy(kcbViewShade); lo->addWidget(lViewShade, 2, 0); lo->addWidget(kcbViewShade, 2, 1); kcbEditShade = new KColorButton(gbEnableShading); lEditShade = new QLabel(i18n("&Modified documents' shade:"), gbEnableShading); lEditShade->setBuddy(kcbEditShade); lo->addWidget(lEditShade, 3, 0); lo->addWidget(kcbEditShade, 3, 1); // sorting QHBoxLayout *lo2 = new QHBoxLayout; layout->addLayout(lo2); lSort = new QLabel(i18n("&Sort by:"), this); lo2->addWidget(lSort); cmbSort = new KComboBox(this); lo2->addWidget(cmbSort); lSort->setBuddy(cmbSort); cmbSort->addItem(i18n("Opening Order"), (int)KateFileTreeModel::OpeningOrderRole); cmbSort->addItem(i18n("Document Name"), (int)Qt::DisplayRole); cmbSort->addItem(i18n("Url"), (int)KateFileTreeModel::PathRole); // view mode QHBoxLayout *lo3 = new QHBoxLayout; layout->addLayout(lo3); lMode = new QLabel(i18n("&View Mode:"), this); lo3->addWidget(lMode); cmbMode = new KComboBox(this); lo3->addWidget(cmbMode); lMode->setBuddy(cmbMode); cmbMode->addItem(i18n("Tree View"), QVariant(false)); cmbMode->addItem(i18n("List View"), QVariant(true)); // Show Full Path on Roots? QHBoxLayout *lo4 = new QHBoxLayout; layout->addLayout(lo4); cbShowFullPath = new QCheckBox(i18n("&Show Full Path"), this); lo4->addWidget(cbShowFullPath); layout->insertStretch(-1, 10); gbEnableShading->setWhatsThis(i18n( "When background shading is enabled, documents that have been viewed " "or edited within the current session will have a shaded background. " "The most recent documents have the strongest shade.")); kcbViewShade->setWhatsThis(i18n( "Set the color for shading viewed documents.")); kcbEditShade->setWhatsThis(i18n( "Set the color for modified documents. This color is blended into " "the color for viewed files. The most recently edited documents get " "most of this color.")); cbShowFullPath->setWhatsThis(i18n( "When enabled, in tree mode, top level folders will show up with their full path " "rather than just the last folder name.")); // cmbSort->setWhatsThis( i18n( // "Set the sorting method for the documents.") ); reset(); connect(gbEnableShading, SIGNAL(toggled(bool)), this, SLOT(slotMyChanged())); connect(kcbViewShade, SIGNAL(changed(QColor)), this, SLOT(slotMyChanged())); connect(kcbEditShade, SIGNAL(changed(QColor)), this, SLOT(slotMyChanged())); connect(cmbSort, SIGNAL(activated(int)), this, SLOT(slotMyChanged())); connect(cmbMode, SIGNAL(activated(int)), this, SLOT(slotMyChanged())); connect(cbShowFullPath, SIGNAL(stateChanged(int)), this, SLOT(slotMyChanged())); }
void FuturesDialog::createDetailsPage () { QWidget *w = new QWidget(this); QVBoxLayout *vbox = new QVBoxLayout(w); vbox->setMargin(5); vbox->setSpacing(0); QGridLayout *grid = new QGridLayout(vbox); grid->setSpacing(5); QLabel *label = new QLabel(tr("Symbol"), w); grid->addWidget(label, 0, 0); QString s; DBIndexItem item; index->getIndexItem(symbol, item); item.getSymbol(s); label = new QLabel(s, w); label->setFrameStyle(QFrame::WinPanel | QFrame::Sunken); grid->addWidget(label, 0, 1); label = new QLabel(tr("Name"), w); grid->addWidget(label, 1, 0); item.getTitle(s); title = new QLineEdit(s, w); grid->addWidget(title, 1, 1); label = new QLabel(tr("Exchange"), w); grid->addWidget(label, 2, 0); item.getExchange(s); Exchange ex; ex.getExchange(s.toInt(), s); label = new QLabel(s, w); label->setFrameStyle(QFrame::WinPanel | QFrame::Sunken); grid->addWidget(label, 2, 1); label = new QLabel(tr("Type"), w); grid->addWidget(label, 3, 0); item.getType(s); label = new QLabel(s, w); label->setFrameStyle(QFrame::WinPanel | QFrame::Sunken); grid->addWidget(label, 3, 1); label = new QLabel(tr("Futures Type"), w); grid->addWidget(label, 4, 0); QString s2; item.getFuturesType(s2); label = new QLabel(s2, w); label->setFrameStyle(QFrame::WinPanel | QFrame::Sunken); grid->addWidget(label, 4, 1); label = new QLabel(tr("Futures Month"), w); grid->addWidget(label, 5, 0); item.getFuturesMonth(s2); label = new QLabel(s2, w); label->setFrameStyle(QFrame::WinPanel | QFrame::Sunken); grid->addWidget(label, 5, 1); label = new QLabel(tr("First Date"), w); grid->addWidget(label, 6, 0); Bar bar; db->getFirstBar(bar); if (! bar.getEmptyFlag()) { bar.getDateTimeString(TRUE, s); label = new QLabel(s, w); label->setFrameStyle(QFrame::WinPanel | QFrame::Sunken); grid->addWidget(label, 6, 1); } label = new QLabel(tr("Last Date"), w); grid->addWidget(label, 7, 0); Bar bar2; db->getLastBar(bar2); if (! bar2.getEmptyFlag()) { bar2.getDateTimeString(TRUE, s); label = new QLabel(s, w); label->setFrameStyle(QFrame::WinPanel | QFrame::Sunken); grid->addWidget(label, 7, 1); } grid->setColStretch(1, 1); vbox->insertStretch(-1, 0); addTab(w, tr("Details")); }
MainDialog::MainDialog(QWidget *parent) : QDialog(parent) , mHostEdit(new QLineEdit) , mPortEdit(new QLineEdit) , mUserEdit(new QLineEdit) , mPswdEdit(new QLineEdit) , mLAddrEdit(new QLineEdit) , mLPortEdit(new QLineEdit) , mWaitEdit(new QLineEdit) , mCtrlBtn(new QPushButton(tr("Start"))) , mQuitBtn(new QPushButton(tr("Quit"))) , mLogList(new QListWidget) , mInfoIcon(QPixmap(":/icon-info.png")) , mWarnIcon(QPixmap(":/icon-warn.png")) , mErrorIcon(QPixmap(":/icon-error.png")) , mStoppedIcon(QPixmap(":/icon-stopped.png")) , mConnectingIcon(QPixmap(":/icon-connecting.png")) , mConnectedIcon(QPixmap(":/icon-connected.png")) , mSleepingIcon(QPixmap(":/icon-sleeping.png")) , mSettings(new QSettings(QSettings::IniFormat, QSettings::UserScope, "glacjay", "sshproxy", this)) , mIsKeepRunning(false) , mProcess(new QProcess(this)) , mRestartTimer(new QTimer(this)) { setWindowTitle(tr("SSH Proxy")); setWindowIcon(mConnectedIcon); mHostEdit->setText(mSettings->value("ssh/host").toString()); mPortEdit->setText(mSettings->value("ssh/port", "22").toString()); mUserEdit->setText(mSettings->value("ssh/user").toString()); mLAddrEdit->setText(mSettings->value("ssh/laddr", "127.0.0.1").toString()); mLPortEdit->setText(mSettings->value("ssh/lport", "1077").toString()); mWaitEdit->setText(mSettings->value("ssh/wait", "10").toString()); mPortEdit->setValidator(new QIntValidator(1, 65535)); mPswdEdit->setEchoMode(QLineEdit::Password); mLPortEdit->setValidator(new QIntValidator(1, 65535)); mWaitEdit->setValidator(new QIntValidator); mLogList->setWordWrap(true); mProcess->setProcessChannelMode(QProcess::MergedChannels); QLabel *hostLabel = new QLabel(tr("SSH Host:")); hostLabel->setBuddy(mHostEdit); QLabel *portLabel = new QLabel(tr("SSH Port:")); portLabel->setBuddy(mPortEdit); QLabel *userLabel = new QLabel(tr("Username:"******"Password:"******"Listen Addr:")); lAddrLabel->setBuddy(mLAddrEdit); QLabel *lPortLabel = new QLabel(tr("Listen Port:")); lPortLabel->setBuddy(mLPortEdit); QLabel *waitLabel = new QLabel(tr("Seconds wait to reconnect:")); waitLabel->setBuddy(mWaitEdit); QVBoxLayout *inputLayout = new QVBoxLayout; inputLayout->addWidget(hostLabel); inputLayout->addWidget(mHostEdit); inputLayout->addWidget(portLabel); inputLayout->addWidget(mPortEdit); inputLayout->addWidget(userLabel); inputLayout->addWidget(mUserEdit); inputLayout->addWidget(pswdLabel); inputLayout->addWidget(mPswdEdit); inputLayout->addWidget(lAddrLabel); inputLayout->addWidget(mLAddrEdit); inputLayout->addWidget(lPortLabel); inputLayout->addWidget(mLPortEdit); inputLayout->addWidget(waitLabel); inputLayout->addWidget(mWaitEdit); inputLayout->insertStretch(-1); inputLayout->addWidget(mCtrlBtn); inputLayout->addWidget(mQuitBtn); QGroupBox *inputGroup = new QGroupBox(tr("Settings")); inputGroup->setLayout(inputLayout); QVBoxLayout *logLayout = new QVBoxLayout; logLayout->addWidget(mLogList); QGroupBox *logGroup = new QGroupBox(tr("Log")); logGroup->setLayout(logLayout); QSplitter *splitter = new QSplitter(Qt::Horizontal); splitter->addWidget(inputGroup); splitter->addWidget(logGroup); splitter->setStretchFactor(1, 5); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addWidget(splitter); setLayout(mainLayout); resize(1000, 600); connect(mCtrlBtn, SIGNAL(clicked(void)), this, SLOT(on_mCtrlBtn_clicked(void))); connect(mQuitBtn, SIGNAL(clicked(void)), this, SLOT(onQuit(void))); mTray = new QSystemTrayIcon(mStoppedIcon); mTray->show(); setSshStatus(StatStopped); connect(mTray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(on_mTray_activated(QSystemTrayIcon::ActivationReason))); QAction *toggleAction = new QAction(tr("Toggle Main Dialog"), this); connect(toggleAction, SIGNAL(triggered(void)), this, SLOT(on_toggleAction_triggered(void))); QAction *quitAction = new QAction(tr("Quit"), this); connect(quitAction, SIGNAL(triggered(void)), this, SLOT(onQuit(void))); QMenu *trayMenu = new QMenu; trayMenu->addAction(toggleAction); trayMenu->addSeparator(); trayMenu->addAction(quitAction); mTray->setContextMenu(trayMenu); connect(qApp, SIGNAL(aboutToQuit(void)), this, SLOT(onQuit(void))); connect(mProcess, SIGNAL(started(void)), this, SLOT(on_mProcess_started(void))); connect(mProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(on_mProcess_finished(int, QProcess::ExitStatus))); connect(mProcess, SIGNAL(error(QProcess::ProcessError)), this, SLOT(on_mProcess_error(QProcess::ProcessError))); connect(mProcess, SIGNAL(readyReadStandardOutput(void)), this, SLOT(on_mProcess_readyReadStandardOutput(void))); connect(mRestartTimer, SIGNAL(timeout(void)), this, SLOT(startRunning(void))); if (mHostEdit->text().isEmpty()) mHostEdit->setFocus(); else if (mPortEdit->text().isEmpty()) mPortEdit->setFocus(); else if (mUserEdit->text().isEmpty()) mUserEdit->setFocus(); else if (mPswdEdit->text().isEmpty()) mPswdEdit->setFocus(); else if (mLAddrEdit->text().isEmpty()) mLAddrEdit->setFocus(); else if (mLPortEdit->text().isEmpty()) mLPortEdit->setFocus(); else if (mWaitEdit->text().isEmpty()) mWaitEdit->setFocus(); }