mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-20 00:41:23 +00:00
Move setLoading() to KonqFrameTabs where it belongs, and fixed the deprecation warning by using KColorScheme.
This is about the text color on tabs where a page is loading (was usually a mix of blue+gray) or has finished loading (was usually blue). I picked some KColorScheme foreground colors (LinkText for loading, ActiveText for loaded), but ActiveText is red by default which looks ugly. Olaf or Matthew, any suggestions? PositiveText for "loaded"? CCMAIL: ojschmidt@kde.org, mw_triad@users.sourceforge.net svn path=/trunk/KDE/kdebase/apps/; revision=682178
This commit is contained in:
parent
e7eacc227f
commit
708d792246
|
@ -240,7 +240,7 @@ KonqView* KonqFrame::childView() const
|
|||
return m_pView;
|
||||
}
|
||||
|
||||
KonqView* KonqFrame::activeChildView()
|
||||
KonqView* KonqFrame::activeChildView() const
|
||||
{
|
||||
return m_pView;
|
||||
}
|
||||
|
|
|
@ -63,6 +63,8 @@ class KonqFrameBase
|
|||
public:
|
||||
virtual ~KonqFrameBase() {}
|
||||
|
||||
virtual bool isContainer() const = 0;
|
||||
|
||||
virtual bool accept( KonqFrameVisitor* visitor ) = 0;
|
||||
|
||||
virtual void saveConfig( KConfigGroup& config, const QString &prefix, bool saveURLs, KonqFrameBase* docContainer, int id = 0, int depth = 0) = 0;
|
||||
|
@ -85,7 +87,7 @@ class KonqFrameBase
|
|||
|
||||
virtual void activateChild() = 0;
|
||||
|
||||
virtual KonqView* activeChildView() = 0;
|
||||
virtual KonqView* activeChildView() const = 0;
|
||||
|
||||
protected:
|
||||
KonqFrameBase() {}
|
||||
|
@ -109,6 +111,8 @@ public:
|
|||
explicit KonqFrame( QWidget* parent, KonqFrameContainerBase *parentContainer = 0 );
|
||||
virtual ~KonqFrame();
|
||||
|
||||
virtual bool isContainer() const { return false; }
|
||||
|
||||
virtual bool accept( KonqFrameVisitor* visitor );
|
||||
|
||||
/**
|
||||
|
@ -166,7 +170,7 @@ public:
|
|||
|
||||
virtual void activateChild();
|
||||
|
||||
virtual KonqView* activeChildView();
|
||||
virtual KonqView* activeChildView() const;
|
||||
|
||||
QString title() const { return m_title; }
|
||||
|
||||
|
|
|
@ -40,6 +40,8 @@ public:
|
|||
*/
|
||||
virtual void removeChildFrame( KonqFrameBase * frame ) = 0;
|
||||
|
||||
virtual bool isContainer() const { return true; }
|
||||
|
||||
virtual QByteArray frameType() { return QByteArray("ContainerBase"); }
|
||||
|
||||
virtual void reparentFrame(QWidget * parent,
|
||||
|
@ -52,7 +54,7 @@ public:
|
|||
|
||||
virtual void activateChild() { if (m_pActiveChild) m_pActiveChild->activateChild(); }
|
||||
|
||||
virtual KonqView* activeChildView() { if (m_pActiveChild) return m_pActiveChild->activeChildView();
|
||||
virtual KonqView* activeChildView() const { if (m_pActiveChild) return m_pActiveChild->activeChildView();
|
||||
else return 0; }
|
||||
|
||||
protected:
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include <kiconloader.h>
|
||||
#include <klocale.h>
|
||||
#include <kstringhandler.h>
|
||||
#include <kcolorscheme.h>
|
||||
|
||||
#include "konqframe.h"
|
||||
#include "konqview.h"
|
||||
|
@ -204,21 +205,21 @@ void KonqFrameTabs::setTitle( const QString &title , QWidget* sender)
|
|||
void KonqFrameTabs::setTabIcon( const KUrl &url, QWidget* sender )
|
||||
{
|
||||
//kDebug(1202) << "KonqFrameTabs::setTabIcon( " << url << " , " << sender << " )" << endl;
|
||||
QIcon iconSet;
|
||||
KIcon iconSet;
|
||||
if (m_permanentCloseButtons)
|
||||
iconSet = KIcon( "window-close" );
|
||||
iconSet = KIcon( "window-close" );
|
||||
else
|
||||
iconSet = KIcon( KonqPixmapProvider::self()->iconNameFor( url ) );
|
||||
if (tabIcon( indexOf( sender ) ).pixmap().serialNumber() != iconSet.pixmap().serialNumber())
|
||||
KTabWidget::setTabIcon( indexOf( sender ), iconSet );
|
||||
iconSet = KIcon( KonqPixmapProvider::self()->iconNameFor( url ) );
|
||||
const int pos = indexOf(sender);
|
||||
if (tabIcon(pos).pixmap().serialNumber() != iconSet.pixmap().serialNumber())
|
||||
KTabWidget::setTabIcon( pos, iconSet );
|
||||
}
|
||||
|
||||
void KonqFrameTabs::activateChild()
|
||||
{
|
||||
if (m_pActiveChild)
|
||||
{
|
||||
setCurrentIndex( indexOf( m_pActiveChild->asQWidget() ) );
|
||||
m_pActiveChild->activateChild();
|
||||
if (m_pActiveChild) {
|
||||
setCurrentIndex( indexOf( m_pActiveChild->asQWidget() ) );
|
||||
m_pActiveChild->activateChild();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -267,17 +268,6 @@ void KonqFrameTabs::removeChildFrame( KonqFrameBase * frame )
|
|||
//kDebug(1202) << "KonqFrameTabs::RemoveChildFrame finished" << endl;
|
||||
}
|
||||
|
||||
void KonqFrameTabs::slotCurrentChanged( QWidget* newPage )
|
||||
{
|
||||
setTabTextColor( indexOf( newPage ), KGlobalSettings::textColor() );
|
||||
KonqFrameBase* currentFrame = dynamic_cast<KonqFrameBase*>(newPage);
|
||||
|
||||
if (currentFrame && !m_pViewManager->isLoadingProfile()) {
|
||||
m_pActiveChild = currentFrame;
|
||||
currentFrame->activateChild();
|
||||
}
|
||||
}
|
||||
|
||||
void KonqFrameTabs::moveTabBackward( int index )
|
||||
{
|
||||
if ( index == 0 )
|
||||
|
@ -540,4 +530,66 @@ bool KonqFrameTabs::accept( KonqFrameVisitor* visitor )
|
|||
return true;
|
||||
}
|
||||
|
||||
void KonqFrameTabs::slotCurrentChanged( QWidget* newPage )
|
||||
{
|
||||
const KColorScheme colorScheme(KColorScheme::Window);
|
||||
setTabTextColor(indexOf(newPage), colorScheme.foreground(KColorScheme::NormalText));
|
||||
|
||||
KonqFrameBase* currentFrame = dynamic_cast<KonqFrameBase*>(newPage);
|
||||
if (currentFrame && !m_pViewManager->isLoadingProfile()) {
|
||||
m_pActiveChild = currentFrame;
|
||||
currentFrame->activateChild();
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
/**
|
||||
* Returns the index position of the tab that contains (directly or indirectly) the frame @p frame,
|
||||
* or -1 if the frame is not in the tab widget.
|
||||
*/
|
||||
int KonqFrameTabs::tabContaining(KonqFrameBase* frame) const
|
||||
{
|
||||
KonqFrameBase* frameBase = frame;
|
||||
while (frameBase && frameBase->parentContainer() != this)
|
||||
frameBase = frameBase->parentContainer();
|
||||
if (frameBase)
|
||||
return indexOf(frameBase->asQWidget());
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
int KonqFrameTabs::tabWhereActive(KonqFrameBase* frame) const
|
||||
{
|
||||
for (int i = 0; i < m_childFrameList.count(); i++ ) {
|
||||
KonqFrameBase* f = m_childFrameList.at(i);
|
||||
while (f && f != frame) {
|
||||
f = f->isContainer() ? static_cast<KonqFrameContainerBase *>(f)->activeChild() : 0;
|
||||
}
|
||||
if (f == frame)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void KonqFrameTabs::setLoading(KonqFrameBase* frame, bool loading)
|
||||
{
|
||||
int pos = tabWhereActive(frame);
|
||||
if (pos == -1)
|
||||
return;
|
||||
|
||||
const KColorScheme colorScheme(KColorScheme::Window);
|
||||
QColor color;
|
||||
if (loading) {
|
||||
color = colorScheme.foreground(KColorScheme::LinkText); // a tab is currently loading
|
||||
} else {
|
||||
if (currentIndex() != pos)
|
||||
color = colorScheme.foreground(KColorScheme::ActiveText); // another tab has newly loaded contents
|
||||
else
|
||||
color = colorScheme.foreground(KColorScheme::NormalText); // this tab has finished loading
|
||||
}
|
||||
setTabTextColor(pos, color);
|
||||
}
|
||||
|
||||
|
||||
#include "konqtabs.moc"
|
||||
|
|
|
@ -84,6 +84,7 @@ public:
|
|||
void moveTabBackward(int index);
|
||||
void moveTabForward(int index);
|
||||
|
||||
void setLoading(KonqFrameBase* frame, bool loading);
|
||||
|
||||
public Q_SLOTS:
|
||||
void slotCurrentChanged( QWidget* newPage );
|
||||
|
@ -97,6 +98,12 @@ private:
|
|||
void refreshSubPopupMenuTab();
|
||||
void hideTabBar();
|
||||
void initPopupMenu();
|
||||
/**
|
||||
* Returns the index position of the tab where the frame @p frame is, assuming that
|
||||
* it's the active frame in that tab,
|
||||
* or -1 if the frame is not in the tab widget or it's not active.
|
||||
*/
|
||||
int tabWhereActive(KonqFrameBase* frame) const;
|
||||
|
||||
private Q_SLOTS:
|
||||
void slotContextMenu( const QPoint& );
|
||||
|
|
|
@ -940,44 +940,8 @@ void KonqViewManager::loadViewProfile( KConfig &cfg, const QString & filename,
|
|||
cfg.setDollarExpansion( true );
|
||||
KConfigGroup profileGroup( &cfg, "Profile" );
|
||||
|
||||
if ( tabContainer()->count() > 1 )
|
||||
{
|
||||
if ( KMessageBox::warningContinueCancel( 0,
|
||||
i18n("You have multiple tabs open in this window.\n"
|
||||
"Loading a view profile will close them."),
|
||||
i18n("Confirmation"),
|
||||
KGuiItem(i18n("Load View Profile")),
|
||||
KStandardGuiItem::cancel(),
|
||||
"LoadProfileTabsConfirm" ) == KMessageBox::Cancel )
|
||||
return;
|
||||
}
|
||||
|
||||
KonqView *originalView = m_pMainWindow->currentView();
|
||||
bool showTabCalled = false;
|
||||
foreach ( KonqFrameBase* frame, m_tabContainer->childFrameList() )
|
||||
{
|
||||
KonqView *view = frame->activeChildView();
|
||||
if (view && view->part() && (view->part()->metaObject()->indexOfProperty("modified") != -1)) {
|
||||
QVariant prop = view->part()->property("modified");
|
||||
if (prop.isValid() && prop.toBool()) {
|
||||
showTab( view );
|
||||
showTabCalled = true;
|
||||
if ( KMessageBox::warningContinueCancel( 0,
|
||||
i18n("This tab contains changes that have not been submitted.\nLoading a profile will discard these changes."),
|
||||
i18n("Discard Changes?"), KGuiItem(i18n("&Discard Changes")), KStandardGuiItem::cancel(), "discardchangesloadprofile") != KMessageBox::Continue )
|
||||
/* WE: maybe KStandardGuiItem(Discard) here? */
|
||||
{
|
||||
showTab( originalView );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( showTabCalled && originalView )
|
||||
showTab( originalView );
|
||||
|
||||
m_currentProfile = filename;
|
||||
m_currentProfileText = profileGroup.readPathEntry("Name",filename);
|
||||
m_currentProfileText = profileGroup.readPathEntry("Name", filename);
|
||||
m_profileHomeURL = profileGroup.readEntry("HomeURL", QString());
|
||||
|
||||
m_pMainWindow->currentProfileChanged();
|
||||
|
@ -1391,7 +1355,8 @@ void KonqViewManager::setProfiles( KActionMenu *profiles )
|
|||
if ( m_pamProfiles )
|
||||
{
|
||||
connect( m_pamProfiles->menu(), SIGNAL( activated( int ) ),
|
||||
this, SLOT( slotProfileActivated( int ) ) ); connect( m_pamProfiles->menu(), SIGNAL( aboutToShow() ),
|
||||
this, SLOT( slotProfileActivated( int ) ) );
|
||||
connect( m_pamProfiles->menu(), SIGNAL( aboutToShow() ),
|
||||
this, SLOT( slotProfileListAboutToShow() ) );
|
||||
}
|
||||
//KonqMainWindow::enableAllActions will call it anyway
|
||||
|
@ -1434,18 +1399,53 @@ void KonqViewManager::profileListDirty( bool broadcast )
|
|||
|
||||
void KonqViewManager::slotProfileActivated( int id )
|
||||
{
|
||||
|
||||
QMap<QString, QString>::ConstIterator iter = m_mapProfileNames.begin();
|
||||
QMap<QString, QString>::ConstIterator end = m_mapProfileNames.end();
|
||||
|
||||
for(int i=0; iter != end; ++iter, ++i) {
|
||||
if( i == id ) {
|
||||
KUrl u;
|
||||
u.setPath( *iter );
|
||||
loadViewProfile( *iter, u.fileName() );
|
||||
break;
|
||||
if ( tabContainer()->count() > 1 )
|
||||
{
|
||||
if ( KMessageBox::warningContinueCancel( m_pMainWindow,
|
||||
i18n("You have multiple tabs open in this window.\n"
|
||||
"Loading a view profile will close them."),
|
||||
i18n("Confirmation"),
|
||||
KGuiItem(i18n("Load View Profile")),
|
||||
KStandardGuiItem::cancel(),
|
||||
"LoadProfileTabsConfirm" ) == KMessageBox::Cancel )
|
||||
return;
|
||||
}
|
||||
KonqView *originalView = m_pMainWindow->currentView();
|
||||
bool showTabCalled = false;
|
||||
foreach ( KonqFrameBase* frame, m_tabContainer->childFrameList() )
|
||||
{
|
||||
KonqView *view = frame->activeChildView();
|
||||
if (view && view->part() && (view->part()->metaObject()->indexOfProperty("modified") != -1)) {
|
||||
QVariant prop = view->part()->property("modified");
|
||||
if (prop.isValid() && prop.toBool()) {
|
||||
showTab( view );
|
||||
showTabCalled = true;
|
||||
if ( KMessageBox::warningContinueCancel( 0,
|
||||
i18n("This tab contains changes that have not been submitted.\nLoading a profile will discard these changes."),
|
||||
i18n("Discard Changes?"), KGuiItem(i18n("&Discard Changes")), KStandardGuiItem::cancel(), "discardchangesloadprofile") != KMessageBox::Continue )
|
||||
/* WE: maybe KStandardGuiItem(Discard) here? */
|
||||
{
|
||||
showTab( originalView );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( showTabCalled && originalView )
|
||||
showTab( originalView );
|
||||
|
||||
|
||||
|
||||
QMap<QString, QString>::ConstIterator iter = m_mapProfileNames.begin();
|
||||
QMap<QString, QString>::ConstIterator end = m_mapProfileNames.end();
|
||||
|
||||
for(int i=0; iter != end; ++iter, ++i) {
|
||||
if( i == id ) {
|
||||
KUrl u( *iter );
|
||||
loadViewProfile( *iter, u.fileName() );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void KonqViewManager::slotProfileListAboutToShow()
|
||||
|
@ -1476,23 +1476,7 @@ void KonqViewManager::slotProfileListAboutToShow()
|
|||
|
||||
void KonqViewManager::setLoading( KonqView *view, bool loading )
|
||||
{
|
||||
KonqFrameContainerBase* parentContainer = view->frame()->parentContainer();
|
||||
if ( parentContainer->frameType() == "Tabs" ) {
|
||||
QColor color;
|
||||
KonqFrameTabs* konqframetabs = static_cast<KonqFrameTabs*>( parentContainer );
|
||||
if ( loading )
|
||||
color = QColor( (KGlobalSettings::linkColor().red() + KGlobalSettings::inactiveTextColor().red())/2,
|
||||
(KGlobalSettings::linkColor().green()+ KGlobalSettings::inactiveTextColor().green())/2,
|
||||
(KGlobalSettings::linkColor().blue() + KGlobalSettings::inactiveTextColor().blue())/2 );
|
||||
else
|
||||
{
|
||||
if ( konqframetabs->currentWidget() != view->frame() )
|
||||
color = KGlobalSettings::linkColor();
|
||||
else
|
||||
color = KGlobalSettings::textColor();
|
||||
}
|
||||
konqframetabs->setTabTextColor( konqframetabs->indexOf( view->frame() ), color );
|
||||
}
|
||||
m_tabContainer->setLoading(view->frame(), loading);
|
||||
}
|
||||
|
||||
void KonqViewManager::showHTML(bool b)
|
||||
|
|
Loading…
Reference in a new issue