]> git.sur5r.net Git - minitube/commitdiff
Removed THAction class, use plain QAction
authorFlavio Tordini <flavio.tordini@gmail.com>
Thu, 13 Aug 2009 17:18:20 +0000 (19:18 +0200)
committerFlavio Tordini <flavio.tordini@gmail.com>
Thu, 13 Aug 2009 17:18:20 +0000 (19:18 +0200)
src/MediaView.cpp
src/MediaView.h
src/thlibrary/thblackbar.cpp
src/thlibrary/thblackbar.h
src/thlibrary/thlibrary.pri

index 9825010356c1e9813bab978b44f5b1041bfa0184..cee7f6242c4b88846e2539c5b2dc70ca76580ea9 100644 (file)
@@ -19,13 +19,13 @@ MediaView::MediaView(QWidget *parent) : QWidget(parent) {
     splitter->setChildrenCollapsible(false);
 
     sortBar = new THBlackBar(this);
-    mostRelevantAction = new THAction(tr("Most relevant"), this);
+    mostRelevantAction = new QAction(tr("Most relevant"), this);
     connect(mostRelevantAction, SIGNAL(triggered()), this, SLOT(searchMostRelevant()), Qt::QueuedConnection);
     sortBar->addAction(mostRelevantAction);
-    mostRecentAction = new THAction(tr("Most recent"), this);
+    mostRecentAction = new QAction(tr("Most recent"), this);
     connect(mostRecentAction, SIGNAL(triggered()), this, SLOT(searchMostRecent()), Qt::QueuedConnection);
     sortBar->addAction(mostRecentAction);
-    mostViewedAction = new THAction(tr("Most viewed"), this);
+    mostViewedAction = new QAction(tr("Most viewed"), this);
     connect(mostViewedAction, SIGNAL(triggered()), this, SLOT(searchMostViewed()), Qt::QueuedConnection);
     sortBar->addAction(mostViewedAction);
 
@@ -129,6 +129,7 @@ void MediaView::stateChanged(Phonon::State newState, Phonon::State /*oldState*/)
 
          case Phonon::ErrorState:
         qDebug() << "Phonon error:" << mediaObject->errorString() << mediaObject->errorType();
+        videoAreaWidget->showError(mediaObject->errorString());
         // recover from errors by skipping to the next video
         skip();
         break;
index a4a8996df6d1df880c6e9bc6f7f84accc290bd70..3ef1bf8cd0bb9a7cf5352201da4ee9df9a640da1 100644 (file)
@@ -7,7 +7,6 @@
 #include <phonon/videowidget.h>
 #include "View.h"
 #include "ListModel.h"
-#include "thaction.h"
 #include "thblackbar.h"
 #include "searchparams.h"
 #include "playlistwidget.h"
@@ -78,9 +77,9 @@ private:
 
     // sortBar
     THBlackBar *sortBar;
-    THAction *mostRelevantAction;
-    THAction *mostRecentAction;
-    THAction *mostViewedAction;
+    QAction *mostRelevantAction;
+    QAction *mostRecentAction;
+    QAction *mostViewedAction;
 
     // phonon
     Phonon::MediaObject *mediaObject;
index d2f3348e39d63cb0828f16b20e20dce21b6745f9..d2bbc652cc42890a28cee0e130515e714506a4fc 100644 (file)
@@ -3,16 +3,15 @@
 #include <QList>
 
 #include "thblackbar.h"
-#include "thaction.h"
 
 /* ============================================================================
  *  PRIVATE Class
  */
 class THBlackBar::Private {
         public:
-    QList<THAction *> actionList;
-    THAction *checkedAction;
-    THAction *hoveredAction;
+    QList<QAction *> actionList;
+    QAction *checkedAction;
+    QAction *hoveredAction;
 };
 
 /* ============================================================================
@@ -36,13 +35,14 @@ THBlackBar::~THBlackBar() {
 /* ============================================================================
  *  PUBLIC Methods
  */
-THAction *THBlackBar::addAction (THAction *action) {
+QAction *THBlackBar::addAction (QAction *action) {
+    action->setCheckable(true);
     d->actionList.append(action);
     return(action);
 }
 
-THAction *THBlackBar::addAction (const QString& text) {
-    THAction *action = new THAction(text, this);
+QAction *THBlackBar::addAction (const QString& text) {
+    QAction *action = new QAction(text, this);
     d->actionList.append(action);
     return(action);
 }
@@ -92,7 +92,7 @@ void THBlackBar::paintEvent (QPaintEvent *event) {
     // Draw Buttons
     // p.translate(0, 4);
     QRect rect(buttonsX, 0, buttonWidth, height);
-    foreach (THAction *action, d->actionList) {
+    foreach (QAction *action, d->actionList) {
         drawButton(&p, rect, action);
         rect.moveLeft(rect.x() + rect.width());
     }
@@ -107,14 +107,15 @@ void THBlackBar::paintEvent (QPaintEvent *event) {
 void THBlackBar::mouseMoveEvent (QMouseEvent *event) {
     QWidget::mouseMoveEvent(event);
 
-    THAction *action = hoveredAction(event->pos());
+    QAction *action = hoveredAction(event->pos());
+
     if (action == NULL && d->hoveredAction != NULL) {
-        d->hoveredAction->hover(false);
+        // d->hoveredAction->hover(false);
         d->hoveredAction = NULL;
         update();
     } else if (action != NULL) {
         d->hoveredAction = action;
-        action->hover(true);
+        action->hover();
         update();
     }
 }
@@ -138,7 +139,7 @@ void THBlackBar::mousePressEvent (QMouseEvent *event) {
     }
 }
 
-THAction *THBlackBar::hoveredAction (const QPoint& pos) const {
+QAction *THBlackBar::hoveredAction (const QPoint& pos) const {
     if (pos.y() <= 0 || pos.y() >= height())
         return(NULL);
 
@@ -168,7 +169,7 @@ int THBlackBar::calculateButtonWidth (void) const {
     smallerBoldFont.setPointSize(smallerBoldFont.pointSize()*.85);
     QFontMetrics fontMetrics(smallerBoldFont);
     int tmpItemWidth, itemWidth = 0;
-    foreach (THAction *action, d->actionList) {
+    foreach (QAction *action, d->actionList) {
         tmpItemWidth = fontMetrics.width(action->text());
         if (itemWidth < tmpItemWidth) itemWidth = tmpItemWidth;
     }
@@ -181,7 +182,7 @@ int THBlackBar::calculateButtonWidth (void) const {
  */
 void THBlackBar::drawUnselectedButton (        QPainter *painter,
                                         const QRect& rect,
-                                        const THAction *action)
+                                        const QAction *action)
 {
     QLinearGradient linearGrad(QPointF(0, 0), QPointF(0, rect.height() / 2));    
     linearGrad.setColorAt(0, QColor(0x8e, 0x8e, 0x8e));
@@ -197,7 +198,7 @@ void THBlackBar::drawUnselectedButton (     QPainter *painter,
 
 void THBlackBar::drawSelectedButton (  QPainter *painter,
                                         const QRect& rect,
-                                        const THAction *action)
+                                        const QAction *action)
 {
     QLinearGradient linearGrad(QPointF(0, 0), QPointF(0, rect.height() / 2));
     linearGrad.setColorAt(0, QColor(0x6d, 0x6d, 0x6d));
@@ -207,7 +208,7 @@ void THBlackBar::drawSelectedButton (       QPainter *painter,
 
 void THBlackBar::drawButton (  QPainter *painter,
                                 const QRect& rect,
-                                const THAction *action)
+                                const QAction *action)
 {
     if (action->isChecked())
         drawSelectedButton(painter, rect, action);
@@ -219,7 +220,7 @@ void THBlackBar::drawButton (       QPainter *painter,
                                 const QRect& rect,
                                 const QLinearGradient& gradient,
                                 const QColor& color,
-                                const THAction *action)
+                                const QAction *action)
 {
     painter->save();
 
index 73e4739f2c3e0c740ecb617ce8a25f7429ce7351..ec0ff1176eb1807d984576a708edcfc1d24ac2e0 100644 (file)
@@ -2,50 +2,51 @@
 #define _THBLACKBAR_H_
 
 #include <QWidget>
-class THAction;
+#include <QAction>
 
 class THBlackBar : public QWidget {
-       Q_OBJECT
-
-       public:
-               THBlackBar (QWidget *parent = 0);
-               ~THBlackBar();
-
-       public:
-               THAction *addAction (THAction *action);
-               THAction *addAction (const QString& text);
-                void setCheckedAction(int index);
-
-               QSize minimumSizeHint (void) const;
-
-       protected:
-               void paintEvent (QPaintEvent *event);
-
-               void mouseMoveEvent (QMouseEvent *event);
-                void mousePressEvent (QMouseEvent *event);
-
-       private:
-               void drawUnselectedButton (     QPainter *painter,
-                                                                       const QRect& rect,
-                                                                       const THAction *action);
-               void drawSelectedButton (       QPainter *painter,
-                                                                       const QRect& rect,
-                                                                       const THAction *action);
-               void drawButton (       QPainter *painter,
-                                                       const QRect& rect,
-                                                       const THAction *action);
-               void drawButton (       QPainter *painter,
-                                                       const QRect& rect,
-                                                       const QLinearGradient& gradient,
-                                                       const QColor& color,
-                                                       const THAction *action);
-
-               THAction *hoveredAction (const QPoint& pos) const;
-               int calculateButtonWidth (void) const;          
-
-       private:
-               class Private;
-               Private *d;
+    
+    Q_OBJECT
+    
+        public:
+    THBlackBar (QWidget *parent = 0);
+    ~THBlackBar();
+    
+        public:
+    QAction *addAction (QAction *action);
+    QAction *addAction (const QString& text);
+    void setCheckedAction(int index);
+    
+    QSize minimumSizeHint (void) const;
+    
+        protected:
+    void paintEvent (QPaintEvent *event);
+    
+    void mouseMoveEvent (QMouseEvent *event);
+    void mousePressEvent (QMouseEvent *event);
+    
+        private:
+    void drawUnselectedButton (        QPainter *painter,
+                                const QRect& rect,
+                                const QAction *action);
+    void drawSelectedButton (  QPainter *painter,
+                                const QRect& rect,
+                                const QAction *action);
+    void drawButton (  QPainter *painter,
+                        const QRect& rect,
+                        const QAction *action);
+    void drawButton (  QPainter *painter,
+                        const QRect& rect,
+                        const QLinearGradient& gradient,
+                        const QColor& color,
+                        const QAction *action);
+    
+    QAction *hoveredAction (const QPoint& pos) const;
+    int calculateButtonWidth (void) const;             
+    
+        private:
+    class Private;
+    Private *d;
 };
 
 #endif /* !_THBLACKBAR_H_ */
index 9d80992a849cab1593e7b53972e13629f7ba05ca..e87b1c37a48fa0f91f24353b7cdf441f2fb1a28d 100644 (file)
@@ -1,9 +1,4 @@
 DEPENDPATH += $$PWD
 INCLUDEPATH += $$PWD
-
-HEADERS += thaction.h \
-           thactiongroup.h \
-           thblackbar.h
-SOURCES += thaction.cpp \
-           thactiongroup.cpp \
-           thblackbar.cpp
+HEADERS += thblackbar.h
+SOURCES += thblackbar.cpp