summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/mediummount/main.cpp16
-rw-r--r--noncore/settings/mediummount/mainwindow.cc55
-rw-r--r--noncore/settings/mediummount/mainwindow.h33
-rw-r--r--noncore/settings/mediummount/mediumglobal.cc182
-rw-r--r--noncore/settings/mediummount/mediumglobal.h59
-rw-r--r--noncore/settings/mediummount/mediummount.pro8
-rw-r--r--noncore/settings/mediummount/mediumwidget.cc190
-rw-r--r--noncore/settings/mediummount/mediumwidget.h77
8 files changed, 620 insertions, 0 deletions
diff --git a/noncore/settings/mediummount/main.cpp b/noncore/settings/mediummount/main.cpp
new file mode 100644
index 0000000..e4443bd
--- a/dev/null
+++ b/noncore/settings/mediummount/main.cpp
@@ -0,0 +1,16 @@
+#include "mediumwidget.h"
+#include "mediumglobal.h"
+#include "mainwindow.h"
+
+#include <qpixmap.h>
+#include <qpe/qpeapplication.h>
+
+int main( int argc, char ** argv )
+{
+ QPEApplication a( argc, argv );
+
+ MediumMountSetting::MainWindow mw;
+ a.showMainWidget( &mw );
+
+ return a.exec();
+}
diff --git a/noncore/settings/mediummount/mainwindow.cc b/noncore/settings/mediummount/mainwindow.cc
new file mode 100644
index 0000000..88f7c61
--- a/dev/null
+++ b/noncore/settings/mediummount/mainwindow.cc
@@ -0,0 +1,55 @@
+
+
+#include <qtabwidget.h>
+#include <qlayout.h>
+
+#include <qpe/storage.h>
+
+#include "mediumwidget.h"
+#include "mediumglobal.h"
+
+#include "mainwindow.h"
+
+using namespace MediumMountSetting;
+
+
+MainWindow::MainWindow( QWidget *parent, const char *name )
+ : QMainWindow( parent, name )
+
+{
+ // m_lay = new QVBoxLayout( this );
+ m_tab = new QTabWidget( this );
+ setCentralWidget( m_tab );
+ init();
+}
+
+MainWindow::~MainWindow()
+{
+
+}
+void MainWindow::init()
+{
+ m_global = new MediumGlobalWidget( m_tab, "test drive" );
+ m_tab->addTab( m_global, tr("Global") );
+
+ StorageInfo storage;
+ const QList<FileSystem> &fs = storage.fileSystems();
+ QListIterator<FileSystem> it( fs );
+ MediumMountWidget *wid;
+ for( ; it.current(); ++it ){
+ if( (*it)->isRemovable() ){
+ wid = new MediumMountWidget((*it)->path(), QPixmap(), m_tab );
+ m_mediums.append( wid );
+ m_tab->addTab( wid, (*it)->name() );
+ }
+ }
+}
+
+void MainWindow::slotGlobalChanged(int )
+{
+
+}
+void MainWindow::slotCheckingChanged(int )
+{
+
+}
diff --git a/noncore/settings/mediummount/mainwindow.h b/noncore/settings/mediummount/mainwindow.h
new file mode 100644
index 0000000..1e60e12
--- a/dev/null
+++ b/noncore/settings/mediummount/mainwindow.h
@@ -0,0 +1,33 @@
+
+
+#ifndef MediumMountMainwindow_h
+#define MediumMountMainwindow_h
+
+#include <qlist.h>
+#include <qmainwindow.h>
+
+class QVBoxLayout;
+class QTabWidget;
+
+namespace MediumMountSetting {
+ class MediumMountWidget;
+ class MediumGlobalWidget;
+ class MainWindow : public QMainWindow {
+ Q_OBJECT
+ public:
+ MainWindow(QWidget *parent = 0, const char *name = 0 );
+ ~MainWindow();
+
+ private slots:
+ void slotGlobalChanged(int );
+ void slotCheckingChanged(int );
+ private:
+ void init();
+ QTabWidget *m_tab;
+ QVBoxLayout *m_lay;
+ MediumGlobalWidget *m_global;
+ QList<MediumMountWidget> m_mediums;
+ };
+};
+
+#endif
diff --git a/noncore/settings/mediummount/mediumglobal.cc b/noncore/settings/mediummount/mediumglobal.cc
new file mode 100644
index 0000000..921fcd1
--- a/dev/null
+++ b/noncore/settings/mediummount/mediumglobal.cc
@@ -0,0 +1,182 @@
+
+
+#include <qlineedit.h>
+#include <qcheckbox.h>
+#include <qlabel.h>
+#include <qabstractlayout.h> // spacer item
+#include <qlayout.h>
+#include <qframe.h>
+#include <qgroupbox.h>
+
+#include <qpe/config.h>
+
+#include "mediumglobal.h"
+
+using namespace MediumMountSetting;
+
+MediumGlobalWidget::MediumGlobalWidget(QWidget *wid, const char *name )
+ : QWidget( wid, name )
+{
+ m_config = 0;
+ initGUI();
+ readConfig();
+
+}
+void MediumGlobalWidget::initGUI()
+{
+ m_layout = new QVBoxLayout(this );
+ m_layout->setMargin( 10 );
+ m_layout->setSpacing( 10 );
+
+
+ m_label = new QLabel( this );
+ m_label->setTextFormat( Qt::RichText );
+ m_label->setText( tr("If a medium gets inserted into this device Opie "
+ "tries to search the medium for Dcouments. On "
+ "large mediums this can take some time. You can choose "
+ "if Opie should scan for Documents globally or on a "
+ "per medium level. You're also able to reconfigure "
+ "each medium."
+ ) );
+ m_layout->addWidget( m_label );
+
+ m_check = new QCheckBox( tr("Enable medium checking" ), this );
+ connect( m_check, SIGNAL(stateChanged(int) ),
+ this, SLOT(slotEnableChecking() ) );
+ m_layout->addWidget(m_check );
+
+ m_frame = new QFrame(this, "Frame" );
+ m_frame->setFrameShape( QFrame::Box );
+ m_frame->setFrameShadow( QFrame::Sunken );
+
+ m_box = new QVBoxLayout( m_frame );
+ m_box->setMargin( 5 );
+ m_useglobal = new QCheckBox( tr("Use global settings"), m_frame );
+ connect( m_useglobal, SIGNAL( stateChanged(int) ),
+ this, SLOT( slotGlobalChanged() ) );
+
+ m_box->addWidget( m_useglobal );
+
+ m_global = new QGroupBox( tr("Which media files"), m_frame );
+ m_frameLay = new QGridLayout(m_global, 4, 3 );
+ m_frameLay->setMargin( 12 );
+
+ QSpacerItem *item2 = new QSpacerItem( 5, 8,
+ QSizePolicy::Fixed,
+ QSizePolicy::Fixed );
+ m_audio = new QCheckBox( tr("Audio"), m_global );
+ m_all = new QCheckBox( tr("All") , m_global );
+ m_image = new QCheckBox( tr("Image"), m_global );
+ m_text = new QCheckBox( tr("Text") , m_global );
+ m_video = new QCheckBox( tr("Video"), m_global );
+
+ connect(m_all, SIGNAL(stateChanged(int) ),
+ this, SLOT(slotAllChanged() ) );
+
+ m_frameLay->addItem( item2, 0, 0 );
+
+ m_frameLay->addWidget( m_audio, 1, 0 );
+ m_frameLay->addWidget( m_image, 2, 0 );
+ m_frameLay->addWidget( m_all, 3, 0 );
+
+ m_frameLay->addWidget( m_text, 1, 2 );
+ m_frameLay->addWidget( m_video, 2, 2 );
+
+ m_frameLay->addRowSpacing( 0, 8 );
+ m_frameLay->addColSpacing( 1, 2 );
+
+ m_box->addWidget( m_global );
+
+
+ m_layout->addWidget( m_frame );
+
+ QSpacerItem *item1 = new QSpacerItem( 1, 24,
+ QSizePolicy::Fixed,
+ QSizePolicy::Expanding );
+ m_layout->addItem( item1 );
+}
+void MediumGlobalWidget::readConfig()
+{
+ if( m_config == 0 )
+ m_config = new Config("medium" );
+
+ m_config->setGroup("main");
+ m_useglobal->setChecked( m_config->readBoolEntry("global", false ) );
+ m_check->setChecked( m_config->readBoolEntry("use", true ) );
+
+ m_config->setGroup("mimetypes" );
+ m_all->setChecked ( m_config->readBoolEntry("all", false ) );
+ m_audio->setChecked( m_config->readBoolEntry("audio", true ) );
+ m_video->setChecked( m_config->readBoolEntry("video", true ) );
+ m_text->setChecked ( m_config->readBoolEntry("text", true ) );
+ m_image->setChecked( m_config->readBoolEntry("image", true ) );
+
+ slotAllChanged();
+ slotEnableChecking();
+ slotGlobalChanged();
+ if( m_all->isChecked() ){
+ m_video->setEnabled( false );
+ m_text->setEnabled( false );
+ m_audio->setEnabled( false );
+ m_image->setEnabled( false );
+
+ }
+}
+void MediumGlobalWidget::writeConfig()
+{
+ m_config->setGroup( "main" );
+ m_config->writeEntry("global", m_useglobal->isChecked() );
+ m_config->writeEntry("use", m_check->isChecked() );
+
+ m_config->setGroup("mimetypes" );
+
+ m_config->writeEntry("all", m_all->isChecked() );
+ m_config->writeEntry("audio", m_audio->isChecked() );
+ m_config->writeEntry("video", m_video->isChecked() );
+ m_config->writeEntry("text", m_text->isChecked() );
+ m_config->writeEntry("image", m_image->isChecked() );
+}
+MediumGlobalWidget::~MediumGlobalWidget()
+{
+ writeConfig();
+ delete m_config;
+}
+void MediumGlobalWidget::slotGlobalChanged()
+{
+ int mode = GLOBAL_DISABLED;
+ bool enabled = false;
+ if( ( enabled =m_useglobal->isChecked() ) ){
+ mode = GLOBAL_ENABLED;
+ }else
+ mode = GLOBAL_DISABLED;
+ qWarning("enabled = %d", enabled );
+ m_all->setEnabled ( enabled );
+ m_audio->setEnabled( enabled );
+ m_image->setEnabled( enabled );
+ m_text->setEnabled ( enabled );
+ m_video->setEnabled ( enabled );
+ slotAllChanged();
+
+ emit globalStateChanged( mode );
+}
+void MediumGlobalWidget::slotEnableChecking()
+{
+ int mode = ENABLE_CHECKS;
+ bool enabled = false;
+ if( ( enabled = m_check->isChecked() ) ){
+ mode = ENABLE_CHECKS;
+ }else{
+ mode = DISABLE_CHECKS;
+ }
+ m_frame->setEnabled( enabled );
+ slotGlobalChanged();
+ emit enableStateChanged( mode );
+}
+void MediumGlobalWidget::slotAllChanged()
+{
+ bool enable = !m_all->isChecked();
+ m_audio->setEnabled( enable );
+ m_text->setEnabled( enable );
+ m_video->setEnabled( enable );
+ m_image->setEnabled( enable );
+}
diff --git a/noncore/settings/mediummount/mediumglobal.h b/noncore/settings/mediummount/mediumglobal.h
new file mode 100644
index 0000000..7b3cea0
--- a/dev/null
+++ b/noncore/settings/mediummount/mediumglobal.h
@@ -0,0 +1,59 @@
+
+
+#ifndef MediumGlobalWidget_H
+#define MediumGlobalWidget_H
+
+#include <qwidget.h>
+
+class Config;
+class QCheckBox;
+class QGroupBox;
+class QFrame;
+class QLineEdit;
+class QVBoxLayout;
+class QGridLayout;
+class QLabel;
+
+namespace MediumMountSetting {
+ enum States { GLOBAL_ENABLED = 0, GLOBAL_DISABLED };
+ enum Checks { ENABLE_CHECKS = 0, DISABLE_CHECKS };
+
+ class MediumGlobalWidget : public QWidget {
+ Q_OBJECT
+ public:
+ MediumGlobalWidget(QWidget *parent = 0, const char *name =0 );
+ ~MediumGlobalWidget();
+ signals:
+ // the global status changed
+ void globalStateChanged( int );
+ void enableStateChanged( int );
+ private slots:
+ void slotGlobalChanged();
+ void slotEnableChecking();
+ void slotAllChanged();
+
+ private:
+ void initGUI();
+ void readConfig();
+ void writeConfig();
+ Config *m_config;
+ QCheckBox *m_check;
+ QCheckBox *m_useglobal;
+
+ QGroupBox *m_global;
+
+ QCheckBox *m_all;
+ QCheckBox *m_audio;
+ QCheckBox *m_video;
+ QCheckBox *m_text;
+ QCheckBox *m_image;
+
+ QFrame *m_frame;
+ QGridLayout *m_frameLay;
+ QVBoxLayout *m_layout;
+ QVBoxLayout *m_box;
+ QLabel *m_label;
+ };
+};
+
+#endif
diff --git a/noncore/settings/mediummount/mediummount.pro b/noncore/settings/mediummount/mediummount.pro
new file mode 100644
index 0000000..2602a00
--- a/dev/null
+++ b/noncore/settings/mediummount/mediummount.pro
@@ -0,0 +1,8 @@
+TEMPLATE = app
+#CONFIG = qt warn_on debug
+CONFIG = qt warn_on release
+HEADERS = mediumwidget.h mediumglobal.h mainwindow.h
+SOURCES = main.cpp mediumwidget.cc mediumglobal.cc mainwindow.cc
+INCLUDEPATH += $(OPIEDIR)/include
+DEPENDPATH += $(OPIEDIR)/include
+LIBS += -lqpe
diff --git a/noncore/settings/mediummount/mediumwidget.cc b/noncore/settings/mediummount/mediumwidget.cc
new file mode 100644
index 0000000..9ce024e
--- a/dev/null
+++ b/noncore/settings/mediummount/mediumwidget.cc
@@ -0,0 +1,190 @@
+
+
+#include <qcheckbox.h>
+#include <qgroupbox.h>
+#include <qhbox.h>
+#include <qlabel.h>
+#include <qabstractlayout.h>
+#include <qlayout.h>
+#include <qlineedit.h>
+#include <qpixmap.h>
+#include <qpushbutton.h>
+#include <qvbox.h>
+
+
+#include <qpe/config.h>
+#include <qpe/qpeapplication.h>
+
+#include "mediumwidget.h"
+
+
+
+using namespace MediumMountSetting;
+
+MediumMountWidget::MediumMountWidget(const QString &path,
+ const QPixmap &pix,
+ QWidget *parent,
+ const char *name )
+ : QWidget( parent, name )
+{
+ if(parent == 0){
+ resize(QApplication::desktop()->width(), QApplication::desktop()->height() );
+ }else{
+ resize(parent->width(), parent->height() );
+ }
+ m_path = path;
+ initGUI();
+ m_label->setPixmap(pix );
+ m_config = 0;
+
+ readConfig();
+}
+// now we fire up the GUI
+// if I would know what I'm doing ;)
+void MediumMountWidget::initGUI()
+{
+ //main layout
+ m_box = new QVBoxLayout( this , 5, 5 );
+ m_box->setSpacing( 5 );
+ //m_box->addStretch( -1 );
+
+ // picture + text
+ m_infoBox = new QHBox(this, "infobox" );
+ m_infoBox->setSpacing( 4 );
+ m_label = new QLabel(m_infoBox );
+ m_desc = new QLabel(m_infoBox );
+ m_desc->setTextFormat( Qt::RichText );
+ m_desc->setText("Configure this medium. The changes will"
+ "go into effect when the application get's"
+ "closed. To update the Document Tab you need"
+ "to removeand insert this medium." );
+ m_box->addWidget( m_infoBox ); // add the widget to the layout
+
+
+ // groupbox
+ m_group = new QGroupBox(tr("Which media files"), this, "MediaFiles" );
+ m_checks = new QGridLayout( m_group, 4, 3 );
+ m_checks->setMargin( 12 );
+
+
+
+ QSpacerItem *item2 = new QSpacerItem(5, 8,
+ QSizePolicy::Fixed,
+ QSizePolicy::Fixed);
+ m_box->addItem( item2 );
+
+ m_audio = new QCheckBox( tr("Audio"), m_group );
+ m_all = new QCheckBox( tr("All") , m_group );
+ m_image = new QCheckBox( tr("Image"), m_group );
+ m_text = new QCheckBox( tr("Text") , m_group );
+ m_video = new QCheckBox( tr("Video"), m_group );
+
+ QSpacerItem *iti1b = new QSpacerItem(2, 10, QSizePolicy::Fixed,
+ QSizePolicy::Fixed );
+ m_checks->addItem( iti1b, 0, 0 );
+
+ m_checks->addWidget(m_audio, 1, 0 );
+ m_checks->addWidget(m_image, 2, 0 );
+ m_checks->addWidget(m_all , 3, 0 );
+
+ m_checks->addWidget(m_text, 1, 2 );
+ m_checks->addWidget(m_video, 2, 2 );
+
+ m_checks->addRowSpacing(0, 8 );
+ m_checks->addColSpacing(1, 2 );
+ m_checks->setColStretch(1, -2 );
+
+ connect(m_all, SIGNAL(stateChanged(int) ),
+ this, SLOT(slotStateChanged() ) );
+
+ m_box->addWidget( m_group );
+
+ // label
+ m_lblPath = new QLabel(tr("Limit search to:"), this );
+ m_box->addWidget( m_lblPath );
+
+ // add to
+ m_hboxAdd = new QHBox( this );
+ m_hboxAdd->setSpacing( 10 );
+ m_edit = new QLineEdit(m_hboxAdd );
+ m_add = new QPushButton(m_hboxAdd );
+ m_add->setText( tr("Add") );
+
+ m_box->addWidget(m_hboxAdd );
+
+ m_always = new QCheckBox( tr("Always check this medium"), this );
+
+ m_box->addWidget( m_always );
+
+ QSpacerItem *item = new QSpacerItem(5, 50,
+ QSizePolicy::Fixed,
+ QSizePolicy::Expanding );
+ m_box->addItem(item );
+}
+
+void MediumMountWidget::readConfig( )
+{
+ if( m_config == 0 )
+ m_config = new Config(m_path + "/.opiestorage.cf", Config::File );
+ m_config->setGroup( "main" );
+
+ m_always->setChecked( m_config->readBoolEntry("check", false) );
+
+ m_config->setGroup( "mimetypes" );
+ if( m_config->readBoolEntry("all", false ) ){
+ m_audio->setEnabled( false );
+ m_image->setEnabled( false );
+ m_text->setEnabled ( false );
+ m_video->setEnabled( false );
+ m_all->setChecked( true );
+ }else{
+ m_audio->setEnabled( true );
+ m_image->setEnabled( true );
+ m_text->setEnabled ( true );
+ m_all->setEnabled ( true );
+
+ m_all->setChecked( false );
+
+ m_audio->setChecked( m_config->readBoolEntry("audio", true ) );
+ m_image->setChecked( m_config->readBoolEntry("image", true ) );
+ m_text->setChecked ( m_config->readBoolEntry("text" , true ) );
+ m_video->setChecked( m_config->readBoolEntry("video", true ) );
+ };
+}
+
+void MediumMountWidget::writeConfig()
+{
+ m_config->setGroup("main");
+ m_config->writeEntry("check", m_always->isChecked() );
+
+ m_config->setGroup("mimetypes" );
+ if(m_all->isChecked() ){
+ m_config->writeEntry("all", true );
+ }else{
+ m_config->writeEntry("audio", m_audio->isChecked() );
+ m_config->writeEntry("image", m_image->isChecked() );
+ m_config->writeEntry("text" , m_text->isChecked() );
+ m_config->writeEntry("video", m_video->isChecked() );
+ }
+}
+MediumMountWidget::~MediumMountWidget()
+{
+ writeConfig();
+ delete m_config;
+}
+
+
+void MediumMountWidget::slotAdd()
+{
+
+}
+void MediumMountWidget::slotStateChanged()
+{
+ bool state = !(m_all->isChecked());
+
+ m_audio->setEnabled( state );
+ m_text->setEnabled ( state );
+ m_video->setEnabled( state );
+ m_image->setEnabled( state );
+
+}
diff --git a/noncore/settings/mediummount/mediumwidget.h b/noncore/settings/mediummount/mediumwidget.h
new file mode 100644
index 0000000..7a801eb
--- a/dev/null
+++ b/noncore/settings/mediummount/mediumwidget.h
@@ -0,0 +1,77 @@
+
+#ifndef MediumMountWidget_H
+#define MediumMountWidget_H
+
+//#include <qpixmap.h>
+#include <qwidget.h>
+
+
+class QLabel;
+class QPixmap;
+class Config;
+class QGridLayout;
+class QCheckBox;
+class QPushButton;
+class QVBoxLayout;
+class QHBoxLayout;
+class QGroupBox;
+class QVBox;
+class QHBox;
+class QLineEdit;
+
+namespace MediumMountSetting {
+
+ class MediumMountWidget : public QWidget {
+ Q_OBJECT
+ public:
+ MediumMountWidget(const QString&, const QPixmap &, QWidget *parent, const char *name = 0 );
+ ~MediumMountWidget();
+
+ private slots:
+ void slotAdd();
+ void slotStateChanged();
+
+ private:
+ void readConfig();
+ void initGUI();
+ void writeConfig();
+
+ bool m_dirty : 1;
+
+ class MediumMountWidgetPrivate;
+ MediumMountWidgetPrivate *d;
+
+ QString m_path;
+
+ Config *m_config;
+
+ QHBox *m_infoBox;
+ QLabel *m_label;
+ QLabel *m_desc;
+
+ QLineEdit *m_edit;
+ QPushButton *m_add;
+
+ QVBoxLayout *m_box;
+ QGridLayout *m_checks;
+
+ QGroupBox *m_group;
+ QCheckBox *m_all;
+ QCheckBox *m_audio;
+ QCheckBox *m_image;
+ QCheckBox *m_text;
+ QCheckBox *m_video;
+
+ QCheckBox *m_always;
+ //QCheckBox *m_yesNo;
+
+ QHBox *m_hboxAdd;
+
+ QLabel *m_lblPath;
+ ////////////////
+
+
+
+ };
+};
+#endif