[mythtv] [mythgallery] [patch] - Add random slideshow.
Neil Whelchel
koyama at firstlight.net
Mon Oct 18 04:31:07 UTC 2004
Hello,
If anyone is interested, this patch adds a random slideshow
function to mythgallery. (Maybe the menu could be made larger so you don't
have to scroll to the settings and some translations added.)
Also, this patch is the first step of two to making a slideshow
screensaver out of mythgallery.
-Neil Whelchel-
- We don't do Window$, that's what the janitor is for -
-------------- next part --------------
--- mythgallery_dist/mythgallery/iconview.cpp Fri Feb 6 14:16:23 2004
+++ mythgallery/mythgallery/iconview.cpp Sun Oct 17 19:21:17 2004
@@ -316,7 +316,7 @@
handled = true;
- bool slideShow = (action == "PLAY");
+ int slideShow = (action == "PLAY")?1:0;
#ifdef OPENGL_SUPPORT
int useOpenGL = gContext->GetNumSetting("SlideshowUseOpenGL");
if (useOpenGL) {
@@ -487,6 +487,8 @@
UIListBtnTypeItem* item;
item = new UIListBtnTypeItem(m_menuType, tr("SlideShow"));
item->setData(new Action(&IconView::actionSlideShow));
+ item = new UIListBtnTypeItem(m_menuType, tr("RandomShow"));
+ item->setData(new Action(&IconView::actionRandomShow));
item = new UIListBtnTypeItem(m_menuType, tr("Rotate CW"));
item->setData(new Action(&IconView::actionRotateCW));
item = new UIListBtnTypeItem(m_menuType, tr("Rotate CCW"));
@@ -855,7 +857,39 @@
else
#endif
{
- SingleView sv(m_db, m_itemList, pos, true,
+ SingleView sv(m_db, m_itemList, pos, 1,
+ gContext->GetMainWindow());
+ sv.exec();
+ }
+}
+
+void IconView::actionRandomShow()
+{
+ ThumbItem* item = m_itemList.at(m_currRow * m_nCols +
+ m_currCol);
+ if (!item || item->isDir)
+ return;
+
+ int pos = m_currRow * m_nCols + m_currCol;
+
+#ifdef OPENGL_SUPPORT
+ int useOpenGL = gContext->GetNumSetting("SlideshowUseOpenGL");
+ if (useOpenGL) {
+ if (QGLFormat::hasOpenGL()) {
+ GLSDialog gv(m_db, m_itemList, pos, true,
+ gContext->GetMainWindow());
+ gv.exec();
+ }
+ else {
+ MythPopupBox::showOkPopup(gContext->GetMainWindow(),
+ tr("Error"),
+ tr("Sorry: OpenGL support not available"));
+ }
+ }
+ else
+#endif
+ {
+ SingleView sv(m_db, m_itemList, pos, 2,
gContext->GetMainWindow());
sv.exec();
}
diff -ur mythgallery_dist/mythgallery/iconview.h mythgallery/mythgallery/iconview.h
--- mythgallery_dist/mythgallery/iconview.h Sat Feb 7 10:15:30 2004
+++ mythgallery/mythgallery/iconview.h Sun Oct 17 19:21:27 2004
@@ -91,6 +91,7 @@
void actionRotateCW();
void actionRotateCCW();
void actionSlideShow();
+ void actionRandomShow();
void actionSettings();
void actionImport();
diff -ur mythgallery_dist/mythgallery/singleview.cpp mythgallery/mythgallery/singleview.cpp
--- mythgallery_dist/mythgallery/singleview.cpp Sun Apr 18 12:24:19 2004
+++ mythgallery/mythgallery/singleview.cpp Sun Oct 17 19:32:17 2004
@@ -30,14 +30,15 @@
#include "singleview.h"
SingleView::SingleView(QSqlDatabase *db, ThumbList itemList,
- int pos, bool slideShow,
+ int pos, int slideShow,
MythMainWindow *parent, const char *name )
: MythDialog(parent, name)
{
m_db = db;
m_itemList = itemList;
m_pos = pos;
-
+ m_slideShow = slideShow;
+
// --------------------------------------------------------------------
// remove all dirs from m_itemList;
@@ -112,6 +113,8 @@
// --------------------------------------------------------------------
+ if(slideShow > 1)
+ randomFrame();
loadImage();
if (slideShow) {
m_running = true;
@@ -398,6 +401,15 @@
m_pos = 0;
}
+void SingleView::randomFrame()
+{
+ int newframe;
+ if(m_itemList.count() > 1){
+ while((newframe = (int)(rand()/(RAND_MAX+1.0) * m_itemList.count())) == m_pos);
+ m_pos = newframe;
+ }
+}
+
void SingleView::retreatFrame()
{
m_pos--;
@@ -1155,7 +1167,10 @@
if (m_effectRandom)
m_effectMethod = getRandomEffect();
- advanceFrame();
+ if(m_slideShow > 1)
+ randomFrame();
+ else
+ advanceFrame();
loadImage();
createEffectPix();
diff -ur mythgallery_dist/mythgallery/singleview.h mythgallery/mythgallery/singleview.h
--- mythgallery_dist/mythgallery/singleview.h Wed Jan 14 09:15:05 2004
+++ mythgallery/mythgallery/singleview.h Sun Oct 17 19:06:01 2004
@@ -32,7 +32,7 @@
public:
SingleView(QSqlDatabase *db, ThumbList itemList,
- int pos, bool slideShow,
+ int pos, int slideShow,
MythMainWindow *parent, const char *name=0);
~SingleView();
@@ -62,6 +62,7 @@
int m_delay;
bool m_effectRunning;
bool m_running;
+ int m_slideShow;
QTimer *m_timer;
QPixmap *m_effectPix;
QPainter *m_painter;
@@ -81,6 +82,7 @@
private:
void advanceFrame();
+ void randomFrame();
void retreatFrame();
void loadImage();
void rotate(int angle);
More information about the mythtv-dev
mailing list