author | sandman <sandman> | 2002-10-31 03:12:25 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-10-31 03:12:25 (UTC) |
commit | 702ab550d1f6b06e779935457e5e25748c8e6fc3 (patch) (unidiff) | |
tree | 852cc6e93f2f0e7c7293e1faab09ab19c17d9c0a | |
parent | d4c2baf3d4998001462ac1be04523b216da02500 (diff) | |
download | opie-702ab550d1f6b06e779935457e5e25748c8e6fc3.zip opie-702ab550d1f6b06e779935457e5e25748c8e6fc3.tar.gz opie-702ab550d1f6b06e779935457e5e25748c8e6fc3.tar.bz2 |
launcher side enhancements to support the "use global font" option from
launcher-settings
-rw-r--r-- | core/launcher/launcher.cpp | 5 | ||||
-rw-r--r-- | core/launcher/launcherview.cpp | 5 | ||||
-rw-r--r-- | core/launcher/launcherview.h | 1 |
3 files changed, 10 insertions, 1 deletions
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp index 5a9ee1b..767efb2 100644 --- a/core/launcher/launcher.cpp +++ b/core/launcher/launcher.cpp | |||
@@ -1046,205 +1046,208 @@ void Launcher::systemMessage( const QCString &msg, const QByteArray &data) | |||
1046 | //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(), | 1046 | //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(), |
1047 | //cfg.readEntry( app ).latin1() ); | 1047 | //cfg.readEntry( app ).latin1() ); |
1048 | } else if ( msg == "setSyncDate(QString,QString)" ) { | 1048 | } else if ( msg == "setSyncDate(QString,QString)" ) { |
1049 | QString app, date; | 1049 | QString app, date; |
1050 | stream >> app >> date; | 1050 | stream >> app >> date; |
1051 | Config cfg( "qpe" ); | 1051 | Config cfg( "qpe" ); |
1052 | cfg.setGroup("SyncDate"); | 1052 | cfg.setGroup("SyncDate"); |
1053 | cfg.writeEntry( app, date ); | 1053 | cfg.writeEntry( app, date ); |
1054 | //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1()); | 1054 | //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1()); |
1055 | } else if ( msg == "startSync(QString)" ) { | 1055 | } else if ( msg == "startSync(QString)" ) { |
1056 | QString what; | 1056 | QString what; |
1057 | stream >> what; | 1057 | stream >> what; |
1058 | delete syncDialog; syncDialog = 0; | 1058 | delete syncDialog; syncDialog = 0; |
1059 | syncDialog = new SyncDialog( this, "syncProgress", FALSE, | 1059 | syncDialog = new SyncDialog( this, "syncProgress", FALSE, |
1060 | WStyle_Tool | WStyle_Customize | | 1060 | WStyle_Tool | WStyle_Customize | |
1061 | Qt::WStyle_StaysOnTop ); | 1061 | Qt::WStyle_StaysOnTop ); |
1062 | syncDialog->showMaximized(); | 1062 | syncDialog->showMaximized(); |
1063 | syncDialog->whatLabel->setText( "<b>" + what + "</b>" ); | 1063 | syncDialog->whatLabel->setText( "<b>" + what + "</b>" ); |
1064 | connect( syncDialog->buttonCancel, SIGNAL( clicked() ), | 1064 | connect( syncDialog->buttonCancel, SIGNAL( clicked() ), |
1065 | SLOT( cancelSync() ) ); | 1065 | SLOT( cancelSync() ) ); |
1066 | } else if ( msg == "stopSync()") { | 1066 | } else if ( msg == "stopSync()") { |
1067 | delete syncDialog; syncDialog = 0; | 1067 | delete syncDialog; syncDialog = 0; |
1068 | } else if ( msg == "getAllDocLinks()" ) { | 1068 | } else if ( msg == "getAllDocLinks()" ) { |
1069 | loadDocs(); | 1069 | loadDocs(); |
1070 | 1070 | ||
1071 | QString contents; | 1071 | QString contents; |
1072 | 1072 | ||
1073 | //Categories cats; | 1073 | //Categories cats; |
1074 | for ( QListIterator<DocLnk> it( docsFolder->children() ); it.current(); ++it ) { | 1074 | for ( QListIterator<DocLnk> it( docsFolder->children() ); it.current(); ++it ) { |
1075 | DocLnk *doc = it.current(); | 1075 | DocLnk *doc = it.current(); |
1076 | QFileInfo fi( doc->file() ); | 1076 | QFileInfo fi( doc->file() ); |
1077 | if ( !fi.exists() ) | 1077 | if ( !fi.exists() ) |
1078 | continue; | 1078 | continue; |
1079 | 1079 | ||
1080 | bool fake = !doc->linkFileKnown(); | 1080 | bool fake = !doc->linkFileKnown(); |
1081 | if ( !fake ) { | 1081 | if ( !fake ) { |
1082 | QFile f( doc->linkFile() ); | 1082 | QFile f( doc->linkFile() ); |
1083 | if ( f.open( IO_ReadOnly ) ) { | 1083 | if ( f.open( IO_ReadOnly ) ) { |
1084 | QTextStream ts( &f ); | 1084 | QTextStream ts( &f ); |
1085 | ts.setEncoding( QTextStream::UnicodeUTF8 ); | 1085 | ts.setEncoding( QTextStream::UnicodeUTF8 ); |
1086 | contents += ts.read(); | 1086 | contents += ts.read(); |
1087 | f.close(); | 1087 | f.close(); |
1088 | } else | 1088 | } else |
1089 | fake = TRUE; | 1089 | fake = TRUE; |
1090 | } | 1090 | } |
1091 | if (fake) { | 1091 | if (fake) { |
1092 | contents += "[Desktop Entry]\n"; | 1092 | contents += "[Desktop Entry]\n"; |
1093 | contents += "Categories = " + // No tr | 1093 | contents += "Categories = " + // No tr |
1094 | // cats.labels("Document View",doc->categories()).join(";") + "\n"; // No tr | 1094 | // cats.labels("Document View",doc->categories()).join(";") + "\n"; // No tr |
1095 | Qtopia::Record::idsToString( doc->categories() ) + "\n"; | 1095 | Qtopia::Record::idsToString( doc->categories() ) + "\n"; |
1096 | contents += "Name = "+doc->name()+"\n"; // No tr | 1096 | contents += "Name = "+doc->name()+"\n"; // No tr |
1097 | contents += "Type = "+doc->type()+"\n"; // No tr | 1097 | contents += "Type = "+doc->type()+"\n"; // No tr |
1098 | } | 1098 | } |
1099 | contents += "File = "+doc->file()+"\n"; // No tr // (resolves path) | 1099 | contents += "File = "+doc->file()+"\n"; // No tr // (resolves path) |
1100 | contents += QString("Size = %1\n").arg( fi.size() ); // No tr | 1100 | contents += QString("Size = %1\n").arg( fi.size() ); // No tr |
1101 | } | 1101 | } |
1102 | 1102 | ||
1103 | //qDebug( "sending length %d", contents.length() ); | 1103 | //qDebug( "sending length %d", contents.length() ); |
1104 | #ifndef QT_NO_COP | 1104 | #ifndef QT_NO_COP |
1105 | QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); | 1105 | QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); |
1106 | e << contents; | 1106 | e << contents; |
1107 | #endif | 1107 | #endif |
1108 | 1108 | ||
1109 | //qDebug( "================ \n\n%s\n\n===============", | 1109 | //qDebug( "================ \n\n%s\n\n===============", |
1110 | //contents.latin1() ); | 1110 | //contents.latin1() ); |
1111 | 1111 | ||
1112 | delete docsFolder; | 1112 | delete docsFolder; |
1113 | docsFolder = 0; | 1113 | docsFolder = 0; |
1114 | #ifdef QWS | 1114 | #ifdef QWS |
1115 | } else if ( msg == "setMouseProto(QString)" ) { | 1115 | } else if ( msg == "setMouseProto(QString)" ) { |
1116 | QString mice; | 1116 | QString mice; |
1117 | stream >> mice; | 1117 | stream >> mice; |
1118 | setenv("QWS_MOUSE_PROTO",mice.latin1(),1); | 1118 | setenv("QWS_MOUSE_PROTO",mice.latin1(),1); |
1119 | qwsServer->openMouse(); | 1119 | qwsServer->openMouse(); |
1120 | } else if ( msg == "setKeyboard(QString)" ) { | 1120 | } else if ( msg == "setKeyboard(QString)" ) { |
1121 | QString kb; | 1121 | QString kb; |
1122 | stream >> kb; | 1122 | stream >> kb; |
1123 | setenv("QWS_KEYBOARD",kb.latin1(),1); | 1123 | setenv("QWS_KEYBOARD",kb.latin1(),1); |
1124 | qwsServer->openKeyboard(); | 1124 | qwsServer->openKeyboard(); |
1125 | #endif | 1125 | #endif |
1126 | } | 1126 | } |
1127 | } | 1127 | } |
1128 | 1128 | ||
1129 | void Launcher::cancelSync() | 1129 | void Launcher::cancelSync() |
1130 | { | 1130 | { |
1131 | #ifndef QT_NO_COP | 1131 | #ifndef QT_NO_COP |
1132 | QCopEnvelope e( "QPE/Desktop", "cancelSync()" ); | 1132 | QCopEnvelope e( "QPE/Desktop", "cancelSync()" ); |
1133 | #endif | 1133 | #endif |
1134 | } | 1134 | } |
1135 | 1135 | ||
1136 | void Launcher::launcherMessage( const QCString &msg, const QByteArray &data) | 1136 | void Launcher::launcherMessage( const QCString &msg, const QByteArray &data) |
1137 | { | 1137 | { |
1138 | QDataStream stream( data, IO_ReadOnly ); | 1138 | QDataStream stream( data, IO_ReadOnly ); |
1139 | if ( msg == "setTabView(QString,int)" ) { | 1139 | if ( msg == "setTabView(QString,int)" ) { |
1140 | QString id; | 1140 | QString id; |
1141 | stream >> id; | 1141 | stream >> id; |
1142 | int mode; | 1142 | int mode; |
1143 | stream >> mode; | 1143 | stream >> mode; |
1144 | if ( tabs->view(id) ) | 1144 | if ( tabs->view(id) ) |
1145 | tabs->view(id)->setViewMode( (LauncherView::ViewMode)mode ); | 1145 | tabs->view(id)->setViewMode( (LauncherView::ViewMode)mode ); |
1146 | } else if ( msg == "setTabBackground(QString,int,QString)" ) { | 1146 | } else if ( msg == "setTabBackground(QString,int,QString)" ) { |
1147 | QString id; | 1147 | QString id; |
1148 | stream >> id; | 1148 | stream >> id; |
1149 | int mode; | 1149 | int mode; |
1150 | stream >> mode; | 1150 | stream >> mode; |
1151 | QString pixmapOrColor; | 1151 | QString pixmapOrColor; |
1152 | stream >> pixmapOrColor; | 1152 | stream >> pixmapOrColor; |
1153 | if ( tabs->view(id) ) | 1153 | if ( tabs->view(id) ) |
1154 | tabs->view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); | 1154 | tabs->view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); |
1155 | } else if ( msg == "setTextColor(QString,QString)" ) { | 1155 | } else if ( msg == "setTextColor(QString,QString)" ) { |
1156 | QString id; | 1156 | QString id; |
1157 | stream >> id; | 1157 | stream >> id; |
1158 | QString color; | 1158 | QString color; |
1159 | stream >> color; | 1159 | stream >> color; |
1160 | if ( tabs->view(id) ) | 1160 | if ( tabs->view(id) ) |
1161 | tabs->view(id)->setTextColor( QColor(color) ); | 1161 | tabs->view(id)->setTextColor( QColor(color) ); |
1162 | } else if ( msg == "setFont(QString,QString,int,int,int)" ) { | 1162 | } else if ( msg == "setFont(QString,QString,int,int,int)" ) { |
1163 | QString id; | 1163 | QString id; |
1164 | stream >> id; | 1164 | stream >> id; |
1165 | QString fam; | 1165 | QString fam; |
1166 | stream >> fam; | 1166 | stream >> fam; |
1167 | int size; | 1167 | int size; |
1168 | stream >> size; | 1168 | stream >> size; |
1169 | int weight; | 1169 | int weight; |
1170 | stream >> weight; | 1170 | stream >> weight; |
1171 | int italic; | 1171 | int italic; |
1172 | stream >> italic; | 1172 | stream >> italic; |
1173 | if ( tabs->view(id) ) | 1173 | if ( tabs->view(id) ) |
1174 | tabs->view(id)->setViewFont( QFont(fam, size, weight, italic!=0) ); | 1174 | if ( !fam. isEmpty ( )) |
1175 | tabs->view(id)->setViewFont( QFont(fam, size, weight, italic!=0) ); | ||
1176 | else | ||
1177 | tabs->view(id)->unsetViewFont(); | ||
1175 | qDebug( "setFont: %s, %d, %d, %d", fam.latin1(), size, weight, italic ); | 1178 | qDebug( "setFont: %s, %d, %d, %d", fam.latin1(), size, weight, italic ); |
1176 | } | 1179 | } |
1177 | else if ( msg == "setBusyIndicatorType(QString)" ) { | 1180 | else if ( msg == "setBusyIndicatorType(QString)" ) { |
1178 | QString type; | 1181 | QString type; |
1179 | stream >> type; | 1182 | stream >> type; |
1180 | tabs->setBusyIndicatorType(type); | 1183 | tabs->setBusyIndicatorType(type); |
1181 | } | 1184 | } |
1182 | } | 1185 | } |
1183 | 1186 | ||
1184 | void Launcher::storageChanged() | 1187 | void Launcher::storageChanged() |
1185 | { | 1188 | { |
1186 | if ( in_lnk_props ) { | 1189 | if ( in_lnk_props ) { |
1187 | got_lnk_change = TRUE; | 1190 | got_lnk_change = TRUE; |
1188 | lnk_change = QString::null; | 1191 | lnk_change = QString::null; |
1189 | } else { | 1192 | } else { |
1190 | updateLink( QString::null ); | 1193 | updateLink( QString::null ); |
1191 | } | 1194 | } |
1192 | } | 1195 | } |
1193 | 1196 | ||
1194 | 1197 | ||
1195 | bool Launcher::mkdir(const QString &localPath) | 1198 | bool Launcher::mkdir(const QString &localPath) |
1196 | { | 1199 | { |
1197 | QDir fullDir(localPath); | 1200 | QDir fullDir(localPath); |
1198 | if (fullDir.exists()) | 1201 | if (fullDir.exists()) |
1199 | return true; | 1202 | return true; |
1200 | 1203 | ||
1201 | // at this point the directory doesn't exist | 1204 | // at this point the directory doesn't exist |
1202 | // go through the directory tree and start creating the direcotories | 1205 | // go through the directory tree and start creating the direcotories |
1203 | // that don't exist; if we can't create the directories, return false | 1206 | // that don't exist; if we can't create the directories, return false |
1204 | 1207 | ||
1205 | QString dirSeps = "/"; | 1208 | QString dirSeps = "/"; |
1206 | int dirIndex = localPath.find(dirSeps); | 1209 | int dirIndex = localPath.find(dirSeps); |
1207 | QString checkedPath; | 1210 | QString checkedPath; |
1208 | 1211 | ||
1209 | // didn't find any seps; weird, use the cur dir instead | 1212 | // didn't find any seps; weird, use the cur dir instead |
1210 | if (dirIndex == -1) { | 1213 | if (dirIndex == -1) { |
1211 | //qDebug("No seperators found in path %s", localPath.latin1()); | 1214 | //qDebug("No seperators found in path %s", localPath.latin1()); |
1212 | checkedPath = QDir::currentDirPath(); | 1215 | checkedPath = QDir::currentDirPath(); |
1213 | } | 1216 | } |
1214 | 1217 | ||
1215 | while (checkedPath != localPath) { | 1218 | while (checkedPath != localPath) { |
1216 | // no more seperators found, use the local path | 1219 | // no more seperators found, use the local path |
1217 | if (dirIndex == -1) | 1220 | if (dirIndex == -1) |
1218 | checkedPath = localPath; | 1221 | checkedPath = localPath; |
1219 | else { | 1222 | else { |
1220 | // the next directory to check | 1223 | // the next directory to check |
1221 | checkedPath = localPath.left(dirIndex) + "/"; | 1224 | checkedPath = localPath.left(dirIndex) + "/"; |
1222 | // advance the iterator; the next dir seperator | 1225 | // advance the iterator; the next dir seperator |
1223 | dirIndex = localPath.find(dirSeps, dirIndex+1); | 1226 | dirIndex = localPath.find(dirSeps, dirIndex+1); |
1224 | } | 1227 | } |
1225 | 1228 | ||
1226 | QDir checkDir(checkedPath); | 1229 | QDir checkDir(checkedPath); |
1227 | if (!checkDir.exists()) { | 1230 | if (!checkDir.exists()) { |
1228 | //qDebug("mkdir making dir %s", checkedPath.latin1()); | 1231 | //qDebug("mkdir making dir %s", checkedPath.latin1()); |
1229 | 1232 | ||
1230 | if (!checkDir.mkdir(checkedPath)) { | 1233 | if (!checkDir.mkdir(checkedPath)) { |
1231 | qDebug("Unable to make directory %s", checkedPath.latin1()); | 1234 | qDebug("Unable to make directory %s", checkedPath.latin1()); |
1232 | return FALSE; | 1235 | return FALSE; |
1233 | } | 1236 | } |
1234 | } | 1237 | } |
1235 | 1238 | ||
1236 | } | 1239 | } |
1237 | return TRUE; | 1240 | return TRUE; |
1238 | } | 1241 | } |
1239 | 1242 | ||
1240 | void Launcher::preloadApps() | 1243 | void Launcher::preloadApps() |
1241 | { | 1244 | { |
1242 | Config cfg("Launcher"); | 1245 | Config cfg("Launcher"); |
1243 | cfg.setGroup("Preload"); | 1246 | cfg.setGroup("Preload"); |
1244 | QStringList apps = cfg.readListEntry("Apps",','); | 1247 | QStringList apps = cfg.readListEntry("Apps",','); |
1245 | for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { | 1248 | for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { |
1246 | #ifndef QT_NO_COP | 1249 | #ifndef QT_NO_COP |
1247 | QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); | 1250 | QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); |
1248 | #endif | 1251 | #endif |
1249 | } | 1252 | } |
1250 | } | 1253 | } |
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp index 9fc4565..2a051a6 100644 --- a/core/launcher/launcherview.cpp +++ b/core/launcher/launcherview.cpp | |||
@@ -725,252 +725,257 @@ void LauncherView::showType(int t) | |||
725 | if ( t >= (int)typelist.count() ) { | 725 | if ( t >= (int)typelist.count() ) { |
726 | icons->setTypeFilter("",TRUE); | 726 | icons->setTypeFilter("",TRUE); |
727 | } else { | 727 | } else { |
728 | QString ty = typelist[t]; | 728 | QString ty = typelist[t]; |
729 | if ( !ty.contains('/') ) | 729 | if ( !ty.contains('/') ) |
730 | ty += "/*"; | 730 | ty += "/*"; |
731 | icons->setTypeFilter(ty,TRUE); | 731 | icons->setTypeFilter(ty,TRUE); |
732 | } | 732 | } |
733 | } | 733 | } |
734 | 734 | ||
735 | void LauncherView::showCategory( int c ) | 735 | void LauncherView::showCategory( int c ) |
736 | { | 736 | { |
737 | icons->setCategoryFilter( c, TRUE ); | 737 | icons->setCategoryFilter( c, TRUE ); |
738 | } | 738 | } |
739 | 739 | ||
740 | void LauncherView::setViewMode( ViewMode m ) | 740 | void LauncherView::setViewMode( ViewMode m ) |
741 | { | 741 | { |
742 | if ( vmode != m ) { | 742 | if ( vmode != m ) { |
743 | bool bigIcons = m == Icon; | 743 | bool bigIcons = m == Icon; |
744 | icons->viewport()->setUpdatesEnabled( FALSE ); | 744 | icons->viewport()->setUpdatesEnabled( FALSE ); |
745 | icons->setBigIcons( bigIcons ); | 745 | icons->setBigIcons( bigIcons ); |
746 | switch ( m ) { | 746 | switch ( m ) { |
747 | case List: | 747 | case List: |
748 | icons->setItemTextPos( QIconView::Right ); | 748 | icons->setItemTextPos( QIconView::Right ); |
749 | break; | 749 | break; |
750 | case Icon: | 750 | case Icon: |
751 | icons->setItemTextPos( QIconView::Bottom ); | 751 | icons->setItemTextPos( QIconView::Bottom ); |
752 | break; | 752 | break; |
753 | } | 753 | } |
754 | icons->hideOrShowItems( FALSE ); | 754 | icons->hideOrShowItems( FALSE ); |
755 | icons->viewport()->setUpdatesEnabled( TRUE ); | 755 | icons->viewport()->setUpdatesEnabled( TRUE ); |
756 | vmode = m; | 756 | vmode = m; |
757 | } | 757 | } |
758 | } | 758 | } |
759 | 759 | ||
760 | void LauncherView::setBackgroundType( BackgroundType t, const QString &val ) | 760 | void LauncherView::setBackgroundType( BackgroundType t, const QString &val ) |
761 | { | 761 | { |
762 | if ( !bgCache ) | 762 | if ( !bgCache ) |
763 | bgCache = new QMap<QString,BgPixmap*>; | 763 | bgCache = new QMap<QString,BgPixmap*>; |
764 | if ( bgCache->contains( bgName ) ) | 764 | if ( bgCache->contains( bgName ) ) |
765 | (*bgCache)[bgName]->ref--; | 765 | (*bgCache)[bgName]->ref--; |
766 | 766 | ||
767 | switch ( t ) { | 767 | switch ( t ) { |
768 | case Ruled: { | 768 | case Ruled: { |
769 | bgName = QString("Ruled_%1").arg(colorGroup().background().name()); // No tr | 769 | bgName = QString("Ruled_%1").arg(colorGroup().background().name()); // No tr |
770 | QPixmap bg; | 770 | QPixmap bg; |
771 | if ( bgCache->contains( bgName ) ) { | 771 | if ( bgCache->contains( bgName ) ) { |
772 | (*bgCache)[bgName]->ref++; | 772 | (*bgCache)[bgName]->ref++; |
773 | bg = (*bgCache)[bgName]->pm; | 773 | bg = (*bgCache)[bgName]->pm; |
774 | } else { | 774 | } else { |
775 | bg.resize( width(), 9 ); | 775 | bg.resize( width(), 9 ); |
776 | QPainter painter( &bg ); | 776 | QPainter painter( &bg ); |
777 | for ( int i = 0; i < 3; i++ ) { | 777 | for ( int i = 0; i < 3; i++ ) { |
778 | painter.setPen( white ); | 778 | painter.setPen( white ); |
779 | painter.drawLine( 0, i*3, width()-1, i*3 ); | 779 | painter.drawLine( 0, i*3, width()-1, i*3 ); |
780 | painter.drawLine( 0, i*3+1, width()-1, i*3+1 ); | 780 | painter.drawLine( 0, i*3+1, width()-1, i*3+1 ); |
781 | painter.setPen( colorGroup().background().light(105) ); | 781 | painter.setPen( colorGroup().background().light(105) ); |
782 | painter.drawLine( 0, i*3+2, width()-1, i*3+2 ); | 782 | painter.drawLine( 0, i*3+2, width()-1, i*3+2 ); |
783 | } | 783 | } |
784 | painter.end(); | 784 | painter.end(); |
785 | bgCache->insert( bgName, new BgPixmap(bg) ); | 785 | bgCache->insert( bgName, new BgPixmap(bg) ); |
786 | } | 786 | } |
787 | icons->setBackgroundPixmap( bg ); | 787 | icons->setBackgroundPixmap( bg ); |
788 | break; | 788 | break; |
789 | } | 789 | } |
790 | 790 | ||
791 | case SolidColor: | 791 | case SolidColor: |
792 | icons->setBackgroundPixmap( QPixmap() ); | 792 | icons->setBackgroundPixmap( QPixmap() ); |
793 | if ( val.isEmpty() ) { | 793 | if ( val.isEmpty() ) { |
794 | icons->setBackgroundColor( colorGroup().base() ); | 794 | icons->setBackgroundColor( colorGroup().base() ); |
795 | } else { | 795 | } else { |
796 | icons->setBackgroundColor( val ); | 796 | icons->setBackgroundColor( val ); |
797 | } | 797 | } |
798 | bgName = ""; | 798 | bgName = ""; |
799 | break; | 799 | break; |
800 | 800 | ||
801 | case Image: | 801 | case Image: |
802 | bgName = val; | 802 | bgName = val; |
803 | if ( bgCache->contains( bgName ) ) { | 803 | if ( bgCache->contains( bgName ) ) { |
804 | (*bgCache)[bgName]->ref++; | 804 | (*bgCache)[bgName]->ref++; |
805 | icons->setBackgroundPixmap( (*bgCache)[bgName]->pm ); | 805 | icons->setBackgroundPixmap( (*bgCache)[bgName]->pm ); |
806 | } else { | 806 | } else { |
807 | qDebug( "Loading image: %s", val.latin1() ); | 807 | qDebug( "Loading image: %s", val.latin1() ); |
808 | QPixmap bg( Resource::loadPixmap( val ) ); | 808 | QPixmap bg( Resource::loadPixmap( val ) ); |
809 | if ( bg.isNull() ) { | 809 | if ( bg.isNull() ) { |
810 | QImageIO imgio; | 810 | QImageIO imgio; |
811 | imgio.setFileName( bgName ); | 811 | imgio.setFileName( bgName ); |
812 | QSize ds = qApp->desktop()->size(); | 812 | QSize ds = qApp->desktop()->size(); |
813 | QString param( "Scale( %1, %2, ScaleMin )" ); // No tr | 813 | QString param( "Scale( %1, %2, ScaleMin )" ); // No tr |
814 | imgio.setParameters( param.arg(ds.width()).arg(ds.height()).latin1() ); | 814 | imgio.setParameters( param.arg(ds.width()).arg(ds.height()).latin1() ); |
815 | imgio.read(); | 815 | imgio.read(); |
816 | bg = imgio.image(); | 816 | bg = imgio.image(); |
817 | } | 817 | } |
818 | bgCache->insert( bgName, new BgPixmap(bg) ); | 818 | bgCache->insert( bgName, new BgPixmap(bg) ); |
819 | icons->setBackgroundPixmap( bg ); | 819 | icons->setBackgroundPixmap( bg ); |
820 | } | 820 | } |
821 | break; | 821 | break; |
822 | } | 822 | } |
823 | 823 | ||
824 | // remove unreferenced backgrounds. | 824 | // remove unreferenced backgrounds. |
825 | QMap<QString,BgPixmap*>::Iterator it = bgCache->begin(); | 825 | QMap<QString,BgPixmap*>::Iterator it = bgCache->begin(); |
826 | while ( it != bgCache->end() ) { | 826 | while ( it != bgCache->end() ) { |
827 | QMap<QString,BgPixmap*>::Iterator curr = it; | 827 | QMap<QString,BgPixmap*>::Iterator curr = it; |
828 | ++it; | 828 | ++it; |
829 | if ( (*curr)->ref == 0 ) { | 829 | if ( (*curr)->ref == 0 ) { |
830 | delete (*curr); | 830 | delete (*curr); |
831 | bgCache->remove( curr ); | 831 | bgCache->remove( curr ); |
832 | } | 832 | } |
833 | } | 833 | } |
834 | 834 | ||
835 | bgType = t; | 835 | bgType = t; |
836 | icons->viewport()->update(); | 836 | icons->viewport()->update(); |
837 | } | 837 | } |
838 | 838 | ||
839 | void LauncherView::setTextColor( const QColor &tc ) | 839 | void LauncherView::setTextColor( const QColor &tc ) |
840 | { | 840 | { |
841 | textCol = tc; | 841 | textCol = tc; |
842 | QColorGroup cg = icons->colorGroup(); | 842 | QColorGroup cg = icons->colorGroup(); |
843 | cg.setColor( QColorGroup::Text, tc ); | 843 | cg.setColor( QColorGroup::Text, tc ); |
844 | icons->setPalette( QPalette(cg,cg,cg) ); | 844 | icons->setPalette( QPalette(cg,cg,cg) ); |
845 | icons->viewport()->update(); | 845 | icons->viewport()->update(); |
846 | } | 846 | } |
847 | 847 | ||
848 | void LauncherView::setViewFont( const QFont &f ) | 848 | void LauncherView::setViewFont( const QFont &f ) |
849 | { | 849 | { |
850 | icons->setFont( f ); | 850 | icons->setFont( f ); |
851 | } | 851 | } |
852 | 852 | ||
853 | void LauncherView::unsetViewFont( ) | ||
854 | { | ||
855 | icons->unsetFont( ); | ||
856 | } | ||
857 | |||
853 | void LauncherView::resizeEvent(QResizeEvent *e) | 858 | void LauncherView::resizeEvent(QResizeEvent *e) |
854 | { | 859 | { |
855 | QVBox::resizeEvent( e ); | 860 | QVBox::resizeEvent( e ); |
856 | if ( e->size().width() != e->oldSize().width() ) | 861 | if ( e->size().width() != e->oldSize().width() ) |
857 | sort(); | 862 | sort(); |
858 | } | 863 | } |
859 | 864 | ||
860 | void LauncherView::populate( AppLnkSet *folder, const QString& typefilter ) | 865 | void LauncherView::populate( AppLnkSet *folder, const QString& typefilter ) |
861 | { | 866 | { |
862 | icons->clear(); | 867 | icons->clear(); |
863 | internalPopulate( folder, typefilter ); | 868 | internalPopulate( folder, typefilter ); |
864 | } | 869 | } |
865 | 870 | ||
866 | QString LauncherView::getAllDocLinkInfo() const | 871 | QString LauncherView::getAllDocLinkInfo() const |
867 | { | 872 | { |
868 | return icons->getAllDocLinkInfo(); | 873 | return icons->getAllDocLinkInfo(); |
869 | } | 874 | } |
870 | 875 | ||
871 | void LauncherView::selectionChanged() | 876 | void LauncherView::selectionChanged() |
872 | { | 877 | { |
873 | QIconViewItem* item = icons->currentItem(); | 878 | QIconViewItem* item = icons->currentItem(); |
874 | if ( item && item->isSelected() ) { | 879 | if ( item && item->isSelected() ) { |
875 | AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); | 880 | AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); |
876 | if ( icons->inKeyEvent() ) // not for mouse press | 881 | if ( icons->inKeyEvent() ) // not for mouse press |
877 | emit clicked( appLnk ); | 882 | emit clicked( appLnk ); |
878 | item->setSelected(FALSE); | 883 | item->setSelected(FALSE); |
879 | } | 884 | } |
880 | } | 885 | } |
881 | 886 | ||
882 | void LauncherView::returnPressed( QIconViewItem *item ) | 887 | void LauncherView::returnPressed( QIconViewItem *item ) |
883 | { | 888 | { |
884 | if ( item ) { | 889 | if ( item ) { |
885 | AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); | 890 | AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); |
886 | emit clicked( appLnk ); | 891 | emit clicked( appLnk ); |
887 | } | 892 | } |
888 | } | 893 | } |
889 | 894 | ||
890 | void LauncherView::itemClicked( int btn, QIconViewItem *item ) | 895 | void LauncherView::itemClicked( int btn, QIconViewItem *item ) |
891 | { | 896 | { |
892 | if ( item ) { | 897 | if ( item ) { |
893 | AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); | 898 | AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); |
894 | if ( btn == LeftButton ) { | 899 | if ( btn == LeftButton ) { |
895 | // Make sure it's the item we execute that gets highlighted | 900 | // Make sure it's the item we execute that gets highlighted |
896 | icons->setCurrentItem( item ); | 901 | icons->setCurrentItem( item ); |
897 | emit clicked( appLnk ); | 902 | emit clicked( appLnk ); |
898 | } | 903 | } |
899 | item->setSelected(FALSE); | 904 | item->setSelected(FALSE); |
900 | } | 905 | } |
901 | } | 906 | } |
902 | 907 | ||
903 | void LauncherView::itemPressed( int btn, QIconViewItem *item ) | 908 | void LauncherView::itemPressed( int btn, QIconViewItem *item ) |
904 | { | 909 | { |
905 | if ( item ) { | 910 | if ( item ) { |
906 | AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); | 911 | AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); |
907 | if ( btn == RightButton ) | 912 | if ( btn == RightButton ) |
908 | emit rightPressed( appLnk ); | 913 | emit rightPressed( appLnk ); |
909 | /* | 914 | /* |
910 | else if ( btn == LeftButton ) | 915 | else if ( btn == LeftButton ) |
911 | emit clicked( appLnk ); | 916 | emit clicked( appLnk ); |
912 | */ | 917 | */ |
913 | item->setSelected(FALSE); | 918 | item->setSelected(FALSE); |
914 | } | 919 | } |
915 | } | 920 | } |
916 | 921 | ||
917 | void LauncherView::internalPopulate( AppLnkSet *folder, const QString& typefilter ) | 922 | void LauncherView::internalPopulate( AppLnkSet *folder, const QString& typefilter ) |
918 | { | 923 | { |
919 | QListIterator<AppLnk> it( folder->children() ); | 924 | QListIterator<AppLnk> it( folder->children() ); |
920 | icons->setTypeFilter(typefilter,FALSE); | 925 | icons->setTypeFilter(typefilter,FALSE); |
921 | 926 | ||
922 | while ( it.current() ) { | 927 | while ( it.current() ) { |
923 | // show only the icons for existing files | 928 | // show only the icons for existing files |
924 | if (QFile(it.current()->file()).exists() || ( it.current()->file().left(4) == "http" )) { | 929 | if (QFile(it.current()->file()).exists() || ( it.current()->file().left(4) == "http" )) { |
925 | icons->addItem(*it,FALSE); | 930 | icons->addItem(*it,FALSE); |
926 | } | 931 | } |
927 | else { | 932 | else { |
928 | //maybe insert some .desktop file deletion code later | 933 | //maybe insert some .desktop file deletion code later |
929 | //maybe dir specific | 934 | //maybe dir specific |
930 | } | 935 | } |
931 | ++it; | 936 | ++it; |
932 | } | 937 | } |
933 | 938 | ||
934 | icons->sort(); | 939 | icons->sort(); |
935 | } | 940 | } |
936 | 941 | ||
937 | bool LauncherView::removeLink(const QString& linkfile) | 942 | bool LauncherView::removeLink(const QString& linkfile) |
938 | { | 943 | { |
939 | return icons->removeLink(linkfile); | 944 | return icons->removeLink(linkfile); |
940 | } | 945 | } |
941 | 946 | ||
942 | void LauncherView::sort() | 947 | void LauncherView::sort() |
943 | { | 948 | { |
944 | icons->sort(); | 949 | icons->sort(); |
945 | } | 950 | } |
946 | 951 | ||
947 | void LauncherView::addItem(AppLnk* app, bool resort) | 952 | void LauncherView::addItem(AppLnk* app, bool resort) |
948 | { | 953 | { |
949 | icons->addItem(app,resort); | 954 | icons->addItem(app,resort); |
950 | } | 955 | } |
951 | 956 | ||
952 | void LauncherView::setFileSystems(const QList<FileSystem> &) | 957 | void LauncherView::setFileSystems(const QList<FileSystem> &) |
953 | { | 958 | { |
954 | // ### does nothing now... | 959 | // ### does nothing now... |
955 | } | 960 | } |
956 | 961 | ||
957 | void LauncherView::paletteChange( const QPalette &p ) | 962 | void LauncherView::paletteChange( const QPalette &p ) |
958 | { | 963 | { |
959 | icons->unsetPalette(); | 964 | icons->unsetPalette(); |
960 | QVBox::paletteChange( p ); | 965 | QVBox::paletteChange( p ); |
961 | if ( bgType == Ruled ) | 966 | if ( bgType == Ruled ) |
962 | setBackgroundType( Ruled, QString::null ); | 967 | setBackgroundType( Ruled, QString::null ); |
963 | QColorGroup cg = icons->colorGroup(); | 968 | QColorGroup cg = icons->colorGroup(); |
964 | cg.setColor( QColorGroup::Text, textCol ); | 969 | cg.setColor( QColorGroup::Text, textCol ); |
965 | icons->setPalette( QPalette(cg,cg,cg) ); | 970 | icons->setPalette( QPalette(cg,cg,cg) ); |
966 | } | 971 | } |
967 | 972 | ||
968 | 973 | ||
969 | void LauncherView::setBusyIndicatorType ( const QString &type ) | 974 | void LauncherView::setBusyIndicatorType ( const QString &type ) |
970 | { | 975 | { |
971 | if ( type. lower ( ) == "blink" ) | 976 | if ( type. lower ( ) == "blink" ) |
972 | icons-> setBusyIndicatorType ( BIT_Blinking ); | 977 | icons-> setBusyIndicatorType ( BIT_Blinking ); |
973 | else | 978 | else |
974 | icons-> setBusyIndicatorType ( BIT_Normal ); | 979 | icons-> setBusyIndicatorType ( BIT_Normal ); |
975 | } | 980 | } |
976 | 981 | ||
diff --git a/core/launcher/launcherview.h b/core/launcher/launcherview.h index 194e4a2..82a319b 100644 --- a/core/launcher/launcherview.h +++ b/core/launcher/launcherview.h | |||
@@ -1,105 +1,106 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef LAUNCHERVIEW_H | 20 | #ifndef LAUNCHERVIEW_H |
21 | #define LAUNCHERVIEW_H | 21 | #define LAUNCHERVIEW_H |
22 | 22 | ||
23 | #include <qpe/storage.h> | 23 | #include <qpe/storage.h> |
24 | 24 | ||
25 | #include <qvbox.h> | 25 | #include <qvbox.h> |
26 | 26 | ||
27 | class AppLnk; | 27 | class AppLnk; |
28 | class AppLnkSet; | 28 | class AppLnkSet; |
29 | class CategorySelect; | 29 | class CategorySelect; |
30 | class LauncherIconView; | 30 | class LauncherIconView; |
31 | class QIconView; | 31 | class QIconView; |
32 | class QIconViewItem; | 32 | class QIconViewItem; |
33 | class MenuButton; | 33 | class MenuButton; |
34 | class QComboBox; | 34 | class QComboBox; |
35 | 35 | ||
36 | class LauncherView : public QVBox | 36 | class LauncherView : public QVBox |
37 | { | 37 | { |
38 | Q_OBJECT | 38 | Q_OBJECT |
39 | 39 | ||
40 | public: | 40 | public: |
41 | LauncherView( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 41 | LauncherView( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
42 | ~LauncherView(); | 42 | ~LauncherView(); |
43 | 43 | ||
44 | bool removeLink(const QString& linkfile); | 44 | bool removeLink(const QString& linkfile); |
45 | void addItem(AppLnk* app, bool resort=TRUE); | 45 | void addItem(AppLnk* app, bool resort=TRUE); |
46 | void sort(); | 46 | void sort(); |
47 | 47 | ||
48 | void setFileSystems(const QList<FileSystem> &); | 48 | void setFileSystems(const QList<FileSystem> &); |
49 | void setToolsEnabled(bool); | 49 | void setToolsEnabled(bool); |
50 | void updateTools(); | 50 | void updateTools(); |
51 | 51 | ||
52 | void setBusy(bool); | 52 | void setBusy(bool); |
53 | 53 | ||
54 | QString getAllDocLinkInfo() const; | 54 | QString getAllDocLinkInfo() const; |
55 | enum ViewMode { Icon, List }; | 55 | enum ViewMode { Icon, List }; |
56 | void setViewMode( ViewMode m ); | 56 | void setViewMode( ViewMode m ); |
57 | ViewMode viewMode() const { return vmode; } | 57 | ViewMode viewMode() const { return vmode; } |
58 | 58 | ||
59 | enum BackgroundType { Ruled, SolidColor, Image }; | 59 | enum BackgroundType { Ruled, SolidColor, Image }; |
60 | void setBackgroundType( BackgroundType t, const QString & ); | 60 | void setBackgroundType( BackgroundType t, const QString & ); |
61 | BackgroundType backgroundType() const { return bgType; } | 61 | BackgroundType backgroundType() const { return bgType; } |
62 | 62 | ||
63 | void setTextColor( const QColor & ); | 63 | void setTextColor( const QColor & ); |
64 | QColor textColor() const { return textCol; } | 64 | QColor textColor() const { return textCol; } |
65 | 65 | ||
66 | void setViewFont( const QFont & ); | 66 | void setViewFont( const QFont & ); |
67 | void unsetViewFont ( ); | ||
67 | 68 | ||
68 | void setBusyIndicatorType ( const QString &type ); | 69 | void setBusyIndicatorType ( const QString &type ); |
69 | 70 | ||
70 | public slots: | 71 | public slots: |
71 | void populate( AppLnkSet *folder, const QString& categoryfilter ); | 72 | void populate( AppLnkSet *folder, const QString& categoryfilter ); |
72 | 73 | ||
73 | signals: | 74 | signals: |
74 | void clicked( const AppLnk * ); | 75 | void clicked( const AppLnk * ); |
75 | void rightPressed( AppLnk * ); | 76 | void rightPressed( AppLnk * ); |
76 | 77 | ||
77 | protected slots: | 78 | protected slots: |
78 | void selectionChanged(); | 79 | void selectionChanged(); |
79 | void returnPressed( QIconViewItem *item ); | 80 | void returnPressed( QIconViewItem *item ); |
80 | void itemClicked( int, QIconViewItem * ); | 81 | void itemClicked( int, QIconViewItem * ); |
81 | void itemPressed( int, QIconViewItem * ); | 82 | void itemPressed( int, QIconViewItem * ); |
82 | void sortBy(int); | 83 | void sortBy(int); |
83 | void showType(int); | 84 | void showType(int); |
84 | void showCategory( int ); | 85 | void showCategory( int ); |
85 | void resizeEvent(QResizeEvent *); | 86 | void resizeEvent(QResizeEvent *); |
86 | 87 | ||
87 | protected: | 88 | protected: |
88 | void internalPopulate( AppLnkSet *, const QString& categoryfilter ); | 89 | void internalPopulate( AppLnkSet *, const QString& categoryfilter ); |
89 | void paletteChange( const QPalette & ); | 90 | void paletteChange( const QPalette & ); |
90 | 91 | ||
91 | private: | 92 | private: |
92 | static bool bsy; | 93 | static bool bsy; |
93 | QWidget* tools; | 94 | QWidget* tools; |
94 | LauncherIconView* icons; | 95 | LauncherIconView* icons; |
95 | QComboBox *typemb; | 96 | QComboBox *typemb; |
96 | QStringList typelist; | 97 | QStringList typelist; |
97 | CategorySelect *catmb; | 98 | CategorySelect *catmb; |
98 | ViewMode vmode; | 99 | ViewMode vmode; |
99 | BackgroundType bgType; | 100 | BackgroundType bgType; |
100 | QString bgName; | 101 | QString bgName; |
101 | QColor textCol; | 102 | QColor textCol; |
102 | int busyType; | 103 | int busyType; |
103 | }; | 104 | }; |
104 | 105 | ||
105 | #endif // LAUNCHERVIEW_H | 106 | #endif // LAUNCHERVIEW_H |