00001
00002
00003
00004 #ifndef _SLMISC_H_INCLUDED
00005 #define _SLMISC_H_INCLUDED
00006
00007 #include <qpeapplication.h>
00008 #include <qfileinfo.h>
00009 #include <global.h>
00010 #include <qmessagebox.h>
00011
00012
00013 #define _SLPOWER
00014
00015 class QPopupMenu;
00016 class QListView;
00017 #if !defined(_SLPOWER)
00018 class PowerStatus;
00019 #else
00020 class SlPowerStatus;
00021 #endif
00022 class Config;
00023
00024 typedef ulong SlResolutionScale;
00025
00026 class SlMisc {
00027 public:
00028 static bool isExecutable(const QString &c) {
00029 QFileInfo exec(QPEApplication::qpeDir() + "/bin/" + c);
00030 return exec.isExecutable();
00031 };
00032 static ulong availableMemory();
00033 static bool invalidFileName(QString &fName);
00034 static QString getValidFileName(const QString &baseName);
00035 static QString getCanonicalPath(const QString &fName);
00036 static void enableAutoPowerOff(bool isOn);
00037 static void enableAutoPowerOff(bool isOn,bool DimAlso,bool ScreenSaverAlso=FALSE);
00038 static void enableLockApplication(bool);
00039 static bool isTheSmbShareFileHasWriteEntry(const QString &shareFName);
00040 static bool isTheSmbShareFileNowCopy(const QString &shareFName);
00041 static bool checkTheSmbShareFileMode(const QString &shareFName,
00042 char modeMask, char checkMode, bool equality);
00043 static bool isTheFileLockedBySmbd(const QString &fName);
00044 static bool isSambaForked();
00045 static void startSamba();
00046 static void stopSamba();
00047 enum ListType { Pid, CmdLine, Both };
00048 static QStringList procList (const QRegExp& re, uint max = 0, enum ListType type = Pid);
00049 static void dumpMemInfo(bool isShowHeap);
00050 static bool canCreateTheFile(const QString&);
00051 static QString getLanguage();
00052 static QSize getMaximizedWidgetInfo();
00053 static QSize SlMisc::getScrollbarMetrics();
00054 static int getDpi();
00055 static SlResolutionScale getResolutionScale();
00056 static int getMaximizedWidgetContentsWidth();
00057 static bool isLandscape();
00058 static void requestCloseFile(const QString&);
00059 static void requestOpenFile(const QString&);
00060
00061 static void insertStandardFontMenu(QPopupMenu *pm);
00062 static void insertAllFontMenu(QPopupMenu *pm);
00063 static int getLogicalSizeFromMenuId(int id);
00064 static void setFontSizeItemChecked(QPopupMenu *pm,int logicalSize);
00065 static int getFontPointSize(int logicalSize);
00066 static void toggleFontSize(QPopupMenu *pm,int &logicalSize,bool isLarge=true);
00067 static void toggleAllFontSize(QPopupMenu *pm,int *fontSize,bool isLarge=true);
00068
00069 static void SlFontArrange (QWidget* widget);
00070 static void SlLayoutSpaceArrange (QObject* object);
00071
00072 static bool checkBatteryError(const QString &module_name, bool force);
00073 static bool checkBatteryErrorWithoutDialog(const QString &module_name, bool force);
00074
00075
00076 enum InputDeviceType {
00077 BuiltinKeyboard = 1,
00078 SoftwareKeyboard = 2
00079 };
00080 static InputDeviceType defaultInputDevice();
00081
00082
00083 typedef struct SlListColumnInfo {
00084 enum Type {
00085 Fixed = 0,
00086 StringLen,
00087 Scale,
00088 FixedDpiAware
00089 };
00090 Type type;
00091 QString str;
00092 int val;
00093 };
00094 typedef QValueList<SlListColumnInfo> SlListColumnInfos;
00095
00096 static void setListColumnsWidth(QWidget *w,SlListColumnInfos &infos,
00097 Config &config);
00098 static void writeListColumnsWidth(QWidget *w,SlListColumnInfos &infos,
00099 Config &config);
00100 static void writeListColumnsWidth(QWidget *w,SlListColumnInfos &infos,
00101 Config &config,bool isLandscape);
00102 static void rotateListColumnsWidth(QWidget *w,SlListColumnInfos &infos,
00103 Config &config);
00104 static void setListColumnsWidth(QWidget *w,SlListColumnInfos &infos, Config *config=NULL);
00105 static void writeListColumnsWidth(QWidget *w,SlListColumnInfos &infos, Config *config=NULL);
00106 static void writeListColumnsWidth(QWidget *w,SlListColumnInfos &infos, bool isLandscape, Config *config=NULL);
00107 static void rotateListColumnsWidth(QWidget *w,SlListColumnInfos &infos, Config *config=NULL);
00108 static void temporaryMessageBox(const QString &caption, const QString &text, int msec=10000, QMessageBox::Icon icon=QMessageBox::NoIcon, int button0=0, int button1=0, int button2=0, QWidget *parent=0, const char *name=0, QWidget::WFlags f=QWidget::WStyle_DialogBorder);
00109
00110 static QString defaultWallPaper();
00111 typedef enum AppCommand {
00112 NoneCommand = 0,
00113 NewCommand,
00114 ModifyCommand,
00115 DeleteCommand,
00116 ZoomInCommand,
00117 ZoomOutCommand,
00118 CutCommand = 50,
00119 CopyCommand,
00120 PasteCommand
00121 };
00122 static AppCommand appCommandFromKey(const QKeyEvent &e);
00123
00124 typedef enum RequiredSize {
00125 SmallSize = 0,
00126 LargeSize
00127 };
00128 static const char* getTmpPath(RequiredSize);
00129 static const char* getTmpPath(ulong);
00130 static QString getObexTmpPath();
00131 static ulong availableInternalStorage(void);
00132 static QString moduleNameFromPath(const QString &path);
00133 };
00134
00135 #endif