From 7269e7fc9a6ef67f22a561fa36a25c284ce2d015 Mon Sep 17 00:00:00 2001 From: lordmulder Date: Wed, 22 Dec 2010 22:59:00 +0100 Subject: [PATCH] Some DropBox improvements. --- gui/DropBox.ui | 5 ++++ src/Config.h | 2 +- src/Dialog_About.cpp | 20 ++++++++-------- src/Dialog_DropBox.cpp | 48 ++++++++++++++++++++++++++++++++++++++- src/Dialog_DropBox.h | 2 ++ src/Dialog_MainWindow.cpp | 26 +++++++++++---------- 6 files changed, 79 insertions(+), 24 deletions(-) diff --git a/gui/DropBox.ui b/gui/DropBox.ui index bbe476ca..3508513e 100644 --- a/gui/DropBox.ui +++ b/gui/DropBox.ui @@ -25,6 +25,9 @@ + + <b>LameXP DropBox</b><br><nobr>You can add files to LameXP via Drag&amp;Drop here!</nobr><br><nobr>(Right-click to close to DropBox)</nobr> + 0 @@ -48,6 +51,8 @@ + + diff --git a/src/Config.h b/src/Config.h index c640278c..f7be0b95 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 179 +#define VER_LAMEXP_BUILD 181 #define VER_LAMEXP_SUFFIX TechPreview /* diff --git a/src/Dialog_About.cpp b/src/Dialog_About.cpp index b5d0b2c5..fadf4582 100644 --- a/src/Dialog_About.cpp +++ b/src/Dialog_About.cpp @@ -40,7 +40,7 @@ #include //Helper macros -#define LINK(URL) QString("%2").arg(URL).arg(URL) +#define LINK(URL) QString("↳%2").arg(URL).arg(URL) #define CONTRIBUTOR(LANG, CNTR, ICON) QString("  %2  %3").arg(ICON, LANG, CNTR); #define VSTR(BASE,TOOL,FORMAT) QString(BASE).arg(lamexp_version2string(FORMAT, lamexp_tool_version(TOOL))) @@ -221,48 +221,48 @@ void AboutDialog::showMoreAbout(void) { QString moreAboutText; moreAboutText += "

The following third-party software is used in LameXP:

"; - moreAboutText += "
    "; + moreAboutText += "
      "; moreAboutText += VSTR( "
    • LAME - OpenSource mp3 Encoder (%1)
      ", "lame.exe", "v?.?? a??"); moreAboutText += "Released under the terms of the GNU Leser General Public License.
      "; moreAboutText += LINK("http://lame.sourceforge.net/"); - moreAboutText += "
      "; + moreAboutText += "

      "; moreAboutText += VSTR("
    • OggEnc - Ogg Vorbis Encoder (%1)", "oggenc2_i386.exe", "v?.??"); moreAboutText += "
      Completely open and patent-free audio encoding technology.
      "; moreAboutText += LINK("http://www.vorbis.com/"); - moreAboutText += "
      "; + moreAboutText += "

      "; moreAboutText += VSTR("
    • Nero AAC reference MPEG-4 Encoder (%1)
      ", "neroAacEnc.exe", "v?.?.?.?"); moreAboutText += "Freeware state-of-the-art HE-AAC encoder with 2-Pass support.
      "; moreAboutText += "Available from vendor web-site as free download:
      "; moreAboutText += LINK(neroAacUrl); - moreAboutText += "
      "; + moreAboutText += "

      "; moreAboutText += VSTR("
    • FLAC - Free Lossless Audio Codec (%1)
      ", "flac.exe", "v?.?.?"); moreAboutText += "Open and patent-free lossless audio compression technology.
      "; moreAboutText += LINK("http://flac.sourceforge.net/"); - moreAboutText += "
      "; + moreAboutText += "

      "; moreAboutText += VSTR("
    • AC3Filter Tools - AC3/DTS Decoder (%1)
      ", "valdec.exe", "v?.??"); moreAboutText += "Released under the terms of the GNU Leser General Public License.
      "; moreAboutText += LINK("http://www.ac3filter.net/projects/tools"); - moreAboutText += "
      "; + moreAboutText += "

      "; moreAboutText += VSTR("
    • MediaInfo - Media File Analysis Tool (%1)
      ", "mediainfo_i386.exe", "v?.?.?"); moreAboutText += "Released under the terms of the GNU Leser General Public License.
      "; moreAboutText += LINK("http://mediainfo.sourceforge.net/"); - moreAboutText += "
      "; + moreAboutText += "

      "; moreAboutText += VSTR("
    • SoX - Sound eXchange (%1)
      ", "sox.exe", "v??.?.?"); moreAboutText += "Released under the terms of the GNU Leser General Public License.
      "; moreAboutText += LINK("http://sox.sourceforge.net/"); - moreAboutText += "
      "; + moreAboutText += "

      "; moreAboutText += VSTR("
    • GnuPG - The GNU Privacy Guard (%1)
      ", "gpgv.exe", "v?.?.??"); moreAboutText += "Released under the terms of the GNU Leser General Public License.
      "; moreAboutText += LINK("http://www.gnupg.org/"); - moreAboutText += "
      "; + moreAboutText += "

      "; moreAboutText += "
    • Silk Icons - Over 700 icons in PNG format (v1.3)
      "; moreAboutText += "By Mark James, released under the Creative Commons 'by' License.
      "; diff --git a/src/Dialog_DropBox.cpp b/src/Dialog_DropBox.cpp index c9ff7311..258e4a2c 100644 --- a/src/Dialog_DropBox.cpp +++ b/src/Dialog_DropBox.cpp @@ -28,6 +28,8 @@ #include #include #include +#include +#include #include #define EPS (1.0E-5) @@ -43,6 +45,7 @@ DropBox::DropBox(QWidget *parent, QAbstractItemModel *model, SettingsModel *sett m_counterLabel(this), m_model(model), m_settings(settings), + m_moving(false), m_firstShow(true) { //Init the dialog, from the .ui file @@ -100,7 +103,10 @@ void DropBox::showEvent(QShowEvent *event) int max_x = screenGeometry.width() - frameGeometry().width(); int max_y = screenGeometry.height() - frameGeometry().height(); move(max_x, max_y); + QTimer::singleShot(333, this, SLOT(showToolTip())); } + + m_moving = false; } void DropBox::keyPressEvent(QKeyEvent *event) @@ -120,6 +126,12 @@ void DropBox::closeEvent(QCloseEvent *event) void DropBox::mousePressEvent(QMouseEvent *event) { + if(m_moving) + { + event->ignore(); + return; + } + if(event->button() == Qt::RightButton) { hide(); @@ -128,17 +140,28 @@ void DropBox::mousePressEvent(QMouseEvent *event) } QApplication::setOverrideCursor(Qt::SizeAllCursor); + m_moving = true; m_windowReferencePoint = this->pos(); m_mouseReferencePoint = event->globalPos(); } void DropBox::mouseReleaseEvent(QMouseEvent *event) { - QApplication::restoreOverrideCursor(); + if(m_moving && event->button() != Qt::RightButton) + { + QApplication::restoreOverrideCursor(); + m_moving = false; + } } void DropBox::mouseMoveEvent(QMouseEvent *event) { + if(!m_moving) + { + return; + } + + static const int magnetic = 22; QRect screenGeometry = QApplication::desktop()->availableGeometry(); int delta_x = m_mouseReferencePoint.x() - event->globalX(); @@ -150,5 +173,28 @@ void DropBox::mouseMoveEvent(QMouseEvent *event) 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)); + if(new_x < magnetic) + { + new_x = 0; + } + else if(max_x - new_x < magnetic) + { + new_x = max_x; + } + + if(new_y < magnetic) + { + new_y = 0; + } + else if(max_y - new_y < magnetic) + { + new_y = max_y; + } + move(new_x, new_y); } + +void DropBox::showToolTip(void) +{ + QToolTip::showText(dropBoxLabel->mapToGlobal(dropBoxLabel->pos()), dropBoxLabel->toolTip()); +} diff --git a/src/Dialog_DropBox.h b/src/Dialog_DropBox.h index 9b67cfc3..52563384 100644 --- a/src/Dialog_DropBox.h +++ b/src/Dialog_DropBox.h @@ -49,6 +49,7 @@ private: QLabel m_counterLabel; QAbstractItemModel *m_model; SettingsModel *m_settings; + bool m_moving; bool m_firstShow; protected: @@ -62,4 +63,5 @@ protected: public slots: void modelChanged(void); + void showToolTip(void); }; diff --git a/src/Dialog_MainWindow.cpp b/src/Dialog_MainWindow.cpp index 0075369d..9af90182 100644 --- a/src/Dialog_MainWindow.cpp +++ b/src/Dialog_MainWindow.cpp @@ -67,6 +67,7 @@ #define ABORT_IF_BUSY if(m_banner->isVisible() || m_delayedFileTimer->isActive()) { MessageBeep(MB_ICONEXCLAMATION); return; } #define SET_TEXT_COLOR(WIDGET,COLOR) { QPalette _palette = WIDGET->palette(); _palette.setColor(QPalette::WindowText, COLOR); WIDGET->setPalette(_palette); } #define SET_FONT_BOLD(WIDGET,BOLD) { QFont _font = WIDGET->font(); _font.setBold(BOLD); WIDGET->setFont(_font); } +#define FLASH_WINDOW(WND) { FLASHWINFO flashInfo; memset(&flashInfo, 0, sizeof(FLASHWINFO)); flashInfo.cbSize = sizeof(FLASHWINFO); flashInfo.dwFlags = FLASHW_ALL; flashInfo.uCount = 12; flashInfo.dwTimeout = 125; flashInfo.hwnd = WND->winId(); FlashWindowEx(&flashInfo); } #define LINK(URL) QString("%2").arg(URL).arg(URL) //Helper class @@ -380,10 +381,12 @@ void MainWindow::showEvent(QShowEvent *event) m_firstTimeShown = false; QTimer::singleShot(0, this, SLOT(windowShown())); } - - if(m_settings->dropBoxWidgetEnabled()) + else { - m_dropBox->setVisible(true); + if(m_settings->dropBoxWidgetEnabled()) + { + m_dropBox->setVisible(true); + } } } @@ -601,6 +604,12 @@ void MainWindow::windowShown(void) { m_delayedFileTimer->start(5000); } + + //Make DropBox visible + if(m_settings->dropBoxWidgetEnabled()) + { + m_dropBox->setVisible(true); + } } /* @@ -1644,13 +1653,6 @@ void MainWindow::showDropBoxWidgetActionTriggered(bool checked) { 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); + + FLASH_WINDOW(m_dropBox); }