Skip to content

Commit

Permalink
configurable hotkeys + help
Browse files Browse the repository at this point in the history
  • Loading branch information
mistic100 committed Sep 9, 2013
1 parent 0b24720 commit 632c7a8
Show file tree
Hide file tree
Showing 18 changed files with 175 additions and 41 deletions.
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,21 @@ License : GNU General Public License Version 3


## Troubleshouting
Q: When I launch UMWP Autochanger, the window doesn't appear.
Q: When I launch UMWP Autochanger, the window doesn't appear.
A: When you have already registered sets, the window automatically minimize to the system bar, double-click on the icon (or right-click => "Show") to open it. This behavior can be changed on the "Options" menu.

Q: Can I rename a set ?
Q: Can I rename a set ?
A: Yes. Double-click on it's name, you will be asked to enter the new name.

Q: How hotkeys work ?
A: Hotkeys allows you two quickly change witch set is activated from the keyboard even when the application window is hidden. You can configure which keys must be pressed in the "Options" menu. Say you choosed Shift+Ctrl, press Shift+Ctrl+1 to activate the first set, Shift+Ctrl+2 for the second set, and so on. Only the 9 first sets can be activated from the keyboard.

Q: How can I unactivate hotkeys ?
A: Uncheck all keys in the "Options" menu.

Q: Can I reorder sets ?
A: Yes. Simply drag & drop them.


## Known bugs
* When changing the wallpaper, with file check activated, the software freezes for some seconds, that's because I don't use multi-threading.
Expand Down
1 change: 1 addition & 0 deletions src/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/*.user
8 changes: 8 additions & 0 deletions src/UMWP_Autochanger.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
<file alias="hide">images/hide.png</file>
<file alias="refresh">images/refresh.png</file>
<file alias="quick">images/quick.png</file>
<file alias="key_alt">images/key_alt.png</file>
<file alias="key_ctrl">images/key_ctrl.png</file>
<file alias="key_shift">images/key_shift.png</file>
<file alias="key_win">images/key_win.png</file>
<file alias="key_alt_on">images/key_alt_on.png</file>
<file alias="key_ctrl_on">images/key_ctrl_on.png</file>
<file alias="key_shift_on">images/key_shift_on.png</file>
<file alias="key_win_on">images/key_win_on.png</file>
</qresource>
<qresource prefix="/lang">
<file alias="en">lang/en.qm</file>
Expand Down
Binary file added src/images/key_alt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/key_alt_on.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/key_ctrl.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/key_ctrl_on.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/key_shift.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/key_shift_on.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/key_win.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/key_win_on.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/keys.psd
Binary file not shown.
27 changes: 26 additions & 1 deletion src/lang/help_en.htm
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
<style>
dt { font-weight:bold; }
dd { margin-bottom:1em; margin-left:1em; }
</style>

<p>
Created by Damien "Mistic" Sorel.<br>
&copy; 2013 <a href="http://strangeplanet.fr">StrangePlanet.fr</a><br>
Licenced under <a href="http://www.gnu.org/licenses/gpl-3.0.txt">GNU General Public License Version 3</a><br>
</p>
</p>

<hr>

<h2>Help</h2>
<dl>
<dt>When I launch UMWP Autochanger, the window doesn't appear.</dt>
<dd>When you have already registered sets, the window automatically minimize to the system bar, double-click on the icon (or right-click => "Show") to open it. This behavior can be changed on the "Options" menu.</dd>

<dt>Can I rename a set ?</dt>
<dd>Yes. Double-click on it's name, you will be asked to enter the new name.</dd>

<dt>How hotkeys work ?</dt>
<dd>Hotkeys allows you two quickly change witch set is activated from the keyboard even when the application window is hidden. You can configure which keys must be pressed in the "Options" menu. Say you choosed <i>hift+Ctrl</i>, press <i>Shift+Ctrl+1</i> to activate the first set, <i>Shift+Ctrl+2</i> for the second set, and so on. Only the 9 first sets can be activated from the keyboard.</dd>

<dt>How can I unactivate hotkeys ?</dt>
<dd>Uncheck all keys in the "Options" menu.</dd>

<dt>Can I reorder sets ?</dt>
<dd>Yes. Simply drag & drop them.</dd>
</dl>
31 changes: 28 additions & 3 deletions src/lang/help_fr.htm
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
<style>
dt { font-weight:bold; }
dd { margin-bottom:1em; margin-left:1em; }
</style>

<p>
Cr&eacute;&eacute; par Damien "Mistic" Sorel.<br>
Créé par Damien "Mistic" Sorel.<br>
&copy; 2013 <a href="http://strangeplanet.fr">StrangePlanet.fr</a><br>
Publi&eacute; sous <a href="http://www.gnu.org/licenses/gpl-3.0.txt">GNU General Public License Version 3</a><br>
</p>
Publié sous <a href="http://www.gnu.org/licenses/gpl-3.0.txt">GNU General Public License Version 3</a><br>
</p>

<hr>

<h3>Aide</h3>
<dl>
<dt>Quand je démarre UMWP Autochanger, aucune fenêtre n'apparaît.</dt>
<dd>Si vous avez déjà enregistré des des sets, la fenêtre est automatiquement réduite dans la zone système, double-cliquez sur l'icône pour l'afficher (ou faites clic-droit => "Afficher"). Ce comportement peut être changé dans le menu "Options".</dd>

<dt>Puis-je renommer un set ?</dt>
<dd>Oui. Double-cliquez sur son nom, il vous sera demandé de choisir le nouveau nom.</dd>

<dt>Comment les raccourcis fonctionnent ?</dt>
<dd>Les raccourcis vous permettez de changer le set actif depuis le clavier même quand la fenêtre de l'application est masquée. Vous pouvez configurer les touches des raccourcis dans le menu "Options". Si par exemple vous avez choisi <i>Maj+Ctrl</i>, appuyez sur <i>Maj+Ctrl+1</i> pour activer le premier set, <i>Maj+Ctrl+2</i> pour le second set, etc. Seuls les 9 premiers sets peuvent être activés depuis le clavier.</dd>

<dt>Comment désactiver les raccourcis ?</dt>
<dd>Décochez toutes les touches dans le menu "Options".</dd>

<dt>Puis-je réordonner les sets ?</dt>
<dd>Oui. Simplement par glisser-déposer.</dd>
</dl>
124 changes: 95 additions & 29 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ MainWindow::MainWindow(Controller* _oCtrl) : QMainWindow(0)
// MENUBAR
m_poMenuBar = new QMenuBar(this);

QAction* poActionQuit1 = m_poMenuBar->addAction(tr("Quit"));
m_poActionPause1 = m_poMenuBar->addAction(tr("Pause"));
m_poActionHide1 = m_poMenuBar->addAction(tr("Hide"));
m_poMenuBar->addSeparator();
m_poOptionsMenu = m_poMenuBar->addMenu(tr("Options"));
m_poMenuBar->addSeparator();
QAction* poActionHelp = m_poMenuBar->addAction(tr("?"));
QAction* poActionQuit1 = m_poMenuBar->addAction(tr("Quit"));
m_poActionPause1 = m_poMenuBar->addAction(tr("Pause"));
m_poActionHide1 = m_poMenuBar->addAction(tr("Hide"));
m_poMenuBar->addSeparator();
m_poOptionsMenu = m_poMenuBar->addMenu(tr("Options"));
m_poMenuBar->addSeparator();
QAction* poActionHelp = m_poMenuBar->addAction(tr("?"));

connect(poActionQuit1, SIGNAL(triggered()), this, SLOT(vSlotQuit()));
connect(m_poActionHide1, SIGNAL(triggered()), this, SLOT(vSlotToggleWindow()));
Expand All @@ -64,26 +64,62 @@ MainWindow::MainWindow(Controller* _oCtrl) : QMainWindow(0)
QAction* poOptionCheckFiles = m_poOptionsMenu->addAction(tr("Check files periodically"));
QAction* poOptionCheckUpdates = m_poOptionsMenu->addAction(tr("Check updates"));
QAction* poOptionAutostart = m_poOptionsMenu->addAction(tr("Start with Windows"));
QMenu* poHotkeysMenu = m_poOptionsMenu->addMenu(tr("Hotkeys"));

QIcon icon_alt = QIcon(":/img/key_alt");
icon_alt.addPixmap(QPixmap(":/img/key_alt_on"), QIcon::Normal, QIcon::On);
QIcon icon_ctrl = QIcon(":/img/key_ctrl");
icon_ctrl.addPixmap(QPixmap(":/img/key_ctrl_on"), QIcon::Normal, QIcon::On);
QIcon icon_shift = QIcon(":/img/key_shift");
icon_shift.addPixmap(QPixmap(":/img/key_shift_on"), QIcon::Normal, QIcon::On);
QIcon icon_win = QIcon(":/img/key_win");
icon_win.addPixmap(QPixmap(":/img/key_win_on"), QIcon::Normal, QIcon::On);

QAction* poHotkeysAlt = poHotkeysMenu->addAction(icon_alt, tr("Alt"));
QAction* poHotkeysCtrl = poHotkeysMenu->addAction(icon_ctrl, tr("Ctrl"));
QAction* poHotkeysShift = poHotkeysMenu->addAction(icon_shift, tr("Shift"));
QAction* poHotkeysWin = poHotkeysMenu->addAction(icon_win, tr("Win"));

poOptionMinimize->setCheckable(true);
poOptionCheckFiles->setCheckable(true);
poOptionCheckUpdates->setCheckable(true);
poOptionAutostart->setCheckable(true);

poHotkeysAlt->setCheckable(true);
poHotkeysCtrl->setCheckable(true);
poHotkeysShift->setCheckable(true);
poHotkeysWin->setCheckable(true);

poOptionMinimize->setChecked(m_poCtrl->settings()->bParam("minimize"));
poOptionCheckFiles->setChecked(m_poCtrl->settings()->bParam("check"));
poOptionCheckUpdates->setChecked(m_poCtrl->settings()->bParam("check_updates"));
poOptionAutostart->setChecked(m_poCtrl->settings()->bIsAutostart());

int hotkey = m_poCtrl->settings()->iParam("hotkey");
poHotkeysAlt->setChecked(hotkey & MOD_ALT);
poHotkeysCtrl->setChecked(hotkey & MOD_CONTROL);
poHotkeysShift->setChecked(hotkey & MOD_SHIFT);
poHotkeysWin->setChecked(hotkey & MOD_WIN);

poOptionMinimize->setProperty("name", "minimize");
poOptionCheckFiles->setProperty("name", "check");
poOptionCheckUpdates->setProperty("name", "check_updates");
poOptionAutostart->setProperty("name", "autostart");

connect(poOptionMinimize, SIGNAL(toggled(bool)), this, SLOT(vSlotOptionToggled(bool)));
connect(poOptionCheckFiles, SIGNAL(toggled(bool)), this, SLOT(vSlotOptionToggled(bool)));
connect(poOptionCheckUpdates, SIGNAL(toggled(bool)), this, SLOT(vSlotOptionToggled(bool)));
connect(poOptionAutostart, SIGNAL(toggled(bool)), this, SLOT(vSlotOptionToggled(bool)));
poHotkeysAlt->setProperty("key", MOD_ALT);
poHotkeysCtrl->setProperty("key", MOD_CONTROL);
poHotkeysShift->setProperty("key", MOD_SHIFT);
poHotkeysWin->setProperty("key", MOD_WIN);

connect(poOptionMinimize, SIGNAL(toggled(bool)), this, SLOT(vSlotOptionToggled(bool)));
connect(poOptionCheckFiles, SIGNAL(toggled(bool)), this, SLOT(vSlotOptionToggled(bool)));
connect(poOptionCheckUpdates, SIGNAL(toggled(bool)), this, SLOT(vSlotOptionToggled(bool)));
connect(poOptionAutostart, SIGNAL(toggled(bool)), this, SLOT(vSlotOptionToggled(bool)));

connect(poHotkeysAlt, SIGNAL(toggled(bool)), this, SLOT(vSlotHotkeyToggled(bool)));
connect(poHotkeysCtrl, SIGNAL(toggled(bool)), this, SLOT(vSlotHotkeyToggled(bool)));
connect(poHotkeysShift, SIGNAL(toggled(bool)), this, SLOT(vSlotHotkeyToggled(bool)));
connect(poHotkeysWin, SIGNAL(toggled(bool)), this, SLOT(vSlotHotkeyToggled(bool)));

if (!(m_poCtrl->settings()->bCanAddShortcut()))
{
Expand Down Expand Up @@ -117,13 +153,8 @@ MainWindow::MainWindow(Controller* _oCtrl) : QMainWindow(0)
m_poTrayIcon->setContextMenu(poTrayMenu);


// register global hotkey if configured
if (m_poCtrl->settings()->iParam("safe_mod", 16) > 0
&& m_poCtrl->settings()->iParam("safe_vk", 16) > 0
&& !m_poCtrl->settings()->sParam("safe_set").isEmpty())
{
RegisterHotKey(winId(), 100, m_poCtrl->settings()->iParam("safe_mod", 16) | MOD_NOREPEAT, m_poCtrl->settings()->iParam("safe_vk", 16));
}
// register global hotkeys
vRegisterHotkeys();
}

/*
Expand Down Expand Up @@ -177,6 +208,29 @@ void MainWindow::vShowMain()
}
}

/*
* register hotkeys 1 to 9
*/
void MainWindow::vRegisterHotkeys()
{
int hotkey = m_poCtrl->settings()->iParam("hotkey");

if (hotkey > 0)
{
for (int i=0; i<9; i++)
{
RegisterHotKey(winId(), 100 + i, hotkey | MOD_NOREPEAT, 0x31 + i);
}
}
else
{
for (int i=0; i<9; i++)
{
UnregisterHotKey(winId(), 100 + i);
}
}
}

/*
* update the quick switch menu
*/
Expand Down Expand Up @@ -208,7 +262,6 @@ void MainWindow::vSlotTrayQuickClicked()
int idx = poAction->data().toInt();

m_poCtrl->vSetOneActiveSet(idx);

vSlotApply();
}

Expand Down Expand Up @@ -354,6 +407,27 @@ void MainWindow::vSlotOptionToggled(bool _c)
m_poCtrl->settings()->vSetParam(sOptionName, _c);
}

/*
* hotkeys changed
*/
void MainWindow::vSlotHotkeyToggled(bool _c)
{
QAction* poAction = (QAction*)(QObject::sender());
int mod = poAction->property("key").toInt();
int hotkey = m_poCtrl->settings()->iParam("hotkey");

if (_c)
{
hotkey |= mod;
}
else
{
hotkey &= ~mod;
}

m_poCtrl->settings()->vSetParam("hotkey", hotkey);
vRegisterHotkeys();
}

/*
* the delay value changed
Expand Down Expand Up @@ -431,16 +505,8 @@ bool MainWindow::winEvent(MSG* message, long*)
switch (message->message)
{
case WM_HOTKEY:
for (int i=0; i<m_poCtrl->settings()->iNbSets(); i++)
{
Set* poSet = m_poCtrl->settings()->poGetSet(i);
if (poSet->name().compare(m_poCtrl->settings()->sParam("safe_set")) == 0)
{
idx = i;
break;
}
}
if (idx > -1)
idx = message->wParam - 100;
if (idx >=0 && idx < m_poCtrl->settings()->iNbSets())
{
m_poCtrl->vSetOneActiveSet(idx);
vSlotApply();
Expand Down
2 changes: 2 additions & 0 deletions src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class MainWindow : public QMainWindow

public:
MainWindow(Controller* _oCtrl);
void vRegisterHotkeys();

protected:
void showEvent(QShowEvent*) { resize(m_poCtrl->settings()->oWindowSize()); }
Expand All @@ -55,6 +56,7 @@ public slots:
void vSlotShowHelp();

void vSlotOptionToggled(bool _c);
void vSlotHotkeyToggled(bool _c);
void vSlotDelayChanged(int _val);

void vSlotTrayAction(QSystemTrayIcon::ActivationReason _reason);
Expand Down
8 changes: 3 additions & 5 deletions src/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ Settings::Settings()
m_options["check"] = true;
m_options["check_updates"] = true;
m_options["msgcount"] = 0;
m_options["safe_mod"] = "0x00";
m_options["safe_vk"] = "0x00";
m_options["safe_set"] = "";
m_options["hotkey"] = MOD_CONTROL | MOD_SHIFT;

m_env["wallpath"] = QVariant();
m_env["bmppath"] = QVariant();
Expand Down Expand Up @@ -61,9 +59,9 @@ bool const Settings::bParam(QString const key) const
return m_options.value(key, false).toBool();
}

int const Settings::iParam(QString const key, int _base) const
int const Settings::iParam(QString const key) const
{
return m_options.value(key, 0).toString().toInt(0, _base);
return m_options.value(key, 0).toInt();
}

QString const Settings::sParam(QString const key) const
Expand Down
2 changes: 1 addition & 1 deletion src/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Settings

QString const sEnv(QString const _key) const;
bool const bEnv(QString const _key) const;
int const iEnv(QString const _key) const;
int const iEnv(QString const _key, int _base=10) const;

Set* poGetSet(int _i) const { return m_oSets.at(_i); }
int const iNbSets() const { return m_oSets.size(); }
Expand Down

0 comments on commit 632c7a8

Please sign in to comment.