summaryrefslogtreecommitdiff
path: root/noncore/applets
authordrw <drw>2005-03-08 21:50:02 (UTC)
committer drw <drw>2005-03-08 21:50:02 (UTC)
commit2b32d3e15f5774ee8f73977d606675e819498614 (patch) (side-by-side diff)
treee30982f7bfdf36bb8bfc2e3762c2d9234b809607 /noncore/applets
parentd32769dbeedb21fd7bdafb1c762e4e501cb02961 (diff)
downloadopie-2b32d3e15f5774ee8f73977d606675e819498614.zip
opie-2b32d3e15f5774ee8f73977d606675e819498614.tar.gz
opie-2b32d3e15f5774ee8f73977d606675e819498614.tar.bz2
Better version of icon
Diffstat (limited to 'noncore/applets') (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
@@ -21,12 +21,13 @@
#include <qpe/filemanager.h>
#include <qpe/qpeapplication.h>
#include <qpe/timestring.h>
#include <qpe/applnk.h>
#include <qpe/ir.h>
#include <qpe/config.h>
+#include <qpe/resource.h>
using namespace Opie::Core;
using namespace Opie::Ui;
/* QT */
#include <qmultilineedit.h>
#include <qlistbox.h>
@@ -45,53 +46,21 @@ using namespace Opie::Ui;
#include <qstringlist.h>
#include <qtimer.h>
/* STD */
#include <stdlib.h>
-/* XPM */
-static char * notes_xpm[] = {
-"16 16 11 1",
-" c None",
-". c #000000",
-"+ c #7F7F7F",
-"@ c #BFBFBF",
-"# c #BFC1FF",
-"$ c #FF0000",
-"% c #FFFFFF",
-"& c #00037F",
-"* c #0006FF",
-"= c #0005BF",
-"- c #7F0000",
-" .. ",
-" .. ",
-" ... ",
-" .+ ",
-" .@. ",
-" . .+ ",
-" ..#.@. ",
-" ..###.+.. ",
-" ..###$...##.. ",
-"..###$$$%+$$##&.",
-".*=####$-###&=&.",
-".=**=###==&=&=..",
-" ..=**=#&=&=.. ",
-" ..=*=&=.. ",
-" ..=.. ",
-" . "};
-
-
NotesControl::NotesControl( QWidget *, const char * )
: QVBox( 0, "NotesControl",/* WDestructiveClose | */WStyle_StaysOnTop )
// : QFrame( parent, name, WDestructiveClose | WStyle_StaysOnTop | WType_Popup )
{
QDir d( QDir::homeDirPath()+"/notes");
if( !d.exists()) {
- odebug << "make dir" << oendl;
+ odebug << "make dir" << oendl;
if(!d.mkdir( QDir::homeDirPath()+"/notes", true))
- odebug << "<<<<<<<<<<<<<<<<<<<<<<<<<<<make dir failed" << oendl;
+ odebug << "<<<<<<<<<<<<<<<<<<<<<<<<<<<make dir failed" << oendl;
}
Config cfg("Notes");
cfg.setGroup("Options");
showMax = cfg.readBoolEntry("ShowMax", false);
setFrameStyle( QFrame::PopupPanel | QFrame::Raised );
@@ -164,43 +133,43 @@ void NotesControl::slotDeleteButtonClicked() {
};
}
void NotesControl::slotDeleteButton() {
QString selectedText = box->currentText();
- odebug << "deleting "+selectedText << oendl;
+ odebug << "deleting "+selectedText << oendl;
if( !selectedText.isEmpty()) {
Config cfg("Notes");
cfg.setGroup("Docs");
int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
QString entryName, entryName2;;
for ( int i = 0; i < noOfFiles; i++ ) {
entryName.sprintf( "File%i", i + 1 );
if(selectedText == cfg.readEntry( entryName )) {
- odebug << "removing " << selectedText.latin1() << ", " << i << "" << oendl;
+ odebug << "removing " << selectedText.latin1() << ", " << i << "" << oendl;
for ( int j = i; j < noOfFiles; j++ ) {
entryName.sprintf( "File%i", i + 1 );
entryName2.sprintf( "File%i", i + 2 );
QString temp = cfg.readEntry(entryName2);
- odebug << "move "+temp << oendl;
+ odebug << "move "+temp << oendl;
cfg.writeEntry(entryName, temp);
i++;
}
cfg.writeEntry("NumberOfFiles", noOfFiles-1 );
entryName.sprintf( "File%i", noOfFiles );
cfg.removeEntry(entryName);
cfg.write();
DocLnk nf(selectedText);
nf.removeFiles();
QString fi=QPEApplication::documentDir()+"/text/plain/"+selectedText+".desktop";
- odebug << fi << oendl;
+ odebug << fi << oendl;
QFile f( fi);
- if( !f.remove()) odebug << ".desktop file not removed" << oendl;
+ if( !f.remove()) odebug << ".desktop file not removed" << oendl;
}
}
view->clear();
populateBox();
@@ -282,13 +251,13 @@ void NotesControl::focusOutEvent ( QFocusEvent * e) {
}
void NotesControl::save() {
Config cfg("Notes");
cfg.setGroup("Docs");
if( edited) {
-// odebug << "is edited" << oendl;
+// odebug << "is edited" << oendl;
QString rt = view->text();
if( rt.length()>1) {
QString pt = rt.simplifyWhiteSpace();
int i = pt.find( ' ', pt.find( ' ' )+2 );
QString docname = pt;
if ( i > 0 )
@@ -300,51 +269,51 @@ void NotesControl::save() {
// cut the length. filenames longer than that don't make sense
// and something goes wrong when they get too long.
if ( docname.length() > 40 )
docname = docname.left(40);
if ( docname.isEmpty() )
docname = "Empty Text";
-// odebug << docname << oendl;
+// odebug << docname << oendl;
if( oldDocName != docname) {
int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
QString entryName;
entryName.sprintf( "File%i", noOfFiles + 1 );
cfg.writeEntry( entryName,docname );
cfg.writeEntry("NumberOfFiles", noOfFiles+1 );
cfg.write();
}
// else
-// odebug << "oldname equals docname" << oendl;
+// odebug << "oldname equals docname" << oendl;
doc = new DocLnk(docname);
if(QFile(doc->linkFile()).exists())
- odebug << "puppie" << oendl;
+ odebug << "puppie" << oendl;
doc->setType("text/plain");
doc->setName(docname);
QString temp = docname.replace( QRegExp(" "), "_" );
doc->setFile( QDir::homeDirPath()+"/notes/"+temp);
FileManager fm;
if ( !fm.saveFile( *doc, rt ) ) {
}
oldDocName=docname;
edited=false;
-// odebug << "save" << oendl;
+// odebug << "save" << oendl;
if (doPopulate)
populateBox();
}
cfg.writeEntry( "LastDoc",oldDocName );
cfg.write();
}
}
void NotesControl::populateBox() {
box->clear();
-// odebug << "populate" << oendl;
+// odebug << "populate" << oendl;
Config cfg("Notes");
cfg.setGroup("Docs");
int noOfFiles = cfg.readNumEntry("NumberOfFiles", 0 );
QStringList list;
QString entryName;
for ( int i = 0; i < noOfFiles; i++ ) {
@@ -373,13 +342,13 @@ void NotesControl::load() {
cfg.writeEntry( "LastDoc",oldDocName );
cfg.write();
}
}
void NotesControl::load(const QString & file) {
- odebug << "loading "+file << oendl;
+ odebug << "loading "+file << oendl;
QString name = file;
QString temp;
if( !QFile( QDir::homeDirPath()+"/"+file).exists() )
temp = QDir::homeDirPath()+"/notes/"+ name.replace( QRegExp(" "), "_" );
else
temp = name;
@@ -400,13 +369,13 @@ void NotesControl::load(const QString & file) {
}
void NotesControl::loadDoc( const DocLnk &f) {
FileManager fm;
QString txt;
if ( !fm.loadFile( f, txt ) ) {
- odebug << "could not load file "+f.file() << oendl;
+ odebug << "could not load file "+f.file() << oendl;
return;
}
view->setText(txt);
}
void NotesControl::slotViewEdited() {
@@ -434,13 +403,13 @@ void NotesControl::slotSearch() {
// void NotesControl::keyReleaseEvent( QKeyEvent *e) {
// switch ( e->state() ) {
// case ControlButton:
// if(e->key() == Key_C) { //copy
-// odebug << "copy" << oendl;
+// odebug << "copy" << oendl;
// QClipboard *cb = QApplication::clipboard();
// QString text;
// // Copy text from the clipboard (paste)
// text = cb->text();
// }
@@ -458,14 +427,15 @@ void NotesControl::slotSearch() {
// }
//===========================================================================
NotesApplet::NotesApplet( QWidget *parent, const char *name )
: QWidget( parent, name ) {
- setFixedHeight( 18 );
- setFixedWidth( 14 );
+ setFixedHeight( AppLnk::smallIconSize() );
+ setFixedWidth( AppLnk::smallIconSize() );
+ notesPixmap.convertFromImage( Resource::loadImage( "edit" ).smoothScale( height(), width() ) );
vc = new NotesControl;
}
NotesApplet::~NotesApplet() {
delete vc;
}
@@ -481,16 +451,16 @@ void NotesApplet::mousePressEvent( QMouseEvent *) {
vc->save();
vc->close();
} else {
// vc = new NotesControl;
// QPoint curPos = mapToGlobal( rect().topLeft() );
if(vc->showMax) {
- odebug << "show max" << oendl;
+ odebug << "show max" << oendl;
vc->showMaximized();
} else {
- odebug << "no show max" << oendl;
+ odebug << "no show max" << oendl;
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);
}
@@ -505,12 +475,12 @@ void NotesApplet::mousePressEvent( QMouseEvent *) {
vc->view->setFocus();
}
}
void NotesApplet::paintEvent( QPaintEvent* ) {
QPainter p(this);
- p.drawPixmap( 0, 1, ( const char** ) notes_xpm );
+ p.drawPixmap( 0, 2, notesPixmap );
}
EXPORT_OPIE_APPLET_v1( NotesApplet )