32 #include "knotesglobalconfig.h"
33 #include "kdepim-version.h"
36 #include <kactioncollection.h>
37 #include <kapplication.h>
38 #include <kcal/journal.h>
39 #include <kcombobox.h>
40 #include <kfiledialog.h>
42 #include <kglobalsettings.h>
44 #include <kiconeffect.h>
45 #include <kiconloader.h>
46 #include <kinputdialog.h>
47 #include <kio/netaccess.h>
50 #include <kmessagebox.h>
52 #include <kselectaction.h>
53 #include <ksocketfactory.h>
54 #include <kstandardaction.h>
55 #include <kstandarddirs.h>
56 #include <ktoggleaction.h>
58 #include <kwindowsystem.h>
59 #include <kxmlguibuilder.h>
60 #include <kxmlguifactory.h>
62 #include <KPrintPreview>
67 #include <QHBoxLayout>
73 #include <QTextStream>
74 #include <QVBoxLayout>
75 #include <QDesktopWidget>
77 #include <QFocusEvent>
88 :
QFrame( parent, Qt::FramelessWindowHint ),
97 m_kwinConf( KSharedConfig::openConfig( QLatin1String(
"kwinrc") ) ),
98 m_blockEmitDataChanged( false ),
99 mBlockWriteConfigDuringCommitData( false )
101 setAcceptDrops(
true );
102 setAttribute( Qt::WA_DeleteOnClose );
103 setDOMDocument( buildDoc );
104 setObjectName( m_journal->uid() );
105 setXMLFile( componentData().componentName() + QLatin1String(
"ui.rc"),
false,
false );
108 m_noteLayout =
new QVBoxLayout(
this );
109 m_noteLayout->setMargin( 0 );
113 if ( m_journal->summary().isNull() && m_journal->dtStart().isValid() ) {
114 const QString s = KGlobal::locale()->formatDateTime( m_journal->dtStart() );
115 m_journal->setSummary( s );
123 buildGui(configFile);
136 m_editor->
setText( m_journal->description() );
137 m_editor->document()->setModified(
false );
138 m_label->setText( m_journal->summary() );
139 updateLabelAlignment();
147 m_blockEmitDataChanged =
true;
149 ( KMessageBox::warningContinueCancel(
this,
150 i18n(
"<qt>Do you really want to delete note <b>%1</b>?</qt>",
152 i18n(
"Confirm Delete" ),
153 KGuiItem( i18n(
"&Delete" ), QLatin1String(
"edit-delete") ),
154 KStandardGuiItem::cancel(),
155 QLatin1String(
"ConfirmDeleteNote") ) != KMessageBox::Continue ) ) {
156 m_blockEmitDataChanged =
false;
172 m_journal->setSummary( m_label->text() );
173 m_journal->setDescription( m_editor->
text() );
179 m_editor->document()->setModified(
false );
190 NETWinInfo wm_client( QX11Info::display(), winId(),
191 QX11Info::appRootWindow(), NET::WMDesktop );
192 if ( ( wm_client.desktop() == NETWinInfo::OnAllDesktops ) ||
193 ( wm_client.desktop() > 0 ) ) {
199 m_config->writeConfig();
204 return m_journal->uid();
209 return m_label->text();
214 return m_editor->
text();
224 m_label->setText( name );
225 updateLabelAlignment();
232 NETWinInfo note_win( QX11Info::display(), winId(), QX11Info::appRootWindow(),
234 note_win.setName( name.toUtf8() );
250 disconnect( m_find );
251 connect( m_find, SIGNAL(highlight(QString,
int,
int)),
252 this, SLOT(slotHighlight(QString,
int,
int)) );
253 connect( m_find, SIGNAL(findNext()),
this, SLOT(slotFindNext()) );
255 m_find->setData( m_editor->toPlainText() );
264 void KNote::slotFindNext()
270 KFind::Result res = m_find->find();
272 if ( res == KFind::NoMatch ) {
274 QTextCursor c = m_editor->textCursor();
276 m_editor->setTextCursor( c );
278 disconnect( m_find, 0,
this, 0 );
287 KWindowSystem::setCurrentDesktop( KWindowSystem::windowInfo( winId(),
288 NET::WMDesktop ).desktop() );
293 void KNote::slotHighlight(
const QString& ,
int idx,
int len )
295 m_editor->textCursor().clearSelection();
296 m_editor->highlightWord( len, idx );
303 return m_editor->document()->isModified();
310 m_blockEmitDataChanged =
true;
313 const QString oldName = m_label->text();
314 const QString newName = KInputDialog::getText( QString::null,
315 i18n(
"Please enter the new name:" ), m_label->text(), &ok, this );
316 m_blockEmitDataChanged =
false;
317 if ( !ok || (oldName == newName) ) {
324 void KNote::slotUpdateReadOnly()
326 const bool readOnly = m_readOnly->isChecked();
328 m_editor->setReadOnly( readOnly );
332 actionCollection()->action( QLatin1String(
"configure_note") )->setEnabled( !readOnly );
333 actionCollection()->action( QLatin1String(
"delete_note") )->setEnabled( !readOnly );
334 actionCollection()->action( QLatin1String(
"format_bold") )->setEnabled( !readOnly );
335 actionCollection()->action( QLatin1String(
"format_italic") )->setEnabled( !readOnly );
336 actionCollection()->action( QLatin1String(
"format_underline") )->setEnabled( !readOnly );
337 actionCollection()->action( QLatin1String(
"format_strikeout") )->setEnabled( !readOnly );
338 actionCollection()->action( QLatin1String(
"format_alignleft") )->setEnabled( !readOnly );
339 actionCollection()->action( QLatin1String(
"format_aligncenter") )->setEnabled( !readOnly );
340 actionCollection()->action( QLatin1String(
"format_alignright") )->setEnabled( !readOnly );
341 actionCollection()->action( QLatin1String(
"format_alignblock" ))->setEnabled( !readOnly );
342 actionCollection()->action( QLatin1String(
"format_list") )->setEnabled( !readOnly );
343 actionCollection()->action( QLatin1String(
"format_super") )->setEnabled( !readOnly );
344 actionCollection()->action( QLatin1String(
"format_sub") )->setEnabled( !readOnly );
345 actionCollection()->action( QLatin1String(
"format_increaseindent" ))->setEnabled( !readOnly );
346 actionCollection()->action( QLatin1String(
"format_decreaseindent") )->setEnabled( !readOnly );
347 actionCollection()->action( QLatin1String(
"text_background_color") )->setEnabled( !readOnly );
348 actionCollection()->action( QLatin1String(
"format_size") )->setEnabled( !readOnly );
349 actionCollection()->action( QLatin1String(
"format_color") )->setEnabled( !readOnly );
350 actionCollection()->action( QLatin1String(
"rename_note") )->setEnabled( !readOnly);
358 mBlockWriteConfigDuringCommitData =
true;
364 NETWinInfo wm_client( QX11Info::display(), winId(),
365 QX11Info::appRootWindow(), NET::WMDesktop );
366 if ( ( wm_client.desktop() == NETWinInfo::OnAllDesktops ) ||
367 ( wm_client.desktop() > 0 ) ) {
372 m_editor->clearFocus();
373 if( !mBlockWriteConfigDuringCommitData ) {
376 m_config->writeConfig();
382 void KNote::slotSetAlarm()
384 m_blockEmitDataChanged =
true;
386 dlg->setIncidence( m_journal );
392 m_blockEmitDataChanged =
false;
395 void KNote::slotPreferences()
397 m_blockEmitDataChanged =
true;
401 connect( dialog, SIGNAL(settingsChanged(QString)) ,
this,
402 SLOT(slotApplyConfig()) );
404 SLOT(slotUpdateCaption(QString)) );
407 m_blockEmitDataChanged =
false;
411 void KNote::slotSend()
416 void KNote::slotMail()
421 void KNote::slotPrint()
426 void KNote::slotPrintPreview()
431 void KNote::print(
bool preview)
434 if ( !Qt::mightBeRichText( m_editor->
text() ) ) {
435 content = Qt::convertFromPlainText( m_editor->
text() );
437 content = m_editor->
text();
441 if ( !m_blockEmitDataChanged ) {
447 QList<KNotePrintObject*> lst;
451 KNotesGlobalConfig *globalConfig = KNotesGlobalConfig::self();
452 QString printingTheme = globalConfig->theme();
453 if (printingTheme.isEmpty()) {
456 printingTheme = dlg->selectedTheme();
460 if (!printingTheme.isEmpty()) {
461 printer.
printNotes( lst, printingTheme, preview );
465 void KNote::slotSaveAs()
468 m_blockEmitDataChanged =
true;
469 QCheckBox *convert = 0;
471 if ( m_editor->acceptRichText() ) {
472 convert =
new QCheckBox( 0 );
473 convert->setText( i18n(
"Save note as plain text" ) );
475 m_blockEmitDataChanged =
true;
477 QPointer<KFileDialog> dlg =
new KFileDialog( url, QString(),
this, convert );
478 dlg->setOperationMode( KFileDialog::Saving );
479 dlg->setCaption( i18n(
"Save As" ) );
481 m_blockEmitDataChanged =
false;
486 QString fileName = dlg->selectedFile();
487 const bool htmlFormatAndSaveAsHtml = (convert && !convert->isChecked());
489 if ( fileName.isEmpty() ) {
490 m_blockEmitDataChanged =
false;
494 QFile file( fileName );
496 if ( file.exists() &&
497 KMessageBox::warningContinueCancel(
this,
498 i18n(
"<qt>A file named <b>%1</b> already exists.<br />"
499 "Are you sure you want to overwrite it?</qt>",
500 QFileInfo( file ).fileName() ) ) != KMessageBox::Continue ) {
501 m_blockEmitDataChanged =
false;
505 if ( file.open( QIODevice::WriteOnly ) ) {
506 QTextStream stream( &file );
507 if ( htmlFormatAndSaveAsHtml ) {
508 stream << m_editor->toHtml();
510 stream << m_editor->toPlainText();
513 m_blockEmitDataChanged =
false;
516 void KNote::slotPopupActionToDesktop(
int id )
524 void KNote::slotApplyConfig()
526 m_label->setFont( m_config->
titleFont() );
535 slotUpdateShowInTaskbar();
538 void KNote::slotKeepAbove()
540 if ( m_keepBelow->isChecked() )
542 m_keepBelow->setChecked(
false );
544 slotUpdateKeepAboveBelow();
547 void KNote::slotKeepBelow()
549 if ( m_keepAbove->isChecked() )
551 m_keepAbove->setChecked(
false );
553 slotUpdateKeepAboveBelow();
556 void KNote::slotUpdateKeepAboveBelow()
559 unsigned long state = KWindowInfo( KWindowSystem::windowInfo( winId(), NET::WMState ) ).state();
561 unsigned long state = 0;
563 if ( m_keepAbove->isChecked() ) {
566 KWindowSystem::setState( winId(), state | NET::KeepAbove );
567 }
else if ( m_keepBelow->isChecked() ) {
570 KWindowSystem::setState( winId(), state | NET::KeepBelow );
573 KWindowSystem::clearState( winId(), NET::KeepAbove );
575 KWindowSystem::clearState( winId(), NET::KeepBelow );
579 void KNote::slotUpdateShowInTaskbar()
583 KWindowSystem::setState( winId(), KWindowSystem::windowInfo( winId(),
584 NET::WMState ).state() | NET::SkipTaskbar );
586 KWindowSystem::clearState( winId(), NET::SkipTaskbar );
591 void KNote::slotUpdateDesktopActions()
594 m_toDesktop->clear();
595 NETRootInfo wm_root( QX11Info::display(), NET::NumberOfDesktops |
597 NETWinInfo wm_client( QX11Info::display(), winId(),
598 QX11Info::appRootWindow(), NET::WMDesktop );
600 KAction *act = m_toDesktop->addAction(i18n(
"&All Desktops" ));
601 if (wm_client.desktop() == NETWinInfo::OnAllDesktops) {
602 act->setChecked(
true);
604 QAction *separator =
new QAction(m_toDesktop);
605 separator->setSeparator(
true);
606 m_toDesktop->addAction(separator);
607 const int count = wm_root.numberOfDesktops();
608 for (
int n = 1; n <= count; ++n ) {
609 KAction *desktopAct = m_toDesktop->addAction(QString::fromLatin1(
"&%1 %2" ).arg( n ).arg(QString::fromUtf8( wm_root.desktopName( n ) ) ));
610 if (wm_client.desktop() == n) {
611 desktopAct->setChecked(
true);
620 void KNote::buildGui(
const QString &configFile)
623 createNoteEditor(configFile);
625 KXMLGUIBuilder builder(
this );
626 KXMLGUIFactory factory( &builder,
this );
627 factory.addClient(
this );
629 m_menu =
dynamic_cast<KMenu*
>( factory.container( QLatin1String(
"note_context"),
this ) );
630 m_tool =
dynamic_cast<KToolBar*
>( factory.container( QLatin1String(
"note_tool"),
this ) );
635 void KNote::createActions()
641 action =
new KAction( KIcon( QLatin1String(
"document-new") ), i18n(
"New" ),
this );
642 actionCollection()->addAction( QLatin1String(
"new_note"), action );
643 connect( action, SIGNAL(triggered(
bool)), SLOT(slotRequestNewNote()) );
645 action =
new KAction( KIcon( QLatin1String(
"edit-rename") ), i18n(
"Rename..." ),
this );
646 actionCollection()->addAction( QLatin1String(
"rename_note"), action );
647 connect( action, SIGNAL(triggered(
bool)), SLOT(
slotRename()) );
649 m_readOnly =
new KToggleAction( KIcon( QLatin1String(
"object-locked") ),
650 i18n(
"Lock" ),
this );
651 actionCollection()->addAction( QLatin1String(
"lock_note"), m_readOnly );
652 connect( m_readOnly, SIGNAL(triggered(
bool)),
653 SLOT(slotUpdateReadOnly()) );
654 m_readOnly->setCheckedState( KGuiItem( i18n(
"Unlock" ), QLatin1String(
"object-unlocked") ) );
656 action =
new KAction( KIcon( QLatin1String(
"window-close") ), i18n(
"Hide" ),
this );
657 actionCollection()->addAction( QLatin1String(
"hide_note"), action );
658 connect( action, SIGNAL(triggered(
bool)), SLOT(
slotClose()) );
659 action->setShortcut( QKeySequence( Qt::Key_Escape ) );
661 action =
new KAction( KIcon( QLatin1String(
"edit-delete") ), i18n(
"Delete" ),
this );
662 actionCollection()->addAction( QLatin1String(
"delete_note"), action );
663 connect( action, SIGNAL(triggered(
bool)), SLOT(
slotKill()),Qt::QueuedConnection );
665 action =
new KAction( KIcon( QLatin1String(
"knotes_alarm") ), i18n(
"Set Alarm..." ),
667 actionCollection()->addAction( QLatin1String(
"set_alarm"), action );
668 connect( action, SIGNAL(triggered(
bool)), SLOT(slotSetAlarm()) );
670 action =
new KAction( KIcon( QLatin1String(
"network-wired") ), i18n(
"Send..." ),
this );
671 actionCollection()->addAction( QLatin1String(
"send_note"), action );
672 connect( action, SIGNAL(triggered(
bool)), SLOT(slotSend()) );
674 action =
new KAction( KIcon( QLatin1String(
"mail-send") ), i18n(
"Mail..." ),
this );
675 actionCollection()->addAction( QLatin1String(
"mail_note"), action );
676 connect( action, SIGNAL(triggered(
bool)), SLOT(slotMail()) );
678 action =
new KAction( KIcon( QLatin1String(
"document-save-as") ), i18n(
"Save As..." ),
680 actionCollection()->addAction( QLatin1String(
"save_note"), action );
681 connect( action, SIGNAL(triggered(
bool)), SLOT(slotSaveAs()) );
682 actionCollection()->addAction( KStandardAction::Print, QLatin1String(
"print_note"),
this,
685 if (KPrintPreview::isAvailable()) {
686 actionCollection()->addAction( KStandardAction::PrintPreview, QLatin1String(
"print_preview_note"),
this,
687 SLOT(slotPrintPreview()) );
689 action =
new KAction( KIcon( QLatin1String(
"configure") ), i18n(
"Preferences..." ),
this );
690 actionCollection()->addAction( QLatin1String(
"configure_note"), action );
691 connect( action, SIGNAL(triggered(
bool)), SLOT(slotPreferences()) );
694 m_keepAbove =
new KToggleAction( KIcon( QLatin1String(
"go-up") ),
695 i18n(
"Keep Above Others" ),
this );
696 actionCollection()->addAction( QLatin1String(
"keep_above"), m_keepAbove );
697 connect( m_keepAbove, SIGNAL(triggered(
bool)),
698 SLOT(slotKeepAbove()) );
700 m_keepBelow =
new KToggleAction( KIcon( QLatin1String(
"go-down") ),
701 i18n(
"Keep Below Others" ),
this );
702 actionCollection()->addAction( QLatin1String(
"keep_below"), m_keepBelow );
703 connect( m_keepBelow, SIGNAL(triggered(
bool)),
704 SLOT(slotKeepBelow()) );
707 m_toDesktop =
new KSelectAction( i18n(
"To Desktop" ),
this );
708 actionCollection()->addAction( QLatin1String(
"to_desktop"), m_toDesktop );
709 connect( m_toDesktop, SIGNAL(triggered(
int)),
710 SLOT(slotPopupActionToDesktop(
int)) );
711 connect( m_toDesktop->menu(), SIGNAL(aboutToShow()),
712 SLOT(slotUpdateDesktopActions()) );
714 slotUpdateDesktopActions();
718 action =
new KAction( i18n(
"Walk Through Notes" ),
this );
719 actionCollection()->addAction( QLatin1String(
"walk_notes"), action );
721 action->setShortcut( QKeySequence( Qt::SHIFT + Qt::Key_Backtab ) );
723 actionCollection()->addAssociatedWidget(
this );
724 foreach (QAction* action, actionCollection()->actions())
725 action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
728 void KNote::createNoteHeader()
731 KConfigGroup styleGroup( m_kwinConf,
"Style" );
733 QBoxLayout::Direction headerLayoutDirection = QBoxLayout::LeftToRight;
735 if ( styleGroup.readEntry(
"CustomButtonPositions",
false ) ) {
736 if ( styleGroup.readEntry(
"ButtonsOnLeft" ).contains( QLatin1Char(
'X') ) ) {
737 headerLayoutDirection = QBoxLayout::RightToLeft;
741 QBoxLayout *headerLayout =
new QBoxLayout( headerLayoutDirection);
745 m_label =
new QLabel(
this );
746 headerLayout->addWidget( m_label );
747 m_label->setFrameStyle( NoFrame );
748 m_label->setBackgroundRole( QPalette::Base );
749 m_label->setLineWidth( 0 );
750 m_label->setAutoFillBackground(
true );
751 m_label->installEventFilter(
this );
753 setName( m_journal->summary() );
755 m_button =
new KNoteButton( QLatin1String(
"knotes_close"),
this );
756 headerLayout->addWidget( m_button );
758 connect( m_button, SIGNAL(clicked()),
this, SLOT(
slotClose()) );
760 m_noteLayout->addItem( headerLayout );
763 void KNote::createNoteEditor(
const QString &configFile)
765 m_editor =
new KNoteEdit( configFile, actionCollection(),
this );
766 m_noteLayout->addWidget( m_editor );
768 m_editor->installEventFilter(
this );
769 setFocusProxy( m_editor );
772 void KNote::slotRequestNewNote()
780 void KNote::createNoteFooter()
783 m_tool->setIconSize( QSize( 10, 10 ) );
784 m_tool->setFixedHeight( 24 );
785 m_tool->setToolButtonStyle( Qt::ToolButtonIconOnly );
789 QHBoxLayout *gripLayout =
new QHBoxLayout;
790 m_grip =
new QSizeGrip(
this );
791 m_grip->setFixedSize( m_grip->sizeHint() );
794 gripLayout->addWidget( m_tool );
795 gripLayout->setAlignment( m_tool, Qt::AlignBottom | Qt::AlignLeft );
799 gripLayout->addWidget( m_grip );
800 gripLayout->setAlignment( m_grip, Qt::AlignBottom | Qt::AlignRight );
801 m_noteLayout->addItem( gripLayout );
805 foreach ( KComboBox *combo, m_tool->findChildren<KComboBox *>() ) {
806 QFont font = combo->font();
807 font.setPointSize( 7 );
808 combo->setFont( font );
809 combo->setFixedHeight( 14 );
814 void KNote::prepare()
817 uint width = m_config->
width();
818 uint height = m_config->
height();
819 resize( width, height );
823 const QPoint& position = m_config->
position();
824 QRect desk = kapp->desktop()->rect();
825 desk.adjust( 10, 10, -10, -10 );
826 if ( desk.intersects( QRect( position, QSize( width, height ) ) ) ) {
837 int desktop = m_config->
desktop();
840 if ( ( desktop < 0 && desktop != NETWinInfo::OnAllDesktops ) ||
842 desktop = KWindowSystem::currentDesktop();
846 if ( desktop != 0 && !m_config->
hideNote() ) {
853 if ( desktop == NETWinInfo::OnAllDesktops ) {
859 m_readOnly->setChecked( m_config->
readOnly() );
860 slotUpdateReadOnly();
863 m_keepAbove->setChecked(
true );
865 m_keepBelow->setChecked(
true );
867 m_keepAbove->setChecked(
false );
868 m_keepBelow->setChecked(
false );
870 slotUpdateKeepAboveBelow();
875 QPixmap icon = effect.apply( qApp->windowIcon().pixmap(
876 IconSize( KIconLoader::Desktop ),
877 IconSize( KIconLoader::Desktop ) ),
878 KIconEffect::Colorize,
879 1, m_config->
bgColor(), false );
880 QPixmap miniIcon = effect.apply( qApp->windowIcon().pixmap(
881 IconSize( KIconLoader::Small ),
882 IconSize( KIconLoader::Small ) ),
883 KIconEffect::Colorize,
884 1, m_config->
bgColor(), false );
886 KWindowSystem::setIcons( winId(), icon, miniIcon );
890 setFrameStyle( Panel | Raised );
891 setMinimumSize( 20, 20 );
892 setBackgroundRole( QPalette::Base );
894 m_editor->setContentsMargins( 0, 0, 0, 0 );
895 m_editor->setBackgroundRole( QPalette::Base );
896 m_editor->setFrameStyle( NoFrame );
897 m_editor->
setText( m_journal->description() );
899 m_editor->document()->setModified(
false );
904 if ( desktop == 0 ) {
909 if ( desktop == NETWinInfo::OnAllDesktops ) {
910 KWindowSystem::setOnAllDesktops( winId(),
true );
912 KWindowSystem::setOnDesktop( winId(), desktop );
917 void KNote::setColor(
const QColor &fg,
const QColor &bg )
919 QPalette p = palette();
926 p.setColor( QPalette::Window, bg );
928 p.setColor( QPalette::Base, bg );
931 p.setColor( QPalette::WindowText, fg );
932 p.setColor( QPalette::Text, fg );
934 p.setColor( QPalette::Button, bg.dark( 116 ) );
935 p.setColor( QPalette::ButtonText, fg );
943 p.setColor( QPalette::Light, bg.light( 180 ) );
944 p.setColor( QPalette::Midlight, bg.light( 150 ) );
945 p.setColor( QPalette::Mid, bg.light( 150 ) );
946 p.setColor( QPalette::Dark, bg.dark( 108 ) );
947 p.setColor( QPalette::Shadow, bg.dark( 116 ) );
952 p.setColor( QPalette::Active, QPalette::Base, bg.dark( 116 ) );
954 m_label->setPalette( p );
957 m_editor->setTextColor( fg );
961 QPixmap icon = effect.apply( qApp->windowIcon().pixmap(
962 IconSize( KIconLoader::Desktop ),
963 IconSize( KIconLoader::Desktop ) ),
964 KIconEffect::Colorize, 1, bg, false );
965 QPixmap miniIcon = effect.apply( qApp->windowIcon().pixmap(
966 IconSize( KIconLoader::Small ),
967 IconSize( KIconLoader::Small ) ),
968 KIconEffect::Colorize, 1, bg, false );
970 KWindowSystem::setIcons( winId(), icon, miniIcon );
977 void KNote::updateLabelAlignment()
980 const QString labelText = m_label->text();
981 if ( m_label->fontMetrics().boundingRect( labelText ).width() >
983 m_label->setAlignment( Qt::AlignLeft );
985 m_label->setAlignment( Qt::AlignHCenter );
989 void KNote::updateFocus()
994 if ( !m_editor->isReadOnly() )
996 if ( m_tool && m_tool->isHidden() && m_editor->acceptRichText() )
1005 if ( m_tool && !m_tool->isHidden() ) {
1016 if ( m_tool && !m_tool->isHidden() )
1024 void KNote::updateLayout()
1027 updateLabelAlignment();
1035 m_menu->popup( e->globalPos() );
1043 slotUpdateKeepAboveBelow();
1044 slotUpdateShowInTaskbar();
1053 QFrame::resizeEvent( qre );
1059 if ( kapp->sessionSaving() ) {
1069 e->setAccepted( e->mimeData()->hasColor() );
1079 const QMimeData *md = e->mimeData();
1080 if ( md->hasColor() ) {
1081 QColor bg = qvariant_cast<QColor>( md->colorData() );
1082 setColor( palette().color( foregroundRole() ), bg );
1083 m_journal->setCustomProperty(
"KNotes",
"BgColor", bg.name() );
1090 if ( ev->type() == QEvent::LayoutRequest ) {
1094 return QFrame::event( ev );
1100 if ( ev->type() == QEvent::DragEnter &&
1101 static_cast<QDragEnterEvent*
>( ev )->mimeData()->hasColor() ) {
1106 if ( ev->type() == QEvent::Drop &&
1107 static_cast<QDropEvent *
>( ev )->mimeData()->hasColor() ) {
1108 dropEvent( static_cast<QDropEvent *>( ev ) );
1112 if ( o == m_label ) {
1113 QMouseEvent *e = ( QMouseEvent * )ev;
1115 if ( ev->type() == QEvent::MouseButtonDblClick ) {
1116 if(!m_editor->isReadOnly())
1120 if ( ev->type() == QEvent::MouseButtonPress &&
1121 ( e->button() == Qt::LeftButton || e->button() == Qt::MidButton ) ) {
1123 e->button() == Qt::LeftButton ? KWindowSystem::raiseWindow( winId() )
1124 : KWindowSystem::lowerWindow( winId() );
1126 XUngrabPointer( QX11Info::display(), QX11Info::appTime() );
1127 NETRootInfo wm_root( QX11Info::display(), NET::WMMoveResize );
1128 wm_root.moveResizeRequest( winId(), e->globalX(), e->globalY(),
1134 if ( ev->type() == QEvent::MouseButtonRelease ) {
1136 NETRootInfo wm_root( QX11Info::display(), NET::WMMoveResize );
1137 wm_root.moveResizeRequest( winId(), e->globalX(), e->globalY(),
1138 NET::MoveResizeCancel );
1146 if ( o == m_editor ) {
1147 if ( ev->type() == QEvent::FocusOut ) {
1148 QFocusEvent *fe =
static_cast<QFocusEvent *
>( ev );
1149 if ( fe->reason() != Qt::PopupFocusReason &&
1150 fe->reason() != Qt::MouseFocusReason ) {
1154 if ( !m_blockEmitDataChanged )
1158 }
else if ( ev->type() == QEvent::FocusIn ) {
1169 #include "knote.moc"
void slotKill(bool force=false)
bool rememberDesktop() const
Get RememberDesktop.
void setTextFont(const QFont &font)
void setKeepAbove(bool v)
Set KeepAbove.
int desktop() const
Get desktop.
void printNotes(const QList< KNotePrintObject * > lst, const QString &themePath, bool preview)
KCal::Journal * journal() const
void setBgColor(const QColor &v)
Set bgcolor.
void changeJournal(KCal::Journal *)
void sigKillNote(KCal::Journal *)
virtual void showEvent(QShowEvent *)
bool isDesktopAssigned() const
void setReadOnly(bool v)
Set ReadOnly.
bool showInTaskbar() const
Get ShowInTaskbar.
void setAutoIndentMode(bool newmode)
bool autoIndent() const
Get autoindent.
void setDefaultFont(const QFont &font)
uint height() const
Get height.
QColor bgColor() const
Get bgcolor.
void setTabStop(int tabs)
virtual void dropEvent(QDropEvent *)
KNote(const QDomDocument &buildDoc, KCal::Journal *journal, QWidget *parent=0)
virtual bool eventFilter(QObject *, QEvent *)
void setRichText(bool)
public slots
KNOTES_EXPORT KNoteConfig * createConfig(KCal::Journal *journal, QString &configPath)
void setPosition(const QPoint &v)
Set position.
QFont titleFont() const
Get titlefont.
void sigDataChanged(const QString &)
void setText(const QString &text)
uint tabSize() const
Get tabsize.
void setHideNote(bool v)
Set HideNote.
void setNote(KNote *_note)
virtual void resizeEvent(QResizeEvent *)
KNOTES_EXPORT void setProperty(KCal::Journal *journal, KNoteConfig *config)
KNOTES_EXPORT void removeNote(KCal::Journal *journal, QWidget *parent)
void saveData(bool update=true)
virtual bool event(QEvent *)
QColor fgColor() const
Get fgcolor.
virtual void dragEnterEvent(QDragEnterEvent *)
void setHeight(uint v)
Set height.
QFont font() const
Get font.
virtual void closeEvent(QCloseEvent *)
bool hideNote() const
Get HideNote.
virtual void contextMenuEvent(QContextMenuEvent *)
bool richText() const
Get richtext.
void setName(const QString &name)
void setDesktop(int v)
Set desktop.
KNOTES_EXPORT void savePreferences(KCal::Journal *journal, KNoteConfig *config)
void toDesktop(int desktop)
uint width() const
Get width.
void setWidth(uint v)
Set width.
QPoint position() const
Get position.
bool keepAbove() const
Get KeepAbove.
void setText(const QString &text)
bool readOnly() const
Get ReadOnly.
KNOTES_EXPORT void sendMail(QWidget *parent, const QString &title, const QString &message)
void setKeepBelow(bool v)
Set KeepBelow.
KNOTES_EXPORT void sendToNetwork(QWidget *parent, const QString &title, const QString &message)
bool keepBelow() const
Get KeepBelow.
void sigNameChanged(const QString &)