25 #include "mainwindow.h"
26 #include "akregator_part.h"
27 #include "akregatorconfig.h"
31 #include <dcopclient.h>
33 #include <tdeaction.h>
34 #include <tdeapplication.h>
35 #include <tdeconfig.h>
37 #include <kedittoolbar.h>
38 #include <tdefiledialog.h>
39 #include <tdeglobal.h>
40 #include <kkeydialog.h>
41 #include <klibloader.h>
42 #include <tdelocale.h>
43 #include <tdemessagebox.h>
44 #include <tdeparts/partmanager.h>
45 #include <ksqueezedtextlabel.h>
46 #include <kstandarddirs.h>
47 #include <kstatusbar.h>
48 #include <kstdaction.h>
51 #include "progressdialog.h"
52 #include "statusbarprogresswidget.h"
55 #include <tqmetaobject.h>
57 #include <tqpainter.h>
58 #include <private/tqucomextra_p.h>
64 BrowserInterface::BrowserInterface( MainWindow *shell,
const char *name )
65 : KParts::BrowserInterface( shell, name )
70 MainWindow::MainWindow()
71 : KParts::MainWindow( 0L,
"akregator_mainwindow" ){
73 setXMLFile(
"akregator_shell.rc");
75 m_browserIface=
new BrowserInterface(
this,
"browser_interface");
85 int statH=fontMetrics().height()+2;
86 m_statusLabel =
new KSqueezedTextLabel(
this);
87 m_statusLabel->setTextFormat(TQt::RichText);
88 m_statusLabel->setSizePolicy(TQSizePolicy( TQSizePolicy::Ignored, TQSizePolicy::Fixed ));
89 m_statusLabel->setMinimumWidth( 0 );
90 m_statusLabel->setFixedHeight( statH );
91 statusBar()->addWidget (m_statusLabel, 1,
false);
97 bool MainWindow::loadPart()
102 KLibFactory *factory = KLibLoader::self()->factory(
"libakregatorpart");
107 m_part =
static_cast<Akregator::Part*
>(factory->create(
this,
"akregator_part",
"KParts::ReadOnlyPart" ));
112 setCentralWidget(m_part->widget());
114 connect(m_part, TQ_SIGNAL(setWindowCaption (
const TQString &)),
this, TQ_SLOT(setCaption (
const TQString &)));
116 connect(TrayIcon::getInstance(), TQ_SIGNAL(quitSelected()),
this, TQ_SLOT(slotQuit()));
118 connectActionCollection(m_part->actionCollection());
120 browserExtension(m_part)->setBrowserInterface(m_browserIface);
121 setAutoSaveSettings();
128 KMessageBox::error(
this, i18n(
"Could not find the Akregator part; please check your installation."));
134 void MainWindow::setupProgressWidgets()
136 KPIM::ProgressDialog *progressDialog =
new KPIM::ProgressDialog( statusBar(),
this );
137 progressDialog->raise();
138 progressDialog->hide();
139 m_progressBar =
new KPIM::StatusbarProgressWidget( progressDialog, statusBar() );
140 m_progressBar->show();
141 statusBar()->addWidget( m_progressBar, 0,
true );
144 MainWindow::~MainWindow()
148 void MainWindow::setCaption(
const TQString &a)
150 KParts::MainWindow::setCaption(a);
153 void MainWindow::setupActions()
155 connectActionCollection(actionCollection());
157 KStdAction::quit(kapp, TQ_SLOT(quit()), actionCollection());
159 setStandardToolBarMenuEnabled(
true);
160 createStandardStatusBarAction();
162 KStdAction::keyBindings(
this, TQ_SLOT(optionsConfigureKeys()), actionCollection());
163 KStdAction::configureToolbars(
this, TQ_SLOT(optionsConfigureToolbars()), actionCollection());
166 void MainWindow::saveProperties(TDEConfig* config)
172 config->writeEntry(
"docked", isHidden());
177 void MainWindow::readProperties(TDEConfig* config)
183 if (Settings::showTrayIcon() && config->readBoolEntry(
"docked",
false))
189 void MainWindow::optionsConfigureKeys()
191 KKeyDialog dlg(
true,
this );
193 dlg.insert(actionCollection());
195 dlg.insert(m_part->actionCollection());
200 void MainWindow::optionsConfigureToolbars()
202 saveMainWindowSettings(TDEGlobal::config(), autoSaveGroup());
205 KEditToolbar dlg(factory());
206 connect(&dlg, TQ_SIGNAL(newToolbarConfig()),
207 this, TQ_SLOT(applyNewToolbarConfig()));
213 void MainWindow::applyNewToolbarConfig()
215 applyMainWindowSettings(TDEGlobal::config(), autoSaveGroup());
219 KParts::BrowserExtension *MainWindow::browserExtension(KParts::ReadOnlyPart *p)
221 return KParts::BrowserExtension::childObject( p );
226 void MainWindow::connectActionCollection( TDEActionCollection *coll )
229 connect( coll, TQ_SIGNAL( actionStatusText(
const TQString & ) ),
230 m_statusLabel, TQ_SLOT( setText(
const TQString & ) ) );
231 connect( coll, TQ_SIGNAL( clearStatusText() ),
232 this, TQ_SLOT( slotClearStatusText() ) );
235 bool MainWindow::queryExit()
237 kdDebug() <<
"MainWindow::queryExit()" << endl;
238 if ( !kapp->sessionSaving() )
244 kdDebug(
"MainWindow::queryExit(): saving session");
246 return TDEMainWindow::queryExit();
249 void MainWindow::slotQuit()
251 if (TrayIcon::getInstance())
252 TrayIcon::getInstance()->hide();
256 bool MainWindow::queryClose()
258 if (kapp->sessionSaving() || TrayIcon::getInstance() == 0 || TrayIcon::getInstance()->isHidden() )
264 TQPixmap shot = TrayIcon::getInstance()->takeScreenshot();
267 TQMimeSourceFactory::defaultFactory()->setPixmap(
"systray_shot", shot);
268 KMessageBox::information(
this, i18n(
"<qt><p>Closing the main window will keep Akregator running in the system tray. Use 'Quit' from the 'File' menu to quit the application.</p><p><center><img source=\"systray_shot\"></center></p></qt>" ), i18n(
"Docking in System Tray" ),
"hideOnCloseInfo");
275 void MainWindow::slotClearStatusText()
277 m_statusLabel->setText(TQString());
280 void MainWindow::slotSetStatusBarText(
const TQString & text )
282 m_statusLabel->setText(text);
287 #include "mainwindow.moc"
This is a RSS Aggregator "Part".