📄 launcher.cpp
字号:
if ( e->timerId() == tid_today ) { QDate today = QDate::currentDate(); if ( today != last_today_show ) { last_today_show = today; Config cfg("today"); cfg.setGroup("Start");#ifndef QPE_DEFAULT_TODAY_MODE#define QPE_DEFAULT_TODAY_MODE "Never"#endif if ( cfg.readEntry("Mode",QPE_DEFAULT_TODAY_MODE) == "Daily" ) { QCopEnvelope env(Service::channel("today"),"raise()"); } } }}void Launcher::createGUI(){ setCaption( tr("Launcher") ); // we have a pretty good idea how big we'll be setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); tb = new TaskBar; tabs = new LauncherTabWidget( this ); setCentralWidget( tabs ); ServerInterface::dockWidget( tb, ServerInterface::Bottom ); qApp->installEventFilter( this ); connect( qApp, SIGNAL(authenticate(bool)), this, SLOT(askForPin(bool)) ); connect( tb, SIGNAL(tabSelected(const QString&)), this, SLOT(showTab(const QString&)) ); 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(const AppLnk*)), this, SLOT(properties(const 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 // all documents QImage img( Resource::loadImage( "DocsIcon" ) ); QPixmap pm; pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); // It could add this itself if it handles docs tabs->newView("Documents", pm, tr("Documents") )->setToolsEnabled( TRUE ); QTimer::singleShot( 0, tabs, SLOT( initLayout() ) ); qApp->setMainWidget( this );}void Launcher::showGUI(){ tb->show(); QTimer::singleShot( 0, this, SLOT( makeVisible() ) );}Launcher::~Launcher(){ if ( tb ) destroyGUI();}void Launcher::makeVisible(){ showMaximized();}void Launcher::destroyGUI(){ delete tb; tb = 0; delete tabs; tabs =0;}bool Launcher::eventFilter( QObject*, QEvent *ev ){#ifdef QT_QWS_SL5XXX if ( ev->type() == QEvent::KeyPress ) { QKeyEvent *ke = (QKeyEvent *)ev; if ( ke->key() == Qt::Key_F11 ) { // menu key QWidget *active = qApp->activeWindow(); if ( active && active->isPopup() ) active->close(); else { Global::terminateBuiltin("calibrate"); // No tr tb->launchStartMenu(); } return TRUE; } }#else Q_UNUSED(ev);#endif return FALSE;}void Launcher::toggleSymbolInput(){ tb->toggleSymbolInput();}void Launcher::toggleNumLockState(){ tb->toggleNumLockState();}void Launcher::toggleCapsLockState(){ tb->toggleCapsLockState();}void Launcher::askForPin(bool apo){ Password::authenticate(apo); ServerApplication::lockScreen(FALSE);}static bool isVisibleWindow(int wid){#ifdef Q_WS_QWS const QList<QWSWindow> &list = qwsServer->clientWindows(); QWSWindow* w; for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { if ( w->winId() == wid ) return !w->isFullyObscured(); }#endif return FALSE;}void Launcher::viewSelected(const QString& s){ setCaption( s + tr(" - Launcher") );}void Launcher::showTab(const QString& id){ tabs->categoryBar->showTab(id); raise();}void Launcher::select( const AppLnk *appLnk ){ if ( appLnk->type() == "Folder" ) { // No tr // Not supported: flat is simpler for the user } else { if ( appLnk->exec().isNull() ) { if ( ! delayedAppLnk ) { delayedAppLnk = new AppLnk(*appLnk); QTimer::singleShot( 0, this, SLOT(delayedSelect()) ); } } else { tabs->setBusy(TRUE); emit executing( appLnk ); appLnk->execute(); } }}void Launcher::delayedSelect(){ if ( !delayedAppLnk ) return; AppLnk *appLnk = delayedAppLnk; delayedAppLnk = 0; int i = QMessageBox::information(this,tr("No application"), tr("<qt>No application is defined for this document. " "Type is %1.</qt>").arg(appLnk->type()), tr("OK"), tr("View as text"), 0, 0, 1); if ( ! QFileInfo(appLnk->file()).exists() ) qDebug( "file no longer exists!" ); else if ( i == 1 ) Global::execute(Service::app("Open/text/*"),appLnk->file()); delete appLnk;}void Launcher::properties( const AppLnk *appLnk ){ if ( appLnk->type() == "Folder" ) { // No tr // Not supported: flat is simpler for the user } else { if ( ! delayedAppLnk ) { delayedAppLnk = new AppLnk(*appLnk); QTimer::singleShot( 0, this, SLOT(delayedProperties()) ); } }}void Launcher::delayedProperties(){ if ( !delayedAppLnk ) return; AppLnk *appLnk = delayedAppLnk; delayedAppLnk = 0; DocPropertiesDialog prop(appLnk,0, appLnk->isDocLnk() ? "document-properties" // No tr : "apps-properties"); // No tr prop.showMaximized(); prop.exec(); delete appLnk;}void Launcher::storageChanged( const QList<FileSystem> &/*fs*/ ){ // ### update combo boxes if we had a combo box for the storage type}void Launcher::systemMessage( const QCString &msg, const QByteArray &data){ QDataStream stream( data, IO_ReadOnly ); if ( msg == "busy()" ) { tb->startWait(); } else if ( msg == "notBusy(QString)" ) { QString app; stream >> app; tabs->setBusy(FALSE); tb->stopWait(app); } else if (msg == "applyStyle()") { tabs->categoryBar->layoutTabs(); }}// These are the update functions from the servervoid Launcher::typeAdded( const QString& type, const QString& name, const QPixmap& pixmap, const QPixmap& ){ tabs->newView( type, pixmap, name ); ids.append( type ); tb->refreshStartMenu(); static bool first = TRUE; if ( first ) { first = FALSE; tabs->categoryBar->showTab(type); } tabs->view( type )->setUpdatesEnabled( FALSE ); tabs->view( type )->setSortEnabled( FALSE );}void Launcher::typeRemoved( const QString& type ){ tabs->view( type )->removeAllItems(); tabs->deleteView( type ); ids.remove( type ); tb->refreshStartMenu();}void Launcher::applicationAdded( const QString& type, const AppLnk& app ){ if ( app.type() == "Separator" ) // No tr return; LauncherView *view = tabs->view( type ); if ( view ) view->addItem( new AppLnk( app ), FALSE ); else qWarning("addAppLnk: No view for type %s. Can't add app %s!", type.latin1(),app.name().latin1() ); MimeType::registerApp( app );}void Launcher::applicationRemoved( const QString& type, const AppLnk& app ){ LauncherView *view = tabs->view( type ); if ( view ) view->removeLink( app.linkFile() ); else qWarning("removeAppLnk: No view for %s!", type.latin1() );}void Launcher::allApplicationsRemoved(){ MimeType::clear(); for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) tabs->view( (*it) )->removeAllItems();}void Launcher::documentAdded( const DocLnk& doc ){ tabs->docView()->addItem( new DocLnk( doc ), FALSE );}void Launcher::showLoadingDocs(){ tabs->docView()->hide();}void Launcher::showDocTab(){ if ( tabs->categoryBar->currentView() == tabs->docView() ) tabs->docView()->show();}void Launcher::documentRemoved( const DocLnk& doc ){ QString file; if ( doc.linkFileKnown() ) file = doc.linkFile(); else if ( doc.fileKnown() ) file = doc.file(); else return; tabs->docView()->removeLink( file );}void Launcher::documentChanged( const DocLnk& oldDoc, const DocLnk& newDoc ){ documentRemoved( oldDoc ); documentAdded( newDoc );}void Launcher::allDocumentsRemoved(){ tabs->docView()->removeAllItems();}void Launcher::applicationStateChanged( const QString& name, ApplicationState state ){ tb->setApplicationState( name, state );}void Launcher::applicationScanningProgress( int percent ){ switch ( percent ) { case 0: { for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) { tabs->view( (*it) )->setUpdatesEnabled( FALSE ); tabs->view( (*it) )->setSortEnabled( FALSE ); } break; } case 100: { for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) { tabs->view( (*it) )->setSortEnabled( TRUE ); tabs->view( (*it) )->setUpdatesEnabled( TRUE ); } break; } default: break; }}void Launcher::documentScanningProgress( int percent ){ switch ( percent ) { case 0: { tabs->setLoadingProgress( 0 ); tabs->setLoadingWidgetEnabled( TRUE ); tabs->docView()->setUpdatesEnabled( FALSE ); tabs->docView()->setSortEnabled( FALSE ); break; } case 100: { tabs->docView()->updateTools(); tabs->docView()->setSortEnabled( TRUE ); tabs->docView()->setUpdatesEnabled( TRUE ); tabs->setLoadingWidgetEnabled( FALSE ); break; } default: tabs->setLoadingProgress( percent ); break; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -