summaryrefslogtreecommitdiff
path: root/src/pmtime/pmtime.cpp
blob: 3c586f40bab016a999dec88ffb02ce614c50f370 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
 * Copyright (c) 2014, Red Hat.
 * 
 * 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 2 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.
 */
#include "pmtime.h"
#include <QtCore/QUrl>
#include <QtCore/QLibraryInfo>
#include <QtGui/QDesktopServices>
#include <QtGui/QWhatsThis>
#include <QtGui/QMessageBox>
#include <QtGui/QCloseEvent>
#include "console.h"
#include "aboutdialog.h"
#include "seealsodialog.h"
#include <pcp/pmapi.h>
#include <pcp/impl.h>

PmTime::PmTime() : QMainWindow(NULL)
{
}

void PmTime::helpAbout()
{
    AboutDialog about(this);
    about.exec();
}

void PmTime::helpAboutQt()
{
    QApplication::aboutQt();
}

void PmTime::helpSeeAlso()
{
    SeeAlsoDialog about(this);
    about.exec();
}

void PmTime::whatsThis()
{
    QWhatsThis::enterWhatsThisMode();
}

void PmTime::helpManual()
{
    bool ok;
    QString documents("file://");
    QString separator = QString(__pmPathSeparator());
    documents.append(pmGetConfig("PCP_HTML_DIR"));
    documents.append(separator).append("timecontrol.html");
    ok = QDesktopServices::openUrl(QUrl(documents, QUrl::TolerantMode));
    if (!ok) {
        documents.prepend("Failed to open:\n");
        QMessageBox::warning(this, pmProgname, documents);
    }
}

void PmTime::hideWindow()
{
    if (isVisible())
	hide();
    else {
	show();
	raise();
    }
}

void PmTime::popup(bool hello_popetts)
{
    if (!hello_popetts)
	hide();
    else {
	show();
	raise();
    }
}

void PmTime::closeEvent(QCloseEvent *ce)
{
    hide();
    ce->ignore();
}

void PmTime::showConsole()
{
    console->show();
}