Beispiel #1
0
ProcessingDialog::ProcessingDialog(FileListModel *fileListModel, AudioFileModel *metaInfo, SettingsModel *settings, QWidget *parent)
:
	QDialog(parent),
	ui(new Ui::ProcessingDialog),
	//m_aacEncoder(SettingsModel::getAacEncoder()),
	m_systemTray(new QSystemTrayIcon(QIcon(":/icons/cd_go.png"), this)),
	m_settings(settings),
	m_metaInfo(metaInfo),
	m_shutdownFlag(shutdownFlag_None),
	m_diskObserver(NULL),
	m_cpuObserver(NULL),
	m_ramObserver(NULL),
	m_progressViewFilter(-1),
	m_firstShow(true)
{
	//Init the dialog, from the .ui file
	ui->setupUi(this);
	setWindowFlags(windowFlags() ^ Qt::WindowContextHelpButtonHint);
	
	//Update header icon
	ui->label_headerIcon->setPixmap(lamexp_app_icon().pixmap(ui->label_headerIcon->size()));
	
	//Setup version info
	ui->label_versionInfo->setText(QString().sprintf("v%d.%02d %s (Build %d)", lamexp_version_major(), lamexp_version_minor(), lamexp_version_release(), lamexp_version_build()));
	ui->label_versionInfo->installEventFilter(this);

	//Register meta type
	qRegisterMetaType<QUuid>("QUuid");

	//Center window in screen
	QRect desktopRect = QApplication::desktop()->screenGeometry();
	QRect thisRect = this->geometry();
	move((desktopRect.width() - thisRect.width()) / 2, (desktopRect.height() - thisRect.height()) / 2);
	setMinimumSize(thisRect.width(), thisRect.height());

	//Enable buttons
	connect(ui->button_AbortProcess, SIGNAL(clicked()), this, SLOT(abortEncoding()));
	
	//Init progress indicator
	m_progressIndicator = new QMovie(":/images/Working.gif");
	m_progressIndicator->setCacheMode(QMovie::CacheAll);
	m_progressIndicator->setSpeed(50);
	ui->label_headerWorking->setMovie(m_progressIndicator);
	ui->progressBar->setValue(0);

	//Init progress model
	m_progressModel = new ProgressModel();
	ui->view_log->setModel(m_progressModel);
	ui->view_log->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
	ui->view_log->verticalHeader()->hide();
	ui->view_log->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
	ui->view_log->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
	ui->view_log->viewport()->installEventFilter(this);
	connect(m_progressModel, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(progressModelChanged()));
	connect(m_progressModel, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)), this, SLOT(progressModelChanged()));
	connect(m_progressModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(progressModelChanged()));
	connect(m_progressModel, SIGNAL(modelReset()), this, SLOT(progressModelChanged()));
	connect(ui->view_log, SIGNAL(activated(QModelIndex)), this, SLOT(logViewDoubleClicked(QModelIndex)));
	connect(ui->view_log->horizontalHeader(), SIGNAL(sectionResized(int,int,int)), this, SLOT(logViewSectionSizeChanged(int,int,int)));

	//Create context menu
	m_contextMenu = new QMenu();
	QAction *contextMenuDetailsAction = m_contextMenu->addAction(QIcon(":/icons/zoom.png"), tr("Show details for selected job"));
	QAction *contextMenuShowFileAction = m_contextMenu->addAction(QIcon(":/icons/folder_go.png"), tr("Browse Output File Location"));
	m_contextMenu->addSeparator();

	//Create "filter" context menu
	m_progressViewFilterGroup = new QActionGroup(this);
	QAction *contextMenuFilterAction[5] = {NULL, NULL, NULL, NULL, NULL};
	if(QMenu *filterMenu = m_contextMenu->addMenu(QIcon(":/icons/filter.png"), tr("Filter Log Items")))
	{
		contextMenuFilterAction[0] = filterMenu->addAction(m_progressModel->getIcon(ProgressModel::JobRunning), tr("Show Running Only"));
		contextMenuFilterAction[1] = filterMenu->addAction(m_progressModel->getIcon(ProgressModel::JobComplete), tr("Show Succeeded Only"));
		contextMenuFilterAction[2] = filterMenu->addAction(m_progressModel->getIcon(ProgressModel::JobFailed), tr("Show Failed Only"));
		contextMenuFilterAction[3] = filterMenu->addAction(m_progressModel->getIcon(ProgressModel::JobSkipped), tr("Show Skipped Only"));
		contextMenuFilterAction[4] = filterMenu->addAction(m_progressModel->getIcon(ProgressModel::JobState(-1)), tr("Show All Items"));
		if(QAction *act = contextMenuFilterAction[0]) { m_progressViewFilterGroup->addAction(act); act->setCheckable(true); act->setData(ProgressModel::JobRunning); }
		if(QAction *act = contextMenuFilterAction[1]) { m_progressViewFilterGroup->addAction(act); act->setCheckable(true); act->setData(ProgressModel::JobComplete); }
		if(QAction *act = contextMenuFilterAction[2]) { m_progressViewFilterGroup->addAction(act); act->setCheckable(true); act->setData(ProgressModel::JobFailed); }
		if(QAction *act = contextMenuFilterAction[3]) { m_progressViewFilterGroup->addAction(act); act->setCheckable(true); act->setData(ProgressModel::JobSkipped); }
		if(QAction *act = contextMenuFilterAction[4]) { m_progressViewFilterGroup->addAction(act); act->setCheckable(true); act->setData(-1); act->setChecked(true); }
	}

	//Create info label
	if(m_filterInfoLabel = new QLabel(ui->view_log))
	{
		m_filterInfoLabel->setFrameShape(QFrame::NoFrame);
		m_filterInfoLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
		m_filterInfoLabel->setUserData(0, new IntUserData(-1));
		SET_FONT_BOLD(m_filterInfoLabel, true);
		SET_TEXT_COLOR(m_filterInfoLabel, Qt::darkGray);
		m_filterInfoLabel->setContextMenuPolicy(Qt::CustomContextMenu);
		connect(m_filterInfoLabel, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuTriggered(QPoint)));
		m_filterInfoLabel->hide();
	}
	if(m_filterInfoLabelIcon = new QLabel(ui->view_log))
	{
		m_filterInfoLabelIcon->setFrameShape(QFrame::NoFrame);
		m_filterInfoLabelIcon->setAlignment(Qt::AlignHCenter | Qt::AlignTop);
		m_filterInfoLabelIcon->setContextMenuPolicy(Qt::CustomContextMenu);
		const QIcon &ico = m_progressModel->getIcon(ProgressModel::JobState(-1));
		m_filterInfoLabelIcon->setPixmap(ico.pixmap(16, 16));
		connect(m_filterInfoLabelIcon, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuTriggered(QPoint)));
		m_filterInfoLabelIcon->hide();
	}

	//Connect context menu
	ui->view_log->setContextMenuPolicy(Qt::CustomContextMenu);
	connect(ui->view_log, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuTriggered(QPoint)));
	connect(contextMenuDetailsAction, SIGNAL(triggered(bool)), this, SLOT(contextMenuDetailsActionTriggered()));
	connect(contextMenuShowFileAction, SIGNAL(triggered(bool)), this, SLOT(contextMenuShowFileActionTriggered()));
	for(size_t i = 0; i < 5; i++)
	{
		if(contextMenuFilterAction[i]) connect(contextMenuFilterAction[i], SIGNAL(triggered(bool)), this, SLOT(contextMenuFilterActionTriggered()));
	}
	SET_FONT_BOLD(contextMenuDetailsAction, true);

	//Enque jobs
	if(fileListModel)
	{
		for(int i = 0; i < fileListModel->rowCount(); i++)
		{
			m_pendingJobs.append(fileListModel->getFile(fileListModel->index(i,0)));
		}
	}

	//Translate
	ui->label_headerStatus->setText(QString("<b>%1</b><br>%2").arg(tr("Encoding Files"), tr("Your files are being encoded, please be patient...")));
	
	//Enable system tray icon
	connect(m_systemTray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(systemTrayActivated(QSystemTrayIcon::ActivationReason)));

	//Init other vars
	m_runningThreads = 0;
	m_currentFile = 0;
	m_allJobs.clear();
	m_succeededJobs.clear();
	m_failedJobs.clear();
	m_skippedJobs.clear();
	m_userAborted = false;
	m_forcedAbort = false;
	m_timerStart = 0I64;
}
Beispiel #2
0
void ProcessThread::processFile()
{
	m_aborted = false;
	bool bSuccess = true;
		
	qDebug("Process thread %s has started.", m_jobId.toString().toLatin1().constData());
	emit processStateInitialized(m_jobId, QFileInfo(m_audioFile.filePath()).fileName(), tr("Starting..."), ProgressModel::JobRunning);
	handleMessage(QString().sprintf("LameXP v%u.%02u (Build #%u), compiled on %s at %s", lamexp_version_major(), lamexp_version_minor(), lamexp_version_build(), lamexp_version_date().toString(Qt::ISODate).toLatin1().constData(), lamexp_version_time()));
	handleMessage("\n-------------------------------\n");

	//Generate output file name
	QString outFileName = generateOutFileName();
	if(outFileName.isEmpty())
	{
		emit processStateChanged(m_jobId, tr("Not found!"), ProgressModel::JobFailed);
		emit processStateFinished(m_jobId, outFileName, false);
		return;
	}

	//Do we need to take care of downsampling the input?
	if(m_encoder->requiresDownsample())
	{
		insertDownsampleFilter();
	}

	//Do we need Stereo downmix?
	if(m_encoder->requiresDownmix())
	{
		insertDownmixFilter();
	}

	QString sourceFile = m_audioFile.filePath();

	//Decode source file
	if(!m_filters.isEmpty() || !m_encoder->isFormatSupported(m_audioFile.formatContainerType(), m_audioFile.formatContainerProfile(), m_audioFile.formatAudioType(), m_audioFile.formatAudioProfile(), m_audioFile.formatAudioVersion()))
	{
		m_currentStep = DecodingStep;
		AbstractDecoder *decoder = DecoderRegistry::lookup(m_audioFile.formatContainerType(), m_audioFile.formatContainerProfile(), m_audioFile.formatAudioType(), m_audioFile.formatAudioProfile(), m_audioFile.formatAudioVersion());
		
		if(decoder)
		{
			QString tempFile = generateTempFileName();

			connect(decoder, SIGNAL(statusUpdated(int)), this, SLOT(handleUpdate(int)), Qt::DirectConnection);
			connect(decoder, SIGNAL(messageLogged(QString)), this, SLOT(handleMessage(QString)), Qt::DirectConnection);

			bSuccess = decoder->decode(sourceFile, tempFile, &m_aborted);
			LAMEXP_DELETE(decoder);

			if(bSuccess)
			{
				sourceFile = tempFile;
				handleMessage("\n-------------------------------\n");
			}
		}
		else
		{
void UpdateDialog::showEvent(QShowEvent *event)
{
    QDialog::showEvent(event);

    if(m_firstShow)
    {
        if(!m_thread)
        {
            m_thread = new UpdateCheckThread(m_binaryWGet, m_binaryGnuPG, m_binaryKeys, m_betaUpdates);
            connect(m_thread, SIGNAL(statusChanged(int)), this, SLOT(threadStatusChanged(int)));
            connect(m_thread, SIGNAL(progressChanged(int)), this, SLOT(threadProgressChanged(int)));
            connect(m_thread, SIGNAL(messageLogged(QString)), this, SLOT(threadMessageLogged(QString)));
            connect(m_thread, SIGNAL(finished()), this, SLOT(threadFinished()));
            connect(m_thread, SIGNAL(terminated()), this, SLOT(threadFinished()));
        }

        threadStatusChanged(m_thread->getUpdateStatus());
        ui->labelVersionInstalled->setText(QString("%1 %2 (%3)").arg(tr("Build"), QString::number(lamexp_version_build()), lamexp_version_date().toString(Qt::ISODate)));
        ui->labelVersionLatest->setText(QString("(%1)").arg(tr("Unknown")));

        ui->installButton->setEnabled(false);
        ui->closeButton->setEnabled(false);
        ui->retryButton->setEnabled(false);
        ui->logButton->setEnabled(false);
        ui->retryButton->hide();
        ui->logButton->hide();
        ui->infoLabel->hide();
        ui->hintLabel->hide();
        ui->hintIcon->hide();
        ui->frameAnimation->hide();

        ui->progressBar->setMaximum(m_thread->getMaximumProgress());
        ui->progressBar->setValue(0);

        m_updaterProcess = NULL;

        QTimer::singleShot(0, this, SLOT(updateInit()));
        m_firstShow = false;
    }
Beispiel #4
0
static void lamexp_print_logo(void)
{
	//Print version info
	qDebug("LameXP - Audio Encoder Front-End v%d.%02d %s (Build #%03d)", lamexp_version_major(), lamexp_version_minor(), lamexp_version_release(), lamexp_version_build());
	qDebug("Copyright (c) 2004-%04d LoRd_MuldeR <*****@*****.**>. Some rights reserved.", qMax(MUtils::Version::app_build_date().year(), MUtils::OS::current_date().year()));
	qDebug("Built on %s at %s with %s for Win-%s.\n", MUTILS_UTF8(MUtils::Version::app_build_date().toString(Qt::ISODate)), MUTILS_UTF8(MUtils::Version::app_build_time().toString(Qt::ISODate)), MUtils::Version::compiler_version(), MUtils::Version::compiler_arch());
	
	//print license info
	qDebug("This program is free software: you can redistribute it and/or modify");
	qDebug("it under the terms of the GNU General Public License <http://www.gnu.org/>.");
	qDebug("Note that this program is distributed with ABSOLUTELY NO WARRANTY.\n");

	//Print library version
	qDebug("This application is powerd by MUtils library v%u.%02u (%s, %s).\n", MUtils::Version::lib_version_major(), MUtils::Version::lib_version_minor(), MUTILS_UTF8(MUtils::Version::lib_build_date().toString(Qt::ISODate)), MUTILS_UTF8(MUtils::Version::lib_build_time().toString(Qt::ISODate)));
	
	//Print warning, if this is a "debug" build
	if(MUTILS_DEBUG)
	{
		qWarning("---------------------------------------------------------");
		qWarning("DEBUG BUILD: DO NOT RELEASE THIS BINARY TO THE PUBLIC !!!");
		qWarning("---------------------------------------------------------\n");
	}
}
	void taskMain(void)
	{
		LockedFile *lockedFile = NULL;
		unsigned int version = m_toolVersion;

		QFileInfo toolFileInfo(m_toolName);
		const QString toolShortName = QString("%1.%2").arg(toolFileInfo.baseName().toLower(), toolFileInfo.suffix().toLower());

		QFileInfo customTool(QString("%1/tools/%2/%3").arg(m_appDir.canonicalPath(), QString::number(lamexp_version_build()), toolShortName));
		if(customTool.exists() && customTool.isFile())
		{
			qDebug("Setting up file: %s <- %s", toolShortName.toLatin1().constData(), m_appDir.relativeFilePath(customTool.canonicalFilePath()).toLatin1().constData());
			lockedFile = new LockedFile(customTool.canonicalFilePath()); version = UINT_MAX; s_bCustom = true;
		}
		else
		{
			qDebug("Extracting file: %s -> %s", m_toolName.toLatin1().constData(), toolShortName.toLatin1().constData());
			lockedFile = new LockedFile(m_toolResource.data(), QString("%1/lxp_%2").arg(MUtils::temp_folder(), toolShortName), m_toolHash);
		}

		if(lockedFile)
		{
			lamexp_tools_register(toolShortName, lockedFile, version, m_toolTag);
		}
	}
Beispiel #6
0
AboutDialog::AboutDialog(SettingsModel *settings, QWidget *parent, bool firstStart)
    :
    QMessageBox(parent),
    m_settings(settings),
    m_disque(NULL),
    m_disqueTimer(NULL),
    m_rotateNext(false),
    m_disqueDelay(_I64_MAX)
{
    const QString versionStr = QString().sprintf
                               (
                                   "Version %d.%02d %s, Build %d [%s], %s %s, Qt v%s",
                                   lamexp_version_major(),
                                   lamexp_version_minor(),
                                   lamexp_version_release(),
                                   lamexp_version_build(),
                                   lamexp_version_date().toString(Qt::ISODate).toLatin1().constData(),
                                   lamexp_version_compiler(),
                                   lamexp_version_arch(),
                                   qVersion()
                               );
    const QString copyrightStr = QString().sprintf
                                 (
                                     "Copyright (C) 2004-%04d LoRd_MuldeR &lt;[email protected]&gt;. Some rights reserved.",
                                     qMax(lamexp_version_date().year(), QDate::currentDate().year())
                                 );

    for(int i = 0; i < 4; i++)
    {
        m_cartoon[i] = NULL;
    }

    QString aboutText;

    aboutText += QString("<h2>%1</h2>").arg(NOBR(tr("LameXP - Audio Encoder Front-end")));
    aboutText += QString("<b>%1</b><br>").arg(NOBR(copyrightStr));
    aboutText += QString("<b>%1</b><br><br>").arg(NOBR(versionStr));
    aboutText += QString("%1<br>").arg(NOBR(tr("Please visit %1 for news and updates!").arg(LINK(lamexp_website_url()))));

    if(LAMEXP_DEBUG)
    {
        int daysLeft = qMax(QDate::currentDate().daysTo(lamexp_version_expires()), 0);
        aboutText += QString("<hr><font color=\"crimson\">%1</font>").arg(NOBR(QString("!!! --- DEBUG BUILD --- Expires at: %1 &middot; Days left: %2 --- DEBUG BUILD --- !!!").arg(lamexp_version_expires().toString(Qt::ISODate), QString::number(daysLeft))));
    }
    else if(lamexp_version_demo())
    {
        int daysLeft = qMax(QDate::currentDate().daysTo(lamexp_version_expires()), 0);
        aboutText += QString("<hr><font color=\"crimson\">%1</font>").arg(NOBR(tr("Note: This demo (pre-release) version of LameXP will expire at %1. Still %2 days left.").arg(lamexp_version_expires().toString(Qt::ISODate), QString::number(daysLeft))));
    }

    aboutText += "<hr><br>";
    aboutText += "<nobr><tt>This program is free software; you can redistribute it and/or<br>";
    aboutText += "modify it under the terms of the GNU General Public License<br>";
    aboutText += "as published by the Free Software Foundation; either version 2<br>";
    aboutText += "of the License, or (at your option) any later version.<br><br>";
    aboutText += "This program is distributed in the hope that it will be useful,<br>";
    aboutText += "but WITHOUT ANY WARRANTY; without even the implied warranty of<br>";
    aboutText += "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the<br>";
    aboutText += "GNU General Public License for more details.<br><br>";
    aboutText += "You should have received a copy of the GNU General Public License<br>";
    aboutText += "along with this program; if not, write to the Free Software<br>";
    aboutText += "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110&minus;1301, USA.</tt></nobr><br>";
    aboutText += "<hr><table><tr>";
    aboutText += "<td valign=\"middle\"><img src=\":/icons/error_big.png\"</td><td>&nbsp;</td>";
    aboutText += QString("<td><font color=\"darkred\">%1</font></td>").arg(tr("Note: LameXP is free software. Do <b>not</b> pay money to obtain or use LameXP! If some third-party website tries to make you pay for downloading LameXP, you should <b>not</b> respond to the offer !!!"));
    aboutText += "</tr></table><hr><br>";
    aboutText += QString("%1<br>").arg(NOBR(tr("Special thanks go out to \"John33\" from %1 for his continuous support.")).arg(LINK("http://www.rarewares.org/")));

    setText(aboutText);
    setIconPixmap(dynamic_cast<QApplication*>(QApplication::instance())->windowIcon().pixmap(QSize(64,64)));
    setWindowTitle(tr("About LameXP"));

    if(firstStart)
    {
        QPushButton *firstButton = addButton(tr("Show License Text"), QMessageBox::AcceptRole);
        firstButton->setIcon(QIcon(":/icons/script.png"));
        firstButton->setIconSize(QSize(16, 16));
        firstButton->setMinimumWidth(135);
        firstButton->disconnect();
        connect(firstButton, SIGNAL(clicked()), this, SLOT(openLicenseText()));

        QPushButton *secondButton = addButton(tr("Accept License"), QMessageBox::AcceptRole);
        secondButton->setIcon(QIcon(":/icons/accept.png"));
        secondButton->setIconSize(QSize(16, 16));
        secondButton->setMinimumWidth(120);

        QPushButton *thirdButton = addButton(tr("Decline License"), QMessageBox::AcceptRole);
        thirdButton->setIcon(QIcon(":/icons/delete.png"));
        thirdButton->setIconSize(QSize(16, 16));
        thirdButton->setMinimumWidth(120);
        thirdButton->setEnabled(false);
    }
    else
    {
        QPushButton *firstButton = addButton(tr("3rd Party S/W"), QMessageBox::AcceptRole);
        firstButton->setIcon(QIcon(":/icons/page_white_cplusplus.png"));
        firstButton->setIconSize(QSize(16, 16));
        firstButton->setMinimumWidth(120);
        firstButton->disconnect();
        connect(firstButton, SIGNAL(clicked()), this, SLOT(showMoreAbout()));

        QPushButton *secondButton = addButton(tr("Contributors"), QMessageBox::AcceptRole);
        secondButton->setIcon(QIcon(":icons/user_suit.png"));
        secondButton->setIconSize(QSize(16, 16));
        secondButton->setMinimumWidth(120);
        secondButton->disconnect();
        connect(secondButton, SIGNAL(clicked()), this, SLOT(showAboutContributors()));

        QPushButton *thirdButton = addButton(tr("About Qt4"), QMessageBox::AcceptRole);
        thirdButton->setIcon(QIcon(":/images/Qt.svg"));
        thirdButton->setIconSize(QSize(16, 16));
        thirdButton->setMinimumWidth(120);
        thirdButton->disconnect();
        connect(thirdButton, SIGNAL(clicked()), this, SLOT(showAboutQt()));

        QPushButton *fourthButton = addButton(tr("Discard"), QMessageBox::AcceptRole);
        fourthButton->setIcon(QIcon(":/icons/cross.png"));
        fourthButton->setIconSize(QSize(16, 16));
        fourthButton->setMinimumWidth(90);

        QPixmap disque(":/images/Disque.png");
        QRect screenGeometry = QApplication::desktop()->availableGeometry();
        m_disque = new QLabel(this, Qt::Window | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
        m_disque->installEventFilter(this);
        m_disque->setStyleSheet("background:transparent;");
        m_disque->setAttribute(Qt::WA_TranslucentBackground);
        m_disque->setGeometry(qrand() % (screenGeometry.width() - disque.width()), qrand() % (screenGeometry.height() - disque.height()), disque.width(), disque.height());
        m_disque->setPixmap(disque);
        m_disque->setWindowOpacity(0.01);
        m_disque->show();
        m_disqueFlags[0] = (qrand() > (RAND_MAX/2));
        m_disqueFlags[1] = (qrand() > (RAND_MAX/2));
        m_disqueTimer = new QTimer;
        connect(m_disqueTimer, SIGNAL(timeout()), this, SLOT(moveDisque()));
        m_disqueTimer->setInterval(10);
        m_disqueTimer->start();
    }

    m_firstShow = firstStart;
}