-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmain.cpp
More file actions
79 lines (71 loc) · 2.18 KB
/
main.cpp
File metadata and controls
79 lines (71 loc) · 2.18 KB
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
#include <KApplication>
#include <KAboutData>
#include <KCmdLineArgs>
#include <KLocale>
#include <KMainWindow>
#include <KConfigGroup>
#include <KProcess>
//#include <KMessageBox>
#include <iostream>
const char* firefoxbin_path = "/usr/lib64/firefox/firefox-bin";
class MainWindow : public KMainWindow
{
public:
MainWindow(QString profile = "", QWidget *parent=0);
protected:
void saveProperties(KConfigGroup& );
void readProperties(const KConfigGroup& );
private:
QString firefoxprofile;
KProcess p;
};
MainWindow::MainWindow(QString profile, QWidget *parent) : KMainWindow(parent)
{
setGeometry(100,100,200,100);
if (profile != "") {
firefoxprofile = profile;
QStringList createProfileCommand;
createProfileCommand << firefoxbin_path << "-CreateProfile" << firefoxprofile << "-no-remote";
KProcess::execute(createProfileCommand);
p << firefoxbin_path << "-P" << firefoxprofile << "-no-remote";
p.start();
} else {
firefoxprofile = "";
}
}
void MainWindow::saveProperties(KConfigGroup& conf) {
conf.writeEntry("ffProfile", firefoxprofile);
p.kill();
}
void MainWindow::readProperties(const KConfigGroup& conf) {
firefoxprofile = conf.readEntry("ffProfile", QString());
p << firefoxbin_path << "-P" << firefoxprofile << "-no-remote";
p.start();
}
int main (int argc, char *argv[])
{
KAboutData aboutData( "activityfox", 0,
ki18n("ActivityFox"), "0.1",
ki18n("Help Firefox work with KDE activities."),
KAboutData::License_GPL,
ki18n("Copyright (c) 2012 Yuen Hoe (Jason moofang)") );
KCmdLineArgs::init( argc, argv, &aboutData );
KCmdLineOptions options;
options.add("+profilename", ki18n("Firefox profile name"));
KCmdLineArgs::addCmdLineOptions(options);
if (argc <= 1) {
std::cout << "Please specify firefox profile name" << std::endl;
return 0;
}
KApplication app;
if ( app.isSessionRestored() ) {
kRestoreMainWindows< MainWindow >();
} else {
// create default application as usual
// example:
MainWindow * window = new MainWindow(argv[1]);
window->setObjectName("MyWindow#");
window->show();
}
return app.exec();
}