From c967a013be69cf4b0ee9db2b87074776601a2be8 Mon Sep 17 00:00:00 2001 From: lordmulder Date: Mon, 14 Feb 2011 19:03:36 +0100 Subject: [PATCH] Properly map the popup menu position to global coordinates. --- src/Config.h | 2 +- src/Dialog_MainWindow.cpp | 18 +++++++++---- src/Dialog_Processing.cpp | 14 +++++++--- src/Global.cpp | 57 +++++++++++++++++++++++---------------- 4 files changed, 59 insertions(+), 32 deletions(-) diff --git a/src/Config.h b/src/Config.h index d076d2cf..1fbec064 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 308 +#define VER_LAMEXP_BUILD 310 #define VER_LAMEXP_SUFFIX RC-1 /* diff --git a/src/Dialog_MainWindow.cpp b/src/Dialog_MainWindow.cpp index e62220f1..0ab68fdf 100644 --- a/src/Dialog_MainWindow.cpp +++ b/src/Dialog_MainWindow.cpp @@ -1962,9 +1962,15 @@ void MainWindow::restoreCursor(void) */ 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(QObject::sender()); + QWidget *sender = scrollArea ? scrollArea->viewport() : dynamic_cast(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) { - - if(pos.x() <= outputFolderView->width() && pos.y() <= outputFolderView->height() && pos.x() >= 0 && pos.y() >= 0) + QAbstractScrollArea *scrollArea = dynamic_cast(QObject::sender()); + QWidget *sender = scrollArea ? scrollArea->viewport() : dynamic_cast(QObject::sender()); + + 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)); } } diff --git a/src/Dialog_Processing.cpp b/src/Dialog_Processing.cpp index ca92a651..9c59825f 100644 --- a/src/Dialog_Processing.cpp +++ b/src/Dialog_Processing.cpp @@ -56,6 +56,8 @@ #include +//////////////////////////////////////////////////////////// + #define CHANGE_BACKGROUND_COLOR(WIDGET, COLOR) \ { \ 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())); \ } +#define SET_FONT_BOLD(WIDGET,BOLD) { QFont _font = WIDGET->font(); _font.setBold(BOLD); WIDGET->setFont(_font); } + //////////////////////////////////////////////////////////// // Constructor //////////////////////////////////////////////////////////// @@ -125,7 +129,8 @@ ProcessingDialog::ProcessingDialog(FileListModel *fileListModel, AudioFileModel connect(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())); - + SET_FONT_BOLD(contextMenuDetailsAction, true); + //Enque jobs if(fileListModel) { @@ -422,9 +427,12 @@ void ProcessingDialog::logViewDoubleClicked(const QModelIndex &index) 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(QObject::sender()); + QWidget *sender = scrollArea ? scrollArea->viewport() : dynamic_cast(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)); } } diff --git a/src/Global.cpp b/src/Global.cpp index c26f3782..9f040ba8 100644 --- a/src/Global.cpp +++ b/src/Global.cpp @@ -298,33 +298,44 @@ void lamexp_message_handler(QtMsgType type, const char *msg) */ void lamexp_init_console(int argc, char* argv[]) { + bool enableConsole = lamexp_version_demo(); + for(int i = 0; i < argc; i++) { - if(lamexp_version_demo() || !_stricmp(argv[i], "--console")) + if(!_stricmp(argv[i], "--console")) { - if(AllocConsole()) - { - //See: http://support.microsoft.com/default.aspx?scid=kb;en-us;105305 - int hCrtStdOut = _open_osfhandle((long) GetStdHandle(STD_OUTPUT_HANDLE), _O_TEXT); - int hCrtStdErr = _open_osfhandle((long) GetStdHandle(STD_ERROR_HANDLE), _O_TEXT); - FILE *hfStdOut = _fdopen(hCrtStdOut, "w"); - FILE *hfStderr = _fdopen(hCrtStdErr, "w"); - *stdout = *hfStdOut; - *stderr = *hfStderr; - setvbuf(stdout, NULL, _IONBF, 0); - setvbuf(stderr, NULL, _IONBF, 0); - } - - HMENU hMenu = GetSystemMenu(GetConsoleWindow(), 0); - EnableMenuItem(hMenu, SC_CLOSE, MF_BYCOMMAND | MF_GRAYED); - RemoveMenu(hMenu, SC_CLOSE, MF_BYCOMMAND); - - SetConsoleCtrlHandler(NULL, TRUE); - SetConsoleTitle(L"LameXP - Audio Encoder Front-End | Debug Console"); - SetConsoleOutputCP(CP_UTF8); - - break; + enableConsole = true; } + else if(!_stricmp(argv[i], "--no-console")) + { + enableConsole = false; + } + } + + if(enableConsole) + { + if(AllocConsole()) + { + //------------------------------------------------------------------- + //See: http://support.microsoft.com/default.aspx?scid=kb;en-us;105305 + //------------------------------------------------------------------- + int hCrtStdOut = _open_osfhandle((long) GetStdHandle(STD_OUTPUT_HANDLE), _O_TEXT); + int hCrtStdErr = _open_osfhandle((long) GetStdHandle(STD_ERROR_HANDLE), _O_TEXT); + FILE *hfStdOut = _fdopen(hCrtStdOut, "w"); + FILE *hfStderr = _fdopen(hCrtStdErr, "w"); + *stdout = *hfStdOut; + *stderr = *hfStderr; + setvbuf(stdout, NULL, _IONBF, 0); + setvbuf(stderr, NULL, _IONBF, 0); + } + + HMENU hMenu = GetSystemMenu(GetConsoleWindow(), 0); + EnableMenuItem(hMenu, SC_CLOSE, MF_BYCOMMAND | MF_GRAYED); + RemoveMenu(hMenu, SC_CLOSE, MF_BYCOMMAND); + + SetConsoleCtrlHandler(NULL, TRUE); + SetConsoleTitle(L"LameXP - Audio Encoder Front-End | Debug Console"); + SetConsoleOutputCP(CP_UTF8); } }