-rw-r--r-- | noncore/applets/notesapplet/notes.cpp | 70 | ||||
-rw-r--r-- | noncore/applets/notesapplet/notes.h | 3 |
2 files changed, 57 insertions, 16 deletions
diff --git a/noncore/applets/notesapplet/notes.cpp b/noncore/applets/notesapplet/notes.cpp index 90c2550..2b25476 100644 --- a/noncore/applets/notesapplet/notes.cpp +++ b/noncore/applets/notesapplet/notes.cpp @@ -82,9 +82,19 @@ static char * notes_xpm[] = { NotesControl::NotesControl( QWidget *parent, const char *name ) : QFrame( parent, name,/* WDestructiveClose | */WStyle_StaysOnTop ) // : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup ) { - setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); + QDir d( QDir::homeDirPath()+"/notes"); + if( !d.exists()) { + qDebug("make dir"); + if(!d.mkdir( QDir::homeDirPath()+"/notes", true)) + qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<make dir failed"); + } + Config cfg("Notes"); + cfg.setGroup("Options"); + showMax = cfg.readBoolEntry("ShowMax", false); + + setFrameStyle( QFrame::PopupPanel | QFrame::Raised ); loaded=false; edited=false; doPopulate=true; isNew=false; @@ -104,12 +114,8 @@ NotesControl::NotesControl( QWidget *parent, const char *name ) vbox->addWidget( view); vbox->addWidget( box); - setFixedHeight(180); - QWidget *wid = QPEApplication::desktop(); - setFixedWidth( wid->width()-10 /*200*/); - setFocusPolicy(QWidget::StrongFocus); newButton= new QPushButton( this, "newButton" ); newButton->setText(tr("New")); @@ -252,17 +258,17 @@ void NotesControl::slotBoxSelected(const QString &itemString) { void NotesControl::showMenu() { QPopupMenu *m = new QPopupMenu(0); - m->insertItem( tr( "Beam Out" ), this, SLOT( slotBeamButton() )); + m->insertItem( tr( "Search For..." ), this, SLOT( slotSearch() )); + m->insertItem( tr( "Toggle Maximized" ), this, SLOT( slotShowMax() )); m->insertSeparator(); m->insertItem( tr( "Delete" ), this, SLOT( slotDeleteButton() )); m->setFocus(); m->exec( QCursor::pos() ); if(m) delete m; - } void NotesControl::focusOutEvent ( QFocusEvent * e) { if( e->reason() == QFocusEvent::Popup) @@ -283,12 +289,12 @@ void NotesControl::save() { // qDebug("is edited"); QString rt = view->text(); if( rt.length()>1) { QString pt = rt.simplifyWhiteSpace(); - int i = pt.find( ' ' ); + int i = pt.find( ' ', pt.find( ' ' )+2 ); QString docname = pt; if ( i > 0 ) - docname = pt.left( i ); + docname = pt.left(i); // remove "." at the beginning while( docname.startsWith( "." ) ) docname = docname.mid( 1 ); docname.replace( QRegExp("/"), "_" ); @@ -310,17 +316,15 @@ void NotesControl::save() { } // else // qDebug("oldname equals docname"); - doc = new DocLnk(docname); - if(QFile(doc->linkFile()).exists()) qDebug("puppie"); doc->setType("text/plain"); - doc->setFile(QDir::homeDirPath()+"/"+docname); doc->setName(docname); - + QString temp = docname.replace( QRegExp(" "), "_" ); + doc->setFile( QDir::homeDirPath()+"/notes/"+temp); FileManager fm; if ( !fm.saveFile( *doc, rt ) ) { } @@ -373,12 +377,18 @@ void NotesControl::load() { } void NotesControl::load(const QString & file) { qDebug("loading "+file); - if(!loaded) { + QString name = file; + QString temp; + if( !QFile( QDir::homeDirPath()+"/"+file).exists() ) + temp = QDir::homeDirPath()+"/notes/"+ name.replace( QRegExp(" "), "_" ); + else + temp = name; + if(!loaded) { DocLnk nf; nf.setType("text/plain"); - nf.setFile( file); + nf.setFile( temp); loadDoc(nf); loaded=true; } @@ -393,8 +403,9 @@ void NotesControl::load(const QString & file) { void NotesControl::loadDoc( const DocLnk &f) { FileManager fm; QString txt; if ( !fm.loadFile( f, txt ) ) { + qDebug("could not load file "+f.file()); return; } view->setText(txt); } @@ -404,8 +415,25 @@ void NotesControl::slotViewEdited() { edited=true; } } + +void NotesControl::slotShowMax() { + Config cfg("Notes"); + cfg.setGroup("Options"); + showMax=!showMax; + cfg.writeEntry("ShowMax", showMax); + cfg.write(); + hide(); +} + +void NotesControl::slotSearch() { + int boxCount = box->count(); + for(int i=0;i< boxCount;i++) { + + } +} + // void NotesControl::keyReleaseEvent( QKeyEvent *e) { // switch ( e->state() ) { // case ControlButton: @@ -449,10 +477,20 @@ void NotesApplet::mousePressEvent( QMouseEvent *) { vc->close(); } else { // vc = new NotesControl; // QPoint curPos = mapToGlobal( rect().topLeft() ); + if(vc->showMax) { + qDebug("show max"); + vc->showMaximized(); + } else { + qDebug("no show max"); + QWidget *wid = QPEApplication::desktop(); + QRect rect = QApplication::desktop()->geometry(); + vc->setGeometry( ( wid->width() / 2) - ( vc->width() / 2 ) , 28 , wid->width() -10 , 180); + vc->move ( (rect.center()/2) - (vc->rect().center()/2)); +// vc->move( (( wid->width() / 2) - ( vc->width() / 2 ))-4, 28); + } vc->show(); - vc->move( 2, 28); vc->doPopulate=true; vc->populateBox(); vc->doPopulate=false; vc->loaded=false; diff --git a/noncore/applets/notesapplet/notes.h b/noncore/applets/notesapplet/notes.h index 381dc80..c428efe 100644 --- a/noncore/applets/notesapplet/notes.h +++ b/noncore/applets/notesapplet/notes.h @@ -41,8 +41,9 @@ public: QListBox *box; QPushButton *saveButton, *deleteButton, *newButton; QString FileNamePath; bool loaded, edited, doPopulate, isNew; + bool showMax; void save(); void populateBox(); void load(); @@ -52,8 +53,10 @@ private: QString oldDocName; void focusOutEvent( QFocusEvent * ); void load(const QString&); private slots: + void slotSearch(); + void slotShowMax(); void slotBeamButton(); void slotBeamFinished( Ir*); void slotDeleteButton(); void slotSaveButton(); |