Menu::Menu(bool useSpecialHeader) { // Init headerAction = 0; headerActionFrame = 0; headerLabel = 0; iconLabel = 0; // Create header action if useSpecialHeader == true if (useSpecialHeader) { headerAction = new QWidgetAction(this); headerAction->setEnabled(false); headerActionFrame = new QFrame; headerActionFrame->setFrameShape(QFrame::Box); headerAction->setDefaultWidget(headerActionFrame); QHBoxLayout *headerActionFrameLayout = new QHBoxLayout(); headerActionFrameLayout->setMargin(3); headerActionFrameLayout->setSpacing(3); headerActionFrame->setLayout(headerActionFrameLayout); iconLabel = new QLabel; headerLabel = new QLabel; iconSize = style()->pixelMetric(QStyle::PM_SmallIconSize); headerActionFrameLayout->insertWidget(-1,iconLabel,0); headerActionFrameLayout->insertWidget(-1,headerLabel,20); QFont font = headerLabel->font(); font.setBold(true); headerLabel->setFont(font); addAction(headerAction); } }
QWidget *QgsProcessingDistanceWidgetWrapper::createWidget() { const QgsProcessingParameterDistance *distanceDef = static_cast< const QgsProcessingParameterDistance * >( parameterDefinition() ); QWidget *spin = QgsProcessingNumericWidgetWrapper::createWidget(); switch ( type() ) { case QgsProcessingGui::Standard: { mLabel = new QLabel(); mUnitsCombo = new QComboBox(); mUnitsCombo->addItem( QgsUnitTypes::toString( QgsUnitTypes::DistanceMeters ), QgsUnitTypes::DistanceMeters ); mUnitsCombo->addItem( QgsUnitTypes::toString( QgsUnitTypes::DistanceKilometers ), QgsUnitTypes::DistanceKilometers ); mUnitsCombo->addItem( QgsUnitTypes::toString( QgsUnitTypes::DistanceFeet ), QgsUnitTypes::DistanceFeet ); mUnitsCombo->addItem( QgsUnitTypes::toString( QgsUnitTypes::DistanceMiles ), QgsUnitTypes::DistanceMiles ); mUnitsCombo->addItem( QgsUnitTypes::toString( QgsUnitTypes::DistanceYards ), QgsUnitTypes::DistanceYards ); const int labelMargin = static_cast< int >( std::round( mUnitsCombo->fontMetrics().width( 'X' ) ) ); QHBoxLayout *layout = new QHBoxLayout(); layout->addWidget( spin, 1 ); layout->insertSpacing( 1, labelMargin / 2 ); layout->insertWidget( 2, mLabel ); layout->insertWidget( 3, mUnitsCombo ); // bit of fiddlyness here -- we want the initial spacing to only be visible // when the warning label is shown, so it's embedded inside mWarningLabel // instead of outside it mWarningLabel = new QWidget(); QHBoxLayout *warningLayout = new QHBoxLayout(); warningLayout->setMargin( 0 ); warningLayout->setContentsMargins( 0, 0, 0, 0 ); QLabel *warning = new QLabel(); QIcon icon = QgsApplication::getThemeIcon( QStringLiteral( "mIconWarning.svg" ) ); const int size = static_cast< int >( std::max( 24.0, spin->minimumSize().height() * 0.5 ) ); warning->setPixmap( icon.pixmap( icon.actualSize( QSize( size, size ) ) ) ); warning->setToolTip( tr( "Distance is in geographic degrees. Consider reprojecting to a projected local coordinate system for accurate results." ) ); warningLayout->insertSpacing( 0, labelMargin / 2 ); warningLayout->insertWidget( 1, warning ); mWarningLabel->setLayout( warningLayout ); layout->insertWidget( 4, mWarningLabel ); setUnits( distanceDef->defaultUnit() ); QWidget *w = new QWidget(); layout->setMargin( 0 ); layout->setContentsMargins( 0, 0, 0, 0 ); w->setLayout( layout ); return w; } case QgsProcessingGui::Batch: case QgsProcessingGui::Modeler: return spin; } return nullptr; }
void TestAnswersChooser::setState(ChooserState _state) { if(_state == ChooseNums) { ui->numsChooser->setEnabled(true); ui->title->show(); ui->subtitle->hide(); m_demonstrator->hide(); } else if(_state == ShowCorrect) { ui->numsChooser->setEnabled(false); ui->title->hide(); ui->subtitle->show(); QHBoxLayout* l = static_cast<QHBoxLayout*>(layout()); if(l) { m_demonstrator->setCountdown(-1); l->insertWidget(l->count()-1, m_demonstrator); m_demonstrator->show(); } else qDebug() << "Wrong layout type in " << Q_FUNC_INFO; } else if(_state == Finish) emit finished(); else qDebug() << "smth goes wrong in" << Q_FUNC_INFO; }
IconLabel::IconLabel(IconLoader *loader, const QStringList &icon, const QString &text, qreal scale, QWidget *parent) : QWidget(parent) { int iconSize = prepare(text, scale, false); QHBoxLayout *hbox = static_cast<QHBoxLayout *>(layout()); hbox->insertWidget(0, loader->newWidget(icon, iconSize)); }
void prependWidget(QWidget *widget) { widget->setParent(p); hLayout->insertWidget(0, widget); widget->setStyleSheet(makeInnerWidgetsTransparent ? transparentStyleSheet : normalStyleSheet); setWidgetReadOnly(widget, m_isReadOnly); fixTabOrder(); }
// ** Configuration Dialog void BaulkInterfaceDialog::configurationDialogLoader() { configurationDialog = new BaulkDialog( parentWidget ); BaulkControl *control = (BaulkControl*)parentWidget; // Window Title configurationDialog->setWindowTitle( tr("Widget Configuration") ); // Layout QVBoxLayout *vlayout = new QVBoxLayout; vlayout->setContentsMargins( 0,0,0,0 ); QHBoxLayout *hlayout = new QHBoxLayout; hlayout->setContentsMargins( 0,0,0,0 ); hlayout->addLayout( vlayout ); configurationDialog->setLayout( hlayout ); // Widget Tree configurationTree = new QTreeWidget; hlayout->insertWidget( 0, configurationTree ); // Title QLabel *title = new QLabel( tr("<big><b>Configs:</b></big>") ); title->setWordWrap( true ); title->setMargin( 5 ); vlayout->addWidget( title ); // Show Dialog configurationDialog->show(); }
void MainWindow::setupUi() { // Create widget pdf_commands_view = new PdfCommandsView(this); QVBoxLayout *vlayout = qobject_cast<QVBoxLayout*>(commandsSection->layout()); vlayout->addWidget(pdf_commands_view); // Set model pdf_commands_view->setModel(pdf_commands); // Create widget property_editor = new PropertyEditor::PropertyEditor(this); property_editor->setObject(document); vlayout = qobject_cast<QVBoxLayout*>(dockWidgetContents->layout()); vlayout->addWidget(property_editor); // Set model pdfView->setScene(pdf_scene); // Create widget pdf_objects_view = new PdfCommandsView(this); QHBoxLayout *hlayout = qobject_cast<QHBoxLayout*>(objectBrowserTab->layout()); hlayout->insertWidget(0, pdf_objects_view); // Set model pdf_objects_view->setModel(pdf_objects); }
IconLabel::IconLabel(IconLoader *loader, const Cache &cache, const QString &text, qreal scale, bool elide, QWidget *parent) : QWidget(parent) { int iconSize = prepare(text, scale, elide); QHBoxLayout *hbox = static_cast<QHBoxLayout *>(layout()); hbox->insertWidget(0, loader->newWidget(cache, iconSize)); }
void TabBar::createTab(QString tabId, bool closable) { enter TabButton *button = new TabButton(tabId, closable); tabs[tabId] = button; QHBoxLayout *layout = static_cast<QHBoxLayout*>(ui->scrollContent->layout()); layout->insertWidget(tabs.count() > 1 ? 1 : 0, button); updateScrollButtonsVisibility(); leave }
RecordDialog::RecordDialog(QWidget *parent, const char *name) :QDialog(parent, name, TRUE) { QVBoxLayout *layout = new QVBoxLayout(this); QHBoxLayout *hlayout = new QHBoxLayout(this); layout->insertSpacing(0,5); output = new QMultiLineEdit(this, "output"); output->setReadOnly(true); output->setWordWrap(QMultiLineEdit::WidgetWidth); output->setText(tr("Please enter the name of the new remote, and press Next\n")); layout->insertWidget(-1, output); layout->insertSpacing(-1, 5); layout->insertLayout(-1, hlayout); layout->insertSpacing(-1, 5); hlayout->insertSpacing(0, 5); input = new QLineEdit(this, "input"); hlayout->insertWidget(-1, input, 1); hlayout->insertSpacing(-1, 5); nextbtn = new QPushButton(tr("Next"), this, "next"); nextbtn->setDefault(true); hlayout->insertWidget(-1, nextbtn); hlayout->insertSpacing(-1, 5); connect(nextbtn, SIGNAL(clicked()), this, SLOT(nextPressed()) ); setCaption(tr("Learn Remote")); input->setFocus(); stepnum = 0; outputenabled = false; writeok = true; ignorekill = false; record = new OProcess; // We need to stop lircd because irrecord accesses the IR device directly lh = new LircHandler(); lh->stopLircd(); }
void QgsFieldExpressionWidget::setLeftHandButtonStyle( bool isLeft ) { QHBoxLayout* layout = dynamic_cast<QHBoxLayout*>( this->layout() ); if ( isLeft ) { QLayoutItem* item = layout->takeAt( 1 ); layout->insertWidget( 0, item->widget() ); } else layout->addWidget( mCombo ); }
void HoverBoxUI::initCancelAllButton() { QHBoxLayout *layout = qobject_cast<QHBoxLayout*>( _ui->_cancelAllContainer->layout() ); if( layout == NULL ) return; _cancelAllButton = new CommandButton( this, _cancelAllImageUrl ); _cancelAllButton->setMouseOverImage( _cancelAllMouseOverImageUrl ); connect( _cancelAllButton, SIGNAL( clicked() ), this, SIGNAL( cancelAllClicked() ) ); layout->insertWidget( 1, _cancelAllButton ); }
CollapsibleGroup::CollapsibleGroup(int ix, bool firstGroup, bool lastGroup, const EffectInfo &info, QWidget * parent) : AbstractCollapsibleWidget(parent) { m_info.groupIndex = ix; m_subWidgets = QList <CollapsibleEffect *> (); setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont)); frame->setObjectName(QStringLiteral("framegroup")); decoframe->setObjectName(QStringLiteral("decoframegroup")); QHBoxLayout *l = static_cast <QHBoxLayout *>(frame->layout()); m_title = new MyEditableLabel(this); l->insertWidget(2, m_title); m_title->setText(info.groupName.isEmpty() ? i18n("Effect Group") : info.groupName); m_info.groupName = m_title->text(); connect(m_title, SIGNAL(editingFinished()), this, SLOT(slotRenameGroup())); buttonUp->setIcon(KoIconUtils::themedIcon(QStringLiteral("kdenlive-up"))); buttonUp->setToolTip(i18n("Move effect up")); buttonDown->setIcon(KoIconUtils::themedIcon(QStringLiteral("kdenlive-down"))); buttonDown->setToolTip(i18n("Move effect down")); buttonDel->setIcon(KoIconUtils::themedIcon(QStringLiteral("kdenlive-deleffect"))); buttonDel->setToolTip(i18n("Delete effect")); if (firstGroup) buttonUp->setVisible(false); if (lastGroup) buttonDown->setVisible(false); m_menu = new QMenu; m_menu->addAction(KoIconUtils::themedIcon(QStringLiteral("view-refresh")), i18n("Reset Group"), this, SLOT(slotResetGroup())); m_menu->addAction(KoIconUtils::themedIcon(QStringLiteral("document-save")), i18n("Save Group"), this, SLOT(slotSaveGroup())); m_menu->addAction(KoIconUtils::themedIcon(QStringLiteral("list-remove")), i18n("Ungroup"), this, SLOT(slotUnGroup())); setAcceptDrops(true); menuButton->setIcon(KoIconUtils::themedIcon(QStringLiteral("kdenlive-menu"))); menuButton->setMenu(m_menu); m_enabledButton = new KDualAction(i18n("Disable Effect"), i18n("Enable Effect"), this); m_enabledButton->setActiveIcon(KoIconUtils::themedIcon(QStringLiteral("hint"))); m_enabledButton->setInactiveIcon(KoIconUtils::themedIcon(QStringLiteral("visibility"))); enabledButton->setDefaultAction(m_enabledButton); if (info.groupIsCollapsed) { slotShow(false); } connect(collapseButton, SIGNAL(clicked()), this, SLOT(slotSwitch())); connect(m_enabledButton, SIGNAL(activeChangedByUser(bool)), this, SLOT(slotEnable(bool))); connect(buttonUp, SIGNAL(clicked()), this, SLOT(slotEffectUp())); connect(buttonDown, SIGNAL(clicked()), this, SLOT(slotEffectDown())); connect(buttonDel, SIGNAL(clicked()), this, SLOT(slotDeleteGroup())); }
QHBoxLayout *IFormWidget::getHBoxLayout(const int labelOption, const QString &text, QWidget *parent) { QHBoxLayout *hb = new QHBoxLayout(parent); //m_Label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); // TODO: Code specific label options if (labelOption != NoLabel) { createLabel(text); } if (m_Label) { hb->insertWidget(0, m_Label); } hb->setSpacing(5); hb->setMargin(5); return hb; }
//------------------------------------------------------------------------------ void ctkColorDialogPrivate::init() { Q_Q(ctkColorDialog); QVBoxLayout* mainLay = qobject_cast<QVBoxLayout*>(q->layout()); QHBoxLayout* topLay = qobject_cast<QHBoxLayout*>(mainLay->itemAt(0)->layout()); QVBoxLayout* leftLay = qobject_cast<QVBoxLayout*>(topLay->takeAt(0)->layout()); leftLay->setParent(0); this->BasicTab = new QWidget(q); this->BasicTab->setLayout(leftLay); this->LeftTabWidget = new QTabWidget(q); topLay->insertWidget(0, this->LeftTabWidget); this->LeftTabWidget->addTab(this->BasicTab, QObject::tr("Basic")); }
void QTitleWidget::addTitle(const QString &title) { if(title == "" || m_textToTitle.keys().contains(title)) { return; } QSingleTitleWidget * wid = new QSingleTitleWidget(title,this); wid->setVisible(true); QHBoxLayout *l = (QHBoxLayout*)layout(); l->insertWidget(l->count()-4,wid); m_titles.append(wid); m_textToTitle.insert(title,wid); connect(wid,SIGNAL(remove()),this,SLOT(titleDeled())); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { test_QDataTime(); mCustomPlot = NULL; tracerTestTracer = NULL; m_pQCPItemTracerCrossHairTop = NULL; m_pQCPItemTracerCrossHairBottom = NULL; ui->setupUi(this); setGeometry(300, 300, 500, 500); QRect rectTmp = this->rect(); mCustomPlot = new QCustomPlot(this); rectTmp = mCustomPlot->rect(); QHBoxLayout *layout = new QHBoxLayout(); ui->centralWidget->setLayout(layout); layout->insertWidget(0, mCustomPlot); mCustomPlot->axisRect()->setupFullAxesBox(true); presetInteractive(mCustomPlot); //setupItemAnchorTest(mCustomPlot); //setupItemTracerTest(mCustomPlot); //setupGraphTest(mCustomPlot); //setupExportTest(mCustomPlot); //setupLogErrorsTest(mCustomPlot); //setupSelectTest(mCustomPlot); //setupDateTest(mCustomPlot); //setupIntegerTickStepCase(mCustomPlot); //setupTickLabelTest(mCustomPlot); //setupDaqPerformance(mCustomPlot); //setupLayoutTest(mCustomPlot); //setupMultiAxisTest(mCustomPlot); //setupLayoutElementBugTest(mCustomPlot); //setupMarginGroupTest(mCustomPlot); //setupInsetLayoutTest(mCustomPlot); //setupLegendTest(mCustomPlot); //setupMultiAxisRectInteractions(mCustomPlot); //setupAdaptiveSamplingTest(mCustomPlot); //setupColorMapTest(mCustomPlot); //setupItemTracerTest_MyTest_1(mCustomPlot); setupItemTracerTest_MyTest_2(mCustomPlot); //setupTestbed(mCustomPlot); }
CollapsibleGroup::CollapsibleGroup(int ix, bool firstGroup, bool lastGroup, EffectInfo info, QWidget * parent) : AbstractCollapsibleWidget(parent) { m_info.groupIndex = ix; m_subWidgets = QList <CollapsibleEffect *> (); setFont(KGlobalSettings::smallestReadableFont()); frame->setObjectName("framegroup"); decoframe->setObjectName("decoframegroup"); QHBoxLayout *l = static_cast <QHBoxLayout *>(frame->layout()); m_title = new MyEditableLabel(this); l->insertWidget(2, m_title); m_title->setText(info.groupName.isEmpty() ? i18n("Effect Group") : info.groupName); m_info.groupName = m_title->text(); connect(m_title, SIGNAL(editingFinished()), this, SLOT(slotRenameGroup())); buttonUp->setIcon(KIcon("kdenlive-up")); buttonUp->setToolTip(i18n("Move effect up")); buttonDown->setIcon(KIcon("kdenlive-down")); buttonDown->setToolTip(i18n("Move effect down")); buttonDel->setIcon(KIcon("kdenlive-deleffect")); buttonDel->setToolTip(i18n("Delete effect")); if (firstGroup) buttonUp->setVisible(false); if (lastGroup) buttonDown->setVisible(false); m_menu = new QMenu; m_menu->addAction(KIcon("view-refresh"), i18n("Reset Group"), this, SLOT(slotResetGroup())); m_menu->addAction(KIcon("document-save"), i18n("Save Group"), this, SLOT(slotSaveGroup())); m_menu->addAction(KIcon("list-remove"), i18n("Ungroup"), this, SLOT(slotUnGroup())); setAcceptDrops(true); menuButton->setIcon(KIcon("kdenlive-menu")); menuButton->setMenu(m_menu); enabledButton->setChecked(false); enabledButton->setIcon(KIcon("visible")); if (info.groupIsCollapsed) { slotShow(false); } connect(collapseButton, SIGNAL(clicked()), this, SLOT(slotSwitch())); connect(enabledButton, SIGNAL(toggled(bool)), this, SLOT(slotEnable(bool))); connect(buttonUp, SIGNAL(clicked()), this, SLOT(slotEffectUp())); connect(buttonDown, SIGNAL(clicked()), this, SLOT(slotEffectDown())); connect(buttonDel, SIGNAL(clicked()), this, SLOT(slotDeleteGroup())); }
void InMessageForm::setMessage(const Message &msg) { if ( msg.items().length() > 0 && msg.direction() == Message::MessageIn ) { m_msgType = msg.items().at(0).type; switch (m_msgType) { case BasicDef::MIT_NONE: break; case BasicDef::MIT_TEXT: case BasicDef::MIT_IMAGE: case BasicDef::MIT_GIF: case BasicDef::MIT_EMOTICONS: { m_contentWidget = new MultiText(msg, this); m_contentWidget->setObjectName("inMultiText"); m_contentWidget->setStyleSheet("#inMultiText{border-image: url(:/picture/pic/chat.png) 27 27 27 27;" "border-width: 27 27 27 27;" "padding: -25 -25 -25 -25;}"); QHBoxLayout *hLayout = qobject_cast<QHBoxLayout*>(ui->bubble->layout()); if(hLayout) { hLayout->insertWidget(0, m_contentWidget, 1); } break; } case BasicDef::MIT_VOICE: break; case BasicDef::MIT_OFFLINEFILE: break; default: break; } } updateGeometry(); }
/*protected*/ void TabbedTableItem::addToBottomBox(QWidget* comp) { QHBoxLayout* bottomBoxLayout; if(bottomBox->layout() == nullptr) { bottomBox->setLayout(bottomBoxLayout = new QHBoxLayout); } else bottomBoxLayout = (QHBoxLayout*)bottomBox->layout(); try { bottomBoxLayout->addStrut(bottomStrutWidth); ++bottomBoxIndex; bottomBoxLayout->insertWidget(bottomBoxIndex, comp); ++bottomBoxIndex; } catch (IllegalArgumentException ex) { // log.error (ex.getLocalizedMessage(), ex); } }
void ActionLineEdit::actionEvent ( QActionEvent * event ) { QHBoxLayout *lo = (QHBoxLayout *)layout(); QAction *act = event->action(); ActionLineEditButton *btn; if (event->type() == QEvent::ActionAdded) { btn = new ActionLineEditButton(this); QAction *before = event->before(); int beforeInd; if (before && (beforeInd = actions().indexOf(before)) >= 0) { //TODO test it lo->insertWidget(beforeInd + 1, btn); //1 - first item is spacer. skip it } else { lo->addWidget(btn); } btn->setDefaultAction(act); } else if (event->type() == QEvent::ActionRemoved) { for (int i=1, count=lo->count(); i<count; i++) { btn = (ActionLineEditButton *)lo->itemAt(i)->widget(); if (btn->defaultAction() == act) { lo->removeWidget(btn); delete btn; break; } } } int sumWidth = 0; for (int i=1, count=lo->count(); i<count; i++) { btn = (ActionLineEditButton *)lo->itemAt(i)->widget(); if (btn->defaultAction()->isVisible()) { sumWidth += btn->width(); } } sumWidth += 4; //+4px padding between text and buttons. should looks better (magic number) int mLeft, mTop, mRight, mBottom; getTextMargins(&mLeft, &mTop, &mRight, &mBottom); setTextMargins(mLeft, mTop, sumWidth, mBottom); }
//------------------------------------------------------------------------------ void ctkColorDialogPrivate::init() { Q_Q(ctkColorDialog); QVBoxLayout* mainLay = qobject_cast<QVBoxLayout*>(q->layout()); QHBoxLayout* topLay = qobject_cast<QHBoxLayout*>(mainLay->itemAt(0)->layout()); QVBoxLayout* leftLay = qobject_cast<QVBoxLayout*>(topLay->takeAt(0)->layout()); leftLay->setParent(0); this->BasicTab = new QWidget(q); this->BasicTab->setLayout(leftLay); this->LeftTabWidget = new QTabWidget(q); topLay->insertWidget(0, this->LeftTabWidget); this->LeftTabWidget->addTab(this->BasicTab, QObject::tr("Basic")); // If you use a ctkColorDialog, it's probably because you have tabs to add // into. Which means that you are likely to want to resize the dialog as // well. q->setSizeGripEnabled(true); q->layout()->setSizeConstraint(QLayout::SetDefaultConstraint); QObject::connect(q, SIGNAL(currentColorChanged(QColor)), q, SLOT(resetColorName())); }
ProfileForm::ProfileForm(QWidget* parent) : QWidget{parent} , qr{nullptr} { bodyUI = new Ui::IdentitySettings; bodyUI->setupUi(this); core = Core::getInstance(); bodyUI->userNameLabel->setToolTip(tr("Tox user names cannot exceed %1 characters.") .arg(TOX_MAX_NAME_LENGTH)); bodyUI->userName->setMaxLength(TOX_MAX_NAME_LENGTH); // tox toxId = new ClickableTE(); toxId->setReadOnly(true); toxId->setFrame(false); toxId->setFont(Style::getFont(Style::Small)); toxId->setToolTip(bodyUI->toxId->toolTip()); QVBoxLayout* toxIdGroup = qobject_cast<QVBoxLayout*>(bodyUI->toxGroup->layout()); delete toxIdGroup->replaceWidget(bodyUI->toxId, toxId); // Original toxId is in heap, delete it bodyUI->toxId->hide(); /* Toxme section init */ bodyUI->toxmeServersList->addItem("toxme.io"); QString toxmeInfo = Settings::getInstance().getToxmeInfo(); if (toxmeInfo.isEmpty()) // User not registered { showRegisterToxme(); } else { showExistingToxme(); } bodyUI->qrLabel->setWordWrap(true); QRegExp re("[^@ ]+"); QRegExpValidator* validator = new QRegExpValidator(re, this); bodyUI->toxmeUsername->setValidator(validator); profilePicture = new MaskablePixmapWidget(this, QSize(64, 64), ":/img/avatar_mask.svg"); profilePicture->setPixmap(QPixmap(":/img/contact_dark.svg")); profilePicture->setContextMenuPolicy(Qt::CustomContextMenu); profilePicture->setClickable(true); profilePicture->installEventFilter(this); profilePicture->setAccessibleName("Profile avatar"); profilePicture->setAccessibleDescription("Set a profile avatar shown to all contacts"); connect(profilePicture, SIGNAL(clicked()), this, SLOT(onAvatarClicked())); connect(profilePicture, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(showProfilePictureContextMenu(const QPoint&))); QHBoxLayout* publicGrouplayout = qobject_cast<QHBoxLayout*>(bodyUI->publicGroup->layout()); publicGrouplayout->insertWidget(0, profilePicture); publicGrouplayout->insertSpacing(1, 7); timer.setInterval(750); timer.setSingleShot(true); connect(&timer, &QTimer::timeout, this, [=]() { bodyUI->toxIdLabel->setText(bodyUI->toxIdLabel->text().replace(" ✔", "")); hasCheck = false; }); connect(bodyUI->toxIdLabel, SIGNAL(clicked()), this, SLOT(copyIdClicked())); connect(toxId, SIGNAL(clicked()), this, SLOT(copyIdClicked())); connect(core, &Core::idSet, this, &ProfileForm::setToxId); connect(bodyUI->userName, SIGNAL(editingFinished()), this, SLOT(onUserNameEdited())); connect(bodyUI->statusMessage, SIGNAL(editingFinished()), this, SLOT(onStatusMessageEdited())); connect(bodyUI->renameButton, &QPushButton::clicked, this, &ProfileForm::onRenameClicked); connect(bodyUI->exportButton, &QPushButton::clicked, this, &ProfileForm::onExportClicked); connect(bodyUI->deleteButton, &QPushButton::clicked, this, &ProfileForm::onDeleteClicked); connect(bodyUI->logoutButton, &QPushButton::clicked, this, &ProfileForm::onLogoutClicked); connect(bodyUI->deletePassButton, &QPushButton::clicked, this, &ProfileForm::onDeletePassClicked); connect(bodyUI->changePassButton, &QPushButton::clicked, this, &ProfileForm::onChangePassClicked); connect(bodyUI->deletePassButton, &QPushButton::clicked, this, &ProfileForm::setPasswordButtonsText); connect(bodyUI->changePassButton, &QPushButton::clicked, this, &ProfileForm::setPasswordButtonsText); connect(bodyUI->saveQr, &QPushButton::clicked, this, &ProfileForm::onSaveQrClicked); connect(bodyUI->copyQr, &QPushButton::clicked, this, &ProfileForm::onCopyQrClicked); connect(bodyUI->toxmeRegisterButton, &QPushButton::clicked, this, &ProfileForm::onRegisterButtonClicked); connect(bodyUI->toxmeUpdateButton, &QPushButton::clicked, this, &ProfileForm::onRegisterButtonClicked); connect(core, &Core::usernameSet, this, [=](const QString& val) { bodyUI->userName->setText(val); }); connect(core, &Core::statusMessageSet, this, [=](const QString& val) { bodyUI->statusMessage->setText(val); }); for (QComboBox* cb : findChildren<QComboBox*>()) { cb->installEventFilter(this); cb->setFocusPolicy(Qt::StrongFocus); } retranslateUi(); Translator::registerHandler(std::bind(&ProfileForm::retranslateUi, this), this); }
StreamPostWidget::StreamPostWidget(DATA::FbStreamPost *post, QWidget *parent) : QWidget(parent), m_post(post), m_triedBothIcons(false) { m_nam = new QNetworkAccessManager(this); connect(m_nam,SIGNAL(finished(QNetworkReply*)), this, SLOT(gotNetworkReply(QNetworkReply*))); //this->setStyleSheet("background : white;"); this->setAutoFillBackground(true); QPalette palette = this->palette(); palette.setColor(QPalette::Background, Qt::white); setPalette(palette); QHBoxLayout *mainLayout = new QHBoxLayout(); QFrame *f = new QFrame(); f->setMinimumWidth(10); f->setFrameShape(QFrame::VLine); mainLayout->insertWidget(1,f); mainLayout->setSizeConstraint(QLayout::SetMinimumSize); m_contentLayout = new QVBoxLayout(); m_contentLayout->setSizeConstraint(QLayout::SetMinimumSize); if (post->isFromUser()) this->setWindowTitle(post->getPoster().getName()); else this->setWindowTitle(post->getPage().getName()); if (post->getMessage() != "" || (post->getTargetId().compare("") != 0)) { QLabel *message = new QLabel(); QString text = post->getMessage(); if (post->getTargetId().compare("") != 0) text.prepend("-> " + post->getTarget().getName() + ": "); message->setText(UTIL::hyperLink(text)); message->setTextInteractionFlags(Qt::TextBrowserInteraction); message->setWordWrap(true); message->setMinimumWidth(450); message->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum); connect(message, SIGNAL(linkActivated(QString)), this, SIGNAL(contentClicked(QString))); m_contentLayout->addWidget(message,0,Qt::AlignTop); } QString ageHtml = "<style type=\"text/css\">a { text-decoration: none; }</style>" "<font style=\"font-size : 8pt;\">" + UTIL::ageString(post->getCreatedTime()) + " "; if (post->getAttribution() != "" && !post->getAttribution().startsWith("via")) ageHtml.append("via "); ageHtml.append(post->getAttribution() + "</font>"); QLabel *age = new QLabel(ageHtml); m_ageLineLayout = new QHBoxLayout(); m_ageLineLayout->insertWidget(1,age,1); // Get the app icon, prefer the one in attachment if present if (post->getAttachment()->getIcon().toString() != "") { QNetworkRequest nr; nr.setUrl(post->getAttachment()->getIcon()); QNetworkReply *reply = m_nam->get(nr); m_outstandingNetworkRequests.insert(reply, AppIcon); } else if (m_post->getAppInfo().getIconUrl() != "") { m_triedBothIcons = true; QNetworkRequest nr; nr.setUrl(QUrl(m_post->getAppInfo().getIconUrl())); QNetworkReply *reply = m_nam->get(nr); m_outstandingNetworkRequests.insert(reply, AppIcon); } if (!post->getAttachment()->isEmpty()) { DATA::FbStreamAttachment *attachment = post->getAttachment(); FbAttachmentWidget *aw = new FbAttachmentWidget(attachment); aw->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum); connect(aw, SIGNAL(userClickedUrl(QString)), this, SIGNAL(contentClicked(QString))); m_contentLayout->addWidget(aw); } m_contentLayout->addLayout(m_ageLineLayout,0); m_contentLayout->addStretch(); m_contentLayout->addSpacing(10); GUI::FbCommentManager *manager = new FbCommentManager(m_post->getPostId(), FbCommentManager::PostId, m_post->getCommentList()->canRemove()); manager->setMaximumHeight(400); QString fbObjectId = m_post->getPostId(); GUI::FbLikeManager *likeManager = new FbLikeManager(fbObjectId, m_post->userLikes()); connect(likeManager, SIGNAL(userChangedLike(bool)), this, SLOT(likeChanged(bool))); QHBoxLayout *hLayout = new QHBoxLayout(); m_showAddCommentButton = new QToolButton(); m_showAddCommentButton->setAutoFillBackground(true); palette = m_showAddCommentButton->palette(); palette.setColor(QPalette::Button,QColor(82,110,166)); m_showAddCommentButton->setPalette(palette); m_showAddCommentButton->setIcon(QIcon(":/uiImages/addComment_50_50.jpg")); m_showAddCommentButton->setIconSize(QSize(40,40)); m_showAddCommentButton->setToolTip("Comment"); connect(m_showAddCommentButton, SIGNAL(clicked()), manager, SLOT(showAddComment())); hLayout->addWidget(m_showAddCommentButton,0); m_likeButton = new QToolButton(); this->likeChanged(m_post->userLikes()); m_likeButton->setIconSize(QSize(40,40)); connect(m_likeButton, SIGNAL(clicked()), likeManager, SLOT(toggleUserLikes())); hLayout->addWidget(m_likeButton,0); hLayout->addStretch(1); m_contentLayout->addLayout(hLayout,0); m_contentLayout->addWidget(likeManager,0); m_contentLayout->addWidget(manager,2); //manager->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum); mainLayout->insertLayout(2,m_contentLayout,1); setLayout(mainLayout); getPosterPixmap(); QDesktopWidget *dw = QApplication::desktop(); QRect r = dw->screenGeometry(); move(r.width() - 240, 40); }
ProfileForm::ProfileForm(QWidget *parent) : QWidget{parent}, qr{nullptr} { bodyUI = new Ui::IdentitySettings; bodyUI->setupUi(this); core = Core::getInstance(); head = new QWidget(this); QHBoxLayout* headLayout = new QHBoxLayout(); head->setLayout(headLayout); QLabel* imgLabel = new QLabel(); headLayout->addWidget(imgLabel); QLabel* nameLabel = new QLabel(); QFont bold; bold.setBold(true); nameLabel->setFont(bold); headLayout->addWidget(nameLabel); headLayout->addStretch(1); nameLabel->setText(tr("User Profile")); imgLabel->setPixmap(QPixmap(":/img/settings/identity.png").scaledToHeight(40, Qt::SmoothTransformation)); // tox toxId = new ClickableTE(); toxId->setReadOnly(true); toxId->setFrame(false); toxId->setFont(Style::getFont(Style::Small)); toxId->setToolTip(bodyUI->toxId->toolTip()); QVBoxLayout *toxIdGroup = qobject_cast<QVBoxLayout*>(bodyUI->toxGroup->layout()); toxIdGroup->replaceWidget(bodyUI->toxId, toxId); bodyUI->toxId->hide(); bodyUI->qrLabel->setWordWrap(true); profilePicture = new MaskablePixmapWidget(this, QSize(64, 64), ":/img/avatar_mask.svg"); profilePicture->setPixmap(QPixmap(":/img/contact_dark.svg")); profilePicture->setClickable(true); connect(profilePicture, SIGNAL(clicked()), this, SLOT(onAvatarClicked())); QHBoxLayout *publicGrouplayout = qobject_cast<QHBoxLayout*>(bodyUI->publicGroup->layout()); publicGrouplayout->insertWidget(0, profilePicture); publicGrouplayout->insertSpacing(1, 7); timer.setInterval(750); timer.setSingleShot(true); connect(&timer, &QTimer::timeout, this, [=]() {bodyUI->toxIdLabel->setText(bodyUI->toxIdLabel->text().replace(" ✔", "")); hasCheck = false;}); connect(bodyUI->toxIdLabel, SIGNAL(clicked()), this, SLOT(copyIdClicked())); connect(toxId, SIGNAL(clicked()), this, SLOT(copyIdClicked())); connect(core, &Core::idSet, this, &ProfileForm::setToxId); connect(core, &Core::statusSet, this, &ProfileForm::onStatusSet); connect(bodyUI->userName, SIGNAL(editingFinished()), this, SLOT(onUserNameEdited())); connect(bodyUI->statusMessage, SIGNAL(editingFinished()), this, SLOT(onStatusMessageEdited())); connect(bodyUI->loadButton, &QPushButton::clicked, this, &ProfileForm::onLoadClicked); connect(bodyUI->renameButton, &QPushButton::clicked, this, &ProfileForm::onRenameClicked); connect(bodyUI->exportButton, &QPushButton::clicked, this, &ProfileForm::onExportClicked); connect(bodyUI->deleteButton, &QPushButton::clicked, this, &ProfileForm::onDeleteClicked); connect(bodyUI->importButton, &QPushButton::clicked, this, &ProfileForm::onImportClicked); connect(bodyUI->newButton, &QPushButton::clicked, this, &ProfileForm::onNewClicked); connect(core, &Core::avStart, this, &ProfileForm::disableSwitching); connect(core, &Core::avStarting, this, &ProfileForm::disableSwitching); connect(core, &Core::avInvite, this, &ProfileForm::disableSwitching); connect(core, &Core::avRinging, this, &ProfileForm::disableSwitching); connect(core, &Core::avCancel, this, &ProfileForm::enableSwitching); connect(core, &Core::avEnd, this, &ProfileForm::enableSwitching); connect(core, &Core::avEnding, this, &ProfileForm::enableSwitching); connect(core, &Core::avPeerTimeout, this, &ProfileForm::enableSwitching); connect(core, &Core::avRequestTimeout, this, &ProfileForm::enableSwitching); connect(core, &Core::usernameSet, this, [=](const QString& val) { bodyUI->userName->setText(val); }); connect(core, &Core::statusMessageSet, this, [=](const QString& val) { bodyUI->statusMessage->setText(val); }); for (QComboBox* cb : findChildren<QComboBox*>()) { cb->installEventFilter(this); cb->setFocusPolicy(Qt::StrongFocus); } }
InstrumentMidiIOView::InstrumentMidiIOView( QWidget* parent ) : QWidget( parent ), ModelView( NULL, this ), m_rpBtn( NULL ), m_wpBtn( NULL ) { QVBoxLayout* layout = new QVBoxLayout( this ); layout->setMargin( 5 ); m_midiInputGroupBox = new GroupBox( tr( "ENABLE MIDI INPUT" ) ); layout->addWidget( m_midiInputGroupBox ); QHBoxLayout* midiInputLayout = new QHBoxLayout( m_midiInputGroupBox ); midiInputLayout->setContentsMargins( 8, 18, 8, 8 ); midiInputLayout->setSpacing( 6 ); m_inputChannelSpinBox = new LcdSpinBox( 2, m_midiInputGroupBox ); m_inputChannelSpinBox->addTextForValue( 0, "--" ); m_inputChannelSpinBox->setLabel( tr( "CHANNEL" ) ); m_inputChannelSpinBox->setEnabled( false ); midiInputLayout->addWidget( m_inputChannelSpinBox ); m_fixedInputVelocitySpinBox = new LcdSpinBox( 3, m_midiInputGroupBox ); m_fixedInputVelocitySpinBox->setDisplayOffset( 1 ); m_fixedInputVelocitySpinBox->addTextForValue( 0, "---" ); m_fixedInputVelocitySpinBox->setLabel( tr( "VELOCITY" ) ); m_fixedInputVelocitySpinBox->setEnabled( false ); midiInputLayout->addWidget( m_fixedInputVelocitySpinBox ); midiInputLayout->addStretch(); connect( m_midiInputGroupBox->ledButton(), SIGNAL( toggled( bool ) ), m_inputChannelSpinBox, SLOT( setEnabled( bool ) ) ); connect( m_midiInputGroupBox->ledButton(), SIGNAL( toggled( bool ) ), m_fixedInputVelocitySpinBox, SLOT( setEnabled( bool ) ) ); m_midiOutputGroupBox = new GroupBox( tr( "ENABLE MIDI OUTPUT" ) ); layout->addWidget( m_midiOutputGroupBox ); QHBoxLayout* midiOutputLayout = new QHBoxLayout( m_midiOutputGroupBox ); midiOutputLayout->setContentsMargins( 8, 18, 8, 8 ); midiOutputLayout->setSpacing( 6 ); m_outputChannelSpinBox = new LcdSpinBox( 2, m_midiOutputGroupBox ); m_outputChannelSpinBox->setLabel( tr( "CHANNEL" ) ); m_outputChannelSpinBox->setEnabled( false ); midiOutputLayout->addWidget( m_outputChannelSpinBox ); m_fixedOutputVelocitySpinBox = new LcdSpinBox( 3, m_midiOutputGroupBox ); m_fixedOutputVelocitySpinBox->setDisplayOffset( 1 ); m_fixedOutputVelocitySpinBox->addTextForValue( 0, "---" ); m_fixedOutputVelocitySpinBox->setLabel( tr( "VELOCITY" ) ); m_fixedOutputVelocitySpinBox->setEnabled( false ); midiOutputLayout->addWidget( m_fixedOutputVelocitySpinBox ); m_outputProgramSpinBox = new LcdSpinBox( 3, m_midiOutputGroupBox ); m_outputProgramSpinBox->setLabel( tr( "PROGRAM" ) ); m_outputProgramSpinBox->setEnabled( false ); midiOutputLayout->addWidget( m_outputProgramSpinBox ); m_fixedOutputNoteSpinBox = new LcdSpinBox( 3, m_midiOutputGroupBox ); m_fixedOutputNoteSpinBox->setDisplayOffset( 1 ); m_fixedOutputNoteSpinBox->addTextForValue( 0, "---" ); m_fixedOutputNoteSpinBox->setLabel( tr( "NOTE" ) ); m_fixedOutputNoteSpinBox->setEnabled( false ); midiOutputLayout->addWidget( m_fixedOutputNoteSpinBox ); midiOutputLayout->addStretch(); connect( m_midiOutputGroupBox->ledButton(), SIGNAL( toggled( bool ) ), m_outputChannelSpinBox, SLOT( setEnabled( bool ) ) ); connect( m_midiOutputGroupBox->ledButton(), SIGNAL( toggled( bool ) ), m_fixedOutputVelocitySpinBox, SLOT( setEnabled( bool ) ) ); connect( m_midiOutputGroupBox->ledButton(), SIGNAL( toggled( bool ) ), m_outputProgramSpinBox, SLOT( setEnabled( bool ) ) ); connect( m_midiOutputGroupBox->ledButton(), SIGNAL( toggled( bool ) ), m_fixedOutputNoteSpinBox, SLOT( setEnabled( bool ) ) ); if( !Engine::mixer()->midiClient()->isRaw() ) { m_rpBtn = new QToolButton; m_rpBtn->setMinimumSize( 32, 32 ); m_rpBtn->setText( tr( "MIDI devices to receive MIDI events from" ) ); m_rpBtn->setIcon( embed::getIconPixmap( "piano" ) ); m_rpBtn->setPopupMode( QToolButton::InstantPopup ); midiInputLayout->insertSpacing( 0, 4 ); midiInputLayout->insertWidget( 0, m_rpBtn ); m_wpBtn = new QToolButton; m_wpBtn->setMinimumSize( 32, 32 ); m_wpBtn->setText( tr( "MIDI devices to send MIDI events to" ) ); m_wpBtn->setIcon( embed::getIconPixmap( "piano" ) ); m_wpBtn->setPopupMode( QToolButton::InstantPopup ); midiOutputLayout->insertSpacing( 0, 4 ); midiOutputLayout->insertWidget( 0, m_wpBtn ); } #define PROVIDE_CUSTOM_BASE_VELOCITY_UI #ifdef PROVIDE_CUSTOM_BASE_VELOCITY_UI GroupBox* baseVelocityGroupBox = new GroupBox( tr( "CUSTOM BASE VELOCITY" ) ); layout->addWidget( baseVelocityGroupBox ); QVBoxLayout* baseVelocityLayout = new QVBoxLayout( baseVelocityGroupBox ); baseVelocityLayout->setContentsMargins( 8, 18, 8, 8 ); baseVelocityLayout->setSpacing( 6 ); QLabel* baseVelocityHelp = new QLabel( tr( "Specify the velocity normalization base for MIDI-based instruments at 100% note velocity" ) ); baseVelocityHelp->setWordWrap( true ); baseVelocityHelp->setFont( pointSize<8>( baseVelocityHelp->font() ) ); baseVelocityLayout->addWidget( baseVelocityHelp ); m_baseVelocitySpinBox = new LcdSpinBox( 3, baseVelocityGroupBox ); m_baseVelocitySpinBox->setLabel( tr( "BASE VELOCITY" ) ); m_baseVelocitySpinBox->setEnabled( false ); baseVelocityLayout->addWidget( m_baseVelocitySpinBox ); connect( baseVelocityGroupBox->ledButton(), SIGNAL( toggled( bool ) ), m_baseVelocitySpinBox, SLOT( setEnabled( bool ) ) ); #endif layout->addStretch(); }
void ParameterWidget::changeFilterObject(int index) { XComboBox *mybox = (XComboBox *)sender(); QStringList split = mybox->itemData(index).toString().split(":"); QString row = split.at(0); int type = split.at(1).toInt(); XSqlQuery qry; QWidget *widget = _filterGroup->findChild<QWidget *>("widget" + row); QWidget *button = _filterGroup->findChild<QToolButton *>("button" + row); QHBoxLayout *layout = _filterGroup->findChild<QHBoxLayout *>("widgetLayout1" + row);; QPair<QString, ParameterWidgetTypes> tempPair; DLineEdit *dLineEdit= new DLineEdit(_filterGroup); UsernameCluster *usernameCluster = new UsernameCluster(_filterGroup); CRMAcctCluster *crmacctCluster = new CRMAcctCluster(_filterGroup); QLineEdit *lineEdit = new QLineEdit(_filterGroup); XComboBox *xBox = new XComboBox(_filterGroup); ContactCluster *contactCluster = new ContactCluster(_filterGroup); if (widget && layout && button) delete widget; else return; switch (type) { case Date: delete usernameCluster; delete crmacctCluster; delete lineEdit; delete xBox; delete contactCluster; dLineEdit->setObjectName("widget" + row); layout->insertWidget(0, dLineEdit); connect(button, SIGNAL(clicked()), dLineEdit, SLOT( deleteLater() ) ); connect(dLineEdit, SIGNAL(newDate(QDate)), this, SLOT( storeFilterValue(QDate) ) ); break; case User: delete dLineEdit; delete crmacctCluster; delete lineEdit; delete xBox; delete contactCluster; usernameCluster->setObjectName("widget" + row); usernameCluster->setNameVisible(false); usernameCluster->setDescriptionVisible(false); usernameCluster->setLabel(""); layout->insertWidget(0, usernameCluster); connect(button, SIGNAL(clicked()), usernameCluster, SLOT( deleteLater() ) ); connect(usernameCluster, SIGNAL(newId(int)), this, SLOT( storeFilterValue(int) ) ); break; case Crmacct: delete dLineEdit; delete usernameCluster; delete lineEdit; delete xBox; delete contactCluster; crmacctCluster->setObjectName("widget" + row); crmacctCluster->setNameVisible(false); crmacctCluster->setDescriptionVisible(false); crmacctCluster->setLabel(""); layout->insertWidget(0, crmacctCluster); connect(button, SIGNAL(clicked()), crmacctCluster, SLOT( deleteLater() ) ); connect(crmacctCluster, SIGNAL(newId(int)), this, SLOT( storeFilterValue(int) ) ); break; case Contact: delete dLineEdit; delete usernameCluster; delete lineEdit; delete xBox; delete crmacctCluster; contactCluster->setObjectName("widget" + row); contactCluster->setDescriptionVisible(false); contactCluster->setLabel(""); layout->insertWidget(0, contactCluster); connect(button, SIGNAL(clicked()), contactCluster, SLOT( deleteLater() ) ); connect(contactCluster, SIGNAL(newId(int)), this, SLOT( storeFilterValue(int) ) ); break; case XComBox: delete dLineEdit; delete usernameCluster; delete lineEdit; delete crmacctCluster; delete contactCluster; xBox->setObjectName("widget" + row); xBox->setType(_comboTypes[mybox->currentText()]); if (_comboTypes[mybox->currentText()] == XComboBox::Adhoc) { qry.prepare( _comboQuery[mybox->currentText()] ); qry.exec(); xBox->populate(qry); } layout->insertWidget(0, xBox); connect(button, SIGNAL(clicked()), xBox, SLOT( deleteLater() ) ); connect(xBox, SIGNAL(newID(int)), this, SLOT( storeFilterValue(int) ) ); break; default: delete dLineEdit; delete usernameCluster; delete crmacctCluster; delete xBox; delete contactCluster; lineEdit->setObjectName("widget" + row); layout->insertWidget(0, lineEdit); connect(button, SIGNAL(clicked()), lineEdit, SLOT( deleteLater() ) ); connect(lineEdit, SIGNAL(editingFinished()), this, SLOT( storeFilterValue() ) ); break; } }
MainWindow::MainWindow(Core::Application *app, QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), m_application(app), m_settings(app->settings()), m_zealListModel(new ListModel(app->docsetRegistry(), this)), m_settingsDialog(new SettingsDialog(app, m_zealListModel, this)), m_globalShortcut(new QxtGlobalShortcut(m_settings->showShortcut, this)) { ui->setupUi(this); connect(m_settings, &Core::Settings::updated, this, &MainWindow::applySettings); m_tabBar = new QTabBar(this); m_tabBar->installEventFilter(this); setWindowIcon(QIcon::fromTheme(QStringLiteral("zeal"), QIcon(QStringLiteral(":/zeal.ico")))); if (m_settings->showSystrayIcon) createTrayIcon(); // initialise key grabber connect(m_globalShortcut, &QxtGlobalShortcut::activated, this, &MainWindow::toggleWindow); QShortcut *focusSearch = new QShortcut(QKeySequence(QStringLiteral("Ctrl+K")), this); focusSearch->setContext(Qt::ApplicationShortcut); connect(focusSearch, &QShortcut::activated, ui->lineEdit, static_cast<void (SearchEdit::*)()>(&SearchEdit::setFocus)); restoreGeometry(m_settings->windowGeometry); ui->splitter->restoreState(m_settings->verticalSplitterGeometry); m_zealNetworkManager = new NetworkAccessManager(this); #ifdef USE_WEBENGINE /// FIXME AngularJS workaround (zealnetworkaccessmanager.cpp) #else ui->webView->page()->setNetworkAccessManager(m_zealNetworkManager); #endif // menu if (QKeySequence(QKeySequence::Quit) != QKeySequence(QStringLiteral("Ctrl+Q"))) { ui->actionQuit->setShortcuts(QList<QKeySequence>{QKeySequence(QStringLiteral("Ctrl+Q")), QKeySequence::Quit}); } else { // Quit == Ctrl+Q - don't set the same sequence twice because it causes // "QAction::eventFilter: Ambiguous shortcut overload: Ctrl+Q" ui->actionQuit->setShortcuts(QList<QKeySequence>{QKeySequence::Quit}); } connect(ui->actionQuit, &QAction::triggered, qApp, &QCoreApplication::quit); connect(ui->actionOptions, &QAction::triggered, [=]() { m_globalShortcut->setEnabled(false); m_settingsDialog->exec(); m_globalShortcut->setEnabled(true); }); ui->actionBack->setShortcut(QKeySequence::Back); addAction(ui->actionBack); ui->actionForward->setShortcut(QKeySequence::Forward); addAction(ui->actionForward); connect(ui->actionBack, &QAction::triggered, this, &MainWindow::back); connect(ui->actionForward, &QAction::triggered, this, &MainWindow::forward); // Help Menu connect(ui->actionReportProblem, &QAction::triggered, [this]() { QDesktopServices::openUrl(QStringLiteral("https://github.com/zealdocs/zeal/issues")); }); connect(ui->actionCheckForUpdate, &QAction::triggered, m_application, &Core::Application::checkForUpdate); connect(ui->actionAboutZeal, &QAction::triggered, [this]() { QScopedPointer<AboutDialog> dialog(new AboutDialog(this)); dialog->exec(); }); connect(ui->actionAboutQt, &QAction::triggered, [this]() { QMessageBox::aboutQt(this); }); // Update check connect(m_application, &Core::Application::updateCheckError, [this](const QString &message) { QMessageBox::warning(this, QStringLiteral("Zeal"), message); }); connect(m_application, &Core::Application::updateCheckDone, [this](const QString &version) { if (version.isEmpty()) { QMessageBox::information(this, QStringLiteral("Zeal"), tr("You are using the latest Zeal version.")); return; } const int ret = QMessageBox::information(this, QStringLiteral("Zeal"), QString(tr("A new version <b>%1</b> is available. Open download page?")).arg(version), QMessageBox::Yes, QMessageBox::No); if (ret == QMessageBox::Yes) QDesktopServices::openUrl(QStringLiteral("https://zealdocs.org/download.html")); }); m_backMenu = new QMenu(ui->backButton); ui->backButton->setMenu(m_backMenu); m_forwardMenu = new QMenu(ui->forwardButton); ui->forwardButton->setMenu(m_forwardMenu); displayViewActions(); // treeView and lineEdit ui->lineEdit->setTreeView(ui->treeView); ui->lineEdit->setFocus(); setupSearchBoxCompletions(); SearchItemDelegate *delegate = new SearchItemDelegate(ui->treeView); connect(ui->lineEdit, &QLineEdit::textChanged, [delegate](const QString &text) { delegate->setHighlight(Zeal::SearchQuery::fromString(text).query()); }); ui->treeView->setItemDelegate(delegate); createTab(); /// FIXME: QTabBar does not emit currentChanged() after the first addTab() call reloadTabState(); connect(ui->treeView, &QTreeView::clicked, [this](const QModelIndex &index) { m_treeViewClicked = true; ui->treeView->activated(index); }); connect(ui->sections, &QListView::clicked, [this](const QModelIndex &index) { m_treeViewClicked = true; ui->sections->activated(index); }); connect(ui->treeView, &QTreeView::activated, this, &MainWindow::openDocset); connect(ui->sections, &QListView::activated, this, &MainWindow::openDocset); connect(ui->forwardButton, &QPushButton::clicked, this, &MainWindow::forward); connect(ui->backButton, &QPushButton::clicked, this, &MainWindow::back); connect(ui->webView, &SearchableWebView::urlChanged, [this](const QUrl &url) { const QString name = docsetName(url); m_tabBar->setTabIcon(m_tabBar->currentIndex(), docsetIcon(name)); Docset *docset = m_application->docsetRegistry()->docset(name); if (docset) m_searchState->sectionsList->setResults(docset->relatedLinks(url)); displayViewActions(); }); connect(ui->webView, &SearchableWebView::titleChanged, [this](const QString &) { displayViewActions(); }); connect(ui->webView, &SearchableWebView::linkClicked, [this](const QUrl &url) { const QString message = tr("Do you want to open an external link?<br>URL: <b>%1</b>"); int ret = QMessageBox::question(this, QStringLiteral("Zeal"), message.arg(url.toString())); if (ret == QMessageBox::Yes) QDesktopServices::openUrl(url); }); connect(m_application->docsetRegistry(), &DocsetRegistry::queryCompleted, this, &MainWindow::onSearchComplete); connect(m_application->docsetRegistry(), &DocsetRegistry::docsetRemoved, this, [this](const QString &name) { setupSearchBoxCompletions(); for (SearchState *searchState : m_tabs) { #ifdef USE_WEBENGINE if (docsetName(searchState->page->url()) != name) continue; searchState->page->load(QUrl(startPageUrl)); #else if (docsetName(searchState->page->mainFrame()->url()) != name) continue; searchState->sectionsList->setResults(); // optimization: disable updates temporarily because // removeSearchResultWithName can call {begin,end}RemoveRows // multiple times which can cause GUI updates to be suboptimal // in case of many rows to be removed ui->treeView->setUpdatesEnabled(false); searchState->zealSearch->removeSearchResultWithName(name); ui->treeView->setUpdatesEnabled(true); searchState->page->mainFrame()->load(QUrl(startPageUrl)); #endif /// TODO: Cleanup history } }); connect(m_application->docsetRegistry(), &DocsetRegistry::docsetAdded, this, [this](const QString &) { setupSearchBoxCompletions(); }); connect(ui->lineEdit, &QLineEdit::textChanged, [this](const QString &text) { if (!m_searchState || text == m_searchState->searchQuery) return; m_searchState->searchQuery = text; m_application->docsetRegistry()->search(text); if (text.isEmpty()) { m_searchState->sectionsList->setResults(); displayTreeView(); } }); ui->actionNewTab->setShortcut(QKeySequence::AddTab); connect(ui->actionNewTab, &QAction::triggered, this, &MainWindow::createTab); addAction(ui->actionNewTab); // save the expanded items: connect(ui->treeView, &QTreeView::expanded, [this](QModelIndex index) { if (m_searchState->expansions.indexOf(index) == -1) m_searchState->expansions.append(index); }); connect(ui->treeView, &QTreeView::collapsed, [this](QModelIndex index) { m_searchState->expansions.removeOne(index); }); #ifdef Q_OS_WIN32 ui->actionCloseTab->setShortcut(QKeySequence(Qt::Key_W + Qt::CTRL)); #else ui->actionCloseTab->setShortcut(QKeySequence::Close); #endif addAction(ui->actionCloseTab); connect(ui->actionCloseTab, &QAction::triggered, this, [this]() { closeTab(); }); m_tabBar->setTabsClosable(true); m_tabBar->setSelectionBehaviorOnRemove(QTabBar::SelectPreviousTab); m_tabBar->setExpanding(false); m_tabBar->setUsesScrollButtons(true); m_tabBar->setDrawBase(false); m_tabBar->setDocumentMode(true); m_tabBar->setElideMode(Qt::ElideRight); m_tabBar->setStyleSheet(QStringLiteral("QTabBar::tab { width: 150px; }")); connect(m_tabBar, &QTabBar::currentChanged, this, &MainWindow::goToTab); connect(m_tabBar, &QTabBar::tabCloseRequested, this, &MainWindow::closeTab); { QHBoxLayout *layout = reinterpret_cast<QHBoxLayout *>(ui->tabBarFrame->layout()); layout->insertWidget(2, m_tabBar, 0, Qt::AlignBottom); } connect(ui->openUrlButton, &QPushButton::clicked, [this]() { const QUrl url(ui->webView->page()->history()->currentItem().url()); if (url.scheme() != QLatin1String("qrc")) QDesktopServices::openUrl(url); }); ui->actionNextTab->setShortcut(QKeySequence::NextChild); addAction(ui->actionNextTab); connect(ui->actionNextTab, &QAction::triggered, [this]() { m_tabBar->setCurrentIndex((m_tabBar->currentIndex() + 1) % m_tabBar->count()); }); ui->actionPreviousTab->setShortcut(QKeySequence::PreviousChild); addAction(ui->actionPreviousTab); connect(ui->actionPreviousTab, &QAction::triggered, [this]() { m_tabBar->setCurrentIndex((m_tabBar->currentIndex() - 1 + m_tabBar->count()) % m_tabBar->count()); }); #ifdef Q_OS_OSX ui->treeView->setAttribute(Qt::WA_MacShowFocusRect, false); ui->sections->setAttribute(Qt::WA_MacShowFocusRect, false); #endif /// TODO: Remove in the future releases // Check pre-0.1 docset path QString oldDocsetDir = QStandardPaths::writableLocation(QStandardPaths::DataLocation); oldDocsetDir.remove(QStringLiteral("Zeal/Zeal")); oldDocsetDir += QLatin1String("zeal/docsets"); if (QFileInfo::exists(oldDocsetDir) && m_settings->docsetPath != oldDocsetDir) { QMessageBox::information(this, QStringLiteral("Zeal"), QString(tr("Old docset storage has been found in <b>%1</b>. " "You can move docsets to <b>%2</b> or change the docset storage path in the settings. <br><br>" "Please note, that old docsets cannot be updated automatically, so it is better to download your docsets again. <br><br>" "Remove or use the old docset storage to avoid this message in the future.")) .arg(QDir::toNativeSeparators(oldDocsetDir), QDir::toNativeSeparators(m_settings->docsetPath))); } if (m_settings->checkForUpdate) m_application->checkForUpdate(true); }
void GameWidgetScrollArea::resizeEvent(QResizeEvent * event) { int widgetWidth = GameChoiceWidget::getWidgetWidth(); int widgetsPerRowNew = event->size().width() / widgetWidth; if (widgetsPerRowNew <= 0) { fprintf(stderr, "Error: window too small. Exiting.\n"); static GameController* instance = GameController::acquire(); instance->terminateApplication(); } if (widgetsPerRowNew < m_widgetsPerRow) { // too many widgets per row, must make rows shorter QVBoxLayout* overallLayout = (QVBoxLayout*) this->widget()->layout(); int numToMove = m_widgetsPerRow - widgetsPerRowNew; for (int i = 0; i < overallLayout->count() - 1 && numToMove > 0; ++i) { QHBoxLayout* horizontalRow = (QHBoxLayout*) overallLayout->itemAt(i)->layout(); QHBoxLayout* nextHorizontalRow; for (int j = 0; j < numToMove; ++j) { QWidget* lastWidget = horizontalRow->itemAt( horizontalRow->count() - 2)->widget(); horizontalRow->removeWidget(lastWidget); if (i == overallLayout->count() - 2) { QHBoxLayout* newRow = new QHBoxLayout(); newRow->addStretch(ms_stretchFactor); overallLayout->insertLayout(overallLayout->count() - 1, newRow); } nextHorizontalRow = (QHBoxLayout*) overallLayout->itemAt(i + 1)->layout(); nextHorizontalRow->insertWidget(0, lastWidget, 0, Qt::AlignLeading); } numToMove = nextHorizontalRow->count() - widgetsPerRowNew - 1; } m_widgetsPerRow = std::min(widgetsPerRowNew, m_totalNumberGameWidgets); } else if (m_widgetsPerRow < m_totalNumberGameWidgets && widgetsPerRowNew > m_widgetsPerRow) { // add widgets to each row to make each longer and have less rows QVBoxLayout* overallLayout = (QVBoxLayout*) this->widget()->layout(); int numToMove = widgetsPerRowNew - m_widgetsPerRow; QHBoxLayout* currentHorizontalRow = (QHBoxLayout*) overallLayout->itemAt(0)->layout(); for (int i = 1; i < overallLayout->count() - 1; ++i) { QHBoxLayout* nextHorizontalRow = (QHBoxLayout*) overallLayout->itemAt(i)->layout(); for (int j = 0; j < numToMove; ++j) { if (nextHorizontalRow->count() <= 1) { if (i == overallLayout->count() - 2) { overallLayout->removeItem(overallLayout->itemAt(i)); break; } overallLayout->removeItem(overallLayout->itemAt(i)); nextHorizontalRow = (QHBoxLayout*) overallLayout->itemAt(i)->layout(); } QWidget* firstWidget = nextHorizontalRow->itemAt(0)->widget(); nextHorizontalRow->removeWidget(firstWidget); currentHorizontalRow->insertWidget( currentHorizontalRow->count() - 1, firstWidget); } currentHorizontalRow = nextHorizontalRow; numToMove = widgetsPerRowNew - (nextHorizontalRow->count() - 1); } m_widgetsPerRow = std::min(widgetsPerRowNew, m_totalNumberGameWidgets); } QWidget* content = this->widget(); content->resize(this->width(), content->sizeHint().height()); }
ProfileForm::ProfileForm(QWidget *parent) : QWidget{parent}, qr{nullptr} { bodyUI = new Ui::IdentitySettings; bodyUI->setupUi(this); core = Core::getInstance(); head = new QWidget(this); QHBoxLayout* headLayout = new QHBoxLayout(); head->setLayout(headLayout); QLabel* imgLabel = new QLabel(); headLayout->addWidget(imgLabel); nameLabel = new QLabel(); QFont bold; bold.setBold(true); nameLabel->setFont(bold); headLayout->addWidget(nameLabel); headLayout->addStretch(1); imgLabel->setPixmap(QPixmap(":/img/settings/identity.png").scaledToHeight(40, Qt::SmoothTransformation)); // tox toxId = new ClickableTE(); toxId->setReadOnly(true); toxId->setFrame(false); toxId->setFont(Style::getFont(Style::Small)); toxId->setToolTip(bodyUI->toxId->toolTip()); QVBoxLayout *toxIdGroup = qobject_cast<QVBoxLayout*>(bodyUI->toxGroup->layout()); delete toxIdGroup->replaceWidget(bodyUI->toxId, toxId); // Original toxId is in heap, delete it bodyUI->toxId->hide(); bodyUI->qrLabel->setWordWrap(true); profilePicture = new MaskablePixmapWidget(this, QSize(64, 64), ":/img/avatar_mask.svg"); profilePicture->setPixmap(QPixmap(":/img/contact_dark.svg")); profilePicture->setContextMenuPolicy(Qt::CustomContextMenu); profilePicture->setClickable(true); profilePicture->installEventFilter(this); connect(profilePicture, SIGNAL(clicked()), this, SLOT(onAvatarClicked())); connect(profilePicture, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(showProfilePictureContextMenu(const QPoint&))); QHBoxLayout *publicGrouplayout = qobject_cast<QHBoxLayout*>(bodyUI->publicGroup->layout()); publicGrouplayout->insertWidget(0, profilePicture); publicGrouplayout->insertSpacing(1, 7); timer.setInterval(750); timer.setSingleShot(true); connect(&timer, &QTimer::timeout, this, [=]() {bodyUI->toxIdLabel->setText(bodyUI->toxIdLabel->text().replace(" ✔", "")); hasCheck = false;}); connect(bodyUI->toxIdLabel, SIGNAL(clicked()), this, SLOT(copyIdClicked())); connect(toxId, SIGNAL(clicked()), this, SLOT(copyIdClicked())); connect(core, &Core::idSet, this, &ProfileForm::setToxId); connect(bodyUI->userName, SIGNAL(editingFinished()), this, SLOT(onUserNameEdited())); connect(bodyUI->statusMessage, SIGNAL(editingFinished()), this, SLOT(onStatusMessageEdited())); connect(bodyUI->renameButton, &QPushButton::clicked, this, &ProfileForm::onRenameClicked); connect(bodyUI->exportButton, &QPushButton::clicked, this, &ProfileForm::onExportClicked); connect(bodyUI->deleteButton, &QPushButton::clicked, this, &ProfileForm::onDeleteClicked); connect(bodyUI->logoutButton, &QPushButton::clicked, this, &ProfileForm::onLogoutClicked); connect(bodyUI->deletePassButton, &QPushButton::clicked, this, &ProfileForm::onDeletePassClicked); connect(bodyUI->changePassButton, &QPushButton::clicked, this, &ProfileForm::onChangePassClicked); connect(bodyUI->saveQr, &QPushButton::clicked, this, &ProfileForm::onSaveQrClicked); connect(bodyUI->copyQr, &QPushButton::clicked, this, &ProfileForm::onCopyQrClicked); connect(core, &Core::usernameSet, this, [=](const QString& val) { bodyUI->userName->setText(val); }); connect(core, &Core::statusMessageSet, this, [=](const QString& val) { bodyUI->statusMessage->setText(val); }); for (QComboBox* cb : findChildren<QComboBox*>()) { cb->installEventFilter(this); cb->setFocusPolicy(Qt::StrongFocus); } retranslateUi(); Translator::registerHandler(std::bind(&ProfileForm::retranslateUi, this), this); }