Пример #1
0
void
MainWindow::handleOpenFile()
{
    auto name = QFileDialog::getOpenFileName( this
                                              , tr( "Open QtPlatz publisher xml" )
                                              , recentFile( "RecentFiles", "Files" )
                                              , tr( "QtPlatz publisher xml(*.xml);;HTML(*.html)" ) );
    if ( !name.isEmpty() ) {
        boost::filesystem::path path( name.toStdWString() );
        if ( path.extension() == ".xml" ) {

            addRecentFiles( "RecentFiles", "Files", name );

            auto doc = std::make_shared< adpublisher::document>();

            if ( doc->load_file( name.toStdString().c_str() ) ) {

                setWindowTitle( name );
                xmlpath_ = name.toStdString();

                ui->actionApply->setEnabled( true );
                processed_.clear();

                docEditor_->setDocument( doc );
            }
        }
        else if ( path.extension() == ".html" ) {
            docEditor_->setOutput( QUrl( QString( "file:///%1" ).arg( path.string().c_str() ) ) );
        }
    }
}
Пример #2
0
void OneToOneRoom::sendFile()
{
	auto filePath = QFileDialog::getOpenFileName(this,
		tr("Open file to send "), "", tr("any files (*.*)"));
	QFileInfo f(filePath);
	if (!f.exists())
		return;
	auto timestamp = time(NULL);
	fileRequestWidget->show();
	fileRequestWidget->addSendRequest(filePath, timestamp);
	stackedWidget->setCurrentWidget(fileRequestWidget);

	auto size = f.size();
	avc::RequestFilesInfo fi;
	fi.fileName = filePath.toStdWString();
	fi.fileSize = size;
	client_->sendFileTransferRequest(remote_, fi, timestamp);
}
Пример #3
0
std::wstring Utils::textEditToMessageText(QTextEdit* textEdit)
{
	std::wstring result;
	QTextCursor c(textEdit->document());
	auto text = textEdit->toPlainText();
	size_t textStart = 0;
	int pos;
	QChar ch(65532);
	while ((pos = text.indexOf(ch, textStart)) != -1) {
		result += text.mid(textStart, pos - textStart).toStdWString();
		c.setPosition(pos + 1);
		auto imageFormat = c.charFormat().toImageFormat();
		if (imageFormat.isValid()) {
			auto fileName = imageFormat.name();
			result += L"<img path=\"" + fileName.toStdWString() + L"\"/>";
		}
		textStart = pos + 1;
	}
	result += text.mid(textStart).toStdWString();
	return result;
}
Пример #4
0
bool Launcher::launch(
		const QString &operation,
		const QString &binaryPath,
		const QStringList &argumentsList) {
	const auto convertPath = [](const QString &path) {
		return QDir::toNativeSeparators(path).toStdWString();
	};
	const auto nativeBinaryPath = convertPath(binaryPath);
	const auto nativeWorkingDir = convertPath(cWorkingDir());
	const auto arguments = argumentsList.join(' ');

	DEBUG_LOG(("Application Info: executing %1 %2"
		).arg(binaryPath
		).arg(arguments
		));

	Logs::closeMain();
	CrashReports::Finish();

	const auto hwnd = HWND(0);
	const auto result = ShellExecute(
		hwnd,
		operation.isEmpty() ? nullptr : operation.toStdWString().c_str(),
		nativeBinaryPath.c_str(),
		arguments.toStdWString().c_str(),
		nativeWorkingDir.empty() ? nullptr : nativeWorkingDir.c_str(),
		SW_SHOWNORMAL);
	if (long(result) < 32) {
		DEBUG_LOG(("Application Error: failed to execute %1, working directory: '%2', result: %3"
			).arg(binaryPath
			).arg(cWorkingDir()
			).arg(long(result)
			));
		return false;
	}
	return true;
}