Skip to content

Commit

Permalink
Added icons for buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandruIstrate committed Jul 21, 2018
1 parent d8e76ac commit e4d7811
Show file tree
Hide file tree
Showing 59 changed files with 398 additions and 161 deletions.
3 changes: 2 additions & 1 deletion ExeQt/TrayIcon.pro
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ SOURCES += \
networkmessage.cpp \
actionreference.cpp \
clientinfodialog.cpp \
settingsregistry.cpp
settingsregistry.cpp \
common.cpp

HEADERS += \
mainwidget.h \
Expand Down
8 changes: 8 additions & 0 deletions ExeQt/actionitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,18 @@ void ActionItem::setupSignalsAndSlots()

void ActionItem::setupUI()
{
setupDialogButtons();

setupActions();
setAction(Action::Type::COMMAND);
}

void ActionItem::setupDialogButtons()
{
ui->buttonBox->button(QDialogButtonBox::StandardButton::Ok)->setIcon(QIcon(":/assets/images/button-icons/ok.png"));
ui->buttonBox->button(QDialogButtonBox::StandardButton::Cancel)->setIcon(QIcon(":/assets/images/button-icons/cancel.png"));
}

void ActionItem::setupActions()
{
addComboAction(Action::Type::COMMAND);
Expand Down
1 change: 1 addition & 0 deletions ExeQt/actionitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class ActionItem : public QDialog, public Saveable
private:
void setupSignalsAndSlots();
void setupUI();
void setupDialogButtons();

void setupActions();
void addComboAction(Action::Type);
Expand Down
3 changes: 3 additions & 0 deletions ExeQt/actionitem.ui
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
<property name="centerButtons">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
Expand Down
54 changes: 17 additions & 37 deletions ExeQt/actiontab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@

#include <QDebug>
#include <QListWidgetItem>
#include <QMessageBox>

#include "commandaction.h"
#include "menuaction.h"
#include "appicon.h"
#include "addgroupdialog.h"
#include "networkmanager.h"
#include "settingsregistry.h"

#define NAME_PROPERTY "name"
#define ICON_PROPERTY "icon"
Expand Down Expand Up @@ -63,38 +65,6 @@ bool ActionTab::checkBundle(const Bundle& bundle) const
return true;
}

//void ActionTab::readProperties(Bundle& bundle)
//{
//// if (!checkBundle(bundle))
//// return;

// m_Name = bundle.get(NAME_PROPERTY);
// m_Icon = AddGroupDialog::getIconByName(bundle.get(ICON_PROPERTY));
// m_TrayIcon->setIcon(m_Icon.icon);

// for (int i = 0; i < bundle.getChildrenCount(); ++i)
// {
// ActionItem* action = new ActionItem(this);
// action->readProperties(bundle.childAt(i));

// addAction(action);
// }
//}

//void ActionTab::writeProperties(Bundle& bundle)
//{
// bundle.add(NAME_PROPERTY, m_Name);
// bundle.add(ICON_PROPERTY, m_Icon.name);

// for (ActionItem* item : m_ActionItems)
// {
// Bundle child(item->getTagName());
// item->writeProperties(child);

// bundle.addChild(child);
// }
//}

void ActionTab::readProperties(Bundle& bundle)
{
// if (!checkBundle(bundle))
Expand Down Expand Up @@ -132,6 +102,16 @@ void ActionTab::removeTrayIcon()
m_TrayIcon->setVisible(false);
}

bool ActionTab::checkDelete()
{
if (!SettingsRegistry::instance()->get(Settings::CONFIRM_DELETE).toBool())
return true;

QMessageBox dialog(QMessageBox::Icon::Question, tr("Remove Action"),
tr("Are you sure you want to remove this action?"), QMessageBox::Yes | QMessageBox::No, this);
return dialog.exec() == QMessageBox::Yes;
}

void ActionTab::setupActions()
{
m_AddAction = new QAction(tr("Add"), this);
Expand Down Expand Up @@ -244,8 +224,10 @@ void ActionTab::onActionRemove()
if (line == -1)
return;

ActionItem* action = m_ActionItems[line];
removeAction(action);
if (!checkDelete())
return;

removeAction(m_ActionItems[line]);

NetworkManager::instance()->requestActionUpdate();
}
Expand All @@ -256,9 +238,7 @@ void ActionTab::onActionEdit()
if (line == -1)
return;

ActionItem* action = m_ActionItems[line];
action->exec();

m_ActionItems[line]->exec();
updateActions();

NetworkManager::instance()->requestActionUpdate();
Expand Down
2 changes: 2 additions & 0 deletions ExeQt/actiontab.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ class ActionTab : public QWidget, public Saveable

void removeTrayIcon();

bool checkDelete();

private:
void setupActions();
void setupSignalsAndSlots();
Expand Down
16 changes: 15 additions & 1 deletion ExeQt/actiontab.ui
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,40 @@
<property name="text">
<string>Add</string>
</property>
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/assets/images/button-icons/add.png</normaloff>:/assets/images/button-icons/add.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnRemove">
<property name="text">
<string>Remove</string>
</property>
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/assets/images/button-icons/remove.png</normaloff>:/assets/images/button-icons/remove.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnEdit">
<property name="text">
<string>Edit</string>
</property>
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/assets/images/button-icons/edit.png</normaloff>:/assets/images/button-icons/edit.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<resources>
<include location="resources.qrc"/>
</resources>
<connections/>
</ui>
12 changes: 10 additions & 2 deletions ExeQt/addgroupdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "ui_addgroupdialog.h"

#include <QDebug>
#include <QPushButton>

#define IMAGE_ASSET_RES ":/assets/images/group-icons/512"

Expand All @@ -22,7 +23,7 @@ AddGroupDialog::AddGroupDialog(QWidget* parent) :
ui(new Ui::AddGroupDialog)
{
ui->setupUi(this);
initUI();
setupUI();
}

AddGroupDialog::AddGroupDialog(ActionTab* tab) : AddGroupDialog { (QWidget*) tab }
Expand Down Expand Up @@ -77,11 +78,18 @@ AppIcon AddGroupDialog::getIconByName(const QString& name)
return AppIcon(s_Icons[0], name);
}

void AddGroupDialog::initUI()
void AddGroupDialog::setupUI()
{
setupDialogButtons();
setupIcons();
}

void AddGroupDialog::setupDialogButtons()
{
ui->buttonBox->button(QDialogButtonBox::StandardButton::Ok)->setIcon(QIcon(":/assets/images/button-icons/ok.png"));
ui->buttonBox->button(QDialogButtonBox::StandardButton::Cancel)->setIcon(QIcon(":/assets/images/button-icons/cancel.png"));
}

void AddGroupDialog::addIcon(const QIcon& icon, const QString& name)
{
ui->cmbIcon->addItem(icon, name);
Expand Down
3 changes: 2 additions & 1 deletion ExeQt/addgroupdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ class AddGroupDialog : public QDialog
static void addIcon(const QIcon&);

private:
void initUI();
void setupUI();
void setupDialogButtons();

void addIcon(const QIcon& icon, const QString& name);
void setupIcons();
Expand Down
8 changes: 7 additions & 1 deletion ExeQt/addtab.ui
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
<property name="text">
<string>Add</string>
</property>
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/assets/images/button-icons/add.png</normaloff>:/assets/images/button-icons/add.png</iconset>
</property>
</widget>
</item>
</layout>
Expand Down Expand Up @@ -86,6 +90,8 @@
</item>
</layout>
</widget>
<resources/>
<resources>
<include location="resources.qrc"/>
</resources>
<connections/>
</ui>
8 changes: 7 additions & 1 deletion ExeQt/applicationaction.ui
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
<property name="text">
<string>Browse...</string>
</property>
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/assets/images/button-icons/browse.png</normaloff>:/assets/images/button-icons/browse.png</iconset>
</property>
</widget>
</item>
</layout>
Expand All @@ -50,6 +54,8 @@
</item>
</layout>
</widget>
<resources/>
<resources>
<include location="resources.qrc"/>
</resources>
<connections/>
</ui>
Binary file added ExeQt/assets/images/button-icons/add.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ExeQt/assets/images/button-icons/arrow-down.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ExeQt/assets/images/button-icons/arrow-up.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ExeQt/assets/images/button-icons/broadcast.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ExeQt/assets/images/button-icons/browse.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ExeQt/assets/images/button-icons/cancel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ExeQt/assets/images/button-icons/cloud.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ExeQt/assets/images/button-icons/configure.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ExeQt/assets/images/button-icons/connect.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ExeQt/assets/images/button-icons/disconnect.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ExeQt/assets/images/button-icons/edit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ExeQt/assets/images/button-icons/info.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ExeQt/assets/images/button-icons/login.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ExeQt/assets/images/button-icons/ok.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ExeQt/assets/images/button-icons/remove.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ExeQt/assets/images/button-icons/run.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ExeQt/assets/images/button-icons/settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ExeQt/assets/images/button-icons/start.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 15 additions & 1 deletion ExeQt/authconnecttab.ui
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,21 @@
<property name="text">
<string>Get Info</string>
</property>
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/assets/images/button-icons/info.png</normaloff>:/assets/images/button-icons/info.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnConnect">
<property name="text">
<string>Connect</string>
</property>
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/assets/images/button-icons/connect.png</normaloff>:/assets/images/button-icons/connect.png</iconset>
</property>
</widget>
</item>
</layout>
Expand All @@ -55,6 +63,10 @@
<property name="text">
<string>Broadcast</string>
</property>
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/assets/images/button-icons/broadcast.png</normaloff>:/assets/images/button-icons/broadcast.png</iconset>
</property>
</widget>
</item>
<item>
Expand All @@ -72,6 +84,8 @@
</item>
</layout>
</widget>
<resources/>
<resources>
<include location="resources.qrc"/>
</resources>
<connections/>
</ui>
13 changes: 6 additions & 7 deletions ExeQt/authmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ void AuthManager::parseLoginResponse(const QString& response)
QJsonDocument doc(QJsonDocument::fromJson(response.toUtf8()));

QJsonObject jsonObj = doc.object();
int flag = jsonObj[Constants::JSON_PROPERTY_FLAG].toInt();
QString message = jsonObj[Constants::JSON_PROPERTY_MESSSAGE].toString();
int flag = jsonObj.value(Constants::JSON_PROPERTY_FLAG).toInt();
QString message = jsonObj.value(Constants::JSON_PROPERTY_MESSSAGE).toString();

if (flag == 0)
if (flag == Constants::FLAG_OK)
{
m_Token = message;
m_IsAuth = true;
Expand All @@ -94,7 +94,7 @@ Bundle getActionBundle(const QString& saveFile)

if (mw) // If it's not null, then it means we are accessing this trough the main app and not from the start page
{
Bundle result;
Bundle result(mw->getTagName());
mw->writeProperties(result);

return result;
Expand All @@ -108,15 +108,14 @@ QString AuthManager::parseSyncActions(const QString& jsonText)
QJsonDocument doc(QJsonDocument::fromJson(jsonText.toUtf8()));

QJsonObject jsonObj = doc.object();
int flag = jsonObj[Constants::JSON_PROPERTY_FLAG].toInt();
QString message = jsonObj[Constants::JSON_PROPERTY_MESSSAGE].toString();
int flag = jsonObj.value(Constants::JSON_PROPERTY_FLAG).toInt();
QString message = jsonObj.value(Constants::JSON_PROPERTY_MESSSAGE).toString();

if (flag == Constants::FLAG_OK)
{
const QString SAVE_FILE = Common::getSaveFilePath();

Bundle webBundle = Bundle::fromXML(message);
// Bundle localBundle = Bundle::fromFile(SAVE_FILE);
Bundle localBundle = getActionBundle(SAVE_FILE);

Bundle merged = Bundle::mergeBundles(webBundle, localBundle);
Expand Down
1 change: 0 additions & 1 deletion ExeQt/authmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ class AuthManager : public QObject
void authenticate(const QString& userName, const QString& password);
void syncActions();

public:
inline static AuthManager* instance() { return s_Instance; }

static void init();
Expand Down
4 changes: 4 additions & 0 deletions ExeQt/bundle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ Bundle Bundle::mergeBundles(const Bundle& bundle1, const Bundle& bundle2)

for (const Bundle& bundle : bundle2.getChildren())
{
// qDebug() << "Bundle 2: " << bundle.toText();

if (!result.hasChild(bundle))
{
result.addChild(bundle);
Expand All @@ -207,10 +209,12 @@ Bundle Bundle::mergeBundles(const Bundle& bundle1, const Bundle& bundle2)
for (int i = 0; i < result.getChildrenCount(); ++i)
{
const Bundle& resultBundle = result.childAt(i);
// qDebug() << "Bundle 1: " << resultBundle.toText();

if (bundle == resultBundle)
{
result.setChildAt(i, mergeBundles(resultBundle, bundle));
break;
}
}
}
Expand Down
Loading

0 comments on commit e4d7811

Please sign in to comment.