Browse Source
This application was written in quite a hurry. It works, but I intend to do more work on it. Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>master
commit
f134cdde34
6 changed files with 236 additions and 0 deletions
@ -0,0 +1,28 @@
|
||||
cmake_minimum_required( VERSION 2.8.12 ) |
||||
|
||||
project( tdetimer ) |
||||
set( VERSION 1.0.0 ) |
||||
|
||||
# include needed modules |
||||
include( FindPkgConfig ) |
||||
include( CheckFunctionExists ) |
||||
include( CheckSymbolExists ) |
||||
include( CheckIncludeFile ) |
||||
include( CheckLibraryExists ) |
||||
include( CheckCSourceCompiles ) |
||||
include( CheckCXXSourceCompiles ) |
||||
|
||||
set( CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules" ) |
||||
include( TDEMacros ) |
||||
include( TDESetupPaths ) |
||||
tde_setup_paths( ) |
||||
|
||||
# configure checks |
||||
include( ConfigureChecks.cmake ) |
||||
|
||||
# compiler flags |
||||
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TQT_CXX_FLAGS}" ) |
||||
set( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined" ) |
||||
set( CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--no-undefined" ) |
||||
|
||||
add_subdirectory( src ) |
@ -0,0 +1,11 @@
|
||||
# TQt/TDE |
||||
find_package( TQt ) |
||||
find_package( TDE ) |
||||
|
||||
# Additional checks |
||||
tde_setup_architecture_flags( ) |
||||
|
||||
include(TestBigEndian) |
||||
test_big_endian(WORDS_BIGENDIAN) |
||||
|
||||
tde_setup_largefiles( ) |
@ -0,0 +1,18 @@
|
||||
include_directories( |
||||
${CMAKE_BINARY_DIR} |
||||
${CMAKE_CURRENT_BINARY_DIR} |
||||
${CMAKE_CURRENT_SOURCE_DIR} |
||||
${TDE_INCLUDE_DIR} |
||||
${TQT_INCLUDE_DIRS} |
||||
) |
||||
|
||||
link_directories( |
||||
${TQT_LIBRARY_DIRS} |
||||
${TDE_LIB_DIR} |
||||
) |
||||
|
||||
tde_add_executable( ${PROJECT_NAME} AUTOMOC |
||||
SOURCES tdetimer.cpp main.cpp |
||||
LINK tdeui-shared tdecore-shared |
||||
DESTINATION ${BIN_INSTALL_DIR} |
||||
) |
@ -0,0 +1,24 @@
|
||||
#include <tdeapplication.h> |
||||
#include <tdeaboutdata.h> |
||||
#include <tdecmdlineargs.h> |
||||
|
||||
#include <kdebug.h> |
||||
|
||||
#include "tdetimer.h" |
||||
|
||||
int main( int argc, char *argv[] ) |
||||
{ |
||||
TDEAboutData about( |
||||
"tdetimer", "TDE Timer", "1.0.0", |
||||
"A little timer for TDE", |
||||
TDEAboutData::License_GPL, |
||||
"Copyright (c) 2021 Mavridis Philippe" |
||||
); |
||||
|
||||
TDECmdLineArgs::init(argc, argv, &about); |
||||
TDEApplication app( argc, argv ); |
||||
|
||||
app.setMainWidget( new TDETimer() ); |
||||
|
||||
return app.exec(); |
||||
} |
@ -0,0 +1,115 @@
|
||||
#include <tqpushbutton.h> |
||||
#include <tqlistbox.h> |
||||
#include <tqlayout.h> |
||||
#include <tqtimer.h> |
||||
|
||||
#include <tdeapplication.h> |
||||
#include <tdemessagebox.h> |
||||
#include <kiconloader.h> |
||||
#include <ktimewidget.h> |
||||
#include <tdelocale.h> |
||||
|
||||
#include "tdetimer.h" |
||||
|
||||
TDETimer::TDETimer() |
||||
{ |
||||
TDEIconLoader *il = kapp->iconLoader(); |
||||
TQVBoxLayout *vlayout = new TQVBoxLayout(this); |
||||
TQHBoxLayout *hlayout = new TQHBoxLayout(this); |
||||
vlayout->addLayout(hlayout); |
||||
|
||||
time = new KTimeWidget(this); |
||||
connect( time, SIGNAL(valueChanged(const TQTime&)), this, SLOT(slotSetTime(const TQTime&)) ); |
||||
hlayout->addWidget(time); |
||||
|
||||
start = new TQPushButton(this, "start"); |
||||
start->setPixmap(il->loadIcon("media-playback-start", TDEIcon::Toolbar)); |
||||
start->setToggleButton(true); |
||||
start->setFocus(); |
||||
hlayout->addWidget(start); |
||||
|
||||
reset = new TQPushButton(this, "reset"); |
||||
reset->setPixmap(il->loadIcon("reload", TDEIcon::Toolbar)); |
||||
hlayout->addWidget(reset); |
||||
|
||||
connect( start, SIGNAL(clicked()), this, SLOT(slotStartStop()) ); |
||||
connect( reset, SIGNAL(clicked()), this, SLOT(slotReset()) ); |
||||
|
||||
step = new TQPushButton(this, "step"); |
||||
step->setPixmap(il->loadIcon("bookmark", TDEIcon::Toolbar)); |
||||
hlayout->addWidget(step); |
||||
|
||||
stepl = new TQListBox(this, "steplist"); |
||||
vlayout->addWidget(stepl); |
||||
connect( step, SIGNAL(clicked()), this, SLOT(slotStep()) ); |
||||
connect( stepl, SIGNAL(doubleClicked(TQListBoxItem*)), this, SLOT(slotSetFromStep(TQListBoxItem*)) ); |
||||
|
||||
TQTime timer; |
||||
pulse = new TQTimer(this); |
||||
connect( pulse, SIGNAL(timeout()), this, SLOT(slotTimeout()) ); |
||||
|
||||
setCaption( i18n("TDE Timer") ); |
||||
|
||||
show(); |
||||
} |
||||
|
||||
TDETimer::~TDETimer() |
||||
{} |
||||
|
||||
void TDETimer::slotStartStop() |
||||
{ |
||||
if( pulse->isActive() ) |
||||
pulse->stop(); |
||||
else |
||||
pulse->start(1000); |
||||
} |
||||
|
||||
void TDETimer::slotReset() |
||||
{ |
||||
int result = KMessageBox::warningYesNo( |
||||
this, |
||||
i18n("Are you sure you want to reset the timer and steps?"), |
||||
i18n("Confirm Reset") |
||||
); |
||||
|
||||
if( result != KMessageBox::Yes ) return; |
||||
|
||||
if( start->isOn() ) |
||||
start->setOn(false); |
||||
pulse->stop(); |
||||
stepl->clear(); |
||||
timer.setHMS(0, 0, 0); |
||||
time->setTime(timer); |
||||
} |
||||
|
||||
void TDETimer::slotSetTime(const TQTime& t) |
||||
{ |
||||
timer = t; |
||||
} |
||||
|
||||
void TDETimer::slotSetFromStep(TQListBoxItem* step) |
||||
{ |
||||
int h, m, s; |
||||
TQStringList step_time = TQStringList::split(":", step->text()); |
||||
h = TQString(step_time[0]).toInt(); |
||||
m = TQString(step_time[1]).toInt(); |
||||
s = TQString(step_time[2]).toInt(); |
||||
|
||||
timer.setHMS(h, m, s); |
||||
time->setTime(timer); |
||||
} |
||||
|
||||
void TDETimer::slotTimeout() |
||||
{ |
||||
timer = timer.addSecs(1); |
||||
time->setTime(timer); |
||||
} |
||||
|
||||
void TDETimer::slotStep() |
||||
{ |
||||
TQString time_str = timer.toString("hh:mm:ss"); |
||||
if( stepl->findItem(time_str) == 0 ) |
||||
stepl->insertItem(time_str); |
||||
} |
||||
|
||||
#include "tdetimer.moc" |
@ -0,0 +1,40 @@
|
||||
#ifndef __TDETIMER_H |
||||
#define __TDETIMER_H |
||||
|
||||
#include <tqdatetime.h> |
||||
#include <tqwidget.h> |
||||
|
||||
class KTimeWidget; |
||||
class TQPushButton; |
||||
class TQListBox; |
||||
class TQListBoxItem; |
||||
class TQTimer; |
||||
|
||||
class TDETimer : public TQWidget { |
||||
TQ_OBJECT |
||||
public: |
||||
TDETimer(); |
||||
~TDETimer(); |
||||
|
||||
public slots: |
||||
void slotStartStop(); |
||||
void slotReset(); |
||||
void slotSetTime(const TQTime& t); |
||||
void slotSetFromStep(TQListBoxItem* item); |
||||
void slotStep(); |
||||
|
||||
private slots: |
||||
void slotTimeout(); |
||||
|
||||
private: |
||||
KTimeWidget* time; |
||||
TQPushButton* start; |
||||
TQPushButton* pause; |
||||
TQPushButton* reset; |
||||
TQPushButton* step; |
||||
TQListBox* stepl; |
||||
TQTimer* pulse; |
||||
TQTime timer; |
||||
}; |
||||
|
||||
#endif // __TDETIMER_H
|
Loading…
Reference in new issue