Esempio n. 1
0
QString ScanGallery::getCurrImageFileName(bool withPath) const
{
   QString result = "";

   FileTreeViewItem *curr = highlightedFileTreeViewItem();
   if( ! curr )
   {
      kDebug() << "nothing selected!";
   }
   else
   {
      if( withPath )
      {
	 result = localFileName(curr);
      }
      else
      {
          // TODO: the next 2 lines don't make sense
	 KUrl url( localFileName(curr));
	 url = curr->url();
	 result = url.fileName();
      }
   }
   return( result );
}
Esempio n. 2
0
void GaduFileTransfer::send()
{
	if (FileTransfer::TypeSend != transferType()) // maybe assert here?
		return;

	if (SocketNotifiers || WaitingForSocketNotifiers) // already sending/receiving
		return;

	setRemoteFile(QString::null);

	if (!account() || localFileName().isEmpty())
	{
		changeFileTransferStatus(FileTransfer::StatusNotConnected);
		return; // TODO: notify
	}

	GaduProtocol *gaduProtocol = dynamic_cast<GaduProtocol *>(account()->protocol());
	if (!gaduProtocol)
	{
		changeFileTransferStatus(FileTransfer::StatusNotConnected);
		return;
	}

	GaduContactAccountData *gcad = gaduProtocol->gaduContactAccountData(contact());
	if (!gcad)
	{
		changeFileTransferStatus(FileTransfer::StatusNotConnected);
		return;
	}

	// async call, will return in setFileTransferNotifiers
	changeFileTransferStatus(FileTransfer::StatusWaitingForConnection);
	WaitingForSocketNotifiers = true;
	gaduProtocol->dccManager()->attachSendFileTransferSocket(this);
}
void RemoteDirectoryListBox::itemDropped (const SourceDetails& dragSourceDetails)
{
	LocalDirectoryListBox *local = dynamic_cast<LocalDirectoryListBox*> (dragSourceDetails.sourceComponent.get());
	
	if (local != nullptr)
	{
		DBG(dragSourceDetails.description.toString());
		{
			String localFileName(File(dragSourceDetails.description.toString()).getFileName());
			
			session.setRemotePath(session.getRemotePath().upToLastOccurrenceOf("/", true, false)+localFileName);
			session.setLocalFile (File (dragSourceDetails.description.toString()));
		}
		session.beginTransfer(true);
	}

    isInterestedInDrag = false;
    repaint();
}
void ContextPaneWidgetImage::setPixmap(const QString &fileName)
{
    QPixmap pix(76,76);
    pix.fill(Qt::black);

    if (m_borderImage) {
        QString localFileName(fileName);
        if (QFile(fileName).exists()) {
            if (fileName.endsWith(QLatin1String("sci"))) {
                QString pixmapFileName;
                int left = 0;
                int right = 0;
                int top = 0;
                int bottom = 0;

                Qt::TileRule horizontalTileRule;
                Qt::TileRule verticalTileRule;
                if (parseSciFile(fileName, pixmapFileName, left, right, top, bottom, horizontalTileRule, verticalTileRule)) {
                    localFileName = QFileInfo(fileName).absoluteDir().absolutePath() + '/' + pixmapFileName;
                    previewDialog()->previewLabel()->setMargins(left, top, right, bottom);
                } else { // sci file not parsed correctly
                    uiBorderImage->sizeLabel->setText("");
                    return;
                }
            }
            QPixmap source(localFileName);
            if (source.isNull())
                source = pix;
            previewDialog()->setPixmap(source, previewDialog()->zoom());
            uiBorderImage->sizeLabel->setText(QString::number(source.width()) + 'x' + QString::number(source.height()));
            QPainter p(&pix);
            Qt::TileRule horizontalTileMode = Qt::StretchTile;
            Qt::TileRule verticalTileMode = Qt::StretchTile;
            if (uiBorderImage->horizontalTileRadioButton->isChecked())
                horizontalTileMode =Qt::RepeatTile;
            if (uiBorderImage->horizontalTileRadioButtonNoCrop->isChecked())
                horizontalTileMode =Qt::RoundTile;
            if (uiBorderImage->verticalTileRadioButton->isChecked())
                verticalTileMode =Qt::RepeatTile;
            if (uiBorderImage->verticalTileRadioButtonNoCrop->isChecked())
                verticalTileMode =Qt::RoundTile;
            QTileRules rules(horizontalTileMode, verticalTileMode);
            QMargins margins(previewDialog()->previewLabel()->leftMarging() ,previewDialog()->previewLabel()->topMarging() ,previewDialog()->previewLabel()->rightMarging(), previewDialog()->previewLabel()->bottomMarging());
            qDrawBorderPixmap(&p, QRect(0, 0, 76, 76), margins, source, source.rect(), margins, rules);
            //p.drawPixmap(0,0,76,76, source);
        } else {
            uiBorderImage->sizeLabel->setText("");
        }
        uiBorderImage->label->setPixmap(pix);
    } else {
        if (QFile(fileName).exists()) {
            QPixmap source(fileName);
            previewDialog()->setPixmap(source, 1);
            ui->sizeLabel->setText(QString::number(source.width()) + 'x' + QString::number(source.height()));
            QPainter p(&pix);
            if (ui->stretchRadioButton->isChecked()) {
                p.drawPixmap(0,0,76,76, source);
            } else if (ui->tileRadioButton->isChecked()) {
                QPixmap small = source.scaled(38,38);
                p.drawTiledPixmap(0,0,76,76, small);
            } else if (ui->horizontalStretchRadioButton->isChecked()) {
                QPixmap small = source.scaled(38,38);
                QPixmap half = pix.scaled(38, 76);
                QPainter p2(&half);
                p2.drawTiledPixmap(0,0,38,76, small);
                p.drawPixmap(0,0,76,76, half);
            } else if (ui->verticalStretchRadioButton->isChecked()) {
                QPixmap small = source.scaled(38,38);
                QPixmap half = pix.scaled(76, 38);
                QPainter p2(&half);
                p2.drawTiledPixmap(0,0,76,38, small);
                p.drawPixmap(0,0,76,76, half);
            } else if (ui->preserveAspectFitRadioButton->isChecked()) {
                QPixmap preserved = source.scaledToWidth(76);
                int offset = (76 - preserved.height()) / 2;
                p.drawPixmap(0, offset, 76, preserved.height(), source);
            } else if (ui->cropAspectFitRadioButton->isChecked()) {
                QPixmap cropped = source.scaledToHeight(76);
                int offset = (76 - cropped.width()) / 2;
                p.drawPixmap(offset, 0, cropped.width(), 76, source);
            }
        } else {
            ui->sizeLabel->setText("");
        }

        ui->label->setPixmap(pix);

    }
}