Properly map the popup menu position to global coordinates.

This commit is contained in:
LoRd_MuldeR 2011-02-14 19:03:36 +01:00
parent 49e5495414
commit c967a013be
4 changed files with 59 additions and 32 deletions

View File

@ -25,7 +25,7 @@
#define VER_LAMEXP_MAJOR 4 #define VER_LAMEXP_MAJOR 4
#define VER_LAMEXP_MINOR_HI 0 #define VER_LAMEXP_MINOR_HI 0
#define VER_LAMEXP_MINOR_LO 0 #define VER_LAMEXP_MINOR_LO 0
#define VER_LAMEXP_BUILD 308 #define VER_LAMEXP_BUILD 310
#define VER_LAMEXP_SUFFIX RC-1 #define VER_LAMEXP_SUFFIX RC-1
/* /*

View File

@ -1962,9 +1962,15 @@ void MainWindow::restoreCursor(void)
*/ */
void MainWindow::sourceFilesContextMenu(const QPoint &pos) void MainWindow::sourceFilesContextMenu(const QPoint &pos)
{ {
if(pos.x() <= sourceFileView->width() && pos.y() <= sourceFileView->height() && pos.x() >= 0 && pos.y() >= 0) QAbstractScrollArea *scrollArea = dynamic_cast<QAbstractScrollArea*>(QObject::sender());
QWidget *sender = scrollArea ? scrollArea->viewport() : dynamic_cast<QWidget*>(QObject::sender());
if(sender)
{ {
m_sourceFilesContextMenu->popup(sourceFileView->mapToGlobal(pos)); if(pos.x() <= sender->width() && pos.y() <= sender->height() && pos.x() >= 0 && pos.y() >= 0)
{
m_sourceFilesContextMenu->popup(sender->mapToGlobal(pos));
}
} }
} }
@ -2051,10 +2057,12 @@ void MainWindow::findFileContextActionTriggered(void)
*/ */
void MainWindow::outputFolderContextMenu(const QPoint &pos) void MainWindow::outputFolderContextMenu(const QPoint &pos)
{ {
QAbstractScrollArea *scrollArea = dynamic_cast<QAbstractScrollArea*>(QObject::sender());
QWidget *sender = scrollArea ? scrollArea->viewport() : dynamic_cast<QWidget*>(QObject::sender());
if(pos.x() <= outputFolderView->width() && pos.y() <= outputFolderView->height() && pos.x() >= 0 && pos.y() >= 0) if(pos.x() <= sender->width() && pos.y() <= sender->height() && pos.x() >= 0 && pos.y() >= 0)
{ {
m_outputFolderContextMenu->popup(outputFolderView->mapToGlobal(pos)); m_outputFolderContextMenu->popup(sender->mapToGlobal(pos));
} }
} }

View File

@ -56,6 +56,8 @@
#include <Windows.h> #include <Windows.h>
////////////////////////////////////////////////////////////
#define CHANGE_BACKGROUND_COLOR(WIDGET, COLOR) \ #define CHANGE_BACKGROUND_COLOR(WIDGET, COLOR) \
{ \ { \
QPalette palette = WIDGET->palette(); \ QPalette palette = WIDGET->palette(); \
@ -69,6 +71,8 @@
m_systemTray->setToolTip(QString().sprintf("LameXP v%d.%02d\n%ls", lamexp_version_major(), lamexp_version_minor(), QString(TXT).utf16())); \ m_systemTray->setToolTip(QString().sprintf("LameXP v%d.%02d\n%ls", lamexp_version_major(), lamexp_version_minor(), QString(TXT).utf16())); \
} }
#define SET_FONT_BOLD(WIDGET,BOLD) { QFont _font = WIDGET->font(); _font.setBold(BOLD); WIDGET->setFont(_font); }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Constructor // Constructor
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
@ -125,6 +129,7 @@ ProcessingDialog::ProcessingDialog(FileListModel *fileListModel, AudioFileModel
connect(view_log, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuTriggered(QPoint))); connect(view_log, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuTriggered(QPoint)));
connect(contextMenuDetailsAction, SIGNAL(triggered(bool)), this, SLOT(contextMenuDetailsActionTriggered())); connect(contextMenuDetailsAction, SIGNAL(triggered(bool)), this, SLOT(contextMenuDetailsActionTriggered()));
connect(contextMenuShowFileAction, SIGNAL(triggered(bool)), this, SLOT(contextMenuShowFileActionTriggered())); connect(contextMenuShowFileAction, SIGNAL(triggered(bool)), this, SLOT(contextMenuShowFileActionTriggered()));
SET_FONT_BOLD(contextMenuDetailsAction, true);
//Enque jobs //Enque jobs
if(fileListModel) if(fileListModel)
@ -422,9 +427,12 @@ void ProcessingDialog::logViewDoubleClicked(const QModelIndex &index)
void ProcessingDialog::contextMenuTriggered(const QPoint &pos) void ProcessingDialog::contextMenuTriggered(const QPoint &pos)
{ {
if(pos.x() <= view_log->width() && pos.y() <= view_log->height() && pos.x() >= 0 && pos.y() >= 0) QAbstractScrollArea *scrollArea = dynamic_cast<QAbstractScrollArea*>(QObject::sender());
QWidget *sender = scrollArea ? scrollArea->viewport() : dynamic_cast<QWidget*>(QObject::sender());
if(pos.x() <= sender->width() && pos.y() <= sender->height() && pos.x() >= 0 && pos.y() >= 0)
{ {
m_contextMenu->popup(view_log->mapToGlobal(pos)); m_contextMenu->popup(sender->mapToGlobal(pos));
} }
} }

View File

@ -298,13 +298,27 @@ void lamexp_message_handler(QtMsgType type, const char *msg)
*/ */
void lamexp_init_console(int argc, char* argv[]) void lamexp_init_console(int argc, char* argv[])
{ {
bool enableConsole = lamexp_version_demo();
for(int i = 0; i < argc; i++) for(int i = 0; i < argc; i++)
{ {
if(lamexp_version_demo() || !_stricmp(argv[i], "--console")) if(!_stricmp(argv[i], "--console"))
{
enableConsole = true;
}
else if(!_stricmp(argv[i], "--no-console"))
{
enableConsole = false;
}
}
if(enableConsole)
{ {
if(AllocConsole()) if(AllocConsole())
{ {
//-------------------------------------------------------------------
//See: http://support.microsoft.com/default.aspx?scid=kb;en-us;105305 //See: http://support.microsoft.com/default.aspx?scid=kb;en-us;105305
//-------------------------------------------------------------------
int hCrtStdOut = _open_osfhandle((long) GetStdHandle(STD_OUTPUT_HANDLE), _O_TEXT); int hCrtStdOut = _open_osfhandle((long) GetStdHandle(STD_OUTPUT_HANDLE), _O_TEXT);
int hCrtStdErr = _open_osfhandle((long) GetStdHandle(STD_ERROR_HANDLE), _O_TEXT); int hCrtStdErr = _open_osfhandle((long) GetStdHandle(STD_ERROR_HANDLE), _O_TEXT);
FILE *hfStdOut = _fdopen(hCrtStdOut, "w"); FILE *hfStdOut = _fdopen(hCrtStdOut, "w");
@ -322,9 +336,6 @@ void lamexp_init_console(int argc, char* argv[])
SetConsoleCtrlHandler(NULL, TRUE); SetConsoleCtrlHandler(NULL, TRUE);
SetConsoleTitle(L"LameXP - Audio Encoder Front-End | Debug Console"); SetConsoleTitle(L"LameXP - Audio Encoder Front-End | Debug Console");
SetConsoleOutputCP(CP_UTF8); SetConsoleOutputCP(CP_UTF8);
break;
}
} }
} }