From: <ck...@us...> - 2008-05-01 09:55:28
|
Revision: 2788 http://krusader.svn.sourceforge.net/krusader/?rev=2788&view=rev Author: ckarai Date: 2008-05-01 02:55:18 -0700 (Thu, 01 May 2008) Log Message: ----------- QColorGroup -> KrColorGroup Modified Paths: -------------- trunk/krusader_kde4/krusader/KViewer/krviewer.cpp trunk/krusader_kde4/krusader/Konfigurator/kgcolors.cpp trunk/krusader_kde4/krusader/Konfigurator/kgdependencies.cpp trunk/krusader_kde4/krusader/Konfigurator/kglookfeel.cpp trunk/krusader_kde4/krusader/Panel/krbriefview.cpp trunk/krusader_kde4/krusader/Panel/krbriefviewitem.cpp trunk/krusader_kde4/krusader/Panel/krcolorcache.cpp trunk/krusader_kde4/krusader/Panel/krcolorcache.h trunk/krusader_kde4/krusader/Panel/krdetailedview.cpp trunk/krusader_kde4/krusader/Panel/krdetailedviewitem.cpp trunk/krusader_kde4/krusader/Synchronizer/synchronizergui.cpp Modified: trunk/krusader_kde4/krusader/KViewer/krviewer.cpp =================================================================== --- trunk/krusader_kde4/krusader/KViewer/krviewer.cpp 2008-05-01 07:29:59 UTC (rev 2787) +++ trunk/krusader_kde4/krusader/KViewer/krviewer.cpp 2008-05-01 09:55:18 UTC (rev 2788) @@ -489,12 +489,12 @@ } void KrViewer::nextTab(){ - int index = (tabBar.currentPageIndex()+1)%tabBar.count(); + int index = (tabBar.currentIndex()+1)%tabBar.count(); tabBar.setCurrentIndex( index ); } void KrViewer::prevTab(){ - int index = (tabBar.currentPageIndex()-1)%tabBar.count(); + int index = (tabBar.currentIndex()-1)%tabBar.count(); while( index < 0 ) index+=tabBar.count(); tabBar.setCurrentIndex( index ); } Modified: trunk/krusader_kde4/krusader/Konfigurator/kgcolors.cpp =================================================================== --- trunk/krusader_kde4/krusader/Konfigurator/kgcolors.cpp 2008-05-01 07:29:59 UTC (rev 2787) +++ trunk/krusader_kde4/krusader/Konfigurator/kgcolors.cpp 2008-05-01 09:55:18 UTC (rev 2788) @@ -410,7 +410,7 @@ void KgColors::generatePreview() { - int currentPage = colorTabWidget->currentPageIndex(); + int currentPage = colorTabWidget->currentIndex(); preview->clear(); @@ -458,7 +458,14 @@ colCache.setColors( colorSettings ); // ask the local color cache for certain color groups and use them to color the preview - QColorGroup cg; + KrColorGroup cg; + + // setting the background color + colCache.getColors(cg, KrColorItemType(KrColorItemType::File, false, isActive, false, false)); + QPalette pal = preview->palette(); + pal.setColor( QPalette::Base, cg.background() ); + preview->setPalette( pal ); + colCache.getColors(cg, KrColorItemType(KrColorItemType::Directory, false, isActive, false, false)); pwDir->setColor( cg.text(), cg.background() ); colCache.getColors(cg, KrColorItemType(KrColorItemType::File, true, isActive, false, false)); @@ -470,7 +477,7 @@ colCache.getColors(cg, KrColorItemType(KrColorItemType::InvalidSymlink, false, isActive, false, false)); pwInvLink->setColor( cg.text(), cg.background() ); colCache.getColors(cg, KrColorItemType(KrColorItemType::File, true, isActive, true, false)); - pwCurrent->setColor( cg.highlightedText(), cg.highlight() ); + pwCurrent->setColor( cg.text(), cg.background() ); colCache.getColors(cg, KrColorItemType(KrColorItemType::File, false, isActive, false, true)); pwMark1->setColor( cg.highlightedText(), cg.highlight() ); colCache.getColors(cg, KrColorItemType(KrColorItemType::File, true, isActive, false, true)); Modified: trunk/krusader_kde4/krusader/Konfigurator/kgdependencies.cpp =================================================================== --- trunk/krusader_kde4/krusader/Konfigurator/kgdependencies.cpp 2008-05-01 07:29:59 UTC (rev 2787) +++ trunk/krusader_kde4/krusader/Konfigurator/kgdependencies.cpp 2008-05-01 09:55:18 UTC (rev 2788) @@ -174,7 +174,7 @@ } int KgDependencies::activeSubPage() { - return tabWidget->currentPageIndex(); + return tabWidget->currentIndex(); } #include "kgdependencies.moc" Modified: trunk/krusader_kde4/krusader/Konfigurator/kglookfeel.cpp =================================================================== --- trunk/krusader_kde4/krusader/Konfigurator/kglookfeel.cpp 2008-05-01 07:29:59 UTC (rev 2787) +++ trunk/krusader_kde4/krusader/Konfigurator/kglookfeel.cpp 2008-05-01 09:55:18 UTC (rev 2788) @@ -392,7 +392,7 @@ } int KgLookFeel::activeSubPage() { - return tabWidget->currentPageIndex(); + return tabWidget->currentIndex(); } #include "kglookfeel.moc" Modified: trunk/krusader_kde4/krusader/Panel/krbriefview.cpp =================================================================== --- trunk/krusader_kde4/krusader/Panel/krbriefview.cpp 2008-05-01 07:29:59 UTC (rev 2787) +++ trunk/krusader_kde4/krusader/Panel/krbriefview.cpp 2008-05-01 09:55:18 UTC (rev 2788) @@ -1245,9 +1245,12 @@ bool isActive = hasFocus(); if ( MAIN_VIEW && ACTIVE_PANEL && ACTIVE_PANEL->view ) isActive = ( static_cast<KrView *>( this ) == ACTIVE_PANEL->view ); - QColorGroup cg; + KrColorGroup cg; KrColorCache::getColorCache().getColors(cg, KrColorItemType(KrColorItemType::File, false, isActive, false, false)); setPaletteBackgroundColor( cg.background() ); + QPalette pal = palette(); + pal.setColor( QPalette::Base, cg.background() ); + setPalette( pal ); } else { // KDE default is choosen: set back the background color setPaletteBackgroundColor( KColorScheme(QPalette::Active, KColorScheme::View).background().color() ); @@ -1373,7 +1376,7 @@ QAction * res = popup.exec(QCursor::pos()); int result= -1; - if( res->data().canConvert<int>() ) + if( res && res->data().canConvert<int>() ) result = res->data().toInt(); KConfigGroup group( krConfig, nameInKConfig() ); Modified: trunk/krusader_kde4/krusader/Panel/krbriefviewitem.cpp =================================================================== --- trunk/krusader_kde4/krusader/Panel/krbriefviewitem.cpp 2008-05-01 07:29:59 UTC (rev 2787) +++ trunk/krusader_kde4/krusader/Panel/krbriefviewitem.cpp 2008-05-01 09:55:18 UTC (rev 2788) @@ -130,8 +130,15 @@ colorItemType.m_fileType = KrColorItemType::Executable; else colorItemType.m_fileType = KrColorItemType::File; - KrColorCache::getColorCache().getColors(_cg, colorItemType); - + + KrColorGroup cols; + KrColorCache::getColorCache().getColors(cols, colorItemType); + _cg.setColor(QColorGroup::Base, cols.background()); + _cg.setColor(QColorGroup::Background, cols.background()); + _cg.setColor(QColorGroup::Text, cols.text()); + _cg.setColor(QColorGroup::HighlightedText, cols.highlightedText()); + _cg.setColor(QColorGroup::Highlight, cols.highlight()); + if( _cg.background() != iconView()->paletteBackgroundColor() ) { p->save(); Modified: trunk/krusader_kde4/krusader/Panel/krcolorcache.cpp =================================================================== --- trunk/krusader_kde4/krusader/Panel/krcolorcache.cpp 2008-05-01 07:29:59 UTC (rev 2787) +++ trunk/krusader_kde4/krusader/Panel/krcolorcache.cpp 2008-05-01 09:55:18 UTC (rev 2788) @@ -382,9 +382,9 @@ class KrColorCacheImpl { friend class KrColorCache; - QMap<QString, QColorGroup> m_cachedColors; + QMap<QString, KrColorGroup> m_cachedColors; KrColorSettings m_colorSettings; - QColorGroup getColors(const KrColorItemType & type) const; + KrColorGroup getColors(const KrColorItemType & type) const; static const QColor & setColorIfContrastIsSufficient(const QColor & background, const QColor & color1, const QColor & color2); QColor getForegroundColor(bool isActive) const; QColor getSpecialForegroundColor(const QString & type, bool isActive) const; @@ -399,9 +399,9 @@ QColor dimColor(QColor color, bool isBackgroundColor) const; }; -QColorGroup KrColorCacheImpl::getColors(const KrColorItemType & type) const +KrColorGroup KrColorCacheImpl::getColors(const KrColorItemType & type) const { - QColorGroup result; + KrColorGroup result; if (m_colorSettings.getBoolValue("KDE Default", _KDEDefaultColors)) { // KDE default? Getcolors from KGlobalSettings. @@ -409,11 +409,10 @@ QColor background = enableAlternateBackground && type.m_alternateBackgroundColor ? KColorScheme(QPalette::Active, KColorScheme::View).background(KColorScheme::AlternateBackground).color() : KColorScheme(QPalette::Active, KColorScheme::View).background().color(); - result.setColor(QColorGroup::Base, background); - result.setColor(QColorGroup::Background, background); - result.setColor(QColorGroup::Text, KColorScheme(QPalette::Active, KColorScheme::View).foreground().color() ); - result.setColor(QColorGroup::HighlightedText, KColorScheme(QPalette::Active, KColorScheme::Selection).foreground().color()); - result.setColor(QColorGroup::Highlight, KColorScheme(QPalette::Active, KColorScheme::Selection).background().color()); + result.setBackground(background); + result.setText( KColorScheme(QPalette::Active, KColorScheme::View).foreground().color() ); + result.setHighlightedText( KColorScheme(QPalette::Active, KColorScheme::Selection).foreground().color()); + result.setHighlight( KColorScheme(QPalette::Active, KColorScheme::Selection).background().color()); /* if (type.m_currentItem && type.m_activePanel) { @@ -458,11 +457,10 @@ } // set the background color - result.setColor(QColorGroup::Base, background); - result.setColor(QColorGroup::Background, background); + result.setBackground(background); // set the foreground color - result.setColor(QColorGroup::Text, foreground); + result.setText(foreground); // now the color of a marked item QColor markedBackground = type.m_alternateBackgroundColor ? @@ -474,8 +472,8 @@ markedForeground = setColorIfContrastIsSufficient(markedBackground, foreground, background); // set it in the color group (different group color than normal foreground!) - result.setColor(QColorGroup::HighlightedText, markedForeground); - result.setColor(QColorGroup::Highlight, markedBackground); + result.setHighlightedText(markedForeground); + result.setHighlight(markedBackground); // In case the current item is a selected one, set the fore- and background colors for the contrast calculation below if (type.m_selectedItem) @@ -494,9 +492,8 @@ currentBackground = background; // set the background - result.setColor(QColorGroup::Highlight, currentBackground); - result.setColor(QColorGroup::Base, currentBackground); - result.setColor(QColorGroup::Background, currentBackground); + result.setHighlight(currentBackground); + result.setBackground(currentBackground); QColor color; if (type.m_selectedItem) @@ -510,18 +507,17 @@ } // set the foreground - result.setColor(QColorGroup::Text, color); - result.setColor(QColorGroup::HighlightedText, color); + result.setText(color); + result.setHighlightedText(color); } if (dimBackground && !type.m_activePanel) { // if color dimming is choosen, dim the colors for the inactive panel - result.setColor(QColorGroup::Base, dimColor(result.base(), true)); - result.setColor(QColorGroup::Background, dimColor(result.base(), true)); - result.setColor(QColorGroup::Text, dimColor(result.text(), false)); - result.setColor(QColorGroup::HighlightedText, dimColor(result.highlightedText(), false)); - result.setColor(QColorGroup::Highlight, dimColor(result.highlight(), true)); + result.setBackground( dimColor(result.background(), true)); + result.setText( dimColor(result.text(), false)); + result.setHighlightedText( dimColor(result.highlightedText(), false)); + result.setHighlight( dimColor(result.highlight(), true)); } return result; } @@ -703,7 +699,7 @@ return * m_instance; } -void KrColorCache::getColors(QColorGroup & result, const KrColorItemType & type) const +void KrColorCache::getColors(KrColorGroup & result, const KrColorItemType & type) const { // for the cache lookup: calculate a unique key from the type char hashKey[128]; @@ -739,14 +735,13 @@ m_impl->m_cachedColors[hashKey] = m_impl->getColors(type); // get color group from cache - const QColorGroup & col = m_impl->m_cachedColors[hashKey]; + const KrColorGroup & col = m_impl->m_cachedColors[hashKey]; // copy colors in question to result color group - result.setColor(QColorGroup::Base, col.base()); - result.setColor(QColorGroup::Background, col.base()); - result.setColor(QColorGroup::Text, col.text()); - result.setColor(QColorGroup::HighlightedText, col.highlightedText()); - result.setColor(QColorGroup::Highlight, col.highlight()); + result.setBackground(col.background()); + result.setText(col.text()); + result.setHighlightedText(col.highlightedText()); + result.setHighlight(col.highlight()); } QColor KrColorCache::dimColor(const QColor & color, int dim, const QColor & targetColor) Modified: trunk/krusader_kde4/krusader/Panel/krcolorcache.h =================================================================== --- trunk/krusader_kde4/krusader/Panel/krcolorcache.h 2008-05-01 07:29:59 UTC (rev 2787) +++ trunk/krusader_kde4/krusader/Panel/krcolorcache.h 2008-05-01 09:55:18 UTC (rev 2788) @@ -80,6 +80,28 @@ colorsRefreshed. getColorCache returns a statis color cached for painting the panels. On the color cache setColors should NEVER be called! */ +class KrColorGroup { +public: + inline KrColorGroup() : _textColor(), _backgroundColor(), _highlightedTextColor(), + _highlightedBackgroundColor() {} + + inline const QColor & text() const { return _textColor; } + inline const QColor & background() const { return _backgroundColor; } + inline const QColor & highlight() const { return _highlightedBackgroundColor; } + inline const QColor & highlightedText() const { return _highlightedTextColor; } + + inline void setText( QColor c ) { _textColor = c; } + inline void setBackground( QColor c) { _backgroundColor = c; } + inline void setHighlight( QColor c ) { _highlightedBackgroundColor = c; } + inline void setHighlightedText( QColor c ) { _highlightedTextColor = c; } + +protected: + QColor _textColor; + QColor _backgroundColor; + QColor _highlightedTextColor; + QColor _highlightedBackgroundColor; +}; + class KrColorCache : public QObject { Q_OBJECT @@ -91,7 +113,7 @@ KrColorCache(); ~KrColorCache(); static KrColorCache & getColorCache(); - void getColors(QColorGroup & result, const KrColorItemType & type) const; + void getColors(KrColorGroup & result, const KrColorItemType & type) const; static QColor dimColor(const QColor & color, int dim, const QColor & targetColor); public slots: void refreshColors(); Modified: trunk/krusader_kde4/krusader/Panel/krdetailedview.cpp =================================================================== --- trunk/krusader_kde4/krusader/Panel/krdetailedview.cpp 2008-05-01 07:29:59 UTC (rev 2787) +++ trunk/krusader_kde4/krusader/Panel/krdetailedview.cpp 2008-05-01 09:55:18 UTC (rev 2788) @@ -1354,9 +1354,12 @@ bool isActive = hasFocus(); if ( MAIN_VIEW && ACTIVE_PANEL && ACTIVE_PANEL->view ) isActive = ( static_cast<KrView *>( this ) == ACTIVE_PANEL->view ); - QColorGroup cg; + KrColorGroup cg; KrColorCache::getColorCache().getColors(cg, KrColorItemType(KrColorItemType::File, false, isActive, false, false)); setPaletteBackgroundColor( cg.background() ); + QPalette pal = palette(); + pal.setColor( QPalette::Base, cg.background() ); + setPalette( pal ); KrColorCache::getColorCache().getColors(cg, KrColorItemType(KrColorItemType::File, true, isActive, false, false)); setAlternateBackground( cg.background() ); Modified: trunk/krusader_kde4/krusader/Panel/krdetailedviewitem.cpp =================================================================== --- trunk/krusader_kde4/krusader/Panel/krdetailedviewitem.cpp 2008-05-01 07:29:59 UTC (rev 2787) +++ trunk/krusader_kde4/krusader/Panel/krdetailedviewitem.cpp 2008-05-01 09:55:18 UTC (rev 2788) @@ -221,7 +221,15 @@ colorItemType.m_fileType = KrColorItemType::Executable; else colorItemType.m_fileType = KrColorItemType::File; - KrColorCache::getColorCache().getColors(_cg, colorItemType); + + KrColorGroup cols; + KrColorCache::getColorCache().getColors(cols, colorItemType); + _cg.setColor(QColorGroup::Base, cols.background()); + _cg.setColor(QColorGroup::Background, cols.background()); + _cg.setColor(QColorGroup::Text, cols.text()); + _cg.setColor(QColorGroup::HighlightedText, cols.highlightedText()); + _cg.setColor(QColorGroup::Highlight, cols.highlight()); + // center the <DIR> thing if needed if(column != COLUMN(Size)) Q3ListViewItem::paintCell(p, _cg, column, width, align); @@ -250,10 +258,11 @@ colorItemType.m_currentItem = (listView()->currentItem() == this); colorItemType.m_selectedItem = isSelected(); colorItemType.m_fileType = KrColorItemType::File; - QColorGroup _cg(cg); - KrColorCache::getColorCache().getColors(_cg, colorItemType); - QColor col = _cg.color( QColorGroup::Text ); + KrColorGroup cols; + KrColorCache::getColorCache().getColors(cols, colorItemType); + QColor col = cols.text(); + QPen pen( col ); pen.setStyle( Qt::DotLine ); p->setPen( pen ); Modified: trunk/krusader_kde4/krusader/Synchronizer/synchronizergui.cpp =================================================================== --- trunk/krusader_kde4/krusader/Synchronizer/synchronizergui.cpp 2008-05-01 07:29:59 UTC (rev 2787) +++ trunk/krusader_kde4/krusader/Synchronizer/synchronizergui.cpp 2008-05-01 09:55:18 UTC (rev 2788) @@ -2509,7 +2509,7 @@ void SynchronizerGUI::connectFilters( const QString &newString ) { - if( synchronizerTabs->currentPageIndex() ) + if( synchronizerTabs->currentIndex() ) fileFilter->setEditText( newString ); else generalFilter->searchFor->setEditText( newString ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |