Skip to content

Commit

Permalink
[UMWP Autochanger] add quick switch tray menu, rewrite boot order
Browse files Browse the repository at this point in the history
  • Loading branch information
mistic100 committed May 12, 2013
1 parent 60ee480 commit 988cdf3
Show file tree
Hide file tree
Showing 19 changed files with 427 additions and 350 deletions.
1 change: 1 addition & 0 deletions UMWP_Autochanger.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<file alias="playpause">images/play_pause.png</file>
<file alias="hide">images/hide.png</file>
<file alias="refresh">images/refresh.png</file>
<file alias="quick">images/quick.png</file>
</qresource>
<qresource prefix="/lang">
<file alias="en">lang/en.qm</file>
Expand Down
120 changes: 91 additions & 29 deletions controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,34 @@ Controller::Controller(Settings* _data) : QObject(0)
m_oRandom.seed((unsigned int)time(NULL));

m_poSettings = _data;
m_poMainTimer = new QTimer(this);

m_poMainTimer = new QTimer(this);
connect(m_poMainTimer, SIGNAL(timeout()), this, SLOT(vSlotUpdate()));
}

/*
* init threads
*/
void Controller::vStart()
{
if (m_poSettings->bParam("check_updates"))
{
VersionChecker* poVersionChecker = new VersionChecker(0);
connect(poVersionChecker, SIGNAL(newVersionAvailable(QString)), this, SLOT(vSlotNewVersion(QString)));
connect(poVersionChecker, SIGNAL(newVersionAvailable(QString)), this, SIGNAL(newVersionAvailable(QString)));

m_poVCThread = new QThread(this);
connect(m_poVCThread, SIGNAL(started()), poVersionChecker, SLOT(doCheckVersion()));
poVersionChecker->moveToThread(m_poVCThread);
QThread* poVCThread = new QThread(this);
poVersionChecker->moveToThread(poVCThread);

QTimer::singleShot(1000, m_poVCThread, SLOT(start()));
connect(poVCThread, SIGNAL(started()), poVersionChecker, SLOT(run()));
connect(poVersionChecker, SIGNAL(finished()), poVCThread, SLOT(quit()));
connect(poVersionChecker, SIGNAL(finished()), poVersionChecker, SLOT(deleteLater()));

QTimer::singleShot(1000, poVCThread, SLOT(start()));
}
}

/*
* update the wallpaper and start the timer
* start the timer and update the wallpaper
*/
void Controller::vStartTimer(bool _keepPause)
{
Expand All @@ -51,7 +60,7 @@ void Controller::vStartTimer(bool _keepPause)
/*
* pause or start the timer
*/
void Controller::vStartPause()
bool Controller::bStartPause()
{
if (m_poMainTimer->isActive())
{
Expand All @@ -61,6 +70,80 @@ void Controller::vStartPause()
{
m_poMainTimer->start();
}

return m_poMainTimer->isActive();
}

/*
* add a new set
*/
void Controller::vAddSet(QString const _dirname)
{
m_poSettings->oAddSet(_dirname);
emit listChanged();
}

/*
* delete sets
*/
void Controller::vDeleteSets(QList<int> const _list)
{
int off=0;
for (QList<int>::const_iterator i=_list.begin(); i!=_list.end(); i++)
{
m_poSettings->vDeleteSet(*i-off);
off++;
}

emit listChanged();
}

/*
* activate sets
*/
void Controller::vActivateSets(QList<int> const _list)
{
for (QList<int>::const_iterator i=_list.begin(); i!=_list.end(); i++)
{
m_poSettings->vSetState(*i, true);
}

emit listChanged();
}

/*
* unactivate sets
*/
void Controller::vUnactivateSets(QList<int> const _list)
{
for (QList<int>::const_iterator i=_list.begin(); i!=_list.end(); i++)
{
m_poSettings->vSetState(*i, false);
}

emit listChanged();
}

/*
* set only one set as active and unactive any other sets
*/
void Controller::vSetOneActiveSet(int _idx)
{
for (int i=0; i<m_poSettings->iNbSets(); i++)
{
m_poSettings->vSetState(i, i==_idx);
}

emit listChanged();
}

/*
* rename a set
*/
void Controller::vRenameSet(int _idx, QString const _name)
{
m_poSettings->vRenameSet(_idx, _name);
emit listChanged();
}


Expand Down Expand Up @@ -106,15 +189,6 @@ void Controller::vSlotUpdate()
QProcess::execute(cmd);
}

/*
* new version available
*/
void Controller::vSlotNewVersion(QString _ver)
{
m_poVCThread->exit();
emit newVersionAvailable(_ver);
}

/*
* get a random file among all active sets
*/
Expand Down Expand Up @@ -147,18 +221,6 @@ QString const Controller::sGetRandomFile(int _total)
return sPath;
}

/*
* get footer text, with hyperlinks
*/
QString const Controller::sGetStatusText() const
{
QString msg = "<a href='"+QString::fromAscii(APP_HOMEPAGE)+"'>"+QString::fromAscii(APP_NAME)+"</a>";
msg+= " "+QString::fromAscii(APP_VERSION);
msg+= " | <a href='http://www.realtimesoft.com/ultramon'>UltraMon</a> "+m_poSettings->sEnv("umversion");
return msg;
}


/*
* generate .wallpaper file
* _files must contains exactly m_iNbWallpapers elements
Expand Down
15 changes: 10 additions & 5 deletions controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,31 @@ class Controller : public QObject
Settings* m_poSettings;

QTimer* m_poMainTimer;
QThread* m_poVCThread;

mt19937 m_oRandom; // mersenne_twister

public:
Controller(Settings* _data);

void vStart();

Settings* const settings() const { return m_poSettings; }

bool const bIsRunning() const { return m_poMainTimer->isActive(); }
QString const sGetRandomFile(int _total=-1);
QString const sGetStatusText() const;

void vStartTimer(bool _keepPause=false);
void vStartPause();
bool bStartPause();
void vGenerateFile(QVector<QString> _files);

void vAddSet(QString const _dirname);
void vDeleteSets(QList<int> const _list);
void vActivateSets(QList<int> const _list);
void vUnactivateSets(QList<int> const _list);
void vSetOneActiveSet(int _idx);
void vRenameSet(int _idx, QString const _name);

public slots:
void vSlotUpdate();
void vSlotNewVersion(QString _ver);

signals:
void listChanged();
Expand Down
14 changes: 10 additions & 4 deletions doc/readme.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
UltraMon Wallpaper Autochanger

Version : 1.0
Release date : March 2nd, 2013
Version : 1.1
Release date : May 12th, 2013
Author : Damien "Mistic" Sorel
Website : http://www.strangeplanet.fr
License : GNU General Public License Version 3
Expand Down Expand Up @@ -53,13 +53,19 @@ Troubleshouting

Known bugs
==========
- When changing the wallpaper, the software freezes for some seconds,
that's because I don't use multi-threading.
- When changing the wallpaper, with file check activated, the software freezes
for some seconds, that's because I don't use multi-threading.


Changelog
=========

--- 1.1 (12/05/2013)
- fixed: use better shuffle
- new: add version checker
- new: add quick switch menu in tray con
- code optimizations

--- 1.0 (02/03/2013)
- fixed: multi delete doesn't work correclty

Expand Down
7 changes: 3 additions & 4 deletions errorwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ ErrorWidget::ErrorWidget(QWidget* _parent, Controller* _poCtrl) : QWidget(_paren

m_poEditPath = NULL;

int iState = m_poCtrl->settings()->iState();


QGridLayout* poMainLayout = new QGridLayout(); // 6 columns

Expand All @@ -42,6 +40,8 @@ ErrorWidget::ErrorWidget(QWidget* _parent, Controller* _poCtrl) : QWidget(_paren
QSpacerItem* poSpacer = new QSpacerItem(100, 100, QSizePolicy::Ignored, QSizePolicy::Ignored);
poMainLayout->addItem(poSpacer, 2, 0, 1, 6);

int iState = m_poCtrl->settings()->iState();

// ASK ULTRAMON.EXE PATH
if (iState & UM_NOT_INSTALLED)
{
Expand Down Expand Up @@ -99,8 +99,7 @@ void ErrorWidget::vSlotSubmit()

if (m_poCtrl->settings()->bSetExePath(filename))
{
MainWindow* w = qobject_cast<MainWindow*>(parent());
w->vInit();
emit pathSaved();
}
else
{
Expand Down
3 changes: 3 additions & 0 deletions errorwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ class ErrorWidget : public QWidget
public slots:
void vSlotBrowse();
void vSlotSubmit();

signals:
void pathSaved();
};

#endif // ERRORWIDGET_H
Binary file added images/quick.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 988cdf3

Please sign in to comment.