diff --git a/ChangeLog b/ChangeLog index a2b74e92c..4f883b1df 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,72 @@ +2006-01-16 Tobias Doerffel + + * src/lib/mmp.cpp: + do not add "mmp"-extensions if there's already "mpt" (multimedia- + project-template) as extension + + * include/arp_and_chords_tab_widget.h: + * src/core/arp_and_chords_tab_widget.cpp: + - added new sync-mode to arpeggiator + - arpeggiator-modes are now selectable from combobox + +2006-01-15 Tobias Doerffel + + * src/core/file_browser.cpp: + use 7.5 instead of 8 as font-size + + * src/widgets/led_checkbox.cpp: + use 7.5 instead of 7 as font-size + + * include/gui_templates.h: + - added more precise pointSizeF()-method + - more precise point-size-calculation for pointSize()-method which + makes all fonts inside LMMS a bit bigger and everything more + readable + + * include/setup_dialog.h: + * src/core/note_play_handle.cpp: + * src/core/setup_dialog.cpp: + * src/tracks/channel_track.cpp: + added switches for disabling several UI-effects for a better + performance even on older hardware + + * include/preset_preview_play_handle.h: + * src/core/preset_preview_play_handle.cpp: + global-data-mutex is not a pointer anymore, instead it's a normal + QMutex - fixes crashes with sort-arpeggio if no preset was previewed + before + +2006-01-14 Tobias Doerffel + + * src/widgets/kmultitabbar.cpp: + made KMultiTabBar working with Qt4 + + * src/audio/audio_jack.cpp: + return if connection to JACK-server failed with old JACK-API + (jack_client_new(...)) - fixes crash when using old JACK-API with + LMMS and JACK-server is not running + + * include/preset_preview_play_handle.h: + * src/core/arp_and_chords_tab_widget.cpp: + * src/core/preset_preview_play_handle.cpp: + as preset-note-play-handle is not registered at mixer, it cannot be + returned in notePlayHandle::nphsOfChannelTrack() and therefore + previewing presets with sort-mode arpeggios doesn't work - now the + arpeggiator also checks preview-note for being the only note there + + * src/core/arp_and_chords_tab_widget.cpp: + fixed some bugs in arpeggiator + + * src/core/piano_roll.cpp: + lock qapp-thread in recordNote() - hopefully fixes some + xlib-async-errors + + * src/tracks/channel_track.cpp: + - do not process note-on-out-events if according key is already pressed + - when invalidating note-play-handles, also reset m_notes-array for not + crashing when applying another preset while key is pressed and + released afterwards + 2006-01-10 Alexey Kouznetsov * locale/ru.ts: diff --git a/Makefile.am b/Makefile.am index 6387f0087..69461aa2b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -56,6 +56,7 @@ lmms_MOC = \ ./file_browser.moc \ ./group_box.moc \ ./kmultitabbar.moc \ + ./kmultitabbar-qt3.moc \ ./knob.moc \ ./lcd_spinbox.moc \ ./led_checkbox.moc \ @@ -227,6 +228,7 @@ lmms_SOURCES = \ $(srcdir)/include/gui_templates.h \ $(srcdir)/include/surround_area.h \ $(srcdir)/include/kmultitabbar.h \ + $(srcdir)/include/kmultitabbar-qt3.h \ $(srcdir)/include/side_bar.h \ $(srcdir)/include/side_bar_widget.h \ $(srcdir)/include/track.h \ diff --git a/TODO b/TODO index ff933cbbe..302d3681c 100644 --- a/TODO +++ b/TODO @@ -1,10 +1,9 @@ to be done as soon as possible: -- debug arpeggio with certain times (TB303-arp!) -- fix bug with recording on arpeggio-channel -- do not skip samples because of rounding when resampling in src/lib/sample_buffer.cpp +- performance-settings +- arp-sync-mode +- do not skip samples because of rounding-errors when resampling in src/lib/sample_buffer.cpp - MIDI-program/MIDI-mapping/process program-/channel-change-events from MIDI-files -- do not allow to connect output-port of channel to own input-port! - add note-len- and note-alignment-selectbox to piano-roll - DSSI-support - somehow avoid hidden plugin-descriptor-widgets plugin-browser if height of window is too small -> add scrollbar diff --git a/acinclude.m4 b/acinclude.m4 index c5ca4133e..2efbab063 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -9,7 +9,7 @@ AC_ARG_WITH([qtdir], [ --with-qtdir=DIR Qt installation directory [defau # Check that QTDIR is defined or that --with-qtdir given if test x"$QTDIR" = x ; then # some usual Qt-locations - QT_SEARCH="/usr /usr/lib/qt /usr/lib/qt3 /usr/lib/qt31 /usr/lib/qt32 /usr/lib/qt33 /usr/lib/qt-3.0 /usr/lib/qt-3.1 /usr/lib/qt-3.2 /usr/lib/qt-3.3 usr/local/qt /usr/local/qt3 /usr/local/qt31/ /usr/local/qt32 /usr/local/qt33 /usr/X11R6 /usr/local/Trolltech/Qt-4.0.0" + QT_SEARCH="/usr /usr/lib/qt /usr/lib/qt3 /usr/lib/qt31 /usr/lib/qt32 /usr/lib/qt33 /usr/lib/qt-3.0 /usr/lib/qt-3.1 /usr/lib/qt-3.2 /usr/lib/qt-3.3 usr/local/qt /usr/local/qt3 /usr/local/qt31/ /usr/local/qt32 /usr/local/qt33 /usr/share/qt3 /usr/X11R6 /usr/share/qt4 /usr/local/Trolltech/Qt-4.0.0 /usr/local/Trolltech/Qt-4.0.1 /usr/local/Trolltech/Qt-4.1.0" else QT_SEARCH=$QTDIR QTDIR="" @@ -141,6 +141,7 @@ case "${host}" in QT_IS_MT="yes" QT_LIB="-lQtCore -lQtGui -lQtXml -lQt3Support" else + QT_CXXFLAGS="-DQT3 $QT_CXXFLAGS" if test "x`ls $QTDIR/lib/libqt-mt.* 2> /dev/null`" != x ; then QT_LIB="-lqt-mt" QT_IS_MT="yes" diff --git a/configure.in b/configure.in index 038f66844..775382dbd 100644 --- a/configure.in +++ b/configure.in @@ -2,8 +2,8 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.50) -AC_INIT(lmms, 0.1.2-cvs20060110, tobydox/at/users.sourceforge.net) -AM_INIT_AUTOMAKE(lmms, 0.1.2-cvs20060110) +AC_INIT(lmms, 0.1.2-cvs20060116, tobydox/at/users.sourceforge.net) +AM_INIT_AUTOMAKE(lmms, 0.1.2-cvs20060116) AM_CONFIG_HEADER(config.h) diff --git a/include/arp_and_chords_tab_widget.h b/include/arp_and_chords_tab_widget.h index 21c55bf8e..248f86ddd 100644 --- a/include/arp_and_chords_tab_widget.h +++ b/include/arp_and_chords_tab_widget.h @@ -115,6 +115,13 @@ private: RANDOM } m_arpDirection; + enum arpModes + { + FREE, + SORT, + SYNC + } ; + // chord-stuff groupBox * m_chordsGroupBox; QComboBox * m_chordsComboBox; @@ -133,7 +140,7 @@ private: pixmapButton * m_arpUpAndDownBtn; pixmapButton * m_arpRandomBtn; - ledCheckBox * m_sortMode; + QComboBox * m_arpModeComboBox; } ; diff --git a/include/gui_templates.h b/include/gui_templates.h index 026604f43..627bc4124 100644 --- a/include/gui_templates.h +++ b/include/gui_templates.h @@ -1,7 +1,7 @@ /* * gui_templates.h - GUI-specific templates * - * Copyright (c) 2005 Tobias Doerffel + * Copyright (c) 2005-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -48,6 +48,20 @@ // the same size in pixels template inline QFont pointSize( QFont _f ) +{ + static const int DPI = 96; +#ifdef QT4 + _f.setPointSizeF( (float) SIZE * DPI / + QApplication::desktop()->logicalDpiY() ); +#else + _f.setPointSizeFloat( (float) SIZE * DPI / + QPaintDeviceMetrics( qApp->desktop() ).logicalDpiY() ); +#endif + return( _f ); +} + + +inline QFont pointSizeF( QFont _f, float SIZE ) { static const int DPI = 96; #ifdef QT4 diff --git a/include/kmultitabbar-qt3.h b/include/kmultitabbar-qt3.h new file mode 100644 index 000000000..8842ba26e --- /dev/null +++ b/include/kmultitabbar-qt3.h @@ -0,0 +1,296 @@ +/*************************************************************************** + kmultitabbar.h - description + ------------------- + begin : 2001 + copyright : (C) 2001,2002,2003 by Joseph Wenninger + ***************************************************************************/ + +/*************************************************************************** + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + ***************************************************************************/ + +#ifndef _KMultitabbar_qt3_h_ +#define _KMultitabbar_qt3_h_ + +#include "qt3support.h" + +#include +#include +#include +#include +#include +#include +#include + +class KMultiTabBarButton; +class KMultiTabBarTab; + +typedef QPtrList buttonList; +typedef QPtrList tabList; + + +class QPixmap; +class QPainter; +class QFrame; + +class KMultiTabBarPrivate; +class KMultiTabBarTabPrivate; +class KMultiTabBarButtonPrivate; +class KMultiTabBarInternal; + +/** + * A Widget for horizontal and vertical tabs. + * It is possible to add normal buttons to the top/left + * The handling if only one tab at a time or multiple tabs + * should be raisable is left to the "user". + *@author Joseph Wenninger + */ +class KMultiTabBar: public QWidget +{ + Q_OBJECT +public: + enum KMultiTabBarMode{ Horizontal, Vertical }; + enum KMultiTabBarPosition{Left, Right, Top, Bottom}; + + /** + * VSNET == Visual Studio .Net like (only show the text of active tabs + * KDEV3 == Kdevelop 3 like (always show the text) + * KONQSBC == konqy's classic sidebar style (unthemed), this one is disabled + * at the moment, but will be renabled soon too + */ + enum KMultiTabBarStyle{VSNET=0, KDEV3=1, KONQSBC=2, KDEV3ICON=3,STYLELAST=0xffff}; + + KMultiTabBar(KMultiTabBarMode m,QWidget *parent=0); + virtual ~KMultiTabBar(); + + /** + * append a new button to the button area. The button can later on be accessed with button(ID) + * eg for connecting signals to it + * @param pic a pixmap for the button + * @param id an arbitraty ID value. It will be emitted in the clicked signal for identifying the button + * if more than one button is connected to a signals. + * @param popup A popup menu which should be displayed if the button is clicked + * @param not_used_yet will be used for a popup text in the future + */ + int appendButton(const QPixmap &pic,int id=-1,QMenu* popup=0,const QString& not_used_yet=QString::null); + /** + * remove a button with the given ID + */ + void removeButton(int id); + /** + * append a new tab to the tab area. It can be accessed lateron with tabb(id); + * @param pic a bitmap for the tab + * @param id an arbitrary ID which can be used later on to identify the tab + * @param text if a mode with text is used it will be the tab text, otherwise a mouse over hint + */ + int appendTab(const QPixmap &pic,int id=-1,const QString& text=QString::null); + /** + * remove a tab with a given ID + */ + void removeTab(int id); + /** + * set a tab to "raised" + * @param id The ID of the tab to manipulate + * @param state true == activated/raised, false == not active + */ + void setTab(int id ,bool state); + /** + * return the state of a tab, identified by it's ID + */ + bool isTabRaised(int id) const; + /** + * get a pointer to a button within the button area identified by its ID + */ + class KMultiTabBarButton *button(int id) const; + + /** + * get a pointer to a tab within the tab area, identiifed by its ID + */ + class KMultiTabBarTab *tab(int id) const; + /** + * set the real position of the widget. + * @param pos if the mode is horizontal, only use top, bottom, if it is vertical use left or right + */ + void setPosition(KMultiTabBarPosition pos); + /** + * set the display style of the tabs + */ + void setStyle(KMultiTabBarStyle style); + /** + * be carefull, don't delete tabs yourself and don't delete the list itself + */ + tabList * tabs(); + /** + * be carefull, don't delete buttons yourself and don't delete the list itself + */ + buttonList * buttons(); + + /** + * might vanish, not sure yet + */ + void showActiveTabTexts(bool show=true); +protected: + friend class KMultiTabBarButton; + virtual void fontChange( const QFont& ); + void updateSeparator(); +private: + class KMultiTabBarInternal *m_internal; + QBoxLayout *m_l; + QFrame *m_btnTabSep; + buttonList m_buttons; + KMultiTabBarPosition m_position; + KMultiTabBarPrivate *d; +}; + +/** + * This class should never be created except with the appendButton call of KMultiTabBar + */ +class KMultiTabBarButton: public QPushButton +{ + Q_OBJECT +public: + KMultiTabBarButton(const QPixmap& pic,const QString&, QMenu *popup, + int id,QWidget *parent, KMultiTabBar::KMultiTabBarPosition pos, KMultiTabBar::KMultiTabBarStyle style); + KMultiTabBarButton(const QString&, QMenu *popup, + int id,QWidget *parent, KMultiTabBar::KMultiTabBarPosition pos, KMultiTabBar::KMultiTabBarStyle style); + virtual ~KMultiTabBarButton(); + int id() const; + +public slots: + /** + * this is used internaly, but can be used by the user, if (s)he wants to + * It the according call of KMultiTabBar is invoked though this modifications will be overwritten + */ + void setPosition(KMultiTabBar::KMultiTabBarPosition); + /** + * this is used internaly, but can be used by the user, if (s)he wants to + * It the according call of KMultiTabBar is invoked though this modifications will be overwritten + */ + void setStyle(KMultiTabBar::KMultiTabBarStyle); + + /** + * modify the text of the button + */ + void setText(const QString &); + + QSize sizeHint() const; + +protected: + KMultiTabBar::KMultiTabBarPosition m_position; + KMultiTabBar::KMultiTabBarStyle m_style; + QString m_text; + virtual void hideEvent( class QHideEvent*); + virtual void showEvent( class QShowEvent*); +private: + int m_id; + KMultiTabBarButtonPrivate *d; +signals: + /** + * this is emitted if the button is clicked + * @param id the ID identifying the button + */ + void clicked(int id); +protected slots: + virtual void slotClicked(); +}; + +/** + * This class should never be created except with the appendTab call of KMultiTabBar + */ +class KMultiTabBarTab: public KMultiTabBarButton +{ + Q_OBJECT +public: + KMultiTabBarTab(const QPixmap& pic,const QString&,int id,QWidget *parent, + KMultiTabBar::KMultiTabBarPosition pos,KMultiTabBar::KMultiTabBarStyle style); + virtual ~KMultiTabBarTab(); + /** + * set the active state of the tab + * @param state true==active false==not active + */ + void setState(bool state); + /** + * choose if the text should always be displayed + * this is only used in classic mode if at all + */ + void showActiveTabText(bool show); + void resize(){ setSize( neededSize() ); } + virtual inline const QColorGroup & palette( void ) const + { + return( colorGroup() ); + } +private: + bool m_showActiveTabText; + int m_expandedSize; + KMultiTabBarTabPrivate *d; +protected: + friend class KMultiTabBarInternal; + void setSize(int); + int neededSize(); + void updateState(); + virtual void drawButton(QPainter *); + virtual void drawButtonLabel(QPainter *); + void drawButtonStyled(QPainter *); + void drawButtonClassic(QPainter *); +protected slots: + virtual void slotClicked(); + void setTabsPosition(KMultiTabBar::KMultiTabBarPosition); + +public slots: + virtual void setIcon(const QString&); + virtual void setIcon(const QPixmap&); +}; + + + +class KMultiTabBarInternal: public Q3ScrollView +{ + Q_OBJECT +public: + KMultiTabBarInternal(QWidget *parent, KMultiTabBar::KMultiTabBarMode m); + int appendTab(const QPixmap &,int=-1,const QString& =QString::null); + KMultiTabBarTab *tab(int) const; + void removeTab(int); + void setPosition(enum KMultiTabBar::KMultiTabBarPosition pos); + void setStyle(enum KMultiTabBar::KMultiTabBarStyle style); + void showActiveTabTexts(bool show); + tabList * tabs(){return &m_tabs;} + virtual inline const QColorGroup & palette( void ) const + { + return( colorGroup() ); + } +private: + friend class KMultiTabBar; + QWidget *box; + QBoxLayout *mainLayout; + tabList m_tabs; + enum KMultiTabBar::KMultiTabBarPosition m_position; + bool m_showActiveTabTexts; + enum KMultiTabBar::KMultiTabBarStyle m_style; + int m_expandedTabSize; + int m_lines; +protected: + /** + * [contentsM|m]ousePressEvent are reimplemented from QScrollView + * in order to ignore all mouseEvents on the viewport, so that the + * parent can handle them. + */ + virtual void contentsMousePressEvent(QMouseEvent *); + virtual void mousePressEvent(QMouseEvent *); + virtual void resizeEvent(QResizeEvent *); +}; + +#endif diff --git a/include/kmultitabbar.h b/include/kmultitabbar.h index fee6bbcdb..15c96c16f 100644 --- a/include/kmultitabbar.h +++ b/include/kmultitabbar.h @@ -1,8 +1,8 @@ /*************************************************************************** kmultitabbar.h - description ------------------- - begin : 2001 - copyright : (C) 2001,2002,2003 by Joseph Wenninger + begin : 2001 + copyright : (C) 2001,2002,2003 by Joseph Wenninger ***************************************************************************/ /*************************************************************************** @@ -18,50 +18,24 @@ You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. ***************************************************************************/ #ifndef _KMultitabbar_h_ #define _KMultitabbar_h_ -#include "qt3support.h" +#ifndef QT3 -class KMultiTabBarButton; -class KMultiTabBarTab; - -#ifdef QT4 - -#include -#include +#include #include -#include #include -#include #include -typedef QList buttonList; -typedef QList tabList; - -#else - -#include -#include -#include -#include -#include -#include -#include - -typedef QPtrList buttonList; -typedef QPtrList tabList; - -#endif - - class QPixmap; class QPainter; class QFrame; +class QMenu; class KMultiTabBarPrivate; class KMultiTabBarTabPrivate; @@ -79,18 +53,18 @@ class KMultiTabBar: public QWidget { Q_OBJECT public: - //enum KMultiTabBarMode{ Horizontal, Vertical }; - enum KMultiTabBarPosition{DockLeft, DockRight, DockTop, DockBottom}; + enum KMultiTabBarMode{Horizontal, Vertical}; + enum KMultiTabBarPosition{Left, Right, Top, Bottom}; /** - * VSNET == Visual Studio .Net like (only show the text of active tabs - * KDEV3 == Kdevelop 3 like (always show the text) - * KONQSBC == konqy's classic sidebar style (unthemed), this one is disabled - * at the moment, but will be renabled soon too + * The list of available styles for KMultiTabBar + * - VSNET - Visual Studio .Net like (only show the text of active tabs + * - KDEV3 - Kdevelop 3 like (always show the text) + * - KONQSBC - konqy's classic sidebar style (unthemed) (currently disabled) */ enum KMultiTabBarStyle{VSNET=0, KDEV3=1, KONQSBC=2, KDEV3ICON=3,STYLELAST=0xffff}; - KMultiTabBar(Qt::Orientation o,QWidget *parent=0); + KMultiTabBar(KMultiTabBarMode bm,QWidget *parent=0 ); virtual ~KMultiTabBar(); /** @@ -102,8 +76,8 @@ public: * @param popup A popup menu which should be displayed if the button is clicked * @param not_used_yet will be used for a popup text in the future */ - int appendButton(const QPixmap &pic,int id=-1,QMenu* popup=0,const QString& not_used_yet=QString::null); - /** + int appendButton(const QPixmap &pic,int id=-1,QMenu* popup=0,const QString& not_used_yet=QString()); + /** * remove a button with the given ID */ void removeButton(int id); @@ -113,7 +87,7 @@ public: * @param id an arbitrary ID which can be used later on to identify the tab * @param text if a mode with text is used it will be the tab text, otherwise a mouse over hint */ - int appendTab(const QPixmap &pic,int id=-1,const QString& text=QString::null); + int appendTab(const QPixmap &pic,int id=-1,const QString& text=QString()); /** * remove a tab with a given ID */ @@ -142,18 +116,28 @@ public: * @param pos if the mode is horizontal, only use top, bottom, if it is vertical use left or right */ void setPosition(KMultiTabBarPosition pos); + /** + * get the tabbar position. + * @return position + */ + KMultiTabBarPosition position() const; /** * set the display style of the tabs */ void setStyle(KMultiTabBarStyle style); + /** + * get the display style of the tabs + * @return display style + */ + KMultiTabBarStyle tabStyle() const; /** * be carefull, don't delete tabs yourself and don't delete the list itself */ - tabList * tabs(); + QList* tabs(); /** * be carefull, don't delete buttons yourself and don't delete the list itself */ - buttonList * buttons(); + QList* buttons(); /** * might vanish, not sure yet @@ -167,7 +151,7 @@ private: class KMultiTabBarInternal *m_internal; QBoxLayout *m_l; QFrame *m_btnTabSep; - buttonList m_buttons; + QList m_buttons; KMultiTabBarPosition m_position; KMultiTabBarPrivate *d; }; @@ -245,12 +229,6 @@ public: */ void showActiveTabText(bool show); void resize(){ setSize( neededSize() ); } -#ifndef QT4 - virtual inline const QColorGroup & palette( void ) const - { - return( colorGroup() ); - } -#endif private: bool m_showActiveTabText; int m_expandedSize; @@ -260,6 +238,7 @@ protected: void setSize(int); int neededSize(); void updateState(); + virtual void paintEvent(QPaintEvent *); virtual void drawButton(QPainter *); virtual void drawButtonLabel(QPainter *); void drawButtonStyled(QPainter *); @@ -272,48 +251,66 @@ public slots: virtual void setIcon(const QString&); virtual void setIcon(const QPixmap&); }; +/*************************************************************************** + kmultitabbar_p.h - description + ------------------- + begin : 2003 + copyright : (C) 2003 by Joseph Wenninger + ***************************************************************************/ + +/*************************************************************************** + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. + ***************************************************************************/ - -class KMultiTabBarInternal: public Q3ScrollView +class KMultiTabBarInternal: public QWidget { Q_OBJECT public: - KMultiTabBarInternal(QWidget *parent,Qt::Orientation o); - int appendTab(const QPixmap &,int=-1,const QString& =QString::null); + KMultiTabBarInternal(QWidget *parent,KMultiTabBar::KMultiTabBarMode bm); + int appendTab(const QPixmap &,int=-1,const QString& =QString()); KMultiTabBarTab *tab(int) const; void removeTab(int); void setPosition(enum KMultiTabBar::KMultiTabBarPosition pos); void setStyle(enum KMultiTabBar::KMultiTabBarStyle style); void showActiveTabTexts(bool show); - tabList * tabs(){return &m_tabs;} -#ifndef QT4 - virtual inline const QColorGroup & palette( void ) const - { - return( colorGroup() ); - } -#endif + QList* tabs(){return &m_tabs;} private: friend class KMultiTabBar; QWidget *box; QBoxLayout *mainLayout; - tabList m_tabs; + QList m_tabs; enum KMultiTabBar::KMultiTabBarPosition m_position; bool m_showActiveTabTexts; enum KMultiTabBar::KMultiTabBarStyle m_style; int m_expandedTabSize; int m_lines; + KMultiTabBar::KMultiTabBarMode m_barMode; protected: - virtual void drawContents ( QPainter *, int, int, int, int); + virtual bool eventFilter(QObject *,QEvent*); +// virtual void paintEvent( QPaintEvent * ); - /** - * [contentsM|m]ousePressEvent are reimplemented from QScrollView - * in order to ignore all mouseEvents on the viewport, so that the - * parent can handle them. - */ - virtual void contentsMousePressEvent(QMouseEvent *); - virtual void mousePressEvent(QMouseEvent *); virtual void resizeEvent(QResizeEvent *); }; + +#else + +#include "kmultitabbar-qt3.h" + +#endif + #endif diff --git a/include/preset_preview_play_handle.h b/include/preset_preview_play_handle.h index 117fa15a1..cd93d2b83 100644 --- a/include/preset_preview_play_handle.h +++ b/include/preset_preview_play_handle.h @@ -2,7 +2,7 @@ * preset_preview_play_handle.h - play-handle for playing a short preview-sound * of a preset * - * Copyright (c) 2005 Tobias Doerffel + * Copyright (c) 2005-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -27,11 +27,11 @@ #ifndef _PRESET_PREVIEW_PLAY_HANDLE_H #define _PRESET_PREVIEW_PLAY_HANDLE_H -#include "play_handle.h" +#include "note_play_handle.h" +#include class channelTrack; -class notePlayHandle; class QMutex; @@ -41,17 +41,17 @@ public: presetPreviewPlayHandle( const QString & _preset_file ); virtual ~presetPreviewPlayHandle(); - static void cleanUp( void ); - - virtual void play( void ); virtual bool done( void ) const; + static void cleanUp( void ); + static constNotePlayHandleVector nphsOfChannelTrack( + const channelTrack * _ct ); private: static channelTrack * s_globalChannelTrack; static notePlayHandle * s_globalPreviewNote; - static QMutex * s_globalDataMutex; + static QMutex s_globalDataMutex; notePlayHandle * m_previewNote; diff --git a/include/qt3support.h b/include/qt3support.h index dcb3b994a..b7b3be02e 100644 --- a/include/qt3support.h +++ b/include/qt3support.h @@ -34,9 +34,17 @@ #include #if QT_VERSION >= 0x040000 + #ifndef QT4 #define QT4 #endif + +#else + +#ifndef QT3 +#define QT3 +#endif + #endif diff --git a/include/setup_dialog.h b/include/setup_dialog.h index e705199d2..babe5c8d6 100644 --- a/include/setup_dialog.h +++ b/include/setup_dialog.h @@ -59,11 +59,12 @@ class setupDialog : public QDialog public: enum configTabs { - GENERAL_SETTINGS, AUDIO_SETTINGS, MIDI_SETTINGS + GENERAL_SETTINGS, DIRECTORY_SETTINGS, PERFORMANCE_SETTINGS, + AUDIO_SETTINGS, MIDI_SETTINGS } ; setupDialog( configTabs _tab_to_open = GENERAL_SETTINGS ); - ~setupDialog(); + virtual ~setupDialog(); protected slots: @@ -100,6 +101,10 @@ private slots: void openVSTDir( void ); + void toggleDisableChActInd( bool _disabled ); + void toggleManualChPiano( bool _enabled ); + + private: tabBar * m_tabBar; @@ -121,6 +126,10 @@ private: QString m_vstDir; + bool m_disableChActInd; + bool m_manualChPiano; + + typedef QMap aswMap; typedef QMap mswMap; diff --git a/include/side_bar.h b/include/side_bar.h index 497bd14ca..b1abfda61 100644 --- a/include/side_bar.h +++ b/include/side_bar.h @@ -1,7 +1,7 @@ /* * side_bar.h - code for side-bar in LMMS * - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2004-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -47,10 +47,11 @@ class sideBar : public KMultiTabBar { Q_OBJECT public: - sideBar( Qt::Orientation _o, QWidget * _parent ) : - KMultiTabBar( _o, _parent ) + sideBar( KMultiTabBarMode _m, QWidget * _parent ) : + KMultiTabBar( _m, _parent ) { } + virtual ~sideBar() { } diff --git a/resources/setup_performance.png b/resources/setup_performance.png new file mode 100644 index 000000000..f93b7ff2e Binary files /dev/null and b/resources/setup_performance.png differ diff --git a/src/audio/audio_alsa.cpp b/src/audio/audio_alsa.cpp index 01dd45069..2fed4b246 100644 --- a/src/audio/audio_alsa.cpp +++ b/src/audio/audio_alsa.cpp @@ -1,7 +1,7 @@ /* * audio_alsa.cpp - device-class which implements ALSA-PCM-output * - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2004-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -182,8 +182,12 @@ void audioALSA::startProcessing( void ) if( !isRunning() ) { start( +#ifdef QT4 + QThread::HighPriority +#else #if QT_VERSION >= 0x030200 QThread::HighestPriority +#endif #endif ); } diff --git a/src/audio/audio_jack.cpp b/src/audio/audio_jack.cpp index 388bf5829..6be4d3c09 100644 --- a/src/audio/audio_jack.cpp +++ b/src/audio/audio_jack.cpp @@ -1,7 +1,7 @@ /* * audio_jack.cpp - support for JACK-transport * - * Copyright (c) 2005 Tobias Doerffel + * Copyright (c) 2005-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -108,7 +108,9 @@ audioJACK::audioJACK( Uint32 _sample_rate, bool & _success_ful ) : #endif jack_get_client_name( m_client ) ); } -#else + +#else /* OLD_JACK */ + m_client = jack_client_new( client_name. #ifdef QT4 toAscii().constData() @@ -116,6 +118,12 @@ audioJACK::audioJACK( Uint32 _sample_rate, bool & _success_ful ) : ascii() #endif ); + if( m_client == NULL ) + { + printf( "jack_client_new() failed\n" ); + return; + } + #endif // set process-callback diff --git a/src/audio/audio_oss.cpp b/src/audio/audio_oss.cpp index 18f3bf022..4c7f9371f 100644 --- a/src/audio/audio_oss.cpp +++ b/src/audio/audio_oss.cpp @@ -1,7 +1,7 @@ /* * audio_oss.cpp - device-class that implements OSS-PCM-output * - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2004-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -285,8 +285,12 @@ void audioOSS::startProcessing( void ) if( !isRunning() ) { start( +#ifdef QT4 + QThread::HighPriority +#else #if QT_VERSION >= 0x030200 QThread::HighestPriority +#endif #endif ); } diff --git a/src/core/arp_and_chords_tab_widget.cpp b/src/core/arp_and_chords_tab_widget.cpp index 5e145dd63..8652caabd 100644 --- a/src/core/arp_and_chords_tab_widget.cpp +++ b/src/core/arp_and_chords_tab_widget.cpp @@ -41,6 +41,9 @@ #include #include +#define setCurrentIndex setCurrentItem +#define currentIndex currentItem + #endif @@ -61,6 +64,7 @@ #include "tempo_sync_knob.h" #include "channel_track.h" #include "led_checkbox.h" +#include "preset_preview_play_handle.h" @@ -208,7 +212,7 @@ arpAndChordsTabWidget::arpAndChordsTabWidget( channelTrack * _channel_track ) : CHORDS_GROUPBOX_HEIGHT ); m_chordsComboBox = new QComboBox( m_chordsGroupBox ); - m_chordsComboBox->setFont( pointSize<9>( m_chordsComboBox->font() ) ); + m_chordsComboBox->setFont( pointSize<8>( m_chordsComboBox->font() ) ); m_chordsComboBox->setGeometry( 10, 25, 140, 22 ); for( int i = 0; s_chords[i].interval[0] != -1; ++i ) @@ -259,7 +263,7 @@ arpAndChordsTabWidget::arpAndChordsTabWidget( channelTrack * _channel_track ) : "major or minor triads. But there're a lot of other " "possible chords, you can select." ) ); m_arpComboBox = new QComboBox( m_arpGroupBox ); - m_arpComboBox->setFont( pointSize<9>( m_arpComboBox->font() ) ); + m_arpComboBox->setFont( pointSize<8>( m_arpComboBox->font() ) ); m_arpComboBox->setGeometry( 10, 25, 140, 22 ); for( int i = 0; s_chords[i].interval[0] != -1; ++i ) @@ -270,6 +274,8 @@ arpAndChordsTabWidget::arpAndChordsTabWidget( channelTrack * _channel_track ) : #endif ) ); } + + m_arpRangeKnob = new knob( knobBright_26, m_arpGroupBox, tr( "Arpeggio range" ) ); m_arpRangeKnob->setLabel( tr( "RANGE" ) ); @@ -321,8 +327,8 @@ arpAndChordsTabWidget::arpAndChordsTabWidget( channelTrack * _channel_track ) : "arpeggio-tone that should be played. With this you " "can make cool staccato-arpeggios." ) ); - m_arpDirectionLbl = new QLabel( tr( "DIRECTION:" ), m_arpGroupBox ); - m_arpDirectionLbl->setGeometry( 10, 60, 64, 8 ); + m_arpDirectionLbl = new QLabel( tr( "Direction:" ), m_arpGroupBox ); + m_arpDirectionLbl->setGeometry( 10, 60, 64, 10 ); m_arpDirectionLbl->setFont( pointSize<7>( m_arpDirectionLbl->font() ) ); @@ -392,9 +398,21 @@ arpAndChordsTabWidget::arpAndChordsTabWidget( channelTrack * _channel_track ) : m_arpDirections_group->hide(); #endif - m_sortMode = new ledCheckBox( tr( "SORT-MODE" ), m_arpGroupBox ); - m_sortMode->move( 10, 90 ); +/* m_sortMode = new ledCheckBox( tr( "Sort-mode" ), m_arpGroupBox ); + m_sortMode->move( 10, 90 );*/ + QLabel * mode_lbl = new QLabel( tr( "Mode:" ), m_arpGroupBox ); + mode_lbl->setGeometry( 10, 90, 64, 10 ); + mode_lbl->setFont( pointSize<7>( mode_lbl->font() ) ); + + m_arpModeComboBox = new QComboBox( m_arpGroupBox ); + m_arpModeComboBox->setFont( pointSize<8>( m_arpModeComboBox->font() ) ); + m_arpModeComboBox->setGeometry( 70, 87, 80, 22 ); + + m_arpModeComboBox->addItem( tr( "Free" ) ); + m_arpModeComboBox->addItem( tr( "Sort" ) ); + m_arpModeComboBox->addItem( tr( "Sync" ) ); + m_arpModeComboBox->setCurrentItem( 0 ); } @@ -421,11 +439,8 @@ void arpAndChordsTabWidget::processNote( notePlayHandle * _n ) m_chordsGroupBox->isActive() == TRUE ) { // then insert sub-notes for chord -#ifdef QT4 const int selected_chord = m_chordsComboBox->currentIndex(); -#else - const int selected_chord = m_chordsComboBox->currentItem(); -#endif + for( int octave_cnt = 0; octave_cnt < m_chordRangeKnob->value(); ++octave_cnt ) { @@ -482,18 +497,21 @@ void arpAndChordsTabWidget::processNote( notePlayHandle * _n ) } -#ifdef QT4 const int selected_arp = m_arpComboBox->currentIndex(); -#else - const int selected_arp = m_arpComboBox->currentItem(); -#endif constNotePlayHandleVector cnphv = notePlayHandle::nphsOfChannelTrack( _n->getChannelTrack() ); - // VERY unlikely, but better check this before ending in a crash - if( cnphv.size() == 0 ) + if( m_arpModeComboBox->currentIndex() != FREE && cnphv.size() == 0 ) { - return; + // maybe we're playing only a preset-preview-note? + cnphv = presetPreviewPlayHandle::nphsOfChannelTrack( + _n->getChannelTrack() ); + if( cnphv.size() == 0 ) + { + // still nothing found here, so lets return + //return; + cnphv.push_back( _n ); + } } const int cur_chord_size = getChordSize( s_chords[selected_arp] ); @@ -509,7 +527,7 @@ void arpAndChordsTabWidget::processNote( notePlayHandle * _n ) // used for calculating remaining frames for arp-note, we have to add // arp_frames-1, otherwise the first arp-note will not be setup // correctly... -> arp_frames frames silence at the start of every note! - int cur_frame = ( ( m_sortMode->isChecked() == TRUE ) ? + int cur_frame = ( ( m_arpModeComboBox->currentIndex() != FREE ) ? cnphv.first()->totalFramesPlayed() : _n->totalFramesPlayed() ) + arp_frames - 1; @@ -533,14 +551,14 @@ void arpAndChordsTabWidget::processNote( notePlayHandle * _n ) // init with zero int cur_arp_idx = 0; - if( m_sortMode->isChecked() == TRUE && + if( m_arpModeComboBox->currentIndex() == SORT && ( ( cur_frame / arp_frames ) % total_range ) / - range != (csize) _n->index() ) + range != (Uint32) _n->index() ) { // update counters frames_processed += arp_frames; cur_frame += arp_frames; - break; + continue; } // process according to arpeggio-direction... @@ -609,7 +627,8 @@ void arpAndChordsTabWidget::processNote( notePlayHandle * _n ) // and is_arp_note=TRUE notePlayHandle * note_play_handle = new notePlayHandle( _n->getChannelTrack(), - ( ( m_sortMode->isChecked() == TRUE ) ? + ( ( m_arpModeComboBox->currentIndex() != + FREE ) ? cnphv.first()->framesAhead() : _n->framesAhead() ) + frames_processed, @@ -628,8 +647,10 @@ void arpAndChordsTabWidget::processNote( notePlayHandle * _n ) // make sure, note is handled as arp-base-note, even if we didn't add a // sub-note so far - _n->setArpNote( TRUE ); - + if( m_arpModeComboBox->currentIndex() != FREE ) + { + _n->setArpNote( TRUE ); + } } @@ -640,19 +661,11 @@ void arpAndChordsTabWidget::saveSettings( QDomDocument & _doc, { QDomElement act_de = _doc.createElement( nodeName() ); act_de.setAttribute( "chorddisabled", !m_chordsGroupBox->isActive() ); -#ifdef QT4 act_de.setAttribute( "chord", m_chordsComboBox->currentIndex() ); -#else - act_de.setAttribute( "chord", m_chordsComboBox->currentItem() ); -#endif act_de.setAttribute( "chordrange", m_chordRangeKnob->value() ); act_de.setAttribute( "arpdisabled", !m_arpGroupBox->isActive() ); -#ifdef QT4 act_de.setAttribute( "arp", m_arpComboBox->currentIndex() ); -#else - act_de.setAttribute( "arp", m_arpComboBox->currentItem() ); -#endif act_de.setAttribute( "arprange", m_arpRangeKnob->value() ); act_de.setAttribute( "arptime", m_arpTimeKnob->value() ); act_de.setAttribute( "arpgate", m_arpGateKnob->value() ); @@ -660,7 +673,7 @@ void arpAndChordsTabWidget::saveSettings( QDomDocument & _doc, act_de.setAttribute( "arpsyncmode", ( int ) m_arpTimeKnob->getSyncMode() ); - act_de.setAttribute( "sortmode", m_sortMode->isChecked() ); + act_de.setAttribute( "arpmode", m_arpModeComboBox->currentIndex() ); _parent.appendChild( act_de ); } @@ -671,17 +684,9 @@ void arpAndChordsTabWidget::loadSettings( const QDomElement & _this ) { m_chordsGroupBox->setState( !_this.attribute ( "chorddisabled" ).toInt() ); -#ifdef QT4 m_chordsComboBox->setCurrentIndex( _this.attribute( "chord" ).toInt() ); -#else - m_chordsComboBox->setCurrentItem( _this.attribute( "chord" ).toInt() ); -#endif m_chordRangeKnob->setValue( _this.attribute( "chordrange" ).toFloat() ); -#ifdef QT4 m_arpComboBox->setCurrentIndex( _this.attribute( "arp" ).toInt() ); -#else - m_arpComboBox->setCurrentItem( _this.attribute( "arp" ).toInt() ); -#endif m_arpRangeKnob->setValue( _this.attribute( "arprange" ).toFloat() ); m_arpTimeKnob->setValue( _this.attribute( "arptime" ).toFloat() ); m_arpGateKnob->setValue( _this.attribute( "arpgate" ).toFloat() ); @@ -691,7 +696,8 @@ void arpAndChordsTabWidget::loadSettings( const QDomElement & _this ) ( tempoSyncKnob::tempoSyncMode ) _this.attribute( "arpsyncmode" ).toInt() ); - m_sortMode->setChecked( _this.attribute( "sortmode" ).toInt() ); + m_arpModeComboBox->setCurrentIndex( _this.attribute( "arpmode" + ).toInt() ); m_arpGroupBox->setState( m_arpDirection != OFF && !_this.attribute( "arpdisabled" ).toInt() ); @@ -766,6 +772,8 @@ void arpAndChordsTabWidget::arpRandomToggled( bool _on ) #undef setChecked +#undef currentIndex +#undef setCurrentIndex #include "arp_and_chords_tab_widget.moc" diff --git a/src/core/config_mgr.cpp b/src/core/config_mgr.cpp index 77f5b9d3b..7c8c9a06d 100644 --- a/src/core/config_mgr.cpp +++ b/src/core/config_mgr.cpp @@ -780,7 +780,7 @@ bool configManager::loadConfigFile( void ) stringPairVector attr; QDomNamedNodeMap node_attr = node.toElement().attributes(); - for( unsigned int i = 0; i < node_attr.count(); ++i ) + for( csize i = 0; i < node_attr.count(); ++i ) { QDomNode n = node_attr.item( i ); if( n.isAttr() ) diff --git a/src/core/file_browser.cpp b/src/core/file_browser.cpp index 7a90923de..4eb63f5c7 100644 --- a/src/core/file_browser.cpp +++ b/src/core/file_browser.cpp @@ -319,7 +319,7 @@ listView::listView( QWidget * _parent ) : setSorting( -1 ); setShowToolTips( TRUE ); - setFont( pointSize<8>( font() ) ); + setFont( pointSizeF( font(), 7.5f ) ); } diff --git a/src/core/main.cpp b/src/core/main.cpp index 28e23d47b..c1acd2137 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -164,7 +164,7 @@ int main( int argc, char * * argv ) pal.setColor( QPalette::Text, QColor( 224, 224, 224 ) ); pal.setColor( QPalette::Button, QColor( 160, 160, 160 ) ); pal.setColor( QPalette::ButtonText, QColor( 255, 255, 255 ) ); - pal.setColor( QPalette::Highlight, QColor( 255, 224, 224 ) ); + pal.setColor( QPalette::Highlight, QColor( 224, 224, 224 ) ); pal.setColor( QPalette::HighlightedText, QColor( 0, 0, 0 ) ); #else pal.setColor( QColorGroup::Background, QColor( 128, 128, 128 ) ); diff --git a/src/core/midi_tab_widget.cpp b/src/core/midi_tab_widget.cpp index 341060a4e..ff2e7aa39 100644 --- a/src/core/midi_tab_widget.cpp +++ b/src/core/midi_tab_widget.cpp @@ -93,7 +93,7 @@ midiTabWidget::midiTabWidget( channelTrack * _channel_track, outputChannelChanged( m_outputChannelSpinBox->value() ); - m_receiveCheckBox = new ledCheckBox( tr( "RECEIVE MIDI-EVENTS" ), + m_receiveCheckBox = new ledCheckBox( tr( "Receive MIDI-events" ), m_setupTabWidget ); m_receiveCheckBox->move( 10, 34 ); connect( m_receiveCheckBox, SIGNAL( toggled( bool ) ), @@ -102,7 +102,7 @@ midiTabWidget::midiTabWidget( channelTrack * _channel_track, m_inputChannelSpinBox, SLOT( setEnabled( bool ) ) ); - m_sendCheckBox = new ledCheckBox( tr( "SEND MIDI-EVENTS" ), + m_sendCheckBox = new ledCheckBox( tr( "Send MIDI-events" ), m_setupTabWidget ); m_sendCheckBox->move( 10, 94 ); connect( m_sendCheckBox, SIGNAL( toggled( bool ) ), diff --git a/src/core/name_label.cpp b/src/core/name_label.cpp index 8ca723216..67387fd5c 100644 --- a/src/core/name_label.cpp +++ b/src/core/name_label.cpp @@ -51,7 +51,7 @@ nameLabel::nameLabel( const QString & _initial_name, QWidget * _parent, QLabel( _initial_name, _parent ), m_pm( _pm ) { -#ifndef QT4 +#ifdef QT3 setBackgroundMode( Qt::NoBackground ); #endif } @@ -100,6 +100,7 @@ void nameLabel::paintEvent( QPaintEvent * ) { #ifdef QT4 QPainter p( this ); + p.fillRect( rect(), palette().color( backgroundRole() ) ); #else QPixmap draw_pm( rect().size() ); draw_pm.fill( this, rect().topLeft() ); diff --git a/src/core/note_play_handle.cpp b/src/core/note_play_handle.cpp index a74cb1546..343265753 100644 --- a/src/core/note_play_handle.cpp +++ b/src/core/note_play_handle.cpp @@ -33,6 +33,7 @@ #include "midi_port.h" #include "song_editor.h" #include "piano_widget.h" +#include "config_mgr.h" @@ -58,7 +59,11 @@ notePlayHandle::notePlayHandle( channelTrack * _chnl_trk, m_muted( FALSE ) { setFrames( _frames ); - m_channelTrack->m_pianoWidget->setKeyState( key(), TRUE ); + if( !configManager::inst()->value( "ui", + "manualchannelpiano" ).toInt() ) + { + m_channelTrack->m_pianoWidget->setKeyState( key(), TRUE ); + } // send MIDI-note-on-event m_channelTrack->processOutEvent( midiEvent( NOTE_ON, m_channelTrack->m_midiPort->outputChannel(), @@ -243,7 +248,12 @@ void notePlayHandle::noteOff( Uint32 _s ) { m_releaseFramesToDo = m_channelTrack->m_envWidget->releaseFrames(); - m_channelTrack->m_pianoWidget->setKeyState( key(), FALSE ); + if( !configManager::inst()->value( "ui", + "manualchannelpiano" ).toInt() ) + { + m_channelTrack->m_pianoWidget->setKeyState( key(), + FALSE ); + } // send MIDI-note-off-event m_channelTrack->processOutEvent( midiEvent( NOTE_OFF, m_channelTrack->m_midiPort->outputChannel(), diff --git a/src/core/piano_roll.cpp b/src/core/piano_roll.cpp index c723c8ac7..2e2776ee3 100644 --- a/src/core/piano_roll.cpp +++ b/src/core/piano_roll.cpp @@ -2093,8 +2093,14 @@ void pianoRoll::recordNote( const note & _n ) note n( _n ); n.setPos( songEditor::inst()->getPlayPos( songEditor::PLAY_PATTERN ) - n.length() ); +#ifndef QT4 + qApp->lock(); +#endif m_pattern->addNote( n ); update(); +#ifndef QT4 + qApp->unlock(); +#endif songEditor::inst()->setModified(); } } diff --git a/src/core/preset_preview_play_handle.cpp b/src/core/preset_preview_play_handle.cpp index db147f6c1..dde540579 100644 --- a/src/core/preset_preview_play_handle.cpp +++ b/src/core/preset_preview_play_handle.cpp @@ -2,7 +2,7 @@ * preset_preview_play_handle.cpp - implementation of class * presetPreviewPlayHandle * - * Copyright (c) 2005 Tobias Doerffel + * Copyright (c) 2005-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -79,13 +79,16 @@ private: { hide(); } - ~blindTrackContainer() + + virtual ~blindTrackContainer() { } + static blindTrackContainer * s_instanceOfMe; friend void presetPreviewPlayHandle::cleanUp( void ); + } ; @@ -94,7 +97,7 @@ blindTrackContainer * blindTrackContainer::s_instanceOfMe = NULL; channelTrack * presetPreviewPlayHandle::s_globalChannelTrack = NULL; notePlayHandle * presetPreviewPlayHandle::s_globalPreviewNote = NULL; -QMutex * presetPreviewPlayHandle::s_globalDataMutex = NULL; +QMutex presetPreviewPlayHandle::s_globalDataMutex; presetPreviewPlayHandle::presetPreviewPlayHandle( @@ -102,12 +105,13 @@ presetPreviewPlayHandle::presetPreviewPlayHandle( playHandle( PRESET_PREVIEW_PLAY_HANDLE ), m_previewNote( NULL ) { - if( s_globalDataMutex == NULL ) +/* if( s_globalDataMutex == NULL ) { s_globalDataMutex = new QMutex; } - s_globalDataMutex->lock(); + s_globalDataMutex->lock();*/ + s_globalDataMutex.lock(); if( s_globalPreviewNote != NULL ) { @@ -141,7 +145,7 @@ presetPreviewPlayHandle::presetPreviewPlayHandle( s_globalPreviewNote = m_previewNote; - s_globalDataMutex->unlock(); + s_globalDataMutex.unlock(); } @@ -149,21 +153,13 @@ presetPreviewPlayHandle::presetPreviewPlayHandle( presetPreviewPlayHandle::~presetPreviewPlayHandle() { - s_globalDataMutex->lock(); + s_globalDataMutex.lock(); if( m_previewNote->muted() == FALSE ) { s_globalPreviewNote = NULL; } delete m_previewNote; - s_globalDataMutex->unlock(); -} - - - - -void presetPreviewPlayHandle::cleanUp( void ) -{ - delete blindTrackContainer::inst(); + s_globalDataMutex.unlock(); } @@ -182,3 +178,31 @@ bool presetPreviewPlayHandle::done( void ) const return( m_previewNote->muted() ); } + + + +void presetPreviewPlayHandle::cleanUp( void ) +{ + delete blindTrackContainer::inst(); +} + + + + +constNotePlayHandleVector presetPreviewPlayHandle::nphsOfChannelTrack( + const channelTrack * _ct ) +{ + constNotePlayHandleVector cnphv; + s_globalDataMutex.lock(); + if( s_globalPreviewNote != NULL && + s_globalPreviewNote->getChannelTrack() == _ct ) + { + cnphv.push_back( s_globalPreviewNote ); + } + s_globalDataMutex.unlock(); + return( cnphv ); +} + + + + diff --git a/src/core/setup_dialog.cpp b/src/core/setup_dialog.cpp index b95ae8afa..98bc2c6aa 100644 --- a/src/core/setup_dialog.cpp +++ b/src/core/setup_dialog.cpp @@ -109,7 +109,12 @@ setupDialog::setupDialog( configTabs _tab_to_open ) : m_noMsgAfterSetup( configManager::inst()->value( "app", "nomsgaftersetup" ).toInt() ), m_workingDir( configManager::inst()->workingDir() ), - m_vstDir( configManager::inst()->vstDir() ) + m_vstDir( configManager::inst()->vstDir() ), + m_disableChActInd( configManager::inst()->value( "ui", + "disablechannelactivityindicators" ).toInt() ), + m_manualChPiano( configManager::inst()->value( "ui", + "manualchannelpiano" ).toInt() ) + { setWindowIcon( embed::getIconPixmap( "setup_general" ) ); setWindowTitle( tr( "Setup LMMS" ) ); @@ -288,6 +293,42 @@ setupDialog::setupDialog( configTabs _tab_to_open ) : + QWidget * performance = new QWidget( ws ); + performance->setFixedSize( 360, 200 ); + QVBoxLayout * perf_layout = new QVBoxLayout( performance ); + perf_layout->setSpacing( 0 ); + perf_layout->setMargin( 0 ); + labelWidget( performance, tr( "Performance settings" ) ); + + tabWidget * ui_fx_tw = new tabWidget( tr( "UI effects vs. " + "performance" ).toUpper(), + performance ); + ui_fx_tw->setFixedHeight( 70 ); + + ledCheckBox * disable_ch_act_ind = new ledCheckBox( + tr( "Disable channel activity indicators" ), + ui_fx_tw ); + disable_ch_act_ind->move( 10, 20 ); + disable_ch_act_ind->setChecked( m_disableChActInd ); + connect( disable_ch_act_ind, SIGNAL( toggled( bool ) ), + this, SLOT( toggleDisableChActInd( bool ) ) ); + + + ledCheckBox * manual_ch_piano = new ledCheckBox( + tr( "Only press keys on channel-piano manually" ), + ui_fx_tw ); + manual_ch_piano->move( 10, 40 ); + manual_ch_piano->setChecked( m_manualChPiano ); + connect( manual_ch_piano, SIGNAL( toggled( bool ) ), + this, SLOT( toggleManualChPiano( bool ) ) ); + + + + + perf_layout->addWidget( ui_fx_tw ); + perf_layout->addStretch(); + + QWidget * audio = new QWidget( ws ); audio->setFixedSize( 360, 200 ); @@ -297,7 +338,7 @@ setupDialog::setupDialog( configTabs _tab_to_open ) : labelWidget( audio, tr( "Audio settings" ) ); tabWidget * audioiface_tw = new tabWidget( tr( "AUDIO INTERFACE" ), - audio ); + audio ); audioiface_tw->setFixedHeight( 60 ); m_audioInterfaces = new QComboBox( audioiface_tw ); @@ -466,9 +507,12 @@ setupDialog::setupDialog( configTabs _tab_to_open ) : m_tabBar->addTab( directories, tr( "Directories" ), 1, FALSE, TRUE )->setIcon( embed::getIconPixmap( "setup_directories" ) ); - m_tabBar->addTab( audio, tr( "Audio settings" ), 2, FALSE, TRUE + m_tabBar->addTab( performance, tr( "Performance settings" ), 2, FALSE, + TRUE )->setIcon( embed::getIconPixmap( + "setup_performance" ) ); + m_tabBar->addTab( audio, tr( "Audio settings" ), 3, FALSE, TRUE )->setIcon( embed::getIconPixmap( "setup_audio" ) ); - m_tabBar->addTab( midi, tr( "MIDI settings" ), 3, TRUE, TRUE + m_tabBar->addTab( midi, tr( "MIDI settings" ), 4, TRUE, TRUE )->setIcon( embed::getIconPixmap( "setup_midi" ) ); #undef setIcon @@ -541,6 +585,11 @@ void setupDialog::accept( void ) QString::number( m_noWizard ) ); configManager::inst()->setValue( "app", "nomsgaftersetup", QString::number( m_noMsgAfterSetup ) ); + configManager::inst()->setValue( "ui", + "disablechannelactivityindicators", + QString::number( m_disableChActInd ) ); + configManager::inst()->setValue( "ui", "manualchannelpiano", + QString::number( m_manualChPiano ) ); configManager::inst()->setWorkingDir( m_workingDir ); configManager::inst()->setVSTDir( m_vstDir ); @@ -590,7 +639,7 @@ void setupDialog::setBufferSize( int _value ) } m_bufferSize = _value * 64; - m_bufSizeLbl->setText( tr( "FRAMES: %1\nLATENCY: %2 ms" ).arg( + m_bufSizeLbl->setText( tr( "Frames: %1\nLatency: %2 ms" ).arg( m_bufferSize ).arg( 1000.0f * m_bufferSize / mixer::inst()->sampleRate(), @@ -627,6 +676,62 @@ void setupDialog::displayBufSizeHelp( void ) +void setupDialog::toggleToolTips( bool _disabled ) +{ + m_disableToolTips = _disabled; +} + + + + +void setupDialog::toggleKnobUsability( bool _classical ) +{ + m_classicalKnobUsability = _classical; +} + + + + +void setupDialog::toggleGIMPLikeWindows( bool _enabled ) +{ + m_gimpLikeWindows = _enabled; +} + + + + +void setupDialog::toggleNoWizard( bool _enabled ) +{ + m_noWizard = _enabled; +} + + + + +void setupDialog::toggleNoMsgAfterSetup( bool _enabled ) +{ + m_noMsgAfterSetup = _enabled; +} + + + + +void setupDialog::toggleDisableChActInd( bool _disabled ) +{ + m_disableChActInd = _disabled; +} + + + + +void setupDialog::toggleManualChPiano( bool _enabled ) +{ + m_manualChPiano = _enabled; +} + + + + void setupDialog::openWorkingDir( void ) { #ifdef QT4 @@ -761,45 +866,5 @@ void setupDialog::displayMIDIHelp( void ) -void setupDialog::toggleToolTips( bool _disabled ) -{ - m_disableToolTips = _disabled; -} - - - - -void setupDialog::toggleKnobUsability( bool _classical ) -{ - m_classicalKnobUsability = _classical; -} - - - - -void setupDialog::toggleGIMPLikeWindows( bool _enabled ) -{ - m_gimpLikeWindows = _enabled; -} - - - - -void setupDialog::toggleNoWizard( bool _enabled ) -{ - m_noWizard = _enabled; -} - - - - -void setupDialog::toggleNoMsgAfterSetup( bool _enabled ) -{ - m_noMsgAfterSetup = _enabled; -} - - - - #include "setup_dialog.moc" diff --git a/src/core/track.cpp b/src/core/track.cpp index c8e7439ed..935494a1e 100644 --- a/src/core/track.cpp +++ b/src/core/track.cpp @@ -920,12 +920,10 @@ trackWidget::trackWidget( track * _track, QWidget * _parent ) : m_initialMouseX( -1 ) { #ifdef QT4 - { - QPalette pal; - pal.setColor( m_trackOperationsWidget.backgroundRole(), + QPalette pal; + pal.setColor( m_trackOperationsWidget.backgroundRole(), QColor( 128, 128, 128 ) ); - m_trackOperationsWidget.setPalette( pal ); - } + m_trackOperationsWidget.setPalette( pal ); #else m_trackOperationsWidget.setPaletteBackgroundColor( QColor( 128, 128, 128 ) ); @@ -934,9 +932,8 @@ trackWidget::trackWidget( track * _track, QWidget * _parent ) : #ifdef QT4 - QPalette pal; pal.setColor( m_trackSettingsWidget.backgroundRole(), - QColor( 64, 64, 64 ) ); + QColor( 64, 64, 64 ) ); m_trackSettingsWidget.setPalette( pal ); #else m_trackSettingsWidget.setPaletteBackgroundColor( QColor( 64, 64, 64 ) ); diff --git a/src/lib/mmp.cpp b/src/lib/mmp.cpp index eb2a6cb9b..ac35821e4 100644 --- a/src/lib/mmp.cpp +++ b/src/lib/mmp.cpp @@ -1,7 +1,7 @@ /* * mmp.cpp - implementation of class multimediaProject * - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2004-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -196,7 +196,8 @@ bool multimediaProject::writeFile( const QString & _fn, bool _overwrite_check ) } else if( type() == SONG_PROJECT ) { - if( fn.section( '.',-1 ) != "mmp" ) + if( fn.section( '.', -1 ) != "mmp" && + fn.section( '.', -1 ) != "mpt" ) { fn += ".mmp"; } diff --git a/src/midi/midi_alsa_seq.cpp b/src/midi/midi_alsa_seq.cpp index c0a942e78..e01cf5bfb 100644 --- a/src/midi/midi_alsa_seq.cpp +++ b/src/midi/midi_alsa_seq.cpp @@ -1,7 +1,7 @@ /* * midi_alsa_seq.cpp - ALSA-sequencer-client * - * Copyright (c) 2005 Tobias Doerffel + * Copyright (c) 2005-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -101,7 +101,7 @@ midiALSASeq::midiALSASeq( void ) : start( #if QT_VERSION >= 0x030200 - QThread::LowPriority + QThread::IdlePriority #endif ); } diff --git a/src/widgets/kmultitabbar.cpp b/src/widgets/kmultitabbar.cpp index 2166bf37c..ed06e09e6 100644 --- a/src/widgets/kmultitabbar.cpp +++ b/src/widgets/kmultitabbar.cpp @@ -1,48 +1,901 @@ -/*************************************************************************** - kmultitabbar.cpp - description - ------------------- - begin : 2001 - copyright : (C) 2001,2002,2003 by Joseph Wenninger - ***************************************************************************/ - -/*************************************************************************** - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - ***************************************************************************/ - -#include "kmultitabbar.h" +#include "templates.h" +#include "tooltip.h" #include "qt3support.h" #ifdef QT4 -#include -#include +#include "kmultitabbar.h" + +#include +#include #include -#include +#include #include #include -#include -#include -#include +#include +#include + +#include + +#define NEARBYINT(i) ((int(float(i) + 0.5))) + +class KMultiTabBarTabPrivate { +public: + QPixmap pix; +}; + + +KMultiTabBarInternal::KMultiTabBarInternal(QWidget *parent, KMultiTabBar::KMultiTabBarMode bm):QWidget(parent) +{ + m_expandedTabSize=-1; + m_showActiveTabTexts=false; + m_barMode=bm; + if (bm==KMultiTabBar::Vertical) + { + box=new QWidget(this); + mainLayout=new QVBoxLayout(box); + box->setFixedWidth(24); + setFixedWidth(24); + } + else + { + box=new QWidget(this); + mainLayout=new QHBoxLayout(box); + box->setFixedHeight(24); + setFixedHeight(24); + } + mainLayout->setMargin(0); + mainLayout->setSpacing(0); +} + +void KMultiTabBarInternal::setStyle(enum KMultiTabBar::KMultiTabBarStyle style) +{ + m_style=style; + for (int i=0;isetStyle(m_style); + + if ( (m_style==KMultiTabBar::KDEV3) || + (m_style==KMultiTabBar::KDEV3ICON ) ) { + delete mainLayout; + mainLayout=0; + resizeEvent(0); + } else if (mainLayout==0) { + if (m_barMode==KMultiTabBar::Vertical) + { + box=new QWidget(this); + mainLayout=new QVBoxLayout(box); + box->setFixedWidth(24); + setFixedWidth(24); + } + else + { + box=new QWidget(this); + mainLayout=new QHBoxLayout(box); + box->setFixedHeight(24); + setFixedHeight(24); + } + for (int i=0;iaddWidget(m_tabs.at(i)); + + } + repaint(); +} + + + +#define CALCDIFF(m_tabs,diff,i) if (m_lines>(int)lines) {\ + int ulen=0;\ + diff=0; \ + for (int i2=i;i2neededSize();\ + if ((ulen+l1)>space){\ + if (ulen==0) diff=0;\ + else diff=((float)(space-ulen))/(i2-i);\ + break;\ + }\ + ulen+=l1;\ + }\ + } else {diff=0; } + + +void KMultiTabBarInternal::resizeEvent(QResizeEvent *ev) { + if (ev) QWidget::resizeEvent(ev); + + if ( (m_style==KMultiTabBar::KDEV3) || + (m_style==KMultiTabBar::KDEV3ICON) ){ + box->setGeometry(0,0,width(),height()); + int lines=1; + uint space; + float tmp=0; + if ((m_position==KMultiTabBar::Bottom) || (m_position==KMultiTabBar::Top)) + space=width(); + else + space=height(); + + int cnt=0; +//CALCULATE LINES + const int tabCount=m_tabs.count(); + for (int i=0;ineededSize(); + if (tmp>space) { + if (cnt>1)i--; + else if (i==(tabCount-1)) break; + cnt=0; + tmp=0; + lines++; + } + } +//SET SIZE & PLACE + float diff=0; + cnt=0; + + if ((m_position==KMultiTabBar::Bottom) || (m_position==KMultiTabBar::Top)) { + + setFixedHeight(lines*24); + box->setFixedHeight(lines*24); + m_lines=height()/24-1; + lines=0; + CALCDIFF(m_tabs,diff,0) + tmp=-diff; + + for (int i=0;ineededSize()+diff; + if (tmp>space) { + if (cnt>1) { + CALCDIFF(m_tabs,diff,i) + i--; + } + else { + tab->removeEventFilter(this); + tab->move(NEARBYINT(tmp-tab->neededSize()),lines*24); + tab->setFixedWidth(NEARBYINT(tmp+diff)-tab->x());; + tab->installEventFilter(this); + CALCDIFF(m_tabs,diff,(i+1)) + + } + tmp=-diff; + cnt=0; + lines++; + + } else { + tab->removeEventFilter(this); + tab->move(NEARBYINT(tmp-tab->neededSize()),lines*24); + tab->setFixedWidth(NEARBYINT(tmp+diff)-tab->x());; + + tab->installEventFilter(this); + + } + } + } + else { + setFixedWidth(lines*24); + box->setFixedWidth(lines*24); + m_lines=lines=width()/24; + lines=0; + CALCDIFF(m_tabs,diff,0) + tmp=-diff; + + for (int i=0;ineededSize()+diff; + if (tmp>space) { + if (cnt>1) { + CALCDIFF(m_tabs,diff,i); + tmp=-diff; + i--; + } + else { + tab->removeEventFilter(this); + tab->move(lines*24,NEARBYINT(tmp-tab->neededSize())); + tab->setFixedHeight(NEARBYINT(tmp+diff)-tab->y());; + tab->installEventFilter(this); + } + cnt=0; + tmp=-diff; + lines++; + } else { + tab->removeEventFilter(this); + tab->move(lines*24,NEARBYINT(tmp-tab->neededSize())); + tab->setFixedHeight(NEARBYINT(tmp+diff)-tab->y());; + tab->installEventFilter(this); + } + } + } + + + } else { + int size=0; /*move the calculation into another function and call it only on add tab and tab click events*/ + for (int i=0;i<(int)m_tabs.count();i++) + size+=(m_barMode==KMultiTabBar::Vertical?m_tabs.at(i)->height():m_tabs.at(i)->width()); + if ((m_position==KMultiTabBar::Bottom) || (m_position==KMultiTabBar::Top)) + box->setGeometry(0,0,size,height()); + else box->setGeometry(0,0,width(),size); + + } +} + + +void KMultiTabBarInternal::showActiveTabTexts(bool show) +{ + m_showActiveTabTexts=show; +} + + +KMultiTabBarTab* KMultiTabBarInternal::tab(int id) const +{ + for (QListIterator it(m_tabs);it.hasNext();it.next()){ + if (it.peekNext()->id()==id) return it.peekNext(); + } + return 0; +} + +bool KMultiTabBarInternal::eventFilter(QObject *, QEvent *e) { + if (e->type()==QEvent::Resize) resizeEvent(0); + return false; +} + +int KMultiTabBarInternal::appendTab(const QPixmap &pic ,int id,const QString& text) +{ + KMultiTabBarTab *tab; + m_tabs.append(tab= new KMultiTabBarTab(pic,text,id,box,m_position,m_style)); + mainLayout->addWidget( tab ); + tab->installEventFilter(this); + tab->showActiveTabText(m_showActiveTabTexts); + + if (m_style==KMultiTabBar::KONQSBC) + { + if (m_expandedTabSizeneededSize()) { + m_expandedTabSize=tab->neededSize(); + for (int i=0;isetSize(m_expandedTabSize); + + } else tab->setSize(m_expandedTabSize); + } else tab->updateState(); + tab->show(); + resizeEvent(0); + return 0; +} + +void KMultiTabBarInternal::removeTab(int id) +{ + for (int pos=0;posid()==id) + { + delete m_tabs.at(pos); + m_tabs.removeAt(pos); + resizeEvent(0); + break; + } + } +} + +void KMultiTabBarInternal::setPosition(enum KMultiTabBar::KMultiTabBarPosition pos) +{ + m_position=pos; + for (int i=0;isetTabsPosition(m_position); + repaint(); +} + +KMultiTabBarButton::KMultiTabBarButton(const QPixmap& pic,const QString& text, QMenu *popup, + int id,QWidget *parent,KMultiTabBar::KMultiTabBarPosition pos,KMultiTabBar::KMultiTabBarStyle style) + :QPushButton(QIcon(),text,parent),m_style(style) +{ + setIcon(pic); + setText(text); + m_position=pos; + if (popup) setMenu(popup); + setFlat(true); + setFixedHeight(24); + setFixedWidth(24); + m_id=id; + setToolTip(text); + connect(this,SIGNAL(clicked()),this,SLOT(slotClicked())); +} + +KMultiTabBarButton::KMultiTabBarButton(const QString& text, QMenu *popup, + int id,QWidget *parent,KMultiTabBar::KMultiTabBarPosition pos,KMultiTabBar::KMultiTabBarStyle style) + :QPushButton(QIcon(),text,parent),m_style(style) +{ + setText(text); + m_position=pos; + if (popup) setMenu(popup); + setFlat(true); + setFixedHeight(24); + setFixedWidth(24); + m_id=id; + setToolTip(text); + connect(this,SIGNAL(clicked()),this,SLOT(slotClicked())); +} + +KMultiTabBarButton::~KMultiTabBarButton() { +} + +int KMultiTabBarButton::id() const{ + return m_id; +} + +void KMultiTabBarButton::setText(const QString& text) +{ + QPushButton::setText(text); + m_text=text; + setToolTip(text); +} + +void KMultiTabBarButton::slotClicked() +{ + emit clicked(m_id); +} + +void KMultiTabBarButton::setPosition(KMultiTabBar::KMultiTabBarPosition pos) +{ + m_position=pos; + repaint(); +} + +void KMultiTabBarButton::setStyle(KMultiTabBar::KMultiTabBarStyle style) +{ + m_style=style; + repaint(); +} + +void KMultiTabBarButton::hideEvent( QHideEvent* he) { + QPushButton::hideEvent(he); + KMultiTabBar *tb=dynamic_cast(parentWidget()); + if (tb) tb->updateSeparator(); +} + +void KMultiTabBarButton::showEvent( QShowEvent* he) { + QPushButton::showEvent(he); + KMultiTabBar *tb=dynamic_cast(parentWidget()); + if (tb) tb->updateSeparator(); +} + + +QSize KMultiTabBarButton::sizeHint() const +{ + //constPolish(); + + int w = 0, h = 0; + + // calculate contents size... + int iw = 0, ih = 0; + if ( !icon().isNull() ) { + iw = 20; + ih = 16; + w += iw; + h = tMax( h, ih ); + } + QStyleOptionButton sob; + if ( menu() != 0 ) + w += style()->pixelMetric(QStyle::PM_MenuButtonIndicator, &sob, this); + + QString s( text() ); + bool empty = s.isEmpty(); + if ( empty ) + s = QLatin1String("XXXX"); + QFontMetrics fm = fontMetrics(); + QSize sz = fm.size( Qt::TextShowMnemonic, s ); + if(!empty || !w) + w += sz.width(); + if(!empty || !h) + h = qMax(h, sz.height()); + + + QStyleOptionToolButton opt; + opt.init(this); + opt.rect = QRect(0, 0, w, h); + opt.subControls = QStyle::SC_All; + opt.activeSubControls = 0; + opt.text = text(); + opt.font = font(); + opt.icon = icon(); + opt.iconSize = QSize(iw, ih); + return (style()->sizeFromContents(QStyle::CT_ToolButton, &opt, QSize(w, h), this). + expandedTo(QApplication::globalStrut())); +} + + +KMultiTabBarTab::KMultiTabBarTab(const QPixmap& pic, const QString& text, + int id,QWidget *parent,KMultiTabBar::KMultiTabBarPosition pos, + KMultiTabBar::KMultiTabBarStyle style) + :KMultiTabBarButton(text,0,id,parent,pos,style), + m_showActiveTabText(false) +{ + d=new KMultiTabBarTabPrivate(); + setIcon(pic); + m_expandedSize=24; + setCheckable(true); +} + +KMultiTabBarTab::~KMultiTabBarTab() { + delete d; +} + + +void KMultiTabBarTab::setTabsPosition(KMultiTabBar::KMultiTabBarPosition pos) +{ + if ((pos!=m_position) && ((pos==KMultiTabBar::Left) || (pos==KMultiTabBar::Right))) { + if (!d->pix.isNull()) { + QMatrix temp;// (1.0F, 0.0F, 0.0F, -1.0F, 0.0F, 0.0F); + temp.rotate(180); + d->pix=d->pix.transformed(temp); + setIcon(d->pix); + } + } + setPosition(pos); +} + +void KMultiTabBarTab::setIcon(const QString& icon) +{ + QPixmap pic(icon); + setIcon(pic); +} + +void KMultiTabBarTab::setIcon(const QPixmap& icon) +{ + + if (m_style!=KMultiTabBar::KDEV3) { + if ((m_position==KMultiTabBar::Left) || (m_position==KMultiTabBar::Right)) { + QMatrix rotateMatrix; +/* if (m_position==KMultiTabBar::Left) + rotateMatrix.rotate(-270); + else*/ + rotateMatrix.rotate(90); + d->pix=icon.transformed(rotateMatrix); //TODO FIX THIS, THIS SHOWS WINDOW + KMultiTabBarButton::setIcon(d->pix); + } else KMultiTabBarButton::setIcon(icon); + } +} + +void KMultiTabBarTab::slotClicked() +{ + updateState(); + KMultiTabBarButton::slotClicked(); +} + +void KMultiTabBarTab::setState(bool b) +{ + setChecked(b); + updateState(); +} + +void KMultiTabBarTab::updateState() +{ + + if (m_style!=KMultiTabBar::KONQSBC) { + if ((m_style==KMultiTabBar::KDEV3) || (m_style==KMultiTabBar::KDEV3ICON) || (isChecked())) { + QPushButton::setText(m_text); + } else { + QPushButton::setText(QString()); + } + + if ((m_position==KMultiTabBar::Right || m_position==KMultiTabBar::Left)) { + setFixedWidth(24); + if ((m_style==KMultiTabBar::KDEV3) || (m_style==KMultiTabBar::KDEV3ICON) || (isChecked())) { + setFixedHeight(KMultiTabBarButton::sizeHint().width()); + } else setFixedHeight(36); + } else { + setFixedHeight(24); + if ((m_style==KMultiTabBar::KDEV3) || (m_style==KMultiTabBar::KDEV3ICON) || (isChecked())) { + setFixedWidth(KMultiTabBarButton::sizeHint().width()); + } else setFixedWidth(36); + } + } else { + if ((!isChecked()) || (!m_showActiveTabText)) + { + setFixedWidth(24); + setFixedHeight(24); + return; + } + if ((m_position==KMultiTabBar::Right || m_position==KMultiTabBar::Left)) + setFixedHeight(m_expandedSize); + else + setFixedWidth(m_expandedSize); + } +} + +int KMultiTabBarTab::neededSize() +{ + return (((m_style!=KMultiTabBar::KDEV3)?24:0)+QFontMetrics(QFont()).width(m_text)+6); +} + +void KMultiTabBarTab::setSize(int size) +{ + m_expandedSize=size; + updateState(); +} + +void KMultiTabBarTab::showActiveTabText(bool show) +{ + m_showActiveTabText=show; +} + +void KMultiTabBarTab::paintEvent(QPaintEvent *) { + QPainter painter(this); + drawButton(&painter); +} + +void KMultiTabBarTab::drawButtonLabel(QPainter *p) { + drawButton(p); +} +void KMultiTabBarTab::drawButton(QPainter *paint) +{ + if (m_style!=KMultiTabBar::KONQSBC) drawButtonStyled(paint); + else drawButtonClassic(paint); +} + +void KMultiTabBarTab::drawButtonStyled(QPainter *paint) { + + QSize sh; + const int width = 36; // rotated + const int height = 24; + if ((m_style==KMultiTabBar::KDEV3) || (m_style==KMultiTabBar::KDEV3ICON) || (isChecked())) { + if ((m_position==KMultiTabBar::Left) || (m_position==KMultiTabBar::Right)) + sh=QSize(this->height(),this->width());//KMultiTabBarButton::sizeHint(); + else sh=QSize(this->width(),this->height()); + } + else + sh=QSize(width,height); + + QPixmap pixmap( sh.width(),height); ///,sh.height()); + pixmap.fill(backgroundRole()); + QPainter painter(&pixmap); + + + QStyle::State st=QStyle::State_None; + + st|=QStyle::State_Enabled; + + if (isChecked()) st|=QStyle::State_On; + + QStyleOptionButton options; + options.init(this); + options.state = st; + options.rect = QRect(0,0,pixmap.width(),pixmap.height()); + options.palette = palette(); + options.text = text(); + options.icon = icon(); + options.iconSize = iconSize(); + + style()->drawControl(QStyle::CE_PushButton, &options, &painter, this); + + switch (m_position) { + case KMultiTabBar::Left: + paint->rotate(-90); + paint->drawPixmap(1-pixmap.width(),0,pixmap); + break; + case KMultiTabBar::Right: + paint->rotate(90); + paint->drawPixmap(0,1-pixmap.height(),pixmap); + break; + + default: + paint->drawPixmap(0,0,pixmap); + break; + } + +} + +void KMultiTabBarTab::drawButtonClassic(QPainter *paint) +{ + QPixmap pixmap; + if( !icon().isNull() ) + pixmap = icon().pixmap( 16, 16 ); + paint->fillRect(0, 0, 24, 24, palette().background().color()); + + if (!isChecked()) + { + + if (m_position==KMultiTabBar::Right) + { + paint->fillRect(0,0,21,21,QBrush(palette().background().color())); + + paint->setPen(palette().background().color().dark(150)); + paint->drawLine(0,22,23,22); + + paint->drawPixmap(12-pixmap.width()/2,12-pixmap.height()/2,pixmap); + + paint->setPen(palette().shadow().color()); + paint->drawLine(0,0,0,23); + paint->setPen(palette().background().color().dark(120)); + paint->drawLine(1,0,1,23); + + } + else + if ((m_position==KMultiTabBar::Bottom) || (m_position==KMultiTabBar::Top)) + { + paint->fillRect(0,1,23,22,QBrush(palette().background().color())); + + paint->drawPixmap(12-pixmap.width()/2,12-pixmap.height()/2,pixmap); + + paint->setPen(palette().background().color().dark(120)); + paint->drawLine(23,0,23,23); + + + paint->setPen(palette().light().color()); + paint->drawLine(0,22,23,22); + paint->drawLine(0,23,23,23); + paint->setPen(palette().shadow().color()); + paint->drawLine(0,0,23,0); + paint->setPen(palette().background().color().dark(120)); + paint->drawLine(0,1,23,1); + + } + else + { + paint->setPen(palette().background().color().dark(120)); + paint->drawLine(0,23,23,23); + paint->fillRect(0,0,23,21,QBrush(palette().background())); + paint->drawPixmap(12-pixmap.width()/2,12-pixmap.height()/2,pixmap); + + paint->setPen(palette().light().color()); + paint->drawLine(23,0,23,23); + paint->drawLine(22,0,22,23); + + paint->setPen(palette().shadow().color()); + paint->drawLine(0,0,0,23); + + } + + + } + else + { + if (m_position==KMultiTabBar::Right) + { + paint->setPen(palette().shadow().color()); + paint->drawLine(0,height()-1,23,height()-1); + paint->drawLine(0,height()-2,23,height()-2); + paint->drawLine(23,0,23,height()-1); + paint->drawLine(22,0,22,height()-1); + paint->fillRect(0,0,21,height()-3,QBrush(palette().light().color())); + paint->drawPixmap(10-pixmap.width()/2,10-pixmap.height()/2,pixmap); + + if (m_showActiveTabText) + { + if (height()<25+4) return; + + QPixmap tpixmap(height()-25-3, width()-2); + QPainter painter(&tpixmap); + + painter.fillRect(0,0,tpixmap.width(),tpixmap.height(),QBrush(palette().light().color())); + + painter.setPen(palette().text().color()); + painter.drawText(0,+width()/2+QFontMetrics(QFont()).height()/2,m_text); + + paint->rotate(90); + paint->drawPixmap(25,-tpixmap.height()+1,tpixmap); + } + + } + else + if (m_position==KMultiTabBar::Top) + { + paint->fillRect(0,0,width()-1,23,QBrush(palette().light().color())); + paint->drawPixmap(10-pixmap.width()/2,10-pixmap.height()/2,pixmap); + if (m_showActiveTabText) + { + paint->setPen(palette().text().color()); + paint->drawText(25,height()/2+QFontMetrics(QFont()).height()/2,m_text); + } + } + else + if (m_position==KMultiTabBar::Bottom) + { + paint->setPen(palette().shadow().color()); + paint->drawLine(0,23,width()-1,23); + paint->drawLine(0,22,width()-1,22); + paint->fillRect(0,0,width()-1,21,QBrush(palette().light().color())); + paint->drawPixmap(10-pixmap.width()/2,10-pixmap.height()/2,pixmap); + if (m_showActiveTabText) + { + paint->setPen(palette().text().color()); + paint->drawText(25,height()/2+QFontMetrics(QFont()).height()/2,m_text); + } + + } + else + { + + + paint->setPen(palette().shadow().color()); + paint->drawLine(0,height()-1,23,height()-1); + paint->drawLine(0,height()-2,23,height()-2); + paint->fillRect(0,0,23,height()-3,QBrush(palette().light().color())); + paint->drawPixmap(10-pixmap.width()/2,10-pixmap.height()/2,pixmap); + if (m_showActiveTabText) + { + + if (height()<25+4) return; + + QPixmap tpixmap(height()-25-3, width()-2); + QPainter painter(&tpixmap); + + painter.fillRect(0,0,tpixmap.width(),tpixmap.height(),QBrush(palette().light().color())); + + painter.setPen(palette().text().color()); + painter.drawText(tpixmap.width()-QFontMetrics(QFont()).width(m_text),+width()/2+QFontMetrics(QFont()).height()/2,m_text); + + paint->rotate(-90); + + paint->drawPixmap(-24-tpixmap.width(),2,tpixmap); + + } + + } + + } +} + +KMultiTabBar::KMultiTabBar(KMultiTabBarMode bm, QWidget *parent) + : QWidget(parent) +{ + if (bm==Vertical) + { + m_l=new QVBoxLayout(this); + setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding)); + } + else + { + m_l=new QHBoxLayout(this); + setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); + } + m_l->setMargin(0); + + m_internal=new KMultiTabBarInternal(this,bm); + setPosition((bm==KMultiTabBar::Vertical)?KMultiTabBar::Right:KMultiTabBar::Bottom); + setStyle(VSNET); + m_l->insertWidget(0,m_internal); + m_l->insertWidget(0,m_btnTabSep=new QFrame(this)); + m_btnTabSep->setFixedHeight(4); + m_btnTabSep->setFrameStyle(QFrame::Panel | QFrame::Sunken); + m_btnTabSep->setLineWidth(2); + m_btnTabSep->hide(); + + updateGeometry(); +} + +KMultiTabBar::~KMultiTabBar() { +} + +int KMultiTabBar::appendButton(const QPixmap &pic ,int id,QMenu *popup,const QString&) +{ + KMultiTabBarButton *btn; + m_buttons.append(btn= new KMultiTabBarButton(pic,QString(), + popup,id,this,m_position,m_internal->m_style)); + m_l->insertWidget(0,btn); + btn->show(); + m_btnTabSep->show(); + return 0; +} + +void KMultiTabBar::updateSeparator() { + bool hideSep=true; + for (QListIterator it(m_buttons);it.hasNext();){ + if (it.next()->isVisibleTo(this)) { + hideSep=false; + break; + } + } + if (hideSep) m_btnTabSep->hide(); + else m_btnTabSep->show(); + +} + +int KMultiTabBar::appendTab(const QPixmap &pic ,int id ,const QString& text) +{ + m_internal->appendTab(pic,id,text); + return 0; +} + +KMultiTabBarButton* KMultiTabBar::button(int id) const +{ + for (QListIterator it(m_buttons);it.hasNext();it.next()){ + if (it.peekNext()->id()==id) return it.peekNext(); + } + return 0; +} + +KMultiTabBarTab* KMultiTabBar::tab(int id) const +{ + return m_internal->tab(id); +} + + + +void KMultiTabBar::removeButton(int id) +{ + for (int pos=0;posid()==id) + { + m_buttons.at(pos)->deleteLater(); + m_buttons.removeAt(pos); + break; + } + } + if (m_buttons.count()==0) m_btnTabSep->hide(); +} + +void KMultiTabBar::removeTab(int id) +{ + m_internal->removeTab(id); +} + +void KMultiTabBar::setTab(int id,bool state) +{ + KMultiTabBarTab *ttab=tab(id); + if (ttab) + { + ttab->setState(state); + } +} + +bool KMultiTabBar::isTabRaised(int id) const +{ + KMultiTabBarTab *ttab=tab(id); + if (ttab) + { + return ttab->isChecked(); + } + + return false; +} + + +void KMultiTabBar::showActiveTabTexts(bool show) +{ + m_internal->showActiveTabTexts(show); +} + +void KMultiTabBar::setStyle(KMultiTabBarStyle style) +{ + m_internal->setStyle(style); +} + +KMultiTabBar::KMultiTabBarStyle KMultiTabBar::tabStyle() const +{ + return m_internal->m_style; +} + +void KMultiTabBar::setPosition(KMultiTabBarPosition pos) +{ + m_position=pos; + m_internal->setPosition(pos); + for (int i=0;isetPosition(pos); +} + +KMultiTabBar::KMultiTabBarPosition KMultiTabBar::position() const +{ + return m_position; +} +void KMultiTabBar::fontChange(const QFont& /* oldFont */) +{ + for (int i=0;icount();i++) + tabs()->at(i)->resize(); + repaint(); +} + +QList* KMultiTabBar::tabs() {return m_internal->tabs();} +QList* KMultiTabBar::buttons() {return &m_buttons;} + + +#include "kmultitabbar.moc" + #else -//#include "kmultitabbar.moc" -//#include "kmultitabbar_p.h" -//#include "kmultitabbar_p.moc" + +#include "kmultitabbar-qt3.h" + #include #include #include @@ -51,30 +904,6 @@ #include #include -//#define palette colorGroup - -/*#define #palette().shadow().color() #colorGroup().shadow() -#define #palette().background().color() #colorGroup().background() -#define #palette().light().color() #colorGroup().light() -#define #palette().text().color() #colorGroup().text()*/ - -#define isChecked isOn -#define TextShowMnemonic ShowPrefix -#define State SFlags -#define State_None Style_Default -#define State_Enabled Style_Enabled -#define State_On Style_On - -#endif - -#include "templates.h" -#include "tooltip.h" - -#include "kmultitabbar.moc" - -//#include -//#include - class KMultiTabBarTabPrivate { public: @@ -82,22 +911,18 @@ public: }; -KMultiTabBarInternal::KMultiTabBarInternal(QWidget *parent, Qt::Orientation o):Q3ScrollView(parent) +KMultiTabBarInternal::KMultiTabBarInternal(QWidget *parent, KMultiTabBar::KMultiTabBarMode m):Q3ScrollView(parent) { m_expandedTabSize=-1; m_showActiveTabTexts=false; -#ifndef QT4 m_tabs.setAutoDelete(true); -#endif setHScrollBarMode(AlwaysOff); setVScrollBarMode(AlwaysOff); - if (o==Qt::Vertical) + if (m==KMultiTabBar::Vertical) { box=new QWidget(viewport()); mainLayout=new QVBoxLayout(box); -#ifndef QT4 mainLayout->setAutoAdd(true); -#endif box->setFixedWidth(24); setFixedWidth(24); } @@ -105,9 +930,7 @@ KMultiTabBarInternal::KMultiTabBarInternal(QWidget *parent, Qt::Orientation o):Q { box=new QWidget(viewport()); mainLayout=new QHBoxLayout(box); -#ifndef QT4 mainLayout->setAutoAdd(true); -#endif box->setFixedHeight(24); setFixedHeight(24); } @@ -115,9 +938,7 @@ KMultiTabBarInternal::KMultiTabBarInternal(QWidget *parent, Qt::Orientation o):Q mainLayout->setSpacing( 0 ); addChild(box); setFrameStyle(NoFrame); -#ifndef QT4 viewport()->setBackgroundMode(Qt::PaletteBackground); -#endif } void KMultiTabBarInternal::setStyle(enum KMultiTabBar::KMultiTabBarStyle style) @@ -133,79 +954,6 @@ void KMultiTabBarInternal::setStyle(enum KMultiTabBar::KMultiTabBarStyle style) viewport()->repaint(); } -void KMultiTabBarInternal::drawContents ( QPainter * paint, int clipx, int clipy, int clipw, int cliph ) -{ - Q3ScrollView::drawContents (paint , clipx, clipy, clipw, cliph ); - - if (m_position==KMultiTabBar::DockRight) - { - - paint->setPen(palette().shadow() -#ifdef QT4 - .color() -#endif - ); - paint->drawLine(0,0,0,viewport()->height()); - paint->setPen(palette().background() -#ifdef QT4 - .color() -#endif - .dark(120)); - paint->drawLine(1,0,1,viewport()->height()); - - - } - else - if (m_position==KMultiTabBar::DockLeft) - { - paint->setPen(palette().light() -#ifdef QT4 - .color() -#endif - ); - paint->drawLine(23,0,23,viewport()->height()); - paint->drawLine(22,0,22,viewport()->height()); - - paint->setPen(palette().shadow() -#ifdef QT4 - .color() -#endif - ); - paint->drawLine(0,0,0,viewport()->height()); - } - else - if (m_position==KMultiTabBar::DockBottom) - { - paint->setPen(palette().shadow() -#ifdef QT4 - .color() -#endif - ); - paint->drawLine(0,0,viewport()->width(),0); - paint->setPen(palette().background() -#ifdef QT4 - .color() -#endif - .dark(120)); - paint->drawLine(0,1,viewport()->width(),1); - } - else - { - paint->setPen(palette().light() -#ifdef QT4 - .color() -#endif - ); - paint->drawLine(0,23,viewport()->width(),23); - paint->drawLine(0,22,viewport()->width(),22); - -/* paint->setPen(palette().shadow().color()); - paint->drawLine(0,0,0,viewport()->height());*/ - - } - - -} void KMultiTabBarInternal::contentsMousePressEvent(QMouseEvent *ev) { @@ -225,7 +973,7 @@ void KMultiTabBarInternal::resizeEvent(QResizeEvent *ev) { int lines=1; int space; int tmp=0; - if ((m_position==KMultiTabBar::DockBottom) || (m_position==KMultiTabBar::DockTop)) + if ((m_position==KMultiTabBar::Bottom) || (m_position==KMultiTabBar::Top)) space=width(); else space=height(); @@ -243,7 +991,7 @@ void KMultiTabBarInternal::resizeEvent(QResizeEvent *ev) { } } //SET SIZE & PLACE - if ((m_position==KMultiTabBar::DockBottom) || (m_position==KMultiTabBar::DockTop)) { + if ((m_position==KMultiTabBar::Bottom) || (m_position==KMultiTabBar::Top)) { setFixedHeight(lines*24); box->setFixedHeight(lines*24); tmp=0; @@ -299,15 +1047,9 @@ void KMultiTabBarInternal::showActiveTabTexts(bool show) KMultiTabBarTab* KMultiTabBarInternal::tab(int id) const { -#ifdef QT4 - for (QListIterator it(m_tabs);it.hasNext();it.next()){ - if (it.peekNext()->id()==id) return it.peekNext(); - } -#else for (QPtrListIterator it(m_tabs);it.current();++it){ if (it.current()->id()==id) return it.current(); } -#endif return 0; } @@ -337,11 +1079,7 @@ void KMultiTabBarInternal::removeTab(int id) if (m_tabs.at(pos)->id()==id) { delete m_tabs.at(pos); -#ifdef QT4 - m_tabs.removeAt(pos); -#else m_tabs.remove(pos); -#endif resizeEvent(0); break; } @@ -440,7 +1178,6 @@ QSize KMultiTabBarButton::sizeHint() const // calculate contents size... #ifndef QT_NO_ICONSET -#ifndef QT4 if ( iconSet() && !iconSet()->isNull() ) { int iw = iconSet()->pixmap( QIcon::Small, QIcon::Normal ).width() + 4; int ih = iconSet()->pixmap( QIcon::Small, QIcon::Normal ).height(); @@ -448,46 +1185,27 @@ QSize KMultiTabBarButton::sizeHint() const h = tMax( h, ih ); } #endif -#endif -#ifdef QT4 - QStyleOptionButton sob; - if ( menu() != 0 ) - w += style()->pixelMetric(QStyle::PM_MenuButtonIndicator, &sob, this); -#else if( isMenuButton() ) w += style().pixelMetric(QStyle::PM_MenuButtonIndicator, this); -#endif -#ifdef QT4 - if ( !icon().isNull() ) { - const QPixmap & pm = icon().pixmap( QSize( 16, 16 ) ); - w += pm.width(); - h += pm.height(); -#else if ( pixmap() ) { QPixmap *pm = (QPixmap *)pixmap(); w += pm->width(); h += pm->height(); -#endif } else { QString s( text() ); bool empty = s.isEmpty(); if ( empty ) s = QString::fromLatin1("XXXX"); QFontMetrics fm = fontMetrics(); - QSize sz = fm.size( Qt::TextShowMnemonic, s ); + QSize sz = fm.size( Qt::ShowPrefix, s ); if(!empty || !w) w += sz.width(); if(!empty || !h) h = tMax(h, sz.height()); } -#ifdef QT4 - return (style()->sizeFromContents(QStyle::CT_ToolButton, &sob, QSize(w, h), this). - expandedTo(QApplication::globalStrut())); -#else return (style().sizeFromContents(QStyle::CT_ToolButton, this, QSize(w, h)). expandedTo(QApplication::globalStrut())); -#endif } @@ -510,7 +1228,7 @@ KMultiTabBarTab::~KMultiTabBarTab() { void KMultiTabBarTab::setTabsPosition(KMultiTabBar::KMultiTabBarPosition pos) { - if ((pos!=m_position) && ((pos==KMultiTabBar::DockLeft) || (pos==KMultiTabBar::DockRight))) { + if ((pos!=m_position) && ((pos==KMultiTabBar::Left) || (pos==KMultiTabBar::Right))) { if (!d->pix.isNull()) { QMatrix temp;// (1.0F, 0.0F, 0.0F, -1.0F, 0.0F, 0.0F); temp.rotate(180); @@ -534,25 +1252,17 @@ void KMultiTabBarTab::setIcon(const QPixmap& icon) { if (m_style!=KMultiTabBar::KDEV3) { - if ((m_position==KMultiTabBar::DockLeft) || (m_position==KMultiTabBar::DockRight)) { + if ((m_position==KMultiTabBar::Left) || (m_position==KMultiTabBar::Right)) { QMatrix rotateMatrix; - if (m_position==KMultiTabBar::DockLeft) + if (m_position==KMultiTabBar::Left) rotateMatrix.rotate(90); else rotateMatrix.rotate(-90); QPixmap pic=icon.transformed(rotateMatrix); d->pix=pic; -#ifdef QT4 - QPushButton::setIcon(pic); -#else setIconSet(pic); -#endif } else -#ifdef QT4 - QPushButton::setIcon(icon); -#else setIconSet(icon); -#endif } } @@ -564,11 +1274,7 @@ void KMultiTabBarTab::slotClicked() void KMultiTabBarTab::setState(bool b) { -#ifdef QT4 - setChecked(b); -#else setOn(b); -#endif updateState(); } @@ -576,32 +1282,31 @@ void KMultiTabBarTab::updateState() { if (m_style!=KMultiTabBar::KONQSBC) { - if ((m_style==KMultiTabBar::KDEV3) || (m_style==KMultiTabBar::KDEV3ICON) || (isChecked())) { + if ((m_style==KMultiTabBar::KDEV3) || (m_style==KMultiTabBar::KDEV3ICON) || (isOn())) { QPushButton::setText(m_text); } else { - //kdDebug()<<"KMultiTabBarTab::updateState(): setting text to an empty QString***************"<rotate(-90); paint->drawPixmap(1-pixmap.width(),0,pixmap); break; - case KMultiTabBar::DockRight: + case KMultiTabBar::Right: paint->rotate(90); paint->drawPixmap(0,1-pixmap.height(),pixmap); break; @@ -679,135 +1377,67 @@ void KMultiTabBarTab::drawButtonStyled(QPainter *paint) { paint->drawPixmap(0,0,pixmap); break; } -// style().drawControl(QStyle::CE_PushButtonLabel,painter,this, QRect(0,0,pixmap.width(),pixmap.height()), -// colorGroup(),QStyle::Style_Enabled); - } void KMultiTabBarTab::drawButtonClassic(QPainter *paint) { QPixmap pixmap; - //if ( iconSet()) - // pixmap = iconSet()->pixmap( QIcon::Small, QIcon::Normal ); -#ifdef QT4 - if( !icon().isNull() ) - { - pixmap = icon().pixmap( 16, 16 ); - } -#else if( iconSet() ) pixmap = iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ); -#endif - paint->fillRect(0, 0, 24, 24, palette().background() -#ifdef QT4 - .color() -#endif - ); + paint->fillRect(0, 0, 24, 24, palette().background()); - if (!isChecked()) + if (!isOn()) { - if (m_position==KMultiTabBar::DockRight) + if (m_position==KMultiTabBar::Right) { - paint->fillRect(0,0,21,21,QBrush(palette().background() -#ifdef QT4 - .color() -#endif - )); + paint->fillRect(0,0,21,21,QBrush(palette().background())); - paint->setPen(palette().background() -#ifdef QT4 - .color() -#endif - .dark(150)); + paint->setPen(palette().background().dark(150)); paint->drawLine(0,22,23,22); paint->drawPixmap(12-pixmap.width()/2,12-pixmap.height()/2,pixmap); - paint->setPen(palette().shadow() -#ifdef QT4 - .color() -#endif - ); + paint->setPen(palette().shadow()); paint->drawLine(0,0,0,23); - paint->setPen(palette().background() -#ifdef QT4 - .color() -#endif - .dark(120)); + paint->setPen(palette().background().dark(120)); paint->drawLine(1,0,1,23); } else - if ((m_position==KMultiTabBar::DockBottom) || (m_position==KMultiTabBar::DockTop)) + if ((m_position==KMultiTabBar::Bottom) || (m_position==KMultiTabBar::Top)) { - paint->fillRect(0,1,23,22,QBrush(palette().background() -#ifdef QT4 - .color() -#endif - )); + paint->fillRect(0,1,23,22,QBrush(palette().background())); paint->drawPixmap(12-pixmap.width()/2,12-pixmap.height()/2,pixmap); - paint->setPen(palette().background() -#ifdef QT4 - .color() -#endif - .dark(120)); + paint->setPen(palette().background().dark(120)); paint->drawLine(23,0,23,23); - paint->setPen(palette().light() -#ifdef QT4 - .color() -#endif - ); + paint->setPen(palette().light()); paint->drawLine(0,22,23,22); paint->drawLine(0,23,23,23); - paint->setPen(palette().shadow() -#ifdef QT4 - .color() -#endif - ); + paint->setPen(palette().shadow()); paint->drawLine(0,0,23,0); - paint->setPen(palette().background() -#ifdef QT4 - .color() -#endif - .dark(120)); + paint->setPen(palette().background().dark(120)); paint->drawLine(0,1,23,1); } else { - paint->setPen(palette().background() -#ifdef QT4 - .color() -#endif - .dark(120)); + paint->setPen(palette().background().dark(120)); paint->drawLine(0,23,23,23); - paint->fillRect(0,0,23,21,QBrush(palette().background() -#ifdef QT4 - .color() -#endif - )); + paint->fillRect(0,0,23,21,QBrush(palette().background())); paint->drawPixmap(12-pixmap.width()/2,12-pixmap.height()/2,pixmap); - paint->setPen(palette().light() -#ifdef QT4 - .color() -#endif - ); + paint->setPen(palette().light()); paint->drawLine(23,0,23,23); paint->drawLine(22,0,22,23); - paint->setPen(palette().shadow() -#ifdef QT4 -.color() -#endif - ); + paint->setPen(palette().shadow()); paint->drawLine(0,0,0,23); } @@ -816,22 +1446,14 @@ void KMultiTabBarTab::drawButtonClassic(QPainter *paint) } else { - if (m_position==KMultiTabBar::DockRight) + if (m_position==KMultiTabBar::Right) { - paint->setPen(palette().shadow() -#ifdef QT4 - .color() -#endif - ); + paint->setPen(palette().shadow()); paint->drawLine(0,height()-1,23,height()-1); paint->drawLine(0,height()-2,23,height()-2); paint->drawLine(23,0,23,height()-1); paint->drawLine(22,0,22,height()-1); - paint->fillRect(0,0,21,height()-3,QBrush(palette().light() -#ifdef QT4 - .color() -#endif - )); + paint->fillRect(0,0,21,height()-3,QBrush(palette().light())); paint->drawPixmap(10-pixmap.width()/2,10-pixmap.height()/2,pixmap); if (m_showActiveTabText) @@ -841,67 +1463,38 @@ void KMultiTabBarTab::drawButtonClassic(QPainter *paint) QPixmap tpixmap(height()-25-3, width()-2); QPainter painter(&tpixmap); - painter.fillRect(0,0,tpixmap.width(),tpixmap.height(),QBrush(palette().light() -#ifdef QT4 - .color() -#endif - )); + painter.fillRect(0,0,tpixmap.width(),tpixmap.height(),QBrush(palette().light())); - painter.setPen(palette().text() -#ifdef QT4 - .color() -#endif - ); + painter.setPen(palette().text()); painter.drawText(0,+width()/2+QFontMetrics(QFont()).height()/2,m_text); paint->rotate(90); - //kdDebug()<<"tpixmap.width:"<drawPixmap(25,-tpixmap.height()+1,tpixmap); } } else - if (m_position==KMultiTabBar::DockTop) + if (m_position==KMultiTabBar::Top) { - paint->fillRect(0,0,width()-1,23,QBrush(palette().light() -#ifdef QT4 - .color() -#endif - )); + paint->fillRect(0,0,width()-1,23,QBrush(palette().light())); paint->drawPixmap(10-pixmap.width()/2,10-pixmap.height()/2,pixmap); if (m_showActiveTabText) { - paint->setPen(palette().text() -#ifdef QT4 - .color() -#endif - ); + paint->setPen(palette().text()); paint->drawText(25,height()/2+QFontMetrics(QFont()).height()/2,m_text); } } else - if (m_position==KMultiTabBar::DockBottom) + if (m_position==KMultiTabBar::Bottom) { - paint->setPen(palette().shadow() -#ifdef QT4 - .color() -#endif - ); + paint->setPen(palette().shadow()); paint->drawLine(0,23,width()-1,23); paint->drawLine(0,22,width()-1,22); - paint->fillRect(0,0,width()-1,21,QBrush(palette().light() -#ifdef QT4 - .color() -#endif - )); + paint->fillRect(0,0,width()-1,21,QBrush(palette().light())); paint->drawPixmap(10-pixmap.width()/2,10-pixmap.height()/2,pixmap); if (m_showActiveTabText) { - paint->setPen(palette().text() -#ifdef QT4 - .color() -#endif - ); + paint->setPen(palette().text()); paint->drawText(25,height()/2+QFontMetrics(QFont()).height()/2,m_text); } @@ -910,18 +1503,10 @@ void KMultiTabBarTab::drawButtonClassic(QPainter *paint) { - paint->setPen(palette().shadow() -#ifdef QT4 - .color() -#endif - ); + paint->setPen(palette().shadow()); paint->drawLine(0,height()-1,23,height()-1); paint->drawLine(0,height()-2,23,height()-2); - paint->fillRect(0,0,23,height()-3,QBrush(palette().light() -#ifdef QT4 - .color() -#endif - )); + paint->fillRect(0,0,23,height()-3,QBrush(palette().light())); paint->drawPixmap(10-pixmap.width()/2,10-pixmap.height()/2,pixmap); if (m_showActiveTabText) { @@ -931,21 +1516,12 @@ void KMultiTabBarTab::drawButtonClassic(QPainter *paint) QPixmap tpixmap(height()-25-3, width()-2); QPainter painter(&tpixmap); - painter.fillRect(0,0,tpixmap.width(),tpixmap.height(),QBrush(palette().light() -#ifdef QT4 - .color() -#endif - )); + painter.fillRect(0,0,tpixmap.width(),tpixmap.height(),QBrush(palette().light())); - painter.setPen(palette().text() -#ifdef QT4 - .color() -#endif - ); + painter.setPen(palette().text()); painter.drawText(tpixmap.width()-QFontMetrics(QFont()).width(m_text),+width()/2+QFontMetrics(QFont()).height()/2,m_text); paint->rotate(-90); - //kdDebug()<<"tpixmap.width:"<drawPixmap(-24-tpixmap.width(),2,tpixmap); @@ -962,40 +1538,24 @@ void KMultiTabBarTab::drawButtonClassic(QPainter *paint) -KMultiTabBar::KMultiTabBar( Qt::Orientation o, QWidget *parent):QWidget(parent) +KMultiTabBar::KMultiTabBar( KMultiTabBarMode m, QWidget *parent):QWidget(parent) { -#ifndef QT4 m_buttons.setAutoDelete(false); -#endif - if (o==Qt::Vertical) + if (m==Vertical) { m_l=new QVBoxLayout(this); - setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding -#ifndef QT4 - , true -#endif - )); -// setFixedWidth(24); + setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding , true)); } else { m_l=new QHBoxLayout(this); - setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed -#ifndef QT4 - , true -#endif - )); -// setFixedHeight(24); + setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed , true)); } m_l->setMargin(0); -#ifndef QT4 m_l->setAutoAdd(false); -#endif - m_internal=new KMultiTabBarInternal(this,o); - setPosition((o==Qt::Vertical)?KMultiTabBar::DockRight:KMultiTabBar::DockBottom); + m_internal=new KMultiTabBarInternal(this,m); + setPosition((m==Vertical)?KMultiTabBar::Right:KMultiTabBar::Bottom); setStyle(VSNET); - // setStyle(KDEV3); - //setStyle(KONQSBC); m_l->insertWidget(0,m_internal); m_l->insertWidget(0,m_btnTabSep=new QFrame(this)); m_btnTabSep->setFixedHeight(4); @@ -1009,11 +1569,6 @@ KMultiTabBar::KMultiTabBar( Qt::Orientation o, QWidget *parent):QWidget(parent) KMultiTabBar::~KMultiTabBar() { } -/*int KMultiTabBar::insertButton(QPixmap pic,int id ,const QString&) -{ - (new KToolbarButton(pic,id,m_internal))->show(); - return 0; -}*/ int KMultiTabBar::appendButton(const QPixmap &pic ,int id,QMenu *popup,const QString&) { @@ -1028,21 +1583,12 @@ int KMultiTabBar::appendButton(const QPixmap &pic ,int id,QMenu *popup,const QSt void KMultiTabBar::updateSeparator() { bool hideSep=true; -#ifdef QT4 - for (QListIterator it(m_buttons);it.hasNext();){ - if (it.next()->isVisibleTo(this)) { - hideSep=false; - break; - } - } -#else for (QPtrListIterator it(m_buttons);it.current();++it){ if (it.current()->isVisibleTo(this)) { hideSep=false; break; } } -#endif if (hideSep) m_btnTabSep->hide(); else m_btnTabSep->show(); @@ -1056,15 +1602,9 @@ int KMultiTabBar::appendTab(const QPixmap &pic ,int id ,const QString& text) KMultiTabBarButton* KMultiTabBar::button(int id) const { -#ifdef QT4 - for (QListIterator it(m_buttons);it.hasNext();it.next()){ - if (it.peekNext()->id()==id) return it.peekNext(); - } -#else for (QPtrListIterator it(m_buttons);it.current();++it){ if (it.current()->id()==id) return it.current(); } -#endif return 0; } @@ -1082,12 +1622,7 @@ void KMultiTabBar::removeButton(int id) if (m_buttons.at(pos)->id()==id) { m_buttons.at(pos)->deleteLater(); -#ifdef QT4 - m_buttons.removeAt(pos); -#else m_buttons.remove(pos); -#endif - //m_buttons.take(pos)->deleteLater(); break; } } @@ -1113,7 +1648,7 @@ bool KMultiTabBar::isTabRaised(int id) const KMultiTabBarTab *ttab=tab(id); if (ttab) { - return ttab->isChecked(); + return ttab->isOn(); } return false; @@ -1147,3 +1682,10 @@ void KMultiTabBar::fontChange(const QFont& /* oldFont */) tabList * KMultiTabBar::tabs() {return m_internal->tabs();} buttonList * KMultiTabBar::buttons() {return &m_buttons;} + +#include "kmultitabbar-qt3.moc" + +#endif + + + diff --git a/src/widgets/led_checkbox.cpp b/src/widgets/led_checkbox.cpp index cb6442074..ed2e876bc 100644 --- a/src/widgets/led_checkbox.cpp +++ b/src/widgets/led_checkbox.cpp @@ -73,8 +73,8 @@ ledCheckBox::ledCheckBox( const QString & _text, QWidget * _parent, setBackgroundMode( Qt::PaletteBackground ); #endif - setFont( pointSize<7>( font() ) ); - setFixedSize( m_ledOffPixmap->width() + 6 + + setFont( pointSizeF( font(), 7.5f ) ); + setFixedSize( m_ledOffPixmap->width() + 4 + QFontMetrics( font() ).width( text() ), m_ledOffPixmap->height() ); } diff --git a/src/widgets/side_bar_widget.cpp b/src/widgets/side_bar_widget.cpp index 9151f6989..33dfc5547 100644 --- a/src/widgets/side_bar_widget.cpp +++ b/src/widgets/side_bar_widget.cpp @@ -1,7 +1,7 @@ /* * side_bar_widget.cpp - implementation of base-widget for side-bar * - * Copyright (c) 2004-2005 Tobias Doerffel + * Copyright (c) 2004-2006 Tobias Doerffel * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * @@ -55,6 +55,7 @@ sideBarWidget::sideBarWidget( const QString & _title, const QPixmap & _icon, m_contents = new QWidget( this ); m_layout = new QVBoxLayout( m_contents ); m_layout->setSpacing( 5 ); + m_layout->setMargin( 0 ); }