• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

ktimetracker

  • sources
  • kde-4.12
  • kdepim
  • ktimetracker
  • new
new/mainwindow.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2003 by Scott Monachello <smonach@cox.net>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the
16  * Free Software Foundation, Inc.
17  * 51 Franklin Street, Fifth Floor
18  * Boston, MA 02110-1301 USA.
19  *
20  */
21 
22 #include "mainwindow.h"
23 
24 #include <numeric>
25 #include "ui_mainwindow.h"
26 #include <QMenu>
27 #include <QString>
28 
29 #include <KAction>
30 #include <KApplication> // kapp
31 #include <KDebug>
32 #include <KGlobal>
33 #include <KIcon>
34 #include <KLocale> // i18n
35 #include <KMessageBox>
36 #include <KPushButton>
37 #include <KShortcutsDialog>
38 #include <KStandardAction>
39 #include <KStatusBar> // statusBar()
40 #include <KXMLGUIFactory>
41 #include <KActionCollection>
42 
43 #include "ktimetrackerutility.h"
44 #include "ktimetracker.h"
45 #include "task.h"
46 #include "taskview.h"
47 #include "timekard.h"
48 #include "tray.h"
49 
50 #include "timetrackerwidget.h"
51 
52 
53 /*
54 
55  Missing:
56  - reaction on click on icons in the toolbar
57  - context menu
58 
59  */
60 MainWindow::MainWindow( const QString &icsfile )
61  : QMainWindow( ),
62  m_ui(new Ui::MainWindow)
63 {
64  m_ui->setupUi(this);
65  delete m_ui->treeWidget;
66  m_ui->treeWidget=new TaskView(m_ui->centralwidget);
67  ((TaskView *) m_ui->treeWidget)->load(icsfile);
68  this->setWindowTitle(QString(icsfile));
69  m_ui->gridLayout->addWidget(m_ui->treeWidget, 1, 0, 1, 1);
70  m_ui->treeWidget->hide();
71  m_ui->treeWidget->show();
72  m_ui->ktreewidgetsearchline->show();
73  m_ui->toolBar->addAction(KIcon("document-new"),"New Task",this,SLOT(newtask()));
74  m_ui->toolBar->addAction(KIcon("subtask-new-ktimetracker"),"New Subtask");
75  m_ui->toolBar->addAction(KIcon("media-playback-start"),"Start");
76  m_ui->toolBar->addAction(KIcon("media-playback-stop"),"Stop");
77  m_ui->toolBar->addAction(KIcon("edit-delete"), "Delete");
78  m_ui->toolBar->addAction(KIcon("document-properties"),"Edit");
79  setWindowFlags( windowFlags() | Qt::WindowContextHelpButtonHint );
80 /*
81 
82  // connections
83  connect( m_part->widget(), SIGNAL(statusBarTextChangeRequested(QString)),
84  this, SLOT(setStatusBar(QString)) );
85  connect( m_part->widget(), SIGNAL(setCaption(QString)),
86  this, SLOT(slotSetCaption(QString)) );
87  loadGeometry();
88 
89  // Setup context menu request handling
90  connect( m_part->widget(),
91  SIGNAL(contextMenuRequested(QPoint)),
92  this,
93  SLOT(taskViewCustomContextMenuRequested(QPoint)) );
94 
95  _tray = new TrayIcon( this );
96 
97  connect( _tray, SIGNAL(quitSelected()), m_part->widget(), SLOT(quit()) );
98 
99  connect( m_part->widget(), SIGNAL(timersActive()), _tray, SLOT(startClock()) );
100  connect( m_part->widget(), SIGNAL(timersInactive()), _tray, SLOT(stopClock()) );
101  connect( m_part->widget(), SIGNAL(tasksChanged(QList<Task*>)),
102  _tray, SLOT(updateToolTip(QList<Task*>)));
103  */
104 }
105 
106 void MainWindow::newtask()
107 {
108  ((TaskView*) m_ui->treeWidget)->newTask();
109 }
110 
111 void MainWindow::showSettingsDialog()
112 {
113  kDebug(5970) << "Entering function";
114  /* show main window b/c if this method was started from tray icon and the window
115  is not visible the application quits after accepting the settings dialog.
116  */
117  window()->show();
118  KTimeTrackerConfigDialog *dialog = new KTimeTrackerConfigDialog( i18n( "Settings" ), this);
119  dialog->exec();
120  m_ui->ktreewidgetsearchline->setHidden(KTimeTrackerSettings::configPDA());
121  ((TaskView*) m_ui->treeWidget)->reconfigure();
122  delete dialog;
123 }
124 
125 void MainWindow::setupActions()
126 {
127  configureAction = new KAction(this);
128  configureAction->setText(i18n("Configure KTimeTracker..."));
129  //actionCollection()->addAction("configure_ktimetracker", configureAction);
130 }
131 
132 void MainWindow::setStatusBar(const QString& qs)
133 {
134  statusBar()->showMessage(i18n(qs.toUtf8()));
135 }
136 
137 MainWindow::~MainWindow()
138 {
139  kDebug(5970) << "MainWindow::~MainWindows: Quitting ktimetracker.";
140  saveGeometry();
141 }
142 
143 void MainWindow::keyBindings()
144 {
145  //KShortcutsDialog::configure( actionCollection(), KShortcutsEditor::LetterShortcutsAllowed, this );
146 }
147 
148 void MainWindow::makeMenus()
149 {
150  //mainWidget->setupActions( actionCollection() );
151  //actionKeyBindings = KStandardAction::keyBindings( this, SLOT(keyBindings()),
152  // actionCollection() );
153  //setupGUI();
154  actionKeyBindings->setToolTip( i18n( "Configure key bindings" ) );
155  actionKeyBindings->setWhatsThis( i18n( "This will let you configure key"
156  "bindings which are specific to ktimetracker" ) );
157 }
158 
159 void MainWindow::loadGeometry()
160 {
161  // if (initialGeometrySet()) setAutoSaveSettings();
162  //else
163  {
164  KConfigGroup config = KGlobal::config()->group( QString::fromLatin1("Main Window Geometry") );
165  int w = config.readEntry( QString::fromLatin1("Width"), 100 );
166  int h = config.readEntry( QString::fromLatin1("Height"), 100 );
167  w = qMax( w, sizeHint().width() );
168  h = qMax( h, sizeHint().height() );
169  resize(w, h);
170  }
171 }
172 
173 
174 void MainWindow::saveGeometry()
175 {
176  KConfigGroup config = KGlobal::config()->group( QString::fromLatin1("Main Window Geometry") );
177  config.writeEntry( QString::fromLatin1("Width"), width());
178  config.writeEntry( QString::fromLatin1("Height"), height());
179  config.sync();
180 }
181 
182 void MainWindow::on_actionConfigure_ktimetracker_triggered()
183 {
184  showSettingsDialog();
185 }
186 
187 void MainWindow::on_actionQuit_triggered()
188 {
189  close();
190 }
191 
192 #include "mainwindow.moc"
timetrackerwidget.h
MainWindow::on_actionConfigure_ktimetracker_triggered
void on_actionConfigure_ktimetracker_triggered()
Definition: new/mainwindow.cpp:182
MainWindow::keyBindings
void keyBindings()
Definition: mainwindow.cpp:164
MainWindow::newtask
void newtask()
Definition: new/mainwindow.cpp:106
MainWindow::on_actionQuit_triggered
void on_actionQuit_triggered()
Definition: new/mainwindow.cpp:187
taskview.h
MainWindow::showSettingsDialog
void showSettingsDialog()
Definition: new/mainwindow.cpp:111
ktimetracker.h
tray.h
MainWindow::setStatusBar
void setStatusBar(const QString &)
Definition: mainwindow.cpp:153
task.h
timekard.h
QMainWindow
MainWindow::saveGeometry
void saveGeometry()
Definition: mainwindow.cpp:195
MainWindow::~MainWindow
virtual ~MainWindow()
Definition: mainwindow.cpp:158
ktimetrackerutility.h
MainWindow::loadGeometry
void loadGeometry()
Definition: mainwindow.cpp:180
MainWindow::MainWindow
MainWindow(const QString &icsfile="")
Definition: mainwindow.cpp:55
KTimeTrackerSettings::configPDA
static bool configPDA()
Get configPDA.
Definition: ktimetracker.h:335
icsfile
QString icsfile(const KCmdLineArgs *args)
Definition: main.cpp:51
mainwindow.h
KTimeTrackerConfigDialog
Definition: ktimetrackerconfigdialog.h:28
TaskView
Container and interface for the tasks.
Definition: taskview.h:50
MainWindow
Main window to tie the application together.
Definition: mainwindow.h:43
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:55:10 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

ktimetracker

Skip menu "ktimetracker"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal