-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
58 lines (51 loc) · 2.04 KB
/
main.cpp
File metadata and controls
58 lines (51 loc) · 2.04 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
#include "mainwindow.h"
#include <QApplication>
#include <QLockFile>
#include <QStandardPaths>
#include <QDir>
#include <QColor>
#include <QMessageBox>
#include <QObject>
#include <QPalette>
#include <QStyleFactory>
int main(int argc, char *argv[]) {
QApplication a(argc, argv);
a.setApplicationName("VoiceToKeys");
QStyle *fusionStyle = QStyleFactory::create("Fusion");
if (fusionStyle) {
a.setStyle(fusionStyle);
}
QPalette palette = a.palette();
palette.setColor(QPalette::Window, QColor(240, 240, 240));
palette.setColor(QPalette::WindowText, QColor(0, 0, 0));
palette.setColor(QPalette::Base, QColor(255, 255, 255));
palette.setColor(QPalette::AlternateBase, QColor(245, 245, 245));
palette.setColor(QPalette::ToolTipBase, QColor(255, 255, 225));
palette.setColor(QPalette::ToolTipText, QColor(0, 0, 0));
palette.setColor(QPalette::Text, QColor(0, 0, 0));
palette.setColor(QPalette::Button, QColor(240, 240, 240));
palette.setColor(QPalette::ButtonText, QColor(0, 0, 0));
palette.setColor(QPalette::BrightText, QColor(255, 0, 0));
palette.setColor(QPalette::Highlight, QColor(0, 120, 215));
palette.setColor(QPalette::HighlightedText, QColor(255, 255, 255));
a.setPalette(palette);
a.setStyleSheet(
"QToolTip { color: #000000; background-color: #ffffe1; border: 1px solid #b5b5b5; }"
"QMenu::item:selected { background-color: #0078d7; color: #ffffff; }"
);
// Ensure single instance using QLockFile
QString tmpDir = QStandardPaths::writableLocation(QStandardPaths::TempLocation);
QDir().mkpath(tmpDir);
QLockFile lockFile(tmpDir + QDir::separator() + "VoiceToKeys.lock");
lockFile.setStaleLockTime(0);
if (!lockFile.tryLock()) {
QMessageBox::warning(nullptr,
QObject::tr("VoiceToKeys"),
QObject::tr("Another instance of VoiceToKeys is already running."));
return 0;
}
a.setQuitOnLastWindowClosed(false);
MainWindow w;
w.hide();
return a.exec();
}