ClockMain::ClockMain(QWidget *parent, Qt::WFlags f) : QWidget(parent, f) , clockIndex(-1) , stopwatchIndex(-1) , alarmIndex(-1) { QVBoxLayout* layout = new QVBoxLayout(this); tabWidget = new QTabWidget(this); layout->addWidget(tabWidget); layout->setContentsMargins(0, 0, 0, 0); clock = new Clock(tabWidget); clock->setFocusPolicy(Qt::TabFocus); //allows left/right to switch to other tabs stopWatch = new StopWatch(tabWidget); alarm = new Alarm(tabWidget); // Add each widget to the tabbed widget, and save the index for each so that // we can refer to it later. clockIndex = tabWidget->addTab(clock, tr("Clock")); alarmIndex = tabWidget->addTab(alarm, tr("Alarm")); stopwatchIndex = tabWidget->addTab(stopWatch, tr("Stopwatch")); contextMenu = QSoftMenuBar::menuFor(this); QAction *action = contextMenu->addAction(tr("Set Time...")); connect(action, SIGNAL(triggered()), this, SLOT(setTime())); connect( qApp, SIGNAL(appMessage(QString,QByteArray)), this, SLOT(appMessage(QString,QByteArray)) ); new ClockService(this); new AlarmService(this); setWindowTitle(tr("Clock")); }
/*! \internal */ UsbGadgetTask::UsbGadgetTask(QObject *parent) : QObject(parent), m_dialog(0), m_tries(UNMOUNT_TRIES), m_action(0) { loadProviders(); m_manager = new QUsbManager(this); connect(m_manager, SIGNAL(cableConnectedChanged(bool)), this, SLOT(cableConnectedChanged(bool))); connect(QtopiaServerApplication::instance(), SIGNAL(appMessage(QString,QByteArray)), this, SLOT(appMessage(QString,QByteArray))); }
QDSync::QDSync( QWidget *parent, Qt::WFlags /*f*/ ) : QTextBrowser( parent ), bridge( 0 ) , selectDown( false ), connected( false ), syncing( false ) , m_ethernetGadget( 0 ), m_serialGadget( 0 ) , selectLabelState( Blank ) { TRACE(QDSync) << "QDSync::QDSync"; setHtml("Synchronization communicates with Qtopia Sync Agent." "<hr>"); qdsync_tb = this; connect( qApp, SIGNAL(appMessage(QString,QByteArray)), this, SLOT(appMessage(QString,QByteArray)) ); QMenu *menu = new QMenu( this ); menu->addAction( "Restart Synchronization", qApp, SLOT(quit()) ); QSoftMenuBar::addMenuTo( this, menu ); QSettings settings("Trolltech", "qdsync"); int version = settings.value("/version", 0).toInt(); if ( version == 0 ) { // version 0: pre-beta // remove everything so the new defaults can take effect version++; settings.remove("/port/tcp"); settings.remove("/port/serial"); settings.remove("/port/greenphone_serial"); settings.remove("/ports"); } settings.setValue("/version", version); ports = settings.value("/ports", QDSYNC_DEFAULT_PORTS ).toStringList(); // Initialize tasks Qtopia4Sync *sync = Qtopia4Sync::instance(); QPluginManager *manager = new QPluginManager( "qdsync", this ); foreach ( const QString &name, manager->list() ) { if ( name == "base" ) continue; QObject *object = manager->instance( name ); if ( Qtopia4SyncPlugin *plugin = qobject_cast<Qtopia4SyncPlugin*>(object) ) { sync->registerPlugin( plugin ); } else if ( Qtopia4SyncPluginFactory *pf = qobject_cast<Qtopia4SyncPluginFactory*>(object) ) { foreach ( const QString &name, pf->keys() ) { Qtopia4SyncPlugin *plugin = pf->plugin( name ); sync->registerPlugin( plugin ); } } }
/*! Constructs a new print server with given \a parent. */ PrintServer::PrintServer(QObject *parent) :QObject(parent) { QtopiaApplication::instance()->registerRunningTask( "PrintServer", this ); d = new PrintServerPrivate(); // listen to the application channel messages connect( qApp, SIGNAL(appMessage(QString,QByteArray)), this, SLOT(receive(QString,QByteArray)) ); // load printer plugins d->m_pluginManager = new QPluginManager( "qtopiaprinting" ); // Print service new PrintService( this ); }
AppearanceSettings::AppearanceSettings(QWidget* parent, Qt::WFlags fl) : QDialog(parent, fl), m_isStatusView(false) { initUi(); loadThemes(); loadColorSchemes(); loadSavedTheme(); connect(qApp, SIGNAL(appMessage(QString,QByteArray)), this, SLOT(receiveAppMessage(QString,QByteArray))); QMenu *menu = QSoftMenuBar::menuFor(this); menu->addAction(QIcon(":icon/Note"), tr("Add to current profile"), this, SLOT(pushSettingStatus())); menu->addAction(QIcon(":image/homescreen/homescreen"), tr("Homescreen Settings..."), this, SLOT(openHomescreenSettings())); setWindowTitle(tr("Appearance")); }
// AppearanceSettings ---------------------------------------------------- AppearanceSettings::AppearanceSettings( QWidget* parent, Qt::WFlags fl ) : QDialog(parent, fl), mIsStatusView(false), mIsFromActiveProfile(false) { setupUi(); readThemeSettings(); readColorSchemeSettings(); // Populate the first combo box (theme). populate(); // Select the theme to populate the other combo boxes. // Note that they are not connected yet, so no preview is requested. themeSelected(mActiveThemeIndex); // Connect the combo boxes. connect( mThemeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(themeSelected(int)) ); connect( mColorCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(colorSelected(int)) ); connect( mBgCombo, SIGNAL(currentIndexChanged(QString)), this, SLOT(backgroundSelected(QString)) ); connect( mLabelCkBox, SIGNAL(toggled(bool)), this, SLOT(labelToggled(bool)) ); connect( qApp, SIGNAL(appMessage(QString,QByteArray)), this, SLOT(receive(QString,QByteArray)) ); // Re-select the theme to request the previews. themeSelected(mActiveThemeIndex); QSoftMenuBar::menuFor( this )->addAction ( QIcon( ":icon/Note" ), tr( "Add to current profile" ), this, SLOT(pushSettingStatus()) ); QSoftMenuBar::menuFor( this )->addAction ( QIcon( ":image/homescreen/homescreen" ), tr( "Homescreen Settings..." ), this, SLOT(openHomescreenSettings()) ); }
LightSettings::LightSettings( QWidget* parent, Qt::WFlags fl ) : QDialog( parent, fl), isStatusView( false ) { setWindowTitle(tr("Power Management")); QVBoxLayout * baseLayout = new QVBoxLayout( this ); baseLayout->setMargin( 0 ); QWidget * container = new QWidget(); QScrollArea *sView = new QScrollArea; sView->setFocusPolicy(Qt::NoFocus); sView->setFrameStyle(QFrame::NoFrame); sView->setWidget( container ); sView->setWidgetResizable( true ); sView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); QVBoxLayout *lightLayout = new QVBoxLayout(container); lightLayout->setMargin( 0 ); b = new LightSettingsContainer(); QtopiaApplication::setInputMethodHint( b->interval_dim, QtopiaApplication::AlwaysOff ); QtopiaApplication::setInputMethodHint( b->interval_lightoff, QtopiaApplication::AlwaysOff ); QtopiaApplication::setInputMethodHint( b->interval_suspend, QtopiaApplication::AlwaysOff ); lightLayout->addWidget(b); baseLayout->addWidget(sView); // add context menu to push its status to Profiles contextMenu = QSoftMenuBar::menuFor( this ); QAction* actionCapture = new QAction( QIcon( ":icon/Note" ), tr( "Add to current profile" ), this ); contextMenu->addAction( actionCapture ); connect( actionCapture, SIGNAL(triggered()), this, SLOT(pushSettingStatus()) ); connect( qApp, SIGNAL(appMessage(QString,QByteArray)), this, SLOT(receive(QString,QByteArray)) ); connect( b->interval_dim, SIGNAL(valueChanged(int)), this, SLOT(updateLightOffMinValue(int)) ); connect( b->interval_dim, SIGNAL(valueChanged(int)), this, SLOT(updateSuspendMinValue(int)) ); connect( b->interval_lightoff, SIGNAL(valueChanged(int)), this, SLOT(updateSuspendMinValue(int)) ); b->officon->setPixmap(QPixmap(":image/off").scaled(24, 24, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); b->brighticon->setPixmap(QPixmap(":image/Light").scaled(24, 24, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); QSettings hwConfig("Trolltech", "Hardware"); hwConfig.beginGroup("PowerManagement"); lockMode.canSuspend = hwConfig.value("CanSuspendLock", false).toBool(); batteryMode.canSuspend = hwConfig.value("CanSuspend", false).toBool(); externalMode.canSuspend = hwConfig.value("CanSuspendAC", false).toBool(); hwConfig.endGroup(); b->notnetworkedsuspend->hide(); if (batteryMode.canSuspend || externalMode.canSuspend || lockMode.canSuspend) { b->interval_suspend->setEnabled(true); } else { b->interval_suspend->hide(); b->label_suspend->hide(); } QSettings config("Trolltech","qpe"); config.beginGroup("LockPower"); lockMode.intervalDim = config.value( "Interval_Dim", 20 ).toInt(); lockMode.intervalLightOff = config.value("Interval_LightOff", 30).toInt(); lockMode.intervalSuspend = config.value("Interval", 60).toInt(); lockMode.brightness = config.value("Brightness", 255).toInt(); lockMode.brightness = qMax(1,lockMode.brightness * qpe_sysBrightnessSteps() / 255); lockMode.initBrightness = lockMode.brightness; lockMode.dim = config.value("Dim", true).toBool(); lockMode.lightoff = config.value("LightOff", false).toBool(); lockMode.suspend = config.value("Suspend", true).toBool(); lockMode.networkedsuspend = config.value("NetworkedSuspend", true).toBool(); config.endGroup(); config.beginGroup("BatteryPower"); batteryMode.intervalDim = config.value( "Interval_Dim", 20 ).toInt(); batteryMode.intervalLightOff = config.value("Interval_LightOff", 30).toInt(); batteryMode.intervalSuspend = config.value("Interval", 60).toInt(); batteryMode.brightness = config.value("Brightness", 255).toInt(); batteryMode.brightness = qMax(1,batteryMode.brightness * qpe_sysBrightnessSteps() / 255); batteryMode.initBrightness = batteryMode.brightness; batteryMode.dim = config.value("Dim", true).toBool(); batteryMode.lightoff = config.value("LightOff", false).toBool(); batteryMode.suspend = config.value("Suspend", true).toBool(); batteryMode.networkedsuspend = config.value("NetworkedSuspend", true).toBool(); config.endGroup(); config.beginGroup("ExternalPower"); externalMode.intervalDim = config.value( "Interval_Dim", 20 ).toInt(); externalMode.intervalLightOff = config.value("Interval_LightOff", 30).toInt(); externalMode.intervalSuspend = config.value("Interval", 240).toInt(); externalMode.brightness = config.value("Brightness", 255).toInt(); externalMode.brightness = qMax(1,externalMode.brightness * qpe_sysBrightnessSteps() / 255); externalMode.initBrightness = externalMode.brightness; externalMode.dim = config.value("Dim", true).toBool(); externalMode.lightoff = config.value("LightOff", false).toBool(); //default to leave on externalMode.suspend = config.value("Suspend", true).toBool(); externalMode.networkedsuspend = config.value("NetworkedSuspend",false).toBool(); config.endGroup(); //must set min > 0 the screen will become completely black int maxbright = qpe_sysBrightnessSteps(); b->brightness->setMaximum( maxbright ); b->brightness->setMinimum( 1 ); b->brightness->setTickInterval( qMax(1,maxbright/16) ); b->brightness->setSingleStep( qMax(1,maxbright/16) ); b->brightness->setPageStep( qMax(1,maxbright/16) ); currentMode = &batteryMode; applyMode(); connect(b->powerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(powerTypeChanged(int))); if ( powerStatus.wallStatus() == QPowerStatus::Available ) { b->powerSource->setCurrentIndex(1); } connect(b->brightness, SIGNAL(valueChanged(int)), this, SLOT(applyBrightness())); QtopiaChannel *channel = new QtopiaChannel("Qtopia/PowerStatus", this); connect(channel, SIGNAL(received(QString,QByteArray)), this, SLOT(sysMessage(QString,QByteArray))); }
HomescreenSettings::HomescreenSettings(QWidget* parent, Qt::WFlags fl) : QDialog( parent, fl) { setWindowTitle(tr("Homescreen")); connect( qApp, SIGNAL(appMessage(QString,QByteArray)), this, SLOT(appMessage(QString,QByteArray)) ); QVBoxLayout *layout = new QVBoxLayout(this); layout->setContentsMargins(0, 0, 0, 0); QTabWidget *tabWidget = new QTabWidget(this); //appearance tab QWidget *appearance = new QWidget; QScrollArea *appearanceWrapper = new QScrollArea; appearanceWrapper->setFocusPolicy(Qt::NoFocus); appearanceWrapper->setFrameStyle(QFrame::NoFrame); appearanceWrapper->setWidget(appearance); appearanceWrapper->setWidgetResizable(true); appearanceWrapper->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); QFormLayout *appearanceLayout = new QFormLayout(appearance); QSettings config("Trolltech", "qpe"); config.beginGroup( "HomeScreen" ); QString hsImgName = config.value("HomeScreenPicture").toString(); int hsDisplayMode = config.value("HomeScreenPictureMode", 0).toInt(); image = new QPushButton(); image->setIconSize(QSize(50,75)); image->setMinimumHeight(80); imageMode = new QComboBox; imageMode->addItem(tr("Scale & Crop")); imageMode->addItem(tr("Stretch")); imageMode->addItem(tr("Tile")); imageMode->addItem(tr("Center")); imageMode->addItem(tr("Scale")); imageMode->setCurrentIndex(hsDisplayMode); hsImage = QContent(hsImgName); if (!hsImage.isValid()) { image->setText(tr("No image")); imageMode->setVisible(false); } else { image->setIcon(QIcon(hsImage.fileName())); } connect( image, SIGNAL(clicked()), this, SLOT(editPhoto()) ); QVBoxLayout *imageLayout = new QVBoxLayout; imageLayout->setContentsMargins(0, 0, 0, 0); imageLayout->setSpacing(0); imageLayout->addWidget(image); imageLayout->addWidget(imageMode); appearanceLayout->addRow(tr("Image"), imageLayout); time = new QCheckBox(tr("Time")); date = new QCheckBox(tr("Date")); op = new QCheckBox(tr("Operator")); profile = new QCheckBox(tr("Profile")); location = new QCheckBox(tr("Location")); time->setCheckState(config.value("ShowTime", "true").toBool() ? Qt::Checked : Qt::Unchecked); date->setCheckState(config.value("ShowDate", "true").toBool() ? Qt::Checked : Qt::Unchecked); op->setCheckState(config.value("ShowOperator", "true").toBool() ? Qt::Checked : Qt::Unchecked); profile->setCheckState(config.value("ShowProfile", "true").toBool() ? Qt::Checked : Qt::Unchecked); location->setCheckState(config.value("ShowLocation", "true").toBool() ? Qt::Checked : Qt::Unchecked); QVBoxLayout *checkLayout = new QVBoxLayout; checkLayout->setContentsMargins(0, 0, 0, 0); checkLayout->setSpacing(0); checkLayout->addWidget(time); checkLayout->addWidget(date); checkLayout->addWidget(op); checkLayout->addWidget(profile); checkLayout->addWidget(location); appearanceLayout->addRow(tr("Display"), checkLayout); //idle tab QWidget *idle = new QWidget; QVBoxLayout *idleLayout = new QVBoxLayout(idle); QLabel *label = new QLabel(tr("Return to homescreen:")); QHBoxLayout *h1 = new QHBoxLayout; QHBoxLayout *h2 = new QHBoxLayout; QHBoxLayout *h3 = new QHBoxLayout; homeScreen = new QComboBox; homeScreen->addItem(tr("On display off")); homeScreen->addItem(tr("On suspend")); homeScreen->addItem(tr("Never")); label->setBuddy(homeScreen); connect(homeScreen, SIGNAL(activated(int)), this, SLOT(homeScreenActivated(int))); QString showHomeScreen = config.value("ShowHomeScreen", "Never").toString(); if (showHomeScreen == "DisplayOff") homeScreen->setCurrentIndex(0); else if (showHomeScreen == "Suspend") homeScreen->setCurrentIndex(1); else homeScreen->setCurrentIndex(2); lock = new QCheckBox(tr("Lock keys")); lock->setCheckState(config.value("AutoKeyLock", false).toBool() ? Qt::Checked : Qt::Unchecked); lock->setEnabled(homeScreen->currentIndex() == homeScreen->count()-1 ? false : true); powerNote = new QLabel; powerNote->setWordWrap( true ); QFont font = QApplication::font(); font.setItalic( true ); powerNote->setFont( font ); homeScreenActivated( homeScreen->currentIndex() ); screenSaver_vsi = new QValueSpaceItem( "/Hardware/ScreenSaver/State", this ); connect( screenSaver_vsi, SIGNAL(contentsChanged()), this, SLOT(homeScreenActivated()) ); h1->addSpacing(20); h1->addWidget(homeScreen); h2->addSpacing(20); h2->addWidget(lock); h3->addSpacing(20); h3->addWidget(powerNote); idleLayout->addWidget(label); idleLayout->addLayout(h1); idleLayout->addLayout(h2); idleLayout->addLayout(h3); idleLayout->addStretch(1); //secondary screen tab //TODO: reduce amount of duplicated code between tabs if (QApplication::desktop()->numScreens() > 1) { QWidget *secondary = new QWidget; QScrollArea *secondaryWrapper = new QScrollArea; secondaryWrapper->setFocusPolicy(Qt::NoFocus); secondaryWrapper->setFrameStyle(QFrame::NoFrame); secondaryWrapper->setWidget(secondary); secondaryWrapper->setWidgetResizable(true); secondaryWrapper->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); QFormLayout *secondaryLayout = new QFormLayout(secondary); hsImgName = config.value("SecondaryHomeScreenPicture").toString(); hsDisplayMode = config.value("SecondaryHomeScreenPictureMode", 0).toInt(); secondaryImage = new QPushButton(); secondaryImage->setIconSize(QSize(50,75)); secondaryImage->setMinimumHeight(80); secondaryImageMode = new QComboBox; secondaryImageMode->addItem(tr("Scale & Crop")); secondaryImageMode->addItem(tr("Stretch")); secondaryImageMode->addItem(tr("Tile")); secondaryImageMode->addItem(tr("Center")); secondaryImageMode->addItem(tr("Scale")); secondaryImageMode->setCurrentIndex(hsDisplayMode); secondaryHsImage = QContent(hsImgName); if (!secondaryHsImage.isValid()) { secondaryImage->setText(tr("No image")); secondaryImageMode->setVisible(false); } else { secondaryImage->setIcon(QIcon(secondaryHsImage.fileName())); } connect( secondaryImage, SIGNAL(clicked()), this, SLOT(editSecondaryPhoto()) ); QVBoxLayout *secondaryImageLayout = new QVBoxLayout; secondaryImageLayout->setContentsMargins(0, 0, 0, 0); secondaryImageLayout->setSpacing(0); secondaryImageLayout->addWidget(secondaryImage); secondaryImageLayout->addWidget(secondaryImageMode); secondaryLayout->addRow(tr("Image"), secondaryImageLayout); tabWidget->addTab(secondaryWrapper, tr("Secondary","Secondary Display")); } tabWidget->insertTab(0, appearanceWrapper, tr("Appearance")); tabWidget->insertTab(1, idle, tr("Idle")); tabWidget->setCurrentIndex(0); layout->addWidget(tabWidget); QDrmContentPlugin::initialize(); }