00001 #include <iostream>
00002
00003
00004 #include <qapplication.h>
00005 #include <qimage.h>
00006 #include <qdir.h>
00007
00008 #include "iconview.h"
00009 #include "gallerysettings.h"
00010 #include "dbcheck.h"
00011 #include "qtiffio.h"
00012
00013 #include <mythtv/mythcontext.h>
00014 #include <mythtv/mythdialogs.h>
00015 #include <mythtv/mythplugin.h>
00016 #include <mythtv/dialogbox.h>
00017 #include <mythtv/mythmedia.h>
00018 #include <mythtv/mythpluginapi.h>
00019
00020 static void run(MythMediaDevice *dev)
00021 {
00022 QString startdir = gContext->GetSetting("GalleryDir");
00023 IconView icv(startdir, dev, gContext->GetMainWindow());
00024 if (icv.GetError().isEmpty())
00025 icv.exec();
00026 else
00027 {
00028 DialogBox *dlg = new DialogBox(
00029 gContext->GetMainWindow(), icv.GetError());
00030
00031 dlg->AddButton(QObject::tr("Ok"));
00032 dlg->exec();
00033 dlg->deleteLater();
00034 }
00035 }
00036
00037 void runGallery(void)
00038 {
00039 gContext->addCurrentLocation("mythgallery");
00040 run(NULL);
00041 gContext->removeCurrentLocation();
00042 }
00043
00044 void handleMedia(MythMediaDevice *dev)
00045 {
00046 if (dev && dev->isUsable())
00047 run(dev);
00048 }
00049
00050 void setupKeys(void)
00051 {
00052 REG_JUMP("MythGallery", "Image viewer / slideshow", "", runGallery);
00053
00054 REG_KEY("Gallery", "PLAY", "Start/Stop Slideshow", "P");
00055 REG_KEY("Gallery", "HOME", "Go to the first image in thumbnail view",
00056 "Home");
00057 REG_KEY("Gallery", "END", "Go to the last image in thumbnail view", "End");
00058 REG_KEY("Gallery", "MENU", "Toggle activating menu in thumbnail view", "M");
00059 REG_KEY("Gallery", "SLIDESHOW", "Start Slideshow in thumbnail view", "S");
00060 REG_KEY("Gallery", "RANDOMSHOW", "Start Random Slideshow in thumbnail view", "R");
00061
00062 REG_KEY("Gallery", "ROTRIGHT", "Rotate image right 90 degrees", "],3");
00063 REG_KEY("Gallery", "ROTLEFT", "Rotate image left 90 degrees", "[,1");
00064 REG_KEY("Gallery", "ZOOMOUT", "Zoom image out", "7");
00065 REG_KEY("Gallery", "ZOOMIN", "Zoom image in", "9");
00066 REG_KEY("Gallery", "SCROLLUP", "Scroll image up", "2");
00067 REG_KEY("Gallery", "SCROLLLEFT", "Scroll image left", "4");
00068 REG_KEY("Gallery", "SCROLLRIGHT", "Scroll image right", "6");
00069 REG_KEY("Gallery", "SCROLLDOWN", "Scroll image down", "8");
00070 REG_KEY("Gallery", "RECENTER", "Recenter image", "5");
00071 REG_KEY("Gallery", "FULLSIZE", "Full-size (un-zoom) image", "0");
00072 REG_KEY("Gallery", "UPLEFT", "Go to the upper-left corner of the image",
00073 "PgUp");
00074 REG_KEY("Gallery", "LOWRIGHT", "Go to the lower-right corner of the image",
00075 "PgDown");
00076 REG_KEY("Gallery", "INFO", "Toggle Showing Information about Image", "I");
00077 REG_KEY("Gallery", "DELETE", "Delete marked images or current image if none are marked", "D");
00078 REG_KEY("Gallery", "MARK", "Mark image", "T");
00079 REG_KEY("Gallery", "FULLSCREEN", "Toggle scale to fullscreen/scale to fit", "W");
00080 REG_MEDIA_HANDLER("MythGallery Media Handler 1/2", "", "", handleMedia,
00081 MEDIATYPE_DATA | MEDIATYPE_MIXED, QString::null);
00082 REG_MEDIA_HANDLER("MythGallery Media Handler 2/2", "", "", handleMedia,
00083 MEDIATYPE_MGALLERY, "gif,jpg,png");
00084 }
00085
00086 int mythplugin_init(const char *libversion)
00087 {
00088 if (!gContext->TestPopupVersion("mythgallery", libversion,
00089 MYTH_BINARY_VERSION))
00090 return -1;
00091
00092 qInitTiffIO();
00093
00094
00095 gContext->ActivateSettingsCache(false);
00096 UpgradeGalleryDatabaseSchema();
00097 gContext->ActivateSettingsCache(true);
00098
00099 GallerySettings settings;
00100 settings.load();
00101 settings.save();
00102
00103 setupKeys();
00104
00105 return 0;
00106 }
00107
00108 int mythplugin_run(void)
00109 {
00110 runGallery();
00111 return 0;
00112 }
00113
00114 int mythplugin_config(void)
00115 {
00116 GallerySettings settings;
00117 settings.exec();
00118
00119 return 0;
00120 }
00121