// TBD: would have been better if all the signals were to originate from PicBucket... void PicsSelectWidget::updateCount() { int newN = PicBucket::instance().selectedCount(); if (newN == m_currentGlobalCount) return; m_currentGlobalCount = newN; // this is OK since there is no atomic operation which can both add pieces and remove piece // except Loading, which is handled in updateView() updateFamSelected(); // update the count of all the families updateSetsSpinBox(m_tabs->currentIndex()); emit changedPieceCount(newN); updateNumLabel(); // update the label only after the document re-calculated the new warning }
void PicsSelectWidget::setBuildTilesCount(int n) { m_currentBuildTilesCount = n; updateNumLabel(); }
void VSearcher::setupUI() { if (m_uiInitialized) { return; } m_uiInitialized = true; // Search button. m_searchBtn = new QPushButton(VIconUtils::buttonIcon(":/resources/icons/search.svg"), "", this); m_searchBtn->setToolTip(tr("Search")); m_searchBtn->setProperty("FlatBtn", true); connect(m_searchBtn, &QPushButton::clicked, this, &VSearcher::startSearch); // Clear button. m_clearBtn = new QPushButton(VIconUtils::buttonDangerIcon(":/resources/icons/clear_search.svg"), "", this); m_clearBtn->setToolTip(tr("Clear Results")); m_clearBtn->setProperty("FlatBtn", true); connect(m_clearBtn, &QPushButton::clicked, this, [this]() { m_results->clearResults(); }); // Advanced button. m_advBtn = new QPushButton(VIconUtils::buttonIcon(":/resources/icons/search_advanced.svg"), "", this); m_advBtn->setToolTip(tr("Advanced Settings")); m_advBtn->setProperty("FlatBtn", true); m_advBtn->setCheckable(true); connect(m_advBtn, &QPushButton::toggled, this, [this](bool p_checked) { m_advWidget->setVisible(p_checked); }); // Console button. m_consoleBtn = new QPushButton(VIconUtils::buttonIcon(":/resources/icons/search_console.svg"), "", this); m_consoleBtn->setToolTip(tr("Console")); m_consoleBtn->setProperty("FlatBtn", true); m_consoleBtn->setCheckable(true); connect(m_consoleBtn, &QPushButton::toggled, this, [this](bool p_checked) { m_consoleEdit->setVisible(p_checked); }); m_numLabel = new QLabel(this); QHBoxLayout *btnLayout = new QHBoxLayout(); btnLayout->addWidget(m_searchBtn); btnLayout->addWidget(m_clearBtn); btnLayout->addWidget(m_advBtn); btnLayout->addWidget(m_consoleBtn); btnLayout->addStretch(); btnLayout->addWidget(m_numLabel); btnLayout->setContentsMargins(0, 0, 0, 0); // Keyword. m_keywordCB = VUtils::getComboBox(this); m_keywordCB->setEditable(true); m_keywordCB->setLineEdit(new VLineEdit(this)); m_keywordCB->setToolTip(tr("Keywords to search for")); m_keywordCB->lineEdit()->setPlaceholderText(tr("Supports space, &&, and ||")); m_keywordCB->lineEdit()->setProperty("EmbeddedEdit", true); connect(m_keywordCB, &QComboBox::currentTextChanged, this, &VSearcher::handleInputChanged); connect(m_keywordCB->lineEdit(), &QLineEdit::returnPressed, this, &VSearcher::animateSearchClick); m_keywordCB->completer()->setCaseSensitivity(Qt::CaseSensitive); // Scope. m_searchScopeCB = VUtils::getComboBox(this); m_searchScopeCB->setToolTip(tr("Scope to search")); connect(m_searchScopeCB, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &VSearcher::handleInputChanged); // Object. m_searchObjectCB = VUtils::getComboBox(this); m_searchObjectCB->setToolTip(tr("Object to search")); connect(m_searchObjectCB, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &VSearcher::handleInputChanged); // Target. m_searchTargetCB = VUtils::getComboBox(this); m_searchTargetCB->setToolTip(tr("Target to search")); connect(m_searchTargetCB, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &VSearcher::handleInputChanged); // Pattern. m_filePatternCB = VUtils::getComboBox(this); m_filePatternCB->setEditable(true); m_filePatternCB->setLineEdit(new VLineEdit(this)); m_filePatternCB->setToolTip(tr("Wildcard pattern to filter the files to be searched")); m_filePatternCB->lineEdit()->setProperty("EmbeddedEdit", true); m_filePatternCB->completer()->setCaseSensitivity(Qt::CaseSensitive); // Engine. m_searchEngineCB = VUtils::getComboBox(this); m_searchEngineCB->setToolTip(tr("Engine to execute the search")); // Case sensitive. m_caseSensitiveCB = new QCheckBox(tr("&Case sensitive"), this); // Whole word only. m_wholeWordOnlyCB = new QCheckBox(tr("&Whole word only"), this); // Fuzzy search. m_fuzzyCB = new QCheckBox(tr("&Fuzzy search"), this); m_fuzzyCB->setToolTip(tr("Not available for content search")); connect(m_fuzzyCB, &QCheckBox::stateChanged, this, [this](int p_state) { bool checked = p_state == Qt::Checked; m_wholeWordOnlyCB->setEnabled(!checked); }); // Regular expression. m_regularExpressionCB = new QCheckBox(tr("Re&gular expression"), this); connect(m_regularExpressionCB, &QCheckBox::stateChanged, this, [this](int p_state) { bool checked = p_state == Qt::Checked; m_wholeWordOnlyCB->setEnabled(!checked); m_fuzzyCB->setEnabled(!checked); }); QFormLayout *advLayout = VUtils::getFormLayout(); advLayout->addRow(tr("File pattern:"), m_filePatternCB); advLayout->addRow(tr("Engine:"), m_searchEngineCB); advLayout->addRow(m_caseSensitiveCB); advLayout->addRow(m_wholeWordOnlyCB); advLayout->addRow(m_fuzzyCB); advLayout->addRow(m_regularExpressionCB); advLayout->setContentsMargins(0, 0, 0, 0); m_advWidget = new QWidget(this); m_advWidget->setLayout(advLayout); m_advWidget->hide(); // Progress bar. m_proBar = new QProgressBar(this); m_proBar->setRange(0, 0); // Cancel button. m_cancelBtn = new QPushButton(VIconUtils::buttonIcon(":/resources/icons/close.svg"), "", this); m_cancelBtn->setToolTip(tr("Cancel")); m_cancelBtn->setProperty("FlatBtn", true); connect(m_cancelBtn, &QPushButton::clicked, this, [this]() { if (m_inSearch) { appendLogLine(tr("Cancelling the search...")); m_askedToStop = true; m_search.stop(); } }); QHBoxLayout *proLayout = new QHBoxLayout(); proLayout->addWidget(m_proBar); proLayout->addWidget(m_cancelBtn); proLayout->setContentsMargins(0, 0, 0, 0); // Console. m_consoleEdit = new QPlainTextEdit(this); m_consoleEdit->setReadOnly(true); m_consoleEdit->setLineWrapMode(QPlainTextEdit::WidgetWidth); m_consoleEdit->setProperty("LineEdit", true); m_consoleEdit->setPlaceholderText(tr("Output logs will be shown here")); m_consoleEdit->setMaximumHeight(m_searchScopeCB->height() * 2); m_consoleEdit->hide(); // List. m_results = new VSearchResultTree(this); m_results->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); connect(m_results, &VSearchResultTree::countChanged, this, [this](int p_count) { m_clearBtn->setEnabled(p_count > 0); updateNumLabel(p_count); }); QFormLayout *formLayout = VUtils::getFormLayout(); formLayout->addRow(tr("Keywords:"), m_keywordCB); formLayout->addRow(tr("Scope:"), m_searchScopeCB); formLayout->addRow(tr("Object:"), m_searchObjectCB); formLayout->addRow(tr("Target:"), m_searchTargetCB); formLayout->setContentsMargins(0, 0, 0, 0); QVBoxLayout *mainLayout = new QVBoxLayout(); mainLayout->addLayout(btnLayout); mainLayout->addLayout(formLayout); mainLayout->addWidget(m_advWidget); mainLayout->addLayout(proLayout); mainLayout->addWidget(m_consoleEdit); mainLayout->addWidget(m_results); mainLayout->setContentsMargins(3, 0, 3, 0); setLayout(mainLayout); }