-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 3595c17
Showing
37 changed files
with
1,231 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# These are some examples of commonly ignored file patterns. | ||
# You should customize this list as applicable to your project. | ||
# Learn more about .gitignore: | ||
# https://www.atlassian.com/git/tutorials/saving-changes/gitignore | ||
|
||
# Node artifact files | ||
node_modules/ | ||
dist/ | ||
|
||
# Compiled Java class files | ||
*.class | ||
|
||
# Compiled Python bytecode | ||
*.py[cod] | ||
|
||
# Log files | ||
*.log | ||
|
||
# Package files | ||
*.jar | ||
|
||
# Maven | ||
target/ | ||
dist/ | ||
|
||
# JetBrains IDE | ||
.idea/ | ||
|
||
# Unit test reports | ||
TEST*.xml | ||
|
||
# Generated by MacOS | ||
.DS_Store | ||
|
||
# Generated by Windows | ||
Thumbs.db | ||
|
||
# Applications | ||
*.app | ||
*.exe | ||
*.war | ||
|
||
# Large media files | ||
*.mp4 | ||
*.tiff | ||
*.avi | ||
*.flv | ||
*.mov | ||
*.wmv | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#------------------------------------------------- | ||
# | ||
# Project created by QtCreator 2021-07-21T11:28:27 | ||
# | ||
#------------------------------------------------- | ||
|
||
QT += core gui | ||
|
||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets multimedia | ||
|
||
TARGET = NewYearCountdown | ||
TEMPLATE = app | ||
CONFIG += c++11 | ||
|
||
SOURCES += main.cpp\ | ||
mainwindow.cpp \ | ||
Settings/settings.cpp \ | ||
mycalendar.cpp \ | ||
updatelefttimethread.cpp | ||
|
||
HEADERS += mainwindow.h \ | ||
Settings/settings.h \ | ||
mycalendar.h \ | ||
updatelefttimethread.h | ||
|
||
RESOURCES += \ | ||
appresources.qrc | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
NewYearCountdown 1.0 | ||
================ | ||
Last update : 8 augost 2021 | ||
|
||
AUTHOR | ||
====== | ||
Kobzev Iliya aka TechnoMag ([email protected]) | ||
|
||
DESCRIPTION | ||
=========== | ||
Desktop application for coundown daya and time to New Year | ||
|
||
Application is supported skins. For apply skins, copy skins | ||
directory to pash $HOME/.newyear and restart application. | ||
|
||
MAKE PROGRAM FROM SOURCE | ||
======================== | ||
Project for make program is ready! | ||
You must only run "make" command in source directory for create binary file! | ||
|
||
CONTACTS | ||
======== | ||
[email protected] | ||
|
||
LICENSE: | ||
======== | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License; | ||
|
||
************** | ||
Copyright (C) TechnoMag 21 july 2021 | ||
************** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include "settings.h" | ||
|
||
Settings::Settings() | ||
{ | ||
QSettings settings; | ||
pathToSkin = settings.value("skin").toString(); | ||
windowPosition.setX(settings.value("xpos").toInt()); | ||
windowPosition.setY(settings.value("ypos").toInt()); | ||
updateDelay = settings.value("updateDelay", 500).toInt(); | ||
bellEachHour = settings.value("bell", true).toBool(); | ||
onTop = settings.value("onTop", true).toBool(); | ||
} | ||
|
||
Settings::~Settings() | ||
{ | ||
QSettings settings; | ||
settings.setValue("skin", pathToSkin); | ||
settings.setValue("xpos", windowPosition.x()); | ||
settings.setValue("ypos", windowPosition.y()); | ||
settings.setValue("updateDelay", updateDelay); | ||
settings.setValue("bell", bellEachHour); | ||
settings.setValue("onTop", onTop); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#ifndef SETTINGS_H | ||
#define SETTINGS_H | ||
|
||
#include <QSettings> | ||
#include <QString> | ||
#include <QPoint> | ||
|
||
class Settings | ||
{ | ||
public: | ||
Settings(); | ||
~Settings(); | ||
|
||
QString pathToSkin; | ||
QPoint windowPosition; | ||
int updateDelay; | ||
bool bellEachHour; | ||
bool onTop; | ||
}; | ||
|
||
#endif // SETTINGS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<RCC> | ||
<qresource prefix="/skin"> | ||
<file>tree1.png</file> | ||
</qresource> | ||
<qresource prefix="/sound"> | ||
<file>chime.wav</file> | ||
</qresource> | ||
</RCC> |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include "mainwindow.h" | ||
#include <QApplication> | ||
#include <QVBoxLayout> | ||
#include <QBitmap> | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
QApplication a(argc, argv); | ||
QCoreApplication::setOrganizationName("TechnoMag"); | ||
QCoreApplication::setApplicationName("NewYearCountdown"); | ||
QCoreApplication::setApplicationVersion("1.0"); | ||
MainWindow mainWin; | ||
mainWin.show(); | ||
return a.exec(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,198 @@ | ||
#include "mainwindow.h" | ||
|
||
const QString PROGRAM_DIR = QDir::homePath() + "/.newyear/skins"; | ||
|
||
MainWindow::MainWindow() | ||
{ | ||
settings = new Settings(); | ||
setAttribute(Qt::WA_TranslucentBackground); | ||
updateWindowFlags(settings->onTop); | ||
move(settings->windowPosition); | ||
|
||
treeLabel = new QLabel(); | ||
treeLabel->setAttribute(Qt::WA_TranslucentBackground); | ||
treeLabel->setWindowFlags(Qt::Window | Qt::FramelessWindowHint); | ||
setCentralWidget(treeLabel); | ||
|
||
updateThread = new UpdateLeftTimeThread(); | ||
updateThread->setUpdateDelay(settings->updateDelay); | ||
updateThread->setBellEnable(settings->bellEachHour); | ||
connect(updateThread, SIGNAL(drawTree(QPixmap*)), this, SLOT(display(QPixmap*))); | ||
applySkin(settings->pathToSkin); | ||
|
||
treeLabel->setContextMenuPolicy(Qt::CustomContextMenu); | ||
initContextMenu(); | ||
connect(treeLabel, SIGNAL(customContextMenuRequested(QPoint)), | ||
SLOT(customMenuRequested(QPoint))); | ||
} | ||
|
||
MainWindow::~MainWindow() | ||
{ | ||
updateThread->deleteLater(); | ||
delete treeLabel; | ||
delete settings; | ||
} | ||
|
||
void MainWindow::initContextMenu() | ||
{ | ||
mainMenu = new QMenu(this); | ||
findSkins(); | ||
|
||
QMenu *delayMenu = new QMenu(tr("Delay"), mainMenu); | ||
|
||
QActionGroup *group = new QActionGroup(delayMenu); | ||
group->setExclusive(true); | ||
|
||
QAction *action = new QAction(tr("0.5 sec"), this); | ||
action->setObjectName("Delay1000"); | ||
action->setActionGroup(group); | ||
action->setCheckable(true); | ||
action->setChecked(settings->updateDelay == 500); | ||
connect(action, &QAction::triggered, this, &MainWindow::menuClicked); | ||
delayMenu->addAction(action); | ||
|
||
action = new QAction(tr("1 sec"), this); | ||
action->setObjectName("Delay1000"); | ||
action->setActionGroup(group); | ||
action->setCheckable(true); | ||
action->setChecked(settings->updateDelay == 1000); | ||
connect(action, &QAction::triggered, this, &MainWindow::menuClicked); | ||
delayMenu->addAction(action); | ||
|
||
action = new QAction(tr("1.5 sec"), this); | ||
action->setObjectName("Delay1500"); | ||
action->setActionGroup(group); | ||
action->setCheckable(true); | ||
action->setChecked(settings->updateDelay == 1500); | ||
connect(action, &QAction::triggered, this, &MainWindow::menuClicked); | ||
delayMenu->addAction(action); | ||
|
||
action = new QAction(tr("2 sec"), this); | ||
action->setObjectName("Delay2000"); | ||
action->setActionGroup(group); | ||
action->setCheckable(true); | ||
action->setChecked(settings->updateDelay == 2000); | ||
connect(action, &QAction::triggered, this, &MainWindow::menuClicked); | ||
delayMenu->addAction(action); | ||
|
||
mainMenu->addMenu(delayMenu); | ||
|
||
action = new QAction(tr("Bell"), this); | ||
action->setObjectName("Bell"); | ||
action->setCheckable(true); | ||
action->setChecked(settings->bellEachHour == true); | ||
connect(action, &QAction::triggered, this, &MainWindow::menuClicked); | ||
mainMenu->addAction(action); | ||
|
||
action = new QAction(tr("On top"), this); | ||
action->setObjectName("OnTop"); | ||
action->setCheckable(true); | ||
action->setChecked(settings->onTop == true); | ||
connect(action, &QAction::triggered, this, &MainWindow::menuClicked); | ||
mainMenu->addAction(action); | ||
|
||
action = new QAction(tr("Exit"), this); | ||
mainMenu->addAction(action); | ||
connect(action, &QAction::triggered, this, &QMainWindow::close); | ||
} | ||
|
||
void MainWindow::customMenuRequested(QPoint pos) { | ||
mainMenu->popup(treeLabel->mapToGlobal(pos)); | ||
} | ||
|
||
void MainWindow::menuClicked(bool checked) | ||
{ | ||
if (checked) { | ||
if (sender()->objectName().compare("Delay500") == 0) { | ||
settings->updateDelay = 500; | ||
updateThread->setUpdateDelay(500); | ||
} | ||
if (sender()->objectName().compare("Delay1000") == 0) { | ||
settings->updateDelay = 1000; | ||
updateThread->setUpdateDelay(1000); | ||
} | ||
if (sender()->objectName().compare("Delay1500") == 0) { | ||
settings->updateDelay = 1500; | ||
updateThread->setUpdateDelay(1500); | ||
} | ||
if (sender()->objectName().compare("Delay2000") == 0) { | ||
settings->updateDelay = 2000; | ||
updateThread->setUpdateDelay(2000); | ||
} | ||
} | ||
if (sender()->objectName().compare("Bell") == 0) { | ||
settings->bellEachHour = checked; | ||
updateThread->setBellEnable(checked); | ||
} | ||
if (sender()->objectName().compare("OnTop") == 0) { | ||
settings->onTop = checked; | ||
} | ||
} | ||
|
||
void MainWindow::skinClicked(bool checked) | ||
{ | ||
if (checked) { | ||
applySkin(sender()->objectName()); | ||
} | ||
} | ||
|
||
void MainWindow::display(QPixmap *treePixmap) | ||
{ | ||
treeLabel->setPixmap(*treePixmap); | ||
treeLabel->setFixedWidth(treePixmap->width()); | ||
treeLabel->setFixedHeight(treePixmap->height()); | ||
setFixedWidth(treePixmap->width()); | ||
setFixedHeight(treePixmap->height()); | ||
setMask(treePixmap->mask()); | ||
} | ||
|
||
void MainWindow::findSkins() | ||
{ | ||
QDir dir(PROGRAM_DIR); | ||
if (dir.exists(PROGRAM_DIR) == false) { | ||
dir.mkpath(PROGRAM_DIR); | ||
} | ||
QDirIterator it(PROGRAM_DIR, | ||
QStringList() << "*", | ||
QDir::NoDotAndDotDot | QDir::Dirs); | ||
QMenu *skinsMenu = nullptr; | ||
QActionGroup *group = nullptr; | ||
QAction *action = nullptr; | ||
if (it.hasNext()) { | ||
skinsMenu = new QMenu(tr("Skins"), mainMenu); | ||
group = new QActionGroup(skinsMenu); | ||
group->setExclusive(true); | ||
} | ||
while (it.hasNext()) { | ||
QString path = it.next(); | ||
QDir skin(path); | ||
action = new QAction(skin.dirName(), this); | ||
action->setObjectName(path); | ||
action->setActionGroup(group); | ||
action->setCheckable(true); | ||
action->setChecked(false); | ||
connect(action, &QAction::triggered, this, &MainWindow::skinClicked); | ||
skinsMenu->addAction(action); | ||
} | ||
if (skinsMenu != nullptr) { | ||
mainMenu->addMenu(skinsMenu); | ||
} | ||
} | ||
|
||
void MainWindow::applySkin(QString pathToSkin) | ||
{ | ||
updateThread->applySkin(pathToSkin); | ||
if (!updateThread->isRunning()) { | ||
updateThread->start(); | ||
} | ||
settings->pathToSkin = pathToSkin; | ||
} | ||
|
||
void MainWindow::updateWindowFlags(bool onTop) | ||
{ | ||
if (onTop) { | ||
setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint); | ||
} else { | ||
setWindowFlags(Qt::Window | Qt::FramelessWindowHint); | ||
} | ||
} |
Oops, something went wrong.