summaryrefslogtreecommitdiff
path: root/src/main-view/WelcomeScreen.cpp
diff options
context:
space:
mode:
authorJedidiah Barber <contact@jedbarber.id.au>2021-07-14 11:49:10 +1200
committerJedidiah Barber <contact@jedbarber.id.au>2021-07-14 11:49:10 +1200
commitd24f813f3f2a05c112e803e4256b53535895fc98 (patch)
tree601e6ae9a1cd44bcfdcf91739a5ca36aedd827c9 /src/main-view/WelcomeScreen.cpp
Initial mirror commitHEADmaster
Diffstat (limited to 'src/main-view/WelcomeScreen.cpp')
-rw-r--r--src/main-view/WelcomeScreen.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/main-view/WelcomeScreen.cpp b/src/main-view/WelcomeScreen.cpp
new file mode 100644
index 0000000..806a57a
--- /dev/null
+++ b/src/main-view/WelcomeScreen.cpp
@@ -0,0 +1,51 @@
+#include "WelcomeScreen.h"
+
+WelcomeScreen::WelcomeScreen(QWidget* parent):
+ QWidget(parent)
+{
+ QPushButton* newButton = createWelcomeButton("filenew",
+ tr("Create new dictionary"), SLOT(newFile()));
+ QPushButton* openButton = createWelcomeButton("fileopen",
+ tr("Open existing dictionary"), SLOT(openFileWithDialog()));
+ QPushButton* openExampleButton = createWelcomeButton("",
+ tr("Open online dictionaries"), SLOT(openOnlineDictionaries()));
+ QPushButton* importButton = createWelcomeButton("",
+ tr("Import from CSV file"), SLOT(importFromCsv()));
+ recentFilesButton = createWelcomeButton("",
+ tr("Recent dictionaries"), NULL);
+
+ QVBoxLayout* buttonsLt = new QVBoxLayout;
+ buttonsLt->addWidget(newButton);
+ buttonsLt->addWidget(openButton);
+ buttonsLt->addWidget(openExampleButton);
+ buttonsLt->addWidget(importButton);
+ buttonsLt->addWidget(recentFilesButton);
+
+ QGridLayout* paddingLt = new QGridLayout;
+ paddingLt->addLayout(buttonsLt, 1, 1);
+ setLayout(paddingLt);
+}
+
+QPushButton* WelcomeScreen::createWelcomeButton(const QString& iconName,
+ const QString& text, const char* slot)
+{
+ static const QSize ButtonSize(350, 50);
+ QPushButton* button = new QPushButton(QIcon(QString(":/images/%1.png").
+ arg(iconName)), text);
+ button->setMaximumSize(ButtonSize);
+ if(slot)
+ connect(button, SIGNAL(clicked()), parentWidget(), slot);
+ return button;
+}
+
+void WelcomeScreen::updateRecentFilesButton()
+{
+ recentFilesButton->setEnabled(recentFilesButton->menu() &&
+ !recentFilesButton->menu()->actions().isEmpty());
+}
+
+void WelcomeScreen::setRecentFilesMenu(QMenu* menu)
+{
+ recentFilesButton->setMenu(menu);
+ updateRecentFilesButton();
+}