Author: JirkaH Date: 2010-02-11 11:18:47 +0100 (Thu, 11 Feb 2010) New Revision: 1708 Added: branches/client/pdf-presentation-branch/elvys-client/bin/data/logo.png branches/client/pdf-presentation-branch/elvys-client/src/logotabbar.cpp branches/client/pdf-presentation-branch/elvys-client/src/logotabbar.h Modified: branches/client/pdf-presentation-branch/elvys-client/Makefile branches/client/pdf-presentation-branch/elvys-client/src/Makefile branches/client/pdf-presentation-branch/elvys-client/src/categorymanager.cpp branches/client/pdf-presentation-branch/elvys-client/src/categorymanager.h branches/client/pdf-presentation-branch/elvys-client/src/src.pro Log: Logo displayed now Modified: branches/client/pdf-presentation-branch/elvys-client/Makefile =================================================================== --- branches/client/pdf-presentation-branch/elvys-client/Makefile 2010-02-10 23:08:06 UTC (rev 1707) +++ branches/client/pdf-presentation-branch/elvys-client/Makefile 2010-02-11 10:18:47 UTC (rev 1708) @@ -1,6 +1,6 @@ ############################################################################# # Makefile for building: elvys-client -# Generated by qmake (2.01a) (Qt 4.5.3) on: Wed Feb 10 10:48:49 2010 +# Generated by qmake (2.01a) (Qt 4.5.3) on: Wed Feb 10 23:04:57 2010 # Project: elvys-client.pro # Template: subdirs # Command: /usr/bin/qmake -spec /usr/share/qt4/mkspecs/linux-g++ -unix CONFIG+=debug_and_release -o Makefile elvys-client.pro Added: branches/client/pdf-presentation-branch/elvys-client/bin/data/logo.png =================================================================== (Binary files differ) Property changes on: branches/client/pdf-presentation-branch/elvys-client/bin/data/logo.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: branches/client/pdf-presentation-branch/elvys-client/src/Makefile =================================================================== --- branches/client/pdf-presentation-branch/elvys-client/src/Makefile 2010-02-10 23:08:06 UTC (rev 1707) +++ branches/client/pdf-presentation-branch/elvys-client/src/Makefile 2010-02-11 10:18:47 UTC (rev 1708) @@ -1,6 +1,6 @@ ############################################################################# # Makefile for building: ../bin/elvys-client -# Generated by qmake (2.01a) (Qt 4.5.3) on: Wed Feb 10 10:48:49 2010 +# Generated by qmake (2.01a) (Qt 4.5.3) on: Thu Feb 11 11:03:45 2010 # Project: src.pro # Template: app # Command: /usr/bin/qmake -spec /usr/share/qt4/mkspecs/linux-g++ -unix CONFIG+=debug_and_release -o Makefile src.pro Modified: branches/client/pdf-presentation-branch/elvys-client/src/categorymanager.cpp =================================================================== --- branches/client/pdf-presentation-branch/elvys-client/src/categorymanager.cpp 2010-02-10 23:08:06 UTC (rev 1707) +++ branches/client/pdf-presentation-branch/elvys-client/src/categorymanager.cpp 2010-02-11 10:18:47 UTC (rev 1708) @@ -13,24 +13,24 @@ connect(catDocMaint, SIGNAL(newCategoryDocuments(int,int)), this, SLOT(gotNewCategoryDocuments(int,int))); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - tabBar = new QTabBar(); - tabBar->setDocumentMode(true); - tabBar->setExpanding(true); - tabBar->setDrawBase(true); - setTabBar(tabBar); + QString logoFileName = "data/logo.png"; + tBar = new LogoTabBar(this, logoFileName, "PNG"); + tBar->setDocumentMode(true); + tBar->setExpanding(true); + tBar->setDrawBase(true); + setTabBar(tBar); setTabPosition(QTabWidget::South); QFont font; font.setPointSize(TAB_FONT_SIZE); - tabBar->setFont(font); - + tBar->setFont(font); } CategoryManager::~CategoryManager() { delete catLayoutMaint; delete catDocMaint; - delete tabBar; + delete tBar; } void CategoryManager::manage() { @@ -271,7 +271,6 @@ cat->readDocumentConfig(catDocMaint->fileName(), catDocMaint->charOffset(), layId); } - void CategoryManager::keyPressEvent ( QKeyEvent * event ) { int tabCount = count(); Modified: branches/client/pdf-presentation-branch/elvys-client/src/categorymanager.h =================================================================== --- branches/client/pdf-presentation-branch/elvys-client/src/categorymanager.h 2010-02-10 23:08:06 UTC (rev 1707) +++ branches/client/pdf-presentation-branch/elvys-client/src/categorymanager.h 2010-02-11 10:18:47 UTC (rev 1708) @@ -8,8 +8,10 @@ #include <QMap> #include "categorymaintainerdoc.h" #include "categorymaintainerlayout.h" +#include "logotabbar.h" #include "category.h" + class CategoryManager : public QTabWidget { Q_OBJECT @@ -35,9 +37,9 @@ QStringList getUsedFilesList(); protected: - void keyPressEvent ( QKeyEvent * event ); + void keyPressEvent ( QKeyEvent * event ); - private: + private: void updateFontSize(); Category * newCategory(int id, QString &name); void manageOrder(); @@ -46,7 +48,7 @@ CategoryMaintainerDoc * catDocMaint; CategoryMaintainerLayout * catLayoutMaint; - QTabBar * tabBar; + LogoTabBar * tBar; QMap<int, int> orderMap; QList<Category *> categories; QMap<int, bool> categoriesFound; Added: branches/client/pdf-presentation-branch/elvys-client/src/logotabbar.cpp =================================================================== --- branches/client/pdf-presentation-branch/elvys-client/src/logotabbar.cpp (rev 0) +++ branches/client/pdf-presentation-branch/elvys-client/src/logotabbar.cpp 2010-02-11 10:18:47 UTC (rev 1708) @@ -0,0 +1,35 @@ +#include "logotabbar.h" + +/** Class constructor. + @param parent parent widget + @param fileName file name of the image that should be shown on the bar + @param format format of the image. Uses the same syntax as Qt functions (see QPixmap::load for example) + */ + +LogoTabBar::LogoTabBar(QWidget * parent, QString & fileName, const char * format) : QTabBar(parent) { + cornerOrigPixmap.load(fileName, format); +} + + +/** Reimplementation of resizeEvent. It makes sure that the image is rescaled corectlly + @param event structure containg information about the event + */ + +void LogoTabBar::resizeEvent(QResizeEvent * event) { + cornerPixmap = cornerOrigPixmap.scaled(size(), Qt::KeepAspectRatio, Qt::SmoothTransformation); + event->ignore(); +} + +/** Reimplementation of paintEvent. It actualy does the painting of the image. Please note that the original QTabBar::paintEvent is called + to preserve the look of potentionaly styled bars. + @param event structure containg information about the event + */ + +void LogoTabBar::paintEvent(QPaintEvent * event) { + QPainter painter; + QTabBar::paintEvent(event); + setUsesScrollButtons(false); + painter.begin(this); + painter.drawPixmap(width() - cornerPixmap.width(), height()- cornerPixmap.height(), cornerPixmap); + painter.end(); +} Added: branches/client/pdf-presentation-branch/elvys-client/src/logotabbar.h =================================================================== --- branches/client/pdf-presentation-branch/elvys-client/src/logotabbar.h (rev 0) +++ branches/client/pdf-presentation-branch/elvys-client/src/logotabbar.h 2010-02-11 10:18:47 UTC (rev 1708) @@ -0,0 +1,29 @@ +#ifndef LOGOTABBAR_H +#define LOGOTABBAR_H + +#include <QTabBar> +#include <QPaintEvent> +#include <QResizeEvent> +#include <QPainter> +#include <QString> + +/** This is fairly simple extension of QTabBar. It is given a picture that will be displayed in the right corner of the widget. + It has basicaly same purpose as CornerWidget, but in case of using Qt StyleSheet feature, it is much more predicable and stable. + + The picture is automatically resized (keeping its aspect ratio) to fill into tab bar. + */ + +class LogoTabBar : public QTabBar { + public: + LogoTabBar(QWidget * widget, QString & fileName, const char * format); + + protected: + void paintEvent(QPaintEvent * event); + void resizeEvent(QResizeEvent * event); + + private: + QPixmap cornerOrigPixmap, cornerPixmap; +}; + + +#endif // LOGOTABBAR_H Modified: branches/client/pdf-presentation-branch/elvys-client/src/src.pro =================================================================== --- branches/client/pdf-presentation-branch/elvys-client/src/src.pro 2010-02-10 23:08:06 UTC (rev 1707) +++ branches/client/pdf-presentation-branch/elvys-client/src/src.pro 2010-02-11 10:18:47 UTC (rev 1708) @@ -45,7 +45,8 @@ videodocument.cpp \ autodeleter.cpp \ xmlfilecacheparser.cpp \ - filecachemaintainer.cpp + filecachemaintainer.cpp \ + logotabbar.cpp HEADERS += elvys.h \ pdfdocument.h \ pdffiller.h \ @@ -93,7 +94,8 @@ videodocument.h \ autodeleter.h \ xmlfilecacheparser.h \ - filecachemaintainer.h + filecachemaintainer.h \ + logotabbar.h TEMPLATE = app CONFIG += warn_on \ thread \