-rw-r--r-- | core/launcher/launcher.cpp | 10 | ||||
-rw-r--r-- | core/launcher/mediummountgui.cpp | 56 | ||||
-rw-r--r-- | core/launcher/mediummountgui.h | 17 |
3 files changed, 47 insertions, 36 deletions
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp index d1df4cc..f9c6c02 100644 --- a/core/launcher/launcher.cpp +++ b/core/launcher/launcher.cpp @@ -464,214 +464,220 @@ Launcher::Launcher( QWidget* parent, const char* name, WFlags fl ) 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" ); DocLnkSet *tmp = 0; QString home = QString(getenv("HOME")) + "/Documents"; tmp = new DocLnkSet( home , QString::null); docsFolder->appendFrom( *tmp ); delete tmp; // 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 ); // generates newtime Stamp StorageInfo storage; const QList<FileSystem> &fileSystems = storage.fileSystems(); QListIterator<FileSystem> it ( fileSystems ); + + for ( ; it.current(); ++it ) { 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 cfg.writeEntry("timestamp", newStamp ); //just write a new timestamp // we need to scan the list now. Hopefully the cache will be there // read the mimetypes from the config and search for documents QStringList mimetypes = configToMime( &cfg); tmp = new DocLnkSet( (*it)->path(), mimetypes.join(";") ); docsFolder->appendFrom( *tmp ); delete tmp; }else{ // come up with the gui cause this a new card - MediumMountGui medium((*it)->path() ); + MediumMountGui medium(&cfg, (*it)->path() ); if( medium.check() ){ // we did not ask before or ask again is off if( medium.exec() ){ // he clicked yes so search it // speicher - cfg.read(); // cause of a race we need to reread + //cfg.read(); // cause of a race we need to reread - fixed cfg.writeEntry("timestamp", newStamp ); + cfg.write(); + tmp = new DocLnkSet( (*it)->path(), medium.mimeTypes().join(";" ) ); + docsFolder->appendFrom( *tmp ); + delete tmp; }// no else }else{ // we checked // do something different see what we need to do // let's see if we should check the device cfg.setGroup("main" ); bool check = cfg.readBoolEntry("autocheck", true ); if( check ){ // find the documents tmp = new DocLnkSet( (*it)->path(), configToMime(&cfg ).join(";") ); docsFolder->appendFrom( *tmp ); delete tmp; } } } } } 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); diff --git a/core/launcher/mediummountgui.cpp b/core/launcher/mediummountgui.cpp index e0acf4e..8cc2411 100644 --- a/core/launcher/mediummountgui.cpp +++ b/core/launcher/mediummountgui.cpp @@ -1,197 +1,199 @@ #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 <qpe/config.h> + #include <opie/oconfig.h> #include <qapplication.h> -MediumMountGui::MediumMountGui( const QString &path ,QWidget* parent, const char* name, bool modal, WFlags fl ) +MediumMountGui::MediumMountGui( Config *cfg, const QString &path ,QWidget* parent, const char* name, bool , WFlags ) : QDialog( parent, name, true ) { - + m_cfg = cfg; 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); + //OConfig cfg (mediumPath +"/.opiestorage.cf"); + m_cfg->setGroup("main"); + checkagain = m_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", ""); + m_cfg->setGroup("mimetypes"); + checkmimeaudio = m_cfg->readBoolEntry("audio", true); + checkmimeimage = m_cfg->readBoolEntry("image", true); + checkmimetext = m_cfg->readBoolEntry("text", true); + checkmimevideo = m_cfg->readBoolEntry("video", true); + checkmimeall = m_cfg->readBoolEntry("all", true); + + m_cfg->setGroup("dirs"); + limittodirs = m_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 ); + //OConfig cfg (mediumPath +"/.opiestorage.cf"); + m_cfg->setGroup("main"); + m_cfg->writeEntry("check", AskBox->isChecked() ); + m_cfg->writeEntry("autocheck", autocheck ); - cfg.setGroup("mimetypes"); + m_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() ); + m_cfg->writeEntry("audio", CheckBoxAudio->isChecked() ); + m_cfg->writeEntry("image",CheckBoxImage->isChecked() ); + m_cfg->writeEntry("text",CheckBoxImage->isChecked() ); + m_cfg->writeEntry("video",CheckBoxVideo->isChecked() ); + m_cfg->writeEntry("all",CheckBoxAll->isChecked() ); - cfg.setGroup("dirs"); - cfg.writeEntry("dirs", ""); + m_cfg->setGroup("dirs"); + m_cfg->writeEntry("dirs", ""); // if all is checked then add only "QString::null" to the list. if (checkmimeall) { mimeTypeList.clear(); mimeTypeList += QString::null; } else { if (checkmimeaudio) { mimeTypeList += ("audio/*"); } if (checkmimetext) { mimeTypeList += ("text/*"); } if (checkmimevideo) { mimeTypeList += ("video/*"); } if (checkmimeimage) { mimeTypeList += ("image/*"); } } - cfg.write(); // not really needed here but just to be sure + m_cfg->write(); // not really needed here but just to be sure } 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() ) ); } diff --git a/core/launcher/mediummountgui.h b/core/launcher/mediummountgui.h index 2e04f94..8292c3a 100644 --- a/core/launcher/mediummountgui.h +++ b/core/launcher/mediummountgui.h @@ -1,68 +1,71 @@ #ifndef MEDIUMMOUNTGUI_H #define MEDIUMMOUNTGUI_H #include <qvariant.h> #include <qdialog.h> class QVBoxLayout; class QHBoxLayout; class QGridLayout; class QCheckBox; class QGroupBox; class QLabel; class QLineEdit; class QPushButton; +class Config; class MediumMountGui : public QDialog { Q_OBJECT public: - MediumMountGui( const QString &path = "tmp/", QWidget* parent = 0, const char* name = 0, bool modal = FALSE ,WFlags fl = 0 ); + MediumMountGui( Config *cfg, const QString &path = "tmp/", QWidget* parent = 0, const char* name = 0, bool modal = FALSE ,WFlags fl = 0 ); ~MediumMountGui(); protected: QPushButton* quit; QPushButton* quit_2; QLabel* DirSelectText_2; QLineEdit* LineEdit1; QPushButton* PushButton3; QLabel* DirSelectText; QLabel* Text_2; QLabel* Text; QGroupBox* GroupBox1; QCheckBox* CheckBoxAudio; QCheckBox* CheckBoxImage; QCheckBox* CheckBoxText; QCheckBox* CheckBoxVideo; QCheckBox* CheckBoxAll; QCheckBox* CheckBoxLink; QCheckBox* AskBox; + public: bool check(); QStringList mimeTypes(); QStringList dirs(); private: void startGui(); void readConfig(); void writeConfig(bool checkagain); private slots: void yesPressed(); void noPressed(); void deactivateOthers(); private: QString mediumPath; - bool checkagain; - bool checkmimeaudio; - bool checkmimeimage; - bool checkmimetext; - bool checkmimevideo; - bool checkmimeall; + bool checkagain:1; + bool checkmimeaudio:1; + bool checkmimeimage:1; + bool checkmimetext:1; + bool checkmimevideo:1; + bool checkmimeall:1; QString limittodirs; QStringList mimeTypeList; + Config *m_cfg; }; #endif |