]> git.sur5r.net Git - minitube/commitdiff
Toolbar redesign
authorFlavio Tordini <flavio.tordini@gmail.com>
Sun, 25 Jul 2010 17:28:34 +0000 (19:28 +0200)
committerFlavio Tordini <flavio.tordini@gmail.com>
Sun, 25 Jul 2010 17:28:34 +0000 (19:28 +0200)
minitube.pro
src/MainWindow.cpp
src/fontutils.cpp [new file with mode: 0644]
src/fontutils.h [new file with mode: 0644]
src/spacer.cpp
src/spacer.h

index 5799830227d2619f0434b2e4c781838e75c84345..cba36bfa9e79e134a81f90bb712e26f43922c19e 100755 (executable)
@@ -1,19 +1,16 @@
 CONFIG += release
 TEMPLATE = app
-VERSION=1.0.1
+VERSION = 1.0.1
 DEFINES += APP_VERSION="$$VERSION"
 INCLUDEPATH += /usr/include/phonon
 
 # TODO Saner string behaviour
 # DEFINES += QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII QT_STRICT_ITERATORS
 TARGET = minitube
-
 QT += network \
     xml \
     phonon
-unix:!mac {
-    QT += dbus
-}
+unix:!mac:QT += dbus
 include(src/qtsingleapplication/qtsingleapplication.pri)
 include(src/thlibrary/thlibrary.pri)
 HEADERS += src/MainWindow.h \
@@ -44,7 +41,8 @@ HEADERS += src/MainWindow.h \
     src/googlesuggest.h \
     src/videowidget.h \
     src/flickcharm.h \
-    src/videodefinition.h
+    src/videodefinition.h \
+    src/fontutils.h
 SOURCES += src/main.cpp \
     src/MainWindow.cpp \
     src/SearchView.cpp \
@@ -72,7 +70,8 @@ SOURCES += src/main.cpp \
     src/videowidget.cpp \
     src/flickcharm.cpp \
     src/videodefinition.cpp \
-    src/constants.cpp
+    src/constants.cpp \
+    src/fontutils.cpp
 RESOURCES += resources.qrc
 DESTDIR = build/target/
 OBJECTS_DIR = build/obj/
@@ -87,8 +86,7 @@ include(locale/locale.pri)
 # deploy
 DISTFILES += CHANGES \
     COPYING
-
-unix {
+unix { 
     isEmpty(PREFIX):PREFIX = /usr
     BINDIR = $$PREFIX/bin
     INSTALLS += target
index d01d9e05930dbd7e7e6afec9f8ac874f581dc7a7..1da7c56c782e75e086e9f3c471fd7e2da7c9e339 100755 (executable)
@@ -4,6 +4,7 @@
 #include "iconloader/qticonloader.h"
 #include "global.h"
 #include "videodefinition.h"
+#include "fontutils.h"
 
 MainWindow::MainWindow() :
         mediaObject(0),
@@ -211,10 +212,13 @@ void MainWindow::createActions() {
     addAction(volumeDownAct);
 
     volumeMuteAct = new QAction(this);
+    volumeMuteAct->setIcon(QtIconLoader::icon("audio-volume-high"));
     volumeMuteAct->setStatusTip(tr("Mute volume"));
-    volumeMuteAct->setShortcuts(QList<QKeySequence>() << QKeySequence(tr("Ctrl+M")) << QKeySequence(Qt::Key_VolumeMute));
+    volumeMuteAct->setShortcuts(QList<QKeySequence>()
+                                << QKeySequence(tr("Ctrl+M"))
+                                << QKeySequence(Qt::Key_VolumeMute));
     actions->insert("volume-mute", volumeMuteAct);
-    connect(volumeMuteAct, SIGNAL(triggered()), this, SLOT(volumeMute()));
+    connect(volumeMuteAct, SIGNAL(triggered()), SLOT(volumeMute()));
     addAction(volumeMuteAct);
 
     QAction *definitionAct = new QAction(this);
@@ -298,22 +302,14 @@ void MainWindow::createMenus() {
 void MainWindow::createToolBars() {
 
     mainToolBar = new QToolBar(this);
-#if QT_VERSION < 0x040600 || defined(Q_WS_MAC)
-    mainToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
+#if QT_VERSION < 0x040600 | defined(Q_WS_MAC)
+    mainToolBar->setToolButtonStyle(Qt::ToolButtonIconOnly);
 #else
     mainToolBar->setToolButtonStyle(Qt::ToolButtonFollowStyle);
 #endif
     mainToolBar->setFloatable(false);
     mainToolBar->setMovable(false);
 
-    QFont smallerFont;
-    smallerFont.setPointSize(smallerFont.pointSize()*.85);
-    QFontInfo fontInfo(smallerFont);
-    if (fontInfo.pixelSize() < 10) {
-        smallerFont.setPixelSize(10);
-    }
-    mainToolBar->setFont(smallerFont);
-
 #ifdef Q_WS_MAC
     mainToolBar->setIconSize(QSize(32, 32));
 #endif
@@ -323,29 +319,48 @@ void MainWindow::createToolBars() {
     mainToolBar->addAction(skipAct);
     mainToolBar->addAction(fullscreenAct);
 
+    mainToolBar->addWidget(new Spacer());
+
+    QFont smallerFont = FontUtils::small();
+    currentTime = new QLabel(mainToolBar);
+    currentTime->setFont(smallerFont);
+    mainToolBar->addWidget(currentTime);
+
+    mainToolBar->addWidget(new Spacer());
+
     seekSlider = new Phonon::SeekSlider(this);
     seekSlider->setIconVisible(false);
-    Spacer *seekSliderSpacer = new Spacer(mainToolBar, seekSlider);
-    seekSliderSpacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
-    mainToolBar->addWidget(seekSliderSpacer);
+    seekSlider->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+    mainToolBar->addWidget(seekSlider);
+
+    mainToolBar->addWidget(new Spacer());
+
+    totalTime = new QLabel(mainToolBar);
+    totalTime->setFont(smallerFont);
+    mainToolBar->addWidget(totalTime);
+
+    mainToolBar->addWidget(new Spacer());
+
+    mainToolBar->addAction(volumeMuteAct);
 
     volumeSlider = new Phonon::VolumeSlider(this);
+    volumeSlider->setMuteVisible(false);
     // qDebug() << volumeSlider->children();
     // status tip for the volume slider
     QSlider* volumeQSlider = volumeSlider->findChild<QSlider*>();
     if (volumeQSlider)
         volumeQSlider->setStatusTip(tr("Press %1 to raise the volume, %2 to lower it").arg(
                 volumeUpAct->shortcut().toString(QKeySequence::NativeText), volumeDownAct->shortcut().toString(QKeySequence::NativeText)));
-    // status tip for the mute button
-    QToolButton* muteToolButton = volumeSlider->findChild<QToolButton*>();
-    if (muteToolButton)
-        muteToolButton->setStatusTip(volumeMuteAct->statusTip());
     // this makes the volume slider smaller
     volumeSlider->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
-    mainToolBar->addWidget(new Spacer(mainToolBar, volumeSlider));
+    mainToolBar->addWidget(volumeSlider);
+
+    mainToolBar->addWidget(new Spacer());
 
     toolbarSearch->setStatusTip(searchFocusAct->statusTip());
-    mainToolBar->addWidget(new Spacer(mainToolBar, toolbarSearch));
+    mainToolBar->addWidget(toolbarSearch);
+
+    mainToolBar->addWidget(new Spacer());
 
     addToolBar(mainToolBar);
 }
@@ -356,12 +371,6 @@ void MainWindow::createStatusBar() {
     // also remove excessive spacing
     statusBar()->setStyleSheet("::item{border:0 solid} QToolBar {padding:0;spacing:0;margin:0}");
 
-    currentTime = new QLabel(this);
-    statusBar()->addPermanentWidget(currentTime);
-
-    totalTime = new QLabel(this);
-    statusBar()->addPermanentWidget(totalTime);
-
     QToolBar *toolBar = new QToolBar(this);
     toolBar->setToolButtonStyle(Qt::ToolButtonTextOnly);
     toolBar->addAction(The::globalActions()->value("definition"));
@@ -707,7 +716,7 @@ void MainWindow::totalTimeChanged(qint64 time) {
         totalTime->clear();
         return;
     }
-    totalTime->setText("/ " + formatTime(time));
+    totalTime->setText(formatTime(time));
 }
 
 QString MainWindow::formatTime(qint64 time) {
@@ -748,10 +757,13 @@ void MainWindow::volumeChanged(qreal newVolume) {
 }
 
 void MainWindow::volumeMutedChanged(bool muted) {
-    if (muted)
+    if (muted) {
+        volumeMuteAct->setIcon(QtIconLoader::icon("audio-volume-muted"));
         statusBar()->showMessage(tr("Volume is muted"));
-    else
+    } else {
+        volumeMuteAct->setIcon(QtIconLoader::icon("audio-volume-high"));
         statusBar()->showMessage(tr("Volume is unmuted"));
+    }
 }
 
 void MainWindow::setDefinitionMode(QString definitionName) {
diff --git a/src/fontutils.cpp b/src/fontutils.cpp
new file mode 100644 (file)
index 0000000..05384b8
--- /dev/null
@@ -0,0 +1,43 @@
+#include "fontutils.h"
+
+const QFont FontUtils::small() {
+    static QFont font;
+    static bool initialized = false;
+    if (!initialized) {
+      initialized = true;
+      font.setPointSize(font.pointSize()*.85);
+    }
+    return font;
+}
+
+const QFont FontUtils::smallBold() {
+    static QFont font;
+    static bool initialized = false;
+    if (!initialized) {
+      initialized = true;
+      font.setPointSize(font.pointSize()*.85);
+      font.setBold(true);
+    }
+    return font;
+}
+
+const QFont FontUtils::big() {
+    static QFont font;
+    static bool initialized = false;
+    if (!initialized) {
+      initialized = true;
+      font.setPointSize(font.pointSize()*1.5);
+    }
+    return font;
+}
+
+const QFont FontUtils::bigBold() {
+    static QFont font;
+    static bool initialized = false;
+    if (!initialized) {
+      initialized = true;
+      font.setPointSize(font.pointSize()*1.5);
+      font.setBold(true);
+    }
+    return font;
+}
diff --git a/src/fontutils.h b/src/fontutils.h
new file mode 100644 (file)
index 0000000..5fe99db
--- /dev/null
@@ -0,0 +1,16 @@
+#ifndef FONTUTILS_H
+#define FONTUTILS_H
+
+#include <QFont>
+
+class FontUtils {
+
+public:
+    static const QFont small();
+    static const QFont smallBold();
+    static const QFont big();
+    static const QFont bigBold();
+
+};
+
+#endif // FONTUTILS_H
index d71367ab418d752aca67a8e10e9828591b4fee67..95594fc82966f21386006c0f1e6bbed594c39c1f 100644 (file)
@@ -1,7 +1,7 @@
 #include "spacer.h"
 
-Spacer::Spacer(QWidget *parent, QWidget *child) : QWidget(parent) {
-    QBoxLayout *layout = new QHBoxLayout();
-    layout->addWidget(child);
-    setLayout(layout);
+Spacer::Spacer(QWidget *parent) : QWidget(parent) { }
+
+QSize Spacer::sizeHint() const {
+    return QSize(10, 1);
 }
index 668001f38d5afadb878ae6ec9133b214b76b97cc..3d1f44fed4600005592e85d97bbb0ee7acc242f1 100644 (file)
@@ -3,10 +3,13 @@
 
 #include <QtGui>
 
-class Spacer : public QWidget
-{
+class Spacer : public QWidget {
+
 public:
-    Spacer(QWidget *parent, QWidget *child);
+    Spacer(QWidget *parent = 0);
+
+protected:
+    QSize sizeHint() const;
 };
 
 #endif // SPACER_H