From: Flavio Tordini Date: Sun, 25 Jul 2010 17:28:34 +0000 (+0200) Subject: Toolbar redesign X-Git-Tag: 1.2~39 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=82d65a3ea3e725333e0ad3b07aea22ecfbd6404e;p=minitube Toolbar redesign --- diff --git a/minitube.pro b/minitube.pro index 5799830..cba36bf 100755 --- a/minitube.pro +++ b/minitube.pro @@ -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 diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index d01d9e0..1da7c56 100755 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -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(tr("Ctrl+M")) << QKeySequence(Qt::Key_VolumeMute)); + volumeMuteAct->setShortcuts(QList() + << 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(); 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(); - 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 index 0000000..05384b8 --- /dev/null +++ b/src/fontutils.cpp @@ -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 index 0000000..5fe99db --- /dev/null +++ b/src/fontutils.h @@ -0,0 +1,16 @@ +#ifndef FONTUTILS_H +#define FONTUTILS_H + +#include + +class FontUtils { + +public: + static const QFont small(); + static const QFont smallBold(); + static const QFont big(); + static const QFont bigBold(); + +}; + +#endif // FONTUTILS_H diff --git a/src/spacer.cpp b/src/spacer.cpp index d71367a..95594fc 100644 --- a/src/spacer.cpp +++ b/src/spacer.cpp @@ -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); } diff --git a/src/spacer.h b/src/spacer.h index 668001f..3d1f44f 100644 --- a/src/spacer.h +++ b/src/spacer.h @@ -3,10 +3,13 @@ #include -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