summaryrefslogtreecommitdiff
authordrw <drw>2005-03-08 21:50:02 (UTC)
committer drw <drw>2005-03-08 21:50:02 (UTC)
commit2b32d3e15f5774ee8f73977d606675e819498614 (patch) (unidiff)
treee30982f7bfdf36bb8bfc2e3762c2d9234b809607
parentd32769dbeedb21fd7bdafb1c762e4e501cb02961 (diff)
downloadopie-2b32d3e15f5774ee8f73977d606675e819498614.zip
opie-2b32d3e15f5774ee8f73977d606675e819498614.tar.gz
opie-2b32d3e15f5774ee8f73977d606675e819498614.tar.bz2
Better version of icon
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/notesapplet/notes.cpp76
1 files changed, 23 insertions, 53 deletions
diff --git a/noncore/applets/notesapplet/notes.cpp b/noncore/applets/notesapplet/notes.cpp
index b3e72a7..d06672a 100644
--- a/noncore/applets/notesapplet/notes.cpp
+++ b/noncore/applets/notesapplet/notes.cpp
@@ -24,6 +24,7 @@
24#include <qpe/applnk.h> 24#include <qpe/applnk.h>
25#include <qpe/ir.h> 25#include <qpe/ir.h>
26#include <qpe/config.h> 26#include <qpe/config.h>
27#include <qpe/resource.h>
27using namespace Opie::Core; 28using namespace Opie::Core;
28using namespace Opie::Ui; 29using namespace Opie::Ui;
29 30
@@ -48,47 +49,15 @@ using namespace Opie::Ui;
48/* STD */ 49/* STD */
49#include <stdlib.h> 50#include <stdlib.h>
50 51
51/* XPM */
52static char * notes_xpm[] = {
53"16 16 11 1",
54" c None",
55". c #000000",
56"+ c #7F7F7F",
57"@ c #BFBFBF",
58"# c #BFC1FF",
59"$ c #FF0000",
60"% c #FFFFFF",
61"& c #00037F",
62"* c #0006FF",
63"= c #0005BF",
64"- c #7F0000",
65" .. ",
66" .. ",
67" ... ",
68" .+ ",
69" .@. ",
70" . .+ ",
71" ..#.@. ",
72" ..###.+.. ",
73" ..###$...##.. ",
74"..###$$$%+$$##&.",
75".*=####$-###&=&.",
76".=**=###==&=&=..",
77" ..=**=#&=&=.. ",
78" ..=*=&=.. ",
79" ..=.. ",
80" . "};
81
82
83NotesControl::NotesControl( QWidget *, const char * ) 52NotesControl::NotesControl( QWidget *, const char * )
84 : QVBox( 0, "NotesControl",/* WDestructiveClose | */WStyle_StaysOnTop ) 53 : QVBox( 0, "NotesControl",/* WDestructiveClose | */WStyle_StaysOnTop )
85// : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup ) 54// : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup )
86{ 55{
87 QDir d( QDir::homeDirPath()+"/notes"); 56 QDir d( QDir::homeDirPath()+"/notes");
88 if( !d.exists()) { 57 if( !d.exists()) {
89 odebug << "make dir" << oendl; 58 odebug << "make dir" << oendl;
90 if(!d.mkdir( QDir::homeDirPath()+"/notes", true)) 59 if(!d.mkdir( QDir::homeDirPath()+"/notes", true))
91 odebug << "<<<<<<<<<<<<<<<<<<<<<<<<<<<make dir failed" << oendl; 60 odebug << "<<<<<<<<<<<<<<<<<<<<<<<<<<<make dir failed" << oendl;
92 } 61 }
93 Config cfg("Notes"); 62 Config cfg("Notes");
94 cfg.setGroup("Options"); 63 cfg.setGroup("Options");
@@ -167,7 +136,7 @@ void NotesControl::slotDeleteButtonClicked() {
167void NotesControl::slotDeleteButton() { 136void NotesControl::slotDeleteButton() {
168 137
169 QString selectedText = box->currentText(); 138 QString selectedText = box->currentText();
170 odebug << "deleting "+selectedText << oendl; 139 odebug << "deleting "+selectedText << oendl;
171 140
172 if( !selectedText.isEmpty()) { 141 if( !selectedText.isEmpty()) {
173 142
@@ -178,12 +147,12 @@ void NotesControl::slotDeleteButton() {
178 for ( int i = 0; i < noOfFiles; i++ ) { 147 for ( int i = 0; i < noOfFiles; i++ ) {
179 entryName.sprintf( "File%i", i + 1 ); 148 entryName.sprintf( "File%i", i + 1 );
180 if(selectedText == cfg.readEntry( entryName )) { 149 if(selectedText == cfg.readEntry( entryName )) {
181 odebug << "removing " << selectedText.latin1() << ", " << i << "" << oendl; 150 odebug << "removing " << selectedText.latin1() << ", " << i << "" << oendl;
182 for ( int j = i; j < noOfFiles; j++ ) { 151 for ( int j = i; j < noOfFiles; j++ ) {
183 entryName.sprintf( "File%i", i + 1 ); 152 entryName.sprintf( "File%i", i + 1 );
184 entryName2.sprintf( "File%i", i + 2 ); 153 entryName2.sprintf( "File%i", i + 2 );
185 QString temp = cfg.readEntry(entryName2); 154 QString temp = cfg.readEntry(entryName2);
186 odebug << "move "+temp << oendl; 155 odebug << "move "+temp << oendl;
187 cfg.writeEntry(entryName, temp); 156 cfg.writeEntry(entryName, temp);
188 i++; 157 i++;
189 } 158 }
@@ -194,10 +163,10 @@ void NotesControl::slotDeleteButton() {
194 DocLnk nf(selectedText); 163 DocLnk nf(selectedText);
195 nf.removeFiles(); 164 nf.removeFiles();
196 QString fi=QPEApplication::documentDir()+"/text/plain/"+selectedText+".desktop"; 165 QString fi=QPEApplication::documentDir()+"/text/plain/"+selectedText+".desktop";
197 odebug << fi << oendl; 166 odebug << fi << oendl;
198 167
199 QFile f( fi); 168 QFile f( fi);
200 if( !f.remove()) odebug << ".desktop file not removed" << oendl; 169 if( !f.remove()) odebug << ".desktop file not removed" << oendl;
201 170
202 } 171 }
203 } 172 }
@@ -285,7 +254,7 @@ void NotesControl::save() {
285 Config cfg("Notes"); 254 Config cfg("Notes");
286 cfg.setGroup("Docs"); 255 cfg.setGroup("Docs");
287 if( edited) { 256 if( edited) {
288// odebug << "is edited" << oendl; 257// odebug << "is edited" << oendl;
289 QString rt = view->text(); 258 QString rt = view->text();
290 if( rt.length()>1) { 259 if( rt.length()>1) {
291 QString pt = rt.simplifyWhiteSpace(); 260 QString pt = rt.simplifyWhiteSpace();
@@ -303,7 +272,7 @@ void NotesControl::save() {
303 docname = docname.left(40); 272 docname = docname.left(40);
304 if ( docname.isEmpty() ) 273 if ( docname.isEmpty() )
305 docname = "Empty Text"; 274 docname = "Empty Text";
306// odebug << docname << oendl; 275// odebug << docname << oendl;
307 276
308 if( oldDocName != docname) { 277 if( oldDocName != docname) {
309 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 278 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
@@ -314,11 +283,11 @@ void NotesControl::save() {
314 cfg.write(); 283 cfg.write();
315 } 284 }
316// else 285// else
317// odebug << "oldname equals docname" << oendl; 286// odebug << "oldname equals docname" << oendl;
318 287
319 doc = new DocLnk(docname); 288 doc = new DocLnk(docname);
320 if(QFile(doc->linkFile()).exists()) 289 if(QFile(doc->linkFile()).exists())
321 odebug << "puppie" << oendl; 290 odebug << "puppie" << oendl;
322 doc->setType("text/plain"); 291 doc->setType("text/plain");
323 doc->setName(docname); 292 doc->setName(docname);
324 QString temp = docname.replace( QRegExp(" "), "_" ); 293 QString temp = docname.replace( QRegExp(" "), "_" );
@@ -329,7 +298,7 @@ void NotesControl::save() {
329 298
330 oldDocName=docname; 299 oldDocName=docname;
331 edited=false; 300 edited=false;
332// odebug << "save" << oendl; 301// odebug << "save" << oendl;
333 if (doPopulate) 302 if (doPopulate)
334 populateBox(); 303 populateBox();
335 } 304 }
@@ -341,7 +310,7 @@ void NotesControl::save() {
341 310
342void NotesControl::populateBox() { 311void NotesControl::populateBox() {
343 box->clear(); 312 box->clear();
344// odebug << "populate" << oendl; 313// odebug << "populate" << oendl;
345 Config cfg("Notes"); 314 Config cfg("Notes");
346 cfg.setGroup("Docs"); 315 cfg.setGroup("Docs");
347 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 ); 316 int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
@@ -376,7 +345,7 @@ void NotesControl::load() {
376} 345}
377 346
378void NotesControl::load(const QString & file) { 347void NotesControl::load(const QString & file) {
379 odebug << "loading "+file << oendl; 348 odebug << "loading "+file << oendl;
380 QString name = file; 349 QString name = file;
381 QString temp; 350 QString temp;
382 if( !QFile( QDir::homeDirPath()+"/"+file).exists() ) 351 if( !QFile( QDir::homeDirPath()+"/"+file).exists() )
@@ -403,7 +372,7 @@ void NotesControl::loadDoc( const DocLnk &f) {
403 FileManager fm; 372 FileManager fm;
404 QString txt; 373 QString txt;
405 if ( !fm.loadFile( f, txt ) ) { 374 if ( !fm.loadFile( f, txt ) ) {
406 odebug << "could not load file "+f.file() << oendl; 375 odebug << "could not load file "+f.file() << oendl;
407 return; 376 return;
408 } 377 }
409 view->setText(txt); 378 view->setText(txt);
@@ -437,7 +406,7 @@ void NotesControl::slotSearch() {
437// switch ( e->state() ) { 406// switch ( e->state() ) {
438// case ControlButton: 407// case ControlButton:
439// if(e->key() == Key_C) { //copy 408// if(e->key() == Key_C) { //copy
440// odebug << "copy" << oendl; 409// odebug << "copy" << oendl;
441// QClipboard *cb = QApplication::clipboard(); 410// QClipboard *cb = QApplication::clipboard();
442// QString text; 411// QString text;
443 412
@@ -461,8 +430,9 @@ void NotesControl::slotSearch() {
461 430
462NotesApplet::NotesApplet( QWidget *parent, const char *name ) 431NotesApplet::NotesApplet( QWidget *parent, const char *name )
463 : QWidget( parent, name ) { 432 : QWidget( parent, name ) {
464 setFixedHeight( 18 ); 433 setFixedHeight( AppLnk::smallIconSize() );
465 setFixedWidth( 14 ); 434 setFixedWidth( AppLnk::smallIconSize() );
435 notesPixmap.convertFromImage( Resource::loadImage( "edit" ).smoothScale( height(), width() ) );
466 vc = new NotesControl; 436 vc = new NotesControl;
467} 437}
468 438
@@ -484,10 +454,10 @@ void NotesApplet::mousePressEvent( QMouseEvent *) {
484// vc = new NotesControl; 454// vc = new NotesControl;
485// QPoint curPos = mapToGlobal( rect().topLeft() ); 455// QPoint curPos = mapToGlobal( rect().topLeft() );
486 if(vc->showMax) { 456 if(vc->showMax) {
487 odebug << "show max" << oendl; 457 odebug << "show max" << oendl;
488 vc->showMaximized(); 458 vc->showMaximized();
489 } else { 459 } else {
490 odebug << "no show max" << oendl; 460 odebug << "no show max" << oendl;
491 QWidget *wid = QPEApplication::desktop(); 461 QWidget *wid = QPEApplication::desktop();
492 QRect rect = QApplication::desktop()->geometry(); 462 QRect rect = QApplication::desktop()->geometry();
493 vc->setGeometry( ( wid->width() / 2) - ( vc->width() / 2 ) , 28 , wid->width() -10 , 180); 463 vc->setGeometry( ( wid->width() / 2) - ( vc->width() / 2 ) , 28 , wid->width() -10 , 180);
@@ -508,7 +478,7 @@ void NotesApplet::mousePressEvent( QMouseEvent *) {
508 478
509void NotesApplet::paintEvent( QPaintEvent* ) { 479void NotesApplet::paintEvent( QPaintEvent* ) {
510 QPainter p(this); 480 QPainter p(this);
511 p.drawPixmap( 0, 1, ( const char** ) notes_xpm ); 481 p.drawPixmap( 0, 2, notesPixmap );
512} 482}
513 483
514 484