41
41
static const QString DEFS_URL = " https://raw.githubusercontent.com/OpenBangla/OpenBangla-Keyboard/master/UPDATES.json" ;
42
42
43
43
TopBar::TopBar (bool darkIcon, QWidget *parent) :
44
- QMainWindow(parent),
45
- ui(new Ui::TopBar) {
44
+ QMainWindow(parent),
45
+ ui(new Ui::TopBar) {
46
46
ui->setupUi (this );
47
47
48
48
gLayout = new Layout ();
@@ -86,7 +86,7 @@ TopBar::TopBar(bool darkIcon, QWidget *parent) :
86
86
// Update the counter to show only the message for the first three times
87
87
gSettings ->setTrayInfoCount (count + 1 );
88
88
}
89
-
89
+
90
90
#ifndef NO_UPDATE_CHECK
91
91
updater = QSimpleUpdater::getInstance ();
92
92
@@ -115,7 +115,7 @@ void TopBar::SetupTopBar() {
115
115
if (gSettings ->getTopBarWindowPosition () == QPoint (0 , 0 )) {
116
116
int width = this ->frameGeometry ().width ();
117
117
int height = this ->frameGeometry ().height ();
118
-
118
+
119
119
QApplication *app = (QApplication *) QApplication::instance ();
120
120
QScreen *screen = app->primaryScreen ();
121
121
@@ -214,7 +214,7 @@ void TopBar::SetupTrayIcon() {
214
214
gSettings ->getTopBarVisibility () ? " Hide the TopBar" : " Show the TopBar" ,
215
215
this
216
216
);
217
-
217
+
218
218
connect (trayTopBarVisibility, &QAction::triggered, [&]() {
219
219
if (this ->isVisible ()) {
220
220
this ->setVisible (false );
@@ -236,7 +236,7 @@ void TopBar::SetupTrayIcon() {
236
236
trayMenu->addSeparator ();
237
237
trayMenu->addAction (trayTopBarVisibility);
238
238
trayMenu->addAction (trayQuit);
239
-
239
+
240
240
tray->setContextMenu (trayMenu);
241
241
tray->setVisible (true );
242
242
}
@@ -293,9 +293,9 @@ void TopBar::layoutMenuLayouts_clicked() {
293
293
294
294
void TopBar::layoutMenuInstall_clicked () {
295
295
QString fileName = QFileDialog::getOpenFileName (Q_NULLPTR, " Select Keyboard Layout" , QDir::homePath (),
296
- " Avro Keyboard 5 Keyboard Layout (*.avrolayout)" );
296
+ " All Supported Layouts (*.avrolayout *.json);; Avro Keyboard 5 Keyboard Layout (*.avrolayout);;OpenBangla Keyboard Layout (*.json )" );
297
297
LayoutConverter conv;
298
- if (fileName.contains (" .avrolayout" ) && fileName != " " ) {
298
+ if (fileName.endsWith (" .avrolayout" )) {
299
299
ConversionResult res = conv.convertAvroLayout (fileName);
300
300
switch (res) {
301
301
case Ok:
@@ -317,6 +317,26 @@ void TopBar::layoutMenuInstall_clicked() {
317
317
QMessageBox::Ok);
318
318
break ;
319
319
}
320
+ } else if (fileName.endsWith (" .json" )) {
321
+ ConversionResult res = conv.saveLayout (fileName);
322
+ switch (res) {
323
+ case Ok:
324
+ QMessageBox::information (Q_NULLPTR, " OpenBangla Keyboard" , " Layout Installed Successfully" ,
325
+ QMessageBox::Ok);
326
+ break ;
327
+ case UnsupportedLayout:
328
+ QMessageBox::critical (Q_NULLPTR, " OpenBangla Keyboard" , " Unsupported Layout file!" ,
329
+ QMessageBox::Ok);
330
+ break ;
331
+ case OpenError:
332
+ QMessageBox::critical (Q_NULLPTR, " OpenBangla Keyboard" ,
333
+ " An error occurred while opening the layout file!" , QMessageBox::Ok);
334
+ break ;
335
+ case SaveError:
336
+ QMessageBox::critical (Q_NULLPTR, " OpenBangla Keyboard" , " Error occurred while saving the file!" ,
337
+ QMessageBox::Ok);
338
+ break ;
339
+ }
320
340
}
321
341
RefreshLayouts ();
322
342
}
0 commit comments