author | zecke <zecke> | 2002-03-22 23:09:26 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-03-22 23:09:26 (UTC) |
commit | 5c17e8b168cf27ac2922e7c118cb886b116eab42 (patch) (side-by-side diff) | |
tree | 5ba4ad0f08f9e93c62b95545d97a462f6924e45c | |
parent | 232a5bed633ba2aa96fcab73ff991ab3a796ad76 (diff) | |
download | opie-5c17e8b168cf27ac2922e7c118cb886b116eab42.zip opie-5c17e8b168cf27ac2922e7c118cb886b116eab42.tar.gz opie-5c17e8b168cf27ac2922e7c118cb886b116eab42.tar.bz2 |
make some people happy update
-rw-r--r-- | core/launcher/launcher.cpp | 1 | ||||
-rw-r--r-- | core/launcher/mediummountgui.cpp | 1 | ||||
-rw-r--r-- | libopie/oconfig.h | 2 |
3 files changed, 3 insertions, 1 deletions
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp index dcc3ba1..1c38a05 100644 --- a/core/launcher/launcher.cpp +++ b/core/launcher/launcher.cpp @@ -356,384 +356,385 @@ void CategoryTabBar::paint( QPainter * p, QTab * t, bool selected ) const int ih = 0; if ( t->iconSet() != 0 ) { iw = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 2; ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); } int w = iw + p->fontMetrics().width( t->text() ) + 4; int h = QMAX(p->fontMetrics().height() + 4, ih ); paintLabel( p, QRect( r.left() + (r.width()-w)/2 - 3, r.top() + (r.height()-h)/2, w, h ), t, #if QT_VERSION >= 300 t->identifier() == keyboardFocusTab() #else t->identitifer() == keyboardFocusTab() #endif ); } void CategoryTabBar::paintLabel( QPainter* p, const QRect&, QTab* t, bool has_focus ) const { QRect r = t->rect(); // if ( t->id != currentTab() ) //r.moveBy( 1, 1 ); // if ( t->iconSet() ) { // the tab has an iconset, draw it in the right mode QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled; if ( mode == QIconSet::Normal && has_focus ) mode = QIconSet::Active; QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, mode ); int pixw = pixmap.width(); int pixh = pixmap.height(); p->drawPixmap( r.left() + 6, r.center().y() - pixh / 2 + 1, pixmap ); r.setLeft( r.left() + pixw + 5 ); } QRect tr = r; if ( r.width() < 20 ) return; if ( t->isEnabled() && isEnabled() ) { #if defined(_WS_WIN32_) if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) ) p->setPen( colorGroup().buttonText() ); else p->setPen( colorGroup().foreground() ); #else p->setPen( colorGroup().foreground() ); #endif p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); } else { p->setPen( palette().disabled().foreground() ); p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); } } //--------------------------------------------------------------------------- Launcher::Launcher( QWidget* parent, const char* name, WFlags fl ) : QMainWindow( parent, name, fl ) { setCaption( tr("Launcher") ); syncDialog = 0; // we have a pretty good idea how big we'll be setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); tabs = 0; rootFolder = 0; docsFolder = 0; int stamp = uidgen.generate(); uidgen.store( stamp ); m_timeStamp = QString::number( stamp ); tabs = new CategoryTabWidget( this ); tabs->setMaximumWidth( qApp->desktop()->width() ); setCentralWidget( tabs ); connect( tabs, SIGNAL(selected(const QString&)), this, SLOT(viewSelected(const QString&)) ); connect( tabs, SIGNAL(clicked(const AppLnk*)), this, SLOT(select(const AppLnk*))); connect( tabs, SIGNAL(rightPressed(AppLnk*)), this, SLOT(properties(AppLnk*))); #if defined(Q_WS_QWS) && !defined(QT_NO_COP) QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), this, SLOT(systemMessage( const QCString &, const QByteArray &)) ); #endif storage = new StorageInfo( this ); connect( storage, SIGNAL( disksChanged() ), SLOT( storageChanged() ) ); updateTabs(); preloadApps(); in_lnk_props = FALSE; got_lnk_change = FALSE; } Launcher::~Launcher() { } static bool isVisibleWindow(int wid) { const QList<QWSWindow> &list = qwsServer->clientWindows(); QWSWindow* w; for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { if ( w->winId() == wid ) return !w->isFullyObscured(); } return FALSE; } void Launcher::showMaximized() { if ( isVisibleWindow( winId() ) ) doMaximize(); else QTimer::singleShot( 20, this, SLOT(doMaximize()) ); } void Launcher::doMaximize() { QMainWindow::showMaximized(); } void Launcher::updateMimeTypes() { MimeType::clear(); updateMimeTypes(rootFolder); } void Launcher::updateMimeTypes(AppLnkSet* folder) { for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) { AppLnk *app = it.current(); if ( app->type() == "Folder" ) updateMimeTypes((AppLnkSet *)app); else { MimeType::registerApp(*app); } } } void Launcher::loadDocs() // ok here comes a hack belonging to Global:: { qWarning("loading Documents" ); qWarning("The currentTimeStamp is: %s", m_timeStamp.latin1() ); delete docsFolder; docsFolder = new DocLnkSet; qWarning("new DocLnkSet" ); // find out wich filesystems are new in this round // We will do this by having a timestamp inside each mountpoint // if the current timestamp doesn't match this is a new file system and // come up with our MediumMountGui :) let the hacking begin int stamp = uidgen.generate(); QString newStamp = QString::number( stamp ); qWarning("new time stamp is: %s", newStamp.latin1() ); StorageInfo storage; const QList<FileSystem> &fileSystems = storage.fileSystems(); qWarning("QList<FileSystem>" ); QListIterator<FileSystem> it ( fileSystems ); qWarning("iterator initiliazed" ); for ( ; it.current(); ++it ) { qWarning("inside for loop" ); qWarning("checking device %s", (*it)->path().latin1() ); if ( (*it)->isRemovable() ) { // let's find out if we should search on it qWarning("%s is removeable", (*it)->path().latin1() ); OConfig cfg( (*it)->path() + "/.opiestorage.cf"); cfg.setGroup("main"); QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() ); if( stamp == m_timeStamp ){ // ok we know this card qWarning("time stamp match" ); cfg.writeEntry("timestamp", newStamp ); // we need to scan the list now. Hopefully the cache will be there }else{ // come up with the gui qWarning("time stamp doesn't match" ); MediumMountGui medium((*it)->path() ); qWarning("medium mount gui created" ); if( medium.check() ){ qWarning("need to check this device" ); if( medium.exec() ){ //ok // speicher qWarning("execed" ); + cfg.read(); cfg.writeEntry("timestamp", newStamp ); } }else{ qWarning("wrong :(" ); // do something different see what we need to do } } } } qWarning("findDocuments" ); Global::findDocuments(docsFolder); // get rid of this call later qWarning("done" ); m_timeStamp = newStamp; } void Launcher::updateTabs() { MimeType::updateApplications(); // ### reads all applnks twice delete rootFolder; rootFolder = new AppLnkSet( MimeType::appsFolderName() ); loadDocs(); tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems()); } void Launcher::updateDocs() { loadDocs(); tabs->updateDocs(docsFolder,storage->fileSystems()); } void Launcher::viewSelected(const QString& s) { setCaption( s + tr(" - Launcher") ); } void Launcher::nextView() { tabs->nextTab(); } void Launcher::select( const AppLnk *appLnk ) { if ( appLnk->type() == "Folder" ) { // Not supported: flat is simpler for the user } else { if ( appLnk->exec().isNull() ) { QMessageBox::information(this,tr("No application"), tr("<p>No application is defined for this document." "<p>Type is %1.").arg(appLnk->type())); return; } tabs->setBusy(TRUE); emit executing( appLnk ); appLnk->execute(); } } void Launcher::externalSelected(const AppLnk *appLnk) { tabs->setBusy(TRUE); emit executing( appLnk ); } void Launcher::properties( AppLnk *appLnk ) { if ( appLnk->type() == "Folder" ) { // Not supported: flat is simpler for the user } else { in_lnk_props = TRUE; got_lnk_change = FALSE; LnkProperties prop(appLnk); connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); prop.showMaximized(); prop.exec(); in_lnk_props = FALSE; if ( got_lnk_change ) { updateLink(lnk_change); } } } void Launcher::updateLink(const QString& link) { if (link.isNull()) updateTabs(); else if (link.isEmpty()) updateDocs(); else tabs->updateLink(link); } void Launcher::systemMessage( const QCString &msg, const QByteArray &data) { QDataStream stream( data, IO_ReadOnly ); if ( msg == "linkChanged(QString)" ) { QString link; stream >> link; if ( in_lnk_props ) { got_lnk_change = TRUE; lnk_change = link; } else { updateLink(link); } } else if ( msg == "busy()" ) { emit busy(); } else if ( msg == "notBusy(QString)" ) { QString app; stream >> app; tabs->setBusy(FALSE); emit notBusy(app); } else if ( msg == "mkdir(QString)" ) { QString dir; stream >> dir; if ( !dir.isEmpty() ) mkdir( dir ); } else if ( msg == "rdiffGenSig(QString,QString)" ) { QString baseFile, sigFile; stream >> baseFile >> sigFile; QRsync::generateSignature( baseFile, sigFile ); } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { QString baseFile, sigFile, deltaFile; stream >> baseFile >> sigFile >> deltaFile; QRsync::generateDiff( baseFile, sigFile, deltaFile ); } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { QString baseFile, deltaFile; stream >> baseFile >> deltaFile; if ( !QFile::exists( baseFile ) ) { QFile f( baseFile ); f.open( IO_WriteOnly ); f.close(); } QRsync::applyDiff( baseFile, deltaFile ); QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); e << baseFile; } else if ( msg == "rdiffCleanup()" ) { mkdir( "/tmp/rdiff" ); QDir dir; dir.setPath( "/tmp/rdiff" ); QStringList entries = dir.entryList(); for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) dir.remove( *it ); } else if ( msg == "sendHandshakeInfo()" ) { QString home = getenv( "HOME" ); QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); e << home; int locked = (int) Desktop::screenLocked(); e << locked; // register an app for autostart // if clear is send the list is cleared. } else if ( msg == "autoStart(QString)" ) { QString appName; stream >> appName; Config cfg( "autostart" ); cfg.setGroup( "AutoStart" ); if ( appName.compare("clear") == 0){ cfg.writeEntry("Apps", ""); } } else if ( msg == "autoStart(QString,QString)" ) { QString modifier, appName; stream >> modifier >> appName; Config cfg( "autostart" ); cfg.setGroup( "AutoStart" ); if ( modifier.compare("add") == 0 ){ // only add it appname is entered if (!appName.isEmpty()) { cfg.writeEntry("Apps", appName); } } else if (modifier.compare("remove") == 0 ) { // need to change for multiple entries // actually remove is right now simular to clear, but in future there // should be multiple apps in autostart possible. QString checkName; checkName = cfg.readEntry("Apps", ""); if (checkName == appName) { cfg.writeEntry("Apps", ""); } } } else if ( msg == "sendCardInfo()" ) { QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); const QList<FileSystem> &fs = storage->fileSystems(); QListIterator<FileSystem> it ( fs ); QString s; QString homeDir = getenv("HOME"); QString hardDiskHome; for ( ; it.current(); ++it ) { if ( (*it)->isRemovable() ) s += (*it)->name() + "=" + (*it)->path() + "/Documents " + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) diff --git a/core/launcher/mediummountgui.cpp b/core/launcher/mediummountgui.cpp index 5225711..e3fa5bd 100644 --- a/core/launcher/mediummountgui.cpp +++ b/core/launcher/mediummountgui.cpp @@ -1,232 +1,233 @@ #include "mediummountgui.h" #include <qvariant.h> #include <qcheckbox.h> #include <qgroupbox.h> #include <qlabel.h> #include <qlineedit.h> #include <qpushbutton.h> #include <qlayout.h> #include <qtooltip.h> #include <qwhatsthis.h> #include <qimage.h> #include <qpixmap.h> #include <qpe/resource.h> #include <opie/oconfig.h> #include <qapplication.h> MediumMountGui::MediumMountGui( const QString &path ,QWidget* parent, const char* name, bool modal, WFlags fl ) : QDialog( parent, name, true ) { QWidget *d = QApplication::desktop(); int w=d->width(); int h=d->height(); resize( w , h ); setCaption( tr( "Medium inserted" ) ); mediumPath = path; readConfig(); startGui(); } void MediumMountGui::readConfig(){ OConfig cfg (mediumPath +"/.opiestorage.cf"); cfg.setGroup("main"); checkagain = cfg.readBoolEntry("check", false); cfg.setGroup("mimetypes"); checkmimeaudio = cfg.readBoolEntry("audio", true); checkmimeimage = cfg.readBoolEntry("image", true); checkmimetext = cfg.readBoolEntry("text", true); checkmimevideo = cfg.readBoolEntry("video", true); checkmimeall = cfg.readBoolEntry("all", true); cfg.setGroup("dirs"); limittodirs = cfg.readEntry("dirs", ""); } bool MediumMountGui::check() { return !checkagain; } QStringList MediumMountGui::dirs() { QStringList list = QStringList::split(",", limittodirs ); return list; } void MediumMountGui::writeConfig(bool autocheck) { OConfig cfg (mediumPath +"/.opiestorage.cf"); cfg.setGroup("main"); cfg.writeEntry("check", AskBox->isChecked() ); cfg.writeEntry("autocheck", autocheck ); cfg.setGroup("mimetypes"); cfg.writeEntry("audio", CheckBoxAudio->isChecked() ); cfg.writeEntry("image",CheckBoxImage->isChecked() ); cfg.writeEntry("text",CheckBoxImage->isChecked() ); cfg.writeEntry("video",CheckBoxVideo->isChecked() ); cfg.writeEntry("all",CheckBoxAll->isChecked() ); cfg.setGroup("dirs"); cfg.writeEntry("dirs", ""); // if all is checked then add only "null" to the list. if (checkmimeall) { mimeTypeList += ("null"); } else { if (checkmimeaudio) { mimeTypeList += ("audio//*"); } if (checkmimetext) { mimeTypeList += ("text//*"); } if (checkmimevideo) { mimeTypeList += ("video//*"); } if (checkmimeimage) { mimeTypeList += ("image//*"); } if (checkmimeall) { mimeTypeList << ("null"); } } + cfg.write(); } void MediumMountGui::startGui() { QPixmap image = Resource::loadPixmap( "HelpBrowser"); Text_2 = new QLabel( this ); Text_2->setGeometry( QRect( 10, 15, 40, 40 ) ); Text_2->setPixmap( image ); Text = new QLabel( this, "Text" ); Text->setGeometry( QRect( 55, 11, this->width()-50, 50 ) ); Text->setText( tr( "A <b>storage medium</b> was inserted. Should it be scanned for media files?" ) ); // media box GroupBox1 = new QGroupBox( this, "GroupBox1" ); GroupBox1->setGeometry( QRect( 10, 80, (this->width())-25, 80 ) ); GroupBox1->setTitle( tr( "Which media files" ) ); CheckBoxAudio = new QCheckBox( GroupBox1, "CheckBoxAudio" ); CheckBoxAudio->setGeometry( QRect( 10, 15, (GroupBox1->width()/2)-15 , 15 ) ); CheckBoxAudio->setText( tr( "Audio" ) ); CheckBoxImage = new QCheckBox( GroupBox1, "CheckBoxImage" ); CheckBoxImage->setGeometry( QRect( 10, 35,(GroupBox1->width()/2)-15, 15 ) ); CheckBoxImage->setText( tr( "Image" ) ); CheckBoxText = new QCheckBox( GroupBox1, "CheckBoxText" ); CheckBoxText->setGeometry( QRect((GroupBox1->width()/2) , 15, (GroupBox1->width()/2)-15, 15 ) ); CheckBoxText->setText( tr( "Text" ) ); CheckBoxVideo = new QCheckBox( GroupBox1, "CheckBoxVideo" ); CheckBoxVideo->setGeometry( QRect( (GroupBox1->width()/2), 35, (GroupBox1->width()/2)-15, 15 ) ); CheckBoxVideo->setText( tr( "Video" ) ); CheckBoxAll = new QCheckBox ( GroupBox1); CheckBoxAll->setGeometry( QRect( 10, 55, (GroupBox1->width()/2)-15, 15 ) ); CheckBoxAll->setText( tr( "All" ) ); QObject::connect( (QObject*)CheckBoxAll, SIGNAL( clicked() ), this, SLOT( deactivateOthers()) ); CheckBoxLink = new QCheckBox ( GroupBox1); CheckBoxLink->setGeometry( QRect( (GroupBox1->width()/2), 55, (GroupBox1->width()/2)-15, 15 ) ); CheckBoxLink->setText( tr( "Link apps" ) ); // as long as the feature is not supported CheckBoxLink->setEnabled(false); // select dirs DirSelectText = new QLabel( this, "DirSelectText" ); DirSelectText->setGeometry( QRect( 10, 160,this->width() , 20 ) ); DirSelectText->setText( tr( "Limit search to dir: (not used yet)" ) ); LineEdit1 = new QLineEdit( this ); LineEdit1->setGeometry( QRect( 10, 180, (this->width())-60, 20 ) ); PushButton3 = new QPushButton( this ); PushButton3->setGeometry( QRect( (this->width())-40, 180, 30, 20 ) ); PushButton3->setText( tr( "Add" ) ); // decision DirSelectText_2 = new QLabel( this ); DirSelectText_2->setGeometry( QRect( 10,240,this->width(), 15 ) ); DirSelectText_2->setText( tr( "Your decision will be stored on the medium." ) ); // ask again AskBox = new QCheckBox( this ); AskBox->setGeometry( QRect( 10, 215, (this->width())-15 , 15 ) ); AskBox->setText( tr( "Do not ask again for this medium" ) ); AskBox->setChecked(checkagain); CheckBoxAudio->setChecked(checkmimeaudio); CheckBoxImage->setChecked(checkmimeimage); CheckBoxText->setChecked(checkmimetext); CheckBoxVideo->setChecked(checkmimevideo); // buttons quit = new QPushButton( this ); quit->setGeometry( QRect( (this->width()/2)- 90 , 260, 80, 22 ) ); quit->setFocus(); quit->setText( tr( "Yes" ) ); quit_2 = new QPushButton( this ); quit_2->setGeometry( QRect((this->width()/2) , 260, 80, 22 ) ); quit_2->setText( tr( "No" ) ); QObject::connect( (QObject*)quit, SIGNAL( clicked() ), this, SLOT(yesPressed() ) ); QObject::connect( (QObject*)quit_2, SIGNAL( clicked() ), this, SLOT(noPressed() ) ); } void MediumMountGui::deactivateOthers() { bool mod = !(CheckBoxAll->isChecked()); //if (!CheckBoxVideo->isChecked()){ // mod = false; //} else { // mod = true; //} CheckBoxVideo->setEnabled(mod); CheckBoxAudio->setEnabled(mod); CheckBoxText->setEnabled(mod); CheckBoxImage->setEnabled(mod); } void MediumMountGui::yesPressed() { writeConfig(true); // and do something accept(); } QStringList MediumMountGui::mimeTypes(){ return mimeTypeList; } void MediumMountGui::noPressed() { writeConfig(false); reject(); } MediumMountGui::~MediumMountGui(){ } diff --git a/libopie/oconfig.h b/libopie/oconfig.h index c97fb6a..f6227d1 100644 --- a/libopie/oconfig.h +++ b/libopie/oconfig.h @@ -1,48 +1,48 @@ /* =. This file is part of the OPIE Project .=l. Copyright (c) 2002 Holger 'zecke' Freyther<freyther@kde.org> .>+-= _;:, .> :=|. This library is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This library is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <qpe/config.h> #ifndef opieconfig_h #define opieconfig_h /** It supports all Config items + it lets you decide * which file to use. */ class OConfig : public Config { public: OConfig( const QString &filename ); ~OConfig(); QString fileName() const; - + void read( ) { Config::read(); }; }; #endif |