00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <qclipboard.h>
00022 #include <qptrlist.h>
00023 #include <qtooltip.h>
00024
00025 #include <kdebug.h>
00026 #include <kaction.h>
00027 #include <kxmlguifactory.h>
00028 #include <kxmlguibuilder.h>
00029 #include <ksystemtray.h>
00030 #include <klocale.h>
00031 #include <kiconeffect.h>
00032 #include <kstandarddirs.h>
00033 #include <kpopupmenu.h>
00034 #include <khelpmenu.h>
00035 #include <kfind.h>
00036 #include <kfinddialog.h>
00037 #include <kkeydialog.h>
00038 #include <kglobalaccel.h>
00039 #include <ksimpleconfig.h>
00040 #include <kwin.h>
00041 #include <kbufferedsocket.h>
00042 #include <kserversocket.h>
00043
00044 #include <libkcal/journal.h>
00045 #include <libkcal/calendarlocal.h>
00046
00047 #include "knotesapp.h"
00048 #include "knote.h"
00049 #include "knotesalarm.h"
00050 #include "knoteconfigdlg.h"
00051 #include "knotesglobalconfig.h"
00052 #include "knoteslegacy.h"
00053 #include "knotesnetrecv.h"
00054
00055 #include "knotes/resourcemanager.h"
00056
00057 using namespace KNetwork;
00058
00059
00060 class KNotesKeyDialog : public KDialogBase
00061 {
00062 public:
00063 KNotesKeyDialog( KGlobalAccel *globals, QWidget *parent, const char* name = 0 )
00064 : KDialogBase( parent, name, true, i18n("Configure Shortcuts"), Default|Ok|Cancel, Ok )
00065 {
00066 m_keyChooser = new KKeyChooser( globals, this );
00067 setMainWidget( m_keyChooser );
00068 connect( this, SIGNAL(defaultClicked()), m_keyChooser, SLOT(allDefault()) );
00069 }
00070
00071 void insert( KActionCollection *actions )
00072 {
00073 m_keyChooser->insert( actions, i18n("Note Actions") );
00074 }
00075
00076 void configure()
00077 {
00078 if ( exec() == Accepted )
00079 m_keyChooser->save();
00080 }
00081
00082 private:
00083 KKeyChooser *m_keyChooser;
00084 };
00085
00086
00087 int KNotesApp::KNoteActionList::compareItems( QPtrCollection::Item s1, QPtrCollection::Item s2 )
00088 {
00089 if ( ((KAction*)s1)->text() == ((KAction*)s2)->text() )
00090 return 0;
00091 return ( ((KAction*)s1)->text() < ((KAction*)s2)->text() ? -1 : 1 );
00092 }
00093
00094
00095 KNotesApp::KNotesApp()
00096 : DCOPObject("KNotesIface"), QLabel( 0, 0, WType_TopLevel ),
00097 m_alarm( 0 ), m_listener( 0 ), m_find( 0 ), m_findPos( 0 )
00098 {
00099 connect( kapp, SIGNAL(lastWindowClosed()), kapp, SLOT(quit()) );
00100
00101 m_noteList.setAutoDelete( true );
00102 m_noteActions.setAutoDelete( true );
00103
00104
00105 KWin::setSystemTrayWindowFor( winId(), qt_xrootwin() );
00106 QToolTip::add( this, i18n( "KNotes: Sticky notes for KDE" ) );
00107 setBackgroundMode( X11ParentRelative );
00108 setPixmap( KSystemTray::loadIcon( "knotes" ) );
00109
00110
00111 KNote::setStyle( KNotesGlobalConfig::style() );
00112
00113
00114 new KAction( i18n("New Note"), "filenew", 0,
00115 this, SLOT(newNote()), actionCollection(), "new_note" );
00116 new KAction( i18n("New Note From Clipboard"), "editpaste", 0,
00117 this, SLOT(newNoteFromClipboard()), actionCollection(), "new_note_clipboard" );
00118 new KAction( i18n("Show All Notes"), "knotes", 0,
00119 this, SLOT(showAllNotes()), actionCollection(), "show_all_notes" );
00120 new KAction( i18n("Hide All Notes"), "fileclose", 0,
00121 this, SLOT(hideAllNotes()), actionCollection(), "hide_all_notes" );
00122 new KHelpMenu( this, kapp->aboutData(), false, actionCollection() );
00123
00124 m_findAction = KStdAction::find( this, SLOT(slotOpenFindDialog()), actionCollection() );
00125 KStdAction::preferences( this, SLOT(slotPreferences()), actionCollection() );
00126 KStdAction::keyBindings( this, SLOT(slotConfigureAccels()), actionCollection() );
00127
00128 KStdAction::quit( this, SLOT(slotQuit()), actionCollection() )->setShortcut( 0 );
00129
00130 setXMLFile( instance()->instanceName() + "appui.rc" );
00131
00132 m_guiBuilder = new KXMLGUIBuilder( this );
00133 m_guiFactory = new KXMLGUIFactory( m_guiBuilder, this );
00134 m_guiFactory->addClient( this );
00135
00136 m_context_menu = static_cast<KPopupMenu*>(m_guiFactory->container( "knotes_context", this ));
00137 m_note_menu = static_cast<KPopupMenu*>(m_guiFactory->container( "notes_menu", this ));
00138
00139
00140 QString xmlFileName = instance()->instanceName() + "ui.rc";
00141 QString filter = QString::fromLatin1( instance()->instanceName() + '/' ) + xmlFileName;
00142 QStringList fileList = instance()->dirs()->findAllResources( "data", filter ) +
00143 instance()->dirs()->findAllResources( "data", xmlFileName );
00144
00145 QString doc;
00146 KXMLGUIClient::findMostRecentXMLFile( fileList, doc );
00147 m_noteGUI.setContent( doc );
00148
00149
00150 m_globalAccel = new KGlobalAccel( this, "global accel" );
00151 m_globalAccel->insert( "global_new_note", i18n("New Note"), "",
00152 ALT+SHIFT+Key_N, ALT+SHIFT+Key_N ,
00153 this, SLOT(newNote()), true, true );
00154 m_globalAccel->insert( "global_new_note_clipboard", i18n("New Note From Clipboard"), "",
00155 ALT+SHIFT+Key_C, ALT+SHIFT+Key_C,
00156 this, SLOT(newNoteFromClipboard()), true, true );
00157 m_globalAccel->insert( "global_hide_all_notes", i18n("Hide All Notes"), "",
00158 ALT+SHIFT+Key_H, ALT+SHIFT+Key_H ,
00159 this, SLOT(hideAllNotes()), true, true );
00160 m_globalAccel->insert( "global_show_all_notes", i18n("Show All Notes"), "",
00161 ALT+SHIFT+Key_S, ALT+SHIFT+Key_S,
00162 this, SLOT(showAllNotes()), true, true );
00163
00164 m_globalAccel->readSettings();
00165
00166 KConfig *config = KGlobal::config();
00167 config->setGroup( "Global Keybindings" );
00168 m_globalAccel->setEnabled( config->readBoolEntry( "Enabled", true ) );
00169
00170 updateGlobalAccels();
00171
00172
00173 KNotesLegacy::cleanUp();
00174
00175
00176 m_manager = new KNotesResourceManager();
00177 connect( m_manager, SIGNAL(sigRegisteredNote( KCal::Journal * )),
00178 this, SLOT(createNote( KCal::Journal * )) );
00179 connect( m_manager, SIGNAL(sigDeregisteredNote( KCal::Journal * )),
00180 this, SLOT(killNote( KCal::Journal * )) );
00181
00182
00183 m_manager->load();
00184
00185
00186 KCal::CalendarLocal calendar( QString::fromLatin1( "UTC" ) );
00187 if ( KNotesLegacy::convert( &calendar ) )
00188 {
00189 KCal::Journal::List notes = calendar.journals();
00190 KCal::Journal::List::ConstIterator it;
00191 for ( it = notes.constBegin(); it != notes.constEnd(); ++it )
00192 m_manager->addNewNote( *it );
00193
00194 m_manager->save();
00195 }
00196
00197
00198
00199 m_alarm = new KNotesAlarm( m_manager, this );
00200
00201
00202 m_listener = new KServerSocket();
00203 m_listener->setResolutionEnabled( true );
00204 connect( m_listener, SIGNAL(readyAccept()), SLOT(acceptConnection()) );
00205 updateNetworkListener();
00206
00207 if ( m_noteList.count() == 0 && !kapp->isRestored() )
00208 newNote();
00209
00210 updateNoteActions();
00211 }
00212
00213 KNotesApp::~KNotesApp()
00214 {
00215 saveNotes();
00216
00217 blockSignals( true );
00218 m_noteList.clear();
00219 blockSignals( false );
00220
00221 delete m_listener;
00222 delete m_manager;
00223 delete m_guiBuilder;
00224 }
00225
00226 bool KNotesApp::commitData( QSessionManager& )
00227 {
00228 saveConfigs();
00229 return true;
00230 }
00231
00232
00233
00234 QString KNotesApp::newNote( const QString& name, const QString& text )
00235 {
00236
00237 KCal::Journal *journal = new KCal::Journal();
00238
00239
00240 if ( !name.isEmpty() )
00241 journal->setSummary( name );
00242 else
00243 journal->setSummary( KGlobal::locale()->formatDateTime( QDateTime::currentDateTime() ) );
00244
00245
00246 journal->setDescription( text );
00247
00248 m_manager->addNewNote( journal );
00249
00250 showNote( journal->uid() );
00251
00252 return journal->uid();
00253 }
00254
00255 QString KNotesApp::newNoteFromClipboard( const QString& name )
00256 {
00257 const QString& text = KApplication::clipboard()->text();
00258 return newNote( name, text );
00259 }
00260
00261 void KNotesApp::hideAllNotes() const
00262 {
00263 QDictIterator<KNote> it( m_noteList );
00264 for ( ; *it; ++it )
00265 (*it)->close();
00266 }
00267
00268 void KNotesApp::showAllNotes() const
00269 {
00270 QDictIterator<KNote> it( m_noteList );
00271 for ( ; *it; ++it )
00272 {
00273 (*it)->show();
00274 }
00275 }
00276
00277 void KNotesApp::showNote( const QString& id ) const
00278 {
00279 KNote* note = m_noteList[id];
00280 if ( note )
00281 showNote( note );
00282 else
00283 kdWarning(5500) << "showNote: no note with id: " << id << endl;
00284 }
00285
00286 void KNotesApp::hideNote( const QString& id ) const
00287 {
00288 KNote* note = m_noteList[id];
00289 if ( note )
00290 note->hide();
00291 else
00292 kdWarning(5500) << "hideNote: no note with id: " << id << endl;
00293 }
00294
00295 void KNotesApp::killNote( const QString& id, bool force )
00296 {
00297 KNote* note = m_noteList[id];
00298 if ( note )
00299 note->slotKill( force );
00300 else
00301 kdWarning(5500) << "killNote: no note with id: " << id << endl;
00302 }
00303
00304
00305 void KNotesApp::killNote( const QString& id )
00306 {
00307 killNote( id, false );
00308 }
00309
00310 QMap<QString,QString> KNotesApp::notes() const
00311 {
00312 QMap<QString,QString> notes;
00313 QDictIterator<KNote> it( m_noteList );
00314
00315 for ( ; it.current(); ++it )
00316 notes.insert( it.current()->noteId(), it.current()->name() );
00317
00318 return notes;
00319 }
00320
00321 QString KNotesApp::name( const QString& id ) const
00322 {
00323 KNote* note = m_noteList[id];
00324 if ( note )
00325 return note->name();
00326 else
00327 return QString::null;
00328 }
00329
00330 QString KNotesApp::text( const QString& id ) const
00331 {
00332 KNote* note = m_noteList[id];
00333 if ( note )
00334 return note->text();
00335 else
00336 return QString::null;
00337 }
00338
00339 void KNotesApp::setName( const QString& id, const QString& newName )
00340 {
00341 KNote* note = m_noteList[id];
00342 if ( note )
00343 note->setName( newName );
00344 else
00345 kdWarning(5500) << "setName: no note with id: " << id << endl;
00346 }
00347
00348 void KNotesApp::setText( const QString& id, const QString& newText )
00349 {
00350 KNote* note = m_noteList[id];
00351 if ( note )
00352 note->setText( newText );
00353 else
00354 kdWarning(5500) << "setText: no note with id: " << id << endl;
00355 }
00356
00357 QString KNotesApp::fgColor( const QString& id ) const
00358 {
00359 KNote* note = m_noteList[id];
00360 if ( note )
00361 return note->fgColor().name();
00362 else
00363 return QString::null;
00364 }
00365
00366 QString KNotesApp::bgColor( const QString& id ) const
00367 {
00368 KNote* note = m_noteList[id];
00369 if ( note )
00370 return note->bgColor().name();
00371 else
00372 return QString::null;
00373 }
00374
00375 void KNotesApp::setColor( const QString& id, const QString& fgColor, const QString& bgColor )
00376 {
00377 KNote* note = m_noteList[id];
00378 if ( note )
00379 note->setColor( QColor( fgColor ), QColor( bgColor ) );
00380 else
00381 kdWarning(5500) << "setColor: no note with id: " << id << endl;
00382 }
00383
00384 int KNotesApp::width( const QString& id ) const
00385 {
00386 KNote* note = m_noteList[id];
00387 if ( note )
00388 return note->width();
00389 else
00390 return 0;
00391 }
00392
00393 int KNotesApp::height( const QString& id ) const
00394 {
00395 KNote* note = m_noteList[id];
00396 if ( note )
00397 return note->height();
00398 else
00399 return 0;
00400 }
00401
00402 void KNotesApp::move( const QString& id, int x, int y ) const
00403 {
00404 KNote* note = m_noteList[id];
00405 if ( note )
00406 return note->move( x, y );
00407 else
00408 kdWarning(5500) << "move: no note with id: " << id << endl;
00409 }
00410
00411 void KNotesApp::resize( const QString& id, int width, int height ) const
00412 {
00413 KNote* note = m_noteList[id];
00414 if ( note )
00415 return note->resize( width, height );
00416 else
00417 kdWarning(5500) << "resize: no note with id: " << id << endl;
00418 }
00419
00420 void KNotesApp::sync( const QString& app )
00421 {
00422 QDictIterator<KNote> it( m_noteList );
00423
00424 for ( ; it.current(); ++it )
00425 it.current()->sync( app );
00426 }
00427
00428 bool KNotesApp::isNew( const QString& app, const QString& id ) const
00429 {
00430 KNote* note = m_noteList[id];
00431 if ( note )
00432 return note->isNew( app );
00433 else
00434 return false;
00435 }
00436
00437 bool KNotesApp::isModified( const QString& app, const QString& id ) const
00438 {
00439 KNote* note = m_noteList[id];
00440 if ( note )
00441 return note->isModified( app );
00442 else
00443 return false;
00444 }
00445
00446
00447
00448
00449 void KNotesApp::mousePressEvent( QMouseEvent* e )
00450 {
00451 if ( !rect().contains( e->pos() ) )
00452 return;
00453
00454 switch ( e->button() )
00455 {
00456 case LeftButton:
00457 if ( m_noteList.count() == 1 )
00458 {
00459 QDictIterator<KNote> it( m_noteList );
00460 showNote( it.toFirst() );
00461 }
00462 else if ( m_note_menu->count() > 0 )
00463 m_note_menu->popup( e->globalPos() );
00464 break;
00465 case MidButton:
00466 newNote();
00467 break;
00468 case RightButton:
00469 m_context_menu->popup( e->globalPos() );
00470 default: break;
00471 }
00472 }
00473
00474
00475
00476 void KNotesApp::slotShowNote()
00477 {
00478
00479 showNote( QString::fromUtf8( sender()->name() ) );
00480 }
00481
00482 void KNotesApp::slotWalkThroughNotes()
00483 {
00484
00485 QDictIterator<KNote> it( m_noteList );
00486 KNote *first = it.toFirst();
00487 for ( ; *it; ++it )
00488 if ( (*it)->hasFocus() )
00489 {
00490 if ( ++it )
00491 showNote( *it );
00492 else
00493 showNote( first );
00494 break;
00495 }
00496 }
00497
00498 void KNotesApp::slotOpenFindDialog()
00499 {
00500 KFindDialog findDia( this, "find_dialog" );
00501 findDia.setHasSelection( false );
00502 findDia.setHasCursor( false );
00503 findDia.setSupportsBackwardsFind( false );
00504
00505 if ( (findDia.exec() != QDialog::Accepted) || findDia.pattern().isEmpty() )
00506 return;
00507
00508 delete m_findPos;
00509 m_findPos = new QDictIterator<KNote>( m_noteList );
00510
00511
00512 delete m_find;
00513 m_find = new KFind( findDia.pattern(), findDia.options(), this );
00514
00515 slotFindNext();
00516 }
00517
00518 void KNotesApp::slotFindNext()
00519 {
00520 if ( **m_findPos )
00521 {
00522 KNote *note = **m_findPos;
00523 ++*m_findPos;
00524 note->find( m_find->pattern(), m_find->options() );
00525 }
00526 else
00527 {
00528 m_find->displayFinalDialog();
00529 delete m_find;
00530 m_find = 0;
00531 delete m_findPos;
00532 m_findPos = 0;
00533 }
00534 }
00535
00536 void KNotesApp::slotPreferences()
00537 {
00538
00539 if ( KNoteConfigDlg::showDialog( "KNotes Default Settings" ) )
00540 return;
00541
00542
00543 KNoteConfigDlg *dialog = new KNoteConfigDlg( 0, i18n("Settings"), this,
00544 "KNotes Settings" );
00545 connect( dialog, SIGNAL(settingsChanged()), this, SLOT(updateNetworkListener()) );
00546 connect( dialog, SIGNAL(settingsChanged()), this, SLOT(updateStyle()) );
00547 dialog->show();
00548 }
00549
00550 void KNotesApp::slotConfigureAccels()
00551 {
00552 KNotesKeyDialog keys( m_globalAccel, this );
00553 QDictIterator<KNote> notes( m_noteList );
00554 if ( !m_noteList.isEmpty() )
00555 keys.insert( (*notes)->actionCollection() );
00556 keys.configure();
00557
00558 m_globalAccel->writeSettings();
00559 updateGlobalAccels();
00560
00561
00562 m_noteGUI.setContent(
00563 KXMLGUIFactory::readConfigFile( instance()->instanceName() + "ui.rc", instance() )
00564 );
00565
00566 if ( m_noteList.isEmpty() )
00567 return;
00568
00569 notes.toFirst();
00570 QValueList<KAction *> list = (*notes)->actionCollection()->actions();
00571 for ( QValueList<KAction *>::iterator it = list.begin(); it != list.end(); ++it )
00572 {
00573 notes.toFirst();
00574 for ( ++notes; *notes; ++notes )
00575 {
00576 KAction *toChange = (*notes)->actionCollection()->action( (*it)->name() );
00577 if ( toChange->shortcut() != (*it)->shortcut() )
00578 toChange->setShortcut( (*it)->shortcut() );
00579 }
00580 }
00581 }
00582
00583 void KNotesApp::slotNoteKilled( KCal::Journal *journal )
00584 {
00585 m_noteUidModify="";
00586 m_manager->deleteNote( journal );
00587 saveNotes();
00588 }
00589
00590 void KNotesApp::slotQuit()
00591 {
00592 QDictIterator<KNote> it( m_noteList );
00593
00594 for ( ; *it; ++it )
00595 if ( (*it)->isModified() )
00596 (*it)->saveData(false);
00597
00598 saveConfigs();
00599 kapp->quit();
00600 }
00601
00602
00603
00604
00605 void KNotesApp::showNote( KNote* note ) const
00606 {
00607 note->show();
00608 KWin::setCurrentDesktop( KWin::windowInfo( note->winId() ).desktop() );
00609 KWin::forceActiveWindow( note->winId() );
00610 note->setFocus();
00611 }
00612
00613 void KNotesApp::createNote( KCal::Journal *journal )
00614 {
00615 if( journal->uid() == m_noteUidModify)
00616 {
00617 KNote *note = m_noteList[m_noteUidModify];
00618 if ( note )
00619 note->changeJournal(journal);
00620
00621 return;
00622 }
00623 m_noteUidModify = journal->uid();
00624 KNote *newNote = new KNote( m_noteGUI, journal, 0, journal->uid().utf8() );
00625 m_noteList.insert( newNote->noteId(), newNote );
00626
00627 connect( newNote, SIGNAL(sigRequestNewNote()), SLOT(newNote()) );
00628 connect( newNote, SIGNAL(sigShowNextNote()), SLOT(slotWalkThroughNotes()) );
00629 connect( newNote, SIGNAL(sigKillNote( KCal::Journal* )),
00630 SLOT(slotNoteKilled( KCal::Journal* )) );
00631 connect( newNote, SIGNAL(sigNameChanged()), SLOT(updateNoteActions()) );
00632 connect( newNote, SIGNAL(sigDataChanged(const QString &)), SLOT(saveNotes(const QString &)) );
00633 connect( newNote, SIGNAL(sigColorChanged()), SLOT(updateNoteActions()) );
00634 connect( newNote, SIGNAL(sigFindFinished()), SLOT(slotFindNext()) );
00635
00636
00637 if ( m_alarm )
00638 updateNoteActions();
00639 }
00640
00641 void KNotesApp::killNote( KCal::Journal *journal )
00642 {
00643 if(m_noteUidModify == journal->uid())
00644 {
00645 return;
00646 }
00647
00648 KNote *note = m_noteList.take( journal->uid() );
00649 if ( note )
00650 {
00651 note->deleteWhenIdle();
00652 updateNoteActions();
00653 }
00654 }
00655
00656 void KNotesApp::acceptConnection()
00657 {
00658
00659 KBufferedSocket *s = static_cast<KBufferedSocket *>(m_listener->accept());
00660 if ( s )
00661 {
00662 KNotesNetworkReceiver *recv = new KNotesNetworkReceiver( s );
00663 connect( recv, SIGNAL(sigNoteReceived( const QString &, const QString & )),
00664 this, SLOT(newNote( const QString &, const QString & )) );
00665 }
00666 }
00667
00668 void KNotesApp::saveNotes( const QString & uid )
00669 {
00670 m_noteUidModify = uid;
00671 saveNotes();
00672 }
00673
00674 void KNotesApp::saveNotes()
00675 {
00676 KNotesGlobalConfig::writeConfig();
00677 m_manager->save();
00678 }
00679
00680 void KNotesApp::saveConfigs()
00681 {
00682 QDictIterator<KNote> it( m_noteList );
00683 for ( ; it.current(); ++it )
00684 it.current()->saveConfig();
00685 }
00686
00687 void KNotesApp::updateNoteActions()
00688 {
00689 unplugActionList( "notes" );
00690 m_noteActions.clear();
00691
00692 for ( QDictIterator<KNote> it( m_noteList ); it.current(); ++it )
00693 {
00694 KAction *action = new KAction( it.current()->name().replace("&", "&&"),
00695 KShortcut(), this, SLOT(slotShowNote()),
00696 (QObject *)0,
00697 it.current()->noteId().utf8() );
00698 KIconEffect effect;
00699 QPixmap icon = effect.apply( kapp->miniIcon(), KIconEffect::Colorize, 1,
00700 it.current()->paletteBackgroundColor(), false );
00701 action->setIconSet( icon );
00702 m_noteActions.append( action );
00703 }
00704
00705 if ( m_noteActions.isEmpty() )
00706 {
00707 actionCollection()->action( "hide_all_notes" )->setEnabled( false );
00708 actionCollection()->action( "show_all_notes" )->setEnabled( false );
00709 m_findAction->setEnabled( false );
00710 KAction *action = new KAction( i18n("No Notes") );
00711 m_noteActions.append( action );
00712 }
00713 else
00714 {
00715 actionCollection()->action( "hide_all_notes" )->setEnabled( true );
00716 actionCollection()->action( "show_all_notes" )->setEnabled( true );
00717 m_findAction->setEnabled( true );
00718 m_noteActions.sort();
00719 }
00720 plugActionList( "notes", m_noteActions );
00721 }
00722
00723 void KNotesApp::updateGlobalAccels()
00724 {
00725 if ( m_globalAccel->isEnabled() )
00726 {
00727 KAction *action = actionCollection()->action( "new_note" );
00728 if ( action )
00729 action->setShortcut( m_globalAccel->shortcut( "global_new_note" ) );
00730 action = actionCollection()->action( "new_note_clipboard" );
00731 if ( action )
00732 action->setShortcut( m_globalAccel->shortcut( "global_new_note_clipboard" ) );
00733 action = actionCollection()->action( "hide_all_notes" );
00734 if ( action )
00735 action->setShortcut( m_globalAccel->shortcut( "global_hide_all_notes" ) );
00736 action = actionCollection()->action( "show_all_notes" );
00737 if ( action )
00738 action->setShortcut( m_globalAccel->shortcut( "global_show_all_notes" ) );
00739
00740 m_globalAccel->updateConnections();
00741 }
00742 else
00743 {
00744 KAction *action = actionCollection()->action( "new_note" );
00745 if ( action )
00746 action->setShortcut( 0 );
00747 action = actionCollection()->action( "new_note_clipboard" );
00748 if ( action )
00749 action->setShortcut( 0 );
00750 action = actionCollection()->action( "hide_all_notes" );
00751 if ( action )
00752 action->setShortcut( 0 );
00753 action = actionCollection()->action( "show_all_notes" );
00754 if ( action )
00755 action->setShortcut( 0 );
00756 }
00757 }
00758
00759 void KNotesApp::updateNetworkListener()
00760 {
00761 m_listener->close();
00762
00763 if ( KNotesGlobalConfig::receiveNotes() )
00764 {
00765 m_listener->setAddress( QString::number( KNotesGlobalConfig::port() ) );
00766 m_listener->bind();
00767 m_listener->listen();
00768 }
00769 }
00770
00771 void KNotesApp::updateStyle()
00772 {
00773 KNote::setStyle( KNotesGlobalConfig::style() );
00774
00775 QDictIterator<KNote> it( m_noteList );
00776 for ( ; it.current(); ++it )
00777 QApplication::postEvent( *it, new QEvent( QEvent::LayoutHint ) );
00778 }
00779
00780 #include "knotesapp.moc"