19 #include "knotes/knoteedit.h"
21 #include <KCal/Journal>
24 #include <KActionCollection>
25 #include <KComponentData>
31 #include <KXMLGUIBuilder>
32 #include <KXMLGUIFactory>
35 #include <QHBoxLayout>
37 #include <QVBoxLayout>
47 void KNoteEditDialog::init(
bool readOnly)
49 setCaption( readOnly ? i18nc(
"@title:window",
"Show Popup Note" ) : i18nc(
"@title:window",
"Edit Popup Note" ) );
50 setButtons( readOnly ? Close : Ok | Cancel );
51 setDefaultButton( readOnly ? Close : Ok );
53 showButtonSeparator(
true );
57 setComponentData( KComponentData(
"knotes" ) );
58 setXMLFile( QLatin1String(
"knotesui.rc") );
61 setMainWidget( page );
62 QVBoxLayout *layout =
new QVBoxLayout( page );
64 QHBoxLayout *hbl =
new QHBoxLayout();
65 layout->addItem( hbl );
66 hbl->setSpacing( marginHint() );
68 label->setText( i18nc(
"@label popup note name",
"Name:" ) );
69 hbl->addWidget( label, 0 );
71 mTitleEdit->setObjectName( QLatin1String(
"name") );
73 connect(mTitleEdit, SIGNAL(textChanged(QString)),
this, SLOT(slotTextChanged(QString)));
74 hbl->addWidget( mTitleEdit, 1, Qt::AlignVCenter );
77 mNoteEdit =
new KNoteEdit( QLatin1String(
"knotesrc"), actionCollection(), page );
78 mNoteEdit->setFocus();
80 KXMLGUIBuilder builder( page );
81 KXMLGUIFactory factory( &builder,
this );
82 factory.addClient(
this );
84 mTool =
static_cast<KToolBar *
>( factory.container( QLatin1String(
"note_tool"),
this ) );
85 layout->addWidget( mTool );
86 layout->addWidget( mNoteEdit );
88 actionCollection()->addAssociatedWidget(
this );
89 foreach ( QAction *action, actionCollection()->actions() ) {
90 action->setShortcutContext( Qt::WidgetWithChildrenShortcut );
103 mNoteEdit->setAcceptRichText( b );
104 mTool->setVisible(b);
109 mNoteEdit->setEnabled( !b );
110 mTool->setEnabled(!b);
111 mTitleEdit->setEnabled(!b);
114 void KNoteEditDialog::readConfig()
116 KConfigGroup grp( KGlobal::config(),
"KNoteEditDialog" );
117 const QSize size = grp.readEntry(
"Size", QSize(300, 200) );
118 if ( size.isValid() ) {
123 void KNoteEditDialog::writeConfig()
125 KConfigGroup grp( KGlobal::config(),
"KNoteEditDialog" );
126 grp.writeEntry(
"Size", size() );
132 return mNoteEdit->text();
137 mNoteEdit->setText( text );
142 return mTitleEdit->text();
147 mTitleEdit->setText( text );
148 if (mTitleEdit->isEnabled())
149 enableButtonOk(!text.isEmpty());
157 void KNoteEditDialog::slotTextChanged(
const QString &
text)
159 enableButtonOk(!text.isEmpty());
164 mNoteEdit->setTabStop(size);
169 mNoteEdit->setAutoIndentMode(newmode);
174 mNoteEdit->setTextFont(font);
177 #include "knoteseditdialog.moc"
void setTabSize(int size)
virtual QByteArray text(quint32 serialNumber) const =0
void setAutoIndentMode(bool newmode)
void setTitle(const QString &text)
void setText(const QString &text)
void setTextFont(const QFont &font)
KNoteEditDialog(bool readOnly, QWidget *parent=0)
KNoteEdit * noteEdit() const
void setAcceptRichText(bool b)