Skip to content

Commit

Permalink
feat: Add new module[014758]
Browse files Browse the repository at this point in the history
  • Loading branch information
Greedysky committed Jul 27, 2020
0 parents commit a9a6b3b
Show file tree
Hide file tree
Showing 11 changed files with 916 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
*.user
*.user.*
*.aps
build-*/
*.*-pre1
*.autosave
*.*~
*.uxf
Thumbs.db
ehthumbs.db
Desktop.ini
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# TTKCalendar
![QtCreator](https://img.shields.io/badge/Coded%20with-QtCreator%20IDE-blue.svg?style=flat-square)
![License](https://img.shields.io/badge/license-GPL%20V3-yellowgreen.svg?style=flat-square)
![TTKCalendar](https://img.shields.io/badge/Greedysky-TTKCalendar-green.svg?style=flat-square)

### **|[About](https://github.com/TTKProject/TTKCalendar#usage)|[License](https://github.com/TTKProject/TTKCalendar#license)|[Screenshots](https://github.com/TTKProject/TTKCalendar#screenshots)|[Copyright](https://github.com/TTKProject/TTKCalendar#copyright)|[Contribute](https://github.com/TTKProject/TTKCalendar#how-to-contribute)|**

Usage
----
* Qt develop version be tested on Qt4.8.7 for windows-mingw 32bit
* Qt develop version be tested on Qt4.8.6 for ubuntu-linux-gcc 64bit
* Qt develop version be tested on Qt5.x for windows-mingw 32bit
* Qt develop version be tested on Qt5.x for ubuntu-linux-gcc 64bit
* Qt develop version be tested on Qt5.x for windows-msvc

| Platform | Qt & Compiler | Status |
| :---: | :---: | :---: |
| Linux | 4.8.7 GCC & 5.x GCC | ![Linux](https://img.shields.io/badge/build-passing-brightgreen.svg) |
| Windows | 4.8.7 GCC & 5.x GCC | ![Windows](https://img.shields.io/badge/build-passing-brightgreen.svg) |
| Windows | 5.x MSVC | ![Windows](https://img.shields.io/badge/build-passing-brightgreen.svg) |
| OS X | 5.x Clang | ![OSX](https://img.shields.io/badge/build-unknown-lightgrey.svg) |

# For Developers

License
---
TTKCalendar is free software licensed under the term of [Licence GPL v3](https://github.com/TTKProject/TTKCalendar/blob/master/LICENSE). If you use TTKCalendar or its constituent libraries, you must add here to the terms of the license in question.

Screenshots
----
### Demo
![Demo](https://github.com/TTKProject/TTKCalendar/blob/master/demo.jpg?raw=true)

Copyright
-------
* This file is part of the TTKCalendar project.
* Copyright (c) 2017 - 2020 Greedysky Studio.
* mail: [email protected].

How To Contribute
-------
* Fork this project on github and make a branch. Commit in that branch, and push, then create a pull request to be reviewed and merged.
* Create an issue if you have any problem when using project or you find a bug, etc.
* What you can do: translation, write document, wiki, find or fix bugs, give your idea for this project etc.
* If you want to join the project developed together, please send e-mail to me.
40 changes: 40 additions & 0 deletions TTKCalendar.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# =================================================
# * This file is part of the TTKCalendar project
# * Copyright (C) 2017 - 2020 Greedysky Studio
#
# * This program is free software; you can redistribute it and/or modify
# * it under the terms of the GNU General Public License as published by
# * the Free Software Foundation; either version 3 of the License, or
# * (at your option) any later version.
#
# * This program is distributed in the hope that it will be useful,
# * but WITHOUT ANY WARRANTY; without even the implied warranty of
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# * GNU General Public License for more details.
#
# * You should have received a copy of the GNU General Public License along
# * with this program; If not, see <http://www.gnu.org/licenses/>.
# =================================================

QT += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = TTKCalendar
TEMPLATE = app

msvc{
CONFIG +=c++11
}else{
QMAKE_CXXFLAGS += -std=c++11
}

SOURCES += \
main.cpp \
ttkapplication.cpp

HEADERS += \
ttkapplication.h

RESOURCES += \
TTKCalendar.qrc
6 changes: 6 additions & 0 deletions TTKCalendar.qrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<RCC>
<qresource prefix="/data">
<file>images/flag-cn.ico</file>
<file>images/today.ico</file>
</qresource>
</RCC>
Binary file added demo.jpg
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 images/flag-cn.ico
Binary file not shown.
Binary file added images/today.ico
Binary file not shown.
11 changes: 11 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include "ttkapplication.h"
#include <QApplication>

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
TTKApplication w;
w.show();

return a.exec();
}
69 changes: 69 additions & 0 deletions ttkapplication.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#include "ttkapplication.h"

TTKButton::TTKButton(QWidget *parent)
: QToolButton(parent)
{
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
setToolButtonStyle(Qt::ToolButtonIconOnly);
setAutoRaise(true);
}

QSize TTKButton::sizeHint() const
{
QSize size = QToolButton::sizeHint();
size.rheight() += 6;
return size;
}


TTKApplication::TTKApplication(QWidget *parent)
: QWidget(parent)
{
createPreviewGroupBox();
setWindowTitle(tr("TTKApplication"));

QGridLayout* layout = new QGridLayout(this);
layout->addWidget(m_groupBox, 0, 0);
layout->setSizeConstraint(QLayout::SetFixedSize);

m_layout->setRowMinimumHeight(0, m_calendar->sizeHint().height());
m_layout->setColumnMinimumWidth(0, m_calendar->sizeHint().width());
m_today = QDate(m_calendar->selectedDate());

setLayout(layout);
}

void TTKApplication::today()
{
m_calendar->setSelectedDate(m_today);
}

void TTKApplication::createPreviewGroupBox()
{
m_groupBox = new QGroupBox(tr("Calendar"), this);
m_calendar = new QCalendarWidget(this);
m_calendar->setMinimumDate(QDate(1900, 1, 1));
m_calendar->setMaximumDate(QDate(3000, 1, 1));
m_calendar->setGridVisible(true);

m_todayButton = new TTKButton(this);
m_todayButton->setIcon(QIcon(":/data/images/today.ico"));
m_todayButton->setToolTip(tr("Today"));
connect(m_todayButton, SIGNAL(clicked()), SLOT(today()));

m_timeZoneButton = new TTKButton(this);
m_timeZoneButton->setIcon(QIcon(":/data/images/flag-cn.ico"));

m_layout = new QGridLayout;
m_layout->addWidget(m_calendar, 0, 0, Qt::AlignCenter);

QHBoxLayout* showLayout = new QHBoxLayout;
showLayout->addWidget(m_timeZoneButton);
showLayout->addStretch();
showLayout->addWidget(m_todayButton);

QVBoxLayout* mainLayout = new QVBoxLayout;
mainLayout->addLayout(m_layout);
mainLayout->addLayout(showLayout);
m_groupBox->setLayout(mainLayout);
}
60 changes: 60 additions & 0 deletions ttkapplication.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#ifndef TTKAPPLICATION_H
#define TTKAPPLICATION_H

/* =================================================
* This file is part of the TTKCalendar project
* Copyright (C) 2017 - 2020 Greedysky Studio
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along
* with this program; If not, see <http://www.gnu.org/licenses/>.
================================================= */

#include <QGroupBox>
#include <QGridLayout>
#include <QToolButton>
#include <QCalendarWidget>

class TTKButton : public QToolButton
{
Q_OBJECT
public:
explicit TTKButton(QWidget *parent = nullptr);

protected:
virtual QSize sizeHint() const override;
};


class TTKApplication : public QWidget
{
Q_OBJECT
public:
explicit TTKApplication(QWidget *parent = nullptr);

protected Q_SLOTS:
void today();

protected:
void createPreviewGroupBox();

QGroupBox *m_groupBox;
QGridLayout *m_layout;
QCalendarWidget *m_calendar;

QDate m_today;
TTKButton *m_timeZoneButton;
TTKButton *m_todayButton;

};

#endif

0 comments on commit a9a6b3b

Please sign in to comment.