diff --git a/LameXP.rc b/LameXP.rc index 46b7c7b4..3336b87a 100644 --- a/LameXP.rc +++ b/LameXP.rc @@ -110,6 +110,7 @@ IDR_WAVE_SUCCESS WAVE "res\\sounds\\success.wav" IDR_WAVE_ERROR WAVE "res\\sounds\\error.wav" IDR_WAVE_ABORTED WAVE "res\\sounds\\aborted.wav" IDR_WAVE_WHAMMY WAVE "res\\sounds\\whammy.wav" +IDR_WAVE_WOOHOO WAVE "res\\sounds\\woohoo.wav" ///////////////////////////////////////////////////////////////////////////// // diff --git a/LameXP.vcproj b/LameXP.vcproj index cbc53f41..8ae4fd54 100644 --- a/LameXP.vcproj +++ b/LameXP.vcproj @@ -326,6 +326,10 @@ RelativePath=".\src\Dialog_About.cpp" > + + @@ -564,6 +568,40 @@ /> + + + + + + + + + + + @@ -1404,6 +1442,10 @@ RelativePath=".\tmp\MOC_Dialog_About.cpp" > + + @@ -1664,6 +1706,40 @@ + + + + + + + + + + + diff --git a/gui/DropBox.ui b/gui/DropBox.ui new file mode 100644 index 00000000..bbe476ca --- /dev/null +++ b/gui/DropBox.ui @@ -0,0 +1,53 @@ + + + DropBox + + + + 0 + 0 + 102 + 102 + + + + LameXP - DropBox + + + + :/icons/package.png:/icons/package.png + + + + 0 + + + + + + + 0 + + + + + + :/images/DropBox.png + + + Qt::AlignCenter + + + + + + + + + + + + + + + diff --git a/gui/MainWindow.ui b/gui/MainWindow.ui index bc53f5bb..89d8bc5d 100644 --- a/gui/MainWindow.ui +++ b/gui/MainWindow.ui @@ -1201,6 +1201,7 @@ + @@ -1397,6 +1398,15 @@ Disable WMA Decoder Notifications + + + + :/icons/package.png:/icons/package.png + + + Show DropBox + + @@ -1500,6 +1510,8 @@ + + diff --git a/res/Images.qrc b/res/Images.qrc index 5bc1ac2e..cce78efb 100644 --- a/res/Images.qrc +++ b/res/Images.qrc @@ -2,19 +2,20 @@ images/Busy.gif - images/HeaderIcon_MetaInfo.png + images/Cogwheels.png + images/Construction.gif + images/DropBox.png images/HeaderIcon_LogFile.png + images/HeaderIcon_MetaInfo.png images/Label.png images/Loading.gif images/Logo.png images/Logo_Contributors.png images/Logo_Software.png + images/Qt.svg images/Splash.png images/Thumb.png - images/Construction.gif - images/Cogwheels.png - images/Qt.svg - images/Working.gif images/Wizard.png + images/Working.gif diff --git a/res/images/DropBox.png b/res/images/DropBox.png new file mode 100644 index 00000000..be457507 Binary files /dev/null and b/res/images/DropBox.png differ diff --git a/res/sounds/woohoo.wav b/res/sounds/woohoo.wav new file mode 100644 index 00000000..837241a4 Binary files /dev/null and b/res/sounds/woohoo.wav differ diff --git a/src/Config.h b/src/Config.h index cbd2cfac..c640278c 100644 --- a/src/Config.h +++ b/src/Config.h @@ -25,7 +25,7 @@ #define VER_LAMEXP_MAJOR 4 #define VER_LAMEXP_MINOR_HI 0 #define VER_LAMEXP_MINOR_LO 0 -#define VER_LAMEXP_BUILD 175 +#define VER_LAMEXP_BUILD 179 #define VER_LAMEXP_SUFFIX TechPreview /* diff --git a/src/Dialog_DropBox.cpp b/src/Dialog_DropBox.cpp new file mode 100644 index 00000000..c9ff7311 --- /dev/null +++ b/src/Dialog_DropBox.cpp @@ -0,0 +1,154 @@ +/////////////////////////////////////////////////////////////////////////////// +// LameXP - Audio Encoder Front-End +// Copyright (C) 2004-2010 LoRd_MuldeR +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// http://www.gnu.org/licenses/gpl-2.0.txt +/////////////////////////////////////////////////////////////////////////////// + +#include "Dialog_DropBox.h" + +#include "Global.h" +#include "Model_Settings.h" + +#include +#include +#include +#include +#include + +#define EPS (1.0E-5) +#define SET_FONT_BOLD(WIDGET,BOLD) { QFont _font = WIDGET.font(); _font.setBold(BOLD); WIDGET.setFont(_font); } + +//////////////////////////////////////////////////////////// +// Constructor +//////////////////////////////////////////////////////////// + +DropBox::DropBox(QWidget *parent, QAbstractItemModel *model, SettingsModel *settings) +: + QDialog(parent, Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint), + m_counterLabel(this), + m_model(model), + m_settings(settings), + m_firstShow(true) +{ + //Init the dialog, from the .ui file + setupUi(this); + + //Init counter + m_counterLabel.setParent(dropBoxLabel); + m_counterLabel.setText("0"); + m_counterLabel.setAlignment(Qt::AlignHCenter | Qt::AlignTop); + SET_FONT_BOLD(m_counterLabel, true); + + //Prevent close + m_canClose = false; + + //Make transparent + setWindowOpacity(0.8); +} + +//////////////////////////////////////////////////////////// +// Destructor +//////////////////////////////////////////////////////////// + +DropBox::~DropBox(void) +{ +} + +//////////////////////////////////////////////////////////// +// PUBLIC SLOTS +//////////////////////////////////////////////////////////// + +void DropBox::modelChanged(void) +{ + if(m_model) + { + m_counterLabel.setText(QString::number(m_model->rowCount())); + } +} + +//////////////////////////////////////////////////////////// +// EVENTS +//////////////////////////////////////////////////////////// + +void DropBox::showEvent(QShowEvent *event) +{ + QRect screenGeometry = QApplication::desktop()->availableGeometry(); + + resize(dropBoxLabel->pixmap()->size()); + setMaximumSize(dropBoxLabel->pixmap()->size()); + + m_counterLabel.setGeometry(0, dropBoxLabel->height() - 30, dropBoxLabel->width(), 25); + + if(m_firstShow) + { + m_firstShow = false; + int max_x = screenGeometry.width() - frameGeometry().width(); + int max_y = screenGeometry.height() - frameGeometry().height(); + move(max_x, max_y); + } +} + +void DropBox::keyPressEvent(QKeyEvent *event) +{ + event->ignore(); +} + +void DropBox::keyReleaseEvent(QKeyEvent *event) +{ + event->ignore(); +} + +void DropBox::closeEvent(QCloseEvent *event) +{ + if(!m_canClose) event->ignore(); +} + +void DropBox::mousePressEvent(QMouseEvent *event) +{ + if(event->button() == Qt::RightButton) + { + hide(); + if(m_settings) m_settings->dropBoxWidgetEnabled(false); + return; + } + + QApplication::setOverrideCursor(Qt::SizeAllCursor); + m_windowReferencePoint = this->pos(); + m_mouseReferencePoint = event->globalPos(); +} + +void DropBox::mouseReleaseEvent(QMouseEvent *event) +{ + QApplication::restoreOverrideCursor(); +} + +void DropBox::mouseMoveEvent(QMouseEvent *event) +{ + QRect screenGeometry = QApplication::desktop()->availableGeometry(); + + int delta_x = m_mouseReferencePoint.x() - event->globalX(); + int delta_y = m_mouseReferencePoint.y() - event->globalY(); + + int max_x = screenGeometry.width() - frameGeometry().width(); + int max_y = screenGeometry.height() - frameGeometry().height(); + + int new_x = min(max_x, max(0, m_windowReferencePoint.x() - delta_x)); + int new_y = min(max_y, max(0, m_windowReferencePoint.y() - delta_y)); + + move(new_x, new_y); +} diff --git a/src/Dialog_DropBox.h b/src/Dialog_DropBox.h new file mode 100644 index 00000000..9b67cfc3 --- /dev/null +++ b/src/Dialog_DropBox.h @@ -0,0 +1,65 @@ +/////////////////////////////////////////////////////////////////////////////// +// LameXP - Audio Encoder Front-End +// Copyright (C) 2004-2010 LoRd_MuldeR +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// http://www.gnu.org/licenses/gpl-2.0.txt +/////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "../tmp/UIC_DropBox.h" + +#include + +class QDragEnterEvent; +class QMouseEvent; +class QAbstractItemModel; +class SettingsModel; + +//////////////////////////////////////////////////////////// +// Splash Frame +//////////////////////////////////////////////////////////// + +class DropBox: public QDialog, private Ui::DropBox +{ + Q_OBJECT + +public: + DropBox(QWidget *parent = 0, QAbstractItemModel *model = 0, SettingsModel *settings = 0); + ~DropBox(void); + +private: + bool m_canClose; + QPoint m_mouseReferencePoint; + QPoint m_windowReferencePoint; + QLabel m_counterLabel; + QAbstractItemModel *m_model; + SettingsModel *m_settings; + bool m_firstShow; + +protected: + void keyPressEvent(QKeyEvent *event); + void keyReleaseEvent(QKeyEvent *event); + void closeEvent(QCloseEvent *event); + void showEvent(QShowEvent *event); + void mousePressEvent(QMouseEvent *event); + void mouseMoveEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + +public slots: + void modelChanged(void); +}; diff --git a/src/Dialog_MainWindow.cpp b/src/Dialog_MainWindow.cpp index 5b4ccd02..0075369d 100644 --- a/src/Dialog_MainWindow.cpp +++ b/src/Dialog_MainWindow.cpp @@ -28,6 +28,7 @@ #include "Dialog_MetaInfo.h" #include "Dialog_About.h" #include "Dialog_Update.h" +#include "Dialog_DropBox.h" #include "Thread_FileAnalyzer.h" #include "Thread_MessageHandler.h" #include "Model_MetaInfo.h" @@ -259,6 +260,7 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, S connect(actionInstallWMADecoder, SIGNAL(triggered(bool)), this, SLOT(installWMADecoderActionTriggered(bool))); connect(actionDisableNeroAacNotifications, SIGNAL(triggered(bool)), this, SLOT(disableNeroAacNotificationsActionTriggered(bool))); connect(actionDisableWmaDecoderNotifications, SIGNAL(triggered(bool)), this, SLOT(disableWmaDecoderNotificationsActionTriggered(bool))); + connect(actionShowDropBoxWidget, SIGNAL(triggered(bool)), this, SLOT(showDropBoxWidgetActionTriggered(bool))); //Activate help menu actions connect(actionCheckUpdates, SIGNAL(triggered()), this, SLOT(checkUpdatesActionActivated())); @@ -273,6 +275,12 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, S //Create banner m_banner = new WorkingBanner(this); + //Create DropBox widget + m_dropBox = new DropBox(this, m_fileListModel, m_settings); + connect(m_fileListModel, SIGNAL(modelReset()), m_dropBox, SLOT(modelChanged())); + connect(m_fileListModel, SIGNAL(rowsInserted(QModelIndex,int,int)), m_dropBox, SLOT(modelChanged())); + connect(m_fileListModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), m_dropBox, SLOT(modelChanged())); + //Create message handler thread m_messageHandler = new MessageHandlerThread(); m_delayedFileList = new QStringList(); @@ -320,6 +328,7 @@ MainWindow::~MainWindow(void) LAMEXP_DELETE(m_encoderButtonGroup); LAMEXP_DELETE(m_encoderButtonGroup); LAMEXP_DELETE(m_sourceFilesContextMenu); + LAMEXP_DELETE(m_dropBox); } //////////////////////////////////////////////////////////// @@ -371,6 +380,11 @@ void MainWindow::showEvent(QShowEvent *event) m_firstTimeShown = false; QTimer::singleShot(0, this, SLOT(windowShown())); } + + if(m_settings->dropBoxWidgetEnabled()) + { + m_dropBox->setVisible(true); + } } void MainWindow::dragEnterEvent(QDragEnterEvent *event) @@ -422,6 +436,11 @@ void MainWindow::closeEvent(QCloseEvent *event) MessageBeep(MB_ICONEXCLAMATION); event->ignore(); } + + if(m_dropBox) + { + m_dropBox->hide(); + } } void MainWindow::resizeEvent(QResizeEvent *event) @@ -470,12 +489,14 @@ void MainWindow::windowShown(void) if(iAccepted <= 0) { m_settings->licenseAccepted(-1); + QApplication::processEvents(); PlaySound(MAKEINTRESOURCE(IDR_WAVE_WHAMMY), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC); QMessageBox::critical(this, "License Declined", "You have declined the license. Consequently the application will exit now!"); QApplication::quit(); return; } - + + PlaySound(MAKEINTRESOURCE(IDR_WAVE_WOOHOO), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC); m_settings->licenseAccepted(1); } @@ -575,6 +596,7 @@ void MainWindow::windowShown(void) } } + //Start delayed files timer if(!m_delayedFileList->isEmpty() && !m_delayedFileTimer->isActive()) { m_delayedFileTimer->start(5000); @@ -587,9 +609,11 @@ void MainWindow::windowShown(void) void MainWindow::aboutButtonClicked(void) { ABORT_IF_BUSY; + if(m_dropBox->isVisible()) m_dropBox->hide(); AboutDialog *aboutBox = new AboutDialog(m_settings, this); aboutBox->exec(); LAMEXP_DELETE(aboutBox); + if(m_settings->dropBoxWidgetEnabled()) m_dropBox->show(); } /* @@ -1021,7 +1045,8 @@ void MainWindow::visitHomepageActionActivated(void) void MainWindow::checkUpdatesActionActivated(void) { ABORT_IF_BUSY; - + + if(m_dropBox->isVisible()) m_dropBox->hide(); UpdateDialog *updateDialog = new UpdateDialog(m_settings, this); updateDialog->exec(); @@ -1031,6 +1056,7 @@ void MainWindow::checkUpdatesActionActivated(void) } LAMEXP_DELETE(updateDialog); + if(m_settings->dropBoxWidgetEnabled()) m_dropBox->show(); } /* @@ -1610,3 +1636,21 @@ void MainWindow::installWMADecoderActionTriggered(bool checked) } } +void MainWindow::showDropBoxWidgetActionTriggered(bool checked) +{ + m_settings->dropBoxWidgetEnabled(true); + + if(!m_dropBox->isVisible()) + { + m_dropBox->show(); + } + + FLASHWINFO flashInfo; + memset(&flashInfo, 0, sizeof(FLASHWINFO)); + flashInfo.cbSize = sizeof(FLASHWINFO); + flashInfo.dwFlags = FLASHW_ALL; + flashInfo.uCount = 12; + flashInfo.dwTimeout = 125; + flashInfo.hwnd = m_dropBox->winId(); + FlashWindowEx(&flashInfo); +} diff --git a/src/Dialog_MainWindow.h b/src/Dialog_MainWindow.h index bdb684af..4a49f382 100644 --- a/src/Dialog_MainWindow.h +++ b/src/Dialog_MainWindow.h @@ -34,6 +34,7 @@ class QButtonGroup; class FileListModel; class AbstractEncoder; class QMenu; +class DropBox; class MainWindow: public QMainWindow, private Ui::MainWindow { @@ -91,6 +92,7 @@ private slots: void installWMADecoderActionTriggered(bool checked); void disableNeroAacNotificationsActionTriggered(bool checked); void disableWmaDecoderNotificationsActionTriggered(bool checked); + void showDropBoxWidgetActionTriggered(bool checked); protected: void showEvent(QShowEvent *event); @@ -121,4 +123,5 @@ private: QLabel *m_dropNoteLabel; QMenu *m_sourceFilesContextMenu; QMenu *m_outputFolderContextMenu; + DropBox *m_dropBox; }; diff --git a/src/Global.cpp b/src/Global.cpp index 36d6b54c..1438ff1d 100644 --- a/src/Global.cpp +++ b/src/Global.cpp @@ -223,12 +223,12 @@ void lamexp_message_handler(QtMsgType type, const char *msg) fflush(stdout); fflush(stderr); SetConsoleTextAttribute(hConsole, FOREGROUND_RED | FOREGROUND_INTENSITY); - fwprintf(stderr, L"\nCRITICAL ERROR !!!\n%S\n\n", msg); - MessageBoxW(NULL, (wchar_t*) QString::fromUtf8(msg).utf16(), L"LameXP - CRITICAL ERROR", MB_ICONERROR | MB_TOPMOST | MB_TASKMODAL); + fwprintf(stderr, L"\nGURU MEDITATION !!!\n%S\n\n", msg); + MessageBoxW(NULL, (wchar_t*) QString::fromUtf8(msg).utf16(), L"LameXP - GURU MEDITATION", MB_ICONERROR | MB_TOPMOST | MB_TASKMODAL); break; case QtWarningMsg: SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY); - //MessageBoxW(NULL, (wchar_t*) QString::fromUtf8(msg).utf16(), L"LameXP - CRITICAL ERROR", MB_ICONWARNING | MB_TOPMOST | MB_TASKMODAL); + //MessageBoxW(NULL, (wchar_t*) QString::fromUtf8(msg).utf16(), L"LameXP - GURU MEDITATION", MB_ICONWARNING | MB_TOPMOST | MB_TASKMODAL); fwprintf(stderr, L"%S\n", msg); fflush(stderr); break; diff --git a/src/Main.cpp b/src/Main.cpp index be110950..6922d6f4 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -186,7 +186,7 @@ int main(int argc, char* argv[]) { fflush(stdout); fflush(stderr); - fprintf(stderr, "\nEXCEPTION ERROR: %s\n", error); + fprintf(stderr, "\nGURU MEDITATION: %s\n", error); FatalAppExit(0, L"Unhandeled exception error, application will exit!"); TerminateProcess(GetCurrentProcess(), -1); } @@ -194,7 +194,7 @@ int main(int argc, char* argv[]) { fflush(stdout); fflush(stderr); - fprintf(stderr, "\nEXCEPTION ERROR: Error code 0x%X\n", error); + fprintf(stderr, "\nGURU MEDITATION: Error code 0x%X\n", error); FatalAppExit(0, L"Unhandeled exception error, application will exit!"); TerminateProcess(GetCurrentProcess(), -1); } @@ -202,7 +202,7 @@ int main(int argc, char* argv[]) { fflush(stdout); fflush(stderr); - fprintf(stderr, "\nEXCEPTION ERROR !!!\n"); + fprintf(stderr, "\nGURU MEDITATION !!!\n"); FatalAppExit(0, L"Unhandeled exception error, application will exit!"); TerminateProcess(GetCurrentProcess(), -1); } diff --git a/src/Model_Settings.cpp b/src/Model_Settings.cpp index 4e70b5d6..2baa9fae 100644 --- a/src/Model_Settings.cpp +++ b/src/Model_Settings.cpp @@ -46,6 +46,7 @@ static const char *g_settingsId_autoUpdateEnabled = "AutoUpdate/Enabled"; static const char *g_settingsId_soundsEnabled = "Flags/EnableSounds"; static const char *g_settingsId_neroAacNotificationsEnabled = "Flags/EnableNeroAacNotifications"; static const char *g_settingsId_wmaDecoderNotificationsEnabled = "Flags/EnableWmaDecoderNotifications"; +static const char *g_settingsId_dropBoxWidgetEnabled = "Flags/EnableDropBoxWidget"; //Macros #define MAKE_OPTION1(OPT,DEF) \ @@ -132,3 +133,4 @@ MAKE_OPTION3(autoUpdateEnabled, true) MAKE_OPTION3(soundsEnabled, true) MAKE_OPTION3(neroAacNotificationsEnabled, true) MAKE_OPTION3(wmaDecoderNotificationsEnabled, true) +MAKE_OPTION3(dropBoxWidgetEnabled, true) diff --git a/src/Model_Settings.h b/src/Model_Settings.h index 962a85d9..e6ccd189 100644 --- a/src/Model_Settings.h +++ b/src/Model_Settings.h @@ -77,6 +77,7 @@ public: MAKE_OPTION_DEC3(soundsEnabled); MAKE_OPTION_DEC3(neroAacNotificationsEnabled) MAKE_OPTION_DEC3(wmaDecoderNotificationsEnabled) + MAKE_OPTION_DEC3(dropBoxWidgetEnabled) //Misc void validate(void); diff --git a/src/Resource.h b/src/Resource.h index d99ab915..58c21e5a 100644 --- a/src/Resource.h +++ b/src/Resource.h @@ -30,6 +30,7 @@ #define IDR_WAVE_ERROR 668 #define IDR_WAVE_ABORTED 669 #define IDR_WAVE_WHAMMY 670 +#define IDR_WAVE_WOOHOO 671 /* * Next default values for new objects diff --git a/src/Thread_Process.cpp b/src/Thread_Process.cpp index 7f5b9ef7..99c16d70 100644 --- a/src/Thread_Process.cpp +++ b/src/Thread_Process.cpp @@ -86,7 +86,7 @@ void ProcessThread::run() { fflush(stdout); fflush(stderr); - fprintf(stderr, "\nEXCEPTION ERROR !!!\n"); + fprintf(stderr, "\nGURU MEDITATION !!!\n"); FatalAppExit(0, L"Unhandeled exception error, application will exit!"); TerminateProcess(GetCurrentProcess(), -1); }