Exemple #1
0
void DkImageContainerT::loadingFinished() {

	DkTimer dt;

	if (getLoadState() == loading_canceled) {
		mLoadState = not_loaded;
		clear();
		return;
	}

	if (!getLoader()->hasImage()) {
		mFileUpdateTimer.stop();
		mEdited = false;
		QString msg = tr("Sorry, I could not load: %1").arg(fileName());
		emit showInfoSignal(msg);
		emit fileLoadedSignal(false);
		mLoadState = exists_not;
		return;
	}
	else if (!getThumb()->hasImage()) {
		getThumb()->setImage(getLoader()->image());
	}

	// clear file buffer if it exceeds a certain size?! e.g. psd files
	if (mFileBuffer && mFileBuffer->size()/(1024.0f*1024.0f) > DkSettings::resources.cacheMemory*0.5f)
		mFileBuffer->clear();
	
	mLoadState = loaded;
	emit fileLoadedSignal(true);
}
//----------------------------------------------------------------------------//
void Scrollbar::initialiseComponents(void)
{
    // Set up thumb
    Thumb* const t = getThumb();
    t->subscribeEvent(Thumb::EventThumbPositionChanged,
                      Event::Subscriber(&CEGUI::Scrollbar::handleThumbMoved,
                      this));

    t->subscribeEvent(Thumb::EventThumbTrackStarted,
                      Event::Subscriber(&CEGUI::Scrollbar::handleThumbTrackStarted,
                      this));

    t->subscribeEvent(Thumb::EventThumbTrackEnded,
                      Event::Subscriber(&CEGUI::Scrollbar::handleThumbTrackEnded,
                      this));

    // set up Increase button
    getIncreaseButton()->
        subscribeEvent(PushButton::EventMouseButtonDown,
                       Event::Subscriber(&CEGUI::Scrollbar::handleIncreaseClicked,
                       this));

    // set up Decrease button
    getDecreaseButton()->
        subscribeEvent(PushButton::EventMouseButtonDown,
                       Event::Subscriber(&CEGUI::Scrollbar::handleDecreaseClicked,
                       this));

    // do initial layout
    performChildWindowLayout();
}
Exemple #3
0
String Card::getAll() {
	String all = getQuantity()+","+getText()+","+getThumb()+","+getFront()+
			","+getBack()+","+getId()+","+getRate()+","+getValue()+","+getNote()+","+getOrientation()+",";
	for (int i = 0; i < stats.size(); i++) {
		all += stats[i]->getAll() + "$";
	}
	return all;
}
Exemple #4
0
/*************************************************************************
	Initialises the Window based object ready for use.
*************************************************************************/
void Slider::initialiseComponents(void)
{
	// get thumb
	Thumb* thumb = getThumb();

	// bind handler to thumb events
	thumb->subscribeEvent(Thumb::EventThumbPositionChanged, Event::Subscriber(&CEGUI::Slider::handleThumbMoved, this));
	thumb->subscribeEvent(Thumb::EventThumbTrackStarted, Event::Subscriber(&CEGUI::Slider::handleThumbTrackStarted, this));
	thumb->subscribeEvent(Thumb::EventThumbTrackEnded, Event::Subscriber(&CEGUI::Slider::handleThumbTrackEnded, this));

	performChildWindowLayout();
}
Exemple #5
0
void DkImageContainerT::checkForFileUpdates() {

#ifdef WITH_QUAZIP
	if(isFromZip()) 
		setFilePath(getZipData()->getZipFilePath());
#endif

	QDateTime modifiedBefore = fileInfo().lastModified();
	mFileInfo.refresh();
	
	bool changed = false;

	// if image exists_not don't do this
	if (!mFileInfo.exists() && mLoadState == loaded) {
		changed = true;
	}

	if (mFileInfo.lastModified() != modifiedBefore)
		mWaitForUpdate = true;

#ifdef WITH_QUAZIP
	if(isFromZip()) 
		setFilePath(getZipData()->getImageFileName());
#endif

	if (changed) {
		mFileUpdateTimer.stop();
		if (DkSettings::global.askToSaveDeletedFiles) {
			mEdited = changed;
			emit fileLoadedSignal(true);
		}
		return;
	}

	// we use our own file watcher, since the qt watcher
	// uses locks to check for updates. this might
	// be more accurate. however, the locks are pretty nasty
	// if the user e.g. wants to delete the file while watching
	// it in nomacs
	if (mWaitForUpdate && mFileInfo.isReadable()) {
		mWaitForUpdate = false;
		getThumb()->setImage(QImage());
		loadImageThreaded(true);
	}

}
Exemple #6
0
bool DkImageContainerT::loadImageThreaded(bool force) {

#ifdef WITH_QUAZIP
	//zip archives: get zip file fileInfo for checks
	if(isFromZip()) 
		setFilePath(getZipData()->getZipFilePath());
#endif
	
	// check file for updates
	QFileInfo fileInfo = filePath();
	QDateTime modifiedBefore = fileInfo.lastModified();
	fileInfo.refresh();

	if (force || fileInfo.lastModified() != modifiedBefore || getLoader()->isDirty()) {
		qDebug() << "updating image...";
		getThumb()->setImage(QImage());
		clear();
	}

	// null file?
	if (fileInfo.fileName().isEmpty() || !fileInfo.exists()) {

		QString msg = tr("Sorry, the file: %1 does not exist... ").arg(fileName());
		emit showInfoSignal(msg);
		mLoadState = exists_not;
		return false;
	}
	else if (!fileInfo.permission(QFile::ReadUser)) {

		QString msg = tr("Sorry, you are not allowed to read: %1").arg(fileName());
		emit showInfoSignal(msg);
		mLoadState = exists_not;
		return false;
	}

#ifdef WITH_QUAZIP
	//zip archives: use the image file info from now on
	if(isFromZip()) 
		setFilePath(getZipData()->getImageFileName());
#endif
	
	mLoadState = loading;
	fetchFile();
	return true;
}
Exemple #7
0
String Card::getAll() {
	String all = getQuantity()+delim+getText()+delim+getThumb()+delim+getFront()+
			delim+getBack()+delim+getId()+delim+getRate()+delim+getValue()+delim+getNote()+delim;
	return all;
}