Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
smariel committed Nov 21, 2015
0 parents commit fd228a7
Show file tree
Hide file tree
Showing 20 changed files with 967 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ignore all build content but keep the folder
build/*

#ignore the deploy folder
deploy/

#ignore all .user files
*.user

#ignore all useless icons
icons/icon.*.fw.*

29 changes: 29 additions & 0 deletions TaskBarSearch.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#-------------------------------------------------
#
# Project created by QtCreator 2015-11-11T12:41:18
#
#-------------------------------------------------

QT += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = TaskBarSearch
TEMPLATE = app

SOURCES += main.cpp\
taskbarmenu.cpp \
settings.cpp

HEADERS += taskbarmenu.h \
settings.h \
searchengine.h

FORMS += taskbarmenu.ui \
settings.ui

RESOURCES += \
resources.qrc

RC_ICONS += \
icons/icon.ico
6 changes: 6 additions & 0 deletions default.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[searchEngines]
1\name=Google
1\url="https://www.google.fr/#q=%s"
2\name=RS
2\url="http://fr.rs-online.com/web/c/?searchTerm=%s"
size=2
69 changes: 69 additions & 0 deletions deploy_release.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
@echo off
echo -------------------------------------------------
echo Don't forget to add "C:\Qt\Tools\mingw492_32\bin"
echo and "C:\Qt\5.5\android_x86\bin"
echo to your path environement variable
echo -------------------------------------------------
echo.
echo.



echo -------------------------------------------------
echo COMPILATION
echo -------------------------------------------------
echo.

rem // compilation of release version
cd build
qmake.exe ../TaskBarSearch.pro -r -spec win32-g++
mingw32-make.exe
cd ..



echo.
echo.
echo.
echo -------------------------------------------------
echo Deployment
echo -------------------------------------------------
echo.

rem // deployment with qt for windows
rmdir deploy /S /Q
mkdir deploy
mkdir deploy\TaskBarSearch
copy "build\release\TaskBarSearch.exe" "deploy\TaskBarSearch\TaskBarSearch.exe"
windeployqt --no-translations deploy/TaskBarSearch/

rem // copy some none essential files
copy "default.ini" "deploy\TaskBarSearch\default.ini"



echo.
echo.
echo.
echo -------------------------------------------------
echo ZIP
echo -------------------------------------------------
echo.

rem // Zip everything
cd deploy
"%ProgramFiles%/7-zip/7z.exe" a TaskBarSearch.zip TaskBarSearch/



echo.
echo ------------------------------------------------
echo.
echo Script over
echo.
echo You can now "/deploy/TaskBarSearch" wherever you want
echo.
echo ------------------------------------------------
echo.
pause

Binary file added icons/icon.128.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 icons/icon.16.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 icons/icon.256.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 icons/icon.32.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 icons/icon.48.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 icons/icon.64.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 icons/icon.ico
Binary file not shown.
75 changes: 75 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#include "taskbarmenu.h"
#include <QApplication>
#include <QWidgetAction>
#include <QMenu>
#include <QSystemTrayIcon>
#include <QIcon>
#include <QMessageBox>
#include <QFile>
#include <QSettings>
#include <QStandardPaths>
#include <QFileInfo>

int main(int argc, char *argv[])
{
// Init app that do not quit without opened window
QApplication a(argc, argv);
a.setQuitOnLastWindowClosed(false);

// Warn if the OS do not support system tray, then exit
if(!QSystemTrayIcon::isSystemTrayAvailable())
{
QMessageBox errorMessage(QMessageBox::Critical,
"System not supported",
"The operating system do not provide any system tray or task bar.\n\nThe application will now exit."
);
errorMessage.exec();
return(0);
}


// Configre the app, essentialy for QSettings
QCoreApplication::setOrganizationName("Sylvain-Mariel");
QCoreApplication::setOrganizationDomain("sylvain-mariel.fr");
QCoreApplication::setApplicationName("TaskBarSearch");


// Init settings
#ifdef Q_OS_WIN
// Special feature on Windows : load default settings if there is no settings.
if(!QFile::exists(QCoreApplication::applicationDirPath()+"/settings.ini"))
{
QFile::copy(QCoreApplication::applicationDirPath()+"/default.ini", QCoreApplication::applicationDirPath()+"/settings.ini");
}
QSettings settings(QCoreApplication::applicationDirPath()+"/settings.ini", QSettings::IniFormat);

// Speacial feature on Windows : overwrite auto startup setting depending on the file existance
settings.setValue("autoStartup",
QFile::exists(
QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation)
+ "/Startup/"
+ QFileInfo( QCoreApplication::applicationFilePath() ).fileName()+".lnk"));
#else
// Other OS than Windows : just create settings wherever the OS want
QSettings settings;
#endif
settings.sync();


// Create a sub-element of a menu that contain the custom UI
QWidgetAction *trayWidget = new QWidgetAction(0);
trayWidget->setDefaultWidget(new TaskBarMenu());

// Create a menu that contain the sub-element
QMenu *trayMenu = new QMenu();
trayMenu->addAction(trayWidget);

// Create a tray icon that show the menu on a right click
QSystemTrayIcon *trayIcon = new QSystemTrayIcon();
trayIcon->setContextMenu(trayMenu);
trayIcon->setIcon(QIcon(":/img/icons/icon.16.png"));
trayIcon->show();


return a.exec();
}
5 changes: 5 additions & 0 deletions resources.qrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/img">
<file>icons/icon.16.png</file>
</qresource>
</RCC>
13 changes: 13 additions & 0 deletions searchengine.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#ifndef SEARCHENGINE_H
#define SEARCHENGINE_H
#include <QString>
#include <QUrl>

struct SearchEngine {
QString name;
QString url;
};

Q_DECLARE_METATYPE(SearchEngine);

#endif // SEARCHENGINE_H
Loading

0 comments on commit fd228a7

Please sign in to comment.