-rw-r--r-- | noncore/apps/zsafe/zsafe.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/noncore/apps/zsafe/zsafe.cpp b/noncore/apps/zsafe/zsafe.cpp index 6aa6392..1ae3b15 100644 --- a/noncore/apps/zsafe/zsafe.cpp +++ b/noncore/apps/zsafe/zsafe.cpp | |||
@@ -2731,97 +2731,97 @@ void ZSafe::addCategory() | |||
2731 | QString categ; | 2731 | QString categ; |
2732 | QString firstCategory; | 2732 | QString firstCategory; |
2733 | dialog->CategoryField->clear(); // remove all items | 2733 | dialog->CategoryField->clear(); // remove all items |
2734 | while( it != list.end() ) | 2734 | while( it != list.end() ) |
2735 | { | 2735 | { |
2736 | QString *cat = new QString (*it); | 2736 | QString *cat = new QString (*it); |
2737 | if (cat->contains("-field1", FALSE)) | 2737 | if (cat->contains("-field1", FALSE)) |
2738 | { | 2738 | { |
2739 | #ifdef DESKTOP | 2739 | #ifdef DESKTOP |
2740 | #ifndef Q_WS_WIN | 2740 | #ifndef Q_WS_WIN |
2741 | categ = cat->section ("-field1", 0, 0); | 2741 | categ = cat->section ("-field1", 0, 0); |
2742 | #else | 2742 | #else |
2743 | int pos = cat->find ("-field1"); | 2743 | int pos = cat->find ("-field1"); |
2744 | categ = cat->left (pos); | 2744 | categ = cat->left (pos); |
2745 | #endif | 2745 | #endif |
2746 | #else | 2746 | #else |
2747 | int pos = cat->find ("-field1"); | 2747 | int pos = cat->find ("-field1"); |
2748 | cat->truncate(pos); | 2748 | cat->truncate(pos); |
2749 | categ = *cat; | 2749 | categ = *cat; |
2750 | #endif | 2750 | #endif |
2751 | if (!categ.isEmpty()) | 2751 | if (!categ.isEmpty()) |
2752 | { | 2752 | { |
2753 | dialog->CategoryField->insertItem (categ, -1); | 2753 | dialog->CategoryField->insertItem (categ, -1); |
2754 | if (firstCategory.isEmpty()) | 2754 | if (firstCategory.isEmpty()) |
2755 | firstCategory = categ; | 2755 | firstCategory = categ; |
2756 | } | 2756 | } |
2757 | } | 2757 | } |
2758 | ++it; | 2758 | ++it; |
2759 | } | 2759 | } |
2760 | 2760 | ||
2761 | 2761 | ||
2762 | if (firstCategory.isEmpty()) | 2762 | if (firstCategory.isEmpty()) |
2763 | setCategoryDialogFields(dialog); | 2763 | setCategoryDialogFields(dialog); |
2764 | else | 2764 | else |
2765 | setCategoryDialogFields(dialog, firstCategory); | 2765 | setCategoryDialogFields(dialog, firstCategory); |
2766 | 2766 | ||
2767 | // CategoryDialog *dialog = new CategoryDialog(this, "Category", TRUE); | 2767 | // CategoryDialog *dialog = new CategoryDialog(this, "Category", TRUE); |
2768 | 2768 | ||
2769 | if (initIcons) | 2769 | if (initIcons) |
2770 | { | 2770 | { |
2771 | Wait waitDialog(this, tr("Wait dialog")); | 2771 | Wait waitDialog(this, tr("Wait dialog")); |
2772 | waitDialog.waitLabel->setText(tr("Gathering icons...")); | 2772 | waitDialog.waitLabel->setText(tr("Gathering icons...")); |
2773 | waitDialog.show(); | 2773 | waitDialog.show(); |
2774 | qApp->processEvents(); | 2774 | qApp->processEvents(); |
2775 | 2775 | ||
2776 | #ifdef DESKTOP | 2776 | #ifdef DESKTOP |
2777 | QDir d(iconPath); | 2777 | QDir d(iconPath); |
2778 | #else | 2778 | #else |
2779 | QDir d(QPEApplication::qpeDir() + "/pics/"); | 2779 | QDir d(QPEApplication::qpeDir() + "pics/"); |
2780 | #endif | 2780 | #endif |
2781 | d.setFilter( QDir::Files); | 2781 | d.setFilter( QDir::Files); |
2782 | 2782 | ||
2783 | const QFileInfoList *list = d.entryInfoList(); | 2783 | const QFileInfoList *list = d.entryInfoList(); |
2784 | QFileInfoListIterator it( *list ); // create list iterator | 2784 | QFileInfoListIterator it( *list ); // create list iterator |
2785 | QFileInfo *fi; // pointer for traversing | 2785 | QFileInfo *fi; // pointer for traversing |
2786 | 2786 | ||
2787 | dialog->IconField->insertItem("predefined"); | 2787 | dialog->IconField->insertItem("predefined"); |
2788 | while ( (fi=it.current()) ) { // for each file... | 2788 | while ( (fi=it.current()) ) { // for each file... |
2789 | QString fileName = fi->fileName(); | 2789 | QString fileName = fi->fileName(); |
2790 | if(fileName.right(4) == ".png"){ | 2790 | if(fileName.right(4) == ".png"){ |
2791 | fileName = fileName.mid(0,fileName.length()-4); | 2791 | fileName = fileName.mid(0,fileName.length()-4); |
2792 | #ifdef DESKTOP | 2792 | #ifdef DESKTOP |
2793 | QPixmap imageOfFile; | 2793 | QPixmap imageOfFile; |
2794 | imageOfFile.load(iconPath + fi->fileName()); | 2794 | imageOfFile.load(iconPath + fi->fileName()); |
2795 | #else | 2795 | #else |
2796 | QPixmap imageOfFile(Resource::loadPixmap(fileName)); | 2796 | QPixmap imageOfFile(Resource::loadPixmap(fileName)); |
2797 | #endif | 2797 | #endif |
2798 | QImage foo = imageOfFile.convertToImage(); | 2798 | QImage foo = imageOfFile.convertToImage(); |
2799 | foo = foo.smoothScale(16,16); | 2799 | foo = foo.smoothScale(16,16); |
2800 | imageOfFile.convertFromImage(foo); | 2800 | imageOfFile.convertFromImage(foo); |
2801 | dialog->IconField->insertItem(imageOfFile,fileName); | 2801 | dialog->IconField->insertItem(imageOfFile,fileName); |
2802 | } | 2802 | } |
2803 | ++it; | 2803 | ++it; |
2804 | } | 2804 | } |
2805 | waitDialog.hide(); | 2805 | waitDialog.hide(); |
2806 | } | 2806 | } |
2807 | 2807 | ||
2808 | #ifndef Q_WS_WIN | 2808 | #ifndef Q_WS_WIN |
2809 | dialog->show(); | 2809 | dialog->show(); |
2810 | #endif | 2810 | #endif |
2811 | #ifndef DESKTOP | 2811 | #ifndef DESKTOP |
2812 | // dialog->move (20, 100); | 2812 | // dialog->move (20, 100); |
2813 | #endif | 2813 | #endif |
2814 | DialogCode result = (DialogCode) dialog->exec(); | 2814 | DialogCode result = (DialogCode) dialog->exec(); |
2815 | #ifdef DESKTOP | 2815 | #ifdef DESKTOP |
2816 | result = Accepted; | 2816 | result = Accepted; |
2817 | #endif | 2817 | #endif |
2818 | 2818 | ||
2819 | QString category; | 2819 | QString category; |
2820 | QString icon; | 2820 | QString icon; |
2821 | QString fullIconPath; | 2821 | QString fullIconPath; |
2822 | QPixmap *pix; | 2822 | QPixmap *pix; |
2823 | if (result == Accepted) | 2823 | if (result == Accepted) |
2824 | { | 2824 | { |
2825 | modified = true; | 2825 | modified = true; |
2826 | category = dialog->CategoryField->currentText(); | 2826 | category = dialog->CategoryField->currentText(); |
2827 | icon = dialog->IconField->currentText()+".png"; | 2827 | icon = dialog->IconField->currentText()+".png"; |
@@ -2915,154 +2915,154 @@ void ZSafe::delCategory() | |||
2915 | ListView->takeItem(selectedItem); | 2915 | ListView->takeItem(selectedItem); |
2916 | delete selectedItem; | 2916 | delete selectedItem; |
2917 | 2917 | ||
2918 | selectedItem = NULL; | 2918 | selectedItem = NULL; |
2919 | break; | 2919 | break; |
2920 | case 1: // Don't delete | 2920 | case 1: // Don't delete |
2921 | break; | 2921 | break; |
2922 | } | 2922 | } |
2923 | 2923 | ||
2924 | } | 2924 | } |
2925 | } | 2925 | } |
2926 | 2926 | ||
2927 | void ZSafe::setCategoryDialogFields(CategoryDialog *dialog) | 2927 | void ZSafe::setCategoryDialogFields(CategoryDialog *dialog) |
2928 | { | 2928 | { |
2929 | if (!dialog) | 2929 | if (!dialog) |
2930 | return; | 2930 | return; |
2931 | 2931 | ||
2932 | QString icon; | 2932 | QString icon; |
2933 | if (selectedItem) | 2933 | if (selectedItem) |
2934 | { | 2934 | { |
2935 | dialog->Field1->setText(getFieldLabel (selectedItem, "1", tr("Name"))); | 2935 | dialog->Field1->setText(getFieldLabel (selectedItem, "1", tr("Name"))); |
2936 | dialog->Field2->setText(getFieldLabel (selectedItem, "2", tr("Username"))); | 2936 | dialog->Field2->setText(getFieldLabel (selectedItem, "2", tr("Username"))); |
2937 | dialog->Field3->setText(getFieldLabel (selectedItem, "3", tr("Password"))); | 2937 | dialog->Field3->setText(getFieldLabel (selectedItem, "3", tr("Password"))); |
2938 | dialog->Field4->setText(getFieldLabel (selectedItem, "4", tr("Comment"))); | 2938 | dialog->Field4->setText(getFieldLabel (selectedItem, "4", tr("Comment"))); |
2939 | dialog->Field5->setText(getFieldLabel (selectedItem, "5", tr("Field 4"))); | 2939 | dialog->Field5->setText(getFieldLabel (selectedItem, "5", tr("Field 4"))); |
2940 | dialog->Field6->setText(getFieldLabel (selectedItem, "6", tr("Field 5"))); | 2940 | dialog->Field6->setText(getFieldLabel (selectedItem, "6", tr("Field 5"))); |
2941 | 2941 | ||
2942 | Category *cat= categories.find (selectedItem->text(0)); | 2942 | Category *cat= categories.find (selectedItem->text(0)); |
2943 | if (cat) | 2943 | if (cat) |
2944 | { | 2944 | { |
2945 | icon = cat->getIconName(); | 2945 | icon = cat->getIconName(); |
2946 | } | 2946 | } |
2947 | else | 2947 | else |
2948 | icon = conf->readEntry(APP_KEY+selectedItem->text(0)); | 2948 | icon = conf->readEntry(APP_KEY+selectedItem->text(0)); |
2949 | } | 2949 | } |
2950 | else | 2950 | else |
2951 | { | 2951 | { |
2952 | dialog->Field1->setText(tr("Name")); | 2952 | dialog->Field1->setText(tr("Name")); |
2953 | dialog->Field2->setText(tr("Username")); | 2953 | dialog->Field2->setText(tr("Username")); |
2954 | dialog->Field3->setText(tr("Password")); | 2954 | dialog->Field3->setText(tr("Password")); |
2955 | dialog->Field4->setText(tr("Comment")); | 2955 | dialog->Field4->setText(tr("Comment")); |
2956 | dialog->Field5->setText(tr("Field 4")); | 2956 | dialog->Field5->setText(tr("Field 4")); |
2957 | dialog->Field6->setText(tr("Field 5")); | 2957 | dialog->Field6->setText(tr("Field 5")); |
2958 | } | 2958 | } |
2959 | 2959 | ||
2960 | #ifdef DESKTOP | 2960 | #ifdef DESKTOP |
2961 | QDir d(iconPath); | 2961 | QDir d(iconPath); |
2962 | #else | 2962 | #else |
2963 | QDir d(QPEApplication::qpeDir() + "/pics/"); | 2963 | QDir d(QPEApplication::qpeDir() + "pics/"); |
2964 | #endif | 2964 | #endif |
2965 | d.setFilter( QDir::Files); | 2965 | d.setFilter( QDir::Files); |
2966 | 2966 | ||
2967 | const QFileInfoList *list = d.entryInfoList(); | 2967 | const QFileInfoList *list = d.entryInfoList(); |
2968 | int i=0; | 2968 | int i=0; |
2969 | QFileInfoListIterator it( *list ); // create list iterator | 2969 | QFileInfoListIterator it( *list ); // create list iterator |
2970 | QFileInfo *fi; // pointer for traversing | 2970 | QFileInfo *fi; // pointer for traversing |
2971 | if (icon.isEmpty() || icon.isNull()) | 2971 | if (icon.isEmpty() || icon.isNull()) |
2972 | { | 2972 | { |
2973 | dialog->IconField->setCurrentItem(0); | 2973 | dialog->IconField->setCurrentItem(0); |
2974 | } | 2974 | } |
2975 | else | 2975 | else |
2976 | { | 2976 | { |
2977 | while ( (fi=it.current()) ) | 2977 | while ( (fi=it.current()) ) |
2978 | { // for each file... | 2978 | { // for each file... |
2979 | QString fileName = fi->fileName(); | 2979 | QString fileName = fi->fileName(); |
2980 | if(fileName.right(4) == ".png") | 2980 | if(fileName.right(4) == ".png") |
2981 | { | 2981 | { |
2982 | fileName = fileName.mid(0,fileName.length()-4); | 2982 | fileName = fileName.mid(0,fileName.length()-4); |
2983 | 2983 | ||
2984 | if(fileName+".png"==icon) | 2984 | if(fileName+".png"==icon) |
2985 | { | 2985 | { |
2986 | dialog->IconField->setCurrentItem(i+1); | 2986 | dialog->IconField->setCurrentItem(i+1); |
2987 | break; | 2987 | break; |
2988 | } | 2988 | } |
2989 | ++i; | 2989 | ++i; |
2990 | } | 2990 | } |
2991 | ++it; | 2991 | ++it; |
2992 | } | 2992 | } |
2993 | } | 2993 | } |
2994 | } | 2994 | } |
2995 | 2995 | ||
2996 | void ZSafe::setCategoryDialogFields(CategoryDialog *dialog, QString category) | 2996 | void ZSafe::setCategoryDialogFields(CategoryDialog *dialog, QString category) |
2997 | { | 2997 | { |
2998 | if (!dialog) | 2998 | if (!dialog) |
2999 | return; | 2999 | return; |
3000 | 3000 | ||
3001 | dialog->Field1->setText(getFieldLabel (category, "1", tr("Name"))); | 3001 | dialog->Field1->setText(getFieldLabel (category, "1", tr("Name"))); |
3002 | dialog->Field2->setText(getFieldLabel (category, "2", tr("Username"))); | 3002 | dialog->Field2->setText(getFieldLabel (category, "2", tr("Username"))); |
3003 | dialog->Field3->setText(getFieldLabel (category, "3", tr("Password"))); | 3003 | dialog->Field3->setText(getFieldLabel (category, "3", tr("Password"))); |
3004 | dialog->Field4->setText(getFieldLabel (category, "4", tr("Comment"))); | 3004 | dialog->Field4->setText(getFieldLabel (category, "4", tr("Comment"))); |
3005 | dialog->Field5->setText(getFieldLabel (category, "5", tr("Field 4"))); | 3005 | dialog->Field5->setText(getFieldLabel (category, "5", tr("Field 4"))); |
3006 | dialog->Field6->setText(getFieldLabel (category, "6", tr("Field 5"))); | 3006 | dialog->Field6->setText(getFieldLabel (category, "6", tr("Field 5"))); |
3007 | 3007 | ||
3008 | QString icon; | 3008 | QString icon; |
3009 | Category *cat= categories.find (category); | 3009 | Category *cat= categories.find (category); |
3010 | if (cat) | 3010 | if (cat) |
3011 | { | 3011 | { |
3012 | icon = cat->getIconName(); | 3012 | icon = cat->getIconName(); |
3013 | } | 3013 | } |
3014 | else | 3014 | else |
3015 | icon = conf->readEntry(APP_KEY+category); | 3015 | icon = conf->readEntry(APP_KEY+category); |
3016 | 3016 | ||
3017 | #ifdef DESKTOP | 3017 | #ifdef DESKTOP |
3018 | QDir d(iconPath); | 3018 | QDir d(iconPath); |
3019 | #else | 3019 | #else |
3020 | QDir d(QPEApplication::qpeDir() + "/pics/"); | 3020 | QDir d(QPEApplication::qpeDir() + "pics/"); |
3021 | #endif | 3021 | #endif |
3022 | d.setFilter( QDir::Files); | 3022 | d.setFilter( QDir::Files); |
3023 | 3023 | ||
3024 | const QFileInfoList *list = d.entryInfoList(); | 3024 | const QFileInfoList *list = d.entryInfoList(); |
3025 | int i=0; | 3025 | int i=0; |
3026 | QFileInfoListIterator it( *list ); // create list iterator | 3026 | QFileInfoListIterator it( *list ); // create list iterator |
3027 | QFileInfo *fi; // pointer for traversing | 3027 | QFileInfo *fi; // pointer for traversing |
3028 | if (icon.isEmpty() || icon.isNull()) | 3028 | if (icon.isEmpty() || icon.isNull()) |
3029 | { | 3029 | { |
3030 | dialog->IconField->setCurrentItem(0); | 3030 | dialog->IconField->setCurrentItem(0); |
3031 | } | 3031 | } |
3032 | else | 3032 | else |
3033 | { | 3033 | { |
3034 | while ( (fi=it.current()) ) | 3034 | while ( (fi=it.current()) ) |
3035 | { // for each file... | 3035 | { // for each file... |
3036 | QString fileName = fi->fileName(); | 3036 | QString fileName = fi->fileName(); |
3037 | if(fileName.right(4) == ".png") | 3037 | if(fileName.right(4) == ".png") |
3038 | { | 3038 | { |
3039 | fileName = fileName.mid(0,fileName.length()-4); | 3039 | fileName = fileName.mid(0,fileName.length()-4); |
3040 | 3040 | ||
3041 | if(fileName+".png"==icon) | 3041 | if(fileName+".png"==icon) |
3042 | { | 3042 | { |
3043 | dialog->IconField->setCurrentItem(i+1); | 3043 | dialog->IconField->setCurrentItem(i+1); |
3044 | break; | 3044 | break; |
3045 | } | 3045 | } |
3046 | ++i; | 3046 | ++i; |
3047 | } | 3047 | } |
3048 | ++it; | 3048 | ++it; |
3049 | } | 3049 | } |
3050 | } | 3050 | } |
3051 | } | 3051 | } |
3052 | 3052 | ||
3053 | void ZSafe::saveCategoryDialogFields(CategoryDialog *dialog) | 3053 | void ZSafe::saveCategoryDialogFields(CategoryDialog *dialog) |
3054 | { | 3054 | { |
3055 | QString app_key = APP_KEY; | 3055 | QString app_key = APP_KEY; |
3056 | #ifndef DESKTOP | 3056 | #ifndef DESKTOP |
3057 | conf->setGroup ("fieldDefs"); | 3057 | conf->setGroup ("fieldDefs"); |
3058 | #else | 3058 | #else |
3059 | #ifndef Q_WS_WIN | 3059 | #ifndef Q_WS_WIN |
3060 | app_key += "/fieldDefs/"; | 3060 | app_key += "/fieldDefs/"; |
3061 | #endif | 3061 | #endif |
3062 | #endif | 3062 | #endif |
3063 | QString category = dialog->CategoryField->currentText(); | 3063 | QString category = dialog->CategoryField->currentText(); |
3064 | // #ifndef Q_WS_WIN | 3064 | // #ifndef Q_WS_WIN |
3065 | conf->writeEntry(app_key+category+"-field1", dialog->Field1->text()); | 3065 | conf->writeEntry(app_key+category+"-field1", dialog->Field1->text()); |
3066 | conf->writeEntry(app_key+category+"-field2", dialog->Field2->text()); | 3066 | conf->writeEntry(app_key+category+"-field2", dialog->Field2->text()); |
3067 | conf->writeEntry(app_key+category+"-field3", dialog->Field3->text()); | 3067 | conf->writeEntry(app_key+category+"-field3", dialog->Field3->text()); |
3068 | conf->writeEntry(app_key+category+"-field4", dialog->Field4->text()); | 3068 | conf->writeEntry(app_key+category+"-field4", dialog->Field4->text()); |
@@ -3151,140 +3151,140 @@ void ZSafe::editCategory() | |||
3151 | #ifndef Q_WS_WIN | 3151 | #ifndef Q_WS_WIN |
3152 | categ = cat->section ("-field1", 0, 0); | 3152 | categ = cat->section ("-field1", 0, 0); |
3153 | #else | 3153 | #else |
3154 | int pos = cat->find ("-field1"); | 3154 | int pos = cat->find ("-field1"); |
3155 | categ = cat->left (pos); | 3155 | categ = cat->left (pos); |
3156 | #endif | 3156 | #endif |
3157 | #else | 3157 | #else |
3158 | int pos = cat->find ("-field1"); | 3158 | int pos = cat->find ("-field1"); |
3159 | cat->truncate(pos); | 3159 | cat->truncate(pos); |
3160 | categ = *cat; | 3160 | categ = *cat; |
3161 | #endif | 3161 | #endif |
3162 | if (!categ.isEmpty()) | 3162 | if (!categ.isEmpty()) |
3163 | { | 3163 | { |
3164 | dialog->CategoryField->insertItem (categ, i); | 3164 | dialog->CategoryField->insertItem (categ, i); |
3165 | if (category.compare(categ) == 0) | 3165 | if (category.compare(categ) == 0) |
3166 | { | 3166 | { |
3167 | dialog->CategoryField->setCurrentItem(i); | 3167 | dialog->CategoryField->setCurrentItem(i); |
3168 | foundCategory = true; | 3168 | foundCategory = true; |
3169 | } | 3169 | } |
3170 | i++; | 3170 | i++; |
3171 | } | 3171 | } |
3172 | } | 3172 | } |
3173 | ++it; | 3173 | ++it; |
3174 | } | 3174 | } |
3175 | if (!foundCategory) | 3175 | if (!foundCategory) |
3176 | { | 3176 | { |
3177 | dialog->CategoryField->insertItem (category, i); | 3177 | dialog->CategoryField->insertItem (category, i); |
3178 | dialog->CategoryField->setCurrentItem(i); | 3178 | dialog->CategoryField->setCurrentItem(i); |
3179 | } | 3179 | } |
3180 | 3180 | ||
3181 | QString icon; | 3181 | QString icon; |
3182 | Category *cat= categories.find (selectedItem->text(0)); | 3182 | Category *cat= categories.find (selectedItem->text(0)); |
3183 | if (cat) | 3183 | if (cat) |
3184 | { | 3184 | { |
3185 | icon = cat->getIconName(); | 3185 | icon = cat->getIconName(); |
3186 | } | 3186 | } |
3187 | 3187 | ||
3188 | if (initIcons) | 3188 | if (initIcons) |
3189 | { | 3189 | { |
3190 | 3190 | ||
3191 | Wait waitDialog(this, tr("Wait dialog")); | 3191 | Wait waitDialog(this, tr("Wait dialog")); |
3192 | waitDialog.waitLabel->setText(tr("Gathering icons...")); | 3192 | waitDialog.waitLabel->setText(tr("Gathering icons...")); |
3193 | waitDialog.show(); | 3193 | waitDialog.show(); |
3194 | qApp->processEvents(); | 3194 | qApp->processEvents(); |
3195 | 3195 | ||
3196 | #ifdef DESKTOP | 3196 | #ifdef DESKTOP |
3197 | QDir d(iconPath); | 3197 | QDir d(iconPath); |
3198 | #else | 3198 | #else |
3199 | QDir d(QPEApplication::qpeDir() + "/pics/"); | 3199 | QDir d(QPEApplication::qpeDir() + "pics/"); |
3200 | #endif | 3200 | #endif |
3201 | d.setFilter( QDir::Files); | 3201 | d.setFilter( QDir::Files); |
3202 | 3202 | ||
3203 | const QFileInfoList *list = d.entryInfoList(); | 3203 | const QFileInfoList *list = d.entryInfoList(); |
3204 | int i=0; | 3204 | int i=0; |
3205 | QFileInfoListIterator it( *list ); // create list iterator | 3205 | QFileInfoListIterator it( *list ); // create list iterator |
3206 | QFileInfo *fi; // pointer for traversing | 3206 | QFileInfo *fi; // pointer for traversing |
3207 | if (icon.isEmpty() || icon.isNull()) | 3207 | if (icon.isEmpty() || icon.isNull()) |
3208 | { | 3208 | { |
3209 | dialog->IconField->setCurrentItem(0); | 3209 | dialog->IconField->setCurrentItem(0); |
3210 | } | 3210 | } |
3211 | 3211 | ||
3212 | dialog->IconField->insertItem("predefined"); | 3212 | dialog->IconField->insertItem("predefined"); |
3213 | while ( (fi=it.current()) ) { // for each file... | 3213 | while ( (fi=it.current()) ) { // for each file... |
3214 | QString fileName = fi->fileName(); | 3214 | QString fileName = fi->fileName(); |
3215 | if(fileName.right(4) == ".png") | 3215 | if(fileName.right(4) == ".png") |
3216 | { | 3216 | { |
3217 | fileName = fileName.mid(0,fileName.length()-4); | 3217 | fileName = fileName.mid(0,fileName.length()-4); |
3218 | #ifdef DESKTOP | 3218 | #ifdef DESKTOP |
3219 | QPixmap imageOfFile; | 3219 | QPixmap imageOfFile; |
3220 | imageOfFile.load(iconPath + fi->fileName()); | 3220 | imageOfFile.load(iconPath + fi->fileName()); |
3221 | #else | 3221 | #else |
3222 | QPixmap imageOfFile(Resource::loadPixmap(fileName)); | 3222 | QPixmap imageOfFile(Resource::loadPixmap(fileName)); |
3223 | #endif | 3223 | #endif |
3224 | QImage foo = imageOfFile.convertToImage(); | 3224 | QImage foo = imageOfFile.convertToImage(); |
3225 | foo = foo.smoothScale(16,16); | 3225 | foo = foo.smoothScale(16,16); |
3226 | imageOfFile.convertFromImage(foo); | 3226 | imageOfFile.convertFromImage(foo); |
3227 | dialog->IconField->insertItem(imageOfFile,fileName); | 3227 | dialog->IconField->insertItem(imageOfFile,fileName); |
3228 | if(fileName+".png"==icon) | 3228 | if(fileName+".png"==icon) |
3229 | dialog->IconField->setCurrentItem(i+1); | 3229 | dialog->IconField->setCurrentItem(i+1); |
3230 | ++i; | 3230 | ++i; |
3231 | } | 3231 | } |
3232 | ++it; | 3232 | ++it; |
3233 | } | 3233 | } |
3234 | waitDialog.hide(); | 3234 | waitDialog.hide(); |
3235 | } | 3235 | } |
3236 | else | 3236 | else |
3237 | { | 3237 | { |
3238 | #ifdef DESKTOP | 3238 | #ifdef DESKTOP |
3239 | // QDir d(QDir::homeDirPath() + "/pics/"); | 3239 | // QDir d(QDir::homeDirPath() + "/pics/"); |
3240 | QDir d(iconPath); | 3240 | QDir d(iconPath); |
3241 | #else | 3241 | #else |
3242 | QDir d(QPEApplication::qpeDir() + "/pics/"); | 3242 | QDir d(QPEApplication::qpeDir() + "pics/"); |
3243 | #endif | 3243 | #endif |
3244 | d.setFilter( QDir::Files); | 3244 | d.setFilter( QDir::Files); |
3245 | 3245 | ||
3246 | const QFileInfoList *list = d.entryInfoList(); | 3246 | const QFileInfoList *list = d.entryInfoList(); |
3247 | int i=0; | 3247 | int i=0; |
3248 | QFileInfoListIterator it( *list ); // create list iterator | 3248 | QFileInfoListIterator it( *list ); // create list iterator |
3249 | QFileInfo *fi; // pointer for traversing | 3249 | QFileInfo *fi; // pointer for traversing |
3250 | if (icon.isEmpty() || icon.isNull()) | 3250 | if (icon.isEmpty() || icon.isNull()) |
3251 | { | 3251 | { |
3252 | dialog->IconField->setCurrentItem(0); | 3252 | dialog->IconField->setCurrentItem(0); |
3253 | } | 3253 | } |
3254 | else | 3254 | else |
3255 | { | 3255 | { |
3256 | 3256 | ||
3257 | while ( (fi=it.current()) ) | 3257 | while ( (fi=it.current()) ) |
3258 | { // for each file... | 3258 | { // for each file... |
3259 | QString fileName = fi->fileName(); | 3259 | QString fileName = fi->fileName(); |
3260 | if(fileName.right(4) == ".png") | 3260 | if(fileName.right(4) == ".png") |
3261 | { | 3261 | { |
3262 | fileName = fileName.mid(0,fileName.length()-4); | 3262 | fileName = fileName.mid(0,fileName.length()-4); |
3263 | 3263 | ||
3264 | 3264 | ||
3265 | if(fileName+".png"==icon) | 3265 | if(fileName+".png"==icon) |
3266 | { | 3266 | { |
3267 | dialog->IconField->setCurrentItem(i+1); | 3267 | dialog->IconField->setCurrentItem(i+1); |
3268 | break; | 3268 | break; |
3269 | } | 3269 | } |
3270 | ++i; | 3270 | ++i; |
3271 | } | 3271 | } |
3272 | ++it; | 3272 | ++it; |
3273 | } | 3273 | } |
3274 | } | 3274 | } |
3275 | } | 3275 | } |
3276 | 3276 | ||
3277 | // dialog->show(); | 3277 | // dialog->show(); |
3278 | #ifndef DESKTOP | 3278 | #ifndef DESKTOP |
3279 | // dialog->move (20, 100); | 3279 | // dialog->move (20, 100); |
3280 | #endif | 3280 | #endif |
3281 | DialogCode result = (DialogCode) dialog->exec(); | 3281 | DialogCode result = (DialogCode) dialog->exec(); |
3282 | #ifdef DESKTOP | 3282 | #ifdef DESKTOP |
3283 | result = Accepted; | 3283 | result = Accepted; |
3284 | #endif | 3284 | #endif |
3285 | 3285 | ||
3286 | QString fullIconPath; | 3286 | QString fullIconPath; |
3287 | QPixmap *pix; | 3287 | QPixmap *pix; |
3288 | if (result == Accepted) | 3288 | if (result == Accepted) |
3289 | { | 3289 | { |
3290 | modified = true; | 3290 | modified = true; |