[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: PATCH: knotes #18086
From: Michael Brade <Michael.Brade () informatik ! uni-muenchen ! de>
Date: 2001-06-23 23:20:59
[Download RAW message or body]
Hi!
The attached patch fixes #18086, this makes it possible to resize a note via
a QSizeGrip. I'm posting this patch in case somebody considers this a new
feature.... However, the patch breaks nothing, that's for sure :-)
Additionally the title's geometry of a note is updated immediately after a
font change and not delayed to the next resize.
Will commit tomorrow afternoon if nobody objects.
Ciao,
Michael
--
Some operating systems are called `user friendly',
Linux however is `expert friendly'.
["diff" (text/x-c++)]
Index: knote.cpp
===================================================================
RCS file: /home/kde/kdeutils/knotes/knote.cpp,v
retrieving revision 1.32
diff -u -p -r1.32 knote.cpp
--- knote.cpp 2001/06/17 17:57:41 1.32
+++ knote.cpp 2001/06/23 23:03:31
@@ -24,6 +24,7 @@
#include "knoteconfigdlg.h"
#include <qlabel.h>
+#include <qsizegrip.h>
#include <qpalette.h>
#include <qcolor.h>
#include <qfile.h>
@@ -103,10 +104,12 @@ KNote::KNote( KXMLGUIBuilder* builder, c
setFocusProxy( m_editor );
// set up the look&feel of the note
+ m_editor->setCornerWidget( new QSizeGrip( this ) );
+
setFrameStyle( WinPanel | Raised );
setLineWidth( 1 );
setMinimumSize( 20, 20 );
- setMargin( 5 );
+ m_editor->setMargin( 5 );
// now create or load the data and configuration
bool oldconfig = false;
@@ -547,11 +550,13 @@ void KNote::slotApplyConfig()
{
m_label->setBackgroundColor( bg.dark(116) );
m_button->show();
+ m_editor->cornerWidget()->show();
}
else
{
m_label->setBackgroundColor( bg );
m_button->hide();
+ m_editor->cornerWidget()->hide();
}
}
@@ -633,11 +638,13 @@ void KNote::convertOldConfig()
{
m_label->setBackgroundColor( bg.dark(116) );
m_button->show();
+ m_editor->cornerWidget()->show();
}
else
{
m_label->setBackgroundColor( bg );
m_button->hide();
+ m_editor->cornerWidget()->hide();
}
// get the font
@@ -727,17 +734,10 @@ void KNote::convertOldConfig()
} else
kdDebug() << "could not open input file" << endl;
}
-
-
-// -------------------- protected methods -------------------- //
-void KNote::resizeEvent( QResizeEvent* qre )
+void KNote::updateLayout()
{
- QFrame::resizeEvent( qre );
-
int headerHeight = m_label->sizeHint().height();
- m_label->setFixedHeight( headerHeight );
- m_button->setFixedSize( headerHeight, headerHeight );
m_button->setGeometry( frameRect().width() - headerHeight - 2, frameRect().y() + 2,
headerHeight, headerHeight );
@@ -747,6 +747,14 @@ void KNote::resizeEvent( QResizeEvent* q
contentsRect().width(), contentsRect().height() - headerHeight - 4 );
}
+// -------------------- protected methods -------------------- //
+
+void KNote::resizeEvent( QResizeEvent* qre )
+{
+ QFrame::resizeEvent( qre );
+ updateLayout();
+}
+
void KNote::closeEvent( QCloseEvent* e )
{
saveConfig();
@@ -763,6 +771,17 @@ void KNote::keyPressEvent( QKeyEvent* e
e->ignore();
}
+bool KNote::event( QEvent* ev )
+{
+ if ( ev->type() == QEvent::LayoutHint )
+ {
+ updateLayout();
+ return true;
+ }
+ else
+ return QFrame::event( ev );
+}
+
bool KNote::eventFilter( QObject* o, QEvent* ev )
{
if ( o == m_label )
@@ -822,6 +841,7 @@ bool KNote::eventFilter( QObject* o, QEv
{
m_label->setBackgroundColor( palette().active().background() );
m_button->hide();
+ m_editor->cornerWidget()->hide();
if ( m_editor->isModified() )
saveData();
@@ -830,6 +850,7 @@ bool KNote::eventFilter( QObject* o, QEv
{
m_label->setBackgroundColor( palette().active().shadow() );
m_button->show();
+ m_editor->cornerWidget()->show();
}
return m_editor->eventFilter( o, ev );
}
Index: knote.h
===================================================================
RCS file: /home/kde/kdeutils/knotes/knote.h,v
retrieving revision 1.13
diff -u -p -r1.13 knote.h
--- knote.h 2001/06/17 12:40:31 1.13
+++ knote.h 2001/06/23 23:03:31
@@ -87,13 +87,15 @@ protected:
virtual void closeEvent( QCloseEvent* );
virtual void keyPressEvent( QKeyEvent* );
- bool eventFilter( QObject*, QEvent* );
+ virtual bool event( QEvent* );
+ virtual bool eventFilter( QObject*, QEvent* );
private slots:
void slotApplyConfig();
private:
void convertOldConfig();
+ void updateLayout();
QDir m_noteDir;
QString m_configFile;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic