MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { //ui->setupUi(this); setFixedHeight(768); //1024 setFixedWidth(768); //Define page structure QWidget * page = new QWidget(this); page->setFixedWidth(this->width()); page->setFixedHeight(this->height()); page->setStyleSheet("background-color:white;"); QVBoxLayout * pageLayout = new QVBoxLayout(); //Define the fixed header QWidget * header = new QWidget(page); header->setFixedWidth(page->width()); QGridLayout * headerLayout = new QGridLayout(); headerLayout->setHorizontalSpacing(2); headerLayout->setVerticalSpacing(2); QLabel * numTable = new QLabel(); QPixmap numTableIm(":/Images/images/NumTable.png"); // numTable->setStyleSheet("margin-right: 5px"); numTable->setPixmap(numTableIm); numTable->setFixedSize(numTableIm.rect().size()); QLabel * banner = new QLabel(header); QPixmap bannerIm(":/Images/images/Banner.png"); banner->setPixmap(bannerIm); banner->setFixedSize(bannerIm.rect().size()); QPushButton * pain = new QPushButton(""); QPixmap painIm(":/Images/images/Pain.png"); QIcon painIcon(painIm); pain->setIcon(painIcon); pain->setIconSize(painIm.rect().size()); pain->setFixedSize(painIm.rect().size()); QPushButton * eau = new QPushButton(""); QPixmap eauIm(":/Images/images/eau.png"); QIcon eauIcon(eauIm); eau->setIcon(eauIcon); eau->setIconSize(eauIm.rect().size()); eau->setFixedSize(eauIm.rect().size()); QPushButton * serveur = new QPushButton(""); QPixmap serveurIm(":/Images/images/Serveur.png"); QIcon serveurIcon(serveurIm); serveur->setIcon(serveurIcon); serveur->setIconSize(serveurIm.rect().size()); serveur->setFixedSize(serveurIm.rect().size()); headerLayout->addWidget(numTable, 0, 0, 2, 0); headerLayout->addWidget(banner, 0, 1, 2, 1); headerLayout->addWidget(serveur,0, 2, 2, 2); headerLayout->addWidget(pain, 0, 3); headerLayout->addWidget(eau, 1, 3); header->setLayout(headerLayout); //Define the widget containing all the meals (Tabs) QTabWidget * repasFrame = new QTabWidget(page); //For one Meal, define the widget containing all the bands QWidget * area = new QWidget(repasFrame); QScrollArea * sArea = new QScrollArea(area); QPalette * palette = new QPalette(); palette->setColor(QPalette::Background, Qt::white); sArea->setPalette(*palette); sArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); sArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); sArea->setFixedWidth(page->width() -20); sArea->setFixedHeight(page->height() - header->height() - 125); bands = new QWidget(); bands->setFixedWidth(page->width() -25); // bands->setMinimumHeight(page->height() - header->height() - 125); bands->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Ignored); bandsLayout = new QVBoxLayout(bands); Headband* menus = HeadbandFactory::buildMenus(bands); bandList.append(menus); bandsLayout->addWidget(menus); usefulLabel = new QLabel(); bandsLayout->addWidget(usefulLabel); bands->setLayout(bandsLayout); sArea->setWidget(bands); repasFrame->setFixedWidth(page->width()); repasFrame->setFixedHeight(page->height() - header->height()); repasFrame->addTab(area, "Repas 1"); repasFrame->addTab(new QLabel(), "+"); //Define the confirmation button QPushButton * confirmButton = new QPushButton(""); QPixmap confirmIm(":/Images/images/Confirm.jpg"); QIcon confirmIcon(confirmIm); confirmButton->setIcon(confirmIcon); confirmButton->setIconSize(confirmIm.rect().size()); confirmButton->setFixedSize(confirmIm.rect().size()); //Define the 'languette' and its 'etiquette' QList<QList<QObject*> > bigDataList; languetteContainer = new LanguetteContainer(bigDataList); languetteContainer->setFixedSize(760, 855); Etiquette * etiquette = new Etiquette(languetteContainer, confirmButton, page); //Link final page layouts pageLayout->addWidget(header); pageLayout->addWidget(repasFrame); pageLayout->addWidget(etiquette); pageLayout->addWidget(confirmButton); pageLayout->addWidget(languetteContainer); page->setLayout(pageLayout); //connect all slots connect(etiquette, SIGNAL(updateLanguetteInfo()), this, SLOT(recapLanguette())); connect(menus, SIGNAL(itemSelect(Headband_Item*)), this, SLOT(changeMenu(Headband_Item*))); connect(confirmButton, SIGNAL(clicked()), this, SLOT(confirmMeal())); connect(pain, SIGNAL(clicked()), this, SLOT(callBread())); connect(eau, SIGNAL(clicked()), this, SLOT(callWater())); connect(serveur, SIGNAL(clicked()), this, SLOT(callServer())); setCentralWidget(page); }
NotificationDialog::NotificationDialog(Notification *notification, QWidget *parent) : QFrame(parent), m_notification(notification), m_closeLabel(new QLabel(this)), m_iconLabel(new QLabel(this)), m_messageLabel(new QLabel(this)), m_closeTimer(0) { m_iconLabel->setStyleSheet(QLatin1String("padding:5px;")); m_iconLabel->setAttribute(Qt::WA_TransparentForMouseEvents); m_messageLabel->setStyleSheet(QLatin1String("padding:5px;font-size:13px;")); m_messageLabel->setAttribute(Qt::WA_TransparentForMouseEvents); m_messageLabel->setWordWrap(true); QStyleOption option; option.rect = QRect(0, 0, 16, 16); option.state = (QStyle::State_Enabled | QStyle::State_AutoRaise); QPixmap pixmap(16, 16); pixmap.fill(Qt::transparent); QPainter painter(&pixmap); style()->drawPrimitive(QStyle::PE_IndicatorTabClose, &option, &painter, this); m_closeLabel->setToolTip(tr("Close")); m_closeLabel->setPixmap(pixmap); m_closeLabel->setAttribute(Qt::WA_TransparentForMouseEvents); m_closeLabel->setAlignment(Qt::AlignTop); m_closeLabel->setMargin(5); QBoxLayout *layout(new QBoxLayout(QBoxLayout::LeftToRight)); layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); layout->setSizeConstraint(QLayout::SetMinimumSize); layout->addWidget(m_iconLabel); layout->addWidget(m_messageLabel); layout->addWidget(m_closeLabel); setLayout(layout); setObjectName(QLatin1String("notificationFrame")); setStyleSheet(QLatin1String("#notificationFrame {padding:5px;border:1px solid #CCC;border-radius:10px;background:#F0F0f0;}")); setCursor(QCursor(Qt::PointingHandCursor)); setFixedWidth(400); setMinimumHeight(50); setMaximumHeight(150); setWindowOpacity(0); setWindowFlags(Qt::WindowStaysOnTopHint | Qt::Tool | Qt::FramelessWindowHint); setFocusPolicy(Qt::NoFocus); setAttribute(Qt::WA_DeleteOnClose, true); setAttribute(Qt::WA_ShowWithoutActivating, true); updateMessage(); adjustSize(); m_animation = new QPropertyAnimation(this, QStringLiteral("windowOpacity").toLatin1()); m_animation->setDuration(500); m_animation->setStartValue(0.0); m_animation->setEndValue(1.0); m_animation->start(); const int visibilityDuration(SettingsManager::getOption(SettingsManager::Interface_NotificationVisibilityDurationOption).toInt()); if (visibilityDuration > 0) { m_closeTimer = startTimer(visibilityDuration * 1000); } connect(notification, &Notification::modified, this, &NotificationDialog::updateMessage); connect(notification, &Notification::requestedClose, this, &NotificationDialog::close); }
CQFontChooser:: CQFontChooser(QWidget *parent) : QWidget(parent), style_(FontButton), fixedWidth_(false), exampleText_("Abc") { setObjectName("fontChooser"); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); font_ = font(); fontName_ = font_.toString(); //----- QHBoxLayout *layout = new QHBoxLayout(this); layout->setMargin(0); layout->setSpacing(0); cedit_ = new QLineEdit (this); cedit_ ->setObjectName("cedit"); cbutton_ = new QToolButton(this); cbutton_->setObjectName("cbutton"); clabel_ = new QLabel (this); clabel_ ->setObjectName("clabel"); button_ = new QToolButton(this); button_ ->setObjectName("button"); ncombo_ = new QFontComboBox(this); ncombo_->setObjectName("ncombo"); scombo_ = new QComboBox (this); scombo_->setObjectName("scombo"); zcombo_ = new QComboBox (this); zcombo_->setObjectName("zcombo"); button_->setIcon(CQPixmapCacheInst->getIcon("FONT_DIALOG")); ncombo_->setWritingSystem(QFontDatabase::Latin); //cbutton_->setFixedSize(QSize(24,24)); //clabel_ ->setFixedSize(QSize(24,24)); //button_ ->setFixedSize(QSize(24,24)); cbutton_->setText(exampleText_); clabel_ ->setText(exampleText_); layout->addWidget(cedit_ ); layout->addWidget(cbutton_); layout->addWidget(clabel_ ); layout->addWidget(button_ ); layout->addWidget(ncombo_ ); layout->addWidget(scombo_ ); layout->addWidget(zcombo_ ); // TODO: add strecth widget and hide if any of the stretchable widgets are visible //layout->addStretch(); cedit_ ->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); cbutton_->setSizePolicy(QSizePolicy::Fixed , QSizePolicy::Fixed); clabel_ ->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); button_ ->setSizePolicy(QSizePolicy::Fixed , QSizePolicy::Fixed); ncombo_->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); scombo_->setSizePolicy(QSizePolicy::Fixed , QSizePolicy::Fixed); zcombo_->setSizePolicy(QSizePolicy::Fixed , QSizePolicy::Fixed); connect(cedit_ , SIGNAL(editingFinished()), this, SLOT(editFont ())); connect(cbutton_, SIGNAL(clicked() ), this, SLOT(applyFont ())); connect(button_ , SIGNAL(clicked() ), this, SLOT(chooseFont())); connect(ncombo_ , SIGNAL(activated(int)), this, SLOT(nameChanged ())); connect(scombo_ , SIGNAL(activated(int)), this, SLOT(styleChanged())); connect(zcombo_ , SIGNAL(activated(int)), this, SLOT(sizeChanged ())); setStyle(FontEdit); setFixedWidth(false); //----- updateWidgets(); setFocusProxy(cedit_); }
void ScriptEdit::NumberBar::update() { int w = fontMetrics().width(QString::number(highestLine)) + 22; if(width() != w) setFixedWidth(w); QWidget::update(); }
TrayNotificationWidget::TrayNotificationWidget(QPixmap pixmapIcon, QString headerText, QString messageText) : QWidget(0) { setWindowFlags( #ifdef Q_WS_MAC Qt::SubWindow | // This type flag is the second point #else Qt::Tool | #endif Qt::FramelessWindowHint | Qt::WindowSystemMenuHint | Qt::WindowStaysOnTopHint ); setAttribute(Qt::WA_NoSystemBackground, true); // set the parent widget's background to translucent setAttribute(Qt::WA_TranslucentBackground, true); //setAttribute(Qt::WA_ShowWithoutActivating, true); setFixedWidth(310); setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); // create a display widget for displaying child widgets QWidget* displayWidget = new QWidget; displayWidget->setStyleSheet(".QWidget { background-color: rgba(0, 0, 0, 75%); border-width: 1px; border-style: solid; border-radius: 10px; border-color: #555555; } .QWidget:hover { background-color: rgba(68, 68, 68, 75%); border-width: 2px; border-style: solid; border-radius: 10px; border-color: #ffffff; }"); displayWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); QLabel* icon = new QLabel; icon->setPixmap(pixmapIcon); icon->setMaximumSize(32, 32); QLabel* header = new QLabel; header->setStyleSheet("QLabel { color: #ffffff; font-weight: bold; font-size: 12px; }"); header->setText(headerText); header->setFixedWidth(200); header->setWordWrap(true); header->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); QTextEdit *message = new QTextEdit; message->setReadOnly(true); message->setFrameStyle(QFrame::NoFrame); message->setLineWrapMode(QTextEdit::WidgetWidth); message->setWordWrapMode(QTextOption::WrapAnywhere); QPalette pal = palette(); pal.setColor(QPalette::Base, Qt::transparent); message->setPalette(pal); message->setStyleSheet("QTextEdit { color: #ffffff; font-size: 10px; }"); message->setText(messageText); message->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); QVBoxLayout* vl = new QVBoxLayout; vl->addWidget(header); vl->addWidget(message); QHBoxLayout* displayMainLayout = new QHBoxLayout; displayMainLayout->addWidget(icon); displayMainLayout->addLayout(vl); displayWidget->setLayout(displayMainLayout); QHBoxLayout* containerLayout = new QHBoxLayout; containerLayout->addWidget(displayWidget); setLayout(containerLayout); show(); resize(this->size().width(), (int)((message->document()->size().height() + header->height()) +70)); timeout = new QTimer(this); connect(timeout, SIGNAL(timeout()), this, SLOT(fadeOut())); timeout->start(3000); }
//added by Rolando 04-11-08 void QtFlagsListWidget::setSize(int width, int height) { setFixedHeight (height); setFixedWidth(width); }
void CompleterTextEditNumberBar::paintEvent(QPaintEvent *event) { QTextDocument* doc=editor->document(); QAbstractTextDocumentLayout *layout = doc->documentLayout(); qreal yPosition=editor->verticalScrollBar()->value(); qreal vpHeight=editor->viewport()->height(); QPainter p(this); p.setFont(linenumberFont); int linenumberWidth=QString::number(doc->blockCount()).size()*p.fontMetrics().width("0")+4; int markerheight=p.fontMetrics().ascent()+2; // set the width of the widget setFixedWidth(linenumberWidth+markerWidth+2); // first we draw the background p.setBrush(QBrush(linenumberColumnColor)); p.setPen(QPen(linenumberColumnColor)); p.drawRect(0,0,width(),vpHeight); p.setPen(QPen(markerColumnColor)); p.setBrush(QBrush(markerColumnColor)); p.drawRect(linenumberWidth,0,width()-linenumberWidth,vpHeight); // reset the rect of all markers QMutableMapIterator<int, itemData> i(markers); while (i.hasNext()) { i.next(); itemData d=i.value(); d.rect=QRect(0,0,0,0); i.setValue(d); } // now we draw the line numbers p.setPen(QPen(linenumberColor)); for (QTextBlock it = doc->begin(); it != doc->end(); it = it.next()) { QRectF brect=layout->blockBoundingRect(it); qreal bottompos=brect.y()+brect.height(); markerheight=brect.height()-8; // we end this loop if the current block lies below the viewport if (brect.y() > yPosition+ vpHeight) break; // if we are inside the viewport, we have to paint a line number for this line if (bottompos >= yPosition) { QString txt = QString::number(it.blockNumber()+1); p.drawText(1, brect.y()-yPosition, linenumberWidth-2, brect.height(), Qt::AlignRight|Qt::AlignVCenter, txt); if (markers.contains(it.blockNumber()+1)) { itemData d=markers[it.blockNumber()+1]; QRect markerrect=QRect(linenumberWidth+2, brect.y()-yPosition+4, width()-linenumberWidth-4, markerheight); markers[it.blockNumber()+1].rect=markerrect; if (d.type==mtInfo) { //p.drawImage(linenumberWidth+2, brect.y()-yPosition, QIcon(":/event_info.png")); p.setBrush(infoMarkerColor); QPen pe=p.pen(); pe.setColor(QColor("black")); pe.setCosmetic(true); pe.setWidth(1); p.setPen(pe); p.drawRect(markerrect); } else if (d.type==mtError) { //p.drawImage(linenumberWidth+2, brect.y()-yPosition, QIcon(":/event_error.png")); p.setBrush(errorMarkerColor); QPen pe=p.pen(); pe.setColor(QColor("black")); pe.setCosmetic(true); pe.setWidth(1); p.setPen(pe); p.drawRect(markerrect); } else { //p.drawImage(linenumberWidth+2, brect.y()-yPosition, QIcon(":/event_warning.png")); p.setBrush(warningMarkerColor); QPen pe=p.pen(); pe.setColor(QColor("black")); pe.setCosmetic(true); pe.setWidth(1); p.setPen(pe); p.drawRect(markerrect); } } } } }
InfoWidget::InfoWidget(Widget* p_pMatrix) : QWidget() , m_pMatrix(p_pMatrix) { QVBoxLayout* layout = new QVBoxLayout(); setLayout(layout); setFixedWidth(INFO_WIDTH + 3); layout->setSpacing(0); layout->setMargin(0); { QWidget *w = new QWidget(); w->setFixedHeight(18); layout->addWidget(w); } layout->addWidget(createToggleButton(m_pMatrix, GAIN)); layout->addWidget(createLabel(26, GAIN)); layout->addWidget(createToggleButton(m_pMatrix, MUTE)); layout->addWidget(createLabel(16, MUTE)); layout->addWidget(createToggleButton(m_pMatrix, TO_PFL)); layout->addWidget(createLabel(16, TO_PFL)); wPre = new QWidget; lPre = new QVBoxLayout; lPre->setSpacing(0); lPre->setMargin(0); wPre->setLayout(lPre); layout->addWidget(wPre); /* { PixmapWidget *pw = new PixmapWidget(NULL); pw->setPixmap("separator.svg"); pw->setFixedSize(CHANNEL_WIDTH, SEPARATOR_HEIGHT); layout->addWidget(pw); }*/ wPost = new QWidget; lPost = new QVBoxLayout; lPost->setSpacing(0); lPost->setMargin(0); wPost->setLayout(lPost); layout->addWidget(wPost); wSub = new QWidget; lSub = new QVBoxLayout; lSub->setSpacing(0); lSub->setMargin(0); wSub->setLayout(lSub); layout->addWidget(wSub); layout->addWidget(createToggleButton(m_pMatrix, PAN_BAL)); layout->addWidget(createLabel(26, PAN_BAL)); layout->addWidget(createToggleButton(m_pMatrix, TO_MAIN)); layout->addWidget(createLabel(16, TO_MAIN)); m_pFader = new IFWidget(p_pMatrix); layout->addWidget(m_pFader); }
AudioEqualizerDialog::AudioEqualizerDialog(QWidget *parent) : QDialog(parent), d(new Data) { d->p = this; auto vbox = new QVBoxLayout; auto hbox = new QHBoxLayout; hbox->addWidget(new QLabel(tr("Preset"))); d->presets = new QComboBox; d->presets->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); for (int i = 0; i < Eq::MaxPreset; ++i) d->presets->addItem(AudioEqualizer::name((Preset)i), i); auto sig = static_cast<Signal<QComboBox, int>>(&QComboBox::currentIndexChanged); auto load = [=] () { auto data = d->presets->currentData(); if (data.type() == (int)QMetaType::Int) setEqualizer(Eq(Preset(data.toInt()))); }; connect(d->presets, sig, this, load); hbox->addWidget(d->presets); auto button = new QPushButton(tr("Load")); connect(button, &QPushButton::clicked, this, load); hbox->addWidget(button); vbox->addLayout(hbox); hbox = new QHBoxLayout; auto font = this->font(); font.setPointSizeF(font.pointSizeF()*0.8); const int w = QFontMetrics(font).width(u"+20.0dB"_q) + 2; for (int i = 0; i < Eq::bands(); ++i) { auto s = d->sliders[i] = new QSlider; s->setOrientation(Qt::Vertical); s->setRange(Eq::min() * Factor, Eq::max() * Factor); s->setFixedWidth(w); auto vbox = new QVBoxLayout; const auto f = Eq::freqeuncy(i); const QString fq = f < 999.9 ? (QString::number(f) % "Hz"_a) : (QString::number(f/1000.0) % "kHz"_a); auto label = new QLabel(fq); label->setFont(font); label->setAlignment(Qt::AlignCenter); vbox->addWidget(label); vbox->addWidget(s); auto dB = new QLabel("0.0dB"_a); dB->setFont(font); dB->setAlignment(Qt::AlignCenter); vbox->addWidget(dB); hbox->addLayout(vbox); connect(s, &QSlider::valueChanged, this, [=] () { const auto v = s->value()/(double)Factor; dB->setText((v > 0 ? "+"_a : ""_a) % QString::number(v, 'f', 1) % "dB"_a); if (_Change(d->eq[i], v) && d->update) d->update(d->eq); }); } vbox->addLayout(hbox); setLayout(vbox); _SetWindowTitle(this, tr("Audio Equalizer")); }
InWidget::InWidget(QString p_sChannel, Widget* p_pMatrix) : ChannelWidget() , m_Channel(p_sChannel) , m_pMatrix(p_pMatrix) , pre_tb() , post_tb() , sub_tb() , pre() , post() , sub() { QVBoxLayout* layout = new QVBoxLayout(); setLayout(layout); setFixedWidth(CHANNEL_WIDTH); layout->setSpacing(0); layout->setMargin(0); m_pLabel = new QLabel(p_sChannel); m_pLabel->setFixedWidth(CHANNEL_WIDTH); m_pLabel->setAlignment(Qt::AlignHCenter); layout->addWidget(m_pLabel); { PixmapWidget *pw = new PixmapWidget(NULL); pw->setPixmap("separator.svg"); pw->setFixedSize(CHANNEL_WIDTH, SEPARATOR_HEIGHT); layout->addWidget(pw); } QWidget *gain = m_pMatrix->createRotary(IN, p_sChannel, GAIN); layout->addWidget(gain); { PixmapWidget *pw = new PixmapWidget(NULL); pw->setPixmap("separator.svg"); pw->setFixedSize(CHANNEL_WIDTH, SEPARATOR_HEIGHT); layout->addWidget(pw); } Toggle* mute = m_pMatrix->createToggle(IN, p_sChannel, MUTE); layout->addWidget(mute); { PixmapWidget *pw = new PixmapWidget(NULL); pw->setPixmap("separator.svg"); pw->setFixedSize(CHANNEL_WIDTH, SEPARATOR_HEIGHT); layout->addWidget(pw); } Toggle* pfl = m_pMatrix->createToggle(IN, p_sChannel, TO_PFL); layout->addWidget(pfl); wPre = new QWidget; lPre = new QVBoxLayout; lPre->setSpacing(0); lPre->setMargin(0); wPre->setLayout(lPre); layout->addWidget(wPre); /* { PixmapWidget *pw = new PixmapWidget(NULL); pw->setPixmap("separator.svg"); pw->setFixedSize(CHANNEL_WIDTH, SEPARATOR_HEIGHT); layout->addWidget(pw); }*/ wPost = new QWidget; lPost = new QVBoxLayout; lPost->setSpacing(0); lPost->setMargin(0); wPost->setLayout(lPost); layout->addWidget(wPost); wSub = new QWidget; lSub = new QVBoxLayout; lSub->setSpacing(0); lSub->setMargin(0); wSub->setLayout(lSub); layout->addWidget(wSub); { PixmapWidget *pw = new PixmapWidget(NULL); pw->setPixmap("separator.svg"); pw->setFixedSize(CHANNEL_WIDTH, SEPARATOR_HEIGHT); layout->addWidget(pw); } QWidget *bal = m_pMatrix->createRotary(IN, p_sChannel, PAN_BAL); layout->addWidget(bal); { PixmapWidget *pw = new PixmapWidget(NULL); pw->setPixmap("separator.svg"); pw->setFixedSize(CHANNEL_WIDTH, SEPARATOR_HEIGHT); layout->addWidget(pw); } Toggle* main_on = m_pMatrix->createToggle(IN, p_sChannel, TO_MAIN); layout->addWidget(main_on); fader = m_pMatrix->createFader(IN, p_sChannel, FADER); layout->addWidget(fader); }
PostWidget::PostWidget(QString channel, Widget* p_pMatrix) : m_Channel(channel) , m_pMatrix(p_pMatrix) , sub_tb() , sub() { QVBoxLayout* layout = new QVBoxLayout; setLayout(layout); setFixedWidth(CHANNEL_WIDTH); layout->setSpacing(0); layout->setMargin(0); { m_pLabel = new QLabel(channel); m_pLabel->setFixedWidth(CHANNEL_WIDTH); m_pLabel->setAlignment(Qt::AlignHCenter); layout->addWidget(m_pLabel); } QWidget *prevol = m_pMatrix->createRotary(POST, channel, PRE_VOL); layout->addWidget(prevol); Toggle* mute = m_pMatrix->createToggle(POST, channel, MUTE); layout->addWidget(mute); Toggle* pfl = m_pMatrix->createToggle(POST, channel, TO_PFL); layout->addWidget(pfl); Widget::addSpacer(layout); { QLabel *label = new QLabel(trUtf8("Return")); label->setFixedWidth(CHANNEL_WIDTH); label->setAlignment(Qt::AlignHCenter); layout->addWidget(label); } Toggle* afl = m_pMatrix->createToggle(POST, channel, TO_AFL); layout->addWidget(afl); wSub = new QWidget; lSub = new QVBoxLayout; lSub->setSpacing(0); lSub->setMargin(0); wSub->setLayout(lSub); layout->addWidget(wSub); { PixmapWidget *pw = new PixmapWidget(NULL); pw->setPixmap("separator.svg"); pw->setFixedSize(CHANNEL_WIDTH, SEPARATOR_HEIGHT); layout->addWidget(pw); } QWidget *bal = m_pMatrix->createRotary(POST, channel, PAN_BAL); layout->addWidget(bal); { PixmapWidget *pw = new PixmapWidget(NULL); pw->setPixmap("separator.svg"); pw->setFixedSize(CHANNEL_WIDTH, SEPARATOR_HEIGHT); layout->addWidget(pw); } Toggle* main_on = m_pMatrix->createToggle(POST, channel, TO_MAIN); layout->addWidget(main_on); fader = m_pMatrix->createFader(POST, channel, FADER); layout->addWidget(fader); }
void ImageBox::resizeEvent( QResizeEvent* evt ) { QVGroupBox::resizeEvent( evt ); if( evt->size().width() != sizeHint().width() ) setFixedWidth( sizeHint().width() ); }
/*! \brief Constructor */ QFoldPanel::QFoldPanel(QWidget *p) : QPanel(p) { setFixedWidth(12); }
/* private */ void mainwindow::_create_menus() { _shading_menu = new QMainWindow(); _info_menu = new QMainWindow(); auto shading_layout = new QVBoxLayout; shading_layout->setAlignment(Qt::AlignTop); auto label_color_a = new QLabel("Ambient", _shading_menu); auto label_color_d = new QLabel("Diffuse", _shading_menu); auto label_color_s = new QLabel("Specular", _shading_menu); auto label_color_sh = new QLabel("Shininess", _shading_menu); auto label_color_o = new QLabel("Opacity", _shading_menu); _addfile_button = new QPushButton("Add"); _deletefile_button = new QPushButton("Delete"); _material_apply = new QPushButton("Apply"); _current_specular = new QPushButton(" "); _current_diffuse = new QPushButton(" "); _current_ambient = new QPushButton(" "); _current_shininess = new FloatSlidersGroup(Qt::Horizontal, tr("Shininess"), 0.0, 1.0f, _shading_menu); _current_shininess->setValue(0.0); _current_opacity = new FloatSlidersGroup(Qt::Horizontal, tr("Opacity"), 0.0, 1.0f, _shading_menu); _current_opacity->setValue(1.0); _current_specular->setFixedSize(40, 40); _current_diffuse->setFixedSize(40, 40); _current_ambient->setFixedSize(40, 40); shading_layout->addWidget(_addfile_button); shading_layout->addWidget(_deletefile_button); auto gridlayout = new QGridLayout(); auto color_widget = new QWidget(); color_widget->setLayout(gridlayout); gridlayout->addWidget(label_color_s, 0, 0); gridlayout->addWidget(_current_specular, 0, 1); gridlayout->addWidget(label_color_d, 1, 0); gridlayout->addWidget(_current_diffuse, 1, 1); gridlayout->addWidget(label_color_a, 2, 0); gridlayout->addWidget(_current_ambient, 2, 1); _object_list = new QListWidget(_shading_menu); _object_list->setSelectionMode(QAbstractItemView::MultiSelection); shading_layout->addWidget(_object_list); shading_layout->addWidget(color_widget); shading_layout->addWidget(_current_shininess); shading_layout->addWidget(_current_opacity); shading_layout->addWidget(_material_apply); ////////////////////////////////////////////////// _menu = new QMainWindow(); auto layout = new QVBoxLayout; _counting_result = new QLabel("", _menu); _fps_result = new QLabel("", _menu); _memory_usage = new QLabel("", _menu); // init buttons _button_recompile = new QPushButton("Recompile Shaders", _menu); _button_set_spheremap = new QPushButton("Choose Spheremap", _menu); // init check boxes _checkbox_pretessellation = new QCheckBox("Enable Pretessellation", _menu); _checkbox_spheremap = new QCheckBox("Enable Spheremapping", _menu); _checkbox_fxaa = new QCheckBox("Enable screen-space FXAA", _menu); _checkbox_vsync = new QCheckBox("Enable VSync", _menu); _checkbox_culling = new QCheckBox("Backface Culling", _menu); _checkbox_counting = new QCheckBox("Enable Triangle/Fragment Counter", _menu); _checkbox_tritesselation = new QCheckBox("Enable Triangular Tesselation", _menu); _checkbox_holefilling = new QCheckBox("Enable Holefilling", _menu); _checkbox_conservative_rasterization = new QCheckBox("Enable Conservative Rasterization", _menu); // init combo boxes _combobox_rendering = new QComboBox; _combobox_antialiasing = new QComboBox; _combobox_trimming = new QComboBox; _combobox_fillmode = new QComboBox; _combobox_preclassification = new QComboBox; std::for_each(_rendering_modes.begin(), _rendering_modes.end(), [&](std::map<gpucast::gl::bezierobject::render_mode, std::string>::value_type const& p) { _combobox_rendering->addItem(p.second.c_str()); }); std::for_each(_antialiasing_modes.begin(), _antialiasing_modes.end(), [&](std::map<gpucast::gl::bezierobject::anti_aliasing_mode, std::string>::value_type const& p) { _combobox_antialiasing->addItem(p.second.c_str()); }); std::for_each(_trimming_modes.begin(), _trimming_modes.end(), [&](std::map<gpucast::beziersurfaceobject::trim_approach_t, std::string>::value_type const& p) { _combobox_trimming->addItem(p.second.c_str()); }); std::for_each(_fill_modes.begin(), _fill_modes.end(), [&](std::map<gpucast::gl::bezierobject::fill_mode, std::string>::value_type const& p) { _combobox_fillmode->addItem(p.second.c_str()); }); std::for_each(_preclassification_modes.begin(), _preclassification_modes.end(), [&](std::map<unsigned, std::string>::value_type const& p) { _combobox_preclassification->addItem(p.second.c_str()); }); _combobox_rendering->setCurrentText(tr(_rendering_modes[gpucast::gl::bezierobject::tesselation].c_str())); _combobox_trimming->setCurrentText(tr(_trimming_modes[gpucast::beziersurfaceobject::contour_kd_partition].c_str())); _combobox_preclassification->setCurrentText(tr(_preclassification_modes[8].c_str())); _slider_trim_max_bisections = new SlidersGroup(Qt::Horizontal, tr("Max. bisections"), 1, 32, _menu); _slider_trim_error_tolerance = new FloatSlidersGroup(Qt::Horizontal, tr("Max. error tolerance"), 0.0001f, 0.1f, _menu); _slider_tesselation_max_object_error = new FloatSlidersGroup(Qt::Horizontal, tr("Tessellation: max. object error"), 0.0001f, 10.0f, _menu); _slider_tesselation_max_pixel_error = new FloatSlidersGroup(Qt::Horizontal,tr("Tessellation: max. pixel error"), 0.5f, 64.0f, _menu); _slider_raycasting_max_iterations = new SlidersGroup(Qt::Horizontal,tr("Raycasting: Newton iterations"), 1, 16, _menu); _slider_raycasting_error_tolerance = new FloatSlidersGroup(Qt::Horizontal, tr("Raycasting: error tolerance"), 0.0001f, 0.1f, _menu); // apply default values _slider_trim_max_bisections->setValue(gpucast::gl::bezierobject::default_render_configuration::trimming_max_bisections); _slider_trim_error_tolerance->setValue(gpucast::gl::bezierobject::default_render_configuration::trimming_error_tolerance); _slider_tesselation_max_object_error->setValue(gpucast::gl::bezierobject::default_render_configuration::tesselation_max_geometric_error); _slider_tesselation_max_pixel_error->setValue(gpucast::gl::bezierobject::default_render_configuration::tesselation_max_pixel_error); _slider_raycasting_max_iterations->setValue(gpucast::gl::bezierobject::default_render_configuration::raycasting_max_iterations); _slider_raycasting_error_tolerance->setValue(gpucast::gl::bezierobject::default_render_configuration::raycasting_error_tolerance); // apply widget into layout QGroupBox* system_desc = new QGroupBox("System", _menu); QVBoxLayout* system_desc_layout = new QVBoxLayout; system_desc_layout->addWidget(_button_recompile); system_desc_layout->addWidget(_checkbox_vsync); system_desc_layout->addWidget(_checkbox_counting); system_desc->setLayout(system_desc_layout); layout->addWidget(system_desc); QGroupBox* aa_desc = new QGroupBox("Anti-Aliasing", _menu); QVBoxLayout* aa_desc_layout = new QVBoxLayout; aa_desc_layout->addWidget(_checkbox_fxaa); aa_desc_layout->addWidget(new QLabel("Shader-based anti-aliasing")); aa_desc_layout->addWidget(_combobox_antialiasing); aa_desc->setLayout(aa_desc_layout); layout->addWidget(aa_desc); QGroupBox* trim_desc = new QGroupBox("Trimming", _menu); QVBoxLayout* trim_desc_layout = new QVBoxLayout; trim_desc_layout->addWidget(_combobox_trimming); trim_desc_layout->addWidget(_combobox_preclassification); trim_desc_layout->addWidget(_slider_trim_max_bisections); trim_desc_layout->addWidget(_slider_trim_error_tolerance); trim_desc->setLayout(trim_desc_layout); layout->addWidget(trim_desc); QGroupBox* rendering_desc = new QGroupBox("Rendering", _menu); QVBoxLayout* rendering_desc_layout = new QVBoxLayout; rendering_desc_layout->addWidget(_combobox_rendering); rendering_desc_layout->addWidget(_combobox_fillmode); rendering_desc_layout->addWidget(_checkbox_pretessellation); rendering_desc_layout->addWidget(_checkbox_holefilling); rendering_desc_layout->addWidget(_checkbox_culling); rendering_desc_layout->addWidget(_checkbox_tritesselation); rendering_desc_layout->addWidget(_checkbox_conservative_rasterization); rendering_desc_layout->addWidget(_slider_tesselation_max_pixel_error); rendering_desc_layout->addWidget(_slider_tesselation_max_object_error); rendering_desc_layout->addWidget(_slider_raycasting_max_iterations); rendering_desc_layout->addWidget(_slider_raycasting_error_tolerance); rendering_desc->setLayout(rendering_desc_layout); layout->addWidget(rendering_desc); QGroupBox* shading_desc = new QGroupBox("Shading", _menu); QVBoxLayout* shading_desc_layout = new QVBoxLayout; shading_desc_layout->addWidget(_checkbox_spheremap); shading_desc_layout->addWidget(_button_set_spheremap); shading_desc->setLayout(shading_desc_layout); layout->addWidget(shading_desc); layout->setAlignment(Qt::AlignTop); auto param_body = new QWidget (); param_body->setFixedWidth(800); param_body->setLayout(layout); _menu->setCentralWidget(param_body); _menu->setWindowTitle("Rendering Parameters"); _menu->show(); auto shading_body = new QWidget(); shading_body->setLayout(shading_layout); shading_body->setFixedWidth(800); _shading_menu->setCentralWidget(shading_body); _shading_menu->setWindowTitle("File Management and Materials"); _shading_menu->show(); auto info_body = new QWidget(); QVBoxLayout* info_layout = new QVBoxLayout; info_layout->addWidget(_memory_usage); info_layout->addWidget(_fps_result); info_layout->addWidget(_counting_result); info_body->setLayout(info_layout); _info_menu->setCentralWidget(info_body); _info_menu->setWindowTitle("Rendering Information"); _info_menu->show(); _file_menu = _shading_menu->menuBar()->addMenu(tr("File")); }
/*! \brief Constructor */ QLineChangePanel::QLineChangePanel(QWidget *p) : QPanel(p) { setFixedWidth(4); setObjectName("lineChangePanel"); }
void controlUC::setAttribute(PCWSTR pstrName, PCWSTR pstrValue) { if( _tcscmp(pstrName, L"pos") == 0 ) { RECT rcPos = { 0 }; PWSTR pstr = NULL; rcPos.left = _tcstol(pstrValue, &pstr, 10); assert(pstr); rcPos.top = _tcstol(pstr + 1, &pstr, 10); assert(pstr); rcPos.right = _tcstol(pstr + 1, &pstr, 10); assert(pstr); rcPos.bottom = _tcstol(pstr + 1, &pstr, 10); assert(pstr); SIZE szXY = {rcPos.left >= 0 ? rcPos.left : rcPos.right, rcPos.top >= 0 ? rcPos.top : rcPos.bottom}; setFixedXY(szXY); setFixedWidth(rcPos.right - rcPos.left); setFixedHeight(rcPos.bottom - rcPos.top); } else if( _tcscmp(pstrName, L"relativepos") == 0 ) { SIZE szMove,szZoom; PWSTR pstr = NULL; szMove.cx = _tcstol(pstrValue, &pstr, 10); assert(pstr); szMove.cy = _tcstol(pstr + 1, &pstr, 10); assert(pstr); szZoom.cx = _tcstol(pstr + 1, &pstr, 10); assert(pstr); szZoom.cy = _tcstol(pstr + 1, &pstr, 10); assert(pstr); setRelativePos(szMove,szZoom); } else if( _tcscmp(pstrName, L"padding") == 0 ) { RECT rcPadding = { 0 }; PWSTR pstr = NULL; rcPadding.left = _tcstol(pstrValue, &pstr, 10); assert(pstr); rcPadding.top = _tcstol(pstr + 1, &pstr, 10); assert(pstr); rcPadding.right = _tcstol(pstr + 1, &pstr, 10); assert(pstr); rcPadding.bottom = _tcstol(pstr + 1, &pstr, 10); assert(pstr); setPadding(rcPadding); } else if( _tcscmp(pstrName, L"bkcolor") == 0 || _tcscmp(pstrName, L"bkcolor1") == 0 ) { while( *pstrValue > L'\0' && *pstrValue <= L' ') pstrValue = ::CharNext(pstrValue); if( *pstrValue == L'#') pstrValue = ::CharNext(pstrValue); PWSTR pstr = NULL; DWORD clrColor = _tcstoul(pstrValue, &pstr, 16); setBkColor(clrColor); } else if( _tcscmp(pstrName, L"bordercolor") == 0 ) { if( *pstrValue == L'#') pstrValue = ::CharNext(pstrValue); PWSTR pstr = NULL; DWORD clrColor = _tcstoul(pstrValue, &pstr, 16); setBorderColor(clrColor); } else if( _tcscmp(pstrName, L"focusbordercolor") == 0 ) { if( *pstrValue == L'#') pstrValue = ::CharNext(pstrValue); PWSTR pstr = NULL; DWORD clrColor = _tcstoul(pstrValue, &pstr, 16); setFocusBorderColor(clrColor); } else if( _tcscmp(pstrName, L"bordersize") == 0 ) setBorderSize(_ttoi(pstrValue)); else if( _tcscmp(pstrName, L"borderround") == 0 ) { SIZE cxyRound = { 0 }; PWSTR pstr = NULL; cxyRound.cx = _tcstol(pstrValue, &pstr, 10); assert(pstr); cxyRound.cy = _tcstol(pstr + 1, &pstr, 10); assert(pstr); setBorderRound(cxyRound); } else if( _tcscmp(pstrName, L"width") == 0 ) setFixedWidth(_ttoi(pstrValue)); else if( _tcscmp(pstrName, L"height") == 0 ) setFixedHeight(_ttoi(pstrValue)); else if( _tcscmp(pstrName, L"minwidth") == 0 ) setMinWidth(_ttoi(pstrValue)); else if( _tcscmp(pstrName, L"minheight") == 0 ) setMinHeight(_ttoi(pstrValue)); else if( _tcscmp(pstrName, L"maxwidth") == 0 ) setMaxWidth(_ttoi(pstrValue)); else if( _tcscmp(pstrName, L"maxheight") == 0 ) setMaxHeight(_ttoi(pstrValue)); else if( _tcscmp(pstrName, L"name") == 0 ) setName(pstrValue); else if( _tcscmp(pstrName, L"text") == 0 ) setText(pstrValue); else if( _tcscmp(pstrName, L"tooltip") == 0 ) setToolTip(pstrValue); else if( _tcscmp(pstrName, L"userdata") == 0 ) setUserData(pstrValue); else if( _tcscmp(pstrName, L"enabled") == 0 ) setEnabled(_tcscmp(pstrValue, L"true") == 0); else if( _tcscmp(pstrName, L"mouse") == 0 ) setMouseEnabled(_tcscmp(pstrValue, L"true") == 0); else if( _tcscmp(pstrName, L"visible") == 0 ) setVisible(_tcscmp(pstrValue, L"true") == 0); else if( _tcscmp(pstrName, L"float") == 0 ) setFloat(_tcscmp(pstrValue, L"true") == 0); else if( _tcscmp(pstrName, L"shortcut") == 0 ) setShortcut(pstrValue[0]); else if( _tcscmp(pstrName, L"menu") == 0 ) setContextMenuUsed(_tcscmp(pstrValue, L"true") == 0); }
void EndGameMessage::set_parent_width(int w) { parent_width = w; setFixedWidth(w); update(); }
/*! */ void QLineNumberPanel::paint(QPainter *p, QEditor *e) { /* possible Unicode caracter for wrapping arrow : 0x21B3 0x2937 */ QFont f(font()); f.setWeight(QFont::Bold); const QFontMetrics sfm(f); #ifndef WIN32 static const QChar wrappingArrow(0x2937); const QFontMetrics specialSfm(sfm); #else static const QChar wrappingArrow('Ä'); QFont specialFont(font()); specialFont.setRawName("Wingdings"); const QFontMetrics specialSfm(specialFont); #endif const int max = e->document()->lines(); const int panelWidth = sfm.width(QString::number(max)) + 5; setFixedWidth(panelWidth); const QFontMetrics fm( e->document()->font() ); int n, posY, as = fm.ascent(), ls = fm.lineSpacing(), pageBottom = e->viewport()->height(), contentsY = e->verticalOffset(); QString txt; QDocument *d = e->document(); const int cursorLine = e->cursor().lineNumber(); n = d->lineNumber(contentsY); posY = as + 2 + d->y(n) - contentsY; //qDebug("first = %i; last = %i", first, last); //qDebug("beg pos : %i", posY); for ( ; ; ++n ) { //qDebug("n = %i; pos = %i", n, posY); QDocumentLine line = d->line(n); if ( line.isNull() || ((posY - as) > pageBottom) ) break; if ( line.isHidden() ) continue; bool draw = true; if ( !m_verbose ) { draw = !((n + 1) % 10) || !n || !line.marks().empty(); } txt = QString::number(n + 1); if ( n == cursorLine ) { draw = true; p->save(); QFont f = p->font(); f.setWeight(QFont::Bold); p->setFont(f); } if ( draw ) { p->drawText(width() - 2 - sfm.width(txt), posY, txt); #ifdef WIN32 if (line.lineSpan()>1) { p->save(); specialFont.setBold(n == cursorLine); //todo: only get bold on the current wrapped line p->setFont(specialFont); } #endif for ( int i = 1; i < line.lineSpan(); ++i ) p->drawText(width() - 2 - specialSfm.width(wrappingArrow), posY + i * ls, wrappingArrow); #ifdef WIN32 if (line.lineSpan()>1) p->restore(); #endif } else { int yOff = posY - (as + 1) + ls / 2; if ( (n + 1) % 5 ) p->drawPoint(width() - 5, yOff); else p->drawLine(width() - 7, yOff, width() - 2, yOff); } if ( n == cursorLine ) { p->restore(); } posY += ls * line.lineSpan(); } //p->setPen(Qt::DotLine); //p->drawLine(width()-1, 0, width()-1, pageBottom); //setFixedWidth(sfm.width(txt) + 5); }
//added by Rolando 04-11-08 void QtFlagsListWidget::setWidthSize(int width) { setFixedWidth(width + width/8);//we add width/8 because to reserve space at the end of item }
/*! \brief Constructor */ QLineNumberPanel::QLineNumberPanel(QWidget *p) : QPanel(p), m_verbose(false) { setFixedWidth(20); }
PluginsSettingsDialog::PluginsSettingsDialog(PluginAbstract* plugin, QWidget* parent, Qt::WindowFlags flags): QDialog(parent, flags), mPlugin(plugin) { QString title = plugin->getName() + " " + tr("Settings"); setWindowTitle(title); /*mLangHelpLab = new QLabel(tr("The following parameters can "), this); QFont f; f.setPointSize(pointSize(11)); mLangHelpLab->setFont(f); mLangHelpLab->setAlignment(Qt::AlignCenter); mLangHelpLab->setWordWrap(true);*/ // ---------------------------------------- // Common form for all plugins // ---------------------------------------- mColorLab = new Label(tr("Color") + " :", this); mColorPicker = new ColorPicker(mPlugin->getColor(), this); mMethodLab = new QLabel(tr("Method") + " :", this); mMethodCombo = new QComboBox(this); mMethodCombo->addItem(ModelUtilities::getDataMethodText(Date::eMHSymetric)); mMethodCombo->addItem(ModelUtilities::getDataMethodText(Date::eInversion)); mMethodCombo->addItem(ModelUtilities::getDataMethodText(Date::eMHSymGaussAdapt)); // ---------------------------------------- // This form is plugin specific // ---------------------------------------- mView = plugin->getSettingsView(); if(mView){ // useless using a layout below... mView->setParent(this); mView->setVisible(true); } // ---------------------------------------- // Connections // ---------------------------------------- connect(this, SIGNAL(accepted()), mView, SLOT(onAccepted())); connect(mColorPicker, SIGNAL(colorChanged(QColor)), this, SLOT(updateColor(QColor))); // ---------------------------------------- // Buttons // ---------------------------------------- mButtonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); connect(mButtonBox, SIGNAL(accepted()), this, SLOT(accept())); connect(mButtonBox, SIGNAL(rejected()), this, SLOT(reject())); // ---------------------------------------- // Layout // ---------------------------------------- QGridLayout* grid = new QGridLayout(); grid->setContentsMargins(0, 0, 0, 0); grid->addWidget(mColorLab, 0, 0, Qt::AlignRight | Qt::AlignVCenter); grid->addWidget(mColorPicker, 0, 1); grid->addWidget(mMethodLab, 1, 0, Qt::AlignRight | Qt::AlignVCenter); grid->addWidget(mMethodCombo, 1, 1); QVBoxLayout* layout = new QVBoxLayout(); layout->addLayout(grid); if(mView){ QFrame* line1 = new QFrame(); line1->setFrameShape(QFrame::HLine); line1->setFrameShadow(QFrame::Sunken); layout->addWidget(line1); layout->addWidget(mView); } layout->addWidget(mButtonBox); setLayout(layout); setFixedWidth(450); }
void QILineEdit::setFixedWidthByText (const QString &aText) { setFixedWidth (featTextWidth (aText).width()); }
void ToggleButton::setText( const QString& s ) { QLabel::setText( s ); setFixedWidth( fontMetrics().width( text() ) + 32 ); }
VpnWizard::VpnWizard(QWidget * parent) : FramelessWizard(parent) { addPage(new CStartPage); addPage(new GeneralPage); addPage(new RemotePage); addPage(new CertPage); addPage(new AdvPage); addPage(new CEndPage); //this->button(QWizard::WizardButton::BackButton)->setIcon(QIcon(":/data/images/back_small.png")); //this->button(QWizard::WizardButton::NextButton)->setIcon(QIcon(":/data/images/next_small.png")); auto geom = this->geometry(); geom.setHeight(460); geom.setWidth(501); QSize size = geom.size(); // int h = size.height(); int w = size.width(); // size.setHeight(qFloor(h * windowsDpiScale())); size.setWidth(qFloor(w * windowsDpiScale())); setFixedWidth(size.width()); setFixedHeight(size.height()); // resize(size); QPixmap pixmap(":/data/images/banner_wiz.png"); pixmap = pixmap.scaledToWidth(size.width(), Qt::TransformationMode::SmoothTransformation); setPixmap(QWizard::BannerPixmap, pixmap); //page(0)->setContentsMargins(0, 20, 0, 0); //page(1)->setContentsMargins(0, 20, 0, 0); //page(2)->setContentsMargins(0, 20, 0, 0); //page(3)->setContentsMargins(0, 20, 0, 0); //page(4)->setContentsMargins(0, 20, 0, 0); setWindowIcon(QIcon(":/data/images/logo.png")); setWindowTitle(QObject::tr("Create a new SSL VPN connection")); setWindowFlags(Qt::WindowCloseButtonHint); setModal(true); this->setWindowFlags(Qt::WindowCloseButtonHint | Qt::FramelessWindowHint); DWORD style = GetWindowLong((HWND)winId(), GWL_STYLE); SetWindowLong((HWND)winId(), GWL_STYLE, style); setWizardStyle(ModernStyle); //this->button(QWizard::WizardButton::NextButton)->setLayoutDirection(Qt::RightToLeft); this->setButtonText(QWizard::WizardButton::NextButton, QObject::tr("Next")); this->setButtonText(QWizard::WizardButton::BackButton, QObject::tr("Back")); this->setButtonText(QWizard::WizardButton::CancelButton, QObject::tr("Cancel")); this->setButtonText(QWizard::WizardButton::FinishButton, QObject::tr("Finish")); setStyleSheet("QPushButton:hover {background-color: rgb(195, 195, 195);}\nQPushButton {;text-align:center; \npadding-left: 3px;\n padding-top: 3px; padding-right: 3px;\n padding-bottom: 3px;}"); this->setupFrameless(); }
CreateGroup::CreateGroup(QStringList items, QWidget *parent) : THWidgetBase(parent) { setAttribute(Qt::WA_DeleteOnClose); setFixedSize(380, 250); setTitleBarWidth(380); setWindowFlags(Qt::FramelessWindowHint | Qt::Tool); setWindowModality(Qt::ApplicationModal); bar->setBarButtons(HappyTitleBar::MinButtonHint); bar->setBarButtons(HappyTitleBar::MaxButtonHint); bar->setExtraButtonVisible(false); bar->setBarIcon(":res/happy.png"); bar->setBarContent(cn("创建群/讨论组")); connect(bar, &HappyTitleBar::signalClose, this, [=] () { this->close(); }); QVBoxLayout *v= new QVBoxLayout(); v->setContentsMargins(0, 0, 0, 0); QHBoxLayout *h = new QHBoxLayout(); h->setContentsMargins(0, 0, 0, 0); QVBoxLayout *v1= new QVBoxLayout(); v1->setContentsMargins(0, 0, 0, 0); QVBoxLayout *v2= new QVBoxLayout(); v2->setContentsMargins(0, 0, 0, 0); EmojiLabel *photo = new EmojiLabel(this); photo->setMoiveRes(":res/ui3/default_group_create.gif"); photo->setMovieable(true); photo->setFixedSize(70, 70); photo->setStyleSheet(cns("QLabel{border-width:1px;border-style:solid;border-radius:3px;border-color:transparent;" "background:transparent;}" "QLabel:hover{border-width:1px;border-style:solid;border-radius:3px;border-color:white;}" "QLabel:pressed{border-width:1px;border-style:solid;border-radius:3px;border-color:rgba(240,240,240,50);}")); QLabel *lbl1 = new QLabel(cn("修改群图片(点击)"), this); lbl1->setStyleSheet(QStringLiteral("font-family:微软雅黑;font:12px;color:white;")); QPushButton *pb1 = new QPushButton(cn("从表情库中选择"), this); pb1->setFixedWidth(120); v1->addWidget(photo, 8, Qt::AlignCenter); v1->addWidget(lbl1, 1, Qt::AlignCenter); v1->addWidget(pb1, 1, Qt::AlignCenter); QLineEdit *edit1 = new QLineEdit(this); edit1->setAlignment(Qt::AlignCenter); edit1->setFixedWidth(180); edit1->setPlaceholderText(cn("输入群/讨论组名称")); QLineEdit *edit2 = new QLineEdit(this); edit2->setText(cn("讨论组")); edit2->setReadOnly(true); edit2->setAlignment(Qt::AlignCenter); edit2->setFixedWidth(180); edit2->setPlaceholderText(cn("选择属性")); HappyTextEdit *edit3 = new HappyTextEdit(this); edit3->setPlaceholderText(cn("写点什么吧,这群是干啥的")); edit3->setFixedWidth(180); v2->addWidget(edit1, 1, Qt::AlignCenter); v2->addWidget(edit2, 1, Qt::AlignCenter); v2->addWidget(edit3, 8, Qt::AlignCenter); h->addLayout(v1, 2); h->addLayout(v2, 3); QHBoxLayout *h1 = new QHBoxLayout(); h1->setContentsMargins(55, 0, 0, 10); QPushButton *selectPb = new QPushButton(cn("选择成员"), this); selectPb->setCheckable(true); selectPb->setFixedWidth(70); QPushButton *confirmPb = new QPushButton(cn("确定"), this); confirmPb->setFixedWidth(50); QPushButton *cancelPb = new QPushButton(cn("取消"), this); cancelPb->setFixedWidth(50); h1->addStretch(7); h1->addWidget(selectPb); h1->addWidget(confirmPb); h1->addWidget(cancelPb); h1->addStretch(1); v->addLayout(h, 9); v->addLayout(h1, 1); QHBoxLayout *h2 = new QHBoxLayout(this); h2->setContentsMargins(5, 35, 5, 10); CheckList *list = new CheckList(this); list->setFixedSize(120, 195); list->setVisible(false); h2->addLayout(v, 5); h2->addWidget(list, 1, Qt::AlignHCenter | Qt::AlignTop); h2->addSpacing(15); QFile file; file.setFileName(":res/css/lineedit.css"); if (file.open(QIODevice::ReadOnly)) { QByteArray ba = file.readAll(); edit1->setStyleSheet(QTextCodec::codecForLocale()->toUnicode(ba)); edit2->setStyleSheet(QTextCodec::codecForLocale()->toUnicode(ba)); } file.close(); file.setFileName(":res/css/button2.css"); if (file.open(QIODevice::ReadOnly)) { QByteArray ba = file.readAll(); pb1->setStyleSheet(QTextCodec::codecForLocale()->toUnicode(ba)); selectPb->setStyleSheet(QTextCodec::codecForLocale()->toUnicode(ba)); confirmPb->setStyleSheet(QTextCodec::codecForLocale()->toUnicode(ba)); cancelPb->setStyleSheet(QTextCodec::codecForLocale()->toUnicode(ba)); } file.close(); file.setFileName(":res/css/list2.css"); if (file.open(QIODevice::ReadOnly)) { QByteArray ba = file.readAll(); list->setStyleSheet(QTextCodec::codecForLocale()->toUnicode(ba)); } file.close(); // load data ConfigureData *conf = ConfigureData::getInstance(); updateColor(conf->getColorIni("color1"), conf->getColorIni("color2")); list->setmyuid(conf->getUuid()); list->addCheckItems(items); connect(confirmPb, &QPushButton::clicked, this, [=] () { QString name = edit1->text(); if (name.trimmed().isEmpty()) { MsgBox::ShowMsgBox(cn("错误"), cn("不能使用空的名称"), cn("确定")); return; } QString attr = edit2->text(); QString des = edit3->toPlainText(); if (des.trimmed().isEmpty()) { int rlt = MsgBox::ShowMsgBox(cn("提示"), cn("真的不写点什么?"), cn("不写了"), cn("那写点")); if (rlt != 0) return; } QString uids = list->checkedids(); if (uids.split(";").size() <= 1) { int rlt = MsgBox::ShowMsgBox(cn("提示"), cn("这个组里面只有你一个人\n" "确定创建这个寂寞的群组么?"), cn("确定"), cn("去选人")); if (rlt == 1) { selectPb->setChecked(true); return; } } // check image QString newPhotoName = photo->ImagePath(); QString path = GetWorkPath() + "/face"; if (QDir().mkpath(path)) { QFile file; file.setFileName(newPhotoName); if (file.exists()) { QString temp = path + "/" + QFileInfo(newPhotoName).fileName(); if (QFile::exists(temp)) { newPhotoName = temp; } else { bool b = file.copy(temp); if (b) newPhotoName = temp; } } file.close(); } // 创建数据 GroupData gd; gd.setName(name); gd.setAttr(attr); gd.setGroupdescribe(des); gd.setPhoto(newPhotoName); gd.setGroupmember(uids); gd.setUid(getUuid()); gd.setDeleteable(true); gd.setEditable(true); QDateTime dt = QDateTime::currentDateTime(); gd.setCreationtime(dt.toString("yyyy-MM-dd hh:mm:ss")); gd.setUpdatetime(dt.toTime_t()); gd.setCreator(conf->getIni("nickname")); gd.setPort(qrand() % 10000 + 20000); gd.setNetmask(createNetmask()); emit confrimCreate(gd); close(); }); connect(cancelPb, &QPushButton::clicked, this, [=] () { emit bar->signalClose(); }); connect(selectPb, &QPushButton::toggled, this, [=] (bool b) { if (b) { setFixedWidth(480); setTitleBarWidth(480); } else { setFixedWidth(380); setTitleBarWidth(380); } list->setVisible(b); }); connect(this, &CreateGroup::updateItems, list, &CheckList::addCheckItems); connect(pb1, &QPushButton::clicked, this, [=] () { EmotionsBox *box = EmotionsBox::GetInstance(); box->show(); box->activateWindow(); QPoint p = QCursor::pos(); box->move(p.x() - box->width() / 2, p.y() - 20 - box->height()); connect(box, &EmotionsBox::select, this, [=] (QString str) { photo->setMoiveRes(str); }); connect(box, &EmotionsBox::signalHide, this, [=] () { disconnect(box, &EmotionsBox::signalHide, 0, 0); disconnect(box, &EmotionsBox::select, 0, 0); }); }); connect(photo, &EmojiLabel::clicked, this, [=] () { QString filter = cns("图片资源(*.jpg *.gif *.png*.bmp);;全部文件(*.*)"); QString path = QFileDialog::getOpenFileName(this, QStringLiteral("选择图片"), ".", filter); if (!QFileInfo(path).isFile() && !QImageReader(path).canRead()) { MsgBox::ShowMsgBox(cn("错误"), cn("不是有效的文件"), cn("确定")); return; } photo->setMoiveRes(path); }); }
virtual void styleChange( QStyle& ) { setFixedWidth( style().pixelMetric( QStyle::PM_SplitterWidth, this ) ); }
ShortcutTester() { setupLayout(); setFixedWidth(200); }
AddRecipients::AddRecipients(QLineEdit & listRecipients,QWidget *parent) : QDialog(parent) { setFixedWidth(300); setWindowTitle("Ajouter un destinataire"); currentListRecipients = &listRecipients; db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName("database.db"); if (!db.open()) { qDebug() << "Impossible de se connecter à la base de données." << endl; return; } listView_users = new QListView(); listView_users->setEditTriggers(0); QSqlQuery query; query.exec("SELECT * FROM Contacts"); modelListUsers = new QStandardItemModel(); int index = 0; while(query.next()) { User user(query.value(1).toInt(),QString(query.value(2).toString())); QStandardItem *item = new QStandardItem(); item->setText(user.address()); QVariant data; data.setValue(user); item->setData(data); modelListUsers->setItem(index,item); index++; } listView_users->setModel(modelListUsers); QVBoxLayout *layout_add_users = new QVBoxLayout(); layout_add_users->addWidget(listView_users); btn_add_user = new QPushButton("Ajouter le contact"); QVBoxLayout *layout_btn_add_users = new QVBoxLayout(); layout_btn_add_users->addWidget(btn_add_user); list_users = new QGroupBox("Contacts"); form_list_users = new QFormLayout(); form_list_users->addRow("Liste des contacts : ", listView_users); form_list_users->addRow("", layout_btn_add_users); list_users->setLayout(form_list_users); QVBoxLayout *layout_main = new QVBoxLayout; layout_main->addWidget(list_users); setLayout(layout_main); connect(btn_add_user, SIGNAL(clicked()), this, SLOT(addUser())); show(); }
/*! \brief Constructor */ QLineMarkPanel::QLineMarkPanel(QWidget *p) : QPanel(p) { setFixedWidth(18); }
StartupView::StartupView( QWidget * parent ) : QWidget( parent ) { m_templateListModel = std::shared_ptr<TemplateListModel>( new TemplateListModel() ); setStyleSheet("openstudio--StartupView { background: #E6E6E6; }"); #ifdef Q_OS_MAC setWindowFlags(Qt::FramelessWindowHint); #else setWindowFlags(Qt::CustomizeWindowHint); #endif auto recentProjectsView = new QWidget(); recentProjectsView->setStyleSheet("QWidget { background: #F2F2F2; }"); auto recentProjectsLayout = new QVBoxLayout(); recentProjectsLayout->setContentsMargins(10,10,10,10); QLabel * recentProjectsLabel = new QLabel("Recent Projects"); recentProjectsLabel->setStyleSheet("QLabel { font: bold }"); recentProjectsLayout->addWidget(recentProjectsLabel,0,Qt::AlignTop); recentProjectsView->setLayout(recentProjectsLayout); auto openButton = new QToolButton(); openButton->setText("Open File"); openButton->setStyleSheet("QToolButton { font: bold; }"); openButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); QIcon openIcon(":/images/open_file.png"); openButton->setIcon(openIcon); openButton->setIconSize(QSize(40,40)); connect(openButton, &QToolButton::clicked, this, &StartupView::openClicked); auto importButton = new QToolButton(); importButton->setText("Import Idf"); importButton->setStyleSheet("QToolButton { font: bold; }"); importButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); QIcon importIcon(":/images/import_file.png"); importButton->setIcon(importIcon); importButton->setIconSize(QSize(40,40)); connect(importButton, &QToolButton::clicked, this, &StartupView::importClicked); /* QToolButton * importSDDButton = new QToolButton(); importSDDButton->setText("Import SDD"); importSDDButton->setStyleSheet("QToolButton { font: bold; }"); importSDDButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); QIcon importSDDIcon(":/images/import_file.png"); importSDDButton->setIcon(importSDDIcon); importSDDButton->setIconSize(QSize(40,40)); connect(importSDDButton, &QToolButton::clicked, this, &StartupView::importSDDClicked); */ auto projectChooserView = new QWidget(); projectChooserView->setFixedWidth(238); projectChooserView->setStyleSheet("QWidget { background: #F2F2F2; }"); auto projectChooserLayout = new QVBoxLayout(); projectChooserLayout->setContentsMargins(10,10,10,10); QLabel * projectChooserLabel = new QLabel("Create New From Template"); projectChooserLabel->setStyleSheet("QLabel { font: bold }"); projectChooserLayout->addWidget(projectChooserLabel,0,Qt::AlignTop); m_listView = new QListView(); m_listView->setViewMode(QListView::IconMode); m_listView->setModel(m_templateListModel.get()); m_listView->setFocusPolicy(Qt::NoFocus); m_listView->setFlow(QListView::LeftToRight); m_listView->setUniformItemSizes(true); m_listView->setSelectionMode(QAbstractItemView::SingleSelection); projectChooserLayout->addWidget(m_listView); projectChooserView->setLayout(projectChooserLayout); m_projectDetailView = new QWidget(); m_projectDetailView->setStyleSheet("QWidget { background: #F2F2F2; }"); auto projectDetailLayout = new QVBoxLayout(); projectDetailLayout->setContentsMargins(10,10,10,10); m_projectDetailView->setLayout(projectDetailLayout); auto footerView = new QWidget(); footerView->setObjectName("FooterView"); footerView->setStyleSheet("QWidget#FooterView { background: #E6E6E6; }"); footerView->setMaximumHeight(50); footerView->setMinimumHeight(50); auto cancelButton = new QPushButton(); cancelButton->setObjectName("StandardGrayButton"); cancelButton->setMinimumSize(QSize(99,28)); #ifdef OPENSTUDIO_PLUGIN cancelButton->setText("Cancel"); connect(cancelButton, &QPushButton::clicked, this, &StartupView::hide); #else #ifdef Q_OS_MAC cancelButton->setText("Quit"); #else cancelButton->setText("Exit"); #endif connect(cancelButton, &QPushButton::clicked, OpenStudioApp::instance(), &OpenStudioApp::quit); #endif cancelButton->setStyleSheet("QPushButton { font: bold; }"); auto chooseButton = new QPushButton(); chooseButton->setObjectName("StandardBlueButton"); chooseButton->setText("Choose"); chooseButton->setMinimumSize(QSize(99,28)); connect(chooseButton, &QPushButton::clicked, this, &StartupView::newFromTemplateSlot); chooseButton->setStyleSheet("QPushButton { font: bold; }"); auto hFooterLayout = new QHBoxLayout(); hFooterLayout->setSpacing(25); hFooterLayout->setContentsMargins(0,0,0,0); hFooterLayout->addStretch(); hFooterLayout->addWidget(cancelButton); hFooterLayout->addWidget(chooseButton); footerView->setLayout(hFooterLayout); auto hLayout = new QHBoxLayout(); auto vLayout = new QVBoxLayout(); auto vOpenLayout = new QVBoxLayout(); vOpenLayout->addWidget(recentProjectsView); vOpenLayout->addWidget(openButton); vOpenLayout->addWidget(importButton); //vOpenLayout->addWidget(importSDDButton); hLayout->addLayout(vOpenLayout); hLayout->addWidget(projectChooserView); hLayout->addWidget(m_projectDetailView,1); vLayout->addSpacing(50); vLayout->addLayout(hLayout); vLayout->addWidget(footerView); setLayout(vLayout); connect(m_listView, &QListView::clicked, this, &StartupView::showDetailsForItem); m_listView->setCurrentIndex(m_templateListModel->index(0,0)); showDetailsForItem(m_templateListModel->index(0,0)); }