2 KNode, the KDE newsreader
3 Copyright (c) 1999-2006 the KNode authors.
4 See file AUTHORS for details
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10 You should have received a copy of the GNU General Public License
11 along with this program; if not, write to the Free Software Foundation,
12 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, US
15 #include "knglobals.h"
17 #include <QApplication>
19 #include <kshortcutsdialog.h>
20 #include <kedittoolbar.h>
21 #include <kstandardaction.h>
24 #include <kiconloader.h>
25 #include <kstatusbar.h>
27 #include <kactioncollection.h>
28 #include <ksqueezedtextlabel.h>
30 #include "broadcaststatus.h"
31 #include "progressdialog.h"
32 #include "statusbarprogresswidget.h"
35 #include "knmainwidget.h"
36 #include "kncollectionviewitem.h"
37 #include "knhdrviewitem.h"
39 KNMainWindow::KNMainWindow( QWidget
* parent
)
40 : KXmlGuiWindow( parent
)
43 createStandardStatusBarAction();
44 setStandardToolBarMenuEnabled(true);
47 KStandardAction::quit(qApp
, SLOT(closeAllWindows()), actionCollection());
48 KStandardAction::configureToolbars(this, SLOT(slotConfToolbar()), actionCollection());
49 KStandardAction::keyBindings(this, SLOT(slotConfKeys()), actionCollection());
51 m_mainWidget
= new KNMainWidget( this, this );
52 connect( m_mainWidget
, SIGNAL(signalCaptionChangeRequest(const QString
&)),
53 SLOT( setCaption(const QString
&)) );
54 setCentralWidget( m_mainWidget
);
56 connect( KPIM::BroadcastStatus::instance(), SIGNAL(statusMsg(const QString
&)),
57 this, SLOT(slotShowStatusMsg(const QString
& )) );
58 createGUI( "knodeui.rc" );
59 knGlobals
.setComponentData( KComponentData() );
61 applyMainWindowSettings(KGlobal::config()->group( "mainWindow_options") );
64 KNMainWindow::~KNMainWindow()
66 saveMainWindowSettings(knGlobals
.config()->group( "mainWindow_options") );
69 void KNMainWindow::openURL( const KUrl
& url
)
71 m_mainWidget
->openURL( url
);
74 void KNMainWindow::slotConfToolbar()
76 saveMainWindowSettings(knGlobals
.config()->group( "mainWindow_options") );
77 KEditToolBar
dlg( actionCollection() );
78 dlg
.setResourceFile( "knodeui.rc" );
79 connect(&dlg
,SIGNAL( newToolbarConfig() ), this, SLOT( slotNewToolbarConfig() ));
83 void KNMainWindow::slotNewToolbarConfig()
85 createGUI("knodeui.rc");
87 applyMainWindowSettings(knGlobals
.config()->group( "mainWindow_options") );
90 void KNMainWindow::slotConfKeys()
92 KShortcutsDialog::configure(actionCollection(), KShortcutsEditor::LetterShortcutsAllowed
);
95 bool KNMainWindow::queryClose()
97 return m_mainWidget
->queryClose();
100 void KNMainWindow::setupStatusBar()
102 mProgressDialog
= new KPIM::ProgressDialog( statusBar(), this );
103 mProgressDialog
->hide();
105 mLittleProgress
= new StatusbarProgressWidget( mProgressDialog
, statusBar() );
106 mLittleProgress
->show();
108 statusBar()->addPermanentWidget( mLittleProgress
, 0 );
110 mStatusMsgLabel
= new KSqueezedTextLabel( QString(), statusBar() );
111 mStatusMsgLabel
->setTextElideMode( Qt::ElideRight
);
112 mStatusMsgLabel
->setAlignment( Qt::AlignLeft
| Qt::AlignVCenter
);
113 statusBar()->addWidget( mStatusMsgLabel
, 2 );
114 statusBar()->addWidget(m_mainWidget
->statusBarLabelFilter(), 2);
115 statusBar()->addWidget(m_mainWidget
->statusBarLabelGroup(), 3);
118 void KNMainWindow::slotShowStatusMsg( const QString
&msg
) {
119 mStatusMsgLabel
->setText( msg
);