void QPlasmaSumFile::onItemChanged(QTreeWidgetItem* item, int column) { if (s_editLock != 0) return; ++s_editLock; int idx = fFileList->indexOfTopLevelItem(item); switch (column) { case 0: if (fSumData.fEntries[idx].fPath != qstr2st(item->text(0))) { fSumData.fEntries[idx].fPath = qstr2st(item->text(0)); item->setIcon(0, QPlasmaDocument::GetDocIcon(st2qstr(fSumData.fEntries[idx].fPath))); makeDirty(); } break; case 1: { QDateTime ts = QDateTime::fromString(item->text(1), Qt::SystemLocaleShortDate); if (!ts.isValid()) { QMessageBox::critical(this, tr("Error"), tr("Invalid date/time: %1").arg(item->text(1)), QMessageBox::Ok); item->setText(1, QDateTime::fromTime_t(fSumData.fEntries[idx].fTimestamp) .toString(Qt::SystemLocaleShortDate)); break; } fSumData.fEntries[idx].fTimestamp = ts.toTime_t(); makeDirty(); } break; case 2: { QString h = item->text(2); if (h.length() != 32) { QMessageBox::critical(this, tr("Error"), tr("Invalid MD5 hash"), QMessageBox::Ok); item->setText(2, st2qstr(fSumData.fEntries[idx].fHash.toHex())); break; } quint32 newhash[4]; bool ok = true; if (ok) newhash[0] = h.mid(0, 8).toUInt(&ok, 16); if (ok) newhash[1] = h.mid(8, 8).toUInt(&ok, 16); if (ok) newhash[2] = h.mid(16, 8).toUInt(&ok, 16); if (ok) newhash[3] = h.mid(24, 8).toUInt(&ok, 16); if (!ok) { QMessageBox::critical(this, tr("Error"), tr("Invalid MD5 hash"), QMessageBox::Ok); item->setText(2, st2qstr(fSumData.fEntries[idx].fHash.toHex())); break; } memcpy(fSumData.fEntries[idx].fHash.fHash, newhash, 32); makeDirty(); } } --s_editLock; }
void Panel::removeAll() { _controls.clear(); if(_focus) setFocus(nullptr); _layout->removeAll(); makeDirty(true); }
void Panel::add(shared_ptr<Control> c,Layout::pos_type pos) { _controls.push_back(c); c->setParent(this); if(_layout) _layout->add(this,c,pos); makeDirty(true); }
QPlasmaTextDoc::QPlasmaTextDoc(QWidget* parent) : QPlasmaDocument(kDocText, parent), fSyntax(kStxNone), fEncoding(kTypeAnsi), fLexersInited(false) { memset(fDroidKey, 0, sizeof(fDroidKey)); fEditor = new QsciScintilla(this); fEditor->setEolMode(QsciScintilla::EolWindows); // Because it's what Plasma uses fEditor->setUtf8(true); fEditor->SendScintilla(QsciScintillaBase::SCI_SETENDATLASTLINE, 0); fEditor->SendScintilla(QsciScintillaBase::SCI_SETSCROLLWIDTHTRACKING, 1); fEditor->SendScintilla(QsciScintillaBase::SCI_SETSCROLLWIDTH, 1000); QGridLayout* layout = new QGridLayout(this); layout->setContentsMargins(4, 4, 4, 4); layout->addWidget(fEditor, 0, 0); setLayout(layout); // Initialize the editor settings, fonts, etc updateSettings(); connect(fEditor, SIGNAL(linesChanged()), this, SLOT(adjustLineNumbers())); connect(fEditor, SIGNAL(SCN_SAVEPOINTLEFT()), this, SLOT(makeDirty())); connect(fEditor, SIGNAL(SCN_SAVEPOINTREACHED()), this, SLOT(maybeClean())); connect(fEditor, SIGNAL(selectionChanged()), this, SIGNAL(statusChanged())); connect(fEditor, SIGNAL(textChanged()), this, SIGNAL(statusChanged())); }
void CPetControl::addToInventory(CGameObject *item) { item->detach(); if (item->getName() == "CarryParcel") { CCarry *child = dynamic_cast<CCarry *>(getLastChild()); if (child) child->detach(); item->petMoveToHiddenRoom(); if (!child) return; item = child; } item->addUnder(this); _inventory.itemsChanged(); setArea(PET_INVENTORY); if (_currentArea == PET_INVENTORY) _inventory.highlightItem(item); makeDirty(); CPETGainedObjectMsg msg; msg.execute(item); }
void QPlasmaSumFile::onUpdate() { QSettings settings("PlasmaShop", "PlasmaShop"); QString gameRoot = settings.value("DialogDir", "").toString(); QString curGame = settings.value("CurrentGame", QString()).toString(); settings.beginGroup("Games"); if (!curGame.isEmpty()) { QStringList gmParams = settings.value(curGame).toStringList(); if (!gmParams.isEmpty()) gameRoot = gmParams[0]; } QString dir = QFileDialog::getExistingDirectory(this, tr("Select Game directory"), gameRoot); if (!dir.isEmpty()) { std::vector<SumData::Entry>::iterator iter; for (iter = fSumData.fEntries.begin(); iter != fSumData.fEntries.end(); ++iter) { QString path = st2qstr(iter->fPath); path.replace('\\', QDir::separator()).replace('/', QDir::separator()); path = dir + QDir::separator() + QFileInfo(path).fileName(); if (QFileInfo(path).exists()) fSumData.addFrom(path); } loadSumData(NULL); makeDirty(); } }
void Sprite::setColor(const fzColor3B& color) { if(color != m_color) { m_color = color; makeDirty(kFZDirty_color); } }
void Sprite::setTextureRect(const fzRect& rect, const fzSize& untrimmedSize, bool rotated) { m_textureRect = rect; m_rectRotated = rotated; setContentSize(untrimmedSize); updateTextureCoords(rect); // Calculate final offset fzPoint relativeOffset(m_unflippedOffset); if( m_flipX ) relativeOffset.x *= -1; if( m_flipY ) relativeOffset.y *= -1; m_offset = relativeOffset + (m_contentSize - m_textureRect.size)/2; // Generate untransformed vertices fzPoint xy2 = m_offset + m_textureRect.size; m_vertices[0] = m_offset; m_vertices[1] = fzVec2(xy2.x, m_offset.y); m_vertices[2] = fzVec2(m_offset.x, xy2.y); m_vertices[3] = xy2; makeDirty(kFZDirty_transform_absolute); }
void Editable::changeSelection(int pos,int oldPos,uchar dir) { int oldStart = _selStart; int oldEnd = _selEnd; if(_startSel || _selStart == -1) { _selStart = dir == DIR_RIGHT ? oldPos : pos; _selEnd = dir == DIR_LEFT ? oldPos : pos; _startSel = false; _selDir = dir; } else { if(_selDir == DIR_LEFT) { if(pos > _selEnd) { _selStart = _selEnd; _selEnd = pos; _selDir = dir; } else _selStart = pos; } else { if(pos <= _selStart) { _selEnd = _selStart; _selStart = pos; _selDir = dir; } else _selEnd = pos; } } makeDirty(_selStart != oldStart || _selEnd != oldEnd); }
void StarsUI::onMotionblurScaleChanged( int value ) { // get max motionblur scale float maxScale = m_maxMotionBlurScale; float scale = ((float)ui.motionblurScaleMultiplier->value()/(float)ui.motionblurScaleMultiplier->maximum())*maxScale; m_stars->setMotionblurScale(scale); makeDirty(); }
void Panel::remove(shared_ptr<Control> c,Layout::pos_type pos) { _controls.erase_first(c); if(c.get() == _focus) setFocus(nullptr); if(_layout) _layout->remove(this,c,pos); makeDirty(true); }
void CudaTracerUI::onMethodChanged( const QString & text ) { if( text == "pathtracing" ) { m_ct->setRenderMethod( CudaTracer::RENDERMETHOD_PATHTRACING ); } makeDirty(); }
void ComboBox::ItemWindow::onMouseMoved(const MouseEvent &e) { int item = getItemAt(e.getPos()); if(item < (int)_cb->_items.size() && item != _highlighted) { _highlighted = item; makeDirty(true); repaint(); } }
void Editable::removeNext() { if(_selStart != -1) deleteSelection(); else if(_cursor < _str.length()) { _str.erase(_cursor,1); makeDirty(true); } }
void Editable::deleteSelection() { if(_selStart != -1) { _str.erase(_selStart,_selEnd - _selStart); makeDirty(true); moveCursorTo(_selStart); clearSelection(); } }
void StarsUI::onDomeBrightnessScaleChanged( int value ) { // get max motionblur scale float maxScale = m_maxDomeBrightnessScale; float scale = ((float)ui.domeBrightnessScaleSlider->value()/(float)ui.domeBrightnessScaleSlider->maximum())*maxScale; m_stars->setDomeBrightnessScale(scale); makeDirty(); }
void Editable::removeLast() { if(_selStart != -1) deleteSelection(); else if(_cursor > 0) { _str.erase(_cursor - 1,1); makeDirty(true); moveCursor(-1); } }
void ComboBox::ItemWindow::onKeyPressed(const KeyEvent &e) { UIElement::onKeyReleased(e); int oldhl = _highlighted; _highlighted = iterate(e.getKeyCode(),_highlighted,_cb->_items.size()); if(oldhl != _highlighted) { makeDirty(true); repaint(); } }
void Sprite::useSelfRender() { if(m_mode == kFZSprite_SelfRendering) return; makeDirty(kFZDirty_all); m_blendFunc = fzBlendFunc(); m_mode = kFZSprite_SelfRendering; }
void ComboBox::onKeyPressed(const KeyEvent &e) { UIElement::onKeyReleased(e); int oldsel = _selected; doSetIndex(iterate(e.getKeyCode(),_selected,_items.size())); if(oldsel != _selected) { makeDirty(true); repaint(); } }
bool CStarControl::MouseMoveMsg(CMouseMoveMsg *msg) { if (_visible && _starRect.contains(msg->_mousePos)) { _view.MouseMoveMsg(0, Point(msg->_mousePos.x - 20, msg->_mousePos.y - 10)); makeDirty(); return true; } else { return false; } }
void Sprite::updateTextureCoords(fzRect rect) { Texture2D *texture = getTexture(); if(texture == NULL) return; fzFloat wide = texture->getPixelsWide(); fzFloat high = texture->getPixelsHigh(); rect *= texture->getFactor(); #if FZ_FIX_ARTIFACTS_BY_STRECHING_TEXEL wide *= 2; high *= 2; rect.origin.x = rect.origin.x*2+1; rect.origin.y = rect.origin.y*2+1; rect.size.width = rect.size.width*2-2; rect.size.height = rect.size.height*2-2; #endif // ! FZ_FIX_ARTIFACTS_BY_STRECHING_TEXEL fzFloat A = rect.origin.x / wide; fzFloat B = A + rect.size.width / wide; fzFloat C = rect.origin.y / high; fzFloat D = C + rect.size.height / high; if(m_rectRotated) { if( m_flipX ) FZ_SWAP(D, C); if( m_flipY ) FZ_SWAP(A, B); m_texCoords[0] = fzVec2(A, D); m_texCoords[1] = fzVec2(A, C); m_texCoords[2] = fzVec2(B, D); m_texCoords[3] = fzVec2(B, C); } else { if( m_flipX ) FZ_SWAP(A, B); if( m_flipY ) FZ_SWAP(C, D); m_texCoords[0] = fzVec2(A, D); m_texCoords[1] = fzVec2(B, D); m_texCoords[2] = fzVec2(A, C); m_texCoords[3] = fzVec2(B, C); } makeDirty(kFZDirty_texcoords); }
bool CEndCreditText::FrameMsg(CFrameMsg *msg) { if (_flag) { if (_credits) { makeDirty(); } else { addTimer(5000); _flag = false; } } return true; }
bool CStarControl::FrameMsg(CFrameMsg *msg) { if (_visible) { Point pt = getMousePos(); if (_starRect.contains(pt)) _view.MouseMoveMsg(0, pt); newFrame(); makeDirty(); return true; } else { return false; } }
void CPetControl::onSummonBot(const CString &name, int val) { CGameObject *bot = findBot(name, getHiddenRoom()); if (!bot) { bot = findBot(name, getRoot()); } if (bot) { removeFromInventory(bot, false, false); COnSummonBotMsg summonMsg(val); summonMsg.execute(bot); makeDirty(); } }
bool CPetControl::MouseButtonUpMsg(CMouseButtonUpMsg *msg) { if (!containsPt(msg->_mousePos) || isInputLocked()) return false; bool result = false; if (isAreaActive()) result = _frame.MouseButtonUpMsg(msg); if (!result) result = _sections[_currentArea]->MouseButtonUpMsg(msg); makeDirty(); return result; }
void Sprite::useBatchRender(SpriteBatch* batch) { FZ_ASSERT(batch != NULL, "Batch node cannot be NULL."); if(m_mode == kFZSprite_BatchRendering) return; if(m_mode == kFZSprite_SelfRendering) setTexture(NULL); makeDirty(kFZDirty_all); mode.B.p_currentQuad = NULL; mode.B.p_batchNode = batch; m_mode = kFZSprite_BatchRendering; updateTextureCoords(m_textureRect); }
PetArea CPetControl::setArea(PetArea newArea, bool forceChange) { if ((!forceChange && newArea == _currentArea) || !isAreaActive()) return _currentArea; // Signal the currently active area that it's being left _sections[_currentArea]->leave(); // Change the current area PetArea oldArea = _currentArea; _frame.setArea(newArea); _currentArea = newArea; // Signal to the new view that it's been activated _sections[_currentArea]->enter(oldArea); makeDirty(); return newArea; }
void QPlasmaPakFile::onAdd() { QSettings settings("PlasmaShop", "PlasmaShop"); QString gameRoot = settings.value("DialogDir", "").toString(); QString curGame = settings.value("CurrentGame", QString()).toString(); settings.beginGroup("Games"); if (!curGame.isEmpty()) { QStringList gmParams = settings.value(curGame).toStringList(); if (!gmParams.isEmpty()) gameRoot = gmParams[0]; } QStringList files = QFileDialog::getOpenFileNames(this, tr("Add / update files"), gameRoot, fPackage.getFilter()); foreach (QString f, files) fPackage.addFrom(f); if (files.size() != 0) { loadPakData(NULL); makeDirty(); } }
bool CEndCredits::FrameMsg(CFrameMsg *msg) { if (_flag) makeDirty(); return true; }