KDE/kdebase/apps/konqueror/src
Eduardo Robles Elvira
edulix at gmail.com
Sat Mar 22 00:33:55 GMT 2008
SVN commit 788633 by edulix:
* remove some kconfig related duplicated code
* print the number of tabs inside the icon of the closed window items in the closed items menu
CCMAIL:kfm-devel at kde.org
M +45 -3 konqcloseditem.cpp
M +5 -1 konqcloseditem.h
M +2 -1 konqmainwindow.cpp
M +2 -7 konqundomanager.cpp
M +1 -1 konqundomanager.h
--- trunk/KDE/kdebase/apps/konqueror/src/konqcloseditem.cpp #788632:788633
@@ -20,10 +20,17 @@
#include "konqcloseditem.h"
#include <QFile>
+#include <QFont>
+#include <QFontMetrics>
+#include <QPainter>
#include <kconfig.h>
#include <kdebug.h>
#include <kglobal.h>
+#include <kglobalsettings.h>
+#include <kicon.h>
+#include <kiconeffect.h>
#include <konqpixmapprovider.h>
+#include <kcolorscheme.h>
#include <kstandarddirs.h>
#include <unistd.h>
@@ -48,7 +55,19 @@
QString filename;
};
+class KonqIcon {
+public:
+ KonqIcon()
+ : image(KIcon("konqueror").pixmap(16).toImage())
+ {
+ KIconEffect::deSaturate(image, 0.60f);
+ }
+
+ QImage image;
+};
+
K_GLOBAL_STATIC(KConfigNew, s_config)
+K_GLOBAL_STATIC(KonqIcon, s_lightIconImage)
KonqClosedItem::KonqClosedItem(const QString& title, const QString& group, quint64 serialNumber)
: m_title(title), m_configGroup(s_config->config, group), m_serialNumber(serialNumber)
@@ -77,8 +96,8 @@
return KonqPixmapProvider::self()->pixmapFor(m_url);
}
-KonqClosedWindowItem::KonqClosedWindowItem(const QString& title, quint64 serialNumber)
- : KonqClosedItem(title, "Closed_Window" + QString::number((qint64)this), serialNumber)
+KonqClosedWindowItem::KonqClosedWindowItem(const QString& title, quint64 serialNumber, int numTabs)
+ : KonqClosedItem(title, "Closed_Window" + QString::number((qint64)this), serialNumber), m_numTabs(numTabs)
{
kDebug(1202) << m_configGroup.name();
}
@@ -90,5 +109,28 @@
}
QPixmap KonqClosedWindowItem::icon() {
- return KonqPixmapProvider::self()->pixmapFor("about:blank");
+ QImage overlayImg = s_lightIconImage->image.copy();
+ int oldWidth = overlayImg.width();
+ QString countStr = QString::number( m_numTabs );
+
+ QFont f = KGlobalSettings::generalFont();
+ f.setBold(true);
+
+ float pointSize = f.pointSizeF();
+ QFontMetrics fm(f);
+ int w = fm.width(countStr);
+ if( w > (oldWidth) )
+ {
+ pointSize *= float(oldWidth) / float(w);
+ f.setPointSizeF(pointSize);
+ }
+
+ // overlay
+ QPainter p(&overlayImg);
+ p.setFont(f);
+ KColorScheme scheme(QPalette::Active, KColorScheme::Window);
+ p.setPen(scheme.foreground(KColorScheme::LinkText).color());
+ p.drawText(overlayImg.rect(), Qt::AlignCenter, countStr);
+
+ return QPixmap::fromImage(overlayImg);
}
--- trunk/KDE/kdebase/apps/konqueror/src/konqcloseditem.h #788632:788633
@@ -24,6 +24,7 @@
#include "konqprivate_export.h"
#include <kconfiggroup.h>
#include <QString>
+#include <QImage>
class KONQ_TESTS_EXPORT KonqClosedItem : public QObject {
public:
@@ -65,9 +66,12 @@
*/
class KONQ_TESTS_EXPORT KonqClosedWindowItem : public KonqClosedItem {
public:
- KonqClosedWindowItem(const QString& title, quint64 serialNumber);
+ KonqClosedWindowItem(const QString& title, quint64 serialNumber, int numTabs);
virtual ~KonqClosedWindowItem();
virtual QPixmap icon();
+
+protected:
+ int m_numTabs;
};
#endif /* KONQCLOSEDITEM_H */
--- trunk/KDE/kdebase/apps/konqueror/src/konqmainwindow.cpp #788632:788633
@@ -5033,13 +5033,14 @@
// 1. We get the current title
KonqFrameTabs* tabContainer = m_pViewManager->tabContainer();
+ int numTabs = m_pViewManager->tabContainer()->childFrameList().count();
QString title( i18n("no name") );
if(m_currentView)
title = m_currentView->caption();
// 2. Create the KonqClosedWindowItem and save its config
- KonqClosedWindowItem* closedWindowItem = new KonqClosedWindowItem(title, m_undoManager->newCommandSerialNumber());
+ KonqClosedWindowItem* closedWindowItem = new KonqClosedWindowItem(title, m_undoManager->newCommandSerialNumber(), numTabs);
KonqFrameBase::Options flags = KonqFrameBase::saveHistoryItems;
QString prefix = QString::fromLatin1( childFrame()->frameType() ) + QString::number(0);
closedWindowItem->configGroup().writeEntry( "RootItem", prefix );
--- trunk/KDE/kdebase/apps/konqueror/src/konqundomanager.cpp #788632:788633
@@ -348,15 +348,10 @@
myKonqUndoManagerCommunicatorPrivate->m_maxNumClosedItems = qMax(1, max);
}
-void KonqUndoManagerCommunicator::readSettings(bool global)
+void KonqUndoManagerCommunicator::readSettings()
{
- KSharedConfigPtr config;
+ KSharedConfigPtr config = KGlobal::config();
- if (global)
- config = KGlobal::config();
- else
- config = KSharedConfig::openConfig("konquerorrc");
-
KConfigGroup configGroup( config, "UndoManagerSettings");
myKonqUndoManagerCommunicatorPrivate->m_maxNumClosedItems = configGroup.readEntry("Maximum number of Closed Items", 20 );
myKonqUndoManagerCommunicatorPrivate->m_maxNumClosedItems = qMax(1, myKonqUndoManagerCommunicatorPrivate->m_maxNumClosedItems);
--- trunk/KDE/kdebase/apps/konqueror/src/konqundomanager.h #788632:788633
@@ -118,7 +118,7 @@
int maxNumClosedItems();
void setMaxNumClosedItems(int max);
public Q_SLOTS:
- void readSettings(bool global = false);
+ void readSettings();
Q_SIGNALS:
void addWindowInOtherInstances(KonqUndoManager *real_sender,
KonqClosedWindowItem *closedWindowItem);
More information about the kfm-devel
mailing list